@kanso-labs/kanso-ui 0.36.0 → 0.37.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 (77) hide show
  1. package/README.md +2 -0
  2. package/dist/button/context.js +7 -0
  3. package/dist/button/context.js.map +1 -0
  4. package/dist/button/group.js +25 -0
  5. package/dist/button/group.js.map +1 -0
  6. package/dist/button/index.js +50 -37
  7. package/dist/button/index.js.map +1 -1
  8. package/dist/chip/index.js +53 -15
  9. package/dist/chip/index.js.map +1 -1
  10. package/dist/chip/styles.js +48 -0
  11. package/dist/chip/styles.js.map +1 -1
  12. package/dist/collection/styles.js +21 -2
  13. package/dist/collection/styles.js.map +1 -1
  14. package/dist/components/badge/index.d.ts +3 -0
  15. package/dist/components/badge/index.js +7 -2
  16. package/dist/components/badge/index.js.map +1 -1
  17. package/dist/components/button/index.d.ts +1 -1
  18. package/dist/components/button/index.js +94 -111
  19. package/dist/components/button/index.js.map +1 -1
  20. package/dist/components/button-group/index.d.ts +54 -0
  21. package/dist/components/button-group/index.js +272 -0
  22. package/dist/components/button-group/index.js.map +1 -0
  23. package/dist/components/checkbox/index.js +15 -1
  24. package/dist/components/checkbox/index.js.map +1 -1
  25. package/dist/components/chip/index.d.ts +55 -8
  26. package/dist/components/chip/index.js +174 -57
  27. package/dist/components/chip/index.js.map +1 -1
  28. package/dist/components/chip-group/index.d.ts +13 -4
  29. package/dist/components/chip-group/index.js +52 -28
  30. package/dist/components/chip-group/index.js.map +1 -1
  31. package/dist/components/combo-box/index.d.ts +5 -3
  32. package/dist/components/combo-box/index.js.map +1 -1
  33. package/dist/components/icon-button/index.d.ts +1 -1
  34. package/dist/components/icon-button/index.js +119 -88
  35. package/dist/components/icon-button/index.js.map +1 -1
  36. package/dist/components/index.d.ts +6 -3
  37. package/dist/components/list/index.js +10 -10
  38. package/dist/components/list/index.js.map +1 -1
  39. package/dist/components/list-box/index.js +11 -11
  40. package/dist/components/list-box/index.js.map +1 -1
  41. package/dist/components/radio-group/index.js +11 -1
  42. package/dist/components/radio-group/index.js.map +1 -1
  43. package/dist/components/search-view/index.d.ts +79 -0
  44. package/dist/components/search-view/index.js +255 -0
  45. package/dist/components/search-view/index.js.map +1 -0
  46. package/dist/components/segmented-button/index.d.ts +1 -1
  47. package/dist/components/segmented-button/index.js +58 -29
  48. package/dist/components/segmented-button/index.js.map +1 -1
  49. package/dist/components/split-button/index.d.ts +83 -0
  50. package/dist/components/split-button/index.js +341 -0
  51. package/dist/components/split-button/index.js.map +1 -0
  52. package/dist/components/switch/index.js +11 -1
  53. package/dist/components/switch/index.js.map +1 -1
  54. package/dist/components/table/index.js +19 -2
  55. package/dist/components/table/index.js.map +1 -1
  56. package/dist/components/tabs/index.d.ts +35 -4
  57. package/dist/components/tabs/index.js +333 -79
  58. package/dist/components/tabs/index.js.map +1 -1
  59. package/dist/components/tree/index.js +10 -10
  60. package/dist/components/tree/index.js.map +1 -1
  61. package/dist/drag/index.js.map +1 -1
  62. package/dist/glyphs/index.js +37 -1
  63. package/dist/glyphs/index.js.map +1 -1
  64. package/dist/hooks/useToggleGroupDisabled.js +24 -0
  65. package/dist/hooks/useToggleGroupDisabled.js.map +1 -0
  66. package/dist/i18n/index.js +1 -0
  67. package/dist/i18n/index.js.map +1 -1
  68. package/dist/i18n/messages.js +34 -0
  69. package/dist/i18n/messages.js.map +1 -1
  70. package/dist/index.d.ts +6 -3
  71. package/dist/index.js +4 -1
  72. package/dist/row/styles.js +15 -0
  73. package/dist/row/styles.js.map +1 -1
  74. package/dist/styles.css +266 -8
  75. package/dist/tokens/design.tokens.stylex.js +25 -1
  76. package/dist/tokens/design.tokens.stylex.js.map +1 -1
  77. package/package.json +3 -3
@@ -0,0 +1,54 @@
1
+ import { ButtonShape, ButtonSize } from "../button/index.js";
2
+ import { CSSProperties, ReactNode, RefAttributes } from "react";
3
+ import { ToggleButtonGroupProps } from "react-aria-components";
4
+ //#region src/components/button-group/index.d.ts
5
+ type ButtonGroupProps = Omit<ToggleButtonGroupProps, 'children' | 'className' | 'selectionMode' | 'style'> & RefAttributes<HTMLDivElement> & {
6
+ /** The buttons: Buttons and IconButtons, each with an `id` in a group that selects. */
7
+ children?: ReactNode;
8
+ /** The class for the group's own element. */
9
+ className?: string;
10
+ /**
11
+ * Makes the group select, as React Aria's `ToggleButtonGroup`: `single`
12
+ * for one at a time, `multiple` for any number. Left out, the group's
13
+ * buttons are plain buttons.
14
+ */
15
+ selectionMode?: ToggleButtonGroupProps['selectionMode'];
16
+ /**
17
+ * The shape a connected group gives its two ends: `round`, the pill, or
18
+ * `square`, the size's corner, which its inner corners take as well.
19
+ * @default 'round'
20
+ */
21
+ shape?: ButtonShape;
22
+ /**
23
+ * The size every button in the group takes, unless it names its own, and
24
+ * the size the group spaces and shapes them for.
25
+ * @default 'md'
26
+ */
27
+ size?: ButtonSize;
28
+ /** The style for the group's own element. */
29
+ style?: CSSProperties;
30
+ /**
31
+ * `standard` sets the buttons apart and widens a pressed one; `connected`
32
+ * sets them 2dp apart with square inner corners.
33
+ * @default 'standard'
34
+ */
35
+ variant?: ButtonGroupVariant;
36
+ };
37
+ type ButtonGroupVariant = 'connected' | 'standard';
38
+ /**
39
+ * A row of Buttons and IconButtons drawn as the button groups page's
40
+ * standard or connected group. Given `selectionMode`, its buttons are
41
+ * toggles whose selection the group keeps, by their `id`s.
42
+ *
43
+ * ```tsx
44
+ * <ButtonGroup aria-label="Label" selectionMode="single" variant="connected">
45
+ * <Button id="first">First item</Button>
46
+ * <Button id="second">Second item</Button>
47
+ * <Button id="third">Third item</Button>
48
+ * </ButtonGroup>
49
+ * ```
50
+ */
51
+ declare function ButtonGroup({ children, className, ref, selectionMode, shape, size, style, variant, ...props }: ButtonGroupProps): import("react").JSX.Element;
52
+ //#endregion
53
+ export { type ButtonGroupProps, type ButtonGroupVariant, ButtonGroup as default };
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,272 @@
1
+ "use client";
2
+ import { props } from "../../node_modules/@stylexjs/stylex/lib/es/stylex.js";
3
+ import { radii, sizing } from "../../tokens/design.tokens.stylex.js";
4
+ import { mergeStyles } from "../../styles/merge.js";
5
+ import { ButtonGroupItemContext } from "../../button/context.js";
6
+ import { c } from "react/compiler-runtime";
7
+ import { Children, isValidElement, useState } from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ import { ButtonContext, Group, ToggleButtonGroup } from "react-aria-components";
10
+ //#region src/components/button-group/index.tsx
11
+ const EXPANDED_RATIO = .15;
12
+ const DISABLED = { isDisabled: true };
13
+ const styles = {
14
+ group: {
15
+ kGNEyG: "x6s0dn4",
16
+ kB7OPa: "x9f619",
17
+ k1xSpc: "x3nfvp2",
18
+ kwnvtZ: "xozqiw3",
19
+ $$css: true
20
+ },
21
+ minimum: {
22
+ k7Eaqz: "x900493",
23
+ $$css: true
24
+ }
25
+ };
26
+ const gaps = {
27
+ connected: {
28
+ kOIVth: "x14qo01y",
29
+ $$css: true
30
+ },
31
+ lg: {
32
+ kOIVth: "x126z3so",
33
+ $$css: true
34
+ },
35
+ md: {
36
+ kOIVth: "x1gka490",
37
+ $$css: true
38
+ },
39
+ xl: {
40
+ kOIVth: "x126z3so",
41
+ $$css: true
42
+ },
43
+ xs: {
44
+ kOIVth: "xaobbuh",
45
+ $$css: true
46
+ },
47
+ xxl: {
48
+ kOIVth: "x126z3so",
49
+ $$css: true
50
+ }
51
+ };
52
+ const corners = { shape: (start, end) => [{
53
+ kT0f0o: end != null ? "x1wsjk4f" : end,
54
+ kVL7Gh: start != null ? "x1oq9ryg" : start,
55
+ kfmiAY: end != null ? "xbsomw4" : end,
56
+ krdFHd: start != null ? "x6pmj1i" : start,
57
+ $$css: true
58
+ }, {
59
+ "--x-borderEndEndRadius": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(end),
60
+ "--x-borderEndStartRadius": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(start),
61
+ "--x-borderStartEndRadius": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(end),
62
+ "--x-borderStartStartRadius": ((val) => typeof val === "number" ? val + "px" : val != null ? val : void 0)(start)
63
+ }] };
64
+ const INNER = {
65
+ lg: radii.sm,
66
+ md: radii.sm,
67
+ xl: radii.lg,
68
+ xs: radii.xs,
69
+ xxl: "20px"
70
+ };
71
+ const ROUND = {
72
+ lg: `calc(${sizing.controlLg} / 2)`,
73
+ md: `calc(${sizing.controlSm} / 2)`,
74
+ xl: `calc(${sizing.controlXl} / 2)`,
75
+ xs: `calc(${sizing.controlXs} / 2)`,
76
+ xxl: `calc(${sizing.controlXxl} / 2)`
77
+ };
78
+ const INNER_PRESSED = {
79
+ lg: radii.xs,
80
+ md: radii.xs,
81
+ xl: radii.sm,
82
+ xs: "2px",
83
+ xxl: "10px"
84
+ };
85
+ /**
86
+ * A row of Buttons and IconButtons drawn as the button groups page's
87
+ * standard or connected group. Given `selectionMode`, its buttons are
88
+ * toggles whose selection the group keeps, by their `id`s.
89
+ *
90
+ * ```tsx
91
+ * <ButtonGroup aria-label="Label" selectionMode="single" variant="connected">
92
+ * <Button id="first">First item</Button>
93
+ * <Button id="second">Second item</Button>
94
+ * <Button id="third">Third item</Button>
95
+ * </ButtonGroup>
96
+ * ```
97
+ */
98
+ function ButtonGroup(t0) {
99
+ const $ = c(40);
100
+ let children;
101
+ let className;
102
+ let props$1;
103
+ let ref;
104
+ let selectionMode;
105
+ let size;
106
+ let style;
107
+ let t1;
108
+ let t2;
109
+ if ($[0] !== t0) {
110
+ ({children, className, ref, selectionMode, shape: t1, size, style, variant: t2, ...props$1} = t0);
111
+ $[0] = t0;
112
+ $[1] = children;
113
+ $[2] = className;
114
+ $[3] = props$1;
115
+ $[4] = ref;
116
+ $[5] = selectionMode;
117
+ $[6] = size;
118
+ $[7] = style;
119
+ $[8] = t1;
120
+ $[9] = t2;
121
+ } else {
122
+ children = $[1];
123
+ className = $[2];
124
+ props$1 = $[3];
125
+ ref = $[4];
126
+ selectionMode = $[5];
127
+ size = $[6];
128
+ style = $[7];
129
+ t1 = $[8];
130
+ t2 = $[9];
131
+ }
132
+ const shape = t1 === void 0 ? "round" : t1;
133
+ const variant = t2 === void 0 ? "standard" : t2;
134
+ const [press, setPress] = useState(null);
135
+ let groupProps;
136
+ let t3;
137
+ if ($[10] !== children || $[11] !== className || $[12] !== press || $[13] !== shape || $[14] !== size || $[15] !== style || $[16] !== variant) {
138
+ const items = Children.toArray(children).filter(isValidElement);
139
+ const sized = size ?? "md";
140
+ let t4;
141
+ if ($[19] !== className || $[20] !== sized || $[21] !== style || $[22] !== variant) {
142
+ t4 = mergeStyles(props(styles.group, variant === "connected" ? gaps.connected : gaps[sized]), {
143
+ className,
144
+ style
145
+ });
146
+ $[19] = className;
147
+ $[20] = sized;
148
+ $[21] = style;
149
+ $[22] = variant;
150
+ $[23] = t4;
151
+ } else t4 = $[23];
152
+ groupProps = t4;
153
+ let t5;
154
+ if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
155
+ t5 = () => {
156
+ setPress(null);
157
+ };
158
+ $[24] = t5;
159
+ } else t5 = $[24];
160
+ const endPress = t5;
161
+ t3 = items.map((child, index) => /* @__PURE__ */ jsx(ButtonGroupItemContext, {
162
+ value: itemFor({
163
+ count: items.length,
164
+ endPress,
165
+ index,
166
+ press,
167
+ setPress,
168
+ shape,
169
+ size,
170
+ variant
171
+ }),
172
+ children: child
173
+ }, child.key ?? index));
174
+ $[10] = children;
175
+ $[11] = className;
176
+ $[12] = press;
177
+ $[13] = shape;
178
+ $[14] = size;
179
+ $[15] = style;
180
+ $[16] = variant;
181
+ $[17] = groupProps;
182
+ $[18] = t3;
183
+ } else {
184
+ groupProps = $[17];
185
+ t3 = $[18];
186
+ }
187
+ const content = t3;
188
+ if (selectionMode !== void 0) {
189
+ let t4;
190
+ if ($[25] !== content || $[26] !== groupProps || $[27] !== props$1 || $[28] !== ref || $[29] !== selectionMode) {
191
+ t4 = /* @__PURE__ */ jsx(ToggleButtonGroup, {
192
+ ref,
193
+ selectionMode,
194
+ ...props$1,
195
+ ...groupProps,
196
+ children: content
197
+ });
198
+ $[25] = content;
199
+ $[26] = groupProps;
200
+ $[27] = props$1;
201
+ $[28] = ref;
202
+ $[29] = selectionMode;
203
+ $[30] = t4;
204
+ } else t4 = $[30];
205
+ return t4;
206
+ }
207
+ const t4 = props$1["aria-label"];
208
+ const t5 = props$1["aria-labelledby"];
209
+ let t6;
210
+ if ($[31] !== content || $[32] !== props$1.isDisabled) {
211
+ t6 = props$1.isDisabled === true ? /* @__PURE__ */ jsx(ButtonContext, {
212
+ value: DISABLED,
213
+ children: content
214
+ }) : content;
215
+ $[31] = content;
216
+ $[32] = props$1.isDisabled;
217
+ $[33] = t6;
218
+ } else t6 = $[33];
219
+ let t7;
220
+ if ($[34] !== groupProps || $[35] !== ref || $[36] !== t4 || $[37] !== t5 || $[38] !== t6) {
221
+ t7 = /* @__PURE__ */ jsx(Group, {
222
+ "aria-label": t4,
223
+ "aria-labelledby": t5,
224
+ ref,
225
+ ...groupProps,
226
+ children: t6
227
+ });
228
+ $[34] = groupProps;
229
+ $[35] = ref;
230
+ $[36] = t4;
231
+ $[37] = t5;
232
+ $[38] = t6;
233
+ $[39] = t7;
234
+ } else t7 = $[39];
235
+ return t7;
236
+ }
237
+ function connectedStyles(index, count, size, shape, state) {
238
+ const outer = shape === "square" ? INNER[size] : ROUND[size];
239
+ const inner = state.isPressed ? INNER_PRESSED[size] : state.isSelected === true ? ROUND[size] : INNER[size];
240
+ const start = index === 0 ? outer : inner;
241
+ const end = index === count - 1 ? outer : inner;
242
+ return [corners.shape(start, end), (size === "xs" || size === "md") && styles.minimum];
243
+ }
244
+ function itemFor({ count, endPress, index, press, setPress, shape, size, variant }) {
245
+ const sized = size ?? "md";
246
+ if (variant === "connected") return {
247
+ shift: 0,
248
+ size,
249
+ styles: (state) => connectedStyles(index, count, sized, shape, state)
250
+ };
251
+ return {
252
+ onPressEnd: endPress,
253
+ onPressStart: (width) => {
254
+ setPress({
255
+ delta: width * EXPANDED_RATIO,
256
+ index
257
+ });
258
+ },
259
+ shift: shiftFor(index, count, press),
260
+ size
261
+ };
262
+ }
263
+ function shiftFor(index, count, press) {
264
+ if (press === null) return 0;
265
+ if (index === press.index) return press.delta;
266
+ if (Math.abs(index - press.index) !== 1) return 0;
267
+ return -(press.index === 0 || press.index === count - 1 ? press.delta : press.delta / 2);
268
+ }
269
+ //#endregion
270
+ export { ButtonGroup as default };
271
+
272
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["c","_c","CSSProperties","ReactNode","RefAttributes","ToggleButtonGroupProps","RACToggleButtonGroupProps","stylex","Children","isValidElement","useCallback","useState","ButtonContext","Group","RACGroup","ToggleButtonGroup","RACToggleButtonGroup","ButtonState","ButtonGroupItem","GroupSize","ButtonShape","ButtonSize","ButtonGroupItemContext","mergeStyles","radii","sizing","spacing","EXPANDED_RATIO","DISABLED","isDisabled","styles","group","kGNEyG","kB7OPa","k1xSpc","kwnvtZ","$$css","minimum","k7Eaqz","gaps","connected","kOIVth","lg","md","xl","xs","xxl","corners","shape","start","end","kT0f0o","kVL7Gh","kfmiAY","krdFHd","val","undefined","INNER","sm","ROUND","controlLg","controlSm","controlXl","controlXs","controlXxl","INNER_PRESSED","ButtonGroupProps","Omit","HTMLDivElement","children","className","selectionMode","size","style","variant","ButtonGroupVariant","Press","delta","index","ButtonGroup","t0","$","props","ref","t1","t2","press","setPress","groupProps","t3","items","toArray","filter","sized","t4","t5","Symbol","for","endPress","map","child","key","itemFor","count","length","content","t6","t7","connectedStyles","state","outer","inner","isPressed","isSelected","shift","onPressEnd","onPressStart","width","shiftFor","Math","abs","atEnd","_c","props","stylex.props","RACToggleButtonGroup","RACGroup"],"sources":["../../../src/components/button-group/index.tsx"],"sourcesContent":["'use client';\n\nimport type { CSSProperties, ReactNode, RefAttributes } from 'react';\nimport type { ToggleButtonGroupProps as RACToggleButtonGroupProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { Children, isValidElement, useCallback, useState } from 'react';\nimport { ButtonContext, Group as RACGroup, ToggleButtonGroup as RACToggleButtonGroup } from 'react-aria-components';\nimport type { ButtonState } from '../../button';\nimport type { ButtonGroupItem, GroupSize } from '../../button/context';\nimport type { ButtonShape, ButtonSize } from '../button';\nimport { ButtonGroupItemContext } from '../../button/context';\nimport { mergeStyles } from '../../styles/merge';\nimport '../../tokens/design.tokens.stylex';\nimport { radii, sizing, spacing } from '../../tokens/design.tokens.stylex';\n\n// The button groups page's two groups, around Buttons and IconButtons placed\n// inside: the standard group, buttons set apart by the page's 18dp, 12dp, 8dp,\n// 8dp and 8dp across the sizes, and the connected group, buttons 2dp apart\n// whose inner corners square off — 4dp, 8dp, 8dp, 16dp and 20dp — while the\n// group's two ends keep the buttons' own round. A square connected group\n// takes the same corner at its ends. The group draws nothing itself; it\n// hands each button its size, its corners and its part in the press\n// interaction through src/button/context.ts.\n//\n// **A press is felt across a standard group.** The pressed button widens by\n// 15% of its width — the share Material Design's own group widens it by —\n// and its neighbours narrow to make the room, so the group's width holds:\n// both neighbours by half the gain each, or the one neighbour of a button at\n// the group's end by all of it. Button takes the change as inline padding\n// and IconButton as width, and both ease it over the motion tokens' short\n// duration.\n//\n// **A connected group answers a press and a selection in the corner\n// instead.** Its buttons stay where they are; a pressed one's inner corners\n// tighten, and a selected one's round off entirely. The page gives the\n// pressed corner for its small group alone, 4dp against the 8dp it rests at;\n// the other sizes press to half their resting corner the same way. The page\n// also gives XS and S buttons in a connected group a 48dp minimum width,\n// which is their touch target.\n//\n// Given `selectionMode` the group is React Aria's `ToggleButtonGroup`, which\n// makes every button in it a toggle and reports the selection by the\n// buttons' `id`s: a radio group for `single`, a toolbar for `multiple`.\n// Without it the group is React Aria's plain `Group`.\n\n// The press interaction's share, from Material Design's own button group.\nconst EXPANDED_RATIO = 0.15;\nconst DISABLED = {\n isDisabled: true\n};\nconst styles = {\n group: {\n kGNEyG: \"x6s0dn4\",\n kB7OPa: \"x9f619\",\n k1xSpc: \"x3nfvp2\",\n kwnvtZ: \"xozqiw3\",\n $$css: true\n },\n minimum: {\n k7Eaqz: \"x900493\",\n $$css: true\n }\n};\n\n// The space between buttons, by variant and size. The standard group's 18dp\n// at XS falls between two steps of the spacing scale and is written out.\nconst gaps = {\n connected: {\n kOIVth: \"x14qo01y\",\n $$css: true\n },\n lg: {\n kOIVth: \"x126z3so\",\n $$css: true\n },\n md: {\n kOIVth: \"x1gka490\",\n $$css: true\n },\n xl: {\n kOIVth: \"x126z3so\",\n $$css: true\n },\n xs: {\n kOIVth: \"xaobbuh\",\n $$css: true\n },\n xxl: {\n kOIVth: \"x126z3so\",\n $$css: true\n }\n};\n\n// A connected button's corners on each side, set from the button's place in\n// the group and its state.\nconst corners = {\n shape: (start: string, end: string) => [{\n kT0f0o: end != null ? \"x1wsjk4f\" : end,\n kVL7Gh: start != null ? \"x1oq9ryg\" : start,\n kfmiAY: end != null ? \"xbsomw4\" : end,\n krdFHd: start != null ? \"x6pmj1i\" : start,\n $$css: true\n }, {\n \"--x-borderEndEndRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(end),\n \"--x-borderEndStartRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(start),\n \"--x-borderStartEndRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(end),\n \"--x-borderStartStartRadius\": (val => typeof val === \"number\" ? val + \"px\" : val != null ? val : undefined)(start)\n }]\n};\n\n// The inner corner each size rests at, and the corner it presses to. The 20dp\n// at XL falls between two steps of the radius scale, and the two halves that\n// are not steps of it are written out too.\nconst INNER = {\n lg: radii.sm,\n md: radii.sm,\n xl: radii.lg,\n xs: radii.xs,\n xxl: '20px'\n};\n\n// The round end at each size: half the button's height. Not the pill's\n// 9999px: CSS scales every corner of a box down together when two on one\n// side add up to more than the side is long, so a 9999px end beside an 8px\n// inner corner shrank the inner one to nothing. Half the height fits as\n// written. A label that wraps makes a button taller than this, and its ends\n// a little less than round.\nconst ROUND = {\n lg: `calc(${sizing.controlLg} / 2)`,\n md: `calc(${sizing.controlSm} / 2)`,\n xl: `calc(${sizing.controlXl} / 2)`,\n xs: `calc(${sizing.controlXs} / 2)`,\n xxl: `calc(${sizing.controlXxl} / 2)`\n};\nconst INNER_PRESSED = {\n lg: radii.xs,\n md: radii.xs,\n xl: radii.sm,\n xs: '2px',\n xxl: '10px'\n};\ntype ButtonGroupProps = Omit<RACToggleButtonGroupProps, 'children' | 'className' | 'selectionMode' | 'style'> & RefAttributes<HTMLDivElement> & {\n /** The buttons: Buttons and IconButtons, each with an `id` in a group that selects. */\n children?: ReactNode;\n /** The class for the group's own element. */\n className?: string;\n /**\n * Makes the group select, as React Aria's `ToggleButtonGroup`: `single`\n * for one at a time, `multiple` for any number. Left out, the group's\n * buttons are plain buttons.\n */\n selectionMode?: RACToggleButtonGroupProps['selectionMode'];\n /**\n * The shape a connected group gives its two ends: `round`, the pill, or\n * `square`, the size's corner, which its inner corners take as well.\n * @default 'round'\n */\n shape?: ButtonShape;\n /**\n * The size every button in the group takes, unless it names its own, and\n * the size the group spaces and shapes them for.\n * @default 'md'\n */\n size?: ButtonSize;\n /** The style for the group's own element. */\n style?: CSSProperties;\n /**\n * `standard` sets the buttons apart and widens a pressed one; `connected`\n * sets them 2dp apart with square inner corners.\n * @default 'standard'\n */\n variant?: ButtonGroupVariant;\n};\ntype ButtonGroupVariant = 'connected' | 'standard';\ntype Press = {\n delta: number;\n index: number;\n};\n\n/**\n * A row of Buttons and IconButtons drawn as the button groups page's\n * standard or connected group. Given `selectionMode`, its buttons are\n * toggles whose selection the group keeps, by their `id`s.\n *\n * ```tsx\n * <ButtonGroup aria-label=\"Label\" selectionMode=\"single\" variant=\"connected\">\n * <Button id=\"first\">First item</Button>\n * <Button id=\"second\">Second item</Button>\n * <Button id=\"third\">Third item</Button>\n * </ButtonGroup>\n * ```\n */\nfunction ButtonGroup({\n children,\n className,\n ref,\n selectionMode,\n shape = 'round',\n size,\n style,\n variant = 'standard',\n ...props\n}: ButtonGroupProps) {\n const [press, setPress] = useState<null | Press>(null);\n const items = Children.toArray(children).filter(isValidElement);\n const sized = size ?? 'md';\n const groupProps = mergeStyles(stylex.props(styles.group, variant === 'connected' ? gaps.connected : gaps[sized]), {\n className,\n style\n });\n const endPress = useCallback(() => {\n setPress(null);\n }, []);\n const content = items.map((child, index) => <ButtonGroupItemContext key={child.key ?? index} value={itemFor({\n count: items.length,\n endPress,\n index,\n press,\n setPress,\n shape,\n size,\n variant\n })}>\n {child}\n </ButtonGroupItemContext>);\n if (selectionMode !== undefined) {\n return <RACToggleButtonGroup ref={ref} selectionMode={selectionMode} {...props} {...groupProps}>\n {content}\n </RACToggleButtonGroup>;\n }\n\n // A plain group disables its buttons through React Aria's own context,\n // which Button and IconButton read; a selecting one does it itself.\n return <RACGroup aria-label={props['aria-label']} aria-labelledby={props['aria-labelledby']} ref={ref} {...groupProps}>\n {props.isDisabled === true ? <ButtonContext value={DISABLED}>{content}</ButtonContext> : content}\n </RACGroup>;\n}\n\n// A connected button's corners: the group's ends keep the outer shape, and\n// every edge it shares with a neighbour takes the inner corner, tighter while\n// pressed and round once selected — a press wins over a selection.\nfunction connectedStyles(index: number, count: number, size: GroupSize, shape: ButtonShape, state: ButtonState) {\n const outer = shape === 'square' ? INNER[size] : ROUND[size];\n const inner = state.isPressed ? INNER_PRESSED[size] : state.isSelected === true ? ROUND[size] : INNER[size];\n const start = index === 0 ? outer : inner;\n const end = index === count - 1 ? outer : inner;\n return [corners.shape(start, end), (size === 'xs' || size === 'md') && styles.minimum];\n}\n\n// One button's part in the group: its size, its corners in a connected\n// group, and its share of a press in a standard one.\nfunction itemFor({\n count,\n endPress,\n index,\n press,\n setPress,\n shape,\n size,\n variant\n}: {\n count: number;\n endPress: () => void;\n index: number;\n press: null | Press;\n setPress: (press: Press) => void;\n shape: ButtonShape;\n size: GroupSize | undefined;\n variant: ButtonGroupVariant;\n}): ButtonGroupItem {\n const sized = size ?? 'md';\n if (variant === 'connected') {\n return {\n shift: 0,\n size,\n styles: (state: ButtonState) => connectedStyles(index, count, sized, shape, state)\n };\n }\n return {\n onPressEnd: endPress,\n onPressStart: (width: number) => {\n setPress({\n delta: width * EXPANDED_RATIO,\n index\n });\n },\n shift: shiftFor(index, count, press),\n size\n };\n}\n\n// How far a standard group moves one button's width while a press is held:\n// the pressed button gains the whole share, and its neighbours give it up —\n// half each, or all of it from the one neighbour of a button at an end.\nfunction shiftFor(index: number, count: number, press: null | Press) {\n if (press === null) {\n return 0;\n }\n if (index === press.index) {\n return press.delta;\n }\n if (Math.abs(index - press.index) !== 1) {\n return 0;\n }\n const atEnd = press.index === 0 || press.index === count - 1;\n return -(atEnd ? press.delta : press.delta / 2);\n}\nexport type { ButtonGroupProps, ButtonGroupVariant };\nexport default ButtonGroup;"],"mappings":";;;;;;;;;;AA8CA,MAAM2B,iBAAiB;AACvB,MAAMC,WAAW,EACfC,YAAY,KACd;AACA,MAAMC,SAAS;CACbC,OAAO;EACLC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;CACT;CACAC,SAAS;EACPC,QAAQ;EACRF,OAAO;CACT;AACF;AAIA,MAAMG,OAAO;CACXC,WAAW;EACTC,QAAQ;EACRL,OAAO;CACT;CACAM,IAAI;EACFD,QAAQ;EACRL,OAAO;CACT;CACAO,IAAI;EACFF,QAAQ;EACRL,OAAO;CACT;CACAQ,IAAI;EACFH,QAAQ;EACRL,OAAO;CACT;CACAS,IAAI;EACFJ,QAAQ;EACRL,OAAO;CACT;CACAU,KAAK;EACHL,QAAQ;EACRL,OAAO;CACT;AACF;AAIA,MAAMW,UAAU,EACdC,QAAQC,OAAeC,QAAgB,CAAC;CACtCC,QAAQD,OAAO,OAAO,aAAaA;CACnCE,QAAQH,SAAS,OAAO,aAAaA;CACrCI,QAAQH,OAAO,OAAO,YAAYA;CAClCI,QAAQL,SAAS,OAAO,YAAYA;CACpCb,OAAO;AACT,GAAG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,aACd,OAAO;EACLwC,OAAO;EACP1C;EACA1C,SAAS+E,UAAuBD,gBAAgB9B,OAAOyB,OAAOV,OAAO7C,OAAO6D,KAAK;CACnF;CAEF,OAAO;EACLM,YAAYjB;EACZkB,eAAeC,UAAkB;GAC/B9B,SAAS;IACPV,OAAOwC,QAAQ1F;IACfmD;GACF,CAAC;EACH;EACAoC,OAAOI,SAASxC,OAAOyB,OAAOjB,KAAK;EACnCd;CACF;AACF;AAKA,SAAS8C,SAASxC,OAAeyB,OAAejB,OAAqB;CACnE,IAAIA,UAAU,MACZ,OAAO;CAET,IAAIR,UAAUQ,MAAMR,OAClB,OAAOQ,MAAMT;CAEf,IAAI0C,KAAKC,IAAI1C,QAAQQ,MAAMR,KAAK,MAAM,GACpC,OAAO;CAGT,OAAO,EADOQ,MAAMR,UAAU,KAAKQ,MAAMR,UAAUyB,QAAQ,IAC1CjB,MAAMT,QAAQS,MAAMT,QAAQ;AAC/C"}
@@ -80,6 +80,20 @@ const hoverLayers = {
80
80
  $$css: true
81
81
  }
82
82
  };
83
+ const focusLayers = {
84
+ error: {
85
+ kWkggS: "xyn212m",
86
+ $$css: true
87
+ },
88
+ marked: {
89
+ kWkggS: "x1sog3nf",
90
+ $$css: true
91
+ },
92
+ unmarked: {
93
+ kWkggS: "xwqhyid",
94
+ $$css: true
95
+ }
96
+ };
83
97
  const pressedLayers = {
84
98
  error: {
85
99
  kWkggS: "x3czxiy",
@@ -102,7 +116,7 @@ function buttonContent(children, ripple) {
102
116
  const active = state.isHovered || state.isPressed || state.isFocusVisible;
103
117
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
104
118
  ...interactive ? ripple.handlers : {},
105
- ...props(controlStyles.disc, styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled, interactive && state.isHovered && hoverLayers[tone], interactive && state.isPressed && pressedLayers[tone], state.isFocusVisible && focus.ringVisible),
119
+ ...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),
106
120
  children: [/* @__PURE__ */ jsx("span", {
107
121
  ...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)),
108
122
  children: state.isIndeterminate ? /* @__PURE__ */ jsx(IndeterminateGlyph, { className: "xmix8c7 x1lliihq x1xp8n7a" }) : state.isSelected ? /* @__PURE__ */ jsx(CheckGlyph, { className: "xmix8c7 x1lliihq x1xp8n7a" }) : null
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","ReactNode","RefAttributes","CheckboxButtonRenderProps","CheckboxFieldProps","RACCheckboxFieldProps","stylex","CheckboxButton","CheckboxField","ControlLabel","controlStyles","FieldMessage","invalidFrom","useFieldValidationBehavior","CheckGlyph","IndeterminateGlyph","useRipple","focus","mergeStatefulStyles","colors","motion","stateLayerOpacity","styles","box","k6CgDc","kGNEyG","kWkggS","kZKoxP","kVAM5u","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kzqmXN","kjj79g","kIyJzY","k1ekBW","kAMwcw","$$css","boxMarked","boxMarkedDisabled","boxMarkedError","boxUnmarkedActive","boxUnmarkedDisabled","boxUnmarkedError","control","hoverLayers","error","marked","unmarked","pressedLayers","CheckboxProps","children","description","Omit","Ripple","ReturnType","HTMLSpanElement","Tone","buttonContent","ripple","state","isSelected","isIndeterminate","interactive","isDisabled","isReadOnly","tone","isInvalid","active","isHovered","isPressed","isFocusVisible","handlers","props","disc","controlReadOnly","controlDisabled","ringVisible","surface","Checkbox","t0","$","validationBehavior","T0","t1","t2","field","t3","t4","t5","Symbol","for","messages","t6","t7","stylex.props","_c","props"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { CheckboxButtonRenderProps, CheckboxFieldProps as RACCheckboxFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { CheckboxButton, CheckboxField } 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.\nconst styles = {\n box: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\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: \"x78zum5\",\n kzqmXN: \"x1xp8n7a\",\n kjj79g: \"xl56j7k\",\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\",\n kMwMTN: \"xrpadme\",\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\",\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};\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 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<HTMLSpanElement>>;\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 handlers and surface go on the\n// control while the checkbox can change, and are left off while it cannot,\n// since a press that changes nothing should not look like one.\nfunction buttonContent(children: ReactNode, ripple: Ripple) {\n return (state: CheckboxButtonRenderProps) => {\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 {...interactive ? ripple.handlers : {}} {...stylex.props(controlStyles.disc, styles.control, state.isReadOnly && controlStyles.controlReadOnly, state.isDisabled && controlStyles.controlDisabled, interactive && state.isHovered && hoverLayers[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 {state.isIndeterminate ? <IndeterminateGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : state.isSelected ? <CheckGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : null}\n </span>\n {interactive ? ripple.surface : null}\n </span>\n <ControlLabel state={state}>{children}</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 * 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 ripple = useRipple<HTMLSpanElement>();\n const validationBehavior = useFieldValidationBehavior();\n return <CheckboxField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(controlStyles.field), props)}>\n <CheckboxButton className=\"xjp7ctv\">\n {buttonContent(children, ripple)}\n </CheckboxButton>\n <div {...stylex.props(controlStyles.messages)}>\n <FieldMessage description={description} error={error} inset={false} />\n </div>\n </CheckboxField>;\n}\nexport type { CheckboxProps };\nexport default Checkbox;"],"mappings":";;;;;;;;;;;;;;AAqCA,MAAMuB,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,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,QAA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F,QAAS;EAACX,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,IAAAY;CAAA,IAAAZ,EAAA,OAAA7B,eAAA6B,EAAA,OAAAnC,OAAA;EAA7C+C,KAAA,oBAAA,OAAA;GAEM,GAFGJ;GACP,UAAA,oBAAC,cAAD;IAA2BrC;IAAoBN;IAAc,OAAA;GAAK,CAAA;EAC9D,CAAA;EAAAmC,EAAA,KAAA7B;EAAA6B,EAAA,KAAAnC;EAAAmC,EAAA,MAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,QAAAE,MAAAF,EAAA,QAAAR,WAAAQ,EAAA,QAAAG,MAAAH,EAAA,QAAAI,MAAAJ,EAAA,QAAAO,MAAAP,EAAA,QAAAY,MAAAZ,EAAA,QAAAC,oBAAA;EANHY,KAAA,qBAAC,IAAD;GAA0B,WAAAV;GAAwCF;GAAkB,GAAMT;GAAK,GAAMY;GAArG,UAAA,CACHG,IAGAK,EAJiB;;EAOHZ,EAAA,MAAAE;EAAAF,EAAA,MAAAR;EAAAQ,EAAA,MAAAG;EAAAH,EAAA,MAAAI;EAAAJ,EAAA,MAAAO;EAAAP,EAAA,MAAAY;EAAAZ,EAAA,MAAAC;EAAAD,EAAA,MAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,OAPXa;AAOW"}
1
+ {"version":3,"file":"index.js","names":["c","_c","ReactNode","RefAttributes","CheckboxButtonRenderProps","CheckboxFieldProps","RACCheckboxFieldProps","stylex","CheckboxButton","CheckboxField","ControlLabel","controlStyles","FieldMessage","invalidFrom","useFieldValidationBehavior","CheckGlyph","IndeterminateGlyph","useRipple","focus","mergeStatefulStyles","colors","motion","stateLayerOpacity","styles","box","k6CgDc","kGNEyG","kWkggS","kZKoxP","kVAM5u","kaIpWk","ksu8eU","kMzoRj","kB7OPa","kMwMTN","k1xSpc","kzqmXN","kjj79g","kIyJzY","k1ekBW","kAMwcw","$$css","boxMarked","boxMarkedDisabled","boxMarkedError","boxUnmarkedActive","boxUnmarkedDisabled","boxUnmarkedError","control","hoverLayers","error","marked","unmarked","focusLayers","pressedLayers","CheckboxProps","children","description","Omit","Ripple","ReturnType","HTMLSpanElement","Tone","buttonContent","ripple","state","isSelected","isIndeterminate","interactive","isDisabled","isReadOnly","tone","isInvalid","active","isHovered","isPressed","isFocusVisible","handlers","props","disc","controlReadOnly","controlDisabled","ringVisible","surface","Checkbox","t0","$","validationBehavior","T0","t1","t2","field","t3","t4","t5","Symbol","for","messages","t6","t7","stylex.props","_c","props"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode, RefAttributes } from 'react';\nimport type { CheckboxButtonRenderProps, CheckboxFieldProps as RACCheckboxFieldProps } from 'react-aria-components';\nimport * as stylex from '@stylexjs/stylex';\nimport { CheckboxButton, CheckboxField } 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.\nconst styles = {\n box: {\n k6CgDc: \"x12w9bfk\",\n kGNEyG: \"x6s0dn4\",\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: \"x78zum5\",\n kzqmXN: \"x1xp8n7a\",\n kjj79g: \"xl56j7k\",\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\",\n kMwMTN: \"xrpadme\",\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\",\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 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<HTMLSpanElement>>;\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 handlers and surface go on the\n// control while the checkbox can change, and are left off while it cannot,\n// since a press that changes nothing should not look like one.\nfunction buttonContent(children: ReactNode, ripple: Ripple) {\n return (state: CheckboxButtonRenderProps) => {\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 {...interactive ? ripple.handlers : {}} {...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 {state.isIndeterminate ? <IndeterminateGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : state.isSelected ? <CheckGlyph className=\"xmix8c7 x1lliihq x1xp8n7a\" /> : null}\n </span>\n {interactive ? ripple.surface : null}\n </span>\n <ControlLabel state={state}>{children}</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 * 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 ripple = useRipple<HTMLSpanElement>();\n const validationBehavior = useFieldValidationBehavior();\n return <CheckboxField isInvalid={invalidFrom(error)} validationBehavior={validationBehavior} {...props} {...mergeStatefulStyles(stylex.props(controlStyles.field), props)}>\n <CheckboxButton className=\"xjp7ctv\">\n {buttonContent(children, ripple)}\n </CheckboxButton>\n <div {...stylex.props(controlStyles.messages)}>\n <FieldMessage description={description} error={error} inset={false} />\n </div>\n </CheckboxField>;\n}\nexport type { CheckboxProps };\nexport default Checkbox;"],"mappings":";;;;;;;;;;;;;;AAqCA,MAAMuB,SAAS;CACbC,KAAK;EACHC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;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BAAC,IAAD;GAA0B,WAAAV;GAAwCF;GAAkB,GAAMT;GAAK,GAAMY;GAArG,UAAA,CACHG,IAGAK,EAJiB;;EAOHZ,EAAA,MAAAE;EAAAF,EAAA,MAAAR;EAAAQ,EAAA,MAAAG;EAAAH,EAAA,MAAAI;EAAAJ,EAAA,MAAAO;EAAAP,EAAA,MAAAY;EAAAZ,EAAA,MAAAC;EAAAD,EAAA,MAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,OAPXa;AAOW"}
@@ -1,7 +1,30 @@
1
1
  import { ReactNode, RefAttributes } from "react";
2
- import { ToggleButtonProps } from "react-aria-components";
2
+ import { ButtonProps, ToggleButtonProps } from "react-aria-components";
3
3
  //#region src/components/chip/index.d.ts
4
- type ChipProps = Omit<ToggleButtonProps, 'children'> & {
4
+ /** An assist or suggestion chip: an action, drawn as a plain button. */
5
+ type ChipActionProps = Omit<ButtonProps, 'children' | 'isPending'> & {
6
+ /** The chip's label. */
7
+ children?: ReactNode;
8
+ /**
9
+ * Raises the chip off the page on a container of its own, at the page's
10
+ * elevation 1, in place of the outline.
11
+ * @default false
12
+ */
13
+ elevated?: boolean;
14
+ /**
15
+ * An icon before the label, in the page's 18dp slot and the primary role.
16
+ * An icon drawn in `em` takes its size from the slot.
17
+ */
18
+ icon?: ReactNode;
19
+ /**
20
+ * `assist` for an action the chip's context suggests, and `suggestion`
21
+ * for one the product generates. Either is an action rather than a
22
+ * selection, so neither is ever selected.
23
+ */
24
+ variant: 'assist' | 'suggestion';
25
+ };
26
+ /** A filter chip: a two-state button, the default. */
27
+ type ChipFilterProps = Omit<ToggleButtonProps, 'children'> & {
5
28
  /**
6
29
  * The chip's label. A node rather than React Aria's node-or-function,
7
30
  * since the chip puts its own check before whatever this is and a function
@@ -9,14 +32,38 @@ type ChipProps = Omit<ToggleButtonProps, 'children'> & {
9
32
  * chip narrows it the same way, for the same reason.
10
33
  */
11
34
  children?: ReactNode;
35
+ /**
36
+ * Raises the chip off the page on a container of its own, at the page's
37
+ * elevation 1, in place of the outline. A selected one keeps the
38
+ * secondary container.
39
+ * @default false
40
+ */
41
+ elevated?: boolean;
42
+ /**
43
+ * An icon before the label, in the page's 18dp slot and the primary role.
44
+ * The check takes its place while the chip is selected, so the chip keeps
45
+ * its width. An icon drawn in `em` takes its size from the slot.
46
+ */
47
+ icon?: ReactNode;
48
+ /**
49
+ * A filter chip, a two-state button.
50
+ * @default 'filter'
51
+ */
52
+ variant?: 'filter';
12
53
  };
54
+ type ChipProps = ChipActionProps | ChipFilterProps;
55
+ /** Which of the chips page's chips a Chip is. */
56
+ type ChipVariant = 'assist' | 'filter' | 'suggestion';
13
57
  /**
14
- * A chip is a two-state button, so its selected state is React Aria's
15
- * `isSelected`: pass it with `onChange` to control it, or `defaultSelected` to
16
- * let it keep its own state. Selection is announced through `aria-pressed`
17
- * rather than a role of its own.
58
+ * A chip. By default a filter chip, which is a two-state button, so its
59
+ * selected state is React Aria's `isSelected`: pass it with `onChange` to
60
+ * control it, or `defaultSelected` to let it keep its own state. Selection is
61
+ * announced through `aria-pressed` rather than a role of its own.
62
+ *
63
+ * `variant="assist"` and `variant="suggestion"` draw the page's two action
64
+ * chips instead: plain buttons, pressed with `onPress`, never selected.
18
65
  */
19
- declare function Chip({ children, onKeyDown, onKeyUp, render, ...props }: ChipProps & RefAttributes<HTMLButtonElement>): import("react").JSX.Element;
66
+ declare function Chip(props: ChipProps & RefAttributes<HTMLButtonElement>): import("react").JSX.Element;
20
67
  //#endregion
21
- export { type ChipProps, Chip as default };
68
+ export { type ChipActionProps, type ChipFilterProps, type ChipProps, type ChipVariant, Chip as default };
22
69
  //# sourceMappingURL=index.d.ts.map