@kanso-labs/react-native-kanso-ui 0.0.0-stage → 0.1.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 (145) hide show
  1. package/LICENSE.md +20 -0
  2. package/README.md +205 -2
  3. package/dist/button/index.d.ts +56 -0
  4. package/dist/button/index.js +169 -0
  5. package/dist/button/index.js.map +1 -0
  6. package/dist/button/palettes.js +47 -0
  7. package/dist/button/palettes.js.map +1 -0
  8. package/dist/chip/index.js +194 -0
  9. package/dist/chip/index.js.map +1 -0
  10. package/dist/chip/styles.js +36 -0
  11. package/dist/chip/styles.js.map +1 -0
  12. package/dist/clipboard/index.js +58 -0
  13. package/dist/clipboard/index.js.map +1 -0
  14. package/dist/components/avatar/index.d.ts +82 -0
  15. package/dist/components/avatar/index.js +62 -0
  16. package/dist/components/avatar/index.js.map +1 -0
  17. package/dist/components/button/index.d.ts +87 -0
  18. package/dist/components/button/index.js +377 -0
  19. package/dist/components/button/index.js.map +1 -0
  20. package/dist/components/card/index.d.ts +78 -0
  21. package/dist/components/card/index.js +315 -0
  22. package/dist/components/card/index.js.map +1 -0
  23. package/dist/components/checkbox/index.d.ts +76 -0
  24. package/dist/components/checkbox/index.js +360 -0
  25. package/dist/components/checkbox/index.js.map +1 -0
  26. package/dist/components/chip/index.d.ts +84 -0
  27. package/dist/components/chip/index.js +257 -0
  28. package/dist/components/chip/index.js.map +1 -0
  29. package/dist/components/chip-group/index.d.ts +143 -0
  30. package/dist/components/chip-group/index.js +669 -0
  31. package/dist/components/chip-group/index.js.map +1 -0
  32. package/dist/components/copy-field/index.d.ts +60 -0
  33. package/dist/components/copy-field/index.js +277 -0
  34. package/dist/components/copy-field/index.js.map +1 -0
  35. package/dist/components/currency/index.d.ts +69 -0
  36. package/dist/components/currency/index.js +162 -0
  37. package/dist/components/currency/index.js.map +1 -0
  38. package/dist/components/form/index.d.ts +84 -0
  39. package/dist/components/form/index.js +95 -0
  40. package/dist/components/form/index.js.map +1 -0
  41. package/dist/components/icon-button/index.d.ts +68 -0
  42. package/dist/components/icon-button/index.js +289 -0
  43. package/dist/components/icon-button/index.js.map +1 -0
  44. package/dist/components/link/index.d.ts +59 -0
  45. package/dist/components/link/index.js +191 -0
  46. package/dist/components/link/index.js.map +1 -0
  47. package/dist/components/number-field/index.d.ts +151 -0
  48. package/dist/components/number-field/index.js +832 -0
  49. package/dist/components/number-field/index.js.map +1 -0
  50. package/dist/components/product-icon/index.d.ts +70 -0
  51. package/dist/components/product-icon/index.js +60 -0
  52. package/dist/components/product-icon/index.js.map +1 -0
  53. package/dist/components/radio-group/index.d.ts +105 -0
  54. package/dist/components/radio-group/index.js +597 -0
  55. package/dist/components/radio-group/index.js.map +1 -0
  56. package/dist/components/search-field/index.d.ts +98 -0
  57. package/dist/components/search-field/index.js +521 -0
  58. package/dist/components/search-field/index.js.map +1 -0
  59. package/dist/components/segmented-button/index.d.ts +113 -0
  60. package/dist/components/segmented-button/index.js +937 -0
  61. package/dist/components/segmented-button/index.js.map +1 -0
  62. package/dist/components/separator/index.d.ts +45 -0
  63. package/dist/components/separator/index.js +109 -0
  64. package/dist/components/separator/index.js.map +1 -0
  65. package/dist/components/stack/index.d.ts +70 -0
  66. package/dist/components/stack/index.js +107 -0
  67. package/dist/components/stack/index.js.map +1 -0
  68. package/dist/components/switch/index.d.ts +76 -0
  69. package/dist/components/switch/index.js +591 -0
  70. package/dist/components/switch/index.js.map +1 -0
  71. package/dist/components/text/index.d.ts +44 -0
  72. package/dist/components/text/index.js +78 -0
  73. package/dist/components/text/index.js.map +1 -0
  74. package/dist/components/text-field/index.d.ts +146 -0
  75. package/dist/components/text-field/index.js +228 -0
  76. package/dist/components/text-field/index.js.map +1 -0
  77. package/dist/control/index.js +117 -0
  78. package/dist/control/index.js.map +1 -0
  79. package/dist/control/styles.js +36 -0
  80. package/dist/control/styles.js.map +1 -0
  81. package/dist/field/index.d.ts +13 -0
  82. package/dist/field/index.js +1007 -0
  83. package/dist/field/index.js.map +1 -0
  84. package/dist/field/styles.js +131 -0
  85. package/dist/field/styles.js.map +1 -0
  86. package/dist/form/index.d.ts +24 -0
  87. package/dist/form/index.js +209 -0
  88. package/dist/form/index.js.map +1 -0
  89. package/dist/glyphs/icon-style.d.ts +25 -0
  90. package/dist/glyphs/icon-style.js +22 -0
  91. package/dist/glyphs/icon-style.js.map +1 -0
  92. package/dist/glyphs/index.js +170 -0
  93. package/dist/glyphs/index.js.map +1 -0
  94. package/dist/glyphs/styles.js +7 -0
  95. package/dist/glyphs/styles.js.map +1 -0
  96. package/dist/hooks/useWindowSizeClass.d.ts +25 -0
  97. package/dist/hooks/useWindowSizeClass.js +39 -0
  98. package/dist/hooks/useWindowSizeClass.js.map +1 -0
  99. package/dist/index.d.ts +31 -0
  100. package/dist/index.js +27 -0
  101. package/dist/mark/image.js +61 -0
  102. package/dist/mark/image.js.map +1 -0
  103. package/dist/mark/index.d.ts +9 -0
  104. package/dist/mark/index.js +234 -0
  105. package/dist/mark/index.js.map +1 -0
  106. package/dist/mark/initials.js +65 -0
  107. package/dist/mark/initials.js.map +1 -0
  108. package/dist/mark/styles.d.ts +1 -0
  109. package/dist/mark/styles.js +73 -0
  110. package/dist/mark/styles.js.map +1 -0
  111. package/dist/number/parser.js +321 -0
  112. package/dist/number/parser.js.map +1 -0
  113. package/dist/number/state.js +235 -0
  114. package/dist/number/state.js.map +1 -0
  115. package/dist/overlay/host.js +111 -0
  116. package/dist/overlay/host.js.map +1 -0
  117. package/dist/press/index.js +350 -0
  118. package/dist/press/index.js.map +1 -0
  119. package/dist/press/styles.js +31 -0
  120. package/dist/press/styles.js.map +1 -0
  121. package/dist/router/index.d.ts +28 -0
  122. package/dist/router/index.js +82 -0
  123. package/dist/router/index.js.map +1 -0
  124. package/dist/theme/color.js +25 -0
  125. package/dist/theme/color.js.map +1 -0
  126. package/dist/theme/resolve.d.ts +6 -0
  127. package/dist/theme/resolve.js +310 -0
  128. package/dist/theme/resolve.js.map +1 -0
  129. package/dist/theme/scope.d.ts +42 -0
  130. package/dist/theme/scope.js +80 -0
  131. package/dist/theme/scope.js.map +1 -0
  132. package/dist/theme/styles.js +39 -0
  133. package/dist/theme/styles.js.map +1 -0
  134. package/dist/theme-scope.d.ts +56 -0
  135. package/dist/theme-scope.js +127 -0
  136. package/dist/theme-scope.js.map +1 -0
  137. package/dist/tokens/defaults.d.ts +407 -0
  138. package/dist/tokens/defaults.js +403 -0
  139. package/dist/tokens/defaults.js.map +1 -0
  140. package/dist/typography/fonts.js +84 -0
  141. package/dist/typography/fonts.js.map +1 -0
  142. package/dist/typography/roles.d.ts +10 -0
  143. package/dist/typography/roles.js +82 -0
  144. package/dist/typography/roles.js.map +1 -0
  145. package/package.json +132 -4
@@ -0,0 +1,257 @@
1
+ import { useTheme } from "../../theme/scope.js";
2
+ import { composeStyles } from "../../theme/styles.js";
3
+ import { AnimatedPressable, toggleState, useButtonAction } from "../../button/index.js";
4
+ import { usePressFeedback } from "../../press/index.js";
5
+ import { shadowsOf, stylesOf } from "../../chip/styles.js";
6
+ import { ChipGlyph, ChipLabel, measureThen, paintOf, targetOf, useEasedColors } from "../../chip/index.js";
7
+ import { c } from "react/compiler-runtime";
8
+ import { useState } from "react";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ //#region src/components/chip/index.tsx
11
+ /**
12
+ * A chip. By default a filter chip, which is a two-state button reporting
13
+ * its state as a toggle Button does: pass `isSelected` with `onChange` to
14
+ * control it, or `defaultSelected` to let it keep its own state.
15
+ *
16
+ * ```tsx
17
+ * <Chip defaultSelected>Label</Chip>
18
+ * ```
19
+ *
20
+ * `variant="assist"` and `variant="suggestion"` draw the page's two action
21
+ * chips instead: plain buttons, pressed with `onPress`, never selected.
22
+ *
23
+ * A column stretches a chip across it, as it does any view; a row of chips is
24
+ * a row that wraps. `style`, `ref` and `testID` land on the `Pressable`.
25
+ */
26
+ function Chip(t0) {
27
+ const $ = c(80);
28
+ let children;
29
+ let defaultSelected;
30
+ let hitSlop;
31
+ let icon;
32
+ let isSelected;
33
+ let onBlur;
34
+ let onChange;
35
+ let onFocus;
36
+ let onHoverIn;
37
+ let onHoverOut;
38
+ let onLayout;
39
+ let onPress;
40
+ let onPressIn;
41
+ let onPressOut;
42
+ let props;
43
+ let style;
44
+ let t1;
45
+ let t2;
46
+ let t3;
47
+ if ($[0] !== t0) {
48
+ ({children, defaultSelected, elevated: t1, hitSlop, icon, isDisabled: t2, isSelected, onBlur, onChange, onFocus, onHoverIn, onHoverOut, onLayout, onPress, onPressIn, onPressOut, style, variant: t3, ...props} = t0);
49
+ $[0] = t0;
50
+ $[1] = children;
51
+ $[2] = defaultSelected;
52
+ $[3] = hitSlop;
53
+ $[4] = icon;
54
+ $[5] = isSelected;
55
+ $[6] = onBlur;
56
+ $[7] = onChange;
57
+ $[8] = onFocus;
58
+ $[9] = onHoverIn;
59
+ $[10] = onHoverOut;
60
+ $[11] = onLayout;
61
+ $[12] = onPress;
62
+ $[13] = onPressIn;
63
+ $[14] = onPressOut;
64
+ $[15] = props;
65
+ $[16] = style;
66
+ $[17] = t1;
67
+ $[18] = t2;
68
+ $[19] = t3;
69
+ } else {
70
+ children = $[1];
71
+ defaultSelected = $[2];
72
+ hitSlop = $[3];
73
+ icon = $[4];
74
+ isSelected = $[5];
75
+ onBlur = $[6];
76
+ onChange = $[7];
77
+ onFocus = $[8];
78
+ onHoverIn = $[9];
79
+ onHoverOut = $[10];
80
+ onLayout = $[11];
81
+ onPress = $[12];
82
+ onPressIn = $[13];
83
+ onPressOut = $[14];
84
+ props = $[15];
85
+ style = $[16];
86
+ t1 = $[17];
87
+ t2 = $[18];
88
+ t3 = $[19];
89
+ }
90
+ const elevated = t1 === void 0 ? false : t1;
91
+ const isDisabled = t2 === void 0 ? false : t2;
92
+ const variant = t3 === void 0 ? "filter" : t3;
93
+ const theme = useTheme();
94
+ const [width, setWidth] = useState(48);
95
+ const isToggle = variant === "filter";
96
+ let t4;
97
+ if ($[20] !== defaultSelected || $[21] !== isSelected || $[22] !== isToggle || $[23] !== onChange || $[24] !== onPress) {
98
+ t4 = {
99
+ defaultSelected,
100
+ href: void 0,
101
+ isSelected,
102
+ isToggle,
103
+ onChange,
104
+ onPress,
105
+ type: void 0
106
+ };
107
+ $[20] = defaultSelected;
108
+ $[21] = isSelected;
109
+ $[22] = isToggle;
110
+ $[23] = onChange;
111
+ $[24] = onPress;
112
+ $[25] = t4;
113
+ } else t4 = $[25];
114
+ const action = useButtonAction(t4);
115
+ const t5 = variant === "assist";
116
+ let t6;
117
+ if ($[26] !== action.selected || $[27] !== elevated || $[28] !== isDisabled || $[29] !== t5 || $[30] !== theme) {
118
+ t6 = paintOf(theme, {
119
+ assist: t5,
120
+ disabled: isDisabled,
121
+ elevated,
122
+ selected: action.selected
123
+ });
124
+ $[26] = action.selected;
125
+ $[27] = elevated;
126
+ $[28] = isDisabled;
127
+ $[29] = t5;
128
+ $[30] = theme;
129
+ $[31] = t6;
130
+ } else t6 = $[31];
131
+ const paint = t6;
132
+ const eased = useEasedColors(paint);
133
+ let t7;
134
+ if ($[32] !== theme.radii.sm) {
135
+ t7 = { borderRadius: theme.radii.sm };
136
+ $[32] = theme.radii.sm;
137
+ $[33] = t7;
138
+ } else t7 = $[33];
139
+ let t8;
140
+ if ($[34] !== isDisabled || $[35] !== onBlur || $[36] !== onFocus || $[37] !== onHoverIn || $[38] !== onHoverOut || $[39] !== onPressIn || $[40] !== onPressOut || $[41] !== paint.layer || $[42] !== t7) {
141
+ t8 = {
142
+ color: paint.layer,
143
+ corners: t7,
144
+ disabled: isDisabled,
145
+ onBlur,
146
+ onFocus,
147
+ onHoverIn,
148
+ onHoverOut,
149
+ onPressIn,
150
+ onPressOut
151
+ };
152
+ $[34] = isDisabled;
153
+ $[35] = onBlur;
154
+ $[36] = onFocus;
155
+ $[37] = onHoverIn;
156
+ $[38] = onHoverOut;
157
+ $[39] = onPressIn;
158
+ $[40] = onPressOut;
159
+ $[41] = paint.layer;
160
+ $[42] = t7;
161
+ $[43] = t8;
162
+ } else t8 = $[43];
163
+ const feedback = usePressFeedback(t8);
164
+ let t9;
165
+ if ($[44] !== action.selected || $[45] !== isToggle) {
166
+ t9 = isToggle ? toggleState(action.selected) : void 0;
167
+ $[44] = action.selected;
168
+ $[45] = isToggle;
169
+ $[46] = t9;
170
+ } else t9 = $[46];
171
+ const t10 = feedback.handlers;
172
+ let t11;
173
+ if ($[47] !== hitSlop || $[48] !== theme || $[49] !== width) {
174
+ t11 = hitSlop ?? targetOf(width, theme);
175
+ $[47] = hitSlop;
176
+ $[48] = theme;
177
+ $[49] = width;
178
+ $[50] = t11;
179
+ } else t11 = $[50];
180
+ let t12;
181
+ if ($[51] !== onLayout) {
182
+ t12 = measureThen(setWidth, onLayout);
183
+ $[51] = onLayout;
184
+ $[52] = t12;
185
+ } else t12 = $[52];
186
+ const t13 = action.onPress;
187
+ let t14;
188
+ if ($[53] !== eased.container || $[54] !== elevated || $[55] !== feedback.hovered || $[56] !== feedback.ring || $[57] !== isDisabled || $[58] !== style || $[59] !== theme) {
189
+ t14 = composeStyles(stylesOf(theme).pill, eased.container, elevated && !isDisabled ? shadowsOf(theme)[feedback.hovered ? "elevation2" : "elevation1"] : void 0, feedback.ring, style);
190
+ $[53] = eased.container;
191
+ $[54] = elevated;
192
+ $[55] = feedback.hovered;
193
+ $[56] = feedback.ring;
194
+ $[57] = isDisabled;
195
+ $[58] = style;
196
+ $[59] = theme;
197
+ $[60] = t14;
198
+ } else t14 = $[60];
199
+ let t15;
200
+ if ($[61] !== action.selected || $[62] !== icon || $[63] !== paint.glyph) {
201
+ t15 = /* @__PURE__ */ jsx(ChipGlyph, {
202
+ color: paint.glyph,
203
+ icon,
204
+ selected: action.selected
205
+ });
206
+ $[61] = action.selected;
207
+ $[62] = icon;
208
+ $[63] = paint.glyph;
209
+ $[64] = t15;
210
+ } else t15 = $[64];
211
+ let t16;
212
+ if ($[65] !== children || $[66] !== eased.label) {
213
+ t16 = /* @__PURE__ */ jsx(ChipLabel, {
214
+ color: eased.label,
215
+ children
216
+ });
217
+ $[65] = children;
218
+ $[66] = eased.label;
219
+ $[67] = t16;
220
+ } else t16 = $[67];
221
+ let t17;
222
+ if ($[68] !== action.onPress || $[69] !== feedback.handlers || $[70] !== feedback.layer || $[71] !== isDisabled || $[72] !== props || $[73] !== t11 || $[74] !== t12 || $[75] !== t14 || $[76] !== t15 || $[77] !== t16 || $[78] !== t9) {
223
+ t17 = /* @__PURE__ */ jsxs(AnimatedPressable, {
224
+ role: "button",
225
+ ...t9,
226
+ ...props,
227
+ ...t10,
228
+ disabled: isDisabled,
229
+ hitSlop: t11,
230
+ onLayout: t12,
231
+ onPress: t13,
232
+ style: t14,
233
+ children: [
234
+ feedback.layer,
235
+ t15,
236
+ t16
237
+ ]
238
+ });
239
+ $[68] = action.onPress;
240
+ $[69] = feedback.handlers;
241
+ $[70] = feedback.layer;
242
+ $[71] = isDisabled;
243
+ $[72] = props;
244
+ $[73] = t11;
245
+ $[74] = t12;
246
+ $[75] = t14;
247
+ $[76] = t15;
248
+ $[77] = t16;
249
+ $[78] = t9;
250
+ $[79] = t17;
251
+ } else t17 = $[79];
252
+ return t17;
253
+ }
254
+ //#endregion
255
+ export { Chip };
256
+
257
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ReactNode","Ref","PressableProps","StyleProp","View","ViewStyle","AnimatedStyle","useState","AnimatedPressable","toggleState","useButtonAction","ChipGlyph","ChipLabel","measureThen","paintOf","targetOf","useEasedColors","shadowsOf","stylesOf","TARGET_SIZE","usePressFeedback","useTheme","composeStyles","ChipActionProps","ChipBaseProps","defaultSelected","isSelected","onChange","variant","Omit","children","elevated","icon","isDisabled","ref","style","ChipFilterProps","ChipProps","ChipVariant","Chip","t0","$","_c","hitSlop","onBlur","onFocus","onHoverIn","onHoverOut","onLayout","onPress","onPressIn","onPressOut","props","t1","t2","t3","undefined","theme","width","setWidth","isToggle","t4","href","type","action","t5","t6","selected","assist","disabled","paint","eased","t7","radii","sm","borderRadius","t8","layer","color","corners","feedback","t9","t10","handlers","t11","t12","t13","t14","container","hovered","ring","pill","t15","glyph","t16","label","t17","_c"],"sources":["../../../src/components/chip/index.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react'\nimport type { PressableProps, StyleProp, View, ViewStyle } from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\n\nimport { useState } from 'react'\n\nimport { AnimatedPressable, toggleState, useButtonAction } from '../../button'\nimport {\n ChipGlyph,\n ChipLabel,\n measureThen,\n paintOf,\n targetOf,\n useEasedColors,\n} from '../../chip'\nimport { shadowsOf, stylesOf } from '../../chip/styles'\nimport { TARGET_SIZE, usePressFeedback } from '../../press'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles } from '../../theme/styles'\n\n// Three of the chips page's four chips, as kanso-ui's Chip draws them. The\n// pill is src/chip's, shared with ChipGroup's chip as on web, which sets out\n// its measurements, colours, motion and target. `variant` picks the chip:\n//\n// - **A filter chip**, the default, is a toggle that reports its state as a\n// toggle Button does, and takes the secondary container pair and the check\n// once selected.\n// - **An assist or suggestion chip** is an action, so nothing is reported as\n// selected and nothing ever is. The two differ in the label alone: on\n// surface on an assist chip, on surface variant on a suggestion chip as on\n// a filter one.\n\n/** An assist or suggestion chip: an action, drawn as a plain button. */\ntype ChipActionProps = ChipBaseProps & {\n readonly defaultSelected?: never\n readonly isSelected?: never\n readonly onChange?: never\n /**\n * `assist` for an action the chip's context suggests, and `suggestion`\n * for one the product generates. Either is an action rather than a\n * selection, so neither is ever selected.\n */\n readonly variant: 'assist' | 'suggestion'\n}\n\ntype ChipBaseProps = Omit<PressableProps, 'children' | 'disabled' | 'style'> & {\n /**\n * The chip's label. Required: the page draws no chip without one, and a\n * chip with none is an empty button to a screen reader.\n */\n readonly children: ReactNode\n /**\n * Raises the chip off the page on a container of its own, at the page's\n * elevation 1, in place of the outline. A selected filter chip keeps the\n * secondary container.\n * @default false\n */\n readonly elevated?: boolean\n /**\n * An icon before the label, in the page's 18dp slot and the primary role,\n * which the slot hands it through `useIconStyle()`. A filter chip's check\n * takes its place while the chip is selected, so the chip keeps its width.\n */\n readonly icon?: ReactNode\n /**\n * Draws the chip disabled, and takes no presses.\n * @default false\n */\n readonly isDisabled?: boolean\n readonly ref?: Ref<View>\n readonly style?: StyleProp<ViewStyle>\n}\n\n/** A filter chip: a two-state button, the default. */\ntype ChipFilterProps = ChipBaseProps & {\n /**\n * Whether the chip starts selected, when it keeps its own state.\n * @default false\n */\n readonly defaultSelected?: boolean\n /**\n * Whether the chip is selected, when the call site holds the state. Pass\n * it with `onChange`.\n */\n readonly isSelected?: boolean\n /** Called with the new state when the chip is pressed, after `onPress`. */\n readonly onChange?: (isSelected: boolean) => void\n /**\n * A filter chip, a two-state button.\n * @default 'filter'\n */\n readonly variant?: 'filter'\n}\n\ntype ChipProps = ChipActionProps | ChipFilterProps\n\n/** Which of the chips page's chips a Chip is. */\ntype ChipVariant = 'assist' | 'filter' | 'suggestion'\n\n/**\n * A chip. By default a filter chip, which is a two-state button reporting\n * its state as a toggle Button does: pass `isSelected` with `onChange` to\n * control it, or `defaultSelected` to let it keep its own state.\n *\n * ```tsx\n * <Chip defaultSelected>Label</Chip>\n * ```\n *\n * `variant=\"assist\"` and `variant=\"suggestion\"` draw the page's two action\n * chips instead: plain buttons, pressed with `onPress`, never selected.\n *\n * A column stretches a chip across it, as it does any view; a row of chips is\n * a row that wraps. `style`, `ref` and `testID` land on the `Pressable`.\n */\nfunction Chip({\n children,\n defaultSelected,\n elevated = false,\n hitSlop,\n icon,\n isDisabled = false,\n isSelected,\n onBlur,\n onChange,\n onFocus,\n onHoverIn,\n onHoverOut,\n onLayout,\n onPress,\n onPressIn,\n onPressOut,\n style,\n variant = 'filter',\n ...props\n}: ChipProps) {\n const theme = useTheme()\n // Until the chip is measured it takes no reach across, rather than one\n // sized for a chip of no width.\n const [width, setWidth] = useState(TARGET_SIZE)\n\n const isToggle = variant === 'filter'\n const action = useButtonAction({\n defaultSelected,\n href: undefined,\n isSelected,\n isToggle,\n onChange,\n onPress,\n type: undefined,\n })\n const paint = paintOf(theme, {\n assist: variant === 'assist',\n disabled: isDisabled,\n elevated,\n selected: action.selected,\n })\n const eased = useEasedColors(paint)\n\n const feedback = usePressFeedback({\n color: paint.layer,\n corners: { borderRadius: theme.radii.sm },\n disabled: isDisabled,\n onBlur,\n onFocus,\n onHoverIn,\n onHoverOut,\n onPressIn,\n onPressOut,\n })\n\n return (\n <AnimatedPressable\n role=\"button\"\n {...(isToggle ? toggleState(action.selected) : undefined)}\n {...props}\n {...feedback.handlers}\n disabled={isDisabled}\n hitSlop={hitSlop ?? targetOf(width, theme)}\n onLayout={measureThen(setWidth, onLayout)}\n onPress={action.onPress}\n style={composeStyles<AnimatedStyle<ViewStyle>>(\n stylesOf(theme).pill,\n eased.container,\n elevated && !isDisabled\n ? shadowsOf(theme)[feedback.hovered ? 'elevation2' : 'elevation1']\n : undefined,\n feedback.ring,\n style,\n )}\n >\n {feedback.layer}\n <ChipGlyph color={paint.glyph} icon={icon} selected={action.selected} />\n <ChipLabel color={eased.label}>{children}</ChipLabel>\n </AnimatedPressable>\n )\n}\n\nexport { Chip }\nexport type { ChipActionProps, ChipFilterProps, ChipProps, ChipVariant }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,SAAAuC,KAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAZ;CAAA,IAAAL;CAAA,IAAAkB;CAAA,IAAAX;CAAA,IAAAN;CAAA,IAAAkB;CAAA,IAAAjB;CAAA,IAAAkB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAjB;CAAA,IAAAkB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAd,EAAA,OAAAD,IAAA;EAAc,CAAA,CAAAV,UAAAL,iBAAAM,UAAAsB,IAAAV,S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D;CAAA,IAAAvD,EAAA,QAAAuB,OAAAf,WAAAR,EAAA,QAAAuC,SAAAG,YAAA1C,EAAA,QAAAuC,SAAAH,SAAApC,EAAA,QAAAR,cAAAQ,EAAA,QAAAW,SAAAX,EAAA,QAAA2C,OAAA3C,EAAA,QAAA4C,OAAA5C,EAAA,QAAA8C,OAAA9C,EAAA,QAAAmD,OAAAnD,EAAA,QAAAqD,OAAArD,EAAA,QAAAwC,IAAA;EArBvDe,MAAA,qBAAC,mBAAD;GACO,MAAA;GAAQ,GACRf;GAAmD,GACpD7B;GAAK,GACL8B;GACMjD,UAAAA;GACD,SAAAmD;GACC,UAAAC;GACD,SAAAC;GACF,OAAAC;GATT,UAAA;IAmBGP,SAAQH;IACTe;IACAE;GArBgB;;EAsBErD,EAAA,MAAAuB,OAAAf;EAAAR,EAAA,MAAAuC,SAAAG;EAAA1C,EAAA,MAAAuC,SAAAH;EAAApC,EAAA,MAAAR;EAAAQ,EAAA,MAAAW;EAAAX,EAAA,MAAA2C;EAAA3C,EAAA,MAAA4C;EAAA5C,EAAA,MAAA8C;EAAA9C,EAAA,MAAAmD;EAAAnD,EAAA,MAAAqD;EAAArD,EAAA,MAAAwC;EAAAxC,EAAA,MAAAuD;CAAA,OAAAA,MAAAvD,EAAA;CAAA,OAtBpBuD;AAsBoB"}
@@ -0,0 +1,143 @@
1
+ import { PressableProps, StyleProp, View, ViewProps, ViewStyle } from "react-native";
2
+ import { ReactElement, ReactNode, Ref } from "react";
3
+ import { Key, Selection, SelectionMode } from "react-stately";
4
+ //#region src/components/chip-group/index.d.ts
5
+ type ChipGroupChipProps = Omit<PressableProps, 'children' | 'disabled' | 'id' | 'style'> & {
6
+ /** The chip's label. */
7
+ readonly children: ReactNode;
8
+ /**
9
+ * An icon before the label, in the page's 18dp slot and the primary role,
10
+ * which the slot hands it through `useIconStyle()`. The check takes its
11
+ * place while the chip is chosen, so the chip keeps its width.
12
+ */
13
+ readonly icon?: ReactNode;
14
+ /**
15
+ * The key selection and removal report the chip by. Without one, a chip
16
+ * drawn from `items` takes its item's `id` or `key`.
17
+ */
18
+ readonly id?: Key;
19
+ /**
20
+ * Draws the chip disabled, and takes no presses on it or on its close
21
+ * target, as a key in the group's `disabledKeys` does.
22
+ * @default false
23
+ */
24
+ readonly isDisabled?: boolean;
25
+ readonly ref?: Ref<View>;
26
+ readonly style?: StyleProp<ViewStyle>;
27
+ /**
28
+ * The chip's text, which names its close target. Read off `children` when
29
+ * they are a plain string, so a chip whose label is an element passes it.
30
+ */
31
+ readonly textValue?: string;
32
+ };
33
+ type ChipGroupProps<T extends object = object> = Omit<ViewProps, 'children' | 'style'> & {
34
+ /**
35
+ * The chips, each a `ChipGroup.Chip` with an `id` of its own. With
36
+ * `items`, a function from an item to its chip, called for each item in
37
+ * turn.
38
+ */
39
+ readonly children?: ((item: T) => ReactElement) | ReactNode;
40
+ /** The keys selected at first, when the group keeps its own selection. */
41
+ readonly defaultSelectedKeys?: 'all' | Iterable<Key>;
42
+ /**
43
+ * A hint under the group. Replaced by `error` when there is one, so the
44
+ * two never stack.
45
+ */
46
+ readonly description?: string;
47
+ /** The keys of the chips drawn disabled, which take no presses. */
48
+ readonly disabledKeys?: Iterable<Key>;
49
+ /**
50
+ * Keeps the last selected chip selected, so a press on it changes
51
+ * nothing.
52
+ * @default false
53
+ */
54
+ readonly disallowEmptySelection?: boolean;
55
+ /**
56
+ * The problem with the current selection, in words. Its presence is what
57
+ * puts the group in its error state: the message and the label's colour
58
+ * both follow from it.
59
+ */
60
+ readonly error?: string;
61
+ /** The entries `children` draws a chip for, when it is a function. */
62
+ readonly items?: Iterable<T>;
63
+ /**
64
+ * What the group is for. Required rather than optional: a set of chips
65
+ * with no name is a row a screen reader cannot introduce.
66
+ */
67
+ readonly label: string;
68
+ /**
69
+ * Called with the key of the chip whose close target was pressed. Given
70
+ * this, every chip draws one; the call site removes the chip from what it
71
+ * renders.
72
+ */
73
+ readonly onRemove?: (keys: Set<Key>) => void;
74
+ /** Called with the selected keys whenever a press changes them. */
75
+ readonly onSelectionChange?: (keys: Selection) => void;
76
+ readonly ref?: Ref<View>;
77
+ /**
78
+ * What the close target on each chip is called, for a screen reader. The
79
+ * chip's own text follows it, so this is the verb rather than the whole
80
+ * phrase: "Remove" becomes "Remove First item".
81
+ * @default 'Remove'
82
+ */
83
+ readonly removeLabel?: string;
84
+ /** What the row draws once it holds no chips. */
85
+ readonly renderEmptyState?: () => ReactNode;
86
+ /**
87
+ * The selected keys, for a call site holding the selection itself with
88
+ * `onSelectionChange`.
89
+ */
90
+ readonly selectedKeys?: 'all' | Iterable<Key>;
91
+ /**
92
+ * Whether a press selects a chip: one at a time, several, or none, in
93
+ * which case the chips are not buttons.
94
+ * @default 'none'
95
+ */
96
+ readonly selectionMode?: SelectionMode;
97
+ readonly style?: StyleProp<ViewStyle>;
98
+ };
99
+ /**
100
+ * A labelled set of chips, one or more of which can be chosen, each of which
101
+ * can be removed. Selection is React Stately's: set `selectionMode` to
102
+ * `single` or `multiple`, and pass `selectedKeys` with `onSelectionChange` to
103
+ * control it, or `defaultSelectedKeys` to let the group keep its own.
104
+ *
105
+ * ```tsx
106
+ * <ChipGroup label="Label" onRemove={remove} selectionMode="multiple">
107
+ * <ChipGroup.Chip id="first">First item</ChipGroup.Chip>
108
+ * </ChipGroup>
109
+ * ```
110
+ *
111
+ * Give the group `onRemove` and each chip draws a close target. A chip that
112
+ * toggles nothing else is Chip; this is for a set that shares a value.
113
+ *
114
+ * A screen reader hears a group named by its label, and each chip as a button
115
+ * named by its label, selected or not. On the web the line under the group
116
+ * describes it, as web's does; on iOS and Android it is read after the chips,
117
+ * where it sits. `style`, `ref` and `testID` land on the group as a whole,
118
+ * which is the element a layout positions.
119
+ */
120
+ declare function ChipGroup<T extends object = object>({ children, defaultSelectedKeys, description, disabledKeys, disallowEmptySelection, error, items, label, onRemove, onSelectionChange, removeLabel, renderEmptyState, selectedKeys, selectionMode, style, ...props }: ChipGroupProps<T>): import("react").JSX.Element;
121
+ declare namespace ChipGroup {
122
+ var Chip: typeof ChipGroupChip;
123
+ }
124
+ /**
125
+ * One chip of a `ChipGroup`, which draws it: the group builds its set from
126
+ * these, so one renders nothing on its own. Give every chip an `id`, which is
127
+ * the key selection and removal report it by.
128
+ */
129
+ declare function ChipGroupChip(_props: ChipGroupChipProps): null;
130
+ declare namespace ChipGroupChip {
131
+ var getCollectionNode: (props: ChipGroupChipProps) => Generator<{
132
+ 'aria-label': string | undefined;
133
+ hasChildNodes: boolean;
134
+ key: Key | undefined;
135
+ props: ChipGroupChipProps;
136
+ rendered: ReactNode;
137
+ textValue: string;
138
+ type: string;
139
+ }, void, unknown>;
140
+ }
141
+ //#endregion
142
+ export { ChipGroup, ChipGroupChip, type ChipGroupChipProps, type ChipGroupProps };
143
+ //# sourceMappingURL=index.d.ts.map