@42-central/ui-react 0.18.0 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/biome/no-gray-color.grit +18 -0
  2. package/dist/{chunk-6I4R3HR6.js → chunk-RQL7FVCS.js} +3 -3
  3. package/dist/{chunk-6I4R3HR6.js.map → chunk-RQL7FVCS.js.map} +1 -1
  4. package/dist/{chunk-JBVFWSRQ.js → chunk-VIYVN4WF.js} +6 -4
  5. package/dist/chunk-VIYVN4WF.js.map +1 -0
  6. package/dist/{chunk-S53FHWNG.js → chunk-YWRBG23W.js} +3 -3
  7. package/dist/chunk-YWRBG23W.js.map +1 -0
  8. package/dist/colors.css +12 -26
  9. package/dist/components/avatar/avatar.d.ts +3 -3
  10. package/dist/components/avatar/index.js.map +1 -1
  11. package/dist/components/chart/chart.d.ts +1 -1
  12. package/dist/components/chart/index.js +1 -1
  13. package/dist/components/chart/index.js.map +1 -1
  14. package/dist/components/code/index.js +1 -1
  15. package/dist/components/data-table/data-table-stack.d.ts +2 -2
  16. package/dist/components/data-table/data-table-stack.d.ts.map +1 -1
  17. package/dist/components/data-table/data-table.d.ts.map +1 -1
  18. package/dist/components/data-table/index.js +45 -6
  19. package/dist/components/data-table/index.js.map +1 -1
  20. package/dist/components/kbd/index.js +29 -14
  21. package/dist/components/kbd/index.js.map +1 -1
  22. package/dist/components/kbd/kbd.d.ts.map +1 -1
  23. package/dist/components/mark/index.js +1 -1
  24. package/dist/components/mark/mark.d.ts +2 -2
  25. package/dist/components/schedule/index.js +2 -1
  26. package/dist/components/schedule/index.js.map +1 -1
  27. package/dist/components/schedule/now-cursor-line.d.ts.map +1 -1
  28. package/dist/components/schedule/schedule-types.d.ts +1 -1
  29. package/dist/components/switch/index.js +1 -1
  30. package/dist/components/switch/index.js.map +1 -1
  31. package/dist/components/switch/switch.d.ts +2 -0
  32. package/dist/components/switch/switch.d.ts.map +1 -1
  33. package/dist/components/theme-icon/index.js +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/lib/colors.d.ts +1 -1
  36. package/dist/lib/colors.d.ts.map +1 -1
  37. package/dist/theme.css +0 -33
  38. package/package.json +2 -1
  39. package/src/biome-plugins.test.ts +61 -0
  40. package/src/colors.css +12 -26
  41. package/src/components/avatar/avatar.tsx +3 -3
  42. package/src/components/chart/chart.test.tsx +1 -2
  43. package/src/components/chart/chart.tsx +1 -1
  44. package/src/components/code-block/gutters.test.ts +2 -2
  45. package/src/components/data-table/data-table-stack.tsx +5 -3
  46. package/src/components/data-table/data-table.test.tsx +91 -0
  47. package/src/components/data-table/data-table.tsx +55 -6
  48. package/src/components/kbd/kbd.test.tsx +31 -0
  49. package/src/components/kbd/kbd.tsx +29 -14
  50. package/src/components/mark/mark.test.tsx +4 -4
  51. package/src/components/mark/mark.tsx +3 -3
  52. package/src/components/schedule/now-cursor-line.test.tsx +19 -0
  53. package/src/components/schedule/now-cursor-line.tsx +10 -1
  54. package/src/components/schedule/schedule-types.ts +1 -1
  55. package/src/components/switch/switch.test.tsx +12 -0
  56. package/src/components/switch/switch.tsx +3 -1
  57. package/src/components/theme-icon/theme-icon.tsx +1 -1
  58. package/src/lib/colors.ts +4 -2
  59. package/src/theme.css +0 -33
  60. package/dist/chunk-JBVFWSRQ.js.map +0 -1
  61. package/dist/chunk-S53FHWNG.js.map +0 -1
@@ -0,0 +1,18 @@
1
+ // Biome lint plugin: warns on `color="gray"` while the gray palette is a
2
+ // deprecated alias of `neutral` (see `colors.css`). TypeScript can't flag it:
3
+ // `Color` accepts any string, and there is no "string except gray" type.
4
+ //
5
+ // Enable it from a consumer's biome.json(c):
6
+ // "plugins": ["./node_modules/@42-central/ui-react/biome/no-gray-color.grit"]
7
+ //
8
+ // JSX attributes only, so objects unrelated to the kit are never flagged.
9
+ // Delete together with the alias.
10
+ //
11
+ // The message avoids backslash escapes: Biome's Grit strings mangle the
12
+ // characters that follow them.
13
+ language js
14
+
15
+ JsxAttribute() as $attr where {
16
+ $attr <: r"color=(?:\"gray\"|\{\s*[\"']gray[\"']\s*\})",
17
+ register_diagnostic(span=$attr, message="The gray palette was removed from the 42 UI kit and color=gray now renders as neutral. Use color=neutral instead.", severity="warn")
18
+ }
@@ -22,7 +22,7 @@ var themeIconVariants = cva(
22
22
  // fill blends with whatever surface it sits on instead of reading
23
23
  // as a painted CTA block. The border mixes in black on top of that
24
24
  // same var — a fixed darkening, not another opacity step of it —
25
- // so it reads as a recessed edge in both themes; some colors (gray
25
+ // so it reads as a recessed edge in both themes; some colors (neutral
26
26
  // in particular) have a dark-mode `--c-solid` that's lighter than
27
27
  // its own soft/text steps, which would flip a same-var-opacity
28
28
  // border the wrong way. This is the ThemeIcon-specific reading of
@@ -86,5 +86,5 @@ var ThemeIcon = ({
86
86
  );
87
87
 
88
88
  export { ThemeIcon };
89
- //# sourceMappingURL=chunk-6I4R3HR6.js.map
90
- //# sourceMappingURL=chunk-6I4R3HR6.js.map
89
+ //# sourceMappingURL=chunk-RQL7FVCS.js.map
90
+ //# sourceMappingURL=chunk-RQL7FVCS.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/theme-icon/theme-icon.tsx"],"names":[],"mappings":";;;;;;;AAuBA,IAAM,iBAAA,GAAoB,GAAA;AAAA,EACxB;AAAA,IACE,yCAAA;AAAA,IACA,oCAAA;AAAA,IACA,mBAAA;AAAA,IACA,8CAAA;AAAA;AAAA;AAAA,IAGA,WAAA;AAAY,GACd;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAYP,MAAA,EACE,6FAAA;AAAA,QACF,KAAA,EAAO,kDAAA;AAAA,QACP,OAAA,EAAS,mDAAA;AAAA,QACT,MAAA,EAAQ,mDAAA;AAAA;AAAA;AAAA;AAAA,QAIR,OAAA,EAAS;AAAA,UACP,mEAAA;AAAA,UACA;AAAA;AACF,OACF;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,oBAAA;AAAA,QACJ,EAAA,EAAI,sBAAA;AAAA,QACJ,EAAA,EAAI,oBAAA;AAAA,QACJ,EAAA,EAAI,qBAAA;AAAA,QACJ,EAAA,EAAI;AAAA,OACN;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,EAAA,EAAI,YAAA;AAAA,QACJ,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,OAAA,EAAS,SAAA;AAAA,MACT,IAAA,EAAM,IAAA;AAAA,MACN,MAAA,EAAQ;AAAA;AACV;AAEJ,CAAA;AAaO,IAAM,YAAY,CAAC;AAAA,EACxB,SAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,GAAG;AACL,CAAA,qBACE,GAAA;AAAA,EAAC,GAAA,CAAI,GAAA;AAAA,EAAJ;AAAA,IACC,OAAA;AAAA,IACA,YAAA,EAAY,KAAA;AAAA,IACZ,gBAAc,OAAA,IAAW,SAAA;AAAA,IACzB,SAAA,EAAW,GAAG,iBAAA,CAAkB,EAAE,SAAS,IAAA,EAAM,MAAA,EAAQ,CAAA,EAAG,SAAS,CAAA;AAAA,IACpE,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,IAClC,GAAG;AAAA;AACN","file":"chunk-6I4R3HR6.js","sourcesContent":["import { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\n/**\n * ThemeIcon — square, non-interactive icon-display box. Visually related to\n * `ActionIcon` (same size/radius scales) but deliberately **not** its\n * (variant × color) look: every variant here is a muted, low-saturation\n * surface — just enough contrast to read as \"raised above the page,\" never\n * a vivid CTA-style fill. There's no hover state and no cursor affordance,\n * because this is a display, not a control.\n *\n * `asChild` renders the single child as the root, so it composes on top of\n * an interactive element (e.g. wrap a `Link`) when the icon itself needs to\n * be clickable. The kit's focus ring (`focusStyles`) rides along for that\n * case and stays inert on the default `<div>` — but reach for `ActionIcon`\n * when an interactive icon is the common case, since it also supplies the\n * `aria-label`, disabled and loading handling a real trigger needs.\n */\nconst themeIconVariants = cva(\n [\n \"inline-flex items-center justify-center\",\n \"aspect-square shrink-0 select-none\",\n \"rounded-lg border\",\n \"[&_svg]:shrink-0 [&_svg]:pointer-events-none\",\n // Inert on the default non-focusable <div>; applies once `asChild`\n // renders ThemeIcon onto a real <a>/<button>. See `focusStyles`.\n focusStyles(),\n ],\n {\n variants: {\n variant: {\n // A translucent wash of `--c-solid` (not the opaque token) so the\n // fill blends with whatever surface it sits on instead of reading\n // as a painted CTA block. The border mixes in black on top of that\n // same var — a fixed darkening, not another opacity step of it —\n // so it reads as a recessed edge in both themes; some colors (gray\n // in particular) have a dark-mode `--c-solid` that's lighter than\n // its own soft/text steps, which would flip a same-var-opacity\n // border the wrong way. This is the ThemeIcon-specific reading of\n // \"filled\": raised, not loud. Button/Badge/ActionIcon's `filled`\n // (opaque bg-(--c-solid)) would look like a button here —\n // intentionally not reused.\n filled:\n \"bg-(--c-solid)/15 text-(--c-text) border-[color-mix(in_oklab,var(--c-solid)_35%,black_65%)]\",\n light: \"bg-(--c-soft) text-(--c-text) border-transparent\",\n outline: \"bg-transparent text-(--c-text) border-(--c-solid)\",\n subtle: \"bg-transparent text-(--c-text) border-transparent\",\n // Palette-independent neutral surface. Unlike ActionIcon's\n // high-contrast inverted `default` (a black/white button look),\n // this stays a muted card in both themes.\n default: [\n \"bg-gray-light-100/50 text-gray-light-700 border-gray-light-300/50\",\n \"dark:bg-gray-dark-800/50 dark:text-gray-dark-300 dark:border-gray-dark-700/50\",\n ],\n },\n size: {\n xs: \"h-7 [&_svg]:size-5\",\n sm: \"h-8 [&_svg]:size-5.5\",\n md: \"h-9 [&_svg]:size-6\",\n lg: \"h-10 [&_svg]:size-7\",\n xl: \"h-12 [&_svg]:size-8\",\n },\n radius: {\n xs: \"rounded-xs\",\n sm: \"rounded-sm\",\n md: \"rounded-md\",\n lg: \"rounded-lg\",\n xl: \"rounded-xl\",\n full: \"rounded-full\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n radius: \"md\",\n },\n },\n)\n\nexport type ThemeIconVariant = NonNullable<VariantProps<typeof themeIconVariants>[\"variant\"]>\nexport type ThemeIconSize = NonNullable<VariantProps<typeof themeIconVariants>[\"size\"]>\nexport type ThemeIconRadius = NonNullable<VariantProps<typeof themeIconVariants>[\"radius\"]>\n\nexport type ThemeIconProps = HTMLArkProps<\"div\"> &\n VariantProps<typeof themeIconVariants> &\n WithTestId & {\n /** Accent palette. Re-exported as `Color` from `@42/ui-react`. */\n color?: Color\n }\n\nexport const ThemeIcon = ({\n className,\n variant,\n size,\n radius,\n color,\n asChild,\n testId,\n ...rest\n}: ThemeIconProps) => (\n <ark.div\n asChild={asChild}\n data-color={color}\n data-variant={variant ?? \"default\"}\n className={cn(themeIconVariants({ variant, size, radius }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n"]}
1
+ {"version":3,"sources":["../src/components/theme-icon/theme-icon.tsx"],"names":[],"mappings":";;;;;;;AAuBA,IAAM,iBAAA,GAAoB,GAAA;AAAA,EACxB;AAAA,IACE,yCAAA;AAAA,IACA,oCAAA;AAAA,IACA,mBAAA;AAAA,IACA,8CAAA;AAAA;AAAA;AAAA,IAGA,WAAA;AAAY,GACd;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,M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AAA,IACpE,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,IAClC,GAAG;AAAA;AACN","file":"chunk-RQL7FVCS.js","sourcesContent":["import { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\n/**\n * ThemeIcon — square, non-interactive icon-display box. Visually related to\n * `ActionIcon` (same size/radius scales) but deliberately **not** its\n * (variant × color) look: every variant here is a muted, low-saturation\n * surface — just enough contrast to read as \"raised above the page,\" never\n * a vivid CTA-style fill. There's no hover state and no cursor affordance,\n * because this is a display, not a control.\n *\n * `asChild` renders the single child as the root, so it composes on top of\n * an interactive element (e.g. wrap a `Link`) when the icon itself needs to\n * be clickable. The kit's focus ring (`focusStyles`) rides along for that\n * case and stays inert on the default `<div>` — but reach for `ActionIcon`\n * when an interactive icon is the common case, since it also supplies the\n * `aria-label`, disabled and loading handling a real trigger needs.\n */\nconst themeIconVariants = cva(\n [\n \"inline-flex items-center justify-center\",\n \"aspect-square shrink-0 select-none\",\n \"rounded-lg border\",\n \"[&_svg]:shrink-0 [&_svg]:pointer-events-none\",\n // Inert on the default non-focusable <div>; applies once `asChild`\n // renders ThemeIcon onto a real <a>/<button>. See `focusStyles`.\n focusStyles(),\n ],\n {\n variants: {\n variant: {\n // A translucent wash of `--c-solid` (not the opaque token) so the\n // fill blends with whatever surface it sits on instead of reading\n // as a painted CTA block. The border mixes in black on top of that\n // same var — a fixed darkening, not another opacity step of it —\n // so it reads as a recessed edge in both themes; some colors (neutral\n // in particular) have a dark-mode `--c-solid` that's lighter than\n // its own soft/text steps, which would flip a same-var-opacity\n // border the wrong way. This is the ThemeIcon-specific reading of\n // \"filled\": raised, not loud. Button/Badge/ActionIcon's `filled`\n // (opaque bg-(--c-solid)) would look like a button here —\n // intentionally not reused.\n filled:\n \"bg-(--c-solid)/15 text-(--c-text) border-[color-mix(in_oklab,var(--c-solid)_35%,black_65%)]\",\n light: \"bg-(--c-soft) text-(--c-text) border-transparent\",\n outline: \"bg-transparent text-(--c-text) border-(--c-solid)\",\n subtle: \"bg-transparent text-(--c-text) border-transparent\",\n // Palette-independent neutral surface. Unlike ActionIcon's\n // high-contrast inverted `default` (a black/white button look),\n // this stays a muted card in both themes.\n default: [\n \"bg-gray-light-100/50 text-gray-light-700 border-gray-light-300/50\",\n \"dark:bg-gray-dark-800/50 dark:text-gray-dark-300 dark:border-gray-dark-700/50\",\n ],\n },\n size: {\n xs: \"h-7 [&_svg]:size-5\",\n sm: \"h-8 [&_svg]:size-5.5\",\n md: \"h-9 [&_svg]:size-6\",\n lg: \"h-10 [&_svg]:size-7\",\n xl: \"h-12 [&_svg]:size-8\",\n },\n radius: {\n xs: \"rounded-xs\",\n sm: \"rounded-sm\",\n md: \"rounded-md\",\n lg: \"rounded-lg\",\n xl: \"rounded-xl\",\n full: \"rounded-full\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n radius: \"md\",\n },\n },\n)\n\nexport type ThemeIconVariant = NonNullable<VariantProps<typeof themeIconVariants>[\"variant\"]>\nexport type ThemeIconSize = NonNullable<VariantProps<typeof themeIconVariants>[\"size\"]>\nexport type ThemeIconRadius = NonNullable<VariantProps<typeof themeIconVariants>[\"radius\"]>\n\nexport type ThemeIconProps = HTMLArkProps<\"div\"> &\n VariantProps<typeof themeIconVariants> &\n WithTestId & {\n /** Accent palette. Re-exported as `Color` from `@42/ui-react`. */\n color?: Color\n }\n\nexport const ThemeIcon = ({\n className,\n variant,\n size,\n radius,\n color,\n asChild,\n testId,\n ...rest\n}: ThemeIconProps) => (\n <ark.div\n asChild={asChild}\n data-color={color}\n data-variant={variant ?? \"default\"}\n className={cn(themeIconVariants({ variant, size, radius }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n"]}
@@ -1,9 +1,11 @@
1
1
  // src/lib/colors.ts
2
2
  var COLORS = [
3
3
  "brand",
4
- "gray",
5
4
  // Composed from existing white/gray/brand-950 tokens rather than its own
6
- // scale — the literal white/dark-navy button from the 42 UI Kit Figma.
5
+ // scale — the literal white/dark-navy button from the 42 UI Kit Figma
6
+ // (where it is still labelled "gray" on Button). The former mid-gray `gray`
7
+ // palette was cut in its favor; `data-color="gray"` survives only as a
8
+ // deprecated CSS alias of this one (see colors.css).
7
9
  "neutral",
8
10
  "red",
9
11
  "orange",
@@ -17,5 +19,5 @@ var COLORS = [
17
19
  ];
18
20
 
19
21
  export { COLORS };
20
- //# sourceMappingURL=chunk-JBVFWSRQ.js.map
21
- //# sourceMappingURL=chunk-JBVFWSRQ.js.map
22
+ //# sourceMappingURL=chunk-VIYVN4WF.js.map
23
+ //# sourceMappingURL=chunk-VIYVN4WF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/colors.ts"],"names":[],"mappings":";AAWO,IAAM,MAAA,GAAS;AAAA,EACpB,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF","file":"chunk-VIYVN4WF.js","sourcesContent":["/**\n * Single source of truth for the `color` prop accepted by colored components\n * (Button, ActionIcon, Slider, …). The const array drives both the type and\n * any runtime iteration (docs swatches, story controls).\n *\n * Adding a new color is a three-step change:\n * 1. Append the name here.\n * 2. Define its `--color-<name>-{25..950}` scale in `theme.css`.\n * 3. Add a `[data-color=\"<name>\"]` block in `colors.css` with the slot vars\n * (and a dark-mode override if the shade should shift).\n */\nexport const COLORS = [\n \"brand\",\n // Composed from existing white/gray/brand-950 tokens rather than its own\n // scale — the literal white/dark-navy button from the 42 UI Kit Figma\n // (where it is still labelled \"gray\" on Button). The former mid-gray `gray`\n // palette was cut in its favor; `data-color=\"gray\"` survives only as a\n // deprecated CSS alias of this one (see colors.css).\n \"neutral\",\n \"red\",\n \"orange\",\n \"yellow\",\n \"green\",\n \"teal\",\n \"cyan\",\n \"blue\",\n \"purple\",\n \"pink\",\n] as const\n\n// Extend the type to allow custom color strings (e.g. `color=\"custom\"`)\n// but still allow complete type safety for the predefined colors\nexport type Color = (typeof COLORS)[number] | (string & {})\n"]}
@@ -20,11 +20,11 @@ var Mark = ({ className, color, background, children, testId, ...rest }) => {
20
20
  showBackground ? "bg-(--c-soft)/60 px-0.5 py-px" : "bg-transparent",
21
21
  className
22
22
  ),
23
- children: /* @__PURE__ */ jsx("span", { "data-color": color ?? "gray", className: "text-(--c-text)", children })
23
+ children: /* @__PURE__ */ jsx("span", { "data-color": color ?? "neutral", className: "text-(--c-text)", children })
24
24
  }
25
25
  );
26
26
  };
27
27
 
28
28
  export { Mark };
29
- //# sourceMappingURL=chunk-S53FHWNG.js.map
30
- //# sourceMappingURL=chunk-S53FHWNG.js.map
29
+ //# sourceMappingURL=chunk-YWRBG23W.js.map
30
+ //# sourceMappingURL=chunk-YWRBG23W.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/mark/mark.tsx"],"names":[],"mappings":";;;;AAqDO,IAAM,IAAA,GAAO,CAAC,EAAE,SAAA,EAAW,KAAA,EAAO,YAAY,QAAA,EAAU,MAAA,EAAQ,GAAG,IAAA,EAAK,KAAiB;AAG9F,EAAA,MAAM,cAAA,GAAiB,UAAA,KAAe,MAAA,IAAa,KAAA,KAAU,MAAA;AAC7D,EAAA,MAAM,KAAK,UAAA,IAAc,QAAA;AACzB,EAAA,uBACE,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,YAAA,EAAY,iBAAiB,EAAA,GAAK,MAAA;AAAA,MACjC,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,MAClC,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,EAAA;AAAA,QACT,YAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAKA,iBAAiB,+BAAA,GAAkC,gBAAA;AAAA,QACnD;AAAA,OACF;AAAA,MAEA,8BAAC,MAAA,EAAA,EAAK,YAAA,EAAY,SAAS,SAAA,EAAW,SAAA,EAAU,mBAC7C,QAAA,EACH;AAAA;AAAA,GACF;AAEJ","file":"chunk-YWRBG23W.js","sourcesContent":["import type { ComponentPropsWithoutRef } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\n/**\n * Mark — an inline `<mark>` highlighter. Pure React Server Component.\n *\n * `background` and `color` are fully independent — `background` only ever\n * changes the highlight, `color` only ever changes the text, neither leaks\n * into the other: `background` alone (no `color`) tints the highlight with\n * *neutral* text, not text matching the highlight; `color` alone (no\n * `background`) renders as tinted text with no highlight at all —\n * `background` only defaults to `\"yellow\"` when it's unset, regardless of\n * `color`. This needs two DOM nodes rather than one: `--c-soft`/`--c-text`\n * are both defined together inside the same `[data-color=\"X\"]` block in\n * `colors.css`, so a single `data-color` attribute can only ever scope one\n * color's worth of both vars at once. Letting background and text pick\n * *different* color names — and stay theme-aware, the whole reason\n * `--c-soft`/`--c-text` exist instead of a fixed shade — means they need two\n * independently-scoped `data-color` attributes. The outer `<mark>` scopes\n * `--c-soft` for the background; the inner `<span>` scopes its own `--c-text`\n * for the text, independent of the outer scope.\n *\n * The inner span's `text-(--c-text)` class is unconditional — never gated\n * behind an `if (color)` branch — so it always declares its own explicit\n * `color`, never inheriting one. That's what makes nesting a colored `<Mark>`\n * inside a colored `<Code>` (or any other colored ancestor) \"just work\": an\n * ancestor's `color` only reaches a descendant by inheritance, the\n * lowest-priority source of a property's value, so the inner span's own\n * declaration always wins, no `!important` or descendant-selector games\n * needed.\n *\n * No `asChild` (plain `ComponentPropsWithoutRef<\"mark\">`, not `HTMLArkProps`):\n * the inner span above already repurposes `children` as \"the highlighted\n * content,\" which collides with `asChild`'s usual meaning (the one child to\n * render as root) — the same reasoning `Skeleton`'s wrap mode uses to skip it.\n */\nexport type MarkProps = ComponentPropsWithoutRef<\"mark\"> &\n WithTestId & {\n /**\n * Text color. Independent of `background` — never falls back to it.\n * @default \"neutral\"\n */\n color?: Color\n /**\n * Background/highlight tint. Re-exported as `Color` from `@42/ui-react`.\n * @default \"yellow\"\n */\n background?: Color\n }\n\nexport const Mark = ({ className, color, background, children, testId, ...rest }: MarkProps) => {\n // A background only defaults to \"yellow\" when neither prop is given —\n // `color` alone must render as tinted text with no highlight at all.\n const showBackground = background !== undefined || color === undefined\n const bg = background ?? \"yellow\"\n return (\n <mark\n data-color={showBackground ? bg : undefined}\n {...props({ \"data-testid\": testId })}\n {...rest}\n className={cn(\n \"rounded-xs\",\n // Browsers ship a UA-stylesheet default for `<mark>` (a solid yellow\n // background, historically with black text) — an explicit\n // `bg-transparent` is required in the no-background branch, or that\n // default bleeds through instead of \"no highlight at all\".\n showBackground ? \"bg-(--c-soft)/60 px-0.5 py-px\" : \"bg-transparent\",\n className,\n )}\n >\n <span data-color={color ?? \"neutral\"} className=\"text-(--c-text)\">\n {children}\n </span>\n </mark>\n )\n}\n"]}
package/dist/colors.css CHANGED
@@ -21,12 +21,10 @@
21
21
  * --c-solid-hover : filled hover state (600 light / 400 dark)
22
22
  * --c-on-solid : foreground sitting on a solid background. brand-950 (dark navy)
23
23
  * for every color, light or dark theme — matches the 42 UI Kit
24
- * Figma, which uses dark navy text on solid fills. `gray` (light
25
- * theme) is the one exception, kept white — its solid shade is
26
- * too dark for brand-950 text to clear WCAG AA (2.05:1; see the
27
- * inline comment there). `purple` is a marginal fail (4.29:1 vs
28
- * the 4.5 AA threshold) but keeps brand-950 anyway for
29
- * consistency with the other nine colors.
24
+ * Figma, which uses dark navy text on solid fills. `neutral`
25
+ * (light theme) is the one exception, white on its black fill.
26
+ * `purple` is a marginal fail (4.29:1 vs the 4.5 AA threshold)
27
+ * but keeps brand-950 anyway for consistency with the others.
30
28
  * --c-soft : tinted surface for `light` / hover tints (50 light / 950 dark)
31
29
  * --c-soft-hover : a step darker than --c-soft
32
30
  * --c-text : text + icon on non-filled surfaces (700 light / 300 dark)
@@ -94,24 +92,6 @@
94
92
  --c-text: var(--color-brand-300);
95
93
  }
96
94
 
97
- [data-color="gray"] {
98
- /* gray-700 is too dark for brand-950 text (2.05:1, fails WCAG AA) — kept white. */
99
- --c-solid: var(--color-gray-light-700);
100
- --c-solid-hover: var(--color-gray-light-800);
101
- --c-on-solid: var(--color-white);
102
- --c-soft: var(--color-gray-light-100);
103
- --c-soft-hover: var(--color-gray-light-200);
104
- --c-text: var(--color-gray-light-700);
105
- }
106
- [data-theme="dark"] [data-color="gray"] {
107
- --c-solid: var(--color-gray-dark-300);
108
- --c-solid-hover: var(--color-gray-dark-200);
109
- --c-on-solid: var(--color-brand-950);
110
- --c-soft: var(--color-gray-dark-800);
111
- --c-soft-hover: var(--color-gray-dark-700);
112
- --c-text: var(--color-gray-dark-300);
113
- }
114
-
115
95
  [data-color="red"] {
116
96
  --c-solid: var(--color-red-500);
117
97
  --c-solid-hover: var(--color-red-600);
@@ -268,7 +248,12 @@
268
248
  --c-text: var(--color-pink-300);
269
249
  }
270
250
 
271
- [data-color="neutral"] {
251
+ /* `gray` is a deprecated alias of `neutral`: the former mid-gray palette was
252
+ cut (Figma's "gray" Button already draws these exact values). The selector
253
+ stays one minor so `data-color="gray"` doesn't silently inherit its
254
+ ancestor's palette instead. Remove in the next minor. */
255
+ [data-color="neutral"],
256
+ [data-color="gray"] {
272
257
  /* Figma "White" hierarchy — the literal white/dark-navy button most of the
273
258
  kit defaults to. --c-soft mirrors Figma's own translucent-white overlay
274
259
  intent, but a single value shared across themes would go invisible (or
@@ -286,7 +271,8 @@
286
271
  --c-soft-hover: color-mix(in oklab, var(--color-black) 35%, transparent);
287
272
  --c-text: var(--color-gray-light-700);
288
273
  }
289
- [data-theme="dark"] [data-color="neutral"] {
274
+ [data-theme="dark"] [data-color="neutral"],
275
+ [data-theme="dark"] [data-color="gray"] {
290
276
  --c-solid: var(--color-white);
291
277
  --c-solid-hover: var(--color-gray-light-300);
292
278
  --c-on-solid: var(--color-brand-950);
@@ -43,9 +43,9 @@ export type AvatarNameMode = "name" | "initials";
43
43
  /**
44
44
  * Default hash pool for `color="name"` / `color="initials"`. Excludes
45
45
  * `brand` (the kit's own primary/CTA identity color — auto-tinting a user
46
- * avatar with it would read as "official") and `gray`/`neutral` (muted, and
47
- * `neutral` is a composed-not-scaled tone per `lib/colors.ts`, so it would
48
- * just look washed-out for some names). Exported so a consumer can extend it,
46
+ * avatar with it would read as "official") and `neutral` (muted, and a
47
+ * composed-not-scaled tone per `lib/colors.ts`, so it would just look
48
+ * washed-out for some names). Exported so a consumer can extend it,
49
49
  * e.g. `palette={[...AVATAR_PALETTE, "brand"]}`.
50
50
  */
51
51
  export declare const AVATAR_PALETTE: Color[];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/avatar/avatar.tsx"],"names":["ArkAvatar"],"mappings":";;;;;;;;AAwCA,IAAM,cAAA,GAAiB,GAAA;AAAA,EACrB;AAAA,IACE,2EAAA;AAAA,IACA,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA,uCAAA;AAAA,IACA,+CAAA;AAAA,IACA,qDAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAUR,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,qDAAA;AAAA,QACJ,EAAA,EAAI,+CAAA;AAAA,QACJ,EAAA,EAAI,gDAAA;AAAA,QACJ,EAAA,EAAI,kDAAA;AAAA,QACJ,EAAA,EAAI;AAAA,OACN;AAAA;AAAA;AAAA;AAAA;AAAA;A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IACA,yEAAA;AAAA,IACA;AAAA;AAEJ,CAAA;AAUA,IAAM,cAAc,CAAC;AAAA,EACnB,OAAA,GAAU,IAAA;AAAA,EACV,WAAA,GAAc,YAAA;AAAA,EACd,SAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,GAAG;AACL,CAAA,qBACE,GAAA;AAAA,EAAC,GAAA,CAAI,GAAA;AAAA,EAAJ;AAAA,IACC,kBAAA,EAAkB,WAAA;AAAA,IAClB,WAAW,EAAA,CAAG,wBAAA,CAAyB,WAAW,CAAA,EAAG,oBAAoB,SAAS,CAAA;AAAA,IAClF,OAAO,EAAE,GAAG,wBAAwB,OAAO,CAAA,EAAG,GAAG,KAAA,EAAM;AAAA,IACtD,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,IAClC,GAAG;AAAA;AACN,CAAA;AAIK,IAAM,SAAS,MAAA,CAAO,MAAA,CAAO,iBAAiB,EAAE,KAAA,EAAO,aAAa","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Avatar as ArkAvatar, ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { UserRound } from \"lucide-react\"\nimport { type ComponentProps, type CSSProperties, type ReactNode, useId } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\n/**\n * Avatar — circular (by default) image with an automatic fallback. Renders\n * `src` once it loads; falls back to `children` (custom initials or an icon)\n * when there's no image or it fails to load, or to initials/name derived from\n * `name`, or finally to a generic person icon. Wraps Ark's `Avatar` machine,\n * which already tracks image-load state (`loading → loaded/error`) — no\n * bespoke `onError` handling needed here.\n *\n * <Avatar src={user.avatarUrl} name={user.fullName} color=\"brand\" />\n *\n * `color=\"name\"` / `color=\"initials\"` deterministically hash `name` (or its\n * derived initials) into a pick from `palette` instead of a literal `Color` —\n * a stable, no-config accent per person. `display` independently controls\n * what the computed fallback shows: `\"initials\"` (default, two letters) or\n * `\"name\"` (a single leading letter — a full name would overflow the circle).\n *\n * No `asChild` — same reasoning as `Skeleton`: `children` is already\n * repurposed as fallback content, which conflicts with Ark's \"single child to\n * render as\" requirement for polymorphism.\n *\n * `Avatar.Group` overlaps a row — or, with `orientation=\"vertical\"`, a\n * column — of standalone `Avatar`s (Mantine-style stacked avatars),\n * punching a transparent notch into each one where its successor overlaps\n * it — true see-through separation instead of a painted border, so it reads\n * correctly over any page background. It's pure CSS\n * layout, like `ButtonGroup` — it doesn't resize or restyle its children, so\n * set `size`/`color` per `Avatar`.\n */\nconst avatarVariants = cva(\n [\n \"relative inline-flex shrink-0 items-center justify-center overflow-hidden\",\n \"select-none\",\n // Neutral gray by default; a `data-color` tint overrides it with the\n // palette's soft surface + text — the same treatment Pill and Badge's\n // `light` variant use. No variant axis: an avatar is always this one\n // soft-surface look, just optionally tinted. No border either: it used\n // to be border-(--c-soft) once tinted, i.e. always the exact same color\n // as its own background — invisible for every `color`, visible only for\n // the untinted default (border-brand-900/20 against bg-gray-light-100,\n // two different colors) — so whether an avatar showed a border at all\n // used to depend on `color`, not on any actual design intent.\n \"bg-gray-light-100 text-gray-light-700\",\n \"dark:bg-gray-dark-800 dark:text-gray-dark-300\",\n \"data-color:bg-(--c-soft) data-color:text-(--c-text)\",\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0\",\n ],\n {\n variants: {\n // `--avatar-r` (this avatar's own radius, in px, as a unitless number)\n // rides along with `size` — it's read by `Avatar.Group`'s notch/margin\n // CSS (see AVATAR_GROUP_NOTCH below) so the notch always matches\n // *this* avatar's actual rendered radius, not whatever radius\n // `Avatar.Group`'s own `spacing` happens to assume. `spacing` only\n // ever controls `--avatar-o` (the overlap amount) — a mismatched\n // `size`/`spacing` pairing (e.g. `md` avatars in a `spacing=\"xs\"`\n // group) still gets a correctly-sized notch, just more or less\n // overlap.\n size: {\n xs: \"size-6 text-[10px] [&_svg]:size-3.5 [--avatar-r:12]\",\n sm: \"size-8 text-xs [&_svg]:size-4 [--avatar-r:16]\",\n md: \"size-10 text-sm [&_svg]:size-5 [--avatar-r:20]\",\n lg: \"size-12 text-base [&_svg]:size-6 [--avatar-r:24]\",\n xl: \"size-16 text-lg [&_svg]:size-8 [--avatar-r:32]\",\n },\n // `--avatar-corner-r` also rides along with `radius`: it's the other\n // half of `Avatar.Group`'s notch for a non-circular avatar (see\n // AVATAR_GROUP_NOTCH and AvatarNotchMaskDefs below). A gradient can\n // only cut a circle/ellipse, never a true rounded rect, so\n // `radius=\"full\"` keeps using a mask-image ellipse (the shape it\n // actually needs), but every other radius instead cuts a real\n // rounded-rect *hole* via a per-instance SVG `<mask>`, using this\n // avatar's own actual radius token (`theme.css`'s\n // `--radius-xs`..`--radius-xl`, in px) as that hole's corner radius.\n // `\"full\"` deliberately has no `--avatar-corner-r` and never renders\n // that SVG mask at all — its radius (50% of the box) isn't a fixed px\n // value the way the others are, so there's nothing meaningful to plug\n // in here; the mask-image ellipse already handles it correctly.\n radius: {\n xs: \"rounded-xs [--avatar-corner-r:4]\",\n sm: \"rounded-sm [--avatar-corner-r:6]\",\n md: \"rounded-md [--avatar-corner-r:8]\",\n lg: \"rounded-lg [--avatar-corner-r:10]\",\n xl: \"rounded-xl [--avatar-corner-r:12]\",\n full: \"rounded-full\",\n },\n },\n defaultVariants: {\n size: \"md\",\n // Unlike ThemeIcon (a square icon surface), an avatar reads as\n // circular by default — matching Mantine's own default.\n radius: \"full\",\n },\n },\n)\n\nexport type AvatarSize = NonNullable<VariantProps<typeof avatarVariants>[\"size\"]>\nexport type AvatarRadius = NonNullable<VariantProps<typeof avatarVariants>[\"radius\"]>\n\n/** Shared by `color`'s auto-computed modes and `display`'s content mode. */\nexport type AvatarNameMode = \"name\" | \"initials\"\n\n/**\n * Default hash pool for `color=\"name\"` / `color=\"initials\"`. Excludes\n * `brand` (the kit's own primary/CTA identity color — auto-tinting a user\n * avatar with it would read as \"official\") and `gray`/`neutral` (muted, and\n * `neutral` is a composed-not-scaled tone per `lib/colors.ts`, so it would\n * just look washed-out for some names). Exported so a consumer can extend it,\n * e.g. `palette={[...AVATAR_PALETTE, \"brand\"]}`.\n */\nexport const AVATAR_PALETTE: Color[] = [\n \"red\",\n \"orange\",\n \"yellow\",\n \"green\",\n \"teal\",\n \"cyan\",\n \"blue\",\n \"purple\",\n \"pink\",\n]\n\ntype AvatarClassNames = {\n root?: string\n image?: string\n fallback?: string\n}\n\nexport type AvatarProps = Omit<ComponentProps<typeof ArkAvatar.Root>, \"color\" | \"asChild\"> &\n VariantProps<typeof avatarVariants> &\n WithTestId & {\n /** Image source. Falls back automatically when unset or on load error. */\n src?: string\n /** Alt text for the image. */\n alt?: string\n /**\n * Accent palette. `\"name\"` / `\"initials\"` deterministically hash `name`\n * (or its derived initials) into a pick from `palette` instead of a\n * literal color. Re-exported as `Color` from `@42/ui-react`.\n */\n color?: Color | AvatarNameMode\n /**\n * Colors eligible for `color=\"name\"` / `color=\"initials\"`'s hash.\n * Ignored otherwise. Defaults to `AVATAR_PALETTE`.\n */\n palette?: Color[]\n /**\n * Full name to derive initials/color from (e.g. \"Ada Lovelace\" → \"AL\")\n * when there's no image and no explicit `children`. Explicit `children`\n * always takes precedence over `name`.\n */\n name?: string\n /**\n * What the computed fallback shows: `\"initials\"` (default, two letters)\n * or `\"name\"` (a single leading letter of `name`).\n */\n display?: AvatarNameMode\n /**\n * Fallback content — shown until the image loads, or permanently when\n * there's no `src`. Overrides the `name`/`display`-derived content.\n */\n children?: ReactNode\n classNames?: AvatarClassNames\n }\n\n/** First + last initial for a multi-word name; first two chars for a single word. */\nconst getInitials = (name: string): string => {\n const parts = name.trim().split(/\\s+/).filter(Boolean)\n const [first, ...rest] = parts\n if (!first) return \"\"\n const last = rest.at(-1)\n return (last ? first.charAt(0) + last.charAt(0) : first.slice(0, 2)).toUpperCase()\n}\n\n/** Single leading letter — `display=\"name\"`'s content; a full name would overflow the circle. */\nconst getLeadingLetter = (name: string): string => name.trim().charAt(0).toUpperCase()\n\n/** Deterministic string hash (Java-style polynomial rolling hash). */\nconst hashString = (input: string): number => {\n let hash = 0\n for (let i = 0; i < input.length; i++) hash = (hash * 31 + input.charCodeAt(i)) | 0\n return Math.abs(hash)\n}\n\nconst pickColor = (input: string, pool: Color[]): Color | undefined =>\n input && pool.length > 0 ? pool[hashString(input) % pool.length] : undefined\n\nconst isAvatarNameMode = (value: unknown): value is AvatarNameMode =>\n value === \"name\" || value === \"initials\"\n\n/**\n * A per-instance SVG `<mask>` cutting `Avatar.Group`'s notch as a true\n * rounded-rect hole for any non-circular `radius` — see AVATAR_GROUP_NOTCH's\n * own doc comment for why a hole (not a trim/clip) is what's actually needed\n * here. Rendered *inside this avatar itself* — not shared, not on\n * `Avatar.Group` — because an SVG `<mask>`'s content resolves `var()` from\n * wherever the `<mask>` element itself sits in the DOM, not from whatever\n * element references it via `mask: url(#id)` (confirmed empirically: a single\n * shared mask read the *ancestor's* `--avatar-r`, not each differently-sized\n * avatar's own). Nesting a practically-free per-instance one inside each\n * avatar instead means it naturally inherits *that* avatar's own\n * `--avatar-r`/`--avatar-corner-r` and the group's `--avatar-o` and\n * `--avatar-dx`/`--avatar-dy`, the same way any of this avatar's own CSS\n * already does.\n *\n * The hole matches the *next* avatar's box (same-size neighbor assumed),\n * grown by a ~2px gap on every side. It sits one step of `2r - o` (diameter\n * minus overlap) along the group's direction vector `(dx, dy)` — so a single\n * mask covers ltr (`1, 0`), rtl (`-1, 0`) and vertical (`0, 1`) stacks.\n *\n * `size-0 absolute` keeps it out of layout entirely. The `<mask>` element's\n * own `x`/`y`/`width`/`height` (not the same as the hole `<rect>`'s) opt out\n * of the CSS default `objectBoundingBox` region (`-10% -10% 120% 120%` of\n * the avatar's own box) — too small to contain a hole that can extend well\n * beyond the box — for a `userSpaceOnUse` region large enough it never\n * actually clips anything; all real clipping is left to the masked avatar's\n * own box, same as everywhere else in this file.\n */\nconst AvatarNotchMaskDefs = ({ id }: { id: string }) => (\n <svg aria-hidden=\"true\" className=\"absolute size-0\">\n <defs>\n <mask id={id} maskUnits=\"userSpaceOnUse\" x={-1000} y={-1000} width={2000} height={2000}>\n <rect x={-1000} y={-1000} width={2000} height={2000} fill=\"white\" />\n <rect\n style={\n {\n x: \"calc((var(--avatar-dx) * (2 * var(--avatar-r) - var(--avatar-o)) - 2) * 1px)\",\n y: \"calc((var(--avatar-dy) * (2 * var(--avatar-r) - var(--avatar-o)) - 2) * 1px)\",\n width: \"calc((2 * var(--avatar-r) + 4) * 1px)\",\n height: \"calc((2 * var(--avatar-r) + 4) * 1px)\",\n rx: \"calc((var(--avatar-corner-r) + 2) * 1px)\",\n } as CSSProperties\n }\n fill=\"black\"\n />\n </mask>\n </defs>\n </svg>\n)\n\nconst AvatarComponent = ({\n src,\n alt,\n size,\n radius,\n color,\n palette = AVATAR_PALETTE,\n name,\n display = \"initials\",\n children,\n className,\n classNames,\n style,\n testId,\n ...rest\n}: AvatarProps) => {\n const resolvedColor = isAvatarNameMode(color)\n ? pickColor(color === \"name\" ? (name ?? \"\") : name ? getInitials(name) : \"\", palette)\n : color\n\n const computed = name ? (display === \"name\" ? getLeadingLetter(name) : getInitials(name)) : \"\"\n const fallback = children ?? (computed || <UserRound />)\n\n // `radius=\"full\"` (the default) uses AVATAR_GROUP_NOTCH's mask-image\n // circle instead — no rounded-rect hole to build, no id needed.\n const needsNotchMask = (radius ?? \"full\") !== \"full\"\n const maskId = useId().replace(/:/g, \"\")\n const notchMaskStyle: CSSProperties = needsNotchMask\n ? ({ \"--avatar-notch-mask\": `url(#${maskId})` } as CSSProperties)\n : {}\n\n return (\n <ArkAvatar.Root\n data-color={resolvedColor}\n className={cn(avatarVariants({ size, radius }), className, classNames?.root)}\n style={{ ...notchMaskStyle, ...style }}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {needsNotchMask && <AvatarNotchMaskDefs id={maskId} />}\n {src && (\n <ArkAvatar.Image\n src={src}\n alt={alt}\n className={cn(\"size-full object-cover\", classNames?.image)}\n />\n )}\n <ArkAvatar.Fallback\n className={cn(\n \"flex items-center justify-center font-medium leading-none\",\n classNames?.fallback,\n )}\n >\n {fallback}\n </ArkAvatar.Fallback>\n </ArkAvatar.Root>\n )\n}\n\n/**\n * Overlap magnitude (px) per `Size` key — larger sizes overlap by more. The\n * only number this whole margin/notch mechanism hardcodes at the group\n * level; `--avatar-r` (each avatar's own radius) instead rides along with\n * `Avatar`'s own `size` variant above, so the notch always matches what's\n * actually rendered even when a group's `spacing` and its avatars' `size`\n * don't happen to match (`Avatar.Group` doesn't restyle children, so\n * nothing stops that).\n */\nconst AVATAR_GROUP_OVERLAP_PX: Record<Size, number> = { xs: 8, sm: 10, md: 12, lg: 14, xl: 16 }\n\n/**\n * `--avatar-o` is a unitless number, not a length — `calc()` casts a\n * unitless custom property into a real length/percentage by multiplying it\n * by `1px`/`1%` (see AVATAR_GROUP_ORIENTATION's `* -1px` and AVATAR_GROUP_NOTCH's\n * `* 1%` below), the same trick that keeps those two classes static text\n * instead of needing a copy per `spacing` value. Set here on the group root\n * and read by children via ordinary CSS custom-property inheritance —\n * `--avatar-r` is deliberately *not* set here (see above).\n */\nconst avatarGroupSpacingStyle = (spacing: Size): CSSProperties =>\n ({ \"--avatar-o\": AVATAR_GROUP_OVERLAP_PX[spacing] }) as CSSProperties\n\n/**\n * Two mutually-exclusive ways to notch every avatar but the last, selected\n * purely by the presence of the `rounded-full` class (set by `radius`\n * above) — `:not(.rounded-full)` and `.rounded-full` never both match the\n * same element, so exactly one of these ever applies to a given avatar:\n *\n * - `.rounded-full` (the default): a `mask-image` circle, unchanged from\n * before. `ellipse RX RY` (not `circle`, whose gradient radius can't be a\n * percentage) with equal `%` radii on a square avatar box renders as a\n * true circle, centered on the next avatar (assuming a same-size\n * neighbor — the same \"uniform stack\" assumption the overlap margin\n * already makes) with a radius a bit larger than that neighbor's own so\n * a thin ring of true transparency survives around it. The radius is\n * `calc((50 + 100 / var(--avatar-r)) * 1%)` — 50% is *this* avatar's own\n * radius (from its own `size` variant, not from the group's `spacing`,\n * so the notch stays correctly sized even if `spacing` and `size` don't\n * match), `100 / r` a ~2px gap expressed as a percentage of its\n * diameter. Must be a pure percentage, not `calc(50% + 2px)` — browsers\n * reject a `%`+length `calc()` as a gradient's explicit circle/ellipse\n * size (unlike almost everywhere else `<length-percentage>` is\n * accepted), so an earlier draft mixing units here silently produced an\n * invalid `mask-image` that just got dropped, with no visible error.\n *\n * - every other `radius`: a `mask-image: var(--avatar-notch-mask)` instead —\n * a real rounded-rect *hole*, cut by a per-instance SVG `<mask>` this\n * avatar renders for itself (see AvatarNotchMaskDefs above for the full\n * rationale). A CSS gradient can only cut a circle/ellipse (hence the\n * circle case above visibly curving away from a rounded-square avatar's\n * flat edges — a corner-shaped gap instead of an edge-shaped one), and\n * `clip-path` can only *keep* one shape, never subtract one — neither can\n * express a rounded-rect hole directly. An SVG `<mask>` can: the hole\n * `<rect>` is sized/positioned to match the *next* avatar's own box\n * (assuming a same-size neighbor, the same \"uniform stack\" assumption the\n * overlap margin already makes) expanded outward by a ~2px gap in every\n * direction, with `rx`/`ry` = that neighbor's own corner radius + the\n * same gap — so the hole's boundary is a true parallel offset of the next\n * avatar's actual silhouette, not an approximation of it. (An earlier\n * attempt just trimmed *this* avatar's own trailing edge with\n * `clip-path: inset(... round ...)` — cheaper, no SVG needed — but that\n * can only shape *this* avatar's own edge, blind to whatever curve the\n * *next* avatar's corner actually traces at each height, so the gap\n * between them didn't follow it: either two independently-rounded edges\n * compounding into an oversized gap at the corner, or, if this avatar's\n * own edge was flattened to avoid that, a straight cut that stayed a\n * constant distance from the next avatar's *box* while that avatar's\n * *rendered* corner receded away from it — reading as an inconsistent gap\n * width rather than a clean ring. Only shaping the hole to match the\n * neighbor's real silhouette avoids both failure modes.)\n *\n * `radius=\"full\"` deliberately isn't handled this way — see the `radius`\n * variant's own comment for why.\n *\n * Neither branch hardcodes a direction. Both place the hole one step of\n * `2r - o` (diameter minus overlap) along the group's direction vector\n * `--avatar-dx`/`--avatar-dy` (see AVATAR_GROUP_ORIENTATION below) — for the\n * circle, `50% + d * (100 - o / (2r) * 100)%` on each axis, i.e. `150 - …`\n * one way and `… - 50` the other. Physical positions (`at X% Y%`, the hole's\n * `x`/`y`) don't flip with `dir` on their own the way the margin's logical\n * `margin-inline-start` does, so rtl flips the vector instead of duplicating\n * every rule with an `rtl:` copy.\n *\n * Both — like AVATAR_GROUP_ORIENTATION's classes below — have to be static string\n * literals, not built from a template at runtime: Tailwind's build only\n * generates CSS for class names it can find verbatim in the source text, so\n * an interpolated/computed class name here would silently produce no\n * styles either, even if every interpolated piece were itself constant.\n */\nconst AVATAR_GROUP_NOTCH = cn(\n \"[&>*:not(:last-child).rounded-full]:[mask-image:radial-gradient(ellipse_calc((50_+_100_/_var(--avatar-r))_*_1%)_calc((50_+_100_/_var(--avatar-r))_*_1%)_at_calc((50_+_var(--avatar-dx)_*_(100_-_var(--avatar-o)_/_(2_*_var(--avatar-r))_*_100))_*_1%)_calc((50_+_var(--avatar-dy)_*_(100_-_var(--avatar-o)_/_(2_*_var(--avatar-r))_*_100))_*_1%),transparent_100%,black_100%)]\",\n \"[&>*:not(:last-child):not(.rounded-full)]:[mask-image:var(--avatar-notch-mask)]\",\n)\n\nexport type AvatarGroupOrientation = \"horizontal\" | \"vertical\"\n\n/**\n * Everything that depends on which way the group stacks: its flex axis,\n * every avatar but the first pulled back over the previous one by\n * `--avatar-o` px along that axis, and where the next avatar sits as the unit\n * vector `--avatar-dx`/`--avatar-dy` that AVATAR_GROUP_NOTCH and\n * AvatarNotchMaskDefs read. Horizontal goes inline-forward, so `1, 0`,\n * mirrored to `-1, 0` in rtl. Vertical goes down, `0, 1`, which `dir` doesn't\n * affect.\n */\nconst AVATAR_GROUP_ORIENTATION: Record<AvatarGroupOrientation, string> = {\n horizontal: cn(\n \"flex items-center\",\n \"[&>*:not(:first-child)]:[margin-inline-start:calc(var(--avatar-o)*-1px)]\",\n \"[--avatar-dx:1] rtl:[--avatar-dx:-1] [--avatar-dy:0]\",\n ),\n vertical: cn(\n \"flex flex-col items-center\",\n \"[&>*:not(:first-child)]:[margin-block-start:calc(var(--avatar-o)*-1px)]\",\n \"[--avatar-dx:0] [--avatar-dy:1]\",\n ),\n}\n\nexport type AvatarGroupProps = HTMLArkProps<\"div\"> &\n WithTestId & {\n /** Overlap amount between avatars — larger sizes overlap by more. */\n spacing?: Size\n /** Stack direction — a row (default) or a top-to-bottom column. */\n orientation?: AvatarGroupOrientation\n }\n\nconst AvatarGroup = ({\n spacing = \"md\",\n orientation = \"horizontal\",\n className,\n style,\n testId,\n ...rest\n}: AvatarGroupProps) => (\n <ark.div\n data-orientation={orientation}\n className={cn(AVATAR_GROUP_ORIENTATION[orientation], AVATAR_GROUP_NOTCH, className)}\n style={{ ...avatarGroupSpacingStyle(spacing), ...style }}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\n/** `Avatar.Group` — see the doc comment above the `Avatar` component itself. */\nexport const Avatar = Object.assign(AvatarComponent, { Group: AvatarGroup })\n"]}
1
+ {"version":3,"sources":["../../../src/components/avatar/avatar.tsx"],"names":["ArkAvatar"],"mappings":";;;;;;;;AAwCA,IAAM,cAAA,GAAiB,GAAA;AAAA,EACrB;AAAA,IACE,2EAAA;AAAA,IACA,aAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUA,uCAAA;AAAA,IACA,+CAAA;AAAA,IACA,qDAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAUR,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,qDAAA;AAAA,QACJ,EAAA,EAAI,+CAAA;AAAA,QACJ,EAAA,EAAI,gDAAA;AAAA,QACJ,EAAA,EAAI,kDAAA;AAAA,QACJ,E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AAAA,EACA,QAAA,EAAU,EAAA;AAAA,IACR,4BAAA;AAAA,IACA,yEAAA;AAAA,IACA;AAAA;AAEJ,CAAA;AAUA,IAAM,cAAc,CAAC;AAAA,EACnB,OAAA,GAAU,IAAA;AAAA,EACV,WAAA,GAAc,YAAA;AAAA,EACd,SAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,GAAG;AACL,CAAA,qBACE,GAAA;AAAA,EAAC,GAAA,CAAI,GAAA;AAAA,EAAJ;AAAA,IACC,kBAAA,EAAkB,WAAA;AAAA,IAClB,WAAW,EAAA,CAAG,wBAAA,CAAyB,WAAW,CAAA,EAAG,oBAAoB,SAAS,CAAA;AAAA,IAClF,OAAO,EAAE,GAAG,wBAAwB,OAAO,CAAA,EAAG,GAAG,KAAA,EAAM;AAAA,IACtD,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,IAClC,GAAG;AAAA;AACN,CAAA;AAIK,IAAM,SAAS,MAAA,CAAO,MAAA,CAAO,iBAAiB,EAAE,KAAA,EAAO,aAAa","file":"index.js","sourcesContent":["\"use client\"\n\nimport { Avatar as ArkAvatar, ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { UserRound } from \"lucide-react\"\nimport { type ComponentProps, type CSSProperties, type ReactNode, useId } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\n/**\n * Avatar — circular (by default) image with an automatic fallback. Renders\n * `src` once it loads; falls back to `children` (custom initials or an icon)\n * when there's no image or it fails to load, or to initials/name derived from\n * `name`, or finally to a generic person icon. Wraps Ark's `Avatar` machine,\n * which already tracks image-load state (`loading → loaded/error`) — no\n * bespoke `onError` handling needed here.\n *\n * <Avatar src={user.avatarUrl} name={user.fullName} color=\"brand\" />\n *\n * `color=\"name\"` / `color=\"initials\"` deterministically hash `name` (or its\n * derived initials) into a pick from `palette` instead of a literal `Color` —\n * a stable, no-config accent per person. `display` independently controls\n * what the computed fallback shows: `\"initials\"` (default, two letters) or\n * `\"name\"` (a single leading letter — a full name would overflow the circle).\n *\n * No `asChild` — same reasoning as `Skeleton`: `children` is already\n * repurposed as fallback content, which conflicts with Ark's \"single child to\n * render as\" requirement for polymorphism.\n *\n * `Avatar.Group` overlaps a row — or, with `orientation=\"vertical\"`, a\n * column — of standalone `Avatar`s (Mantine-style stacked avatars),\n * punching a transparent notch into each one where its successor overlaps\n * it — true see-through separation instead of a painted border, so it reads\n * correctly over any page background. It's pure CSS\n * layout, like `ButtonGroup` — it doesn't resize or restyle its children, so\n * set `size`/`color` per `Avatar`.\n */\nconst avatarVariants = cva(\n [\n \"relative inline-flex shrink-0 items-center justify-center overflow-hidden\",\n \"select-none\",\n // Neutral gray by default; a `data-color` tint overrides it with the\n // palette's soft surface + text — the same treatment Pill and Badge's\n // `light` variant use. No variant axis: an avatar is always this one\n // soft-surface look, just optionally tinted. No border either: it used\n // to be border-(--c-soft) once tinted, i.e. always the exact same color\n // as its own background — invisible for every `color`, visible only for\n // the untinted default (border-brand-900/20 against bg-gray-light-100,\n // two different colors) — so whether an avatar showed a border at all\n // used to depend on `color`, not on any actual design intent.\n \"bg-gray-light-100 text-gray-light-700\",\n \"dark:bg-gray-dark-800 dark:text-gray-dark-300\",\n \"data-color:bg-(--c-soft) data-color:text-(--c-text)\",\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0\",\n ],\n {\n variants: {\n // `--avatar-r` (this avatar's own radius, in px, as a unitless number)\n // rides along with `size` — it's read by `Avatar.Group`'s notch/margin\n // CSS (see AVATAR_GROUP_NOTCH below) so the notch always matches\n // *this* avatar's actual rendered radius, not whatever radius\n // `Avatar.Group`'s own `spacing` happens to assume. `spacing` only\n // ever controls `--avatar-o` (the overlap amount) — a mismatched\n // `size`/`spacing` pairing (e.g. `md` avatars in a `spacing=\"xs\"`\n // group) still gets a correctly-sized notch, just more or less\n // overlap.\n size: {\n xs: \"size-6 text-[10px] [&_svg]:size-3.5 [--avatar-r:12]\",\n sm: \"size-8 text-xs [&_svg]:size-4 [--avatar-r:16]\",\n md: \"size-10 text-sm [&_svg]:size-5 [--avatar-r:20]\",\n lg: \"size-12 text-base [&_svg]:size-6 [--avatar-r:24]\",\n xl: \"size-16 text-lg [&_svg]:size-8 [--avatar-r:32]\",\n },\n // `--avatar-corner-r` also rides along with `radius`: it's the other\n // half of `Avatar.Group`'s notch for a non-circular avatar (see\n // AVATAR_GROUP_NOTCH and AvatarNotchMaskDefs below). A gradient can\n // only cut a circle/ellipse, never a true rounded rect, so\n // `radius=\"full\"` keeps using a mask-image ellipse (the shape it\n // actually needs), but every other radius instead cuts a real\n // rounded-rect *hole* via a per-instance SVG `<mask>`, using this\n // avatar's own actual radius token (`theme.css`'s\n // `--radius-xs`..`--radius-xl`, in px) as that hole's corner radius.\n // `\"full\"` deliberately has no `--avatar-corner-r` and never renders\n // that SVG mask at all — its radius (50% of the box) isn't a fixed px\n // value the way the others are, so there's nothing meaningful to plug\n // in here; the mask-image ellipse already handles it correctly.\n radius: {\n xs: \"rounded-xs [--avatar-corner-r:4]\",\n sm: \"rounded-sm [--avatar-corner-r:6]\",\n md: \"rounded-md [--avatar-corner-r:8]\",\n lg: \"rounded-lg [--avatar-corner-r:10]\",\n xl: \"rounded-xl [--avatar-corner-r:12]\",\n full: \"rounded-full\",\n },\n },\n defaultVariants: {\n size: \"md\",\n // Unlike ThemeIcon (a square icon surface), an avatar reads as\n // circular by default — matching Mantine's own default.\n radius: \"full\",\n },\n },\n)\n\nexport type AvatarSize = NonNullable<VariantProps<typeof avatarVariants>[\"size\"]>\nexport type AvatarRadius = NonNullable<VariantProps<typeof avatarVariants>[\"radius\"]>\n\n/** Shared by `color`'s auto-computed modes and `display`'s content mode. */\nexport type AvatarNameMode = \"name\" | \"initials\"\n\n/**\n * Default hash pool for `color=\"name\"` / `color=\"initials\"`. Excludes\n * `brand` (the kit's own primary/CTA identity color — auto-tinting a user\n * avatar with it would read as \"official\") and `neutral` (muted, and a\n * composed-not-scaled tone per `lib/colors.ts`, so it would just look\n * washed-out for some names). Exported so a consumer can extend it,\n * e.g. `palette={[...AVATAR_PALETTE, \"brand\"]}`.\n */\nexport const AVATAR_PALETTE: Color[] = [\n \"red\",\n \"orange\",\n \"yellow\",\n \"green\",\n \"teal\",\n \"cyan\",\n \"blue\",\n \"purple\",\n \"pink\",\n]\n\ntype AvatarClassNames = {\n root?: string\n image?: string\n fallback?: string\n}\n\nexport type AvatarProps = Omit<ComponentProps<typeof ArkAvatar.Root>, \"color\" | \"asChild\"> &\n VariantProps<typeof avatarVariants> &\n WithTestId & {\n /** Image source. Falls back automatically when unset or on load error. */\n src?: string\n /** Alt text for the image. */\n alt?: string\n /**\n * Accent palette. `\"name\"` / `\"initials\"` deterministically hash `name`\n * (or its derived initials) into a pick from `palette` instead of a\n * literal color. Re-exported as `Color` from `@42/ui-react`.\n */\n color?: Color | AvatarNameMode\n /**\n * Colors eligible for `color=\"name\"` / `color=\"initials\"`'s hash.\n * Ignored otherwise. Defaults to `AVATAR_PALETTE`.\n */\n palette?: Color[]\n /**\n * Full name to derive initials/color from (e.g. \"Ada Lovelace\" → \"AL\")\n * when there's no image and no explicit `children`. Explicit `children`\n * always takes precedence over `name`.\n */\n name?: string\n /**\n * What the computed fallback shows: `\"initials\"` (default, two letters)\n * or `\"name\"` (a single leading letter of `name`).\n */\n display?: AvatarNameMode\n /**\n * Fallback content — shown until the image loads, or permanently when\n * there's no `src`. Overrides the `name`/`display`-derived content.\n */\n children?: ReactNode\n classNames?: AvatarClassNames\n }\n\n/** First + last initial for a multi-word name; first two chars for a single word. */\nconst getInitials = (name: string): string => {\n const parts = name.trim().split(/\\s+/).filter(Boolean)\n const [first, ...rest] = parts\n if (!first) return \"\"\n const last = rest.at(-1)\n return (last ? first.charAt(0) + last.charAt(0) : first.slice(0, 2)).toUpperCase()\n}\n\n/** Single leading letter — `display=\"name\"`'s content; a full name would overflow the circle. */\nconst getLeadingLetter = (name: string): string => name.trim().charAt(0).toUpperCase()\n\n/** Deterministic string hash (Java-style polynomial rolling hash). */\nconst hashString = (input: string): number => {\n let hash = 0\n for (let i = 0; i < input.length; i++) hash = (hash * 31 + input.charCodeAt(i)) | 0\n return Math.abs(hash)\n}\n\nconst pickColor = (input: string, pool: Color[]): Color | undefined =>\n input && pool.length > 0 ? pool[hashString(input) % pool.length] : undefined\n\nconst isAvatarNameMode = (value: unknown): value is AvatarNameMode =>\n value === \"name\" || value === \"initials\"\n\n/**\n * A per-instance SVG `<mask>` cutting `Avatar.Group`'s notch as a true\n * rounded-rect hole for any non-circular `radius` — see AVATAR_GROUP_NOTCH's\n * own doc comment for why a hole (not a trim/clip) is what's actually needed\n * here. Rendered *inside this avatar itself* — not shared, not on\n * `Avatar.Group` — because an SVG `<mask>`'s content resolves `var()` from\n * wherever the `<mask>` element itself sits in the DOM, not from whatever\n * element references it via `mask: url(#id)` (confirmed empirically: a single\n * shared mask read the *ancestor's* `--avatar-r`, not each differently-sized\n * avatar's own). Nesting a practically-free per-instance one inside each\n * avatar instead means it naturally inherits *that* avatar's own\n * `--avatar-r`/`--avatar-corner-r` and the group's `--avatar-o` and\n * `--avatar-dx`/`--avatar-dy`, the same way any of this avatar's own CSS\n * already does.\n *\n * The hole matches the *next* avatar's box (same-size neighbor assumed),\n * grown by a ~2px gap on every side. It sits one step of `2r - o` (diameter\n * minus overlap) along the group's direction vector `(dx, dy)` — so a single\n * mask covers ltr (`1, 0`), rtl (`-1, 0`) and vertical (`0, 1`) stacks.\n *\n * `size-0 absolute` keeps it out of layout entirely. The `<mask>` element's\n * own `x`/`y`/`width`/`height` (not the same as the hole `<rect>`'s) opt out\n * of the CSS default `objectBoundingBox` region (`-10% -10% 120% 120%` of\n * the avatar's own box) — too small to contain a hole that can extend well\n * beyond the box — for a `userSpaceOnUse` region large enough it never\n * actually clips anything; all real clipping is left to the masked avatar's\n * own box, same as everywhere else in this file.\n */\nconst AvatarNotchMaskDefs = ({ id }: { id: string }) => (\n <svg aria-hidden=\"true\" className=\"absolute size-0\">\n <defs>\n <mask id={id} maskUnits=\"userSpaceOnUse\" x={-1000} y={-1000} width={2000} height={2000}>\n <rect x={-1000} y={-1000} width={2000} height={2000} fill=\"white\" />\n <rect\n style={\n {\n x: \"calc((var(--avatar-dx) * (2 * var(--avatar-r) - var(--avatar-o)) - 2) * 1px)\",\n y: \"calc((var(--avatar-dy) * (2 * var(--avatar-r) - var(--avatar-o)) - 2) * 1px)\",\n width: \"calc((2 * var(--avatar-r) + 4) * 1px)\",\n height: \"calc((2 * var(--avatar-r) + 4) * 1px)\",\n rx: \"calc((var(--avatar-corner-r) + 2) * 1px)\",\n } as CSSProperties\n }\n fill=\"black\"\n />\n </mask>\n </defs>\n </svg>\n)\n\nconst AvatarComponent = ({\n src,\n alt,\n size,\n radius,\n color,\n palette = AVATAR_PALETTE,\n name,\n display = \"initials\",\n children,\n className,\n classNames,\n style,\n testId,\n ...rest\n}: AvatarProps) => {\n const resolvedColor = isAvatarNameMode(color)\n ? pickColor(color === \"name\" ? (name ?? \"\") : name ? getInitials(name) : \"\", palette)\n : color\n\n const computed = name ? (display === \"name\" ? getLeadingLetter(name) : getInitials(name)) : \"\"\n const fallback = children ?? (computed || <UserRound />)\n\n // `radius=\"full\"` (the default) uses AVATAR_GROUP_NOTCH's mask-image\n // circle instead — no rounded-rect hole to build, no id needed.\n const needsNotchMask = (radius ?? \"full\") !== \"full\"\n const maskId = useId().replace(/:/g, \"\")\n const notchMaskStyle: CSSProperties = needsNotchMask\n ? ({ \"--avatar-notch-mask\": `url(#${maskId})` } as CSSProperties)\n : {}\n\n return (\n <ArkAvatar.Root\n data-color={resolvedColor}\n className={cn(avatarVariants({ size, radius }), className, classNames?.root)}\n style={{ ...notchMaskStyle, ...style }}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n {needsNotchMask && <AvatarNotchMaskDefs id={maskId} />}\n {src && (\n <ArkAvatar.Image\n src={src}\n alt={alt}\n className={cn(\"size-full object-cover\", classNames?.image)}\n />\n )}\n <ArkAvatar.Fallback\n className={cn(\n \"flex items-center justify-center font-medium leading-none\",\n classNames?.fallback,\n )}\n >\n {fallback}\n </ArkAvatar.Fallback>\n </ArkAvatar.Root>\n )\n}\n\n/**\n * Overlap magnitude (px) per `Size` key — larger sizes overlap by more. The\n * only number this whole margin/notch mechanism hardcodes at the group\n * level; `--avatar-r` (each avatar's own radius) instead rides along with\n * `Avatar`'s own `size` variant above, so the notch always matches what's\n * actually rendered even when a group's `spacing` and its avatars' `size`\n * don't happen to match (`Avatar.Group` doesn't restyle children, so\n * nothing stops that).\n */\nconst AVATAR_GROUP_OVERLAP_PX: Record<Size, number> = { xs: 8, sm: 10, md: 12, lg: 14, xl: 16 }\n\n/**\n * `--avatar-o` is a unitless number, not a length — `calc()` casts a\n * unitless custom property into a real length/percentage by multiplying it\n * by `1px`/`1%` (see AVATAR_GROUP_ORIENTATION's `* -1px` and AVATAR_GROUP_NOTCH's\n * `* 1%` below), the same trick that keeps those two classes static text\n * instead of needing a copy per `spacing` value. Set here on the group root\n * and read by children via ordinary CSS custom-property inheritance —\n * `--avatar-r` is deliberately *not* set here (see above).\n */\nconst avatarGroupSpacingStyle = (spacing: Size): CSSProperties =>\n ({ \"--avatar-o\": AVATAR_GROUP_OVERLAP_PX[spacing] }) as CSSProperties\n\n/**\n * Two mutually-exclusive ways to notch every avatar but the last, selected\n * purely by the presence of the `rounded-full` class (set by `radius`\n * above) — `:not(.rounded-full)` and `.rounded-full` never both match the\n * same element, so exactly one of these ever applies to a given avatar:\n *\n * - `.rounded-full` (the default): a `mask-image` circle, unchanged from\n * before. `ellipse RX RY` (not `circle`, whose gradient radius can't be a\n * percentage) with equal `%` radii on a square avatar box renders as a\n * true circle, centered on the next avatar (assuming a same-size\n * neighbor — the same \"uniform stack\" assumption the overlap margin\n * already makes) with a radius a bit larger than that neighbor's own so\n * a thin ring of true transparency survives around it. The radius is\n * `calc((50 + 100 / var(--avatar-r)) * 1%)` — 50% is *this* avatar's own\n * radius (from its own `size` variant, not from the group's `spacing`,\n * so the notch stays correctly sized even if `spacing` and `size` don't\n * match), `100 / r` a ~2px gap expressed as a percentage of its\n * diameter. Must be a pure percentage, not `calc(50% + 2px)` — browsers\n * reject a `%`+length `calc()` as a gradient's explicit circle/ellipse\n * size (unlike almost everywhere else `<length-percentage>` is\n * accepted), so an earlier draft mixing units here silently produced an\n * invalid `mask-image` that just got dropped, with no visible error.\n *\n * - every other `radius`: a `mask-image: var(--avatar-notch-mask)` instead —\n * a real rounded-rect *hole*, cut by a per-instance SVG `<mask>` this\n * avatar renders for itself (see AvatarNotchMaskDefs above for the full\n * rationale). A CSS gradient can only cut a circle/ellipse (hence the\n * circle case above visibly curving away from a rounded-square avatar's\n * flat edges — a corner-shaped gap instead of an edge-shaped one), and\n * `clip-path` can only *keep* one shape, never subtract one — neither can\n * express a rounded-rect hole directly. An SVG `<mask>` can: the hole\n * `<rect>` is sized/positioned to match the *next* avatar's own box\n * (assuming a same-size neighbor, the same \"uniform stack\" assumption the\n * overlap margin already makes) expanded outward by a ~2px gap in every\n * direction, with `rx`/`ry` = that neighbor's own corner radius + the\n * same gap — so the hole's boundary is a true parallel offset of the next\n * avatar's actual silhouette, not an approximation of it. (An earlier\n * attempt just trimmed *this* avatar's own trailing edge with\n * `clip-path: inset(... round ...)` — cheaper, no SVG needed — but that\n * can only shape *this* avatar's own edge, blind to whatever curve the\n * *next* avatar's corner actually traces at each height, so the gap\n * between them didn't follow it: either two independently-rounded edges\n * compounding into an oversized gap at the corner, or, if this avatar's\n * own edge was flattened to avoid that, a straight cut that stayed a\n * constant distance from the next avatar's *box* while that avatar's\n * *rendered* corner receded away from it — reading as an inconsistent gap\n * width rather than a clean ring. Only shaping the hole to match the\n * neighbor's real silhouette avoids both failure modes.)\n *\n * `radius=\"full\"` deliberately isn't handled this way — see the `radius`\n * variant's own comment for why.\n *\n * Neither branch hardcodes a direction. Both place the hole one step of\n * `2r - o` (diameter minus overlap) along the group's direction vector\n * `--avatar-dx`/`--avatar-dy` (see AVATAR_GROUP_ORIENTATION below) — for the\n * circle, `50% + d * (100 - o / (2r) * 100)%` on each axis, i.e. `150 - …`\n * one way and `… - 50` the other. Physical positions (`at X% Y%`, the hole's\n * `x`/`y`) don't flip with `dir` on their own the way the margin's logical\n * `margin-inline-start` does, so rtl flips the vector instead of duplicating\n * every rule with an `rtl:` copy.\n *\n * Both — like AVATAR_GROUP_ORIENTATION's classes below — have to be static string\n * literals, not built from a template at runtime: Tailwind's build only\n * generates CSS for class names it can find verbatim in the source text, so\n * an interpolated/computed class name here would silently produce no\n * styles either, even if every interpolated piece were itself constant.\n */\nconst AVATAR_GROUP_NOTCH = cn(\n \"[&>*:not(:last-child).rounded-full]:[mask-image:radial-gradient(ellipse_calc((50_+_100_/_var(--avatar-r))_*_1%)_calc((50_+_100_/_var(--avatar-r))_*_1%)_at_calc((50_+_var(--avatar-dx)_*_(100_-_var(--avatar-o)_/_(2_*_var(--avatar-r))_*_100))_*_1%)_calc((50_+_var(--avatar-dy)_*_(100_-_var(--avatar-o)_/_(2_*_var(--avatar-r))_*_100))_*_1%),transparent_100%,black_100%)]\",\n \"[&>*:not(:last-child):not(.rounded-full)]:[mask-image:var(--avatar-notch-mask)]\",\n)\n\nexport type AvatarGroupOrientation = \"horizontal\" | \"vertical\"\n\n/**\n * Everything that depends on which way the group stacks: its flex axis,\n * every avatar but the first pulled back over the previous one by\n * `--avatar-o` px along that axis, and where the next avatar sits as the unit\n * vector `--avatar-dx`/`--avatar-dy` that AVATAR_GROUP_NOTCH and\n * AvatarNotchMaskDefs read. Horizontal goes inline-forward, so `1, 0`,\n * mirrored to `-1, 0` in rtl. Vertical goes down, `0, 1`, which `dir` doesn't\n * affect.\n */\nconst AVATAR_GROUP_ORIENTATION: Record<AvatarGroupOrientation, string> = {\n horizontal: cn(\n \"flex items-center\",\n \"[&>*:not(:first-child)]:[margin-inline-start:calc(var(--avatar-o)*-1px)]\",\n \"[--avatar-dx:1] rtl:[--avatar-dx:-1] [--avatar-dy:0]\",\n ),\n vertical: cn(\n \"flex flex-col items-center\",\n \"[&>*:not(:first-child)]:[margin-block-start:calc(var(--avatar-o)*-1px)]\",\n \"[--avatar-dx:0] [--avatar-dy:1]\",\n ),\n}\n\nexport type AvatarGroupProps = HTMLArkProps<\"div\"> &\n WithTestId & {\n /** Overlap amount between avatars — larger sizes overlap by more. */\n spacing?: Size\n /** Stack direction — a row (default) or a top-to-bottom column. */\n orientation?: AvatarGroupOrientation\n }\n\nconst AvatarGroup = ({\n spacing = \"md\",\n orientation = \"horizontal\",\n className,\n style,\n testId,\n ...rest\n}: AvatarGroupProps) => (\n <ark.div\n data-orientation={orientation}\n className={cn(AVATAR_GROUP_ORIENTATION[orientation], AVATAR_GROUP_NOTCH, className)}\n style={{ ...avatarGroupSpacingStyle(spacing), ...style }}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\n/** `Avatar.Group` — see the doc comment above the `Avatar` component itself. */\nexport const Avatar = Object.assign(AvatarComponent, { Group: AvatarGroup })\n"]}
@@ -6,7 +6,7 @@ import type { WithTestId } from "../../lib/test-id";
6
6
  /**
7
7
  * Ordered categorical palette for multi-series charts, built from `COLORS`
8
8
  * (`lib/colors.ts`) minus `brand` (kept free for `color`'s own single-series
9
- * identity) and `gray`/`neutral` (already the chart's own chrome color, via
9
+ * identity) and `neutral` (already the chart's own chrome color, via
10
10
  * `styles.css`).
11
11
  *
12
12
  * The first four — `blue`/`green`/`red`/`pink` — are the only 4-combination
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { COLORS } from '../../chunk-JBVFWSRQ.js';
2
+ import { COLORS } from '../../chunk-VIYVN4WF.js';
3
3
  import { props } from '../../chunk-WYCMIIRR.js';
4
4
  import { cn } from '../../chunk-QP4I37PA.js';
5
5
  import { Chart as Chart$2 } from '@tanstack/charts/react';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AAAA,MACC,WAAA,EAAU,MAAA;AAAA,MACV,YAAA,EAAY,SAAA;AAAA,MACZ,SAAA,EAAW,EAAA,CAAG,YAAA,EAAc,SAAS,CAAA;AAAA,MACrC,KAAA,EAAO,EAAE,GAAG,YAAA,EAAc,GAAG,KAAA,EAAM;AAAA,MAClC,GAAG,KAAA,CAAM,EAAE,aAAA,EAAe,QAAQ,CAAA;AAAA,MAElC,QAAA,EAAA,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAMC,GAAA;AAAA,UAACA,OAAA;AAAA,UAAA;AAAA,YACC,QAAA;AAAA,YACA,QAAA;AAAA,YACC,GAAG;AAAA;AAAA;AACN,0BAEA,GAAA,CAACC,OAAA,EAAA,EAAc,SAAA,EAAsB,QAAA,EAAqB,GAAG,IAAA,EAAM;AAAA;AAAA,GAEvE;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport type { ChartValue } from \"@tanstack/charts\"\nimport {\n Chart as TanStackChart,\n type ChartProps as TanStackChartProps,\n} from \"@tanstack/charts/react\"\nimport {\n Chart as TanStackRendererChart,\n type ChartProps as TanStackRendererChartProps,\n} from \"@tanstack/charts/react/core\"\nimport type { CSSProperties } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport { COLORS, type Color } from \"../../lib/colors\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\nconst KNOWN_COLORS: readonly string[] = COLORS\n\n/**\n * Resolves a kit `Color` token to its solid CSS value: `var(--color-<name>-500)`\n * for a known palette color — the same step `--c-solid` itself resolves to in\n * both light and dark (see `colors.css`; the \"solid\" slot doesn't shift with\n * the theme) — or the string verbatim for a custom color.\n */\nconst resolveChartColor = (color: Color): string =>\n KNOWN_COLORS.includes(color) ? `var(--color-${color}-500)` : color\n\n/**\n * Ordered categorical palette for multi-series charts, built from `COLORS`\n * (`lib/colors.ts`) minus `brand` (kept free for `color`'s own single-series\n * identity) and `gray`/`neutral` (already the chart's own chrome color, via\n * `styles.css`).\n *\n * The first four — `blue`/`green`/`red`/`pink` — are the only 4-combination\n * of this kit's own hues that clears every check in the dataviz skill's\n * `validate_palette.js` (lightness band, CVD Delta E, and normal-vision\n * separation, all-pairs, not just adjacent) without relying on a specific\n * order. Every other pairing among the remaining five hues fails outright at\n * the \"solid\" (500) step this palette resolves to — `red`/`orange` and\n * `teal`/`green` read as near-duplicates even to normal color vision, and\n * `purple`/`blue` and `cyan`/`pink` fail the colorblind-safety floor. Rather\n * than drop those five hues from a consumer's options entirely, they're\n * appended after the validated four: safe to reach for a 5th+ series, same\n * as this kit accepts elsewhere, paired with the legend/tooltip (TanStack's\n * own default, \"secondary encoding\" in the skill's terms) every multi-series\n * example in the docs already ships.\n */\nexport const CHART_PALETTE: Color[] = [\n \"blue\",\n \"green\",\n \"red\",\n \"pink\",\n \"orange\",\n \"purple\",\n \"teal\",\n \"yellow\",\n \"cyan\",\n]\n\n/**\n * Resolves an ordered `Color[]` into literal CSS color values — for a\n * consumer building an explicit color scale themselves, e.g.\n * `scaleOrdinal().range(chartColors())`, or for `Chart`'s own `color`/\n * `colors` props (below), which build the `--ts-chart-N` custom properties\n * TanStack Charts' own default categorical scale already reads (see\n * `defaultChartTheme.palette` in `@tanstack/charts`) from this same output.\n * Defaults to `CHART_PALETTE`.\n */\nexport function chartColors(colors: Color[] = CHART_PALETTE): string[] {\n return colors.map(resolveChartColor)\n}\n\nexport type ChartProps<\n TDatum = unknown,\n TXValue extends ChartValue = ChartValue,\n TYValue extends ChartValue = ChartValue,\n> = Omit<TanStackChartProps<TDatum, TXValue, TYValue>, \"renderSvg\"> &\n WithTestId & {\n /**\n * Single accent for a one-series chart: sets `data-color` and TanStack's\n * first categorical slot (`--ts-chart-1`) to this color. Ignored for the\n * palette slots when `colors` is also given (still sets `data-color`, if\n * `colors` isn't a multi-entry array).\n */\n color?: Color\n /**\n * Ordered palette for a multi-series chart — see `CHART_PALETTE`/\n * `chartColors`. Sets `--ts-chart-1` through `--ts-chart-N`, one per\n * entry, for TanStack's own default categorical color scale to pick up\n * with zero changes to how the chart's `definition` builds its scales.\n * Beyond `--ts-chart-6`, only a custom `scaleOrdinal().range(...)` (see\n * `chartColors`) actually consumes the extra slots — TanStack's own\n * implicit default only cycles through six.\n */\n colors?: Color[]\n /**\n * Plain SVG paint function — TanStack's default renderer if omitted.\n * Ignored when `renderer` (below) is given.\n */\n renderSvg?: TanStackChartProps<TDatum, TXValue, TYValue>[\"renderSvg\"]\n /**\n * A full custom renderer, e.g. `motion({...})` from\n * `@tanstack/charts/motion` — needed for continuous focus/crosshair\n * motion between points. TanStack's default SVG renderer paints each\n * frame at its target position with no interpolation; a mark's own\n * `motion` option alone does nothing without this. Routes through\n * `@tanstack/charts/react/core`'s lower-level `Chart` instead of the\n * plain one when given (its own prop surface has `renderer`, not\n * `renderSvg`, so the two are mutually exclusive).\n */\n renderer?: TanStackRendererChartProps<TDatum, TXValue, TYValue>[\"renderer\"]\n }\n\n/**\n * Chart — a light theme wrapper around TanStack Charts' own `<Chart>`\n * (`@tanstack/charts/react`), an optional peer dependency. TanStack owns the\n * grammar (`defineChart`, marks, scales — imported directly from\n * `@tanstack/charts`, never re-exported here) and the SVG rendering; this\n * wrapper only makes it look native to the kit:\n *\n * - Chrome (axis/grid/frame/legend/crosshair) already renders through\n * inherited `currentColor` — `styles.css` sets `color` on this root,\n * gated by `[data-theme=\"dark\"]` like every other dark-mode rule in the\n * kit, so chrome tracks the kit's own theme toggle rather than the OS\n * `prefers-color-scheme` TanStack's un-themed default would otherwise\n * follow via its `Canvas`/`CanvasText` system-color fallbacks.\n * - The DOM tooltip surface/text/shadow/border and its \"active row\"\n * highlight theme through `--ts-chart-tooltip-*` / `--ts-chart-tooltip-\n * active-row-*`, also set in `styles.css`.\n * - `color`/`colors` (above) theme the categorical series palette via\n * `--ts-chart-N`, TanStack's own default color-scale slots.\n *\n * Not routed through Ark's `ark.*` factory (no `asChild`): TanStack's\n * `<Chart>` owns its entire internal DOM/SVG tree end to end, so there's no\n * \"render as\" swap for `asChild` to meaningfully do here — the same\n * rationale already documented on `Skeleton`/`Collapse` for components that\n * fully own their own rendering.\n *\n * `testId`/`data-color` land on this wrapping root, not on TanStack's own\n * `<Chart>` — its prop surface is a closed, typed interface (only\n * `className`/`style` reach its DOM), so this root is the only element that\n * can carry them.\n */\nexport function Chart<\n TDatum,\n TXValue extends ChartValue = ChartValue,\n TYValue extends ChartValue = ChartValue,\n>({\n color,\n colors,\n className,\n style,\n testId,\n renderer,\n renderSvg,\n onRender,\n ...rest\n}: ChartProps<TDatum, TXValue, TYValue>) {\n const palette = colors ?? (color ? [color] : undefined)\n const paletteStyle: CSSProperties | undefined = palette\n ? (Object.fromEntries(\n chartColors(palette).map((value, index) => [`--ts-chart-${index + 1}`, value]),\n ) as CSSProperties)\n : undefined\n const dataColor = color ?? (colors?.length === 1 ? colors[0] : undefined)\n\n return (\n <div\n data-part=\"root\"\n data-color={dataColor}\n className={cn(\"chart-root\", className)}\n style={{ ...paletteStyle, ...style }}\n {...props({ \"data-testid\": testId })}\n >\n {renderer ? (\n // `onRender`'s context is renderer-agnostic here (no guaranteed\n // `.svg`, unlike the plain SVG renderer below) — a real narrowing,\n // not a cast of convenience; `renderer` callers reach for `onRender`\n // rarely enough that re-typing the whole prop for this one branch\n // isn't worth it.\n <TanStackRendererChart\n renderer={renderer}\n onRender={onRender as TanStackRendererChartProps<TDatum, TXValue, TYValue>[\"onRender\"]}\n {...rest}\n />\n ) : (\n <TanStackChart renderSvg={renderSvg} onRender={onRender} {...rest} />\n )}\n </div>\n )\n}\n"]}
1
+ {"version":3,"sources":["../../../src/components/chart/chart.tsx"],"names":["TanStackRendererChart","TanStackChart"],"mappings":";;;;;;;AAiBA,IAAM,YAAA,GAAkC,MAAA;AAQxC,IAAM,iBAAA,GAAoB,CAAC,KAAA,KACzB,YAAA,CAAa,SAAS,KAAK,CAAA,GAAI,CAAA,YAAA,EAAe,KAAK,CAAA,KAAA,CAAA,GAAU,KAAA;AAsB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,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAMC,GAAA;AAAA,UAACA,OAAA;AAAA,UAAA;AAAA,YACC,QAAA;AAAA,YACA,QAAA;AAAA,YACC,GAAG;AAAA;AAAA;AACN,0BAEA,GAAA,CAACC,OAAA,EAAA,EAAc,SAAA,EAAsB,QAAA,EAAqB,GAAG,IAAA,EAAM;AAAA;AAAA,GAEvE;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport type { ChartValue } from \"@tanstack/charts\"\nimport {\n Chart as TanStackChart,\n type ChartProps as TanStackChartProps,\n} from \"@tanstack/charts/react\"\nimport {\n Chart as TanStackRendererChart,\n type ChartProps as TanStackRendererChartProps,\n} from \"@tanstack/charts/react/core\"\nimport type { CSSProperties } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport { COLORS, type Color } from \"../../lib/colors\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\n\nconst KNOWN_COLORS: readonly string[] = COLORS\n\n/**\n * Resolves a kit `Color` token to its solid CSS value: `var(--color-<name>-500)`\n * for a known palette color — the same step `--c-solid` itself resolves to in\n * both light and dark (see `colors.css`; the \"solid\" slot doesn't shift with\n * the theme) — or the string verbatim for a custom color.\n */\nconst resolveChartColor = (color: Color): string =>\n KNOWN_COLORS.includes(color) ? `var(--color-${color}-500)` : color\n\n/**\n * Ordered categorical palette for multi-series charts, built from `COLORS`\n * (`lib/colors.ts`) minus `brand` (kept free for `color`'s own single-series\n * identity) and `neutral` (already the chart's own chrome color, via\n * `styles.css`).\n *\n * The first four — `blue`/`green`/`red`/`pink` — are the only 4-combination\n * of this kit's own hues that clears every check in the dataviz skill's\n * `validate_palette.js` (lightness band, CVD Delta E, and normal-vision\n * separation, all-pairs, not just adjacent) without relying on a specific\n * order. Every other pairing among the remaining five hues fails outright at\n * the \"solid\" (500) step this palette resolves to — `red`/`orange` and\n * `teal`/`green` read as near-duplicates even to normal color vision, and\n * `purple`/`blue` and `cyan`/`pink` fail the colorblind-safety floor. Rather\n * than drop those five hues from a consumer's options entirely, they're\n * appended after the validated four: safe to reach for a 5th+ series, same\n * as this kit accepts elsewhere, paired with the legend/tooltip (TanStack's\n * own default, \"secondary encoding\" in the skill's terms) every multi-series\n * example in the docs already ships.\n */\nexport const CHART_PALETTE: Color[] = [\n \"blue\",\n \"green\",\n \"red\",\n \"pink\",\n \"orange\",\n \"purple\",\n \"teal\",\n \"yellow\",\n \"cyan\",\n]\n\n/**\n * Resolves an ordered `Color[]` into literal CSS color values — for a\n * consumer building an explicit color scale themselves, e.g.\n * `scaleOrdinal().range(chartColors())`, or for `Chart`'s own `color`/\n * `colors` props (below), which build the `--ts-chart-N` custom properties\n * TanStack Charts' own default categorical scale already reads (see\n * `defaultChartTheme.palette` in `@tanstack/charts`) from this same output.\n * Defaults to `CHART_PALETTE`.\n */\nexport function chartColors(colors: Color[] = CHART_PALETTE): string[] {\n return colors.map(resolveChartColor)\n}\n\nexport type ChartProps<\n TDatum = unknown,\n TXValue extends ChartValue = ChartValue,\n TYValue extends ChartValue = ChartValue,\n> = Omit<TanStackChartProps<TDatum, TXValue, TYValue>, \"renderSvg\"> &\n WithTestId & {\n /**\n * Single accent for a one-series chart: sets `data-color` and TanStack's\n * first categorical slot (`--ts-chart-1`) to this color. Ignored for the\n * palette slots when `colors` is also given (still sets `data-color`, if\n * `colors` isn't a multi-entry array).\n */\n color?: Color\n /**\n * Ordered palette for a multi-series chart — see `CHART_PALETTE`/\n * `chartColors`. Sets `--ts-chart-1` through `--ts-chart-N`, one per\n * entry, for TanStack's own default categorical color scale to pick up\n * with zero changes to how the chart's `definition` builds its scales.\n * Beyond `--ts-chart-6`, only a custom `scaleOrdinal().range(...)` (see\n * `chartColors`) actually consumes the extra slots — TanStack's own\n * implicit default only cycles through six.\n */\n colors?: Color[]\n /**\n * Plain SVG paint function — TanStack's default renderer if omitted.\n * Ignored when `renderer` (below) is given.\n */\n renderSvg?: TanStackChartProps<TDatum, TXValue, TYValue>[\"renderSvg\"]\n /**\n * A full custom renderer, e.g. `motion({...})` from\n * `@tanstack/charts/motion` — needed for continuous focus/crosshair\n * motion between points. TanStack's default SVG renderer paints each\n * frame at its target position with no interpolation; a mark's own\n * `motion` option alone does nothing without this. Routes through\n * `@tanstack/charts/react/core`'s lower-level `Chart` instead of the\n * plain one when given (its own prop surface has `renderer`, not\n * `renderSvg`, so the two are mutually exclusive).\n */\n renderer?: TanStackRendererChartProps<TDatum, TXValue, TYValue>[\"renderer\"]\n }\n\n/**\n * Chart — a light theme wrapper around TanStack Charts' own `<Chart>`\n * (`@tanstack/charts/react`), an optional peer dependency. TanStack owns the\n * grammar (`defineChart`, marks, scales — imported directly from\n * `@tanstack/charts`, never re-exported here) and the SVG rendering; this\n * wrapper only makes it look native to the kit:\n *\n * - Chrome (axis/grid/frame/legend/crosshair) already renders through\n * inherited `currentColor` — `styles.css` sets `color` on this root,\n * gated by `[data-theme=\"dark\"]` like every other dark-mode rule in the\n * kit, so chrome tracks the kit's own theme toggle rather than the OS\n * `prefers-color-scheme` TanStack's un-themed default would otherwise\n * follow via its `Canvas`/`CanvasText` system-color fallbacks.\n * - The DOM tooltip surface/text/shadow/border and its \"active row\"\n * highlight theme through `--ts-chart-tooltip-*` / `--ts-chart-tooltip-\n * active-row-*`, also set in `styles.css`.\n * - `color`/`colors` (above) theme the categorical series palette via\n * `--ts-chart-N`, TanStack's own default color-scale slots.\n *\n * Not routed through Ark's `ark.*` factory (no `asChild`): TanStack's\n * `<Chart>` owns its entire internal DOM/SVG tree end to end, so there's no\n * \"render as\" swap for `asChild` to meaningfully do here — the same\n * rationale already documented on `Skeleton`/`Collapse` for components that\n * fully own their own rendering.\n *\n * `testId`/`data-color` land on this wrapping root, not on TanStack's own\n * `<Chart>` — its prop surface is a closed, typed interface (only\n * `className`/`style` reach its DOM), so this root is the only element that\n * can carry them.\n */\nexport function Chart<\n TDatum,\n TXValue extends ChartValue = ChartValue,\n TYValue extends ChartValue = ChartValue,\n>({\n color,\n colors,\n className,\n style,\n testId,\n renderer,\n renderSvg,\n onRender,\n ...rest\n}: ChartProps<TDatum, TXValue, TYValue>) {\n const palette = colors ?? (color ? [color] : undefined)\n const paletteStyle: CSSProperties | undefined = palette\n ? (Object.fromEntries(\n chartColors(palette).map((value, index) => [`--ts-chart-${index + 1}`, value]),\n ) as CSSProperties)\n : undefined\n const dataColor = color ?? (colors?.length === 1 ? colors[0] : undefined)\n\n return (\n <div\n data-part=\"root\"\n data-color={dataColor}\n className={cn(\"chart-root\", className)}\n style={{ ...paletteStyle, ...style }}\n {...props({ \"data-testid\": testId })}\n >\n {renderer ? (\n // `onRender`'s context is renderer-agnostic here (no guaranteed\n // `.svg`, unlike the plain SVG renderer below) — a real narrowing,\n // not a cast of convenience; `renderer` callers reach for `onRender`\n // rarely enough that re-typing the whole prop for this one branch\n // isn't worth it.\n <TanStackRendererChart\n renderer={renderer}\n onRender={onRender as TanStackRendererChartProps<TDatum, TXValue, TYValue>[\"onRender\"]}\n {...rest}\n />\n ) : (\n <TanStackChart renderSvg={renderSvg} onRender={onRender} {...rest} />\n )}\n </div>\n )\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Mark } from '../../chunk-S53FHWNG.js';
1
+ import { Mark } from '../../chunk-YWRBG23W.js';
2
2
  import { props } from '../../chunk-WYCMIIRR.js';
3
3
  import { cn } from '../../chunk-QP4I37PA.js';
4
4
  import { ark } from '@ark-ui/react';
@@ -13,7 +13,7 @@ import { type DataTablePlaceholder, type DataTableView } from "./data-table-plac
13
13
  * fields from `meta.label`, and `"scroll"` (the default) stays the
14
14
  * SR-faithful path.
15
15
  */
16
- export declare function DataTableStackedRows<TEntity extends RowData>({ rows, view, error, refetching, empty, onRowClick, isInteractiveTarget, onRetry, table, className, skeletonRowCount, }: {
16
+ export declare function DataTableStackedRows<TEntity extends RowData>({ rows, view, error, refetching, empty, onRowClick, isRowClickIgnored, onRetry, table, className, skeletonRowCount, }: {
17
17
  rows: Row<TEntity>[];
18
18
  /** Resolved once in `DataTable` (see the `match` there) and passed down so
19
19
  * the `<table>` and stacked-card renderings never disagree on state. */
@@ -22,7 +22,7 @@ export declare function DataTableStackedRows<TEntity extends RowData>({ rows, vi
22
22
  empty?: DataTablePlaceholder;
23
23
  refetching: boolean;
24
24
  onRowClick?: (row: TEntity) => void;
25
- isInteractiveTarget: (target: EventTarget | null) => boolean;
25
+ isRowClickIgnored: (target: EventTarget | null, row: Element) => boolean;
26
26
  onRetry?: () => void;
27
27
  table: ReactTableInstance<DataTableFeatures, TEntity>;
28
28
  className?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"data-table-stack.d.ts","sourceRoot":"","sources":["../../../src/components/data-table/data-table-stack.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,KAAK,IAAI,kBAAkB,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAqBlG,OAAO,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAGnE,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAA;AAEjC;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,OAAO,EAAE,EAC5D,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,UAAU,EACV,KAAK,EACL,UAAU,EACV,mBAAmB,EACnB,OAAO,EACP,KAAK,EACL,SAAS,EACT,gBAAgB,GACjB,EAAE;IACD,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAA;IACpB;6EACyE;IACzE,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,CAAC,EAAE,oBAAoB,CAAA;IAC5B,KAAK,CAAC,EAAE,oBAAoB,CAAA;IAC5B,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IACnC,mBAAmB,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,KAAK,OAAO,CAAA;IAC5D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,KAAK,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACrD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;CACzB,+BAiIA;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,OAAO,EAAE,EAC7D,KAAK,EACL,sBAAsB,EACtB,SAAS,GACV,EAAE;IACD,KAAK,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACrD;;kCAE8B;IAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,sCA0JA"}
1
+ {"version":3,"file":"data-table-stack.d.ts","sourceRoot":"","sources":["../../../src/components/data-table/data-table-stack.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,KAAK,IAAI,kBAAkB,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAqBlG,OAAO,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAGnE,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAA;AAEjC;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,OAAO,EAAE,EAC5D,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,UAAU,EACV,KAAK,EACL,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,KAAK,EACL,SAAS,EACT,gBAAgB,GACjB,EAAE;IACD,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAA;IACpB;6EACyE;IACzE,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,CAAC,EAAE,oBAAoB,CAAA;IAC5B,KAAK,CAAC,EAAE,oBAAoB,CAAA;IAC5B,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IACnC,iBAAiB,EAAE,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,EAAE,OAAO,KAAK,OAAO,CAAA;IACxE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,KAAK,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACrD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;CACzB,+BAmIA;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,OAAO,EAAE,EAC7D,KAAK,EACL,sBAAsB,EACtB,SAAS,GACV,EAAE;IACD,KAAK,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACrD;;kCAE8B;IAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,sCA0JA"}
@@ -1 +1 @@
1
- {"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../../src/components/data-table/data-table.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAE1B,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAElB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,OAAO,CAAA;AAGlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,KAAK,SAAS,EAAqB,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,CAAC,OAAO,SAAS,OAAO,EAAE,EACnD,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,OAAO,EAAE,WAAW,EACpB,eAAe,EACf,OAAO,EAAE,WAAW,EACpB,eAAe,EACf,YAAY,EAAE,gBAAgB,EAC9B,oBAAoB,EACpB,UAAU,EAAE,cAAc,EAC1B,kBAAkB,EAClB,YAAY,EAAE,gBAAgB,EAC9B,oBAAoB,EACpB,gBAAgB,EAAE,oBAAoB,EACtC,wBAAwB,EACxB,YAAY,EAAE,gBAAgB,EAC9B,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,SAAS,EACT,WAAW,EACX,eAAe,EACf,YAAY,EACZ,cAAc,EACd,OAAe,EACf,KAAK,EACL,OAAO,EACP,KAAgC,EAChC,kBAAkB,EAClB,UAAU,EACV,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EAAE,uBAAuB,EAC/C,oBAAoB,EACpB,gBAAuB,EACvB,MAAgB,EAChB,cAAqB,EACrB,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,UAAqB,EACrB,SAAS,EACT,UAAU,GACX,EAAE,cAAc,CAAC,OAAO,CAAC,+BAiazB;AAED,eAAO,MAAM,SAAS;;CAEpB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { ThemeIcon } from '../../chunk-6I4R3HR6.js';
2
+ import { ThemeIcon } from '../../chunk-RQL7FVCS.js';
3
3
  import '../../chunk-ZP6EBROY.js';
4
4
  import { Table } from '../../chunk-YBJB7FGE.js';
5
5
  import { Text } from '../../chunk-CSCVTESP.js';
@@ -826,7 +826,7 @@ function DataTableStackedRows({
826
826
  refetching,
827
827
  empty,
828
828
  onRowClick,
829
- isInteractiveTarget: isInteractiveTarget2,
829
+ isRowClickIgnored: isRowClickIgnored2,
830
830
  onRetry,
831
831
  table,
832
832
  className,
@@ -908,7 +908,9 @@ function DataTableStackedRows({
908
908
  ),
909
909
  ...props({ "data-selected": row.getIsSelected() }),
910
910
  onClick: onRowClick ? (event) => {
911
- if (!isInteractiveTarget2(event.target)) onRowClick(row.original);
911
+ if (!isRowClickIgnored2(event.target, event.currentTarget)) {
912
+ onRowClick(row.original);
913
+ }
912
914
  } : void 0,
913
915
  children: /* @__PURE__ */ jsx(Flex, { direction: "col", gap: "xs", children: row.getVisibleCells().map((cell) => {
914
916
  const header = headersByColumnId.get(cell.column.id);
@@ -1111,7 +1113,44 @@ function DataTableColumnVisibilityMenu({
1111
1113
  )) })
1112
1114
  ] });
1113
1115
  }
1114
- var isInteractiveTarget = (target) => target instanceof Element && target.closest("a,button,input,label,select,textarea,summary,[role]") != null;
1116
+ var INTERACTIVE_SELECTOR = [
1117
+ "a[href]",
1118
+ "button",
1119
+ "input",
1120
+ "label",
1121
+ "select",
1122
+ "textarea",
1123
+ "summary",
1124
+ "[contenteditable]",
1125
+ ...[
1126
+ "button",
1127
+ "link",
1128
+ "checkbox",
1129
+ "radio",
1130
+ "switch",
1131
+ "menuitem",
1132
+ "menuitemcheckbox",
1133
+ "menuitemradio",
1134
+ "tab",
1135
+ "option",
1136
+ "combobox",
1137
+ "slider",
1138
+ "spinbutton",
1139
+ "textbox",
1140
+ "searchbox"
1141
+ ].map((role) => `[role="${role}"]`)
1142
+ ].join(",");
1143
+ var isRowClickIgnored = (target, row) => {
1144
+ const selection = row.ownerDocument.getSelection();
1145
+ const selectsRow = selection != null && !selection.isCollapsed && Array.from({ length: selection.rangeCount }, (_, i) => selection.getRangeAt(i)).some(
1146
+ (range) => range.intersectsNode(row)
1147
+ );
1148
+ if (selectsRow) return true;
1149
+ if (!(target instanceof Element)) return false;
1150
+ if (!row.contains(target)) return true;
1151
+ const hit = target.closest(INTERACTIVE_SELECTOR);
1152
+ return hit != null && hit !== row && row.contains(hit);
1153
+ };
1115
1154
  function resolveSort(canSort, sorted) {
1116
1155
  return canSort ? sorted ? sorted === "asc" ? "ascending" : "descending" : "none" : void 0;
1117
1156
  }
@@ -1326,7 +1365,7 @@ function DataTableComponent({
1326
1365
  const isRefetching = loading && rows.length > 0;
1327
1366
  const skeletonRowCount = Math.min(Math.max(pagination.pageSize, 1), 100);
1328
1367
  const handleRowClick = (row) => (event) => {
1329
- if (!onRowClick || isInteractiveTarget(event.target)) return;
1368
+ if (!onRowClick || isRowClickIgnored(event.target, event.currentTarget)) return;
1330
1369
  onRowClick(row);
1331
1370
  };
1332
1371
  const enableColumnVisibility = _enableColumnVisibility && table.getAllLeafColumns().some((column) => !column.columnDef.meta?.hideFromMenu);
@@ -1564,7 +1603,7 @@ function DataTableComponent({
1564
1603
  refetching: isRefetching,
1565
1604
  empty,
1566
1605
  onRowClick,
1567
- isInteractiveTarget,
1606
+ isRowClickIgnored,
1568
1607
  onRetry,
1569
1608
  table,
1570
1609
  skeletonRowCount,