@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
@@ -1 +1 @@
1
- {"version":3,"file":"now-cursor-line.d.ts","sourceRoot":"","sources":["../../../src/components/schedule/now-cursor-line.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAiDhC,wBAAgB,aAAa,CAAC,EAC5B,GAAG,EACH,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAkB,EAClB,OAAe,EACf,SAAS,GACV,EAAE;IACD,iFAAiF;IACjF,GAAG,CAAC,EAAE,IAAI,CAAA;IACV;;;;;gCAK4B;IAC5B,MAAM,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;IAC5B,yFAAyF;IACzF,SAAS,EAAE,MAAM,CAAA;IACjB;;;;sEAIkE;IAClE,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAA;IAC5B;;;;;;8BAM0B;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,sCA8BA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,GAAG,EACH,SAAS,EACT,OAAO,EACP,MAAM,EACN,SAAS,GACV,EAAE;IACD,iFAAiF;IACjF,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf;2BACuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,+BA6EA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,KAAK,EACL,GAAG,EACH,SAAS,EACT,OAAO,EACP,eAAe,EACf,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,iFAAiF;IACjF,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,OAAO,CAAA;CACzB,+BAaA"}
1
+ {"version":3,"file":"now-cursor-line.d.ts","sourceRoot":"","sources":["../../../src/components/schedule/now-cursor-line.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAiDhC,wBAAgB,aAAa,CAAC,EAC5B,GAAG,EACH,MAAM,EACN,SAAS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5
5
  import type { ScheduleSlotPredicate } from "../../lib/schedule-predicates";
6
6
  /**
7
7
  * A closed subset of the kit's full palette (`lib/colors.ts`), not the
8
- * shared `Color` type: `brand` and `gray` are excluded (reserved for chrome),
8
+ * shared `Color` type: `brand` and `neutral` are excluded (reserved for chrome),
9
9
  * and there's no custom-string escape hatch — every allowed value's
10
10
  * `--c-text`/`--c-soft` pairing has been checked against a white/near-black
11
11
  * grid background, a guarantee an arbitrary custom color couldn't make.
@@ -105,7 +105,7 @@ var Switch = ({
105
105
  name,
106
106
  value,
107
107
  id,
108
- "data-color": color,
108
+ "data-color": color === "neutral" ? "green" : color,
109
109
  ...props({ "data-testid": testId }),
110
110
  className: cn(
111
111
  "relative inline-flex items-center gap-2 select-none",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/switch/switch.tsx"],"names":["Ark"],"mappings":";;;;;;;;;AAuCA,IAAM,WAAA,GAAc,GAAA;AAAA,EAClB;AAAA,IACE,yEAAA;AAAA;AAAA,IAEA,yCAAA;AAAA;AAAA,IAEA,qCAAA;AAAA;AAAA;AAAA;AAAA,IAIA,WAAA,CAAY,EAAE,MAAA,EAAQ,oBAAA,EAAsB,CAAA;AAAA;AAAA,IAE5C,4BAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,eAAA;AAAA,QACJ,EAAA,EAAI,iBAAA;AAAA,QACJ,EAAA,EAAI,eAAA;AAAA,QACJ,EAAA,EAAI,gBAAA;AAAA,QACJ,EAAA,EAAI;AAAA;AACN,KACF;AAAA,IACA,eAAA,EAAiB,EAAE,IAAA,EAAM,IAAA;AAAK;AAElC,CAAA;AAEA,IAAM,WAAA,GAAc,GAAA;AAAA,EAClB;AAAA,IACE;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,QAAA;AA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cAAW,WAAA,EAA0B,KAAA,EAAc,MAClD,QAAA,kBAAA,GAAA,CAAC,iBAAA,EAAA,EAAkB,GAAA,EAAU,MAAA,EAAgB,CAAA,EAC/C;AAAA,SAAA,EACF,oBAEA,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,UAAA,SAAA;AAAA,0BACD,GAAA;AAAA,YAAC,UAAA;AAAA,YAAA;AAAA,cACC,WAAA;AAAA,cACA,KAAA;AAAA,cACA,IAAA;AAAA,cACA,WAAW,UAAA,EAAY,KAAA;AAAA,cAEvB,QAAA,kBAAA,GAAA,CAAC,iBAAA,EAAA,EAAkB,GAAA,EAAU,MAAA,EAAgB;AAAA;AAAA;AAC/C,SAAA,EACF;AAAA;AAAA;AAAA,GAEJ;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { Switch as Ark } from \"@ark-ui/react/switch\"\nimport { cva } from \"class-variance-authority\"\nimport type { FocusEvent, ReactNode, Ref } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { FieldShell, fieldA11yProps, fieldLabel, fieldRoot } from \"../field/field\"\n\n/**\n * Switch — a single boolean toggle on Ark UI's Switch machine, styled as a\n * sliding track + thumb. The label sits inline beside the track, rendered\n * through the switch's own `Ark.Label` part (not `Field`'s) so it stays\n * correctly wired to the hidden input's `aria-labelledby` and carries no\n * layout footprint when visually hidden (e.g. `classNames.label: \"sr-only\"`).\n * `description` / `error` / `required` live below it via the shared `Field`\n * scaffold, so a `Switch` is accessible and complete on its own. Implements\n * the kit's `FormControlProps` contract: the `ref` and `onBlur` land on the\n * submittable hidden `<input>`, and `name` wires it into native form\n * submission.\n *\n * - `onCheckedChange` hands you the next boolean directly (a value, not a DOM\n * event), matching the rest of the family.\n * - `invalid` is OR'd with `error != null`, so a form library can flip the\n * red state independently of the message.\n *\n * Unlike the selection controls, the Switch authors its own track / thumb\n * geometry rather than reusing `controlIndicator` (a pill, not a box), but\n * follows the same conventions: the track is palette-independent at rest and\n * only the checked fill / focus ring reference the active palette via the slot\n * vars (`--c-solid`), so it tints for free from whatever `data-color` sits on\n * the root.\n */\n\nconst switchTrack = cva(\n [\n \"inline-flex shrink-0 items-center rounded-sm transition-colors relative\",\n // Neutral resting track.\n \"bg-gray-light-300 dark:bg-gray-dark-700\",\n // Checked fill — palette solid, via the slot var.\n \"data-[state=checked]:bg-(--c-solid)\",\n // The kit's standard focus ring, keyed off the Control's own\n // `data-focus-visible` (zag mirrors the hidden input's focus-visible state\n // onto every switch part).\n focusStyles({ source: \"data-focus-visible\" }),\n // Invalid wins over the palette: red wash.\n \"data-invalid:bg-red-500/40\",\n // Disabled affordances.\n \"data-disabled:opacity-60 data-disabled:cursor-not-allowed\",\n ],\n {\n variants: {\n size: {\n xs: \"h-4 w-7 p-0.5\",\n sm: \"h-4.5 w-8 p-0.5\",\n md: \"h-5 w-9 p-0.5\",\n lg: \"h-6 w-11 p-0.5\",\n xl: \"h-7 w-13 p-0.5\",\n },\n },\n defaultVariants: { size: \"md\" },\n },\n)\n\nconst switchThumb = cva(\n [\n \"rounded-xs bg-white shadow-sm transition-[inset] absolute inset-s-0.5 data-[state=checked]:inset-s-1/2\",\n ],\n {\n variants: {\n size: {\n xs: \"size-3\",\n sm: \"size-3.5\",\n md: \"size-4\",\n lg: \"size-5\",\n xl: \"size-6\",\n },\n },\n defaultVariants: { size: \"md\" },\n },\n)\n\nexport type SwitchProps = WithTestId & {\n /** Controlled checked state. */\n checked?: boolean\n /** Uncontrolled initial checked state. */\n defaultChecked?: boolean\n /** Fires with the next checked state (a value, not a DOM event). */\n onCheckedChange?: (checked: boolean) => void\n /** Inline label beside the track. */\n label?: ReactNode\n /** Helper text above the control. */\n description?: ReactNode\n /** Error message below the control; its presence sets the invalid state. */\n error?: ReactNode\n /** Required flag (and, with a label, the red asterisk). */\n required?: boolean\n /** Red invalid state, OR'd with `error != null`. */\n invalid?: boolean\n /** Dims and blocks interaction. */\n disabled?: boolean\n /** Keeps full contrast but blocks edits. */\n readOnly?: boolean\n size?: Size\n color?: Color\n /** Field name for native form submission. */\n name?: string\n /** Submitted value when checked (defaults to `\"on\"`). */\n value?: string\n /** Explicit id for label association. */\n id?: string\n /** Lands on the hidden `<input>` for focus-on-error. */\n ref?: Ref<HTMLInputElement>\n /** Forwarded to the hidden `<input>`; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void\n className?: string\n classNames?: {\n root?: string\n control?: string\n thumb?: string\n label?: string\n field?: string\n }\n}\n\n/**\n * The real, submittable hidden `<input>`, split out so it reads the `Field`\n * context from *inside* the wrapping `FieldShell` — `Switch` itself renders\n * that shell, so calling `useFieldContext()` at its own top level would run\n * too early.\n */\nconst SwitchHiddenInput = ({ ref, onBlur }: Pick<SwitchProps, \"ref\" | \"onBlur\">) => {\n const field = useFieldContext()\n return <Ark.HiddenInput ref={ref} onBlur={onBlur} {...fieldA11yProps(field)} />\n}\n\nexport const Switch = ({\n checked,\n defaultChecked,\n onCheckedChange,\n label,\n description,\n error,\n required,\n invalid,\n disabled,\n readOnly,\n size = \"md\",\n color = \"green\",\n name,\n value,\n id,\n ref,\n onBlur,\n className,\n classNames,\n testId,\n}: SwitchProps) => {\n // Red state is driven independently of the `Field` error slot so a form\n // library can flip it from `fieldState.invalid` (see FormControlProps).\n const isInvalid = invalid || error != null\n\n // A visible label above description/error needs the two grouped into one\n // flex-col item, or they'd land side by side in the root's row instead of\n // stacked. Label-only (incl. sr-only) never needs this extra wrapper.\n const hasStack = label != null && (description != null || error != null)\n\n const labelNode = label != null && (\n <Ark.Label\n className={cn(fieldLabel({ size }), !hasStack && \"min-w-0 flex-1\", classNames?.label)}\n >\n {label}\n {required && (\n <span aria-hidden=\"true\" className=\"ms-0.5 text-red-500\">\n *\n </span>\n )}\n </Ark.Label>\n )\n\n return (\n <Ark.Root\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={onCheckedChange ? (d) => onCheckedChange(d.checked) : undefined}\n invalid={isInvalid}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n name={name}\n value={value}\n id={id}\n data-color={color}\n {...props({ \"data-testid\": testId })}\n // `relative` contains the absolutely positioned hidden input, which would\n // otherwise escape any scroller this control sits in.\n className={cn(\n \"relative inline-flex items-center gap-2 select-none\",\n className,\n classNames?.root,\n )}\n >\n <Ark.Control className={cn(switchTrack({ size }), classNames?.control)}>\n <Ark.Thumb className={cn(switchThumb({ size }), classNames?.thumb)} />\n </Ark.Control>\n\n {hasStack ? (\n <div className={cn(fieldRoot({ size }), classNames?.field)}>\n {labelNode}\n <FieldShell description={description} error={error} size={size}>\n <SwitchHiddenInput ref={ref} onBlur={onBlur} />\n </FieldShell>\n </div>\n ) : (\n <>\n {labelNode}\n <FieldShell\n description={description}\n error={error}\n size={size}\n className={classNames?.field}\n >\n <SwitchHiddenInput ref={ref} onBlur={onBlur} />\n </FieldShell>\n </>\n )}\n </Ark.Root>\n )\n}\n"]}
1
+ {"version":3,"sources":["../../../src/components/switch/switch.tsx"],"names":["Ark"],"mappings":";;;;;;;;;AAuCA,IAAM,WAAA,GAAc,GAAA;AAAA,EAClB;AAAA,IACE,yEAAA;AAAA;AAAA,IAEA,yCAAA;AAAA;AAAA,IAEA,qCAAA;AAAA;AAAA;AAAA;AAAA,IAIA,WAAA,CAAY,EAAE,MAAA,EAAQ,oBAAA,EAAsB,CAAA;AAAA;AAAA,IAE5C,4BAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,IAAA,EAAM;AAAA,QACJ,EAAA,EAAI,eAAA;AAAA,QACJ,EAAA,EAAI,iBAAA;AAAA,QACJ,EAAA,EAAI,eAAA;AAAA,QACJ,EAAA,EAAI,gBAAA;A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,WAAA,CAAY,EAAE,IAAA,EAAM,CAAA,EAAG,UAAA,EAAY,KAAK,CAAA,EAAG,CAAA,EACtE,CAAA;AAAA,QAEC,QAAA,mBACC,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAW,EAAA,CAAG,SAAA,CAAU,EAAE,IAAA,EAAM,CAAA,EAAG,UAAA,EAAY,KAAK,CAAA,EACtD,QAAA,EAAA;AAAA,UAAA,SAAA;AAAA,0BACD,GAAA,CAAC,cAAW,WAAA,EAA0B,KAAA,EAAc,MAClD,QAAA,kBAAA,GAAA,CAAC,iBAAA,EAAA,EAAkB,GAAA,EAAU,MAAA,EAAgB,CAAA,EAC/C;AAAA,SAAA,EACF,oBAEA,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,UAAA,SAAA;AAAA,0BACD,GAAA;AAAA,YAAC,UAAA;AAAA,YAAA;AAAA,cACC,WAAA;AAAA,cACA,KAAA;AAAA,cACA,IAAA;AAAA,cACA,WAAW,UAAA,EAAY,KAAA;AAAA,cAEvB,QAAA,kBAAA,GAAA,CAAC,iBAAA,EAAA,EAAkB,GAAA,EAAU,MAAA,EAAgB;AAAA;AAAA;AAC/C,SAAA,EACF;AAAA;AAAA;AAAA,GAEJ;AAEJ","file":"index.js","sourcesContent":["\"use client\"\n\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { Switch as Ark } from \"@ark-ui/react/switch\"\nimport { cva } from \"class-variance-authority\"\nimport type { FocusEvent, ReactNode, Ref } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { FieldShell, fieldA11yProps, fieldLabel, fieldRoot } from \"../field/field\"\n\n/**\n * Switch — a single boolean toggle on Ark UI's Switch machine, styled as a\n * sliding track + thumb. The label sits inline beside the track, rendered\n * through the switch's own `Ark.Label` part (not `Field`'s) so it stays\n * correctly wired to the hidden input's `aria-labelledby` and carries no\n * layout footprint when visually hidden (e.g. `classNames.label: \"sr-only\"`).\n * `description` / `error` / `required` live below it via the shared `Field`\n * scaffold, so a `Switch` is accessible and complete on its own. Implements\n * the kit's `FormControlProps` contract: the `ref` and `onBlur` land on the\n * submittable hidden `<input>`, and `name` wires it into native form\n * submission.\n *\n * - `onCheckedChange` hands you the next boolean directly (a value, not a DOM\n * event), matching the rest of the family.\n * - `invalid` is OR'd with `error != null`, so a form library can flip the\n * red state independently of the message.\n *\n * Unlike the selection controls, the Switch authors its own track / thumb\n * geometry rather than reusing `controlIndicator` (a pill, not a box), but\n * follows the same conventions: the track is palette-independent at rest and\n * only the checked fill / focus ring reference the active palette via the slot\n * vars (`--c-solid`), so it tints for free from whatever `data-color` sits on\n * the root.\n */\n\nconst switchTrack = cva(\n [\n \"inline-flex shrink-0 items-center rounded-sm transition-colors relative\",\n // Neutral resting track.\n \"bg-gray-light-300 dark:bg-gray-dark-700\",\n // Checked fill — palette solid, via the slot var.\n \"data-[state=checked]:bg-(--c-solid)\",\n // The kit's standard focus ring, keyed off the Control's own\n // `data-focus-visible` (zag mirrors the hidden input's focus-visible state\n // onto every switch part).\n focusStyles({ source: \"data-focus-visible\" }),\n // Invalid wins over the palette: red wash.\n \"data-invalid:bg-red-500/40\",\n // Disabled affordances.\n \"data-disabled:opacity-60 data-disabled:cursor-not-allowed\",\n ],\n {\n variants: {\n size: {\n xs: \"h-4 w-7 p-0.5\",\n sm: \"h-4.5 w-8 p-0.5\",\n md: \"h-5 w-9 p-0.5\",\n lg: \"h-6 w-11 p-0.5\",\n xl: \"h-7 w-13 p-0.5\",\n },\n },\n defaultVariants: { size: \"md\" },\n },\n)\n\nconst switchThumb = cva(\n [\n \"rounded-xs bg-white shadow-sm transition-[inset] absolute inset-s-0.5 data-[state=checked]:inset-s-1/2\",\n ],\n {\n variants: {\n size: {\n xs: \"size-3\",\n sm: \"size-3.5\",\n md: \"size-4\",\n lg: \"size-5\",\n xl: \"size-6\",\n },\n },\n defaultVariants: { size: \"md\" },\n },\n)\n\nexport type SwitchProps = WithTestId & {\n /** Controlled checked state. */\n checked?: boolean\n /** Uncontrolled initial checked state. */\n defaultChecked?: boolean\n /** Fires with the next checked state (a value, not a DOM event). */\n onCheckedChange?: (checked: boolean) => void\n /** Inline label beside the track. */\n label?: ReactNode\n /** Helper text above the control. */\n description?: ReactNode\n /** Error message below the control; its presence sets the invalid state. */\n error?: ReactNode\n /** Required flag (and, with a label, the red asterisk). */\n required?: boolean\n /** Red invalid state, OR'd with `error != null`. */\n invalid?: boolean\n /** Dims and blocks interaction. */\n disabled?: boolean\n /** Keeps full contrast but blocks edits. */\n readOnly?: boolean\n size?: Size\n /** Checked fill. `neutral` is the one exception: it fills green, since\n * neutral's solid is the same white as the thumb on a dark page. */\n color?: Color\n /** Field name for native form submission. */\n name?: string\n /** Submitted value when checked (defaults to `\"on\"`). */\n value?: string\n /** Explicit id for label association. */\n id?: string\n /** Lands on the hidden `<input>` for focus-on-error. */\n ref?: Ref<HTMLInputElement>\n /** Forwarded to the hidden `<input>`; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void\n className?: string\n classNames?: {\n root?: string\n control?: string\n thumb?: string\n label?: string\n field?: string\n }\n}\n\n/**\n * The real, submittable hidden `<input>`, split out so it reads the `Field`\n * context from *inside* the wrapping `FieldShell` — `Switch` itself renders\n * that shell, so calling `useFieldContext()` at its own top level would run\n * too early.\n */\nconst SwitchHiddenInput = ({ ref, onBlur }: Pick<SwitchProps, \"ref\" | \"onBlur\">) => {\n const field = useFieldContext()\n return <Ark.HiddenInput ref={ref} onBlur={onBlur} {...fieldA11yProps(field)} />\n}\n\nexport const Switch = ({\n checked,\n defaultChecked,\n onCheckedChange,\n label,\n description,\n error,\n required,\n invalid,\n disabled,\n readOnly,\n size = \"md\",\n color = \"green\",\n name,\n value,\n id,\n ref,\n onBlur,\n className,\n classNames,\n testId,\n}: SwitchProps) => {\n // Red state is driven independently of the `Field` error slot so a form\n // library can flip it from `fieldState.invalid` (see FormControlProps).\n const isInvalid = invalid || error != null\n\n // A visible label above description/error needs the two grouped into one\n // flex-col item, or they'd land side by side in the root's row instead of\n // stacked. Label-only (incl. sr-only) never needs this extra wrapper.\n const hasStack = label != null && (description != null || error != null)\n\n const labelNode = label != null && (\n <Ark.Label\n className={cn(fieldLabel({ size }), !hasStack && \"min-w-0 flex-1\", classNames?.label)}\n >\n {label}\n {required && (\n <span aria-hidden=\"true\" className=\"ms-0.5 text-red-500\">\n *\n </span>\n )}\n </Ark.Label>\n )\n\n return (\n <Ark.Root\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={onCheckedChange ? (d) => onCheckedChange(d.checked) : undefined}\n invalid={isInvalid}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n name={name}\n value={value}\n id={id}\n data-color={color === \"neutral\" ? \"green\" : color}\n {...props({ \"data-testid\": testId })}\n // `relative` contains the absolutely positioned hidden input, which would\n // otherwise escape any scroller this control sits in.\n className={cn(\n \"relative inline-flex items-center gap-2 select-none\",\n className,\n classNames?.root,\n )}\n >\n <Ark.Control className={cn(switchTrack({ size }), classNames?.control)}>\n <Ark.Thumb className={cn(switchThumb({ size }), classNames?.thumb)} />\n </Ark.Control>\n\n {hasStack ? (\n <div className={cn(fieldRoot({ size }), classNames?.field)}>\n {labelNode}\n <FieldShell description={description} error={error} size={size}>\n <SwitchHiddenInput ref={ref} onBlur={onBlur} />\n </FieldShell>\n </div>\n ) : (\n <>\n {labelNode}\n <FieldShell\n description={description}\n error={error}\n size={size}\n className={classNames?.field}\n >\n <SwitchHiddenInput ref={ref} onBlur={onBlur} />\n </FieldShell>\n </>\n )}\n </Ark.Root>\n )\n}\n"]}
@@ -24,6 +24,8 @@ export type SwitchProps = WithTestId & {
24
24
  /** Keeps full contrast but blocks edits. */
25
25
  readOnly?: boolean;
26
26
  size?: Size;
27
+ /** Checked fill. `neutral` is the one exception: it fills green, since
28
+ * neutral's solid is the same white as the thumb on a dark page. */
27
29
  color?: Color;
28
30
  /** Field name for native form submission. */
29
31
  name?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/components/switch/switch.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAG7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AA4EnD,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACrC,gCAAgC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,0CAA0C;IAC1C,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,oEAAoE;IACpE,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC5C,qCAAqC;IACrC,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,qCAAqC;IACrC,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yCAAyC;IACzC,EAAE,C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D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;yEACqE;IACrE,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yCAAyC;IACzC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,wDAAwD;IACxD,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAA;IAC3B,4EAA4E;IAC5E,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IACtD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACF,CAAA;AAaD,eAAO,MAAM,MAAM,8LAqBhB,WAAW,gCAuEb,CAAA"}
@@ -1,4 +1,4 @@
1
- export { ThemeIcon } from '../../chunk-6I4R3HR6.js';
1
+ export { ThemeIcon } from '../../chunk-RQL7FVCS.js';
2
2
  import '../../chunk-WYCMIIRR.js';
3
3
  import '../../chunk-B2LCHXUB.js';
4
4
  import '../../chunk-QP4I37PA.js';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DEFAULT_THEME_STORAGE_KEY, resolveTheme, applyThemeAttribute, getSystemTheme, isThemeMode, disableTransitionsDuringChange } from './chunk-EEMRRRYS.js';
2
2
  export { DEFAULT_THEME_STORAGE_KEY, THEME_MODES, buildThemeInitScript, getSystemTheme, isThemeMode, resolveTheme } from './chunk-EEMRRRYS.js';
3
3
  export { DEFAULT_LOCALE, DEFAULT_TIME_ZONE, IntlProvider, useLocale, useTimeZone } from './chunk-7NZSTCJO.js';
4
- export { COLORS } from './chunk-JBVFWSRQ.js';
4
+ export { COLORS } from './chunk-VIYVN4WF.js';
5
5
  export { useContainerQuery } from './chunk-P3XMBETI.js';
6
6
  export { LinkComponentProvider, useLinkComponent } from './chunk-GTKKRV5N.js';
7
7
  import { useIsomorphicLayoutEffect } from './chunk-BUIHQJGE.js';
@@ -9,6 +9,6 @@
9
9
  * 3. Add a `[data-color="<name>"]` block in `colors.css` with the slot vars
10
10
  * (and a dark-mode override if the shade should shift).
11
11
  */
12
- export declare const COLORS: readonly ["brand", "gray", "neutral", "red", "orange", "yellow", "green", "teal", "cyan", "blue", "purple", "pink"];
12
+ export declare const COLORS: readonly ["brand", "neutral", "red", "orange", "yellow", "green", "teal", "cyan", "blue", "purple", "pink"];
13
13
  export type Color = (typeof COLORS)[number] | (string & {});
14
14
  //# sourceMappingURL=colors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/lib/colors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,YACjB,OAAO,EACP,MAAM,EAGN,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,CACE,CAAA;AAIV,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA"}
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/lib/colors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,YACjB,OAAO,EAMP,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,CACE,CAAA;AAIV,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA"}
package/dist/theme.css CHANGED
@@ -48,34 +48,6 @@
48
48
  --color-gray-dark-900: #13161b;
49
49
  --color-gray-dark-950: #0c0e12;
50
50
 
51
- /* Gray Modern */
52
- --color-gray-modern-25: #fcfcfd;
53
- --color-gray-modern-50: #f8fafc;
54
- --color-gray-modern-100: #eef2f6;
55
- --color-gray-modern-200: #e3e8ef;
56
- --color-gray-modern-300: #cdd5df;
57
- --color-gray-modern-400: #9aa4b2;
58
- --color-gray-modern-500: #697586;
59
- --color-gray-modern-600: #4b5565;
60
- --color-gray-modern-700: #364152;
61
- --color-gray-modern-800: #202939;
62
- --color-gray-modern-900: #121926;
63
- --color-gray-modern-950: #0d121c;
64
-
65
- /* Gray Blue */
66
- --color-gray-blue-25: #fcfcfd;
67
- --color-gray-blue-50: #f8f9fc;
68
- --color-gray-blue-100: #eaecf5;
69
- --color-gray-blue-200: #d5d9eb;
70
- --color-gray-blue-300: #b3b8db;
71
- --color-gray-blue-400: #717bbc;
72
- --color-gray-blue-500: #4e5ba6;
73
- --color-gray-blue-600: #3e4784;
74
- --color-gray-blue-700: #363f72;
75
- --color-gray-blue-800: #293056;
76
- --color-gray-blue-900: #101323;
77
- --color-gray-blue-950: #0d0f1c;
78
-
79
51
  /* Gray True */
80
52
  --color-gray-true-25: #fcfcfc;
81
53
  --color-gray-true-50: #f7f7f7;
@@ -1274,8 +1246,3 @@ body {
1274
1246
 
1275
1247
  /* Variants to use with slider's values */
1276
1248
  @custom-variant state-under-or-at (&:is([data-state="under-value"], [data-state="at-value"]));
1277
-
1278
- *,
1279
- :root {
1280
- @apply scrollbar-thumb-gray-300/60 hover:scrollbar-thumb-gray-300 dark:scrollbar-thumb-gray-500/60 dark:hover:scrollbar-thumb-gray-500 scrollbar-track-transparent;
1281
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@42-central/ui-react",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "description": "React UI kit for 42 tools",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -10,6 +10,7 @@
10
10
  "files": [
11
11
  "dist",
12
12
  "src",
13
+ "biome",
13
14
  "README.md"
14
15
  ],
15
16
  "exports": {
@@ -0,0 +1,61 @@
1
+ import { execFileSync } from "node:child_process"
2
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs"
3
+ import { tmpdir } from "node:os"
4
+ import { join, resolve } from "node:path"
5
+ import { afterAll, describe, expect, it } from "vitest"
6
+
7
+ /**
8
+ * Runs the shipped Biome plugins (`biome/*.grit`) against a throwaway file
9
+ * with the repo's own Biome. A Grit rule that stops matching fails silently,
10
+ * with no lint error, so this pins what each one flags and what it leaves alone.
11
+ */
12
+ const pkg = resolve(__dirname, "..")
13
+ const biome = resolve(pkg, "../../node_modules/.bin/biome")
14
+ // Outside the repo: Biome never lints anything under `node_modules`, and the
15
+ // fixture must not pick up the repo's own biome.json either.
16
+ const dir = mkdtempSync(join(tmpdir(), "biome-plugins-"))
17
+
18
+ const lint = (plugin: string, source: string) => {
19
+ writeFileSync(
20
+ join(dir, "biome.json"),
21
+ JSON.stringify({
22
+ root: true,
23
+ plugins: [resolve(pkg, "biome", plugin)],
24
+ linter: { rules: { recommended: false } },
25
+ formatter: { enabled: false },
26
+ }),
27
+ )
28
+ writeFileSync(join(dir, "sample.tsx"), source)
29
+ const out = execFileSync(biome, ["lint", "--reporter=json", "sample.tsx"], {
30
+ cwd: dir,
31
+ encoding: "utf8",
32
+ })
33
+ const { diagnostics } = JSON.parse(out) as {
34
+ diagnostics: { location: { start: { line: number } } }[]
35
+ }
36
+ return diagnostics.map((d) => d.location.start.line)
37
+ }
38
+
39
+ afterAll(() => rmSync(dir, { recursive: true, force: true }))
40
+
41
+ describe("no-gray-color.grit", () => {
42
+ it("warns on gray literals and nothing else", () => {
43
+ const lines = lint(
44
+ "no-gray-color.grit",
45
+ [
46
+ `export const A = () => (`,
47
+ ` <>`,
48
+ ` <Badge color="gray" variant="light">a</Badge>`,
49
+ ` <Button color={"gray"} />`,
50
+ ` <Button color={'gray'}>b</Button>`,
51
+ ` <Button color="neutral" />`,
52
+ ` <Text c="gray" />`,
53
+ ` <Badge background="gray" />`,
54
+ ` </>`,
55
+ `)`,
56
+ `export const data = { color: "gray" }`,
57
+ ].join("\n"),
58
+ )
59
+ expect(lines).toEqual([3, 4, 5])
60
+ })
61
+ })
package/src/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);
@@ -114,9 +114,9 @@ export type AvatarNameMode = "name" | "initials"
114
114
  /**
115
115
  * Default hash pool for `color="name"` / `color="initials"`. Excludes
116
116
  * `brand` (the kit's own primary/CTA identity color — auto-tinting a user
117
- * avatar with it would read as "official") and `gray`/`neutral` (muted, and
118
- * `neutral` is a composed-not-scaled tone per `lib/colors.ts`, so it would
119
- * just look washed-out for some names). Exported so a consumer can extend it,
117
+ * avatar with it would read as "official") and `neutral` (muted, and a
118
+ * composed-not-scaled tone per `lib/colors.ts`, so it would just look
119
+ * washed-out for some names). Exported so a consumer can extend it,
120
120
  * e.g. `palette={[...AVATAR_PALETTE, "brand"]}`.
121
121
  */
122
122
  export const AVATAR_PALETTE: Color[] = [
@@ -90,9 +90,8 @@ describe("chartColors", () => {
90
90
  expect(chartColors(["#ff00aa"])).toEqual(["#ff00aa"])
91
91
  })
92
92
 
93
- it("excludes brand, gray, and neutral from the default palette", () => {
93
+ it("excludes brand and neutral from the default palette", () => {
94
94
  expect(CHART_PALETTE).not.toContain("brand")
95
- expect(CHART_PALETTE).not.toContain("gray")
96
95
  expect(CHART_PALETTE).not.toContain("neutral")
97
96
  })
98
97
  })
@@ -29,7 +29,7 @@ const resolveChartColor = (color: Color): string =>
29
29
  /**
30
30
  * Ordered categorical palette for multi-series charts, built from `COLORS`
31
31
  * (`lib/colors.ts`) minus `brand` (kept free for `color`'s own single-series
32
- * identity) and `gray`/`neutral` (already the chart's own chrome color, via
32
+ * identity) and `neutral` (already the chart's own chrome color, via
33
33
  * `styles.css`).
34
34
  *
35
35
  * The first four — `blue`/`green`/`red`/`pink` — are the only 4-combination
@@ -262,12 +262,12 @@ describe("resolveGutterColumns", () => {
262
262
 
263
263
  it("{ text: true, color } renders the payload verbatim, still colored", () => {
264
264
  const columns: CodeBlockGutterColumn[] = [
265
- { kind: "content", tags: { blame: { text: true, color: "gray" } } },
265
+ { kind: "content", tags: { blame: { text: true, color: "neutral" } } },
266
266
  ]
267
267
  const gutters = resolveGutterColumns(columns, notationOf([]), 0)
268
268
  const span = gutters.render(line([{ tag: "blame", payload: "alice" }]))[0]!
269
269
  expect(text(span)).toBe("alice")
270
- expect(span.properties["data-color"]).toBe("gray")
270
+ expect(span.properties["data-color"]).toBe("neutral")
271
271
  })
272
272
 
273
273
  it("a content column with no color/background on the matched tag has no data-color/decoration classes", () => {
@@ -49,7 +49,7 @@ export function DataTableStackedRows<TEntity extends RowData>({
49
49
  refetching,
50
50
  empty,
51
51
  onRowClick,
52
- isInteractiveTarget,
52
+ isRowClickIgnored,
53
53
  onRetry,
54
54
  table,
55
55
  className,
@@ -63,7 +63,7 @@ export function DataTableStackedRows<TEntity extends RowData>({
63
63
  empty?: DataTablePlaceholder
64
64
  refetching: boolean
65
65
  onRowClick?: (row: TEntity) => void
66
- isInteractiveTarget: (target: EventTarget | null) => boolean
66
+ isRowClickIgnored: (target: EventTarget | null, row: Element) => boolean
67
67
  onRetry?: () => void
68
68
  table: ReactTableInstance<DataTableFeatures, TEntity>
69
69
  className?: string
@@ -169,7 +169,9 @@ export function DataTableStackedRows<TEntity extends RowData>({
169
169
  onClick={
170
170
  onRowClick
171
171
  ? (event) => {
172
- if (!isInteractiveTarget(event.target)) onRowClick(row.original)
172
+ if (!isRowClickIgnored(event.target, event.currentTarget)) {
173
+ onRowClick(row.original)
174
+ }
173
175
  }
174
176
  : undefined
175
177
  }
@@ -1,4 +1,5 @@
1
1
  import { fireEvent, render, screen, waitFor, within } from "@testing-library/react"
2
+ import { createPortal } from "react-dom"
2
3
  import { describe, expect, it, vi } from "vitest"
3
4
  import { DATA_TABLE_DEFAULT_EMPTY, DataTable } from "./data-table"
4
5
  import { createColumnHelper } from "./data-table-features"
@@ -188,6 +189,96 @@ describe("DataTable", () => {
188
189
  expect(onRowClick).not.toHaveBeenCalled()
189
190
  })
190
191
 
192
+ it("fires onRowClick when an ancestor of the table carries a role (#304)", () => {
193
+ const onRowClick = vi.fn()
194
+ render(
195
+ <div role="tabpanel">
196
+ <DataTable columns={columns} data={USERS} onRowClick={onRowClick} />
197
+ </div>,
198
+ )
199
+ fireEvent.click(screen.getByText("Ada"))
200
+ expect(onRowClick).toHaveBeenCalledWith(USERS[0])
201
+ })
202
+
203
+ it("fires onRowClick through a non-widget role inside the row", () => {
204
+ const onRowClick = vi.fn()
205
+ const c = createColumnHelper<User>()
206
+ const cols = [
207
+ c.accessor("name", { header: "Name" }),
208
+ c.display({ id: "status", cell: () => <span role="img">●</span> }),
209
+ ]
210
+ render(<DataTable columns={cols} data={USERS} onRowClick={onRowClick} />)
211
+ fireEvent.click(screen.getAllByRole("img")[0] as HTMLElement)
212
+ expect(onRowClick).toHaveBeenCalledWith(USERS[0])
213
+ })
214
+
215
+ it("still ignores a nested button when an ancestor carries a role", () => {
216
+ const onRowClick = vi.fn()
217
+ const c = createColumnHelper<User>()
218
+ const cols = [
219
+ c.accessor("name", { header: "Name" }),
220
+ c.display({ id: "actions", cell: () => <button type="button">Edit</button> }),
221
+ ]
222
+ render(
223
+ <div role="tabpanel">
224
+ <DataTable columns={cols} data={USERS} onRowClick={onRowClick} />
225
+ </div>,
226
+ )
227
+ fireEvent.click(screen.getAllByText("Edit")[0] as HTMLElement)
228
+ expect(onRowClick).not.toHaveBeenCalled()
229
+ })
230
+
231
+ it("ignores clicks on content a cell portals out of the row", () => {
232
+ const onRowClick = vi.fn()
233
+ const c = createColumnHelper<User>()
234
+ const cols = [
235
+ c.accessor("name", { header: "Name" }),
236
+ c.display({
237
+ id: "menu",
238
+ cell: ({ row }) => createPortal(<p>Menu of {row.original.name}</p>, document.body),
239
+ }),
240
+ ]
241
+ render(<DataTable columns={cols} data={USERS} onRowClick={onRowClick} />)
242
+ fireEvent.click(screen.getByText("Menu of Ada"))
243
+ expect(onRowClick).not.toHaveBeenCalled()
244
+ })
245
+
246
+ it("fires onRowClick from a stacked card when an ancestor carries a role", () => {
247
+ const onRowClick = vi.fn()
248
+ render(
249
+ <div role="tabpanel">
250
+ <DataTable columns={columns} data={USERS} responsive="stack" onRowClick={onRowClick} />
251
+ </div>,
252
+ )
253
+ const cardCell = screen.getAllByText("Ada").find((el) => el.closest("tr") == null)
254
+ fireEvent.click(cardCell as HTMLElement)
255
+ expect(onRowClick).toHaveBeenCalledWith(USERS[0])
256
+ })
257
+
258
+ it("ignores the click that ends a text selection inside the row", () => {
259
+ const onRowClick = vi.fn()
260
+ render(<DataTable columns={columns} data={USERS} onRowClick={onRowClick} />)
261
+ const cell = screen.getByText("Ada")
262
+ document.getSelection()?.selectAllChildren(cell)
263
+ fireEvent.click(cell)
264
+ document.getSelection()?.removeAllRanges()
265
+ expect(onRowClick).not.toHaveBeenCalled()
266
+ })
267
+
268
+ it("still fires onRowClick while text outside the row is selected", () => {
269
+ const onRowClick = vi.fn()
270
+ render(
271
+ <>
272
+ <p>Elsewhere</p>
273
+ <DataTable columns={columns} data={USERS} onRowClick={onRowClick} />
274
+ </>,
275
+ )
276
+ document.getSelection()?.selectAllChildren(screen.getByText("Elsewhere"))
277
+ fireEvent.click(screen.getByText("Ada"))
278
+ document.getSelection()?.removeAllRanges()
279
+ expect(onRowClick).toHaveBeenCalledWith(USERS[0])
280
+ })
281
+
191
282
  it("forwards size/striped/sticky to the underlying Table", () => {
192
283
  const { container } = render(
193
284
  <DataTable columns={columns} data={USERS} size="sm" striped stickyHeader />,
@@ -216,13 +216,62 @@ export type DataTableProps<TEntity extends RowData> = WithTestId & {
216
216
  classNames?: DataTableClassNames
217
217
  }
218
218
 
219
+ /** Native controls plus the ARIA widget roles — not a bare `[role]`, which
220
+ * would also match a cell's `role="img"` spinner or `role="progressbar"`. */
221
+ const INTERACTIVE_SELECTOR = [
222
+ "a[href]",
223
+ "button",
224
+ "input",
225
+ "label",
226
+ "select",
227
+ "textarea",
228
+ "summary",
229
+ "[contenteditable]",
230
+ ...[
231
+ "button",
232
+ "link",
233
+ "checkbox",
234
+ "radio",
235
+ "switch",
236
+ "menuitem",
237
+ "menuitemcheckbox",
238
+ "menuitemradio",
239
+ "tab",
240
+ "option",
241
+ "combobox",
242
+ "slider",
243
+ "spinbutton",
244
+ "textbox",
245
+ "searchbox",
246
+ ].map((role) => `[role="${role}"]`),
247
+ ].join(",")
248
+
219
249
  /** A click landing on a nested interactive element shouldn't also fire
220
250
  * `onRowClick` — a `<tr>` with a link / menu / checkbox can't itself be a
221
251
  * button (nested interactives break keyboard + SR semantics), so the row
222
- * handler only fires when the event target isn't one. */
223
- const isInteractiveTarget = (target: EventTarget | null): boolean =>
224
- target instanceof Element &&
225
- target.closest("a,button,input,label,select,textarea,summary,[role]") != null
252
+ * handler only fires when the event target isn't one.
253
+ *
254
+ * The search stops at `row`: an ancestor of the table (a `role="tabpanel"`,
255
+ * a dialog) must not count. A target outside the row's DOM is portaled
256
+ * content — a cell's Menu or Dialog, whose clicks still bubble through the
257
+ * React tree to the row — and never counts as a row click.
258
+ *
259
+ * A click that ends a drag-selection over the row is the user copying a
260
+ * value, not opening the row, so it is ignored too. */
261
+ const isRowClickIgnored = (target: EventTarget | null, row: Element): boolean => {
262
+ const selection = row.ownerDocument.getSelection()
263
+ const selectsRow =
264
+ selection != null &&
265
+ !selection.isCollapsed &&
266
+ Array.from({ length: selection.rangeCount }, (_, i) => selection.getRangeAt(i)).some((range) =>
267
+ range.intersectsNode(row),
268
+ )
269
+ if (selectsRow) return true
270
+ if (!(target instanceof Element)) return false
271
+ if (!row.contains(target)) return true
272
+ const hit = target.closest(INTERACTIVE_SELECTOR)
273
+ return hit != null && hit !== row && row.contains(hit)
274
+ }
226
275
 
227
276
  /** Utility to resolve aria-sort from table state
228
277
  *
@@ -527,7 +576,7 @@ function DataTableComponent<TEntity extends RowData>({
527
576
  const skeletonRowCount = Math.min(Math.max(pagination.pageSize, 1), 100)
528
577
 
529
578
  const handleRowClick = (row: TEntity) => (event: MouseEvent<HTMLTableRowElement>) => {
530
- if (!onRowClick || isInteractiveTarget(event.target)) return
579
+ if (!onRowClick || isRowClickIgnored(event.target, event.currentTarget)) return
531
580
  onRowClick(row)
532
581
  }
533
582
 
@@ -802,7 +851,7 @@ function DataTableComponent<TEntity extends RowData>({
802
851
  refetching={isRefetching}
803
852
  empty={empty}
804
853
  onRowClick={onRowClick}
805
- isInteractiveTarget={isInteractiveTarget}
854
+ isRowClickIgnored={isRowClickIgnored}
806
855
  onRetry={onRetry}
807
856
  table={table}
808
857
  skeletonRowCount={skeletonRowCount}
@@ -17,4 +17,35 @@ describe("Kbd", () => {
17
17
  const trigger = screen.getByRole("button", { name: "⌘K" })
18
18
  expect(trigger.className).toContain("focus-visible:ring-brand-500")
19
19
  })
20
+
21
+ it("pairs the light-mode surface with a dark-mode one, so the cap never vanishes", () => {
22
+ render(<Kbd>K</Kbd>)
23
+ const cls = screen.getByText("K").className
24
+ // `bg-white/4` alone is invisible on a near-white page.
25
+ expect(cls).toContain("bg-black/3")
26
+ expect(cls).toContain("dark:bg-white/4")
27
+ })
28
+
29
+ it("sets regular weight, so fallback symbol glyphs are not bolded", () => {
30
+ render(<Kbd>⌘</Kbd>)
31
+ const cls = screen.getByText("⌘").className
32
+ expect(cls).toContain("font-normal")
33
+ expect(cls).not.toContain("font-medium")
34
+ })
35
+
36
+ it.each([
37
+ ["sm", "text-xs"],
38
+ ["md", "text-sm"],
39
+ ["lg", "text-base"],
40
+ ] as const)("uses a legible type step at size %s", (size, text) => {
41
+ render(<Kbd size={size}>Esc</Kbd>)
42
+ expect(screen.getByText("Esc").className).toContain(text)
43
+ })
44
+
45
+ it("draws a 1.5px non-scaling stroke on an inner svg at every size", () => {
46
+ render(<Kbd>K</Kbd>)
47
+ const cls = screen.getByText("K").className
48
+ expect(cls).toContain("[&_svg]:stroke-[1.5]")
49
+ expect(cls).toContain("[&_svg_*]:[vector-effect:non-scaling-stroke]")
50
+ })
20
51
  })