@kanso-labs/kanso-ui 0.47.5 → 0.48.0

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 (82) hide show
  1. package/dist/button/hooks.js +35 -1
  2. package/dist/button/hooks.js.map +1 -1
  3. package/dist/button/index.js +78 -65
  4. package/dist/button/index.js.map +1 -1
  5. package/dist/calendar/styles.js +5 -5
  6. package/dist/calendar/styles.js.map +1 -1
  7. package/dist/chip/styles.js +1 -1
  8. package/dist/chip/styles.js.map +1 -1
  9. package/dist/collection/context.js +6 -0
  10. package/dist/collection/context.js.map +1 -0
  11. package/dist/collection/styles.js +29 -6
  12. package/dist/collection/styles.js.map +1 -1
  13. package/dist/components/button/index.js.map +1 -1
  14. package/dist/components/calendar/index.js +7 -0
  15. package/dist/components/calendar/index.js.map +1 -1
  16. package/dist/components/checkbox/index.js +10 -7
  17. package/dist/components/checkbox/index.js.map +1 -1
  18. package/dist/components/checkbox-group/index.js +2 -1
  19. package/dist/components/checkbox-group/index.js.map +1 -1
  20. package/dist/components/chip-group/index.js +69 -66
  21. package/dist/components/chip-group/index.js.map +1 -1
  22. package/dist/components/color-swatch-picker/index.js +1 -0
  23. package/dist/components/color-swatch-picker/index.js.map +1 -1
  24. package/dist/components/combo-box/index.js +5 -1
  25. package/dist/components/combo-box/index.js.map +1 -1
  26. package/dist/components/drop-zone/styles.js +11 -11
  27. package/dist/components/drop-zone/styles.js.map +1 -1
  28. package/dist/components/fab-menu/index.js +3 -3
  29. package/dist/components/fab-menu/index.js.map +1 -1
  30. package/dist/components/icon-button/index.js.map +1 -1
  31. package/dist/components/list/index.js +58 -11
  32. package/dist/components/list/index.js.map +1 -1
  33. package/dist/components/list-box/index.js +82 -103
  34. package/dist/components/list-box/index.js.map +1 -1
  35. package/dist/components/navigation-rail/index.js +4 -4
  36. package/dist/components/navigation-rail/index.js.map +1 -1
  37. package/dist/components/number-field/index.js +3 -3
  38. package/dist/components/number-field/index.js.map +1 -1
  39. package/dist/components/popover/index.js +3 -3
  40. package/dist/components/popover/index.js.map +1 -1
  41. package/dist/components/radio-group/index.js +12 -11
  42. package/dist/components/radio-group/index.js.map +1 -1
  43. package/dist/components/search-field/index.js +4 -4
  44. package/dist/components/search-field/index.js.map +1 -1
  45. package/dist/components/select/index.js +5 -1
  46. package/dist/components/select/index.js.map +1 -1
  47. package/dist/components/sheet/index.js +1 -1
  48. package/dist/components/sheet/index.js.map +1 -1
  49. package/dist/components/slider/index.js +2 -2
  50. package/dist/components/slider/index.js.map +1 -1
  51. package/dist/components/snackbar/index.js +3 -3
  52. package/dist/components/snackbar/index.js.map +1 -1
  53. package/dist/components/split-button/index.js +53 -41
  54. package/dist/components/split-button/index.js.map +1 -1
  55. package/dist/components/table/index.js +58 -45
  56. package/dist/components/table/index.js.map +1 -1
  57. package/dist/components/tabs/index.js +81 -30
  58. package/dist/components/tabs/index.js.map +1 -1
  59. package/dist/components/time-picker/index.js +5 -5
  60. package/dist/components/time-picker/index.js.map +1 -1
  61. package/dist/components/tree/index.js +78 -21
  62. package/dist/components/tree/index.js.map +1 -1
  63. package/dist/field/index.js +103 -104
  64. package/dist/field/index.js.map +1 -1
  65. package/dist/field/styles.js +1 -1
  66. package/dist/field/styles.js.map +1 -1
  67. package/dist/hooks/useScrollEdges.js +73 -0
  68. package/dist/hooks/useScrollEdges.js.map +1 -0
  69. package/dist/navigation/styles.js +5 -5
  70. package/dist/navigation/styles.js.map +1 -1
  71. package/dist/row/styles.js +7 -7
  72. package/dist/row/styles.js.map +1 -1
  73. package/dist/styles/color.js +16 -16
  74. package/dist/styles/color.js.map +1 -1
  75. package/dist/styles/focus.js +4 -4
  76. package/dist/styles/focus.js.map +1 -1
  77. package/dist/styles/overlay.js +3 -3
  78. package/dist/styles/overlay.js.map +1 -1
  79. package/dist/styles/scroll-fade.js +33 -0
  80. package/dist/styles/scroll-fade.js.map +1 -0
  81. package/dist/styles.css +61 -20
  82. package/package.json +7 -7
@@ -149,7 +149,7 @@ function buttonContent(children, surface, inGroup) {
149
149
  * which is the element a layout positions.
150
150
  */
151
151
  function Checkbox(t0) {
152
- const $ = c(15);
152
+ const $ = c(16);
153
153
  const { children, description, error, ...props$1 } = t0;
154
154
  const validationBehavior = useFieldValidationBehavior();
155
155
  const group = useContext(CheckboxGroupStateContext);
@@ -162,6 +162,7 @@ function Checkbox(t0) {
162
162
  $[0] = t1;
163
163
  } else t1 = $[0];
164
164
  const ripple = useRipple(interactive, t1, true, true);
165
+ const speaks = props$1.slot !== "selection" || description !== void 0 || error !== void 0;
165
166
  const press = { onPress: (event) => {
166
167
  if (event.pointerType === "keyboard") ripple.play();
167
168
  props$1.onPress?.(event);
@@ -194,14 +195,15 @@ function Checkbox(t0) {
194
195
  $[9] = t6;
195
196
  } else t6 = $[9];
196
197
  let t7;
197
- if ($[10] !== description || $[11] !== error || $[12] !== reachable || $[13] !== t6) {
198
- t7 = fieldContent(t6, description, error, reachable);
198
+ if ($[10] !== description || $[11] !== error || $[12] !== reachable || $[13] !== speaks || $[14] !== t6) {
199
+ t7 = fieldContent(t6, description, error, reachable, speaks);
199
200
  $[10] = description;
200
201
  $[11] = error;
201
202
  $[12] = reachable;
202
- $[13] = t6;
203
- $[14] = t7;
204
- } else t7 = $[14];
203
+ $[13] = speaks;
204
+ $[14] = t6;
205
+ $[15] = t7;
206
+ } else t7 = $[15];
205
207
  return /* @__PURE__ */ jsx(CheckboxField, {
206
208
  isInvalid: t2,
207
209
  validationBehavior,
@@ -211,7 +213,8 @@ function Checkbox(t0) {
211
213
  children: t7
212
214
  });
213
215
  }
214
- function fieldContent(button, description, error, reserve) {
216
+ function fieldContent(button, description, error, reserve, speaks) {
217
+ if (!speaks) return button;
215
218
  return ({ isDisabled }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [button, /* @__PURE__ */ jsx("div", {
216
219
  ...props(controlStyles.messages),
217
220
  children: /* @__PURE__ */ jsx(FieldMessage, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_c","stylex","useContext","CheckboxGroupStateContext","controlStyles","invalidFrom","useFieldValidationBehavior","useRipple","focus","mergeStatefulStyles","styles","box","k6CgDc","kWkggS","kZKoxP","kVAM5u","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kzqmXN","kVAEAm","kIyJzY","k1ekBW","kAMwcw","$$css","boxMarked","boxMarkedDisabled","boxMarkedError","boxUnmarkedActive","boxUnmarkedDisabled","boxUnmarkedError","control","hoverLayers","error","marked","unmarked","focusLayers","pressedLayers","children","description","buttonContent","surface","inGroup","state","required","isRequired","isSelected","isIndeterminate","interactive","isDisabled","isReadOnly","tone","isInvalid","active","isHovered","isPressed","isFocusVisible","props","disc","controlReadOnly","controlDisabled","ringVisible","className","Checkbox","t0","$","validationBehavior","group","reachable","validate","undefined","name","t1","Symbol","for","ripple","press","onPress","event","pointerType","play","t2","t3","field","t4","handlers","t5","t6","t7","fieldContent","button","reserve","messages"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { CheckboxButtonRenderProps, CheckboxFieldRenderProps, PressEvent, CheckboxFieldProps as RACCheckboxFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CheckboxButton, CheckboxField, CheckboxGroupStateContext } from 'react-aria-components';\nimport { ControlLabel } from '../../control';\nimport { controlStyles } from '../../control/styles';\nimport { FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CheckGlyph, IndeterminateGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The checkbox page: an 18dp box with a 2dp corner and an 18dp glyph, inside\n// a 40dp state layer, with a 48dp target. Unselected, the box is a 2dp rule\n// in on surface variant that turns on surface while hovered, pressed or\n// focused; selected or indeterminate, it fills with primary and the glyph\n// takes on primary. The error pair is error and on error, and disabled is\n// on surface at the disabled opacity for the rule or the fill, with the\n// glyph in surface. The state layer is on surface over an unselected box and\n// primary over a selected one while hovered, and the two swap once pressed.\n//\n// React Aria's `CheckboxField` is the root, a div holding the description\n// and error slots; its `CheckboxButton` is the label around a visually\n// hidden input, and everything drawn is that label's children, chosen from\n// the render state React Aria hands them. The field is a two-column grid —\n// the control, then the text — and the label is `display: contents`, so the\n// control and the label text each take a column and the description and\n// error line up under the text rather than under the box.\n//\n// The adjacent label is body-large on surface, which the page keeps the same\n// whether or not the box is selected. The corner is a literal: the page's\n// 2dp is a step the shape scale does not carry.\n//\n// A change of state moves together: the fill and the rule fade, and the glyph\n// fades and grows in or shrinks out with them, over the same duration and\n// curve. Both glyphs are always drawn, one over the other, so a box moving\n// between checked and indeterminate crosses from one to the other, and one\n// being cleared fades out the mark it had.\n//\n// The ripple answers every press: on the control, on the text beside it, or\n// from a key, and grows from the middle of the control whichever it is. The\n// text runs the width of the row, so a ripple following the pointer there\n// reached the control only as it finished growing. A key press ripples once\n// the key has activated the checkbox, as Button's does.\n\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n box: {\n k6CgDc: \"x12w9bfk\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xmix8c7\",\n kVAM5u: \"x1is7jjm\",\n kaIpWk: \"x1cum3z5\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xdh2fpr\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"xwjo7ld\",\n k1xSpc: \"x1lliihq\",\n kzqmXN: \"x1xp8n7a\",\n kVAEAm: \"x1n2onr6\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xts7igz\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n boxMarked: {\n kWkggS: \"xnety89\",\n kVAM5u: \"x9r1u3d\",\n $$css: true\n },\n boxMarkedDisabled: {\n kWkggS: \"x1crcgwy\",\n kVAM5u: \"x9r1u3d xmnqt3w\",\n kMwMTN: \"xrpadme x1bhcspo\",\n $$css: true\n },\n boxMarkedError: {\n kWkggS: \"xwi4nbo\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"x1l7c2jh\",\n $$css: true\n },\n boxUnmarkedActive: {\n kVAM5u: \"x1pacwz9\",\n $$css: true\n },\n boxUnmarkedDisabled: {\n kVAM5u: \"xp1r3on xmnqt3w\",\n $$css: true\n },\n boxUnmarkedError: {\n kVAM5u: \"xx78ee7\",\n $$css: true\n },\n control: {\n kMwMTN: \"x139gbkf\",\n $$css: true\n }\n};\n\n// The state layer's colour follows the box: on surface over an unmarked box\n// and primary over a marked one while hovered, the two swapped once pressed,\n// and error throughout while invalid.\nconst hoverLayers = {\n error: {\n kWkggS: \"x55e1u4\",\n $$css: true\n },\n marked: {\n kWkggS: \"x659ado\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n }\n};\n\n// A keyboard's focus draws the hover layer's colour at the focus opacity.\nconst focusLayers = {\n error: {\n kWkggS: \"xyn212m\",\n $$css: true\n },\n marked: {\n kWkggS: \"x1sog3nf\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"xwqhyid\",\n $$css: true\n }\n};\nconst pressedLayers = {\n error: {\n kWkggS: \"x3czxiy\",\n $$css: true\n },\n marked: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n }\n};\ntype CheckboxProps = {\n /**\n * The label, beside the box. A checkbox that a row labels some other way\n * leaves it out and passes `aria-label` instead.\n *\n * A link or a button in it acts on its own, as in a native label: a press\n * or Enter on \"the terms\" in \"I agree to the terms\" follows the link and\n * leaves the checkbox as it was. A press anywhere else in the label\n * toggles it.\n */\n children?: ReactNode;\n /**\n * A hint under the label. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the checkbox in its error state — the message, the error colours and\n * `aria-invalid` all follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n} & Omit<RACCheckboxFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;\ntype Ripple = ReturnType<typeof useRipple<HTMLLabelElement>>;\ntype Tone = 'error' | 'marked' | 'unmarked';\n\n// What the label draws, chosen from the render state React Aria hands it.\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs. The ripple's surface goes on the control while\n// the checkbox can change, and is left off while it cannot, since a press\n// that changes nothing should not look like one. Its handlers are the\n// label's, in `Checkbox` below.\nfunction buttonContent(children: ReactNode, surface: Ripple['surface'], inGroup: boolean) {\n return (state: CheckboxButtonRenderProps) => {\n // A checkbox in a group is marked by the group's label rather than its\n // own: the group is what has to have a choice made in it.\n const required = state.isRequired && !inGroup;\n const marked = state.isSelected || state.isIndeterminate;\n const interactive = !state.isDisabled && !state.isReadOnly;\n const tone: Tone = state.isInvalid ? 'error' : marked ? 'marked' : 'unmarked';\n const active = state.isHovered || state.isPressed || state.isFocusVisible;\n return <>\n <span {...stylex.props(controlStyles.disc, styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled, interactive && state.isHovered && hoverLayers[tone], interactive && state.isFocusVisible && focusLayers[tone], interactive && state.isPressed && pressedLayers[tone], state.isFocusVisible && focus.ringVisible)}>\n <span {...stylex.props(styles.box, marked && styles.boxMarked, !marked && state.isInvalid && styles.boxUnmarkedError, !marked && !state.isInvalid && interactive && active && styles.boxUnmarkedActive, marked && state.isInvalid && styles.boxMarkedError, state.isDisabled && (marked ? styles.boxMarkedDisabled : styles.boxUnmarkedDisabled))}>\n <CheckGlyph {...{\n 0: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g xg01cxk x10l6tqk x1a33avv x1qno0dh x6o7n8i xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g x10l6tqk x1qno0dh x6o7n8i xpc4ca7 x1hc1fzr x3oybdh\"\n }\n }[!!(state.isSelected && !state.isIndeterminate) << 0]} />\n <IndeterminateGlyph {...{\n 0: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g xg01cxk x10l6tqk x1a33avv x1qno0dh x6o7n8i xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g x10l6tqk x1qno0dh x6o7n8i xpc4ca7 x1hc1fzr x3oybdh\"\n }\n }[!!state.isIndeterminate << 0]} />\n </span>\n {interactive ? surface : null}\n </span>\n <ControlLabel isRequired={required} state={state}>\n {children}\n </ControlLabel>\n </>;\n };\n}\n\n/**\n * A checkbox with its label, and optionally a description or an error under\n * it. Its state is React Aria's: pass `isSelected` with `onChange` to\n * control it, or `defaultSelected` to let it keep its own; `isIndeterminate`\n * draws the dash for a box that stands for a partly selected set. Inside a\n * `CheckboxGroup` it takes its `value` and the group's selection instead.\n *\n * `isRequired` ends the label in the asterisk every required field's label\n * ends in. Inside a `CheckboxGroup` the group's label carries it instead,\n * since the group is what must have a choice made in it.\n *\n * The call site's `className` and `style` land on the field as a whole,\n * which is the element a layout positions.\n */\nfunction Checkbox({\n children,\n description,\n error,\n ...props\n}: CheckboxProps & RefAttributes<HTMLDivElement>) {\n const validationBehavior = useFieldValidationBehavior();\n\n // Whether a message can ever reach this checkbox, which is what a form\n // keeps an empty line under a field for. One in a group cannot — the\n // group owns the one message and keeps its own line for it — and one on\n // its own can only where something can find it wanting: a requirement, a\n // check of its own, or a name a form's errors can be keyed by. Without\n // this every checkbox in a form sat a line taller than it draws, and a\n // group of them in a form gained a line after every item.\n const group = useContext(CheckboxGroupStateContext);\n const inGroup = group !== null;\n const reachable = !inGroup && (props.isRequired === true || props.validate !== undefined || props.name !== undefined);\n\n // The ripple listens on the label, which hears a pointer on the control and\n // on the text alike, and grows from the middle of the control for both.\n // React Aria drops a click handler there, so a press ends on its release\n // instead. A key reaches the input rather than the label, so its press is\n // played once it activates the checkbox. React Aria reports that\n // activation twice, as the key and then as the click the browser makes of\n // it, and only the first plays. A checkbox that a press cannot change\n // listens for neither, as in `buttonContent`.\n const interactive = props.isDisabled !== true && props.isReadOnly !== true && group?.isDisabled !== true && group?.isReadOnly !== true;\n const ripple = useRipple<HTMLLabelElement>(interactive, {}, true, true);\n const press = {\n onPress: (event: PressEvent) => {\n if (event.pointerType === 'keyboard') {\n ripple.play();\n }\n props.onPress?.(event);\n }\n };\n return <CheckboxField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...press} {...mergeStatefulStyles(stylex.props(controlStyles.field), props)}>\n {fieldContent(<CheckboxButton {...ripple.handlers} className=\"xjp7ctv\">\n {buttonContent(children, ripple.surface, inGroup)}\n </CheckboxButton>, description, error, reachable)}\n </CheckboxField>;\n}\n\n// The button and the line under it, from the field's render state: the\n// description fades with a disabled checkbox, by itself or by its group, as\n// its label does. Built by a call for the same reason as `buttonContent`.\nfunction fieldContent(button: ReactNode, description: string | undefined, error: string | undefined, reserve: boolean) {\n return ({\n isDisabled\n }: CheckboxFieldRenderProps) => <>\n {button}\n <div {...stylex.props(controlStyles.messages)}>\n <FieldMessage description={description} error={error} indent inset={false} isDisabled={isDisabled} reserve={reserve} />\n </div>\n </>;\n}\nexport type { CheckboxProps };\nexport default Checkbox;"],"mappings":";;;;;;;;;;;;;;;AAwDA,MAAMU,SAAS;CACbC,KAAK;EACHC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EAC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AA,KAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,IAAAsB;CAAA,IAAAtB,EAAA,OAAAU,OAAAU,YAAApB,EAAA,OAAAqB,IAAA;EADvCC,KAAA,oBAAC,gBAAD;GAAe,GAAKH;GAA2B,WAAA;GACxDE,UAAAA;EADwB,CAAA;EAEVrB,EAAA,KAAAU,OAAAU;EAAApB,EAAA,KAAAqB;EAAArB,EAAA,KAAAsB;CAAA,OAAAA,KAAAtB,EAAA;CAAA,IAAAuB;CAAA,IAAAvB,EAAA,QAAA1B,eAAA0B,EAAA,QAAAhC,SAAAgC,EAAA,QAAAG,aAAAH,EAAA,QAAAsB,IAAA;EAFlBC,KAAAC,aAAaF,IAEOhD,aAAaN,OAAOmC,SAAS;EAACH,EAAA,MAAA1B;EAAA0B,EAAA,MAAAhC;EAAAgC,EAAA,MAAAG;EAAAH,EAAA,MAAAsB;EAAAtB,EAAA,MAAAuB;CAAA,OAAAA,KAAAvB,EAAA;CAAA,OAHhD,oBAAC,eAAD;EAA0B,WAAAgB;EAAwCf;EAAkB,GAAMT;EAAK,GAAMmB;EAAK,GAAMM;EAClHM,UAAAA;CADgB,CAAA;AAIH;AAMpB,SAASC,aAAaC,QAAmBnD,aAAiCN,OAA2B0D,SAAkB;CACrH,QAAQ,EACN1C,iBAC8B,qBAAA,YAAA,EAAA,UAAA,CAC3ByC,QACD,oBAAC,OAAD;EAAK,GAAI5F,MAAaG,cAAc2F,QAAQ;EAC1C,UAAA,oBAAC,cAAD;GAA2BrD;GAAoBN;GAAO,QAAA;GAAO,OAAO;GAAmBgB;GAAqB0C;EAAQ,CAAA;CACjH,CAAA,CACP,EAAA,CAAA;AACJ"}
1
+ {"version":3,"file":"index.js","names":["_c","stylex","useContext","CheckboxGroupStateContext","controlStyles","invalidFrom","useFieldValidationBehavior","useRipple","focus","mergeStatefulStyles","styles","box","k6CgDc","kWkggS","kZKoxP","kVAM5u","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kzqmXN","kVAEAm","kIyJzY","k1ekBW","kAMwcw","$$css","boxMarked","boxMarkedDisabled","boxMarkedError","boxUnmarkedActive","boxUnmarkedDisabled","boxUnmarkedError","control","hoverLayers","error","marked","unmarked","focusLayers","pressedLayers","children","description","buttonContent","surface","inGroup","state","required","isRequired","isSelected","isIndeterminate","interactive","isDisabled","isReadOnly","tone","isInvalid","active","isHovered","isPressed","isFocusVisible","props","disc","controlReadOnly","controlDisabled","ringVisible","className","Checkbox","t0","$","validationBehavior","group","reachable","validate","undefined","name","t1","Symbol","for","ripple","speaks","slot","press","onPress","event","pointerType","play","t2","t3","field","t4","handlers","t5","t6","t7","fieldContent","button","reserve","messages"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { CheckboxButtonRenderProps, CheckboxFieldRenderProps, PressEvent, CheckboxFieldProps as RACCheckboxFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { useContext } from 'react';\nimport { CheckboxButton, CheckboxField, CheckboxGroupStateContext } from 'react-aria-components';\nimport { ControlLabel } from '../../control';\nimport { controlStyles } from '../../control/styles';\nimport { FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { CheckGlyph, IndeterminateGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, motion, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\n\n// The checkbox page: an 18dp box with a 2dp corner and an 18dp glyph, inside\n// a 40dp state layer, with a 48dp target. Unselected, the box is a 2dp rule\n// in on surface variant that turns on surface while hovered, pressed or\n// focused; selected or indeterminate, it fills with primary and the glyph\n// takes on primary. The error pair is error and on error, and disabled is\n// on surface at the disabled opacity for the rule or the fill, with the\n// glyph in surface. The state layer is on surface over an unselected box and\n// primary over a selected one while hovered, and the two swap once pressed.\n//\n// React Aria's `CheckboxField` is the root, a div holding the description\n// and error slots; its `CheckboxButton` is the label around a visually\n// hidden input, and everything drawn is that label's children, chosen from\n// the render state React Aria hands them. The field is a two-column grid —\n// the control, then the text — and the label is `display: contents`, so the\n// control and the label text each take a column and the description and\n// error line up under the text rather than under the box.\n//\n// The adjacent label is body-large on surface, which the page keeps the same\n// whether or not the box is selected. The corner is a literal: the page's\n// 2dp is a step the shape scale does not carry.\n//\n// A change of state moves together: the fill and the rule fade, and the glyph\n// fades and grows in or shrinks out with them, over the same duration and\n// curve. Both glyphs are always drawn, one over the other, so a box moving\n// between checked and indeterminate crosses from one to the other, and one\n// being cleared fades out the mark it had.\n//\n// The ripple answers every press: on the control, on the text beside it, or\n// from a key, and grows from the middle of the control whichever it is. The\n// text runs the width of the row, so a ripple following the pointer there\n// reached the control only as it finished growing. A key press ripples once\n// the key has activated the checkbox, as Button's does.\n\n// Windows High Contrast and the rest of the forced-colours modes. Spelled\n// here rather than imported, for the reason src/field/styles.ts records: the\n// StyleX compiler resolves a constant across files only out of a `.stylex.ts`\n// module, and the generated one holds design tokens rather than queries.\nconst FORCED_COLORS = '@media (forced-colors: active)';\nconst styles = {\n box: {\n k6CgDc: \"x12w9bfk\",\n kWkggS: \"xjbqb8w\",\n kZKoxP: \"xmix8c7\",\n kVAM5u: \"x1is7jjm\",\n kaIpWk: \"x1cum3z5\",\n ksu8eU: \"x1y0btm7\",\n kMzoRj: \"xdh2fpr\",\n kB7OPa: \"x9f619\",\n kMwMTN: \"xwjo7ld\",\n k1xSpc: \"x1lliihq\",\n kzqmXN: \"x1xp8n7a\",\n kVAEAm: \"x1n2onr6\",\n kIyJzY: \"x1qno0dh\",\n k1ekBW: \"xts7igz\",\n kAMwcw: \"xpc4ca7\",\n $$css: true\n },\n boxMarked: {\n kWkggS: \"xnety89\",\n kVAM5u: \"x9r1u3d\",\n $$css: true\n },\n boxMarkedDisabled: {\n kWkggS: \"x1crcgwy\",\n kVAM5u: \"x9r1u3d xmnqt3w\",\n kMwMTN: \"xrpadme x1bhcspo\",\n $$css: true\n },\n boxMarkedError: {\n kWkggS: \"xwi4nbo\",\n kVAM5u: \"x9r1u3d\",\n kMwMTN: \"x1l7c2jh\",\n $$css: true\n },\n boxUnmarkedActive: {\n kVAM5u: \"x1pacwz9\",\n $$css: true\n },\n boxUnmarkedDisabled: {\n kVAM5u: \"xp1r3on xmnqt3w\",\n $$css: true\n },\n boxUnmarkedError: {\n kVAM5u: \"xx78ee7\",\n $$css: true\n },\n control: {\n kMwMTN: \"x139gbkf\",\n $$css: true\n }\n};\n\n// The state layer's colour follows the box: on surface over an unmarked box\n// and primary over a marked one while hovered, the two swapped once pressed,\n// and error throughout while invalid.\nconst hoverLayers = {\n error: {\n kWkggS: \"x55e1u4\",\n $$css: true\n },\n marked: {\n kWkggS: \"x659ado\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1b18xnh\",\n $$css: true\n }\n};\n\n// A keyboard's focus draws the hover layer's colour at the focus opacity.\nconst focusLayers = {\n error: {\n kWkggS: \"xyn212m\",\n $$css: true\n },\n marked: {\n kWkggS: \"x1sog3nf\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"xwqhyid\",\n $$css: true\n }\n};\nconst pressedLayers = {\n error: {\n kWkggS: \"x3czxiy\",\n $$css: true\n },\n marked: {\n kWkggS: \"xjeeohs\",\n $$css: true\n },\n unmarked: {\n kWkggS: \"x1dvjsmr\",\n $$css: true\n }\n};\ntype CheckboxProps = {\n /**\n * The label, beside the box. A checkbox that a row labels some other way\n * leaves it out and passes `aria-label` instead.\n *\n * A link or a button in it acts on its own, as in a native label: a press\n * or Enter on \"the terms\" in \"I agree to the terms\" follows the link and\n * leaves the checkbox as it was. A press anywhere else in the label\n * toggles it.\n */\n children?: ReactNode;\n /**\n * A hint under the label. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current value, in words. Its presence is what puts\n * the checkbox in its error state — the message, the error colours and\n * `aria-invalid` all follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n} & Omit<RACCheckboxFieldProps, 'children' | 'isInvalid' | 'validationBehavior'>;\ntype Ripple = ReturnType<typeof useRipple<HTMLLabelElement>>;\ntype Tone = 'error' | 'marked' | 'unmarked';\n\n// What the label draws, chosen from the render state React Aria hands it.\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs. The ripple's surface goes on the control while\n// the checkbox can change, and is left off while it cannot, since a press\n// that changes nothing should not look like one. Its handlers are the\n// label's, in `Checkbox` below.\nfunction buttonContent(children: ReactNode, surface: Ripple['surface'], inGroup: boolean) {\n return (state: CheckboxButtonRenderProps) => {\n // A checkbox in a group is marked by the group's label rather than its\n // own: the group is what has to have a choice made in it.\n const required = state.isRequired && !inGroup;\n const marked = state.isSelected || state.isIndeterminate;\n const interactive = !state.isDisabled && !state.isReadOnly;\n const tone: Tone = state.isInvalid ? 'error' : marked ? 'marked' : 'unmarked';\n const active = state.isHovered || state.isPressed || state.isFocusVisible;\n return <>\n <span {...stylex.props(controlStyles.disc, styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled, interactive && state.isHovered && hoverLayers[tone], interactive && state.isFocusVisible && focusLayers[tone], interactive && state.isPressed && pressedLayers[tone], state.isFocusVisible && focus.ringVisible)}>\n <span {...stylex.props(styles.box, marked && styles.boxMarked, !marked && state.isInvalid && styles.boxUnmarkedError, !marked && !state.isInvalid && interactive && active && styles.boxUnmarkedActive, marked && state.isInvalid && styles.boxMarkedError, state.isDisabled && (marked ? styles.boxMarkedDisabled : styles.boxUnmarkedDisabled))}>\n <CheckGlyph {...{\n 0: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g xg01cxk x10l6tqk x1a33avv x1qno0dh x6o7n8i xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g x10l6tqk x1qno0dh x6o7n8i xpc4ca7 x1hc1fzr x3oybdh\"\n }\n }[!!(state.isSelected && !state.isIndeterminate) << 0]} />\n <IndeterminateGlyph {...{\n 0: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g xg01cxk x10l6tqk x1a33avv x1qno0dh x6o7n8i xpc4ca7\"\n },\n 1: {\n className: \"x12w9bfk xmix8c7 x1lliihq x1xp8n7a x1qiirwl x5pnq3g x10l6tqk x1qno0dh x6o7n8i xpc4ca7 x1hc1fzr x3oybdh\"\n }\n }[!!state.isIndeterminate << 0]} />\n </span>\n {interactive ? surface : null}\n </span>\n <ControlLabel isRequired={required} state={state}>\n {children}\n </ControlLabel>\n </>;\n };\n}\n\n/**\n * A checkbox with its label, and optionally a description or an error under\n * it. Its state is React Aria's: pass `isSelected` with `onChange` to\n * control it, or `defaultSelected` to let it keep its own; `isIndeterminate`\n * draws the dash for a box that stands for a partly selected set. Inside a\n * `CheckboxGroup` it takes its `value` and the group's selection instead.\n *\n * `isRequired` ends the label in the asterisk every required field's label\n * ends in. Inside a `CheckboxGroup` the group's label carries it instead,\n * since the group is what must have a choice made in it.\n *\n * The call site's `className` and `style` land on the field as a whole,\n * which is the element a layout positions.\n */\nfunction Checkbox({\n children,\n description,\n error,\n ...props\n}: CheckboxProps & RefAttributes<HTMLDivElement>) {\n const validationBehavior = useFieldValidationBehavior();\n\n // Whether a message can ever reach this checkbox, which is what a form\n // keeps an empty line under a field for. One in a group cannot — the\n // group owns the one message and keeps its own line for it — and one on\n // its own can only where something can find it wanting: a requirement, a\n // check of its own, or a name a form's errors can be keyed by. Without\n // this every checkbox in a form sat a line taller than it draws, and a\n // group of them in a form gained a line after every item.\n const group = useContext(CheckboxGroupStateContext);\n const inGroup = group !== null;\n const reachable = !inGroup && (props.isRequired === true || props.validate !== undefined || props.name !== undefined);\n\n // The ripple listens on the label, which hears a pointer on the control and\n // on the text alike, and grows from the middle of the control for both.\n // React Aria drops a click handler there, so a press ends on its release\n // instead. A key reaches the input rather than the label, so its press is\n // played once it activates the checkbox. React Aria reports that\n // activation twice, as the key and then as the click the browser makes of\n // it, and only the first plays. A checkbox that a press cannot change\n // listens for neither, as in `buttonContent`.\n const interactive = props.isDisabled !== true && props.isReadOnly !== true && group?.isDisabled !== true && group?.isReadOnly !== true;\n const ripple = useRipple<HTMLLabelElement>(interactive, {}, true, true);\n\n // Whether the line under the checkbox is drawn at all. It is drawn even\n // empty, since it holds the live region an error is read out from, and a\n // region has to be in the document before the error it announces arrives\n // — see `FieldMessage`. A collection's selection checkbox is the one that\n // never has anything to say: the row it selects labels it, nothing\n // validates it, and it is drawn by the List, Tree or Table rather than by\n // a call site, so nothing can hand it a message later either. Drawn, the\n // line was a `FieldMessage` and a `FieldError` in every row, re-rendered\n // with the row on every selection change while showing nothing.\n const speaks = props.slot !== 'selection' || description !== undefined || error !== undefined;\n const press = {\n onPress: (event: PressEvent) => {\n if (event.pointerType === 'keyboard') {\n ripple.play();\n }\n props.onPress?.(event);\n }\n };\n return <CheckboxField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...press} {...mergeStatefulStyles(stylex.props(controlStyles.field), props)}>\n {fieldContent(<CheckboxButton {...ripple.handlers} className=\"xjp7ctv\">\n {buttonContent(children, ripple.surface, inGroup)}\n </CheckboxButton>, description, error, reachable, speaks)}\n </CheckboxField>;\n}\n\n// The button and the line under it, from the field's render state: the\n// description fades with a disabled checkbox, by itself or by its group, as\n// its label does. Built by a call for the same reason as `buttonContent`.\n// Without `speaks` the button is all there is — see `Checkbox`.\nfunction fieldContent(button: ReactNode, description: string | undefined, error: string | undefined, reserve: boolean, speaks: boolean): RACCheckboxFieldProps['children'] {\n if (!speaks) {\n return button;\n }\n return ({\n isDisabled\n }: CheckboxFieldRenderProps) => <>\n {button}\n <div {...stylex.props(controlStyles.messages)}>\n <FieldMessage description={description} error={error} indent inset={false} isDisabled={isDisabled} reserve={reserve} />\n </div>\n </>;\n}\nexport type { CheckboxProps };\nexport default Checkbox;"],"mappings":";;;;;;;;;;;;;;;AAwDA,MAAMU,SAAS;CACbC,KAAK;EACHC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,WAAW;EACTf,QAAQ;EACRE,QAAQ;EACRY,OAAO;CACT;CACAE,mBAAmB;EACjBhB,QAAQ;EACRE,QAAQ;EACRK,QAAQ;EACRO,OAAO;CACT;CACAG,gBAAgB;EACdjB,QAAQ;EACRE,QAAQ;EACRK,QAAQ;EACRO,OAAO;CACT;CACAI,mBAAmB;EACjBhB,QAAQ;EACRY,OAAO;CACT;CACAK,qBAAqB;EACnBjB,QAAQ;EACRY,OAAO;CACT;CACAM,kBAAkB;EAChBlB,QAAQ;EACRY,OAAO;CACT;CACAO,SAAS;EACPd,QAAQ;EACRO,OAAO;CACT;AACF;AAKA,MAAMQ,cAAc;CAClBC,OAAO;EACLvB,QAAQ;EACRc,OAAO;CACT;CACAU,QAAQ;EACNxB,QAAQ;EACRc,OAAO;CACT;CACAW,UAAU;EACRzB,QAAQ;EACRc,OAAO;CACT;AACF;AAGA,MAAMY,cAAc;CAClBH,OAAO;EACLvB,QAAQ;EACRc,OAAO;CACT;CACAU,QAAQ;EACNxB,QAAQ;EACRc,OAAO;CACT;CACAW,UAAU;EACRzB,QAAQ;EACRc,OAAO;CACT;AACF;AACA,MAAMa,gBAAgB;CACpBJ,OAAO;EACLvB,QAAQ;EACRc,OAAO;CACT;CACAU,QAAQ;EACNxB,QAAQ;EACRc,OAAO;CACT;CACAW,UAAU;EACRzB,QAAQ;EAC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AA,EAAA,UAAA,CAC3B2C,QACD,oBAAC,OAAD;EAAK,GAAI9F,MAAaG,cAAc6F,QAAQ;EAC1C,UAAA,oBAAC,cAAD;GAA2BvD;GAAoBN;GAAO,QAAA;GAAO,OAAO;GAAmBgB;GAAqB4C;EAAQ,CAAA;CACjH,CAAA,CACP,EAAA,CAAA;AACJ"}
@@ -62,8 +62,9 @@ function CheckboxGroup(t0) {
62
62
  function groupContent(label, children, description, error) {
63
63
  return (state) => /* @__PURE__ */ jsxs(Fragment, { children: [
64
64
  /* @__PURE__ */ jsx(FieldLabel, {
65
+ isDisabled: state.isDisabled,
66
+ isInvalid: state.isInvalid,
65
67
  isRequired: state.isRequired,
66
- state,
67
68
  variant: "group",
68
69
  children: label
69
70
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_c","stylex","CheckboxGroup","RACCheckboxGroup","controlStyles","invalidFrom","useFieldValidationBehavior","groupStyles","mergeStatefulStyles","children","description","error","label","t0","$","props","validationBehavior","T0","t1","t2","root","t3","groupContent","t4","state","isRequired","stack","isDisabled"],"sources":["../../../src/components/checkbox-group/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { CheckboxGroupRenderProps, CheckboxGroupProps as RACCheckboxGroupProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { CheckboxGroup as RACCheckboxGroup } from 'react-aria-components';\nimport { controlStyles } from '../../control/styles';\nimport { FieldLabel, FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { groupStyles } from '../../field/styles';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// A labelled set of checkboxes sharing one value. The checkbox page draws\n// the boxes; the group is what the ARIA pattern asks for around them — a\n// group named by its label, described by its description, and invalid as a\n// whole — and its label, description and error are the field chrome's, so a\n// group reads like the fields beside it. The label is label-large, the role\n// a field's label takes at rest, since a group has no box to float it in.\ntype CheckboxGroupProps = {\n /** The checkboxes, each with a `value` of its own. */\n children?: ReactNode;\n /**\n * A hint under the group. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current selection, in words. Its presence is what\n * puts the group in its error state — the message, the boxes' error\n * colours and `aria-invalid` all follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n /**\n * What the group is for. Required rather than optional: a group of\n * checkboxes with no name is a set of boxes a screen reader cannot\n * introduce.\n */\n label: string;\n} & Omit<RACCheckboxGroupProps, 'children' | 'isInvalid' | 'validationBehavior'>;\n\n/**\n * A labelled set of checkboxes with one value between them. The value is\n * React Aria's: pass `value` with `onChange` to control it, or\n * `defaultValue` to let the group keep its own, and each `Checkbox` inside\n * names the entry it stands for with `value`. Disabled, read-only and the\n * error state reach every checkbox from here.\n *\n * The call site's `className` and `style` land on the group as a whole,\n * which is the element a layout positions.\n */\nfunction CheckboxGroup({\n children,\n description,\n error,\n label,\n ...props\n}: CheckboxGroupProps & RefAttributes<HTMLDivElement>) {\n const validationBehavior = useFieldValidationBehavior();\n return <RACCheckboxGroup isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(groupStyles.root), props)}>\n {groupContent(label, children, description, error)}\n </RACCheckboxGroup>;\n}\n\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs. The label takes the group's render state, so\n// its colour follows disabled and invalid the way a field's follows its box.\nfunction groupContent(label: string, children: ReactNode, description: string | undefined, error: string | undefined) {\n return (state: CheckboxGroupRenderProps) => <>\n <FieldLabel isRequired={state.isRequired} state={state} variant=\"group\">\n {label}\n </FieldLabel>\n <div {...stylex.props(controlStyles.stack)}>{children}</div>\n <FieldMessage description={description} error={error} inset={false} isDisabled={state.isDisabled} />\n </>;\n}\nexport type { CheckboxGroupProps };\nexport default CheckboxGroup;"],"mappings":";;;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AAA;EACxC,oBAAC,YAAD;GAAY,YAAYA,MAAMC;GAAmBD;GAAO,SAAQ;GAC7DZ,UAAAA;EACS,CAAA;EACZ,oBAAC,OAAD;GAAK,GAAIX,MAAaG,cAAcsB,KAAK;GAAIjB;EAAc,CAAA;EAC3D,oBAAC,cAAD;GAA2BC;GAAoBC;GAAO,OAAO;GAAO,YAAYa,MAAMG;EAAW,CAAA;CACnG,EAAA,CAAA;AACJ"}
1
+ {"version":3,"file":"index.js","names":["_c","stylex","CheckboxGroup","RACCheckboxGroup","controlStyles","invalidFrom","useFieldValidationBehavior","groupStyles","mergeStatefulStyles","children","description","error","label","t0","$","props","validationBehavior","T0","t1","t2","root","t3","groupContent","t4","state","isDisabled","isInvalid","isRequired","stack"],"sources":["../../../src/components/checkbox-group/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { CheckboxGroupRenderProps, CheckboxGroupProps as RACCheckboxGroupProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { CheckboxGroup as RACCheckboxGroup } from 'react-aria-components';\nimport { controlStyles } from '../../control/styles';\nimport { FieldLabel, FieldMessage } from '../../field';\nimport { invalidFrom, useFieldValidationBehavior } from '../../field/root';\nimport { groupStyles } from '../../field/styles';\nimport { mergeStatefulStyles } from '../../styles/merge';\n\n// A labelled set of checkboxes sharing one value. The checkbox page draws\n// the boxes; the group is what the ARIA pattern asks for around them — a\n// group named by its label, described by its description, and invalid as a\n// whole — and its label, description and error are the field chrome's, so a\n// group reads like the fields beside it. The label is label-large, the role\n// a field's label takes at rest, since a group has no box to float it in.\ntype CheckboxGroupProps = {\n /** The checkboxes, each with a `value` of its own. */\n children?: ReactNode;\n /**\n * A hint under the group. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current selection, in words. Its presence is what\n * puts the group in its error state — the message, the boxes' error\n * colours and `aria-invalid` all follow from it.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n /**\n * What the group is for. Required rather than optional: a group of\n * checkboxes with no name is a set of boxes a screen reader cannot\n * introduce.\n */\n label: string;\n} & Omit<RACCheckboxGroupProps, 'children' | 'isInvalid' | 'validationBehavior'>;\n\n/**\n * A labelled set of checkboxes with one value between them. The value is\n * React Aria's: pass `value` with `onChange` to control it, or\n * `defaultValue` to let the group keep its own, and each `Checkbox` inside\n * names the entry it stands for with `value`. Disabled, read-only and the\n * error state reach every checkbox from here.\n *\n * The call site's `className` and `style` land on the group as a whole,\n * which is the element a layout positions.\n */\nfunction CheckboxGroup({\n children,\n description,\n error,\n label,\n ...props\n}: CheckboxGroupProps & RefAttributes<HTMLDivElement>) {\n const validationBehavior = useFieldValidationBehavior();\n return <RACCheckboxGroup isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(groupStyles.root), props)}>\n {groupContent(label, children, description, error)}\n </RACCheckboxGroup>;\n}\n\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's no-new-function-as-prop is after; the React Compiler memoises\n// the result on its inputs. The label takes the group's render state, so\n// its colour follows disabled and invalid the way a field's follows its box.\nfunction groupContent(label: string, children: ReactNode, description: string | undefined, error: string | undefined) {\n return (state: CheckboxGroupRenderProps) => <>\n <FieldLabel isDisabled={state.isDisabled} isInvalid={state.isInvalid} isRequired={state.isRequired} variant=\"group\">\n {label}\n </FieldLabel>\n <div {...stylex.props(controlStyles.stack)}>{children}</div>\n <FieldMessage description={description} error={error} inset={false} isDisabled={state.isDisabled} />\n </>;\n}\nexport type { CheckboxGroupProps };\nexport default CheckboxGroup;"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsDA,SAAAE,cAAAW,IAAA;CAAA,MAAAC,IAAAd,EAAA,EAAA;CAAuB,MAAA,EAAAS,UAAAC,aAAAC,OAAAC,OAAA,GAAAG,YAAAF;CAOrB,MAAAG,qBAA2BV,2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,KAAK;GAAInB;EAAc,CAAA;EAC3D,oBAAC,cAAD;GAA2BC;GAAoBC;GAAO,OAAO;GAAO,YAAYa,MAAMC;EAAW,CAAA;CACnG,EAAA,CAAA;AACJ"}
@@ -44,8 +44,6 @@ function chipContent(children, icon, removeLabel, surface, acts) {
44
44
  }
45
45
  const RemoveLabelContext = createContext(void 0);
46
46
  const GroupActionContext = createContext(false);
47
- const LABEL_STATE_VALID = { isInvalid: false };
48
- const LABEL_STATE_INVALID = { isInvalid: true };
49
47
  function actingChipPropsFor(state) {
50
48
  return chipPropsFor(state, { kind: kindOf(state) });
51
49
  }
@@ -80,7 +78,7 @@ function actingChipPropsFor(state) {
80
78
  * which is the element a layout positions.
81
79
  */
82
80
  function ChipGroup(t0) {
83
- const $ = c(39);
81
+ const $ = c(41);
84
82
  let T0;
85
83
  let children;
86
84
  let description;
@@ -105,7 +103,13 @@ function ChipGroup(t0) {
105
103
  renderEmptyState = t11;
106
104
  props$1 = t12;
107
105
  const escapeKeyBehavior = t7 === void 0 ? "none" : t7;
108
- invalid = invalidFrom(error);
106
+ let t13;
107
+ if ($[14] !== error) {
108
+ t13 = invalidFrom(error);
109
+ $[14] = error;
110
+ $[15] = t13;
111
+ } else t13 = $[15];
112
+ invalid = t13;
109
113
  T0 = TagGroup;
110
114
  t1 = escapeKeyBehavior;
111
115
  t2 = props$1;
@@ -139,90 +143,89 @@ function ChipGroup(t0) {
139
143
  t2 = $[12];
140
144
  t3 = $[13];
141
145
  }
142
- const t4 = invalid ? LABEL_STATE_INVALID : LABEL_STATE_VALID;
143
- let t5;
144
- if ($[14] !== label || $[15] !== t4) {
145
- t5 = /* @__PURE__ */ jsx(FieldLabel, {
146
- state: t4,
146
+ let t4;
147
+ if ($[16] !== invalid || $[17] !== label) {
148
+ t4 = /* @__PURE__ */ jsx(FieldLabel, {
149
+ isInvalid: invalid,
147
150
  variant: "group",
148
151
  children: label
149
152
  });
150
- $[14] = label;
151
- $[15] = t4;
152
- $[16] = t5;
153
- } else t5 = $[16];
154
- const t6 = props$1.onAction !== void 0;
153
+ $[16] = invalid;
154
+ $[17] = label;
155
+ $[18] = t4;
156
+ } else t4 = $[18];
157
+ const t5 = props$1.onAction !== void 0;
158
+ let t6;
159
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
160
+ t6 = props(styles.list, focus.ring);
161
+ $[19] = t6;
162
+ } else t6 = $[19];
155
163
  let t7;
156
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
157
- t7 = props(styles.list, focus.ring);
158
- $[17] = t7;
159
- } else t7 = $[17];
160
- let t8;
161
- if ($[18] !== children || $[19] !== items || $[20] !== renderEmptyState) {
162
- t8 = /* @__PURE__ */ jsx(TagList, {
164
+ if ($[20] !== children || $[21] !== items || $[22] !== renderEmptyState) {
165
+ t7 = /* @__PURE__ */ jsx(TagList, {
163
166
  items,
164
167
  renderEmptyState,
165
- ...t7,
168
+ ...t6,
166
169
  children
167
170
  });
168
- $[18] = children;
169
- $[19] = items;
170
- $[20] = renderEmptyState;
171
- $[21] = t8;
172
- } else t8 = $[21];
171
+ $[20] = children;
172
+ $[21] = items;
173
+ $[22] = renderEmptyState;
174
+ $[23] = t7;
175
+ } else t7 = $[23];
176
+ let t8;
177
+ if ($[24] !== t5 || $[25] !== t7) {
178
+ t8 = /* @__PURE__ */ jsx(GroupActionContext, {
179
+ value: t5,
180
+ children: t7
181
+ });
182
+ $[24] = t5;
183
+ $[25] = t7;
184
+ $[26] = t8;
185
+ } else t8 = $[26];
173
186
  let t9;
174
- if ($[22] !== t6 || $[23] !== t8) {
175
- t9 = /* @__PURE__ */ jsx(GroupActionContext, {
176
- value: t6,
187
+ if ($[27] !== removeLabel || $[28] !== t8) {
188
+ t9 = /* @__PURE__ */ jsx(RemoveLabelContext, {
189
+ value: removeLabel,
177
190
  children: t8
178
191
  });
179
- $[22] = t6;
180
- $[23] = t8;
181
- $[24] = t9;
182
- } else t9 = $[24];
192
+ $[27] = removeLabel;
193
+ $[28] = t8;
194
+ $[29] = t9;
195
+ } else t9 = $[29];
183
196
  let t10;
184
- if ($[25] !== removeLabel || $[26] !== t9) {
185
- t10 = /* @__PURE__ */ jsx(RemoveLabelContext, {
186
- value: removeLabel,
187
- children: t9
188
- });
189
- $[25] = removeLabel;
190
- $[26] = t9;
191
- $[27] = t10;
192
- } else t10 = $[27];
193
- let t11;
194
- if ($[28] !== description || $[29] !== error) {
195
- t11 = /* @__PURE__ */ jsx(FieldMessage, {
197
+ if ($[30] !== description || $[31] !== error) {
198
+ t10 = /* @__PURE__ */ jsx(FieldMessage, {
196
199
  description,
197
200
  error,
198
201
  inset: false
199
202
  });
200
- $[28] = description;
201
- $[29] = error;
202
- $[30] = t11;
203
- } else t11 = $[30];
204
- let t12;
205
- if ($[31] !== T0 || $[32] !== t1 || $[33] !== t10 || $[34] !== t11 || $[35] !== t2 || $[36] !== t3 || $[37] !== t5) {
206
- t12 = /* @__PURE__ */ jsxs(T0, {
203
+ $[30] = description;
204
+ $[31] = error;
205
+ $[32] = t10;
206
+ } else t10 = $[32];
207
+ let t11;
208
+ if ($[33] !== T0 || $[34] !== t1 || $[35] !== t10 || $[36] !== t2 || $[37] !== t3 || $[38] !== t4 || $[39] !== t9) {
209
+ t11 = /* @__PURE__ */ jsxs(T0, {
207
210
  escapeKeyBehavior: t1,
208
211
  ...t2,
209
212
  ...t3,
210
213
  children: [
211
- t5,
212
- t10,
213
- t11
214
+ t4,
215
+ t9,
216
+ t10
214
217
  ]
215
218
  });
216
- $[31] = T0;
217
- $[32] = t1;
218
- $[33] = t10;
219
- $[34] = t11;
220
- $[35] = t2;
221
- $[36] = t3;
222
- $[37] = t5;
223
- $[38] = t12;
224
- } else t12 = $[38];
225
- return t12;
219
+ $[33] = T0;
220
+ $[34] = t1;
221
+ $[35] = t10;
222
+ $[36] = t2;
223
+ $[37] = t3;
224
+ $[38] = t4;
225
+ $[39] = t9;
226
+ $[40] = t11;
227
+ } else t11 = $[40];
228
+ return t11;
226
229
  }
227
230
  /**
228
231
  * One chip. Give every chip an `id` — that is the key selection and removal
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_c","stylex","createContext","useContext","RACTag","RACTagGroup","chipGlyph","chipLabel","chipPropsFor","chipRemoveClassName","chipStyles","textOf","invalidFrom","groupStyles","useRipple","focus","mergeStatefulStyles","mergeStyles","styles","list","kGNEyG","kaIpWk","kB7OPa","k1xSpc","kwnvtZ","kOIVth","kAzted","kg3NbH","$$css","children","icon","textValue","description","error","escapeKeyBehavior","label","removeLabel","chipContent","surface","acts","state","selectionMode","isDisabled","props","surfaceCorners","allowsRemoving","removeGlyph","RemoveLabelContext","undefined","GroupActionContext","LABEL_STATE_VALID","isInvalid","LABEL_STATE_INVALID","actingChipPropsFor","kind","kindOf","ChipGroup","t0","$","T0","invalid","items","renderEmptyState","t1","t2","t3","t4","t5","t6","t7","t8","t9","t10","t11","t12","root","onAction","Symbol","for","ring","ChipGroupChip","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","href","ripple","handlers","groupChipPropsFor","inert","Chip","RACButton","RACTagList"],"sources":["../../../src/components/chip-group/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactElement, ReactNode, RefAttributes } from 'react';\nimport type { TagGroupProps as RACTagGroupProps, TagListProps as RACTagListProps, TagProps as RACTagProps, TagRenderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { createContext, useContext } from 'react';\nimport { Button as RACButton, Tag as RACTag, TagGroup as RACTagGroup, TagList as RACTagList } from 'react-aria-components';\nimport { chipGlyph, chipLabel, chipPropsFor, chipRemoveClassName } from '../../chip';\nimport { chipStyles } from '../../chip/styles';\nimport { textOf } from '../../collection/text';\nimport { FieldLabel, FieldMessage } from '../../field';\nimport { invalidFrom } from '../../field/root';\nimport { groupStyles } from '../../field/styles';\nimport { CloseGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, sizing, spacing } from '../../tokens/design.tokens.stylex';\n\n// The chips page's filter and input chips as a set: one or more chosen from a\n// row, each one removable. The pill is the chip module's in `src/chip`,\n// shared with the standalone Chip, so the two cannot drift; what is here is\n// the group around them.\n//\n// Three things it adds over a row of Chips.\n//\n// **It is a group, not a row of buttons.** React Aria's `TagGroup` names the\n// set, describes it, points it at its error, and moves between its chips\n// with the arrow keys rather than making each one a tab stop — which\n// is what a set of a dozen filters needs. The label, the supporting line and\n// the error are the field chrome's, so a group reads like the fields beside\n// it, exactly as CheckboxGroup and RadioGroup do.\n//\n// **A chip can be removed.** Give the group `onRemove` and each chip draws\n// the page's trailing close target, an 18dp glyph in a target of its own so a\n// press there removes rather than toggles. Backspace and Delete remove the\n// focused chip too, which is React Aria's. A chosen chip's check sits at the\n// other end, so a chip that is both selected and removable carries one glyph\n// on each side of its label.\n//\n// **Selection is the group's, not each chip's.** `selectionMode` and\n// `selectedKeys` live on the group, so a set that chooses one of its chips\n// and a set that chooses several are the same component with a different\n// word. A chip on its own that toggles nothing else is still Chip.\n//\n// **Escape leaves the selection alone.** React Aria's collections clear the\n// selection on Escape and stop the key there, which suits a list whose\n// selection is what an action is about to act on. A set of chips holds a\n// value, as a checkbox group does, and usually sits in a Sheet, Dialog or\n// Popover, where Escape is what dismisses it: clearing it there wiped the\n// reader's filters and took a second press to close. So the group passes\n// React Aria's `escapeKeyBehavior` as `none` unless told `clearSelection`.\n//\n// **A chip a press does nothing to does not look pressable.** In a group\n// that selects nothing, a chip with no action of its own or the group's is\n// a control only for its close target. It draws the arrow cursor, no layer\n// and no ripple, and its close target keeps the pointer. A disabled chip's\n// close target takes the chip's `not-allowed` with it.\n//\n// One thing is worth knowing about how this maps onto React Aria. A chip's\n// text value is read off its children and found only when they are a plain\n// string, and a chip here is always an element — the label sits beside a\n// close target. So a plain-string label is passed through as the text value,\n// which is what typeahead and a screen reader's announcement are made of;\n// see ListBox.Item, where the same thing bit.\n\nconst styles = {\n list: {\n kGNEyG: \"x6s0dn4\",\n kaIpWk: \"x1xdvaa9\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kwnvtZ: \"x1a02dak\",\n kOIVth: \"x126z3so\",\n kAzted: \"xlzjxrf\",\n kg3NbH: \"x91pird xnjsko4\",\n $$css: true\n }\n};\ntype ChipGroupChipProps = {\n /**\n * The chip's label. Text, numbers, or a mix of the two — `Label {3}` —\n * also name the chip; a label holding an element needs `textValue`.\n */\n children?: ReactNode;\n /** A function may compute the class from the chip's render state. */\n className?: RACTagProps['className'];\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * The check takes its place while the chip is chosen, so the chip keeps\n * its width. An icon drawn in `em` takes its size from the slot.\n */\n icon?: ReactNode;\n /** A function may compute the style from the chip's render state. */\n style?: RACTagProps['style'];\n /**\n * The chip's name as text, which is what a screen reader announces for\n * its row. Read from the label when that is text or numbers, so it is\n * needed only when the label holds an element — emphasis, a count in a\n * badge — and React Aria warns in the console when such a chip has none.\n * Given, it wins over the text read from the label.\n */\n textValue?: string;\n} & Omit<RACTagProps, 'children' | 'className' | 'style' | 'textValue'>;\ntype ChipGroupProps<T extends object = object> = {\n /**\n * The chips, each with an `id` of its own. With `items`, a function from an\n * item to its chip, which React Aria calls for each item in turn.\n */\n children?: ((item: T) => ReactElement) | ReactNode;\n /**\n * A hint under the group. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current selection, in words. Its presence is what\n * puts the group in its error state: the label and the message take the\n * error colour, the grid's `aria-describedby` names the message, and the\n * message is read out politely as it appears. The grid carries no\n * `aria-invalid`, which ARIA does not allow on a grid, so the message is\n * the whole of what a screen reader is told.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n /**\n * What Escape does on a chip. `none`, the default, keeps the selection and\n * lets the key through to whatever is around the group, so a group in a\n * Sheet, Dialog or Popover closes it on the first press. `clearSelection`\n * empties the selection first, as React Aria's own default does, and lets\n * a second press through.\n *\n * @default 'none'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n /**\n * What the group is for. Required rather than optional: a set of chips\n * with no name is a row a screen reader cannot introduce.\n */\n label: string;\n /**\n * What the close target on each chip is called, for a screen reader. React\n * Aria adds the chip's own label after it, so this is the verb rather than\n * the whole phrase — \"Remove\" becomes \"Remove First item\". Left out, React\n * Aria names it in the reader's locale — \"Remove\" in English.\n */\n removeLabel?: string;\n} & Omit<RACTagGroupProps, 'children' | 'escapeKeyBehavior'> & Pick<RACTagListProps<T>, 'items' | 'renderEmptyState'>;\n\n// What the chip draws, from React Aria's render state. Built by a call rather\n// than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after; the React Compiler memoises the result on\n// its inputs.\n//\n// The check and the icon it replaces are the chip module's, so a chip in a\n// group and a chip on its own draw the same ones. The close target is drawn\n// only where the group allows removing, which React Aria reports rather than\n// the call site saying so on every chip.\n//\n// The ripple is drawn only on a chip a press does something to, and not\n// disabled: one the group lets be selected, or one with an action, its own\n// or the group's. Any other chip in a group that selects nothing is a\n// control only for its close target, and React Aria reports neither hover\n// nor press on it, so a ripple there would answer a press that changes\n// nothing. `acts` is the action half, which the render state does not carry.\n//\n// It sits in a box of its own carrying the chip's corner, since React Aria's\n// cell between the chip and this content would otherwise hand the ripple a\n// square one to inherit; see the header of src/chip/styles.ts.\nfunction chipContent(children: ReactNode, icon: ReactNode, removeLabel: string | undefined, surface: ReactNode, acts: boolean) {\n return (state: TagRenderProps) => <>\n {chipGlyph(state, icon, state.selectionMode !== 'none')}\n {chipLabel(children)}\n {(acts || state.selectionMode !== 'none') && !state.isDisabled ? <span {...stylex.props(chipStyles.surfaceCorners)}>{surface}</span> : null}\n {state.allowsRemoving ? <RACButton aria-label={removeLabel} className={chipRemoveClassName} slot=\"remove\">\n <CloseGlyph {...stylex.props(chipStyles.removeGlyph)} />\n </RACButton> : null}\n </>;\n}\n\n// What each chip calls its close target. A context rather than a prop on the\n// chip, since it is the group's decision and repeating it on every chip is\n// how the two drift. Undefined unless the group is given one, which leaves\n// the name React Aria gives in the reader's locale.\nconst RemoveLabelContext = createContext<string | undefined>(undefined);\n\n// Whether the group was given `onAction`, which makes every chip in it\n// pressable whether or not it selects. A context for the reason the close\n// target's name is one.\nconst GroupActionContext = createContext(false);\n\n// Hoisted so neither is a new object on every render.\nconst LABEL_STATE_VALID = {\n isInvalid: false\n};\nconst LABEL_STATE_INVALID = {\n isInvalid: true\n};\n\n// The pill of a chip with an action, which a press always reaches.\nfunction actingChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state, {\n kind: kindOf(state)\n });\n}\n\n/**\n * A labelled set of chips, one or more of which can be chosen, each of which\n * can be removed. Selection is React Aria's: set `selectionMode` to `single`\n * or `multiple` and pass `selectedKeys` with `onSelectionChange` to control\n * it, or `defaultSelectedKeys` to let it keep its own.\n *\n * ```tsx\n * <ChipGroup label=\"Label\" selectionMode=\"multiple\" onRemove={remove}>\n * <ChipGroup.Chip id=\"first\">First item</ChipGroup.Chip>\n * </ChipGroup>\n * ```\n *\n * Give the group `onRemove` and each chip draws a close target. The arrow\n * keys move between chips, so a set of many is one tab stop rather than many.\n *\n * A chip is never wider than its row, so a label with no room ends in an\n * ellipsis rather than wrapping, and shows its full text in the browser's\n * tooltip on hover.\n *\n * Escape on a chip keeps the selection and reaches whatever is around the\n * group, so a group in a Sheet, Dialog or Popover closes it. Pass\n * `escapeKeyBehavior=\"clearSelection\"` for React Aria's own default, which\n * empties the selection on the first press and lets the second through.\n *\n * A chip that toggles nothing else is Chip; this is for a set that shares a\n * value.\n *\n * The call site's `className` and `style` land on the group as a whole,\n * which is the element a layout positions.\n */\nfunction ChipGroup<T extends object = object>({\n children,\n description,\n error,\n escapeKeyBehavior = 'none',\n items,\n label,\n removeLabel,\n renderEmptyState,\n ...props\n}: ChipGroupProps<T> & RefAttributes<HTMLDivElement>) {\n const invalid = invalidFrom(error);\n return <RACTagGroup escapeKeyBehavior={escapeKeyBehavior} {...props} {...mergeStyles(stylex.props(groupStyles.root), props)}>\n {/* React Aria's tag group has no disabled state of its own — a chip is\n disabled through the group's `disabledKeys` — so the label follows\n validity alone. */}\n <FieldLabel state={invalid ? LABEL_STATE_INVALID : LABEL_STATE_VALID} variant=\"group\">\n {label}\n </FieldLabel>\n <RemoveLabelContext value={removeLabel}>\n <GroupActionContext value={props.onAction !== undefined}>\n <RACTagList<T> items={items} renderEmptyState={renderEmptyState} {...stylex.props(styles.list, focus.ring)}>\n {children}\n </RACTagList>\n </GroupActionContext>\n </RemoveLabelContext>\n <FieldMessage description={description} error={error} inset={false} />\n </RACTagGroup>;\n}\n\n/**\n * One chip. Give every chip an `id` — that is the key selection and removal\n * are reported by.\n */\nfunction ChipGroupChip({\n children,\n icon,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n ...props\n}: ChipGroupChipProps & RefAttributes<HTMLDivElement>) {\n const removeLabel = useContext(RemoveLabelContext);\n // An action of its own, a link or the group's makes a chip pressable even\n // in a group that selects nothing, as React Aria treats it.\n const acts = useContext(GroupActionContext) || props.onAction !== undefined || props.href !== undefined;\n // The press ripple a list's rows draw — see ListItem there. A chip in a\n // group is a collection row, whose clicks React Aria keeps for itself, so\n // the press ends when the pointer is released rather than on a click.\n const ripple = useRipple<HTMLDivElement>(true, {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n }, true);\n return <RACTag textValue={props.textValue ?? textOf(children)} {...ripple.handlers} {...props} {...mergeStatefulStyles(acts ? actingChipPropsFor : groupChipPropsFor, props)}>\n {chipContent(children, icon, removeLabel, ripple.surface, acts)}\n </RACTag>;\n}\n\n// The pill a standalone Chip draws, from `src/chip`, touch target included:\n// every chip's reaches halfway across the gap its rows wrap at. Inert where\n// the group selects nothing and the chip has no action — see the header.\nfunction groupChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state, {\n inert: state.selectionMode === 'none',\n kind: kindOf(state)\n });\n}\n\n// Which of the page's chips a group's chip is: an input chip once it can be\n// removed, and a filter chip until then, which is what decides whether a\n// selected one lifts under a hovering pointer.\nfunction kindOf(state: TagRenderProps) {\n return state.allowsRemoving ? 'input' : 'filter';\n}\nChipGroup.Chip = ChipGroupChip;\nexport type { ChipGroupChipProps, ChipGroupProps };\nexport { ChipGroupChip };\nexport default ChipGroup;"],"mappings":";;;;;;;;;;;;;;;;;AAmEA,MAAMkB,SAAS,EACbC,MAAM;CACJC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;AA8FA,SAASS,YAAYR,UAAqBC,MAAiBM,aAAiCE,SAAoBC,MAAe;CAC7H,QAAQC,UAA0B,qBAAA,YAAA,EAAA,UAAA;EAC7BlC,UAAUkC,OAAOV,MAAMU,MAAMC,kBAAkB,MAAM;EACrDlC,UAAUsB,QAAQ;GACjBU,QAAQC,MAAMC,kBAAkB,WAAW,CAACD,MAAME,aAAa,oBAAC,QAAD;GAAM,GAAIzC,MAAaS,WAAWkC,cAAc;GAAIN,UAAAA;EAAc,CAAA,IAAI;EACtIE,MAAMK,iBAAiB,oBAAC+C,QAAD;GAAW,cAAYxD;GAAa,WAAW3B;GAAqB,MAAK;GAC7F,UAAA,oBAAC,YAAD,EAAY,GAAIR,MAAaS,WAAWoC,WAAW,EAAE,CAAA;EAC5C,CAAA,IAAI;CACnB,EAAA,CAAA;AACJ;AAMA,MAAMC,qBAAqB7C,cAAkC8C,KAAAA,CAAS;AAKtE,MAAMC,qBAAqB/C,cAAc,KAAK;AAG9C,MAAMgD,oBAAoB,EACxBC,WAAW,MACb;AACA,MAAMC,sBAAsB,EAC1BD,WAAW,KACb;AAGA,SAASE,mBAAmBb,OAAuB;CACjD,OAAOhC,aAAagC,OAAO,EACzBc,MAAMC,OA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;GAC9FC,UAAAA;EADS,CAAA;EAEHT,EAAA,MAAAC;EAAAD,EAAA,MAAAf;EAAAe,EAAA,MAAA6B,OAAAC;EAAA9B,EAAA,MAAAM;EAAAN,EAAA,MAAAQ;EAAAR,EAAA,MAAAS;EAAAT,EAAA,MAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFJU;AAEI;AAMb,SAASqB,kBAAkBjD,OAAuB;CAChD,OAAOhC,aAAagC,OAAO;EACzBkD,OAAOlD,MAAMC,kBAAkB;EAC/Ba,MAAMC,OAAOf,KAAK;CACpB,CAAC;AACH;AAKA,SAASe,OAAOf,OAAuB;CACrC,OAAOA,MAAMK,iBAAiB,UAAU;AAC1C;AACAW,UAAUmC,OAAOX"}
1
+ {"version":3,"file":"index.js","names":["_c","stylex","createContext","useContext","RACTag","RACTagGroup","chipGlyph","chipLabel","chipPropsFor","chipRemoveClassName","chipStyles","textOf","invalidFrom","groupStyles","useRipple","focus","mergeStatefulStyles","mergeStyles","styles","list","kGNEyG","kaIpWk","kB7OPa","k1xSpc","kwnvtZ","kOIVth","kAzted","kg3NbH","$$css","children","icon","textValue","description","error","escapeKeyBehavior","label","removeLabel","chipContent","surface","acts","state","selectionMode","isDisabled","props","surfaceCorners","allowsRemoving","removeGlyph","RemoveLabelContext","undefined","GroupActionContext","actingChipPropsFor","kind","kindOf","ChipGroup","t0","$","T0","invalid","items","renderEmptyState","t1","t2","t3","t4","t5","t6","t7","t8","t9","t10","t11","t12","t13","root","onAction","Symbol","for","ring","ChipGroupChip","onContextMenu","onPointerCancel","onPointerDown","onPointerLeave","onPointerUp","href","ripple","handlers","groupChipPropsFor","inert","Chip","RACButton","RACTagList"],"sources":["../../../src/components/chip-group/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactElement, ReactNode, RefAttributes } from 'react';\nimport type { TagGroupProps as RACTagGroupProps, TagListProps as RACTagListProps, TagProps as RACTagProps, TagRenderProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { createContext, useContext } from 'react';\nimport { Button as RACButton, Tag as RACTag, TagGroup as RACTagGroup, TagList as RACTagList } from 'react-aria-components';\nimport { chipGlyph, chipLabel, chipPropsFor, chipRemoveClassName } from '../../chip';\nimport { chipStyles } from '../../chip/styles';\nimport { textOf } from '../../collection/text';\nimport { FieldLabel, FieldMessage } from '../../field';\nimport { invalidFrom } from '../../field/root';\nimport { groupStyles } from '../../field/styles';\nimport { CloseGlyph } from '../../glyphs';\nimport { useRipple } from '../../hooks/useRipple';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles, mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, sizing, spacing } from '../../tokens/design.tokens.stylex';\n\n// The chips page's filter and input chips as a set: one or more chosen from a\n// row, each one removable. The pill is the chip module's in `src/chip`,\n// shared with the standalone Chip, so the two cannot drift; what is here is\n// the group around them.\n//\n// Three things it adds over a row of Chips.\n//\n// **It is a group, not a row of buttons.** React Aria's `TagGroup` names the\n// set, describes it, points it at its error, and moves between its chips\n// with the arrow keys rather than making each one a tab stop — which\n// is what a set of a dozen filters needs. The label, the supporting line and\n// the error are the field chrome's, so a group reads like the fields beside\n// it, exactly as CheckboxGroup and RadioGroup do.\n//\n// **A chip can be removed.** Give the group `onRemove` and each chip draws\n// the page's trailing close target, an 18dp glyph in a target of its own so a\n// press there removes rather than toggles. Backspace and Delete remove the\n// focused chip too, which is React Aria's. A chosen chip's check sits at the\n// other end, so a chip that is both selected and removable carries one glyph\n// on each side of its label.\n//\n// **Selection is the group's, not each chip's.** `selectionMode` and\n// `selectedKeys` live on the group, so a set that chooses one of its chips\n// and a set that chooses several are the same component with a different\n// word. A chip on its own that toggles nothing else is still Chip.\n//\n// **Escape leaves the selection alone.** React Aria's collections clear the\n// selection on Escape and stop the key there, which suits a list whose\n// selection is what an action is about to act on. A set of chips holds a\n// value, as a checkbox group does, and usually sits in a Sheet, Dialog or\n// Popover, where Escape is what dismisses it: clearing it there wiped the\n// reader's filters and took a second press to close. So the group passes\n// React Aria's `escapeKeyBehavior` as `none` unless told `clearSelection`.\n//\n// **A chip a press does nothing to does not look pressable.** In a group\n// that selects nothing, a chip with no action of its own or the group's is\n// a control only for its close target. It draws the arrow cursor, no layer\n// and no ripple, and its close target keeps the pointer. A disabled chip's\n// close target takes the chip's `not-allowed` with it.\n//\n// One thing is worth knowing about how this maps onto React Aria. A chip's\n// text value is read off its children and found only when they are a plain\n// string, and a chip here is always an element — the label sits beside a\n// close target. So a plain-string label is passed through as the text value,\n// which is what typeahead and a screen reader's announcement are made of;\n// see ListBox.Item, where the same thing bit.\n\nconst styles = {\n list: {\n kGNEyG: \"x6s0dn4\",\n kaIpWk: \"x1xdvaa9\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x78zum5\",\n kwnvtZ: \"x1a02dak\",\n kOIVth: \"x126z3so\",\n kAzted: \"xlzjxrf\",\n kg3NbH: \"x91pird xnjsko4\",\n $$css: true\n }\n};\ntype ChipGroupChipProps = {\n /**\n * The chip's label. Text, numbers, or a mix of the two — `Label {3}` —\n * also name the chip; a label holding an element needs `textValue`.\n */\n children?: ReactNode;\n /** A function may compute the class from the chip's render state. */\n className?: RACTagProps['className'];\n /**\n * An icon before the label, in the page's 18dp slot and the primary role.\n * The check takes its place while the chip is chosen, so the chip keeps\n * its width. An icon drawn in `em` takes its size from the slot.\n */\n icon?: ReactNode;\n /** A function may compute the style from the chip's render state. */\n style?: RACTagProps['style'];\n /**\n * The chip's name as text, which is what a screen reader announces for\n * its row. Read from the label when that is text or numbers, so it is\n * needed only when the label holds an element — emphasis, a count in a\n * badge — and React Aria warns in the console when such a chip has none.\n * Given, it wins over the text read from the label.\n */\n textValue?: string;\n} & Omit<RACTagProps, 'children' | 'className' | 'style' | 'textValue'>;\ntype ChipGroupProps<T extends object = object> = {\n /**\n * The chips, each with an `id` of its own. With `items`, a function from an\n * item to its chip, which React Aria calls for each item in turn.\n */\n children?: ((item: T) => ReactElement) | ReactNode;\n /**\n * A hint under the group. Replaced by `error` when there is one, so the\n * two never stack.\n */\n description?: string;\n /**\n * The problem with the current selection, in words. Its presence is what\n * puts the group in its error state: the label and the message take the\n * error colour, the grid's `aria-describedby` names the message, and the\n * message is read out politely as it appears. The grid carries no\n * `aria-invalid`, which ARIA does not allow on a grid, so the message is\n * the whole of what a screen reader is told.\n *\n * Outside a `Form` the message line arrives with the message, so the\n * field grows when this does and moves what is under it. A `Form` holds\n * that space from the start; so does a permanent `description`.\n */\n error?: string;\n /**\n * What Escape does on a chip. `none`, the default, keeps the selection and\n * lets the key through to whatever is around the group, so a group in a\n * Sheet, Dialog or Popover closes it on the first press. `clearSelection`\n * empties the selection first, as React Aria's own default does, and lets\n * a second press through.\n *\n * @default 'none'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n /**\n * What the group is for. Required rather than optional: a set of chips\n * with no name is a row a screen reader cannot introduce.\n */\n label: string;\n /**\n * What the close target on each chip is called, for a screen reader. React\n * Aria adds the chip's own label after it, so this is the verb rather than\n * the whole phrase — \"Remove\" becomes \"Remove First item\". Left out, React\n * Aria names it in the reader's locale — \"Remove\" in English.\n */\n removeLabel?: string;\n} & Omit<RACTagGroupProps, 'children' | 'escapeKeyBehavior'> & Pick<RACTagListProps<T>, 'items' | 'renderEmptyState'>;\n\n// What the chip draws, from React Aria's render state. Built by a call rather\n// than written inline at the prop, which is what react-perf's\n// no-new-function-as-prop is after; the React Compiler memoises the result on\n// its inputs.\n//\n// The check and the icon it replaces are the chip module's, so a chip in a\n// group and a chip on its own draw the same ones. The close target is drawn\n// only where the group allows removing, which React Aria reports rather than\n// the call site saying so on every chip.\n//\n// The ripple is drawn only on a chip a press does something to, and not\n// disabled: one the group lets be selected, or one with an action, its own\n// or the group's. Any other chip in a group that selects nothing is a\n// control only for its close target, and React Aria reports neither hover\n// nor press on it, so a ripple there would answer a press that changes\n// nothing. `acts` is the action half, which the render state does not carry.\n//\n// It sits in a box of its own carrying the chip's corner, since React Aria's\n// cell between the chip and this content would otherwise hand the ripple a\n// square one to inherit; see the header of src/chip/styles.ts.\nfunction chipContent(children: ReactNode, icon: ReactNode, removeLabel: string | undefined, surface: ReactNode, acts: boolean) {\n return (state: TagRenderProps) => <>\n {chipGlyph(state, icon, state.selectionMode !== 'none')}\n {chipLabel(children)}\n {(acts || state.selectionMode !== 'none') && !state.isDisabled ? <span {...stylex.props(chipStyles.surfaceCorners)}>{surface}</span> : null}\n {state.allowsRemoving ? <RACButton aria-label={removeLabel} className={chipRemoveClassName} slot=\"remove\">\n <CloseGlyph {...stylex.props(chipStyles.removeGlyph)} />\n </RACButton> : null}\n </>;\n}\n\n// What each chip calls its close target. A context rather than a prop on the\n// chip, since it is the group's decision and repeating it on every chip is\n// how the two drift. Undefined unless the group is given one, which leaves\n// the name React Aria gives in the reader's locale.\nconst RemoveLabelContext = createContext<string | undefined>(undefined);\n\n// Whether the group was given `onAction`, which makes every chip in it\n// pressable whether or not it selects. A context for the reason the close\n// target's name is one.\nconst GroupActionContext = createContext(false);\n\n// The pill of a chip with an action, which a press always reaches.\nfunction actingChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state, {\n kind: kindOf(state)\n });\n}\n\n/**\n * A labelled set of chips, one or more of which can be chosen, each of which\n * can be removed. Selection is React Aria's: set `selectionMode` to `single`\n * or `multiple` and pass `selectedKeys` with `onSelectionChange` to control\n * it, or `defaultSelectedKeys` to let it keep its own.\n *\n * ```tsx\n * <ChipGroup label=\"Label\" selectionMode=\"multiple\" onRemove={remove}>\n * <ChipGroup.Chip id=\"first\">First item</ChipGroup.Chip>\n * </ChipGroup>\n * ```\n *\n * Give the group `onRemove` and each chip draws a close target. The arrow\n * keys move between chips, so a set of many is one tab stop rather than many.\n *\n * A chip is never wider than its row, so a label with no room ends in an\n * ellipsis rather than wrapping, and shows its full text in the browser's\n * tooltip on hover.\n *\n * Escape on a chip keeps the selection and reaches whatever is around the\n * group, so a group in a Sheet, Dialog or Popover closes it. Pass\n * `escapeKeyBehavior=\"clearSelection\"` for React Aria's own default, which\n * empties the selection on the first press and lets the second through.\n *\n * A chip that toggles nothing else is Chip; this is for a set that shares a\n * value.\n *\n * The call site's `className` and `style` land on the group as a whole,\n * which is the element a layout positions.\n */\nfunction ChipGroup<T extends object = object>({\n children,\n description,\n error,\n escapeKeyBehavior = 'none',\n items,\n label,\n removeLabel,\n renderEmptyState,\n ...props\n}: ChipGroupProps<T> & RefAttributes<HTMLDivElement>) {\n const invalid = invalidFrom(error);\n return <RACTagGroup escapeKeyBehavior={escapeKeyBehavior} {...props} {...mergeStyles(stylex.props(groupStyles.root), props)}>\n {/* React Aria's tag group has no disabled state of its own — a chip is\n disabled through the group's `disabledKeys` — so the label follows\n validity alone. */}\n <FieldLabel isInvalid={invalid} variant=\"group\">\n {label}\n </FieldLabel>\n <RemoveLabelContext value={removeLabel}>\n <GroupActionContext value={props.onAction !== undefined}>\n <RACTagList<T> items={items} renderEmptyState={renderEmptyState} {...stylex.props(styles.list, focus.ring)}>\n {children}\n </RACTagList>\n </GroupActionContext>\n </RemoveLabelContext>\n <FieldMessage description={description} error={error} inset={false} />\n </RACTagGroup>;\n}\n\n/**\n * One chip. Give every chip an `id` — that is the key selection and removal\n * are reported by.\n */\nfunction ChipGroupChip({\n children,\n icon,\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp,\n ...props\n}: ChipGroupChipProps & RefAttributes<HTMLDivElement>) {\n const removeLabel = useContext(RemoveLabelContext);\n // An action of its own, a link or the group's makes a chip pressable even\n // in a group that selects nothing, as React Aria treats it.\n const acts = useContext(GroupActionContext) || props.onAction !== undefined || props.href !== undefined;\n // The press ripple a list's rows draw — see ListItem there. A chip in a\n // group is a collection row, whose clicks React Aria keeps for itself, so\n // the press ends when the pointer is released rather than on a click.\n const ripple = useRipple<HTMLDivElement>(true, {\n onContextMenu,\n onPointerCancel,\n onPointerDown,\n onPointerLeave,\n onPointerUp\n }, true);\n return <RACTag textValue={props.textValue ?? textOf(children)} {...ripple.handlers} {...props} {...mergeStatefulStyles(acts ? actingChipPropsFor : groupChipPropsFor, props)}>\n {chipContent(children, icon, removeLabel, ripple.surface, acts)}\n </RACTag>;\n}\n\n// The pill a standalone Chip draws, from `src/chip`, touch target included:\n// every chip's reaches halfway across the gap its rows wrap at. Inert where\n// the group selects nothing and the chip has no action — see the header.\nfunction groupChipPropsFor(state: TagRenderProps) {\n return chipPropsFor(state, {\n inert: state.selectionMode === 'none',\n kind: kindOf(state)\n });\n}\n\n// Which of the page's chips a group's chip is: an input chip once it can be\n// removed, and a filter chip until then, which is what decides whether a\n// selected one lifts under a hovering pointer.\nfunction kindOf(state: TagRenderProps) {\n return state.allowsRemoving ? 'input' : 'filter';\n}\nChipGroup.Chip = ChipGroupChip;\nexport type { ChipGroupChipProps, ChipGroupProps };\nexport { ChipGroupChip };\nexport default ChipGroup;"],"mappings":";;;;;;;;;;;;;;;;;AAmEA,MAAMkB,SAAS,EACbC,MAAM;CACJC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,QAAQ;CACRC,OAAO;AACT,EACF;AA8FA,SAASS,YAAYR,UAAqBC,MAAiBM,aAAiCE,SAAoBC,MAAe;CAC7H,QAAQC,UAA0B,qBAAA,YAAA,EAAA,UAAA;EAC7BlC,UAAUkC,OAAOV,MAAMU,MAAMC,kBAAkB,MAAM;EACrDlC,UAAUsB,QAAQ;GACjBU,QAAQC,MAAMC,kBAAkB,WAAW,CAACD,MAAME,aAAa,oBAAC,QAAD;GAAM,GAAIzC,MAAaS,WAAWkC,cAAc;GAAIN,UAAAA;EAAc,CAAA,IAAI;EACtIE,MAAMK,iBAAiB,oBAAC6C,QAAD;GAAW,cAAYtD;GAAa,WAAW3B;GAAqB,MAAK;GAC7F,UAAA,oBAAC,YAAD,EAAY,GAAIR,MAAaS,WAAWoC,WAAW,EAAE,CAAA;EAC5C,CAAA,IAAI;CACnB,EAAA,CAAA;A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A,KAAAT,EAAA;CAAA,IAAAU;CAAA,IAAAV,EAAA,QAAAC,MAAAD,EAAA,QAAAZ,SAAAY,EAAA,QAAA8B,OAAAC,YAAA/B,EAAA,QAAAM,MAAAN,EAAA,QAAAQ,MAAAR,EAAA,QAAAS,IAAA;EAD5DC,KAAA,oBAAC,IAAD;GAAmB,WAAAJ;GAAmC,GAAMC;GAAe,GAAMnB;GAAK,GAAMoB;GAC9FC,UAAAA;EADS,CAAA;EAEHT,EAAA,MAAAC;EAAAD,EAAA,MAAAZ;EAAAY,EAAA,MAAA8B,OAAAC;EAAA/B,EAAA,MAAAM;EAAAN,EAAA,MAAAQ;EAAAR,EAAA,MAAAS;EAAAT,EAAA,MAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFJU;AAEI;AAMb,SAASsB,kBAAkB/C,OAAuB;CAChD,OAAOhC,aAAagC,OAAO;EACzBgD,OAAOhD,MAAMC,kBAAkB;EAC/BU,MAAMC,OAAOZ,KAAK;CACpB,CAAC;AACH;AAKA,SAASY,OAAOZ,OAAuB;CACrC,OAAOA,MAAMK,iBAAiB,UAAU;AAC1C;AACAQ,UAAUoC,OAAOX"}
@@ -42,6 +42,7 @@ const styles = {
42
42
  },
43
43
  itemFocused: {
44
44
  kInvED: "x8wkva7",
45
+ kMeerF: "x1de99jn",
45
46
  $$css: true
46
47
  },
47
48
  itemHovered: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_c","stylex","ColorSwatchPicker","ColorSwatchPickerItem","RACColorSwatchPickerItem","focus","mergeStatefulStyles","colors","surface","onSurface","styles","item","kUfP38","kbwMcY","kPGmMm","kWgvks","k5JduY","kv0HGH","kloYau","kwXMNM","kaIpWk","kB7OPa","kkrTdU","k1xSpc","k3XXqK","kVAEAm","$$css","itemDisabled","k3DiCg","kPB484","kQmYQc","kgeoSG","ku0W4C","kFcpXp","km8f2m","kEoFBp","kxmVGU","itemFocused","kInvED","itemHovered","kXtpa","itemPressed","itemSelected","children","className","props","$","t0","t1","T0","t2","t3","itemStyles","state","0","1","isDisabled","t4","isFocusVisible","isHovered","isPressed","isSelected","ringVisible","Item","RACColorSwatchPicker","ColorSwatch"],"sources":["../../../src/components/color-swatch-picker/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ColorSwatchPickerItemProps as RACColorSwatchPickerItemProps, ColorSwatchPickerProps as RACColorSwatchPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorSwatchPicker as RACColorSwatchPicker, ColorSwatchPickerItem as RACColorSwatchPickerItem } from 'react-aria-components';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\nimport ColorSwatch from '../color-swatch';\n\n// A row of colours to choose one from. React Aria makes it a listbox of\n// swatches, so it is a selection control rather than a palette: arrow keys\n// move between colours and one of them is selected.\n//\n// The design carries no page for this either, so what an item looks like\n// when it is chosen is the library's own. Three choices, each with its\n// reason.\n//\n// **Selection is a ring around the swatch, not a mark on it.** A tick drawn\n// over a colour has to be readable against every colour in the row, which no\n// single ink is; a ring sits outside the swatch and needs only to read\n// against the surface behind it.\n//\n// **The ring is 3px of on-surface, and offset.** It sits 2px out from the\n// swatch so the colour stays whole — a ring drawn on the swatch would eat\n// pixels of the thing being chosen. It is not the focus ring's colour or\n// weight on purpose: the arrow keys move focus without choosing, so one\n// swatch is chosen while another is focused, and when both rings were 2px of\n// primary only their distance from the swatch told them apart. Focus keeps\n// the library's ring, the one every other control draws, so the selection\n// ring is the one that differs, heavier and in on-surface.\n//\n// **Focus and selection are drawn by different properties.** An element has\n// one outline, so with both drawn in it the second replaced the first, and a\n// keyboard arrowing onto the chosen colour saw a swatch that looked\n// unchosen. The focus ring is the item's outline, 6px out; the selection\n// ring is a border on a box laid 5px around the swatch, inside it, with 1px\n// clear between the two. Both are properties forced colours keep, which a\n// box shadow is not, and there the difference in weight is what is left.\n//\n// **Hover and press are a ring too, in the slot selection would take.** Every\n// other interactive element here answers the pointer with a state layer, but\n// a state layer is a fill and a swatch's fill is the colour being chosen:\n// behind it the tint is hidden, over it the tint changes the colour. So an\n// unselected swatch under the pointer takes a ring at the selection ring's\n// outer edge, 2px wide and in the outline roles, so it cannot be read\n// as chosen — outline variant while a pointer is over it, and outline while a\n// touch or a pen holds it. Those are the only presses anyone sees: React Aria\n// chooses a swatch the moment a mouse or a key presses it, and on release for\n// a touch, so that press is the one a reader waits through before the swatch\n// is theirs. Under forced colours both roles become one system colour, so the\n// ring turns dashed there, where the selection ring stays solid.\n//\n// **A colour that cannot be chosen is struck through, as well as faded.**\n// Faded alone it read as a paler colour, and a pale colour is as good an\n// option as any. The slash is drawn over the swatch, where the first choice\n// says no single ink reads against every colour, so it is two: an on-surface\n// line edged in surface, and whichever of the two the colour beneath is\n// nearer to, the other reads against it. The fade is on the item's contents\n// rather than the item, so the slash over them keeps its full strength.\n\nconst FORCED_COLORS = '@media (forced-colors: active)';\n\n// The slash, corner to corner across a square: a 2px line of ink with 1.5px\n// of edge either side, measured across the line rather than along the\n// square's side. Written out twice, once per pair of colours, since StyleX\n// evaluates a constant but not a function building one.\nconst SLASH = `linear-gradient(to top right, transparent calc(50% - 2.5px), ${colors.surface} calc(50% - 2.5px) calc(50% - 1px), ${colors.onSurface} calc(50% - 1px) calc(50% + 1px), ${colors.surface} calc(50% + 1px) calc(50% + 2.5px), transparent calc(50% + 2.5px))`;\nconst SLASH_FORCED = 'linear-gradient(to top right, transparent calc(50% - 2.5px), Canvas calc(50% - 2.5px) calc(50% - 1px), GrayText calc(50% - 1px) calc(50% + 1px), Canvas calc(50% + 1px) calc(50% + 2.5px), transparent calc(50% + 2.5px))';\nconst styles = {\n item: {\n kUfP38: \"xdzrvcx\",\n kbwMcY: \"x1v5kskh\",\n kPGmMm: \"x1941vk7\",\n kWgvks: \"xx38sju\",\n k5JduY: \"x1s928wv\",\n kv0HGH: \"xzkkzs7\",\n kloYau: \"x2q1x1w\",\n kwXMNM: \"x1j6awrg\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n k3XXqK: \"x1t137rt\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n itemDisabled: {\n k3DiCg: \"xkqgyyi x1vz15c4\",\n kPB484: \"x13uuyx9\",\n kQmYQc: \"xtql2tq\",\n kgeoSG: \"x1cpjm7i\",\n ku0W4C: \"x13rwrtk\",\n kFcpXp: \"xxx281p\",\n km8f2m: \"xkk1bqk\",\n kEoFBp: \"x1hmns74\",\n kxmVGU: \"x12maryy\",\n kkrTdU: \"xt0e3qv\",\n $$css: true\n },\n itemFocused: {\n kInvED: \"x8wkva7\",\n $$css: true\n },\n itemHovered: {\n kXtpa: \"x1ek9lwj\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemPressed: {\n kXtpa: \"xrwozs3\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemSelected: {\n kXtpa: \"xmi6dwc\",\n kbwMcY: \"x86avzo\",\n kPGmMm: \"x14wq4lv\",\n $$css: true\n }\n};\ntype ColorSwatchPickerItemProps = Omit<RACColorSwatchPickerItemProps, 'children' | 'className' | 'style'> & {\n /** What the item draws. A `ColorSwatch` with no `color` of its own by default. */\n children?: ReactNode;\n /** A function may compute the class from the item's render state. */\n className?: RACColorSwatchPickerItemProps['className'];\n /** A function may compute the style from the item's render state. */\n style?: RACColorSwatchPickerItemProps['style'];\n};\ntype ColorSwatchPickerProps = Omit<RACColorSwatchPickerProps, 'className' | 'style'> & {\n /** A function may compute the class from the picker's render state. */\n className?: RACColorSwatchPickerProps['className'];\n /** A function may compute the style from the picker's render state. */\n style?: RACColorSwatchPickerProps['style'];\n};\n\n/**\n * A row of colours to choose one from, drawn as swatches. The value is React\n * Aria's — pass `value` with `onChange` to control it, or `defaultValue` —\n * as a CSS colour string or a `Color` from `parseColor`, which this package\n * re-exports.\n *\n * ```tsx\n * <ColorSwatchPicker defaultValue=\"#6750A4\">\n * <ColorSwatchPicker.Item color=\"#6750A4\" />\n * <ColorSwatchPicker.Item color=\"#625B71\" />\n * </ColorSwatchPicker>\n * ```\n *\n * It is a listbox, so arrow keys move between colours and the chosen one\n * carries a ring. Name it with `aria-label` or `aria-labelledby`; React Aria\n * calls it \"Color swatches\" otherwise.\n *\n * The call site's `className` and `style` land on the picker, which is the\n * element a layout positions.\n */\nfunction ColorSwatchPicker(props: ColorSwatchPickerProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPicker {...props} {...mergeStatefulStyles({\n className: \"x9f619 x78zum5 x1a02dak x126z3so x1t137rt\"\n }, props)} />;\n}\n\n/**\n * One swatch in a {@link ColorSwatchPicker}. Renders a `ColorSwatch` of its\n * own `color` unless given different children.\n */\nfunction ColorSwatchPickerItem({\n children,\n ...props\n}: ColorSwatchPickerItemProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPickerItem {...props} {...mergeStatefulStyles(itemStyles, props)}>\n {state => <span {...{\n 0: {\n className: \"x9f619 x3nfvp2\"\n },\n 1: {\n className: \"x9f619 x3nfvp2 x1ppv7y9\"\n }\n }[!!state.isDisabled << 0]}>\n {children ?? <ColorSwatch />}\n </span>}\n </RACColorSwatchPickerItem>;\n}\n\n// The item's styles, from React Aria's render state. StyleX cannot target\n// `[data-selected]` on the element it is styling, so the state comes from\n// what React Aria hands the className.\n//\n// The order matters where two styles draw on one property. The hover and\n// press rings come before `selected`, which draws on the same border, so a\n// chosen swatch keeps the ring that says so. Focus is the library's ring and\n// then `focused`, which moves it out; both draw on the outline, which\n// nothing else touches but the item's resting `none`, so a swatch that is\n// chosen and focused keeps both. `disabled` is last, so it takes the cursor\n// with it, and draws the slash; React Aria reports neither hover nor press\n// on one.\nfunction itemStyles(state: {\n isDisabled: boolean;\n isFocusVisible: boolean;\n isHovered: boolean;\n isPressed: boolean;\n isSelected: boolean;\n}) {\n return stylex.props(styles.item, state.isHovered && styles.itemHovered, state.isPressed && styles.itemPressed, state.isSelected && styles.itemSelected, state.isFocusVisible && [focus.ringVisible, styles.itemFocused], state.isDisabled && styles.itemDisabled);\n}\nColorSwatchPicker.Item = ColorSwatchPickerItem;\nexport type { ColorSwatchPickerItemProps, ColorSwatchPickerProps };\nexport { ColorSwatchPickerItem };\nexport default ColorSwatchPicker;"],"mappings":";;;;;;;;;;AAqEc,GAAgEO,OAAOC,UAA8CD,OAAOE,YAA8CF,OAAOC;AAE/L,MAAME,SAAS;CACbC,MAAM;EACJC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,cAAc;EACZC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRd,QAAQ;EACRI,OAAO;CACT;CACAW,aAAa;EACXC,QAAQ;EACRZ,OAAO;CACT;CACAa,aAAa;EACXC,OAAO;EACP3B,QAAQ;EACRa,OAAO;CACT;CACAe,aAAa;EACXD,OAAO;EACP3B,QAAQ;EACRa,OAAO;CACT;CACAgB,cAAc;EACZF,OAAO;EACP3B,QAAQ;EACRC,QAAQ;EACRY,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAAxB,kBAAA2C,OAAA;CAAA,MAAAC,IAAA9C,EAAA,CAAA;CAAA,IAAA+C;CAAA,IAAAD,EAAA,OAAAD,OAAA;EAC8CE,KAAAzC,oBAAoB,EAAAsC,WACnD,4CACb,GAAGC,KAAK;EAACC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAA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K;GAC3CC,UAAAA;EAD2B,CAAA;EAWHL,EAAA,KAAAG;EAAAH,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,MAAAK;EAAAL,EAAA,MAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,OAXtBW;AAWsB;AAe/B,SAASL,WAAWC,OAMjB;CACD,OAAOpD,MAAaS,OAAOC,MAAM0C,MAAMM,aAAajD,OAAO6B,aAAac,MAAMO,aAAalD,OAAO+B,aAAaY,MAAMQ,cAAcnD,OAAOgC,cAAcW,MAAMK,kBAAkB,CAACrD,MAAMyD,aAAapD,OAAO2B,WAAW,GAAGgB,MAAMG,cAAc9C,OAAOiB,YAAY;AAClQ;AACAzB,kBAAkB6D,OAAO5D"}
1
+ {"version":3,"file":"index.js","names":["_c","stylex","ColorSwatchPicker","ColorSwatchPickerItem","RACColorSwatchPickerItem","focus","mergeStatefulStyles","colors","surface","onSurface","styles","item","kUfP38","kbwMcY","kPGmMm","kWgvks","k5JduY","kv0HGH","kloYau","kwXMNM","kaIpWk","kB7OPa","kkrTdU","k1xSpc","k3XXqK","kVAEAm","$$css","itemDisabled","k3DiCg","kPB484","kQmYQc","kgeoSG","ku0W4C","kFcpXp","km8f2m","kEoFBp","kxmVGU","itemFocused","kInvED","kMeerF","itemHovered","kXtpa","itemPressed","itemSelected","children","className","props","$","t0","t1","T0","t2","t3","itemStyles","state","0","1","isDisabled","t4","isFocusVisible","isHovered","isPressed","isSelected","ringVisible","Item","RACColorSwatchPicker","ColorSwatch"],"sources":["../../../src/components/color-swatch-picker/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { ColorSwatchPickerItemProps as RACColorSwatchPickerItemProps, ColorSwatchPickerProps as RACColorSwatchPickerProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { ColorSwatchPicker as RACColorSwatchPicker, ColorSwatchPickerItem as RACColorSwatchPickerItem } from 'react-aria-components';\nimport { focus } from '../../styles/focus';\nimport { mergeStatefulStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { colors, radii, spacing, stateLayerOpacity } from '../../tokens/design.tokens.stylex';\nimport ColorSwatch from '../color-swatch';\n\n// A row of colours to choose one from. React Aria makes it a listbox of\n// swatches, so it is a selection control rather than a palette: arrow keys\n// move between colours and one of them is selected.\n//\n// The design carries no page for this either, so what an item looks like\n// when it is chosen is the library's own. Three choices, each with its\n// reason.\n//\n// **Selection is a ring around the swatch, not a mark on it.** A tick drawn\n// over a colour has to be readable against every colour in the row, which no\n// single ink is; a ring sits outside the swatch and needs only to read\n// against the surface behind it.\n//\n// **The ring is 3px of on-surface, and offset.** It sits 2px out from the\n// swatch so the colour stays whole — a ring drawn on the swatch would eat\n// pixels of the thing being chosen. It is not the focus ring's colour or\n// weight on purpose: the arrow keys move focus without choosing, so one\n// swatch is chosen while another is focused, and when both rings were 2px of\n// primary only their distance from the swatch told them apart. Focus takes\n// the library's ring in its secondary role, so the two differ in colour.\n// They differ in weight too, and that is the one place a swatch's focus ring\n// departs from the library's 3dp: it stays at 2px, lighter than the\n// selection ring, since under forced colours both rings take system colours\n// and the weight is what is left to tell them apart. Drawn at 3px, the two\n// would differ there only in their distance from the swatch, which is what\n// the 2px rings of primary did.\n//\n// **Focus and selection are drawn by different properties.** An element has\n// one outline, so with both drawn in it the second replaced the first, and a\n// keyboard arrowing onto the chosen colour saw a swatch that looked\n// unchosen. The focus ring is the item's outline, 6px out; the selection\n// ring is a border on a box laid 5px around the swatch, inside it, with 1px\n// clear between the two. Both are properties forced colours keep, which a\n// box shadow is not, and there the difference in weight is what is left.\n//\n// **Hover and press are a ring too, in the slot selection would take.** Every\n// other interactive element here answers the pointer with a state layer, but\n// a state layer is a fill and a swatch's fill is the colour being chosen:\n// behind it the tint is hidden, over it the tint changes the colour. So an\n// unselected swatch under the pointer takes a ring at the selection ring's\n// outer edge, 2px wide and in the outline roles, so it cannot be read\n// as chosen — outline variant while a pointer is over it, and outline while a\n// touch or a pen holds it. Those are the only presses anyone sees: React Aria\n// chooses a swatch the moment a mouse or a key presses it, and on release for\n// a touch, so that press is the one a reader waits through before the swatch\n// is theirs. Under forced colours both roles become one system colour, so the\n// ring turns dashed there, where the selection ring stays solid.\n//\n// **A colour that cannot be chosen is struck through, as well as faded.**\n// Faded alone it read as a paler colour, and a pale colour is as good an\n// option as any. The slash is drawn over the swatch, where the first choice\n// says no single ink reads against every colour, so it is two: an on-surface\n// line edged in surface, and whichever of the two the colour beneath is\n// nearer to, the other reads against it. The fade is on the item's contents\n// rather than the item, so the slash over them keeps its full strength.\n\nconst FORCED_COLORS = '@media (forced-colors: active)';\n\n// The slash, corner to corner across a square: a 2px line of ink with 1.5px\n// of edge either side, measured across the line rather than along the\n// square's side. Written out twice, once per pair of colours, since StyleX\n// evaluates a constant but not a function building one.\nconst SLASH = `linear-gradient(to top right, transparent calc(50% - 2.5px), ${colors.surface} calc(50% - 2.5px) calc(50% - 1px), ${colors.onSurface} calc(50% - 1px) calc(50% + 1px), ${colors.surface} calc(50% + 1px) calc(50% + 2.5px), transparent calc(50% + 2.5px))`;\nconst SLASH_FORCED = 'linear-gradient(to top right, transparent calc(50% - 2.5px), Canvas calc(50% - 2.5px) calc(50% - 1px), GrayText calc(50% - 1px) calc(50% + 1px), Canvas calc(50% + 1px) calc(50% + 2.5px), transparent calc(50% + 2.5px))';\nconst styles = {\n item: {\n kUfP38: \"xdzrvcx\",\n kbwMcY: \"x1v5kskh\",\n kPGmMm: \"x1941vk7\",\n kWgvks: \"xx38sju\",\n k5JduY: \"x1s928wv\",\n kv0HGH: \"xzkkzs7\",\n kloYau: \"x2q1x1w\",\n kwXMNM: \"x1j6awrg\",\n kaIpWk: \"x1tfhd1\",\n kB7OPa: \"x9f619\",\n kkrTdU: \"x1ypdohk\",\n k1xSpc: \"x3nfvp2\",\n k3XXqK: \"x1t137rt\",\n kVAEAm: \"x1n2onr6\",\n $$css: true\n },\n itemDisabled: {\n k3DiCg: \"xkqgyyi x1vz15c4\",\n kPB484: \"x13uuyx9\",\n kQmYQc: \"xtql2tq\",\n kgeoSG: \"x1cpjm7i\",\n ku0W4C: \"x13rwrtk\",\n kFcpXp: \"xxx281p\",\n km8f2m: \"xkk1bqk\",\n kEoFBp: \"x1hmns74\",\n kxmVGU: \"x12maryy\",\n kkrTdU: \"xt0e3qv\",\n $$css: true\n },\n itemFocused: {\n kInvED: \"x8wkva7\",\n kMeerF: \"x1de99jn\",\n $$css: true\n },\n itemHovered: {\n kXtpa: \"x1ek9lwj\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemPressed: {\n kXtpa: \"xrwozs3\",\n kbwMcY: \"x86avzo xssfeg4\",\n $$css: true\n },\n itemSelected: {\n kXtpa: \"xmi6dwc\",\n kbwMcY: \"x86avzo\",\n kPGmMm: \"x14wq4lv\",\n $$css: true\n }\n};\ntype ColorSwatchPickerItemProps = Omit<RACColorSwatchPickerItemProps, 'children' | 'className' | 'style'> & {\n /** What the item draws. A `ColorSwatch` with no `color` of its own by default. */\n children?: ReactNode;\n /** A function may compute the class from the item's render state. */\n className?: RACColorSwatchPickerItemProps['className'];\n /** A function may compute the style from the item's render state. */\n style?: RACColorSwatchPickerItemProps['style'];\n};\ntype ColorSwatchPickerProps = Omit<RACColorSwatchPickerProps, 'className' | 'style'> & {\n /** A function may compute the class from the picker's render state. */\n className?: RACColorSwatchPickerProps['className'];\n /** A function may compute the style from the picker's render state. */\n style?: RACColorSwatchPickerProps['style'];\n};\n\n/**\n * A row of colours to choose one from, drawn as swatches. The value is React\n * Aria's — pass `value` with `onChange` to control it, or `defaultValue` —\n * as a CSS colour string or a `Color` from `parseColor`, which this package\n * re-exports.\n *\n * ```tsx\n * <ColorSwatchPicker defaultValue=\"#6750A4\">\n * <ColorSwatchPicker.Item color=\"#6750A4\" />\n * <ColorSwatchPicker.Item color=\"#625B71\" />\n * </ColorSwatchPicker>\n * ```\n *\n * It is a listbox, so arrow keys move between colours and the chosen one\n * carries a ring. Name it with `aria-label` or `aria-labelledby`; React Aria\n * calls it \"Color swatches\" otherwise.\n *\n * The call site's `className` and `style` land on the picker, which is the\n * element a layout positions.\n */\nfunction ColorSwatchPicker(props: ColorSwatchPickerProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPicker {...props} {...mergeStatefulStyles({\n className: \"x9f619 x78zum5 x1a02dak x126z3so x1t137rt\"\n }, props)} />;\n}\n\n/**\n * One swatch in a {@link ColorSwatchPicker}. Renders a `ColorSwatch` of its\n * own `color` unless given different children.\n */\nfunction ColorSwatchPickerItem({\n children,\n ...props\n}: ColorSwatchPickerItemProps & RefAttributes<HTMLDivElement>) {\n return <RACColorSwatchPickerItem {...props} {...mergeStatefulStyles(itemStyles, props)}>\n {state => <span {...{\n 0: {\n className: \"x9f619 x3nfvp2\"\n },\n 1: {\n className: \"x9f619 x3nfvp2 x1ppv7y9\"\n }\n }[!!state.isDisabled << 0]}>\n {children ?? <ColorSwatch />}\n </span>}\n </RACColorSwatchPickerItem>;\n}\n\n// The item's styles, from React Aria's render state. StyleX cannot target\n// `[data-selected]` on the element it is styling, so the state comes from\n// what React Aria hands the className.\n//\n// The order matters where two styles draw on one property. The hover and\n// press rings come before `selected`, which draws on the same border, so a\n// chosen swatch keeps the ring that says so. Focus is the library's ring and\n// then `focused`, which moves it out; both draw on the outline, which\n// nothing else touches but the item's resting `none`, so a swatch that is\n// chosen and focused keeps both. `disabled` is last, so it takes the cursor\n// with it, and draws the slash; React Aria reports neither hover nor press\n// on one.\nfunction itemStyles(state: {\n isDisabled: boolean;\n isFocusVisible: boolean;\n isHovered: boolean;\n isPressed: boolean;\n isSelected: boolean;\n}) {\n return stylex.props(styles.item, state.isHovered && styles.itemHovered, state.isPressed && styles.itemPressed, state.isSelected && styles.itemSelected, state.isFocusVisible && [focus.ringVisible, styles.itemFocused], state.isDisabled && styles.itemDisabled);\n}\nColorSwatchPicker.Item = ColorSwatchPickerItem;\nexport type { ColorSwatchPickerItemProps, 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OrD,MAAaS,OAAOC,MAAM2C,MAAMM,aAAalD,OAAO8B,aAAac,MAAMO,aAAanD,OAAOgC,aAAaY,MAAMQ,cAAcpD,OAAOiC,cAAcW,MAAMK,kBAAkB,CAACtD,MAAM0D,aAAarD,OAAO2B,WAAW,GAAGiB,MAAMG,cAAc/C,OAAOiB,YAAY;AAClQ;AACAzB,kBAAkB8D,OAAO7D"}
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
3
+ import { OptionRowContext } from "../../collection/context.js";
3
4
  import { FieldBox, FieldInput, FieldMessage, FieldValue } from "../../field/index.js";
4
5
  import { fieldStyles, invalidFrom, useFieldValidationBehavior } from "../../field/root.js";
5
6
  import { ChevronEndGlyph } from "../../glyphs/index.js";
@@ -150,7 +151,10 @@ function ComboBox(t0) {
150
151
  } else t11 = $[16];
151
152
  let t12;
152
153
  if ($[17] !== options) {
153
- t12 = /* @__PURE__ */ jsx(ListBox$1, { children: options });
154
+ t12 = /* @__PURE__ */ jsx(OptionRowContext, {
155
+ value: "menu",
156
+ children: /* @__PURE__ */ jsx(ListBox$1, { children: options })
157
+ });
154
158
  $[17] = options;
155
159
  $[18] = t12;
156
160
  } else t12 = $[18];