@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,832 @@
1
+ import { IconStyleContext } from "../../glyphs/icon-style.js";
2
+ import { MinusGlyph, PlusGlyph } from "../../glyphs/index.js";
3
+ import { useTheme } from "../../theme/scope.js";
4
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
5
+ import { useFieldValidation } from "../../form/index.js";
6
+ import { withOpacity } from "../../theme/color.js";
7
+ import { hitSlop, usePressFeedback } from "../../press/index.js";
8
+ import { IconButton } from "../icon-button/index.js";
9
+ import { FieldBox, FieldInput, FieldMessage, describedBy, useFieldFocus } from "../../field/index.js";
10
+ import { useNumberFieldState } from "../../number/state.js";
11
+ import { c } from "react/compiler-runtime";
12
+ import { AccessibilityInfo, Platform, Pressable, StyleSheet, View, useWindowDimensions } from "react-native";
13
+ import { useEffect, useId, useImperativeHandle, useRef, useState } from "react";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ import { NumberFormatter } from "@internationalized/number";
16
+ //#region src/components/number-field/index.tsx
17
+ const STEPPER_WIDTH = 32;
18
+ const GLYPH_SIZE = 20;
19
+ const SPIN_DELAY = 600;
20
+ const SPIN_INTERVAL = 60;
21
+ let deviceLocale;
22
+ const stylesOf = themedStyles(({ radii, spacing }) => StyleSheet.create({
23
+ stepper: {
24
+ alignItems: "center",
25
+ flexBasis: 0,
26
+ flexGrow: 1,
27
+ justifyContent: "center",
28
+ width: STEPPER_WIDTH
29
+ },
30
+ stepperBottomOutlined: { borderBottomEndRadius: radii.xs },
31
+ stepperRing: { outlineOffset: -2 },
32
+ steppers: {
33
+ alignSelf: "stretch",
34
+ flexDirection: "column",
35
+ marginEnd: -spacing.lg,
36
+ marginStart: spacing.sm - spacing.lg,
37
+ marginVertical: -spacing.sm
38
+ },
39
+ steppersInline: {
40
+ alignSelf: "center",
41
+ flexDirection: "row",
42
+ gap: spacing.sm,
43
+ marginEnd: spacing.md - spacing.lg,
44
+ marginStart: spacing.sm - spacing.lg
45
+ },
46
+ steppersOutlined: { marginVertical: -spacing.lg },
47
+ stepperTop: { borderTopEndRadius: radii.xs }
48
+ }));
49
+ function blurThen(onBlur, then) {
50
+ return (event) => {
51
+ onBlur();
52
+ then?.(event);
53
+ };
54
+ }
55
+ function commitBefore(state, handler) {
56
+ return (event) => {
57
+ state.commit();
58
+ handler?.(event);
59
+ };
60
+ }
61
+ function editInto(state, onEdit) {
62
+ return (text) => {
63
+ if (state.validate(text)) {
64
+ state.setInputValue(text);
65
+ onEdit();
66
+ }
67
+ };
68
+ }
69
+ function glyphOf(color) {
70
+ return {
71
+ color,
72
+ size: GLYPH_SIZE
73
+ };
74
+ }
75
+ function halfOf({ spacing, typography }, outlined, fontScale) {
76
+ return outlined ? spacing.lg + typography.bodyLargeLineHeight * fontScale / 2 : spacing.sm + (typography.bodySmallLineHeight + typography.bodyLargeLineHeight) * fontScale / 2;
77
+ }
78
+ function keyboardOf(minValue, hasDecimals) {
79
+ if (minValue === void 0 || Number.isNaN(minValue) || minValue < 0) return Platform.OS === "ios" ? "numbers-and-punctuation" : "numeric";
80
+ return hasDecimals ? "decimal-pad" : "number-pad";
81
+ }
82
+ function localeOf(locale) {
83
+ if (locale !== void 0) try {
84
+ Intl.NumberFormat.supportedLocalesOf(locale);
85
+ return locale;
86
+ } catch {}
87
+ deviceLocale ??= new Intl.NumberFormat().resolvedOptions().locale;
88
+ return deviceLocale;
89
+ }
90
+ function marginVerticalOf(margin) {
91
+ return { marginVertical: margin };
92
+ }
93
+ /**
94
+ * A labelled number input with steppers, the text fields page's filled or
95
+ * outlined field. Pass `value` with `onChange` to control it, or
96
+ * `defaultValue` to let it keep its own; `onChange` is handed the committed
97
+ * number, `NaN` for an empty field. `minValue`, `maxValue` and `step` shape
98
+ * it, and `formatOptions` says how it reads, in `locale`: a currency, a
99
+ * percentage, a unit.
100
+ *
101
+ * React Native's own `TextInput` props, the return key among them, reach the
102
+ * control; `style` and `ref` are the field as a whole, and `inputRef` the
103
+ * control.
104
+ *
105
+ * ```tsx
106
+ * <NumberField defaultValue={1234.5} label="Label" />
107
+ * ```
108
+ */
109
+ function NumberField(t0) {
110
+ const $ = c(110);
111
+ let decrementLabel;
112
+ let defaultValue;
113
+ let description;
114
+ let error;
115
+ let formatOptions;
116
+ let incrementLabel;
117
+ let inputRef;
118
+ let label;
119
+ let locale;
120
+ let maxValue;
121
+ let minValue;
122
+ let name;
123
+ let onBlur;
124
+ let onChange;
125
+ let onFocus;
126
+ let onSubmitEditing;
127
+ let props;
128
+ let ref;
129
+ let step;
130
+ let style;
131
+ let t1;
132
+ let t2;
133
+ let t3;
134
+ let t4;
135
+ let t5;
136
+ let t6;
137
+ let t7;
138
+ let t8;
139
+ let validate;
140
+ let value;
141
+ if ($[0] !== t0) {
142
+ ({decrementLabel, defaultValue, description, error, floatingLabel: t1, formatOptions, incrementLabel, inputRef, isDisabled: t2, isReadOnly: t3, isRequired: t4, label, locale, maxValue, minValue, name, numeric: t5, onBlur, onChange, onFocus, onSubmitEditing, ref, returnKeyType: t6, step, steppers: t7, style, validate, value, variant: t8, ...props} = t0);
143
+ $[0] = t0;
144
+ $[1] = decrementLabel;
145
+ $[2] = defaultValue;
146
+ $[3] = description;
147
+ $[4] = error;
148
+ $[5] = formatOptions;
149
+ $[6] = incrementLabel;
150
+ $[7] = inputRef;
151
+ $[8] = label;
152
+ $[9] = locale;
153
+ $[10] = maxValue;
154
+ $[11] = minValue;
155
+ $[12] = name;
156
+ $[13] = onBlur;
157
+ $[14] = onChange;
158
+ $[15] = onFocus;
159
+ $[16] = onSubmitEditing;
160
+ $[17] = props;
161
+ $[18] = ref;
162
+ $[19] = step;
163
+ $[20] = style;
164
+ $[21] = t1;
165
+ $[22] = t2;
166
+ $[23] = t3;
167
+ $[24] = t4;
168
+ $[25] = t5;
169
+ $[26] = t6;
170
+ $[27] = t7;
171
+ $[28] = t8;
172
+ $[29] = validate;
173
+ $[30] = value;
174
+ } else {
175
+ decrementLabel = $[1];
176
+ defaultValue = $[2];
177
+ description = $[3];
178
+ error = $[4];
179
+ formatOptions = $[5];
180
+ incrementLabel = $[6];
181
+ inputRef = $[7];
182
+ label = $[8];
183
+ locale = $[9];
184
+ maxValue = $[10];
185
+ minValue = $[11];
186
+ name = $[12];
187
+ onBlur = $[13];
188
+ onChange = $[14];
189
+ onFocus = $[15];
190
+ onSubmitEditing = $[16];
191
+ props = $[17];
192
+ ref = $[18];
193
+ step = $[19];
194
+ style = $[20];
195
+ t1 = $[21];
196
+ t2 = $[22];
197
+ t3 = $[23];
198
+ t4 = $[24];
199
+ t5 = $[25];
200
+ t6 = $[26];
201
+ t7 = $[27];
202
+ t8 = $[28];
203
+ validate = $[29];
204
+ value = $[30];
205
+ }
206
+ const floatingLabel = t1 === void 0 ? true : t1;
207
+ const isDisabled = t2 === void 0 ? false : t2;
208
+ const isReadOnly = t3 === void 0 ? false : t3;
209
+ const isRequired = t4 === void 0 ? false : t4;
210
+ const numeric = t5 === void 0 ? true : t5;
211
+ const returnKeyType = t6 === void 0 ? "done" : t6;
212
+ const steppers = t7 === void 0 ? "vertical" : t7;
213
+ const variant = t8 === void 0 ? "filled" : t8;
214
+ const id = useId();
215
+ const control = useRef(null);
216
+ const writtenIn = localeOf(locale);
217
+ const state = useNumberFieldState({
218
+ defaultValue,
219
+ formatOptions,
220
+ isDisabled,
221
+ isReadOnly,
222
+ locale: writtenIn,
223
+ maxValue,
224
+ minValue,
225
+ onChange,
226
+ step,
227
+ value
228
+ });
229
+ let t9;
230
+ if ($[31] !== state.numberValue) {
231
+ t9 = Number.isNaN(state.numberValue);
232
+ $[31] = state.numberValue;
233
+ $[32] = t9;
234
+ } else t9 = $[32];
235
+ const empty = t9;
236
+ const t10 = empty ? "" : String(state.numberValue);
237
+ let t11;
238
+ if ($[33] !== empty || $[34] !== error || $[35] !== isDisabled || $[36] !== isReadOnly || $[37] !== isRequired || $[38] !== name || $[39] !== state.numberValue || $[40] !== t10 || $[41] !== validate) {
239
+ t11 = {
240
+ control,
241
+ error,
242
+ isDisabled,
243
+ isEmpty: empty,
244
+ isReadOnly,
245
+ isRequired,
246
+ name,
247
+ submitted: t10,
248
+ validate,
249
+ value: state.numberValue
250
+ };
251
+ $[33] = empty;
252
+ $[34] = error;
253
+ $[35] = isDisabled;
254
+ $[36] = isReadOnly;
255
+ $[37] = isRequired;
256
+ $[38] = name;
257
+ $[39] = state.numberValue;
258
+ $[40] = t10;
259
+ $[41] = validate;
260
+ $[42] = t11;
261
+ } else t11 = $[42];
262
+ const validation = useFieldValidation(t11);
263
+ const shownError = validation.error;
264
+ let t12;
265
+ if ($[43] !== onBlur || $[44] !== state || $[45] !== validation.onBlur) {
266
+ t12 = commitBefore(state, blurThen(validation.onBlur, onBlur));
267
+ $[43] = onBlur;
268
+ $[44] = state;
269
+ $[45] = validation.onBlur;
270
+ $[46] = t12;
271
+ } else t12 = $[46];
272
+ let t13;
273
+ if ($[47] !== onFocus || $[48] !== t12) {
274
+ t13 = {
275
+ onBlur: t12,
276
+ onFocus
277
+ };
278
+ $[47] = onFocus;
279
+ $[48] = t12;
280
+ $[49] = t13;
281
+ } else t13 = $[49];
282
+ const focus = useFieldFocus(t13);
283
+ const hasDecimals = (new NumberFormatter(writtenIn, formatOptions).resolvedOptions().maximumFractionDigits ?? 0) > 0;
284
+ const announced = useStepAnnouncement(state.inputValue);
285
+ const [stepperFocused, setStepperFocused] = useState(false);
286
+ let t14;
287
+ let t15;
288
+ if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
289
+ t14 = () => control.current;
290
+ t15 = [];
291
+ $[50] = t14;
292
+ $[51] = t15;
293
+ } else {
294
+ t14 = $[50];
295
+ t15 = $[51];
296
+ }
297
+ useImperativeHandle(inputRef, t14, t15);
298
+ const t16 = decrementLabel ?? `Decrease ${label}`;
299
+ const t17 = incrementLabel ?? `Increase ${label}`;
300
+ const t18 = steppers === "horizontal";
301
+ let t19;
302
+ if ($[52] === Symbol.for("react.memo_cache_sentinel")) {
303
+ t19 = () => {
304
+ setStepperFocused(false);
305
+ };
306
+ $[52] = t19;
307
+ } else t19 = $[52];
308
+ let t20;
309
+ if ($[53] !== announced || $[54] !== state.canDecrement || $[55] !== state.canIncrement || $[56] !== state.decrement || $[57] !== state.increment || $[58] !== t16 || $[59] !== t17 || $[60] !== t18 || $[61] !== validation.onEdit || $[62] !== variant) {
310
+ let t21;
311
+ if ($[64] === Symbol.for("react.memo_cache_sentinel")) {
312
+ t21 = () => {
313
+ setStepperFocused(true);
314
+ };
315
+ $[64] = t21;
316
+ } else t21 = $[64];
317
+ t20 = steppersOf({
318
+ canDecrement: state.canDecrement,
319
+ canIncrement: state.canIncrement,
320
+ decrementLabel: t16,
321
+ incrementLabel: t17,
322
+ inline: t18,
323
+ onBlur: t19,
324
+ onDecrement: announced(stepThen(state.decrement, validation.onEdit)),
325
+ onFocus: t21,
326
+ onIncrement: announced(stepThen(state.increment, validation.onEdit)),
327
+ outlined: variant === "outlined"
328
+ });
329
+ $[53] = announced;
330
+ $[54] = state.canDecrement;
331
+ $[55] = state.canIncrement;
332
+ $[56] = state.decrement;
333
+ $[57] = state.increment;
334
+ $[58] = t16;
335
+ $[59] = t17;
336
+ $[60] = t18;
337
+ $[61] = validation.onEdit;
338
+ $[62] = variant;
339
+ $[63] = t20;
340
+ } else t20 = $[63];
341
+ const t21 = focus.focused || stepperFocused;
342
+ const t22 = shownError !== void 0;
343
+ const t23 = state.inputValue !== "";
344
+ const t24 = focus.handlers;
345
+ let t25;
346
+ if ($[65] !== description || $[66] !== id || $[67] !== shownError) {
347
+ t25 = describedBy(id, {
348
+ description,
349
+ error: shownError
350
+ });
351
+ $[65] = description;
352
+ $[66] = id;
353
+ $[67] = shownError;
354
+ $[68] = t25;
355
+ } else t25 = $[68];
356
+ const t26 = !isDisabled && !isReadOnly;
357
+ let t27;
358
+ if ($[69] !== hasDecimals || $[70] !== minValue) {
359
+ t27 = keyboardOf(minValue, hasDecimals);
360
+ $[69] = hasDecimals;
361
+ $[70] = minValue;
362
+ $[71] = t27;
363
+ } else t27 = $[71];
364
+ let t28;
365
+ if ($[72] !== state || $[73] !== validation.onEdit) {
366
+ t28 = editInto(state, validation.onEdit);
367
+ $[72] = state;
368
+ $[73] = validation.onEdit;
369
+ $[74] = t28;
370
+ } else t28 = $[74];
371
+ let t29;
372
+ if ($[75] !== onSubmitEditing || $[76] !== state) {
373
+ t29 = commitBefore(state, onSubmitEditing);
374
+ $[75] = onSubmitEditing;
375
+ $[76] = state;
376
+ $[77] = t29;
377
+ } else t29 = $[77];
378
+ let t30;
379
+ if ($[78] !== focus.handlers || $[79] !== label || $[80] !== numeric || $[81] !== props || $[82] !== returnKeyType || $[83] !== state.inputValue || $[84] !== t25 || $[85] !== t26 || $[86] !== t27 || $[87] !== t28 || $[88] !== t29) {
380
+ t30 = /* @__PURE__ */ jsx(FieldInput, {
381
+ ...props,
382
+ ...t24,
383
+ "aria-label": label,
384
+ autoComplete: "off",
385
+ autoCorrect: false,
386
+ described: t25,
387
+ editable: t26,
388
+ keyboardType: t27,
389
+ numeric,
390
+ onChangeText: t28,
391
+ onSubmitEditing: t29,
392
+ ref: control,
393
+ returnKeyType,
394
+ spellCheck: false,
395
+ value: state.inputValue
396
+ });
397
+ $[78] = focus.handlers;
398
+ $[79] = label;
399
+ $[80] = numeric;
400
+ $[81] = props;
401
+ $[82] = returnKeyType;
402
+ $[83] = state.inputValue;
403
+ $[84] = t25;
404
+ $[85] = t26;
405
+ $[86] = t27;
406
+ $[87] = t28;
407
+ $[88] = t29;
408
+ $[89] = t30;
409
+ } else t30 = $[89];
410
+ let t31;
411
+ if ($[90] !== floatingLabel || $[91] !== isDisabled || $[92] !== isRequired || $[93] !== label || $[94] !== t20 || $[95] !== t21 || $[96] !== t22 || $[97] !== t23 || $[98] !== t30 || $[99] !== variant) {
412
+ t31 = /* @__PURE__ */ jsx(FieldBox, {
413
+ control,
414
+ end: t20,
415
+ floatingLabel,
416
+ isDisabled,
417
+ isFocused: t21,
418
+ isInvalid: t22,
419
+ isPopulated: t23,
420
+ isRequired,
421
+ label,
422
+ variant,
423
+ children: t30
424
+ });
425
+ $[90] = floatingLabel;
426
+ $[91] = isDisabled;
427
+ $[92] = isRequired;
428
+ $[93] = label;
429
+ $[94] = t20;
430
+ $[95] = t21;
431
+ $[96] = t22;
432
+ $[97] = t23;
433
+ $[98] = t30;
434
+ $[99] = variant;
435
+ $[100] = t31;
436
+ } else t31 = $[100];
437
+ let t32;
438
+ if ($[101] !== description || $[102] !== id || $[103] !== shownError) {
439
+ t32 = /* @__PURE__ */ jsx(FieldMessage, {
440
+ description,
441
+ error: shownError,
442
+ id
443
+ });
444
+ $[101] = description;
445
+ $[102] = id;
446
+ $[103] = shownError;
447
+ $[104] = t32;
448
+ } else t32 = $[104];
449
+ let t33;
450
+ if ($[105] !== ref || $[106] !== style || $[107] !== t31 || $[108] !== t32) {
451
+ t33 = /* @__PURE__ */ jsxs(View, {
452
+ ref,
453
+ style,
454
+ children: [t31, t32]
455
+ });
456
+ $[105] = ref;
457
+ $[106] = style;
458
+ $[107] = t31;
459
+ $[108] = t32;
460
+ $[109] = t33;
461
+ } else t33 = $[109];
462
+ return t33;
463
+ }
464
+ function outwardSlop(half, place) {
465
+ const slop = hitSlop(half, STEPPER_WIDTH);
466
+ if (slop === void 0) return;
467
+ const reach = (slop.top ?? 0) + (slop.bottom ?? 0);
468
+ return place === "top" ? {
469
+ ...slop,
470
+ bottom: 0,
471
+ top: reach
472
+ } : {
473
+ ...slop,
474
+ bottom: reach,
475
+ top: 0
476
+ };
477
+ }
478
+ /**
479
+ * One of the stacked pair: half the column, the glyph in on surface
480
+ * variant, and the state layer, the ripple and the ring every control
481
+ * draws, the ring inside it. Disabled at the end of the range, where the
482
+ * glyph takes on surface at the disabled opacity.
483
+ */
484
+ function Stepper(t0) {
485
+ const $ = c(23);
486
+ const { "aria-label": ariaLabel, children, half, isDisabled, onBlur, onFocus, onPress, onPressIn, onPressOut, outlined, place } = t0;
487
+ const theme = useTheme();
488
+ const styles = stylesOf(theme);
489
+ const { colors, stateLayerOpacity } = theme;
490
+ const corner = place === "top" ? styles.stepperTop : outlined ? styles.stepperBottomOutlined : void 0;
491
+ const feedback = usePressFeedback({
492
+ color: colors.onSurfaceVariant,
493
+ corners: corner,
494
+ disabled: isDisabled,
495
+ onBlur,
496
+ onFocus,
497
+ onPressIn,
498
+ onPressOut
499
+ });
500
+ const T0 = Pressable;
501
+ const t1 = feedback.handlers;
502
+ let t2;
503
+ if ($[0] !== half || $[1] !== place) {
504
+ t2 = outwardSlop(half, place);
505
+ $[0] = half;
506
+ $[1] = place;
507
+ $[2] = t2;
508
+ } else t2 = $[2];
509
+ const t3 = "button";
510
+ const t4 = composeStyles(styles.stepper, corner, feedback.ring, feedback.ring === void 0 ? void 0 : styles.stepperRing);
511
+ const t5 = feedback.layer;
512
+ let t6;
513
+ if ($[3] !== colors.onSurface || $[4] !== colors.onSurfaceVariant || $[5] !== isDisabled || $[6] !== stateLayerOpacity) {
514
+ t6 = isDisabled ? withOpacity(colors.onSurface, stateLayerOpacity.disabledContent) : colors.onSurfaceVariant;
515
+ $[3] = colors.onSurface;
516
+ $[4] = colors.onSurfaceVariant;
517
+ $[5] = isDisabled;
518
+ $[6] = stateLayerOpacity;
519
+ $[7] = t6;
520
+ } else t6 = $[7];
521
+ let t7;
522
+ if ($[8] !== t6) {
523
+ t7 = glyphOf(t6);
524
+ $[8] = t6;
525
+ $[9] = t7;
526
+ } else t7 = $[9];
527
+ let t8;
528
+ if ($[10] !== children || $[11] !== t7) {
529
+ t8 = /* @__PURE__ */ jsx(IconStyleContext, {
530
+ value: t7,
531
+ children
532
+ });
533
+ $[10] = children;
534
+ $[11] = t7;
535
+ $[12] = t8;
536
+ } else t8 = $[12];
537
+ let t9;
538
+ if ($[13] !== T0 || $[14] !== ariaLabel || $[15] !== feedback.handlers || $[16] !== feedback.layer || $[17] !== isDisabled || $[18] !== onPress || $[19] !== t2 || $[20] !== t4 || $[21] !== t8) {
539
+ t9 = /* @__PURE__ */ jsxs(T0, {
540
+ ...t1,
541
+ "aria-label": ariaLabel,
542
+ disabled: isDisabled,
543
+ hitSlop: t2,
544
+ onPress,
545
+ role: t3,
546
+ style: t4,
547
+ children: [t5, t8]
548
+ });
549
+ $[13] = T0;
550
+ $[14] = ariaLabel;
551
+ $[15] = feedback.handlers;
552
+ $[16] = feedback.layer;
553
+ $[17] = isDisabled;
554
+ $[18] = onPress;
555
+ $[19] = t2;
556
+ $[20] = t4;
557
+ $[21] = t8;
558
+ $[22] = t9;
559
+ } else t9 = $[22];
560
+ return t9;
561
+ }
562
+ /**
563
+ * The two steppers at the box's end, stacked or side by side, each
564
+ * disabled where it would not move the value.
565
+ */
566
+ function Steppers(t0) {
567
+ const $ = c(41);
568
+ const { canDecrement, canIncrement, decrementLabel, incrementLabel, inline, onBlur, onDecrement, onFocus, onIncrement, outlined } = t0;
569
+ const theme = useTheme();
570
+ const styles = stylesOf(theme);
571
+ const { fontScale } = useWindowDimensions();
572
+ const { sizing, typography } = theme;
573
+ const up = useSpin(onIncrement, canIncrement);
574
+ const down = useSpin(onDecrement, canDecrement);
575
+ if (inline) {
576
+ const t1 = !canDecrement;
577
+ let t2;
578
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
579
+ t2 = /* @__PURE__ */ jsx(MinusGlyph, {});
580
+ $[0] = t2;
581
+ } else t2 = $[0];
582
+ let t3;
583
+ if ($[1] !== decrementLabel || $[2] !== down || $[3] !== onBlur || $[4] !== onFocus || $[5] !== t1) {
584
+ t3 = /* @__PURE__ */ jsx(IconButton, {
585
+ ...down,
586
+ "aria-label": decrementLabel,
587
+ isDisabled: t1,
588
+ onBlur,
589
+ onFocus,
590
+ size: "xs",
591
+ children: t2
592
+ });
593
+ $[1] = decrementLabel;
594
+ $[2] = down;
595
+ $[3] = onBlur;
596
+ $[4] = onFocus;
597
+ $[5] = t1;
598
+ $[6] = t3;
599
+ } else t3 = $[6];
600
+ const t4 = !canIncrement;
601
+ let t5;
602
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
603
+ t5 = /* @__PURE__ */ jsx(PlusGlyph, {});
604
+ $[7] = t5;
605
+ } else t5 = $[7];
606
+ let t6;
607
+ if ($[8] !== incrementLabel || $[9] !== onBlur || $[10] !== onFocus || $[11] !== t4 || $[12] !== up) {
608
+ t6 = /* @__PURE__ */ jsx(IconButton, {
609
+ ...up,
610
+ "aria-label": incrementLabel,
611
+ isDisabled: t4,
612
+ onBlur,
613
+ onFocus,
614
+ size: "xs",
615
+ children: t5
616
+ });
617
+ $[8] = incrementLabel;
618
+ $[9] = onBlur;
619
+ $[10] = onFocus;
620
+ $[11] = t4;
621
+ $[12] = up;
622
+ $[13] = t6;
623
+ } else t6 = $[13];
624
+ return /* @__PURE__ */ jsxs(View, {
625
+ style: composeStyles(styles.steppersInline, marginVerticalOf((typography.bodyLargeLineHeight * fontScale - sizing.controlXs) / 2)),
626
+ children: [t3, t6]
627
+ });
628
+ }
629
+ let t1;
630
+ if ($[14] !== fontScale || $[15] !== outlined || $[16] !== theme) {
631
+ t1 = halfOf(theme, outlined, fontScale);
632
+ $[14] = fontScale;
633
+ $[15] = outlined;
634
+ $[16] = theme;
635
+ $[17] = t1;
636
+ } else t1 = $[17];
637
+ const half = t1;
638
+ const T0 = View;
639
+ const t2 = composeStyles(styles.steppers, outlined ? styles.steppersOutlined : void 0);
640
+ const t3 = !canIncrement;
641
+ let t4;
642
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
643
+ t4 = /* @__PURE__ */ jsx(PlusGlyph, {});
644
+ $[18] = t4;
645
+ } else t4 = $[18];
646
+ let t5;
647
+ if ($[19] !== half || $[20] !== incrementLabel || $[21] !== onBlur || $[22] !== onFocus || $[23] !== outlined || $[24] !== t3 || $[25] !== up) {
648
+ t5 = /* @__PURE__ */ jsx(Stepper, {
649
+ ...up,
650
+ "aria-label": incrementLabel,
651
+ half,
652
+ isDisabled: t3,
653
+ onBlur,
654
+ onFocus,
655
+ outlined,
656
+ place: "top",
657
+ children: t4
658
+ });
659
+ $[19] = half;
660
+ $[20] = incrementLabel;
661
+ $[21] = onBlur;
662
+ $[22] = onFocus;
663
+ $[23] = outlined;
664
+ $[24] = t3;
665
+ $[25] = up;
666
+ $[26] = t5;
667
+ } else t5 = $[26];
668
+ const t6 = !canDecrement;
669
+ let t7;
670
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
671
+ t7 = /* @__PURE__ */ jsx(MinusGlyph, {});
672
+ $[27] = t7;
673
+ } else t7 = $[27];
674
+ let t8;
675
+ if ($[28] !== decrementLabel || $[29] !== down || $[30] !== half || $[31] !== onBlur || $[32] !== onFocus || $[33] !== outlined || $[34] !== t6) {
676
+ t8 = /* @__PURE__ */ jsx(Stepper, {
677
+ ...down,
678
+ "aria-label": decrementLabel,
679
+ half,
680
+ isDisabled: t6,
681
+ onBlur,
682
+ onFocus,
683
+ outlined,
684
+ place: "bottom",
685
+ children: t7
686
+ });
687
+ $[28] = decrementLabel;
688
+ $[29] = down;
689
+ $[30] = half;
690
+ $[31] = onBlur;
691
+ $[32] = onFocus;
692
+ $[33] = outlined;
693
+ $[34] = t6;
694
+ $[35] = t8;
695
+ } else t8 = $[35];
696
+ let t9;
697
+ if ($[36] !== T0 || $[37] !== t2 || $[38] !== t5 || $[39] !== t8) {
698
+ t9 = /* @__PURE__ */ jsxs(T0, {
699
+ style: t2,
700
+ children: [t5, t8]
701
+ });
702
+ $[36] = T0;
703
+ $[37] = t2;
704
+ $[38] = t5;
705
+ $[39] = t8;
706
+ $[40] = t9;
707
+ } else t9 = $[40];
708
+ return t9;
709
+ }
710
+ function steppersOf(props) {
711
+ return /* @__PURE__ */ jsx(Steppers, { ...props });
712
+ }
713
+ /**
714
+ * A stepper's press handlers: a tap steps once, when it is released, and a
715
+ * hold keeps stepping, from `SPIN_DELAY` on and every `SPIN_INTERVAL` after,
716
+ * until the press ends or the value reaches its bound. A hold steps nothing
717
+ * more on release, and a press the finger slides off steps nothing at all,
718
+ * as React Aria's stepper does for a touch.
719
+ */
720
+ function stepThen(step, onEdit) {
721
+ return () => {
722
+ step();
723
+ onEdit();
724
+ };
725
+ }
726
+ function useSpin(step, canStep) {
727
+ const $ = c(9);
728
+ let t0;
729
+ if ($[0] !== canStep || $[1] !== step) {
730
+ t0 = {
731
+ canStep,
732
+ step
733
+ };
734
+ $[0] = canStep;
735
+ $[1] = step;
736
+ $[2] = t0;
737
+ } else t0 = $[2];
738
+ const latest = useRef(t0);
739
+ const timer = useRef(void 0);
740
+ const spun = useRef(false);
741
+ let t1;
742
+ if ($[3] !== canStep || $[4] !== step) {
743
+ t1 = () => {
744
+ latest.current = {
745
+ canStep,
746
+ step
747
+ };
748
+ };
749
+ $[3] = canStep;
750
+ $[4] = step;
751
+ $[5] = t1;
752
+ } else t1 = $[5];
753
+ useEffect(t1);
754
+ let t2;
755
+ let t3;
756
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
757
+ t2 = () => () => {
758
+ clearTimeout(timer.current);
759
+ };
760
+ t3 = [];
761
+ $[6] = t2;
762
+ $[7] = t3;
763
+ } else {
764
+ t2 = $[6];
765
+ t3 = $[7];
766
+ }
767
+ useEffect(t2, t3);
768
+ let t4;
769
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
770
+ const tick = () => {
771
+ if (!latest.current.canStep) return;
772
+ spun.current = true;
773
+ latest.current.step();
774
+ timer.current = setTimeout(tick, SPIN_INTERVAL);
775
+ };
776
+ t4 = {
777
+ onPress: () => {
778
+ if (!spun.current) latest.current.step();
779
+ },
780
+ onPressIn: () => {
781
+ clearTimeout(timer.current);
782
+ spun.current = false;
783
+ timer.current = setTimeout(tick, SPIN_DELAY);
784
+ },
785
+ onPressOut: () => {
786
+ clearTimeout(timer.current);
787
+ }
788
+ };
789
+ $[8] = t4;
790
+ } else t4 = $[8];
791
+ return t4;
792
+ }
793
+ /**
794
+ * Says the field's text after a stepper press, once the field has written
795
+ * it, on iOS and Android, where the screen reader stays on the stepper.
796
+ * Wrap each step in what it returns.
797
+ */
798
+ function useStepAnnouncement(text) {
799
+ const $ = c(4);
800
+ const pending = useRef(false);
801
+ let t0;
802
+ let t1;
803
+ if ($[0] !== text) {
804
+ t0 = () => {
805
+ if (pending.current) {
806
+ pending.current = false;
807
+ AccessibilityInfo.announceForAccessibility(text);
808
+ }
809
+ };
810
+ t1 = [text];
811
+ $[0] = text;
812
+ $[1] = t0;
813
+ $[2] = t1;
814
+ } else {
815
+ t0 = $[1];
816
+ t1 = $[2];
817
+ }
818
+ useEffect(t0, t1);
819
+ let t2;
820
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
821
+ t2 = (step) => () => {
822
+ pending.current = Platform.OS === "ios" || Platform.OS === "android";
823
+ step();
824
+ };
825
+ $[3] = t2;
826
+ } else t2 = $[3];
827
+ return t2;
828
+ }
829
+ //#endregion
830
+ export { NumberField };
831
+
832
+ //# sourceMappingURL=index.js.map