{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stack",
  "title": "Stack",
  "description": "Lays its children out top to bottom with an even gap.",
  "registryDependencies": [
    "@ouro/lib-appearance-hints",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-use-dev-messages"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/stack/stack-styles.ts",
      "content": "import { toneFor } from \"@/registry/ouro/lib/ouro/appearance-hints\";\nimport { baseOf } from \"@/registry/ouro/lib/ouro/class-name-check\";\n\nexport {\n  alignWords,\n  gapClasses,\n  justifyClasses,\n  layoutElements,\n  elementReset,\n  checkGap,\n  checkJustify,\n  checkElement,\n  checkFlexClassName,\n  layoutHint,\n  layoutAlignHint,\n};\nexport type { LayoutGap, LayoutJustify, LayoutElement };\n\n// Shared by Stack and Row, apart from the components so each component file exports only\n// components (React Fast Refresh). The export list comes first because the shadcn CLI\n// drops comments before a file's first statement.\n\n/**\n * A gap from the spacing scale: `xs` 4px, `sm` 8px, `md` 16px, `lg` 24px, `xl` 32px.\n *\n * @claim \"A gap from the spacing scale\" registry/ouro/components/ouro/stack/stack.test.tsx verify:fileLine(registry/ouro/components/ouro/stack/stack.test.tsx, /\\[\"xs\",\\s\"4px\"\\],/)\n * @claim \"A gap from the spacing scale\" registry/ouro/components/ouro/stack/stack.test.tsx verify:fileLine(registry/ouro/components/ouro/stack/stack.test.tsx, /\\[\"xl\",\\s\"32px\"\\],/)\n */\ntype LayoutGap = \"none\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\n/** Where the children sit along the main axis; `between` spreads them to both ends. */\ntype LayoutJustify = \"start\" | \"center\" | \"end\" | \"between\";\n\n/** The elements Stack and Row render. */\ntype LayoutElement = \"div\" | \"section\" | \"ul\" | \"ol\" | \"nav\" | \"header\" | \"footer\" | \"main\" | \"aside\" | \"form\" | \"fieldset\";\n\n/**\n * Gap classes, one per step. Literal strings so the app's Tailwind finds them.\n *\n * @internal\n */\nconst gapClasses = { none: \"gap-0\", xs: \"gap-1\", sm: \"gap-2\", md: \"gap-4\", lg: \"gap-6\", xl: \"gap-8\" } as const;\n\n/**\n * Main-axis classes.\n *\n * @internal\n */\nconst justifyClasses = { start: \"justify-start\", center: \"justify-center\", end: \"justify-end\", between: \"justify-between\" } as const;\n\n/**\n * The elements Stack and Row may render, for the dev message.\n *\n * @internal\n */\nconst layoutElements: readonly LayoutElement[] = [\"div\", \"section\", \"ul\", \"ol\", \"nav\", \"header\", \"footer\", \"main\", \"aside\", \"form\", \"fieldset\"];\n\n/**\n * What the browser sets on these elements that a layout primitive must not keep: list\n * bullets and indents, and a fieldset's border, padding and minimum width. The margin is\n * cleared in a sublayer of Tailwind's utilities (`[@layer_ouro-reset]:`), which every plain\n * utility beats whatever its specificity, so a parent's `space-y-4` and the app's own margin\n * class still apply.\n *\n * @internal\n * @claim \"The margin is cleared in a\" registry/ouro/components/ouro/stack/stack.test.tsx verify:testExists(registry/ouro/components/ouro/stack/stack.test.tsx::Stack > passes HTML attributes and a ref through, and lets layout classes win)\n * @claim \"The margin is cleared in a\" registry/ouro/components/ouro/stack/stack.test.tsx verify:fileLine(registry/ouro/components/ouro/stack/stack.test.tsx, /expect\\(getComputedStyle\\(el\\)\\.marginTop\\)\\.toBe\\(\"16px\"\\)/)\n */\nconst elementReset = \"[@layer_ouro-reset]:m-0 p-0 list-none min-w-0 border-0\" as const;\n\nconst names = (values: readonly string[]) => values.map((value) => `\"${value}\"`).join(\", \");\n\n/**\n * A Tailwind spacing number (gap-4) to the nearest named gap.\n *\n * @claim \"A Tailwind spacing number (gap-4) to\" registry/ouro/components/ouro/stack/stack.test.tsx verify:fileLine(registry/ouro/components/ouro/stack/stack.test.tsx, /\\[\"gap\\snumber\",\\s\\{\\sgap:\\s4\\s\\}/)\n */\nfunction nearestGap(value: number): LayoutGap {\n  if (value <= 0) return \"none\";\n  if (value <= 1) return \"xs\";\n  if (value <= 2) return \"sm\";\n  if (value <= 4) return \"md\";\n  if (value <= 6) return \"lg\";\n  return \"xl\";\n}\n\n/**\n * The gap to render and the dev message for one that is not a name: a number (`gap={4}`,\n * Chakra's and MUI's spacing units, which match Tailwind's) points to the nearest name.\n *\n * @internal\n */\nfunction checkGap(component: string, gap: unknown, fallback: LayoutGap): [LayoutGap, readonly [string, string] | false] {\n  if (gap === undefined) return [fallback, false];\n  if (typeof gap === \"string\" && Object.hasOwn(gapClasses, gap)) return [gap as LayoutGap, false];\n  return [\n    fallback,\n    process.env.NODE_ENV !== \"production\"\n      ? [\n          `${typeof gap === \"number\" ? `gap={${gap}}` : `gap=\"${String(gap)}\"`} is not a gap; use a name: ${names(Object.keys(gapClasses))}`,\n          `<${component} gap=\"${typeof gap === \"number\" ? nearestGap(gap) : \"md\"}\">`,\n        ]\n      : /* istanbul ignore next @preserve -- production only */ false,\n  ];\n}\n\n/**\n * Words agents use for a direction, to the logical alignment.\n *\n * @internal\n */\nconst alignWords: Readonly<Record<string, string>> = {\n  left: \"start\",\n  top: \"start\",\n  \"flex-start\": \"start\",\n  right: \"end\",\n  bottom: \"end\",\n  \"flex-end\": \"end\",\n  \"space-between\": \"between\",\n};\n\n/**\n * The value to render from a set of named options and the dev message for one that is\n * not in it: `left`, `top` and `flex-start` point to `start`, and so on.\n *\n * @internal\n */\nfunction checkJustify(component: string, justify: unknown): [LayoutJustify, readonly [string, string] | false] {\n  if (justify === undefined) return [\"start\", false];\n  if (typeof justify === \"string\" && Object.hasOwn(justifyClasses, justify)) return [justify as LayoutJustify, false];\n  return [\n    \"start\",\n    process.env.NODE_ENV !== \"production\"\n      ? [\n          `justify=\"${String(justify)}\" is not a justification; use ${names(Object.keys(justifyClasses))}`,\n          `<${component} justify=\"${alignWords[String(justify)] ?? \"start\"}\">`,\n        ]\n      : /* istanbul ignore next @preserve -- production only */ false,\n  ];\n}\n\n/**\n * The element to render and the dev message for one that is not in the list.\n *\n * @internal\n */\nfunction checkElement(component: string, as: unknown): [LayoutElement, readonly [string, string] | false] {\n  if (as === undefined) return [\"div\", false];\n  if (typeof as === \"string\" && (layoutElements as readonly string[]).includes(as)) return [as as LayoutElement, false];\n  return [\n    \"div\",\n    process.env.NODE_ENV !== \"production\"\n      ? [`as=\"${String(as)}\" is not an element ${component} renders; use ${names(layoutElements)}`, `<${component} as=\"section\">`]\n      : /* istanbul ignore next @preserve -- production only */ false,\n  ];\n}\n\n/**\n * The fix for an appearance class on a layout primitive: a surface is a Card, text\n * styling belongs on the Text or Heading inside. Development only.\n *\n * @internal\n */\nfunction layoutHint(component: string): (token: string) => string {\n  return (token) => {\n    if (/^text-/.test(token) && !/^text-(xs|sm|base|lg|\\d?xl)$/.test(token)) return `<Text tone=\"${toneFor(token)}\"> on the text inside`;\n    if (/^(text|font)-/.test(token)) return \"<Text> or <Heading> on the text inside\";\n    return `<Card> for a surface, or wrap the ${component} in an element of your own`;\n  };\n}\n\n/**\n * The fix for a text alignment class on a layout primitive. Development only.\n *\n * @internal\n */\nfunction layoutAlignHint(component: string, prop: \"align\" | \"justify\"): string {\n  return `<Text align=\"center\"> on the text inside, or <${component} ${prop}=\"center\"> to center the children`;\n}\n\nconst justifyWords: Readonly<Record<string, LayoutJustify>> = {\n  start: \"start\",\n  normal: \"start\",\n  stretch: \"start\",\n  center: \"center\",\n  end: \"end\",\n  between: \"between\",\n  around: \"between\",\n  evenly: \"between\",\n};\n\n/**\n * Dev messages for the flex classes a Stack or Row owns through its props (`gap-3`,\n * `flex-row`, `items-center`, `justify-between`, `flex-wrap`), each with the prop to use.\n * The class still applies, last, so these are messages, not errors. Development only.\n *\n * @internal\n * @claim \"Dev messages for the flex classes\" registry/ouro/components/ouro/stack/stack.test.tsx verify:testExists(registry/ouro/components/ouro/stack/stack.test.tsx::Stack development messages > names each flex class it finds)\n */\nfunction checkFlexClassName(component: \"Stack\" | \"Row\", className: string | undefined, alignments: readonly string[]): (readonly [string, string])[] {\n  const messages: (readonly [string, string])[] = [];\n  if (!className) return messages;\n  for (const token of className.split(/\\s+/)) {\n    const base = baseOf(token);\n    const breakpoint = /^(?:max-)?(sm|md):/.exec(token)?.[1];\n    const gap = /^gap(?:-[xy])?-(.+)$/.exec(base);\n    if (gap) {\n      const step = Number(gap[1]);\n      messages.push([`\"${token}\" sets the gap, which the gap prop owns`, `<${component} gap=\"${Number.isFinite(step) ? nearestGap(step) : \"md\"}\">`]);\n    } else if (base === \"flex-row\" || base === \"flex-col\") {\n      const vertical = base === \"flex-col\";\n      const already = vertical === (component === \"Stack\");\n      const stacks = breakpoint && (component === \"Stack\" ? !vertical : vertical);\n      messages.push([\n        `\"${token}\" sets the direction, and ${component} is ${already ? \"already\" : \"always\"} ${component === \"Stack\" ? \"vertical\" : \"horizontal\"}`,\n        stacks ? `<Row stackBelow=\"${breakpoint}\">` : vertical ? \"<Stack>\" : \"<Row>\",\n      ]);\n    } else if (/^items-/.test(base)) {\n      const value = base.slice(\"items-\".length);\n      messages.push([`\"${token}\" sets the alignment, which the align prop owns`, `<${component} align=\"${alignments.includes(value) ? value : \"start\"}\">`]);\n    } else if (/^justify-(?!items-|self-)/.test(base)) {\n      const value = base.slice(\"justify-\".length);\n      messages.push([`\"${token}\" sets the justification, which the justify prop owns`, `<${component} justify=\"${justifyWords[value] ?? \"start\"}\">`]);\n    } else if (base === \"flex-wrap\" || base === \"flex-wrap-reverse\") {\n      messages.push([\n        component === \"Row\" ? `\"${token}\" wraps the children, which the wrap prop owns` : `\"${token}\" wraps the children, and a Stack is one column`,\n        \"<Row wrap>\",\n      ]);\n    }\n  }\n  return messages;\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/stack/stack-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/stack/stack.tsx",
      "content": "\"use client\";\n\nimport { createElement, type HTMLAttributes, type JSX, type ReactNode, type Ref } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport {\n  alignWords,\n  checkElement,\n  checkFlexClassName,\n  checkGap,\n  checkJustify,\n  elementReset,\n  gapClasses,\n  justifyClasses,\n  layoutAlignHint,\n  layoutHint,\n  type LayoutElement,\n  type LayoutGap,\n  type LayoutJustify,\n} from \"@/registry/ouro/components/ouro/stack/stack-styles\";\n\nexport type { LayoutElement, LayoutGap, LayoutJustify } from \"@/registry/ouro/components/ouro/stack/stack-styles\";\n\n/**\n * Where a Stack's children sit across it: `stretch` makes each as wide as the Stack.\n *\n * @claim \"Where a Stack's children sit across\" registry/ouro/components/ouro/stack/stack.tsx verify:fileLine(registry/ouro/components/ouro/stack/stack.tsx, /stretch:\\s\"items-stretch\"/)\n */\nexport type StackAlign = \"start\" | \"center\" | \"end\" | \"stretch\";\n\n/** The props Stack adds to the HTML attributes it passes through. */\nexport interface StackOwnProps {\n  /**\n   * Space between the children: `xs` 4px, `sm` 8px, `md` 16px, `lg` 24px, `xl` 32px.\n   * @default \"md\"\n   * @claim \"Space between the children: `xs` 4px\" registry/ouro/components/ouro/stack/stack.test.tsx verify:fileLine(registry/ouro/components/ouro/stack/stack.test.tsx, /\\[\"xs\",\\s\"4px\"\\],/)\n   * @claim \"Space between the children: `xs` 4px\" registry/ouro/components/ouro/stack/stack.test.tsx verify:fileLine(registry/ouro/components/ouro/stack/stack.test.tsx, /\\[\"xl\",\\s\"32px\"\\],/)\n   * @claim \"Space between the children: `xs` 4px\" registry/ouro/components/ouro/stack/stack.test.tsx verify:testExists(registry/ouro/components/ouro/stack/stack.test.tsx::Stack > renders a vertical flex <div> with data-ouro and a 16px gap by default)\n   */\n  gap?: LayoutGap | (string & { 'Use \"none\", \"xs\", \"sm\", \"md\", \"lg\" or \"xl\"': never }) | (number & { 'Use a name: gap=\"md\" is 16px': never }) | undefined;\n  /**\n   * Where the children sit across the Stack. `stretch` makes each child full width.\n   * @default \"stretch\"\n   * @claim \"`stretch` makes each child full width\" registry/ouro/components/ouro/stack/stack.tsx verify:fileLine(registry/ouro/components/ouro/stack/stack.tsx, /stretch:\\s\"items-stretch\"/)\n   */\n  align?: StackAlign | (string & { 'Use \"start\", \"center\", \"end\" or \"stretch\": left is \"start\"': never }) | undefined;\n  /**\n   * Where the children sit down the Stack, when it is taller than they are.\n   * @default \"start\"\n   */\n  justify?: LayoutJustify | (string & { 'Use \"start\", \"center\", \"end\" or \"between\"': never }) | undefined;\n  /**\n   * The element to render. A `ul` or `ol` loses its bullets and indent, a `fieldset` its border.\n   * @default \"div\"\n   */\n  as?: LayoutElement | (string & { 'Use div, section, ul, ol, nav, header, footer, main, aside, form or fieldset': never }) | undefined;\n  /**\n   * Layout only: margins, width, grid placement (`mt-4`, `max-w-md`). Appearance classes\n   * warn in development: a Stack has no look; use `Card` for a surface. So do the flex\n   * classes the props own: use `gap`, `align` and `justify`, not `gap-*`, `items-*` or\n   * `justify-*`, and `<Row>`, not `flex-row`.\n   * @claim \"Appearance classes warn in development: a\" registry/ouro/components/ouro/stack/stack.test.tsx verify:testExists(registry/ouro/components/ouro/stack/stack.test.tsx::Stack development messages > names each flex class it finds)\n   */\n  className?: string | undefined;\n  /** The children, laid out top to bottom. */\n  children?: ReactNode;\n  ref?: Ref<HTMLElement> | undefined;\n\n  /** Not a prop. Stack is vertical; for a horizontal layout use `<Row>`. */\n  direction?: { \"Use <Row> for a horizontal layout\": never };\n  /** Not a prop. Ouro UI uses `gap`: `<Stack gap=\"sm\">`. */\n  spacing?: { 'Use <Stack gap=\"sm\">': never };\n  /** Not a prop. Ouro UI uses `align`: `<Stack align=\"center\">`. */\n  alignItems?: { 'Use <Stack align=\"center\">': never };\n  /** Not a prop. Ouro UI uses `justify`: `<Stack justify=\"between\">`. */\n  justifyContent?: { 'Use <Stack justify=\"between\">': never };\n}\n\n/** Props for {@link Stack}: its own props and the HTML attributes it passes through. */\nexport type StackProps = Omit<HTMLAttributes<HTMLElement>, keyof StackOwnProps> & StackOwnProps;\n\nconst alignClasses = { start: \"items-start\", center: \"items-center\", end: \"items-end\", stretch: \"items-stretch\" } as const;\n\n/**\n * Lays its children out top to bottom with an even gap. It is layout only: it\n * replaces the `flex flex-col gap-4` an agent would otherwise write by hand.\n *\n * Use `Row` instead for a horizontal layout, `Card` when the group needs a surface, and\n * `ItemGroup` for a list of rows with media, titles and actions.\n *\n * @group Layout\n * @see https://ui.ouroboros.bot/docs/stack\n *\n * @example\n * <Stack gap=\"sm\">\n *   <Heading level={2}>Ingredients</Heading>\n *   <Text>Two pounds of short ribs.</Text>\n * </Stack>\n * <Stack as=\"ul\" gap=\"xs\">{items.map((item) => <li key={item.id}>{item.name}</li>)}</Stack>\n */\nexport function Stack(props: StackProps): JSX.Element {\n  const { gap: gapProp, align: alignProp, justify: justifyProp, as: asProp, className, children, direction, spacing, alignItems, justifyContent, ...rest } = props;\n  const [gap, gapWarning] = checkGap(\"Stack\", gapProp, \"md\");\n  const [justify, justifyWarning] = checkJustify(\"Stack\", justifyProp);\n  const [element, elementWarning] = checkElement(\"Stack\", asProp);\n  const align = alignProp !== undefined && Object.hasOwn(alignClasses, alignProp) ? (alignProp as StackAlign) : \"stretch\";\n  useAppearanceClassNameCheck(\n    \"Stack\",\n    className,\n    process.env.NODE_ENV !== \"production\" ? layoutHint(\"Stack\") : /* istanbul ignore next @preserve -- production only */ \"\",\n    process.env.NODE_ENV !== \"production\" ? layoutAlignHint(\"Stack\", \"align\") : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  useDevWarnings(\n    \"Stack\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          gapWarning,\n          justifyWarning,\n          elementWarning,\n          ...checkFlexClassName(\"Stack\", className, Object.keys(alignClasses)),\n          alignProp !== undefined &&\n            align !== alignProp && [\n              `align=\"${String(alignProp)}\" is not an alignment; use \"start\", \"center\", \"end\", \"stretch\"`,\n              `<Stack align=\"${alignWords[String(alignProp)] ?? \"start\"}\">`,\n            ],\n          direction !== undefined && [\n            \"direction is not a prop; Stack is always vertical\",\n            String(direction).startsWith(\"row\") ? \"<Row>\" : \"<Stack>\",\n          ],\n          spacing !== undefined && [\"spacing is not a prop\", '<Stack gap=\"sm\">'],\n          alignItems !== undefined && [\"alignItems is not a prop\", `<Stack align=\"${alignWords[String(alignItems)] ?? String(alignItems)}\">`],\n          justifyContent !== undefined && [\n            \"justifyContent is not a prop\",\n            `<Stack justify=\"${alignWords[String(justifyContent)] ?? String(justifyContent)}\">`,\n          ],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  return createElement(\n    element,\n    {\n      ...rest,\n      \"data-ouro\": \"stack\",\n      className: cn(\"flex flex-col\", elementReset, gapClasses[gap], alignClasses[align], justifyClasses[justify], className),\n    },\n    children,\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/stack/stack.tsx"
    }
  ],
  "docs": "Lays its children out top to bottom with an even gap. Import: import { Stack } from \"@/components/ouro/stack/stack\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: the helpers it imports in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/stack.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}