{"version":3,"sources":["../src/box/config.ts","../src/box/index.tsx"],"names":["cva","spacing","radiusTokens","useTheme","jsx","forwardRef"],"mappings":";;;;;;;;;AAOO,IAAM,SAAA,GAAYA,2BAAI,UAAA,EAAY;AAAA,EACvC,QAAA,EAAU;AAAA,IACR,OAAA,EAAS;AAAA,MACP,IAAA,EAAM,EAAA;AAAA,MACN,OAAA,EAAS,2BAAA;AAAA,MACT,MAAA,EAAS,0BAAA;AAAA,MACT,MAAA,EAAS;AAAA,KACX;AAAA,IACA,OAAA,EAAS;AAAA,MACP,IAAA,EAAM,EAAA;AAAA,MACN,EAAA,EAAI,kBAAA;AAAA,MACJ,EAAA,EAAI,kBAAA;AAAA,MACJ,EAAA,EAAI;AAAA,KACN;AAAA,IACA,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,EAAA;AAAA,MACN,EAAA,EAAI,qBAAA;AAAA,MACJ,EAAA,EAAI,qBAAA;AAAA,MACJ,EAAA,EAAI,qBAAA;AAAA,MACJ,IAAA,EAAM;AAAA;AACR,GACF;AAAA,EACA,eAAA,EAAiB;AAAA,IACf,OAAA,EAAS,MAAA;AAAA,IACT,OAAA,EAAS,MAAA;AAAA,IACT,MAAA,EAAQ;AAAA;AAEZ,CAAC,CAAA;ACAD,SAAS,aAAa,KAAA,EAA0C;AAC9D,EAAA,OAAO,KAAA,CAAM,MAAA,CAAO,OAAO,CAAA,CAAE,KAAK,GAAG,CAAA;AACvC;AAEA,IAAM,MAAA,GAA8D;AAAA,EAClE,IAAA,EAAM,CAAA;AAAA,EACN,EAAA,EAAIC,aAAQ,CAAC,CAAA;AAAA,EACb,EAAA,EAAIA,aAAQ,CAAC,CAAA;AAAA,EACb,EAAA,EAAIA,aAAQ,CAAC;AACf,CAAA;AAEA,IAAM,SAAA,GAAgE;AAAA,EACpE,IAAA,EAAM,CAAA;AAAA,EACN,IAAIC,WAAA,CAAa,EAAA;AAAA,EACjB,IAAIA,WAAA,CAAa,EAAA;AAAA,EACjB,IAAIA,WAAA,CAAa,EAAA;AAAA,EACjB,MAAMA,WAAA,CAAa;AACrB,CAAA;AAEA,SAAS,OAAA,CACP,EAAE,EAAA,EAAI,SAAA,EAAW,KAAA,EAAO,OAAA,EAAS,OAAA,EAAS,MAAA,EAAQ,QAAA,EAAU,GAAG,IAAA,EAAK,EACpE,GAAA,EACA;AACA,EAAA,MAAM,YAAa,EAAA,IAAM,KAAA;AACzB,EAAA,MAAM,EAAE,MAAA,EAAO,GAAIC,eAAA,EAAS;AAC5B,EAAA,MAAM,eAAe,SAAA,CAAU,EAAE,OAAA,EAAS,OAAA,EAAS,QAAQ,CAAA;AAE3D,EAAA,MAAM,YAAA,GACJ,OAAA,KAAY,SAAA,GACR,MAAA,CAAO,WAAA,GACP,OAAA,KAAY,QAAA,GACV,MAAA,CAAO,WAAA,GACP,OAAA,KAAY,QAAA,GACV,MAAA,CAAO,aAAA,GACP,MAAA;AAEV,EAAA,MAAM,QAAA,GAA0B;AAAA,IAC9B,SAAA,EAAW,YAAA;AAAA,IACX,OAAA,EAAS,MAAA,CAAO,OAAA,IAAW,MAAM,CAAA;AAAA,IACjC,YAAA,EAAc,SAAA,CAAU,MAAA,IAAU,MAAM,CAAA;AAAA,IACxC,GAAI,YAAA,GAAe,EAAE,eAAA,EAAiB,cAAa,GAAI,IAAA;AAAA,IACvD,GAAG;AAAA,GACL;AAEA,EAAA,uBACEC,cAAA,CAAC,SAAA,EAAA,EAAU,GAAA,EAAU,SAAA,EAAW,SAAA,CAAU,YAAA,EAAc,SAAS,CAAA,EAAG,KAAA,EAAO,QAAA,EAAW,GAAG,IAAA,EACtF,QAAA,EACH,CAAA;AAEJ;AAQO,IAAM,GAAA,GAAMC,iBAAW,OAAO","file":"box.cjs","sourcesContent":["import { cva, type VariantProps } from \"class-variance-authority\";\n\n/**\n * Box variants. Kept deliberately small for the foundation commit.\n * Stack, Flex, and Center will land later as either Box variants\n * or as siblings; not sure which I prefer yet.\n */\nexport const boxConfig = cva(\"omni-box\", {\n  variants: {\n    surface: {\n      none: \"\",\n      primary: \"omni-box--surface-primary\",\n      raised:  \"omni-box--surface-raised\",\n      sunken:  \"omni-box--surface-sunken\",\n    },\n    padding: {\n      none: \"\",\n      sm: \"omni-box--pad-sm\",\n      md: \"omni-box--pad-md\",\n      lg: \"omni-box--pad-lg\",\n    },\n    radius: {\n      none: \"\",\n      sm: \"omni-box--radius-sm\",\n      md: \"omni-box--radius-md\",\n      lg: \"omni-box--radius-lg\",\n      pill: \"omni-box--radius-pill\",\n    },\n  },\n  defaultVariants: {\n    surface: \"none\",\n    padding: \"none\",\n    radius: \"none\",\n  },\n});\n\nexport type BoxVariants = VariantProps<typeof boxConfig>;\n","/**\n * Box (web).\n *\n * The single most-used primitive. Polymorphic: renders any HTML element\n * via the `as` prop while preserving the element's native attribute types.\n *\n * ```tsx\n * <Box as=\"a\" href=\"/x\" surface=\"raised\" padding=\"md\">Link</Box>\n * <Box as=\"button\" type=\"submit\" surface=\"primary\">Submit</Box>\n * ```\n *\n * The matching `index.native.tsx` always renders a `<View>` (RN has no\n * polymorphism story worth simulating). `as` is silently ignored on native.\n *\n * Variants resolve via cva for type-safe className output AND via inline\n * styles from the active theme so the primitive works without a stylesheet.\n * Classes are kept as override hooks for consumers who want their own CSS.\n */\nimport { forwardRef, type ElementType, type ForwardedRef, type CSSProperties } from \"react\";\nimport type { PolymorphicComponentPropsWithRef } from \"@plyxui/core\";\nimport { radius as radiusTokens, spacing } from \"@plyxui/core\";\nimport { useTheme } from \"@plyxui/styles\";\nimport { boxConfig, type BoxVariants } from \"./config\";\n\ntype BoxOwnProps = BoxVariants & {\n  className?: string;\n  style?: CSSProperties;\n};\n\nexport type BoxProps<C extends ElementType = \"div\"> = PolymorphicComponentPropsWithRef<\n  C,\n  BoxOwnProps\n>;\n\nfunction joinClass(...parts: Array<string | undefined>): string {\n  return parts.filter(Boolean).join(\" \");\n}\n\nconst padMap: Record<NonNullable<BoxVariants[\"padding\"]>, number> = {\n  none: 0,\n  sm: spacing[2],\n  md: spacing[4],\n  lg: spacing[6],\n};\n\nconst radiusMap: Record<NonNullable<BoxVariants[\"radius\"]>, number> = {\n  none: 0,\n  sm: radiusTokens.sm,\n  md: radiusTokens.md,\n  lg: radiusTokens.lg,\n  pill: radiusTokens.pill,\n};\n\nfunction BoxImpl<C extends ElementType = \"div\">(\n  { as, className, style, surface, padding, radius, children, ...rest }: BoxProps<C>,\n  ref: ForwardedRef<Element>,\n) {\n  const Component = (as ?? \"div\") as ElementType;\n  const { colors } = useTheme();\n  const variantClass = boxConfig({ surface, padding, radius });\n\n  const surfaceColor =\n    surface === \"primary\"\n      ? colors.primaryFill\n      : surface === \"raised\"\n        ? colors.surfaceFill\n        : surface === \"sunken\"\n          ? colors.containerFill\n          : undefined;\n\n  const computed: CSSProperties = {\n    boxSizing: \"border-box\",\n    padding: padMap[padding ?? \"none\"],\n    borderRadius: radiusMap[radius ?? \"none\"],\n    ...(surfaceColor ? { backgroundColor: surfaceColor } : null),\n    ...style,\n  };\n\n  return (\n    <Component ref={ref} className={joinClass(variantClass, className)} style={computed} {...rest}>\n      {children}\n    </Component>\n  );\n}\n\n/**\n * Forwarded-ref + polymorphic Box.\n *\n * NOTE: React's forwardRef erases polymorphic generics, so the cast below\n * is intentional. The exported type carries the generics; runtime is unchanged.\n */\nexport const Box = forwardRef(BoxImpl) as <C extends ElementType = \"div\">(\n  props: BoxProps<C>,\n) => React.ReactElement | null;\n"]}