@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,360 @@
1
+ import { CheckGlyph, IndeterminateGlyph } from "../../glyphs/index.js";
2
+ import { useTheme } from "../../theme/scope.js";
3
+ import { composeStyles } from "../../theme/styles.js";
4
+ import { withOpacity } from "../../theme/color.js";
5
+ import { hitSlop, usePressFeedback } from "../../press/index.js";
6
+ import { controlStylesOf } from "../../control/styles.js";
7
+ import { ControlLabel, ControlMessage, describedBy, messageOf } from "../../control/index.js";
8
+ import { c } from "react/compiler-runtime";
9
+ import { Pressable, StyleSheet, View } from "react-native";
10
+ import { useId } from "react";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
12
+ import Animated, { Easing, useAnimatedStyle, useReducedMotion, withTiming } from "react-native-reanimated";
13
+ import { useToggleState } from "react-stately/useToggleState";
14
+ //#region src/components/checkbox/index.tsx
15
+ const BOX_SIZE = 18;
16
+ const BOX_CORNER = 2;
17
+ const BOX_RULE = 2;
18
+ const LAYERS = {
19
+ error: {
20
+ hover: "error",
21
+ pressed: "error"
22
+ },
23
+ marked: {
24
+ hover: "primary",
25
+ pressed: "onSurface"
26
+ },
27
+ unmarked: {
28
+ hover: "onSurface",
29
+ pressed: "primary"
30
+ }
31
+ };
32
+ const styles = StyleSheet.create({
33
+ box: {
34
+ borderRadius: BOX_CORNER,
35
+ borderWidth: BOX_RULE,
36
+ height: BOX_SIZE,
37
+ width: BOX_SIZE
38
+ },
39
+ glyph: {
40
+ left: 11,
41
+ position: "absolute",
42
+ top: 11
43
+ }
44
+ });
45
+ /**
46
+ * A checkbox with its label, and optionally a description or an error under
47
+ * it. Its state is React Stately's, as web's is: pass `isSelected` with
48
+ * `onChange` to control it, or `defaultSelected` to let it keep its own.
49
+ * `isIndeterminate` draws the dash for a box that stands for a partly
50
+ * selected set.
51
+ *
52
+ * ```tsx
53
+ * <Checkbox defaultSelected description="Supporting line">
54
+ * Label
55
+ * </Checkbox>
56
+ * ```
57
+ *
58
+ * A screen reader hears it as a checkbox named by its label, checked,
59
+ * unchecked or mixed, followed by the line under it. A press anywhere on the
60
+ * box or the label toggles it, and the row takes presses over the 48dp target
61
+ * the page asks of the box. `style`, `ref` and `testID` land on the view
62
+ * holding the row and the line under it, which is the element a layout
63
+ * positions.
64
+ */
65
+ function Checkbox(t0) {
66
+ const $ = c(77);
67
+ let ariaLabel;
68
+ let children;
69
+ let defaultSelected;
70
+ let description;
71
+ let error;
72
+ let isSelected;
73
+ let onChange;
74
+ let props;
75
+ let style;
76
+ let t1;
77
+ let t2;
78
+ let t3;
79
+ if ($[0] !== t0) {
80
+ ({"aria-label": ariaLabel, children, defaultSelected, description, error, isDisabled: t1, isIndeterminate: t2, isReadOnly: t3, isSelected, onChange, style, ...props} = t0);
81
+ $[0] = t0;
82
+ $[1] = ariaLabel;
83
+ $[2] = children;
84
+ $[3] = defaultSelected;
85
+ $[4] = description;
86
+ $[5] = error;
87
+ $[6] = isSelected;
88
+ $[7] = onChange;
89
+ $[8] = props;
90
+ $[9] = style;
91
+ $[10] = t1;
92
+ $[11] = t2;
93
+ $[12] = t3;
94
+ } else {
95
+ ariaLabel = $[1];
96
+ children = $[2];
97
+ defaultSelected = $[3];
98
+ description = $[4];
99
+ error = $[5];
100
+ isSelected = $[6];
101
+ onChange = $[7];
102
+ props = $[8];
103
+ style = $[9];
104
+ t1 = $[10];
105
+ t2 = $[11];
106
+ t3 = $[12];
107
+ }
108
+ const isDisabled = t1 === void 0 ? false : t1;
109
+ const isIndeterminate = t2 === void 0 ? false : t2;
110
+ const isReadOnly = t3 === void 0 ? false : t3;
111
+ const theme = useTheme();
112
+ let t4;
113
+ if ($[13] !== defaultSelected || $[14] !== isReadOnly || $[15] !== isSelected || $[16] !== onChange) {
114
+ t4 = {
115
+ defaultSelected,
116
+ isReadOnly,
117
+ isSelected,
118
+ onChange
119
+ };
120
+ $[13] = defaultSelected;
121
+ $[14] = isReadOnly;
122
+ $[15] = isSelected;
123
+ $[16] = onChange;
124
+ $[17] = t4;
125
+ } else t4 = $[17];
126
+ const state = useToggleState(t4);
127
+ const messageId = useId();
128
+ const { colors, radii } = theme;
129
+ const marked = state.isSelected || isIndeterminate;
130
+ const interactive = !isDisabled && !isReadOnly;
131
+ const tone = error === void 0 ? marked ? "marked" : "unmarked" : "error";
132
+ const t5 = colors[LAYERS[tone].hover];
133
+ let t6;
134
+ if ($[18] !== radii.circle) {
135
+ t6 = { borderRadius: radii.circle };
136
+ $[18] = radii.circle;
137
+ $[19] = t6;
138
+ } else t6 = $[19];
139
+ const t7 = !interactive;
140
+ const t8 = colors[LAYERS[tone].pressed];
141
+ let t9;
142
+ if ($[20] !== t5 || $[21] !== t6 || $[22] !== t7 || $[23] !== t8) {
143
+ t9 = {
144
+ color: t5,
145
+ corners: t6,
146
+ disabled: t7,
147
+ disc: 40,
148
+ pressedColor: t8
149
+ };
150
+ $[20] = t5;
151
+ $[21] = t6;
152
+ $[22] = t7;
153
+ $[23] = t8;
154
+ $[24] = t9;
155
+ } else t9 = $[24];
156
+ const feedback = usePressFeedback(t9);
157
+ const active = feedback.hovered || feedback.pressed || feedback.ring !== void 0;
158
+ let t10;
159
+ if ($[25] !== active || $[26] !== isDisabled || $[27] !== marked || $[28] !== theme || $[29] !== tone) {
160
+ t10 = paintOf(theme, {
161
+ active,
162
+ isDisabled,
163
+ marked,
164
+ tone
165
+ });
166
+ $[25] = active;
167
+ $[26] = isDisabled;
168
+ $[27] = marked;
169
+ $[28] = theme;
170
+ $[29] = tone;
171
+ $[30] = t10;
172
+ } else t10 = $[30];
173
+ const paint = t10;
174
+ const box = useBoxColors(paint);
175
+ const Glyph = isIndeterminate ? IndeterminateGlyph : state.isSelected ? CheckGlyph : null;
176
+ const t11 = isIndeterminate ? "mixed" : state.isSelected;
177
+ let t12;
178
+ if ($[31] !== description || $[32] !== error || $[33] !== messageId) {
179
+ t12 = describedBy(messageId, messageOf(description, error));
180
+ $[31] = description;
181
+ $[32] = error;
182
+ $[33] = messageId;
183
+ $[34] = t12;
184
+ } else t12 = $[34];
185
+ const t13 = feedback.handlers;
186
+ let t14;
187
+ if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
188
+ t14 = hitSlop(40, 40);
189
+ $[35] = t14;
190
+ } else t14 = $[35];
191
+ let t15;
192
+ if ($[36] !== state) {
193
+ t15 = toggleOf(state);
194
+ $[36] = state;
195
+ $[37] = t15;
196
+ } else t15 = $[37];
197
+ let t16;
198
+ if ($[38] !== theme) {
199
+ t16 = controlStylesOf(theme);
200
+ $[38] = theme;
201
+ $[39] = t16;
202
+ } else t16 = $[39];
203
+ const t17 = t16.row;
204
+ let t18;
205
+ if ($[40] !== feedback.ring || $[41] !== theme) {
206
+ t18 = composeStyles(controlStylesOf(theme).disc, feedback.ring);
207
+ $[40] = feedback.ring;
208
+ $[41] = theme;
209
+ $[42] = t18;
210
+ } else t18 = $[42];
211
+ const t19 = feedback.layer;
212
+ let t20;
213
+ if ($[43] !== box) {
214
+ t20 = composeStyles(styles.box, box);
215
+ $[43] = box;
216
+ $[44] = t20;
217
+ } else t20 = $[44];
218
+ let t21;
219
+ if ($[45] !== t20) {
220
+ t21 = /* @__PURE__ */ jsx(Animated.View, { style: t20 });
221
+ $[45] = t20;
222
+ $[46] = t21;
223
+ } else t21 = $[46];
224
+ let t22;
225
+ if ($[47] !== Glyph || $[48] !== paint) {
226
+ t22 = Glyph === null ? null : /* @__PURE__ */ jsx(Glyph, {
227
+ color: paint.glyph,
228
+ size: BOX_SIZE,
229
+ style: styles.glyph
230
+ });
231
+ $[47] = Glyph;
232
+ $[48] = paint;
233
+ $[49] = t22;
234
+ } else t22 = $[49];
235
+ let t23;
236
+ if ($[50] !== feedback.layer || $[51] !== t18 || $[52] !== t21 || $[53] !== t22) {
237
+ t23 = /* @__PURE__ */ jsxs(View, {
238
+ style: t18,
239
+ children: [
240
+ t19,
241
+ t21,
242
+ t22
243
+ ]
244
+ });
245
+ $[50] = feedback.layer;
246
+ $[51] = t18;
247
+ $[52] = t21;
248
+ $[53] = t22;
249
+ $[54] = t23;
250
+ } else t23 = $[54];
251
+ let t24;
252
+ if ($[55] !== children || $[56] !== isDisabled) {
253
+ t24 = /* @__PURE__ */ jsx(ControlLabel, {
254
+ isDisabled,
255
+ children
256
+ });
257
+ $[55] = children;
258
+ $[56] = isDisabled;
259
+ $[57] = t24;
260
+ } else t24 = $[57];
261
+ let t25;
262
+ if ($[58] !== ariaLabel || $[59] !== feedback.handlers || $[60] !== isDisabled || $[61] !== t11 || $[62] !== t12 || $[63] !== t15 || $[64] !== t16.row || $[65] !== t23 || $[66] !== t24) {
263
+ t25 = /* @__PURE__ */ jsxs(Pressable, {
264
+ "aria-checked": t11,
265
+ "aria-label": ariaLabel,
266
+ role: "checkbox",
267
+ ...t12,
268
+ ...t13,
269
+ disabled: isDisabled,
270
+ hitSlop: t14,
271
+ onPress: t15,
272
+ style: t17,
273
+ children: [t23, t24]
274
+ });
275
+ $[58] = ariaLabel;
276
+ $[59] = feedback.handlers;
277
+ $[60] = isDisabled;
278
+ $[61] = t11;
279
+ $[62] = t12;
280
+ $[63] = t15;
281
+ $[64] = t16.row;
282
+ $[65] = t23;
283
+ $[66] = t24;
284
+ $[67] = t25;
285
+ } else t25 = $[67];
286
+ let t26;
287
+ if ($[68] !== description || $[69] !== error || $[70] !== messageId) {
288
+ t26 = /* @__PURE__ */ jsx(ControlMessage, {
289
+ description,
290
+ error,
291
+ id: messageId
292
+ });
293
+ $[68] = description;
294
+ $[69] = error;
295
+ $[70] = messageId;
296
+ $[71] = t26;
297
+ } else t26 = $[71];
298
+ let t27;
299
+ if ($[72] !== props || $[73] !== style || $[74] !== t25 || $[75] !== t26) {
300
+ t27 = /* @__PURE__ */ jsxs(View, {
301
+ ...props,
302
+ style,
303
+ children: [t25, t26]
304
+ });
305
+ $[72] = props;
306
+ $[73] = style;
307
+ $[74] = t25;
308
+ $[75] = t26;
309
+ $[76] = t27;
310
+ } else t27 = $[76];
311
+ return t27;
312
+ }
313
+ /**
314
+ * What the box is painted in: its fill, its rule and the glyph's colour.
315
+ * Where the page draws no fill or no rule it is the colour beside it made
316
+ * clear rather than plain transparent black, so the box eases through its
317
+ * own colour rather than through grey.
318
+ */
319
+ function paintOf({ colors, stateLayerOpacity }, { active, isDisabled, marked, tone }) {
320
+ const disabled = withOpacity(colors.onSurface, stateLayerOpacity.disabledContent);
321
+ if (marked) {
322
+ const fill = isDisabled ? disabled : tone === "error" ? colors.error : colors.primary;
323
+ return {
324
+ fill,
325
+ glyph: isDisabled ? colors.surface : tone === "error" ? colors.onError : colors.onPrimary,
326
+ rule: withOpacity(fill, 0)
327
+ };
328
+ }
329
+ const rule = isDisabled ? disabled : tone === "error" ? colors.error : active ? colors.onSurface : colors.onSurfaceVariant;
330
+ return {
331
+ fill: withOpacity(rule, 0),
332
+ glyph: colors.onPrimary,
333
+ rule
334
+ };
335
+ }
336
+ function toggleOf(state) {
337
+ return () => {
338
+ state.toggle();
339
+ };
340
+ }
341
+ function useBoxColors(t0) {
342
+ const { fill, rule } = t0;
343
+ const { motion } = useTheme();
344
+ const reduceMotion = useReducedMotion();
345
+ const timing = {
346
+ duration: motion.durationShort2,
347
+ easing: Easing.bezier(...motion.easingStandard)
348
+ };
349
+ return useAnimatedStyle(() => {
350
+ "worklet";
351
+ return {
352
+ backgroundColor: reduceMotion ? fill : withTiming(fill, timing),
353
+ borderColor: reduceMotion ? rule : withTiming(rule, timing)
354
+ };
355
+ });
356
+ }
357
+ //#endregion
358
+ export { Checkbox };
359
+
360
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ReactNode","Ref","StyleProp","ViewProps","ViewStyle","AnimatedStyle","ToggleState","useId","Pressable","StyleSheet","View","Animated","Easing","useAnimatedStyle","useReducedMotion","withTiming","useToggleState","ResolvedTheme","ControlLabel","ControlMessage","describedBy","LAYER_SIZE","messageOf","controlStylesOf","CheckGlyph","IndeterminateGlyph","hitSlop","usePressFeedback","withOpacity","useTheme","composeStyles","CheckboxProps","Omit","children","defaultSelected","description","error","isDisabled","isIndeterminate","isReadOnly","isSelected","onChange","ref","style","Tone","BOX_SIZE","BOX_CORNER","BOX_RULE","LAYERS","Readonly","Record","hover","pressed","marked","unmarked","styles","create","box","borderRadius","borderWidth","height","width","glyph","left","position","top","Checkbox","t0","$","_c","ariaLabel","props","t1","t2","t3","undefined","theme","t4","state","messageId","colors","radii","interactive","tone","t5","t6","circle","t7","t8","t9","color","corners","disabled","disc","pressedColor","feedback","active","hovered","ring","t10","paintOf","paint","useBoxColors","Glyph","t11","t12","t13","handlers","t14","Symbol","for","t15","toggleOf","t16","t17","row","t18","t19","layer","t20","t21","t22","t23","t24","t25","t26","t27","stateLayerOpacity","onSurface","disabledContent","fill","primary","surface","onError","onPrimary","rule","onSurfaceVariant","toggle","motion","reduceMotion","timing","duration","durationShort2","easing","bezier","easingStandard","backgroundColor","borderColor","_c"],"sources":["../../../src/components/checkbox/index.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react'\nimport type { StyleProp, ViewProps, ViewStyle } from 'react-native'\nimport type { AnimatedStyle } from 'react-native-reanimated'\nimport type { ToggleState } from 'react-stately/useToggleState'\n\nimport { useId } from 'react'\nimport { Pressable, StyleSheet, View } from 'react-native'\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useReducedMotion,\n withTiming,\n} from 'react-native-reanimated'\nimport { useToggleState } from 'react-stately/useToggleState'\n\nimport type { ResolvedTheme } from '../../theme/scope'\n\nimport {\n ControlLabel,\n ControlMessage,\n describedBy,\n LAYER_SIZE,\n messageOf,\n} from '../../control'\nimport { controlStylesOf } from '../../control/styles'\nimport { CheckGlyph, IndeterminateGlyph } from '../../glyphs'\nimport { hitSlop, usePressFeedback } from '../../press'\nimport { withOpacity } from '../../theme/color'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles } from '../../theme/styles'\n\n// The checkbox page, as kanso-ui's Checkbox draws it: an 18dp box with a 2dp\n// corner and an 18dp glyph, inside a 40dp state layer, with a 48dp target.\n// Unselected, the box is a 2dp rule in on surface variant that turns on\n// surface while hovered, pressed or focused; selected or indeterminate, it\n// fills with primary and the glyph takes on primary. The error pair is error\n// and on error, and disabled is on surface at the disabled opacity for the\n// rule or the fill, with the glyph in surface. The state layer is on surface\n// over an unselected box and primary over a selected one while hovered, and\n// the two swap once pressed.\n//\n// The box eases between its colours over the motion tokens' short duration\n// on the standard curve, as web's transition does, and at once for a reader\n// who asks the device for reduced motion. The glyph arrives with the fill.\n//\n// The row, the label and the line under it are src/control's, which Radio\n// and Switch draw through as well. The whole row is the `Pressable`, so a\n// press on the label toggles the box, as a press on web's label does. The\n// line under it is outside the row, as web's is outside its label.\n//\n// The corner is a literal: the page's 2dp is a step the shape scale does not\n// carry.\n\ntype CheckboxProps = Omit<ViewProps, 'children' | 'style'> & {\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 readonly children?: ReactNode\n /**\n * Whether the checkbox starts selected, when it keeps its own state.\n * @default false\n */\n readonly defaultSelected?: boolean\n /**\n * A hint under the label. Replaced by `error` when there is one, so the\n * two never stack.\n */\n readonly 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 and the error colours both\n * follow from it.\n */\n readonly error?: string\n /**\n * Draws the checkbox disabled, and takes no presses.\n * @default false\n */\n readonly isDisabled?: boolean\n /**\n * Draws the dash for a box that stands for a partly selected set, and\n * reports the box as mixed to a screen reader. It is the call site's to\n * clear: a press still changes `isSelected` underneath.\n * @default false\n */\n readonly isIndeterminate?: boolean\n /**\n * Shows the state without letting a press change it.\n * @default false\n */\n readonly isReadOnly?: boolean\n /**\n * Whether the checkbox is selected, for a call site holding the state\n * itself with `onChange`.\n */\n readonly isSelected?: boolean\n /** Called with the new state whenever a press changes it. */\n readonly onChange?: (isSelected: boolean) => void\n readonly ref?: Ref<View>\n readonly style?: StyleProp<ViewStyle>\n}\n\ntype Tone = 'error' | 'marked' | 'unmarked'\n\n// The box's side, its rule and its corner, from the page. The glyph is the\n// box's size and sits over the whole of it, rule included.\nconst BOX_SIZE = 18\nconst BOX_CORNER = 2\nconst BOX_RULE = 2\n\n// The state layer's colour roles, hovered or focused and pressed. Error is\n// error throughout; otherwise the two swap once pressed.\nconst LAYERS: Readonly<\n Record<\n Tone,\n {\n readonly hover: keyof ResolvedTheme['colors']\n readonly pressed: keyof ResolvedTheme['colors']\n }\n >\n> = {\n error: { hover: 'error', pressed: 'error' },\n marked: { hover: 'primary', pressed: 'onSurface' },\n unmarked: { hover: 'onSurface', pressed: 'primary' },\n}\n\nconst styles = StyleSheet.create({\n box: {\n borderRadius: BOX_CORNER,\n borderWidth: BOX_RULE,\n height: BOX_SIZE,\n width: BOX_SIZE,\n },\n // Over the box rather than inside it, since a box's children are laid out\n // inside its rule and the glyph covers the rule as well.\n glyph: {\n left: (LAYER_SIZE - BOX_SIZE) / 2,\n position: 'absolute',\n top: (LAYER_SIZE - BOX_SIZE) / 2,\n },\n})\n\n/**\n * A checkbox with its label, and optionally a description or an error under\n * it. Its state is React Stately's, as web's is: pass `isSelected` with\n * `onChange` to control it, or `defaultSelected` to let it keep its own.\n * `isIndeterminate` draws the dash for a box that stands for a partly\n * selected set.\n *\n * ```tsx\n * <Checkbox defaultSelected description=\"Supporting line\">\n * Label\n * </Checkbox>\n * ```\n *\n * A screen reader hears it as a checkbox named by its label, checked,\n * unchecked or mixed, followed by the line under it. A press anywhere on the\n * box or the label toggles it, and the row takes presses over the 48dp target\n * the page asks of the box. `style`, `ref` and `testID` land on the view\n * holding the row and the line under it, which is the element a layout\n * positions.\n */\nfunction Checkbox({\n 'aria-label': ariaLabel,\n children,\n defaultSelected,\n description,\n error,\n isDisabled = false,\n isIndeterminate = false,\n isReadOnly = false,\n isSelected,\n onChange,\n style,\n ...props\n}: CheckboxProps) {\n const theme = useTheme()\n const state = useToggleState({\n defaultSelected,\n isReadOnly,\n isSelected,\n onChange,\n })\n const messageId = useId()\n\n const { colors, radii } = theme\n const marked = state.isSelected || isIndeterminate\n const interactive = !isDisabled && !isReadOnly\n const tone: Tone =\n error === undefined ? (marked ? 'marked' : 'unmarked') : 'error'\n\n const feedback = usePressFeedback({\n color: colors[LAYERS[tone].hover],\n corners: { borderRadius: radii.circle },\n disabled: !interactive,\n disc: LAYER_SIZE,\n pressedColor: colors[LAYERS[tone].pressed],\n })\n const active =\n feedback.hovered || feedback.pressed || feedback.ring !== undefined\n const paint = paintOf(theme, { active, isDisabled, marked, tone })\n const box = useBoxColors(paint)\n const Glyph = isIndeterminate\n ? IndeterminateGlyph\n : state.isSelected\n ? CheckGlyph\n : null\n\n return (\n <View {...props} style={style}>\n <Pressable\n aria-checked={isIndeterminate ? 'mixed' : state.isSelected}\n aria-label={ariaLabel}\n role=\"checkbox\"\n {...describedBy(messageId, messageOf(description, error))}\n {...feedback.handlers}\n disabled={isDisabled}\n hitSlop={hitSlop(LAYER_SIZE, LAYER_SIZE)}\n onPress={toggleOf(state)}\n style={controlStylesOf(theme).row}\n >\n <View\n style={composeStyles<ViewStyle>(\n controlStylesOf(theme).disc,\n feedback.ring,\n )}\n >\n {feedback.layer}\n <Animated.View\n style={composeStyles<AnimatedStyle<ViewStyle>>(styles.box, box)}\n />\n {Glyph === null ? null : (\n <Glyph color={paint.glyph} size={BOX_SIZE} style={styles.glyph} />\n )}\n </View>\n <ControlLabel isDisabled={isDisabled}>{children}</ControlLabel>\n </Pressable>\n <ControlMessage description={description} error={error} id={messageId} />\n </View>\n )\n}\n\n/**\n * What the box is painted in: its fill, its rule and the glyph's colour.\n * Where the page draws no fill or no rule it is the colour beside it made\n * clear rather than plain transparent black, so the box eases through its\n * own colour rather than through grey.\n */\nfunction paintOf(\n { colors, stateLayerOpacity }: ResolvedTheme,\n {\n active,\n isDisabled,\n marked,\n tone,\n }: {\n readonly active: boolean\n readonly isDisabled: boolean\n readonly marked: boolean\n readonly tone: Tone\n },\n) {\n const disabled = withOpacity(\n colors.onSurface,\n stateLayerOpacity.disabledContent,\n )\n\n if (marked) {\n const fill = isDisabled\n ? disabled\n : tone === 'error'\n ? colors.error\n : colors.primary\n const glyph = isDisabled\n ? colors.surface\n : tone === 'error'\n ? colors.onError\n : colors.onPrimary\n\n return { fill, glyph, rule: withOpacity(fill, 0) }\n }\n\n const rule = isDisabled\n ? disabled\n : tone === 'error'\n ? colors.error\n : active\n ? colors.onSurface\n : colors.onSurfaceVariant\n\n return { fill: withOpacity(rule, 0), glyph: colors.onPrimary, rule }\n}\n\n// A press's toggle. Built by a call rather than declared in the component,\n// which is what react-perf's jsx-no-new-function-as-prop is after; the React\n// Compiler memoises the result on its input.\nfunction toggleOf(state: ToggleState) {\n return () => {\n state.toggle()\n }\n}\n\n// The box's fill and rule, eased to as the state changes.\nfunction useBoxColors({ fill, rule }: { fill: string; rule: string }) {\n const { motion } = useTheme()\n const reduceMotion = useReducedMotion()\n const timing = {\n duration: motion.durationShort2,\n easing: Easing.bezier(...motion.easingStandard),\n }\n\n return useAnimatedStyle(() => {\n 'worklet'\n return {\n backgroundColor: reduceMotion ? fill : withTiming(fill, timing),\n borderColor: reduceMotion ? rule : withTiming(rule, timing),\n }\n })\n}\n\nexport { Checkbox }\nexport type { CheckboxProps }\n"],"mappings":";;;;;;;;;;;;;;AA2GA,MAAM6C,WAAW;AACjB,MAAMC,aAAa;AACnB,MAAMC,WAAW;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AAOlG,aACTuD,WACAT,SAAS,UACPH,OAAO5C,QACP4D,SACEhB,OAAOgD,YACPhD,OAAOwD;CAEf,OAAO;EAAEN,MAAMtG,YAAY2G,MAAM,CAAC;EAAGzE,OAAOkB,OAAOsD;EAAWC;CAAK;AACrE;AAKA,SAASvB,SAASlC,OAAoB;CACpC,aAAa;EACXA,MAAM2D,OAAO;CACf;AACF;AAGA,SAAAnC,aAAAnC,IAAA;CAAsB,MAAA,EAAA+D,MAAAK,SAAApE;CACpB,MAAA,EAAAuE,WAAmB7G,SAAS;CAC5B,MAAA8G,eAAqB7H,iBAAiB;CACtC,MAAA8H,SAAe;EAAAC,UACHH,OAAMI;EAAeC,QACvBnI,OAAMoI,OAAO,GAAIN,OAAMO,cAAe;CAChD;CAAC,OAEMpI,uBAAiB;EAAA;EAAA,OAEf;GAAAqI,iBACYP,eAAAT,OAAsBnH,WAAWmH,MAAMU,MAAM;GAACO,aAClDR,eAAAJ,OAAsBxH,WAAWwH,MAAMK,MAAM;EAC5D;CAAC,CACF;AAAC"}
@@ -0,0 +1,84 @@
1
+ import { PressableProps, StyleProp, View, ViewStyle } from "react-native";
2
+ import { ReactNode, Ref } from "react";
3
+ //#region src/components/chip/index.d.ts
4
+ /** An assist or suggestion chip: an action, drawn as a plain button. */
5
+ type ChipActionProps = ChipBaseProps & {
6
+ readonly defaultSelected?: never;
7
+ readonly isSelected?: never;
8
+ readonly onChange?: never;
9
+ /**
10
+ * `assist` for an action the chip's context suggests, and `suggestion`
11
+ * for one the product generates. Either is an action rather than a
12
+ * selection, so neither is ever selected.
13
+ */
14
+ readonly variant: 'assist' | 'suggestion';
15
+ };
16
+ type ChipBaseProps = Omit<PressableProps, 'children' | 'disabled' | 'style'> & {
17
+ /**
18
+ * The chip's label. Required: the page draws no chip without one, and a
19
+ * chip with none is an empty button to a screen reader.
20
+ */
21
+ readonly children: ReactNode;
22
+ /**
23
+ * Raises the chip off the page on a container of its own, at the page's
24
+ * elevation 1, in place of the outline. A selected filter chip keeps the
25
+ * secondary container.
26
+ * @default false
27
+ */
28
+ readonly elevated?: boolean;
29
+ /**
30
+ * An icon before the label, in the page's 18dp slot and the primary role,
31
+ * which the slot hands it through `useIconStyle()`. A filter chip's check
32
+ * takes its place while the chip is selected, so the chip keeps its width.
33
+ */
34
+ readonly icon?: ReactNode;
35
+ /**
36
+ * Draws the chip disabled, and takes no presses.
37
+ * @default false
38
+ */
39
+ readonly isDisabled?: boolean;
40
+ readonly ref?: Ref<View>;
41
+ readonly style?: StyleProp<ViewStyle>;
42
+ };
43
+ /** A filter chip: a two-state button, the default. */
44
+ type ChipFilterProps = ChipBaseProps & {
45
+ /**
46
+ * Whether the chip starts selected, when it keeps its own state.
47
+ * @default false
48
+ */
49
+ readonly defaultSelected?: boolean;
50
+ /**
51
+ * Whether the chip is selected, when the call site holds the state. Pass
52
+ * it with `onChange`.
53
+ */
54
+ readonly isSelected?: boolean;
55
+ /** Called with the new state when the chip is pressed, after `onPress`. */
56
+ readonly onChange?: (isSelected: boolean) => void;
57
+ /**
58
+ * A filter chip, a two-state button.
59
+ * @default 'filter'
60
+ */
61
+ readonly variant?: 'filter';
62
+ };
63
+ type ChipProps = ChipActionProps | ChipFilterProps;
64
+ /** Which of the chips page's chips a Chip is. */
65
+ type ChipVariant = 'assist' | 'filter' | 'suggestion';
66
+ /**
67
+ * A chip. By default a filter chip, which is a two-state button reporting
68
+ * its state as a toggle Button does: pass `isSelected` with `onChange` to
69
+ * control it, or `defaultSelected` to let it keep its own state.
70
+ *
71
+ * ```tsx
72
+ * <Chip defaultSelected>Label</Chip>
73
+ * ```
74
+ *
75
+ * `variant="assist"` and `variant="suggestion"` draw the page's two action
76
+ * chips instead: plain buttons, pressed with `onPress`, never selected.
77
+ *
78
+ * A column stretches a chip across it, as it does any view; a row of chips is
79
+ * a row that wraps. `style`, `ref` and `testID` land on the `Pressable`.
80
+ */
81
+ declare function Chip({ children, defaultSelected, elevated, hitSlop, icon, isDisabled, isSelected, onBlur, onChange, onFocus, onHoverIn, onHoverOut, onLayout, onPress, onPressIn, onPressOut, style, variant, ...props }: ChipProps): import("react").JSX.Element;
82
+ //#endregion
83
+ export { Chip, type ChipActionProps, type ChipFilterProps, type ChipProps, type ChipVariant };
84
+ //# sourceMappingURL=index.d.ts.map