{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "layout-spacing",
  "title": "Layout spacing",
  "description": "Shared layout vocabulary: gap, align, and justify scales, breakpoints, and the Responsive<T> helper.",
  "files": [
    {
      "path": "lib/spacing.ts",
      "content": "// Shared layout vocabulary for every layout primitive.\n//\n// Tailwind only generates classes it can find verbatim in source files, so every\n// responsive class below is written out in full. Do not build class names with\n// template strings.\n\nconst breakpoints = [\"base\", \"sm\", \"md\", \"lg\", \"xl\", \"2xl\"] as const;\n\n/** Tailwind's default breakpoints. `base` applies at every width. */\ntype Breakpoint = (typeof breakpoints)[number];\n\n/** A single value, or a partial map from breakpoint to value (mobile first). */\ntype Responsive<T> = T | Partial<Record<Breakpoint, T>>;\n\n/** One class per value, per breakpoint. */\ntype ResponsiveVariants<T extends PropertyKey> = Record<Breakpoint, Record<T, string>>;\n\nfunction isResponsiveObject<T>(value: Responsive<T>): value is Partial<Record<Breakpoint, T>> {\n  return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Resolves a scalar or responsive value to Tailwind classes, ordered from the\n * smallest breakpoint to the largest. Unknown keys and undefined values are skipped.\n */\nfunction responsiveClasses<T extends PropertyKey>(\n  value: Responsive<T> | undefined,\n  variants: ResponsiveVariants<T>,\n): string[] {\n  if (value === undefined) return [];\n  if (!isResponsiveObject(value)) return [variants.base[value]];\n\n  const classes: string[] = [];\n  for (const breakpoint of breakpoints) {\n    const entry = value[breakpoint];\n    if (entry !== undefined) classes.push(variants[breakpoint][entry]);\n  }\n  return classes;\n}\n\n// ------------------------------------------------------------------\n// Gap\n// ------------------------------------------------------------------\n\n/** Gap on the Tailwind spacing scale (`4` is 1rem). */\ntype Gap = 0 | 1 | 2 | 3 | 4 | 6 | 8 | 12;\n\nconst gapVariants = {\n  base: {\n    0: \"gap-0\",\n    1: \"gap-1\",\n    2: \"gap-2\",\n    3: \"gap-3\",\n    4: \"gap-4\",\n    6: \"gap-6\",\n    8: \"gap-8\",\n    12: \"gap-12\",\n  },\n  sm: {\n    0: \"sm:gap-0\",\n    1: \"sm:gap-1\",\n    2: \"sm:gap-2\",\n    3: \"sm:gap-3\",\n    4: \"sm:gap-4\",\n    6: \"sm:gap-6\",\n    8: \"sm:gap-8\",\n    12: \"sm:gap-12\",\n  },\n  md: {\n    0: \"md:gap-0\",\n    1: \"md:gap-1\",\n    2: \"md:gap-2\",\n    3: \"md:gap-3\",\n    4: \"md:gap-4\",\n    6: \"md:gap-6\",\n    8: \"md:gap-8\",\n    12: \"md:gap-12\",\n  },\n  lg: {\n    0: \"lg:gap-0\",\n    1: \"lg:gap-1\",\n    2: \"lg:gap-2\",\n    3: \"lg:gap-3\",\n    4: \"lg:gap-4\",\n    6: \"lg:gap-6\",\n    8: \"lg:gap-8\",\n    12: \"lg:gap-12\",\n  },\n  xl: {\n    0: \"xl:gap-0\",\n    1: \"xl:gap-1\",\n    2: \"xl:gap-2\",\n    3: \"xl:gap-3\",\n    4: \"xl:gap-4\",\n    6: \"xl:gap-6\",\n    8: \"xl:gap-8\",\n    12: \"xl:gap-12\",\n  },\n  \"2xl\": {\n    0: \"2xl:gap-0\",\n    1: \"2xl:gap-1\",\n    2: \"2xl:gap-2\",\n    3: \"2xl:gap-3\",\n    4: \"2xl:gap-4\",\n    6: \"2xl:gap-6\",\n    8: \"2xl:gap-8\",\n    12: \"2xl:gap-12\",\n  },\n} as const satisfies ResponsiveVariants<Gap>;\n\n// ------------------------------------------------------------------\n// Align (cross axis, items-*)\n// ------------------------------------------------------------------\n\ntype Align = \"start\" | \"center\" | \"end\" | \"stretch\" | \"baseline\";\n\nconst alignVariants = {\n  base: {\n    start: \"items-start\",\n    center: \"items-center\",\n    end: \"items-end\",\n    stretch: \"items-stretch\",\n    baseline: \"items-baseline\",\n  },\n  sm: {\n    start: \"sm:items-start\",\n    center: \"sm:items-center\",\n    end: \"sm:items-end\",\n    stretch: \"sm:items-stretch\",\n    baseline: \"sm:items-baseline\",\n  },\n  md: {\n    start: \"md:items-start\",\n    center: \"md:items-center\",\n    end: \"md:items-end\",\n    stretch: \"md:items-stretch\",\n    baseline: \"md:items-baseline\",\n  },\n  lg: {\n    start: \"lg:items-start\",\n    center: \"lg:items-center\",\n    end: \"lg:items-end\",\n    stretch: \"lg:items-stretch\",\n    baseline: \"lg:items-baseline\",\n  },\n  xl: {\n    start: \"xl:items-start\",\n    center: \"xl:items-center\",\n    end: \"xl:items-end\",\n    stretch: \"xl:items-stretch\",\n    baseline: \"xl:items-baseline\",\n  },\n  \"2xl\": {\n    start: \"2xl:items-start\",\n    center: \"2xl:items-center\",\n    end: \"2xl:items-end\",\n    stretch: \"2xl:items-stretch\",\n    baseline: \"2xl:items-baseline\",\n  },\n} as const satisfies ResponsiveVariants<Align>;\n\n// ------------------------------------------------------------------\n// Justify (main axis, justify-*)\n// ------------------------------------------------------------------\n\ntype Justify = \"start\" | \"center\" | \"end\" | \"between\" | \"around\" | \"evenly\";\n\nconst justifyVariants = {\n  base: {\n    start: \"justify-start\",\n    center: \"justify-center\",\n    end: \"justify-end\",\n    between: \"justify-between\",\n    around: \"justify-around\",\n    evenly: \"justify-evenly\",\n  },\n  sm: {\n    start: \"sm:justify-start\",\n    center: \"sm:justify-center\",\n    end: \"sm:justify-end\",\n    between: \"sm:justify-between\",\n    around: \"sm:justify-around\",\n    evenly: \"sm:justify-evenly\",\n  },\n  md: {\n    start: \"md:justify-start\",\n    center: \"md:justify-center\",\n    end: \"md:justify-end\",\n    between: \"md:justify-between\",\n    around: \"md:justify-around\",\n    evenly: \"md:justify-evenly\",\n  },\n  lg: {\n    start: \"lg:justify-start\",\n    center: \"lg:justify-center\",\n    end: \"lg:justify-end\",\n    between: \"lg:justify-between\",\n    around: \"lg:justify-around\",\n    evenly: \"lg:justify-evenly\",\n  },\n  xl: {\n    start: \"xl:justify-start\",\n    center: \"xl:justify-center\",\n    end: \"xl:justify-end\",\n    between: \"xl:justify-between\",\n    around: \"xl:justify-around\",\n    evenly: \"xl:justify-evenly\",\n  },\n  \"2xl\": {\n    start: \"2xl:justify-start\",\n    center: \"2xl:justify-center\",\n    end: \"2xl:justify-end\",\n    between: \"2xl:justify-between\",\n    around: \"2xl:justify-around\",\n    evenly: \"2xl:justify-evenly\",\n  },\n} as const satisfies ResponsiveVariants<Justify>;\n\nexport {\n  breakpoints,\n  responsiveClasses,\n  isResponsiveObject,\n  gapVariants,\n  alignVariants,\n  justifyVariants,\n};\n\nexport type { Breakpoint, Responsive, ResponsiveVariants, Gap, Align, Justify };\n",
      "type": "registry:lib"
    }
  ],
  "type": "registry:lib"
}