@kanso-labs/react-native-kanso-ui 0.9.0 → 0.10.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 (196) hide show
  1. package/README.md +4 -3
  2. package/dist/autocomplete/index.js +15 -1
  3. package/dist/autocomplete/index.js.map +1 -1
  4. package/dist/button/group.d.ts +5 -0
  5. package/dist/button/group.js +115 -0
  6. package/dist/button/group.js.map +1 -0
  7. package/dist/button/index.d.ts +4 -1
  8. package/dist/button/index.js +44 -22
  9. package/dist/button/index.js.map +1 -1
  10. package/dist/button/slots.js +2 -1
  11. package/dist/button/slots.js.map +1 -1
  12. package/dist/calendar/index.js +351 -182
  13. package/dist/calendar/index.js.map +1 -1
  14. package/dist/calendar/styles.js +33 -2
  15. package/dist/calendar/styles.js.map +1 -1
  16. package/dist/carousel/arrangement.d.ts +5 -0
  17. package/dist/carousel/arrangement.js +123 -0
  18. package/dist/carousel/arrangement.js.map +1 -0
  19. package/dist/chequer/index.js +95 -0
  20. package/dist/chequer/index.js.map +1 -0
  21. package/dist/collection/index.d.ts +157 -0
  22. package/dist/collection/index.js +1331 -0
  23. package/dist/collection/index.js.map +1 -0
  24. package/dist/color-thumb/index.js +56 -0
  25. package/dist/color-thumb/index.js.map +1 -0
  26. package/dist/components/button/index.d.ts +4 -2
  27. package/dist/components/button/index.js +227 -188
  28. package/dist/components/button/index.js.map +1 -1
  29. package/dist/components/button-group/index.d.ts +87 -0
  30. package/dist/components/button-group/index.js +275 -0
  31. package/dist/components/button-group/index.js.map +1 -0
  32. package/dist/components/calendar/index.d.ts +11 -3
  33. package/dist/components/calendar/index.js +60 -45
  34. package/dist/components/calendar/index.js.map +1 -1
  35. package/dist/components/carousel/index.d.ts +72 -0
  36. package/dist/components/carousel/index.js +496 -0
  37. package/dist/components/carousel/index.js.map +1 -0
  38. package/dist/components/checkbox-group/index.d.ts +3 -4
  39. package/dist/components/checkbox-group/index.js +1 -1
  40. package/dist/components/checkbox-group/index.js.map +1 -1
  41. package/dist/components/color-area/index.d.ts +85 -0
  42. package/dist/components/color-area/index.js +630 -0
  43. package/dist/components/color-area/index.js.map +1 -0
  44. package/dist/components/color-field/index.d.ts +144 -0
  45. package/dist/components/color-field/index.js +516 -0
  46. package/dist/components/color-field/index.js.map +1 -0
  47. package/dist/components/color-picker/index.d.ts +74 -0
  48. package/dist/components/color-picker/index.js +317 -0
  49. package/dist/components/color-picker/index.js.map +1 -0
  50. package/dist/components/color-slider/index.d.ts +82 -0
  51. package/dist/components/color-slider/index.js +456 -0
  52. package/dist/components/color-slider/index.js.map +1 -0
  53. package/dist/components/color-swatch/index.d.ts +46 -0
  54. package/dist/components/color-swatch/index.js +127 -0
  55. package/dist/components/color-swatch/index.js.map +1 -0
  56. package/dist/components/color-swatch-picker/index.d.ts +81 -0
  57. package/dist/components/color-swatch-picker/index.js +287 -0
  58. package/dist/components/color-swatch-picker/index.js.map +1 -0
  59. package/dist/components/color-wheel/index.d.ts +71 -0
  60. package/dist/components/color-wheel/index.js +407 -0
  61. package/dist/components/color-wheel/index.js.map +1 -0
  62. package/dist/components/combo-box/index.d.ts +193 -0
  63. package/dist/components/combo-box/index.js +616 -0
  64. package/dist/components/combo-box/index.js.map +1 -0
  65. package/dist/components/date-field/index.d.ts +120 -0
  66. package/dist/components/date-field/index.js +111 -0
  67. package/dist/components/date-field/index.js.map +1 -0
  68. package/dist/components/date-picker/index.d.ts +130 -0
  69. package/dist/components/date-picker/index.js +310 -0
  70. package/dist/components/date-picker/index.js.map +1 -0
  71. package/dist/components/date-range-picker/index.d.ts +139 -0
  72. package/dist/components/date-range-picker/index.js +421 -0
  73. package/dist/components/date-range-picker/index.js.map +1 -0
  74. package/dist/components/disclosure/index.d.ts +94 -0
  75. package/dist/components/disclosure/index.js +365 -0
  76. package/dist/components/disclosure/index.js.map +1 -0
  77. package/dist/components/disclosure-group/index.d.ts +61 -0
  78. package/dist/components/disclosure-group/index.js +100 -0
  79. package/dist/components/disclosure-group/index.js.map +1 -0
  80. package/dist/components/drop-zone/index.d.ts +113 -0
  81. package/dist/components/drop-zone/index.js +304 -0
  82. package/dist/components/drop-zone/index.js.map +1 -0
  83. package/dist/components/fab/index.d.ts +1 -1
  84. package/dist/components/fab/index.js +91 -76
  85. package/dist/components/fab/index.js.map +1 -1
  86. package/dist/components/form/index.d.ts +3 -2
  87. package/dist/components/form/index.js.map +1 -1
  88. package/dist/components/icon-button/index.d.ts +4 -2
  89. package/dist/components/icon-button/index.js +204 -171
  90. package/dist/components/icon-button/index.js.map +1 -1
  91. package/dist/components/list/index.d.ts +15 -158
  92. package/dist/components/list/index.js +21 -1047
  93. package/dist/components/list/index.js.map +1 -1
  94. package/dist/components/list-box/index.d.ts +73 -0
  95. package/dist/components/list-box/index.js +82 -0
  96. package/dist/components/list-box/index.js.map +1 -0
  97. package/dist/components/loading-indicator/index.d.ts +32 -0
  98. package/dist/components/loading-indicator/index.js +174 -0
  99. package/dist/components/loading-indicator/index.js.map +1 -0
  100. package/dist/components/navigation-tree/index.d.ts +117 -0
  101. package/dist/components/navigation-tree/index.js +135 -0
  102. package/dist/components/navigation-tree/index.js.map +1 -0
  103. package/dist/components/number-field/index.js +132 -143
  104. package/dist/components/number-field/index.js.map +1 -1
  105. package/dist/components/range-calendar/index.d.ts +69 -0
  106. package/dist/components/range-calendar/index.js +144 -0
  107. package/dist/components/range-calendar/index.js.map +1 -0
  108. package/dist/components/search-view/index.d.ts +78 -0
  109. package/dist/components/search-view/index.js +570 -0
  110. package/dist/components/search-view/index.js.map +1 -0
  111. package/dist/components/select/index.d.ts +152 -0
  112. package/dist/components/select/index.js +419 -0
  113. package/dist/components/select/index.js.map +1 -0
  114. package/dist/components/slider/index.d.ts +111 -0
  115. package/dist/components/slider/index.js +673 -0
  116. package/dist/components/slider/index.js.map +1 -0
  117. package/dist/components/split-button/index.d.ts +77 -0
  118. package/dist/components/split-button/index.js +354 -0
  119. package/dist/components/split-button/index.js.map +1 -0
  120. package/dist/components/tabs/index.d.ts +196 -0
  121. package/dist/components/tabs/index.js +1137 -0
  122. package/dist/components/tabs/index.js.map +1 -0
  123. package/dist/components/time-field/index.d.ts +43 -0
  124. package/dist/components/time-field/index.js +107 -0
  125. package/dist/components/time-field/index.js.map +1 -0
  126. package/dist/components/time-picker/index.d.ts +65 -0
  127. package/dist/components/time-picker/index.js +1168 -0
  128. package/dist/components/time-picker/index.js.map +1 -0
  129. package/dist/components/tooltip/index.d.ts +101 -0
  130. package/dist/components/tooltip/index.js +223 -0
  131. package/dist/components/tooltip/index.js.map +1 -0
  132. package/dist/components/tree/index.d.ts +112 -0
  133. package/dist/components/tree/index.js +157 -0
  134. package/dist/components/tree/index.js.map +1 -0
  135. package/dist/disclosure/chevron.js +75 -0
  136. package/dist/disclosure/chevron.js.map +1 -0
  137. package/dist/disclosure/index.js +7 -0
  138. package/dist/disclosure/index.js.map +1 -0
  139. package/dist/drop/index.d.ts +54 -0
  140. package/dist/drop/index.js +161 -0
  141. package/dist/drop/index.js.map +1 -0
  142. package/dist/field/chevron.js +74 -0
  143. package/dist/field/chevron.js.map +1 -0
  144. package/dist/field/index.d.ts +2 -1
  145. package/dist/field/index.js +310 -154
  146. package/dist/field/index.js.map +1 -1
  147. package/dist/field/styles.js +9 -0
  148. package/dist/field/styles.js.map +1 -1
  149. package/dist/files/index.d.ts +18 -0
  150. package/dist/files/index.js +107 -0
  151. package/dist/files/index.js.map +1 -0
  152. package/dist/form/index.d.ts +5 -2
  153. package/dist/form/index.js +64 -85
  154. package/dist/form/index.js.map +1 -1
  155. package/dist/glyphs/index.js +92 -1
  156. package/dist/glyphs/index.js.map +1 -1
  157. package/dist/i18n/index.js +20 -1
  158. package/dist/i18n/index.js.map +1 -1
  159. package/dist/i18n/messages.js +1394 -34
  160. package/dist/i18n/messages.js.map +1 -1
  161. package/dist/index.d.ts +35 -3
  162. package/dist/index.js +34 -3
  163. package/dist/indicator/paths.js +23 -1
  164. package/dist/indicator/paths.js.map +1 -1
  165. package/dist/modal/index.js +92 -77
  166. package/dist/modal/index.js.map +1 -1
  167. package/dist/number/keyboard.js +16 -0
  168. package/dist/number/keyboard.js.map +1 -0
  169. package/dist/overlay/anchored.js +68 -38
  170. package/dist/overlay/anchored.js.map +1 -1
  171. package/dist/overlay/keyboard.js +57 -0
  172. package/dist/overlay/keyboard.js.map +1 -0
  173. package/dist/overlay/panel.js +173 -19
  174. package/dist/overlay/panel.js.map +1 -1
  175. package/dist/overlay/placement.js +13 -1
  176. package/dist/overlay/placement.js.map +1 -1
  177. package/dist/picker/index.js +322 -0
  178. package/dist/picker/index.js.map +1 -0
  179. package/dist/press/index.d.ts +2 -0
  180. package/dist/press/index.js +102 -100
  181. package/dist/press/index.js.map +1 -1
  182. package/dist/row/index.js +77 -69
  183. package/dist/row/index.js.map +1 -1
  184. package/dist/row/styles.js +13 -2
  185. package/dist/row/styles.js.map +1 -1
  186. package/dist/segments/field.js +277 -0
  187. package/dist/segments/field.js.map +1 -0
  188. package/dist/segments/index.js +574 -0
  189. package/dist/segments/index.js.map +1 -0
  190. package/dist/segments/styles.js +24 -0
  191. package/dist/segments/styles.js.map +1 -0
  192. package/dist/slider/index.js +145 -0
  193. package/dist/slider/index.js.map +1 -0
  194. package/dist/swatch/index.js +56 -0
  195. package/dist/swatch/index.js.map +1 -0
  196. package/package.json +11 -2
@@ -0,0 +1,616 @@
1
+ import { useTheme } from "../../theme/scope.js";
2
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
3
+ import { hitSlop, usePressFeedback } from "../../press/index.js";
4
+ import { containsIn } from "../../autocomplete/index.js";
5
+ import { listFor } from "../../i18n/index.js";
6
+ import { useLocaleOf, useMessages } from "../../i18n/provider.js";
7
+ import { useFieldValidation } from "../../form/index.js";
8
+ import { DismissLayer, PANEL_ORIGINS, useBackToClose, useFocusOnPlaced, usePanelMotion, useReturnFocus } from "../../overlay/panel.js";
9
+ import { FieldChevron } from "../../field/chevron.js";
10
+ import { FieldBox, FieldInput, FieldMessage, describedBy, useFieldFocus } from "../../field/index.js";
11
+ import { Overlay } from "../../overlay/host.js";
12
+ import { useAnchoredPlacement } from "../../overlay/anchored.js";
13
+ import { CollectionView, ResultsStatus, focusKeyOf, rowCountOf } from "../../collection/index.js";
14
+ import { c } from "react/compiler-runtime";
15
+ import { Platform, Pressable, StyleSheet, View } from "react-native";
16
+ import Animated from "react-native-reanimated";
17
+ import { useId, useImperativeHandle, useRef, useState } from "react";
18
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
19
+ import { useComboBoxState } from "react-stately/useComboBoxState";
20
+ //#region src/components/combo-box/index.tsx
21
+ const TOGGLE_SIZE = 24;
22
+ const TOGGLE_SLOP = hitSlop(TOGGLE_SIZE, TOGGLE_SIZE);
23
+ const SHRINKS = { flexGrow: 0 };
24
+ const stylesOf = themedStyles(({ colors, radii, shadows }) => StyleSheet.create({
25
+ list: {
26
+ backgroundColor: colors.surfaceContainerLow,
27
+ borderRadius: radii.xs,
28
+ boxShadow: shadows.elevation2,
29
+ overflow: "hidden"
30
+ },
31
+ toggle: {
32
+ alignItems: "center",
33
+ borderRadius: radii.circle,
34
+ height: TOGGLE_SIZE,
35
+ justifyContent: "center",
36
+ width: TOGGLE_SIZE
37
+ }
38
+ }));
39
+ /**
40
+ * A labelled text field that filters a list of options as it is typed. Its
41
+ * value is React Stately's: pass `value` with `onChange` to hold which
42
+ * option is chosen, `inputValue` with `onInputChange` to hold the text, or
43
+ * the `default` forms of either to let it keep its own. The value is an
44
+ * option's `id`, so give every option one; with `selectionMode="multiple"`
45
+ * it is a list of them.
46
+ *
47
+ * ```tsx
48
+ * <ComboBox
49
+ * label="Label"
50
+ * options={[
51
+ * <ListBox.Item id="first" key="first">First item</ListBox.Item>,
52
+ * <ListBox.Item id="second" key="second">Second item</ListBox.Item>,
53
+ * ]}
54
+ * />
55
+ * ```
56
+ *
57
+ * The box, the label, the input, the supporting line and the error are the
58
+ * field chrome every field here draws; the list is a ListBox's, on the
59
+ * surface every anchored panel here draws. `style` and `ref` are the field
60
+ * as a whole, and `inputRef` and `testID` its `TextInput`.
61
+ */
62
+ function ComboBox(t0) {
63
+ const $ = c(92);
64
+ const { allowsCustomValue: t1, allowsEmptyCollection, defaultFilter, defaultInputValue, defaultItems, defaultValue, description, disabledKeys, error, floatingLabel: t2, formValue: t3, inputRef, inputValue, isDisabled: t4, isReadOnly: t5, isRequired: t6, items, label, leadingIcon, menuTrigger, name, onChange, onInputChange, onOpenChange, options, ref, selectionMode, style, testID, validate, value, variant: t7 } = t0;
65
+ const allowsCustomValue = t1 === void 0 ? false : t1;
66
+ const floatingLabel = t2 === void 0 ? true : t2;
67
+ const formValue = t3 === void 0 ? "key" : t3;
68
+ const isDisabled = t4 === void 0 ? false : t4;
69
+ const isReadOnly = t5 === void 0 ? false : t5;
70
+ const isRequired = t6 === void 0 ? false : t6;
71
+ const variant = t7 === void 0 ? "filled" : t7;
72
+ const id = useId();
73
+ const box = useRef(null);
74
+ const control = useRef(null);
75
+ const [openedBy, setOpenedBy] = useState();
76
+ const messages = useMessages();
77
+ const locale = useLocaleOf(void 0);
78
+ const state = useComboBoxState({
79
+ allowsCustomValue,
80
+ allowsEmptyCollection,
81
+ children: options,
82
+ defaultFilter: defaultFilter ?? containsIn(locale),
83
+ defaultInputValue,
84
+ defaultItems,
85
+ defaultValue,
86
+ disabledKeys,
87
+ inputValue,
88
+ isDisabled,
89
+ isReadOnly,
90
+ items,
91
+ menuTrigger,
92
+ onChange: (changed) => {
93
+ validation.onEdit();
94
+ validation.onBlur();
95
+ onChange?.(changed);
96
+ },
97
+ onInputChange,
98
+ onOpenChange: (isOpen, trigger) => {
99
+ if (isOpen) setOpenedBy(trigger);
100
+ if (isOpen && trigger === "manual") control.current?.focus();
101
+ onOpenChange?.(isOpen, trigger);
102
+ },
103
+ selectionMode,
104
+ shouldCloseOnBlur: Platform.OS !== "web",
105
+ value
106
+ });
107
+ let chosen;
108
+ let several;
109
+ let t10;
110
+ let t11;
111
+ let t12;
112
+ let t13;
113
+ let t14;
114
+ let t15;
115
+ let t16;
116
+ let t8;
117
+ let t9;
118
+ if ($[0] !== allowsCustomValue || $[1] !== error || $[2] !== formValue || $[3] !== isDisabled || $[4] !== isReadOnly || $[5] !== isRequired || $[6] !== name || $[7] !== state.inputValue || $[8] !== state.selectionManager.selectionMode || $[9] !== state.value) {
119
+ chosen = keysOf(state.value);
120
+ several = state.selectionManager.selectionMode === "multiple";
121
+ const submitsText = !several && (allowsCustomValue || formValue === "text");
122
+ t16 = useFieldValidation;
123
+ t8 = control;
124
+ t9 = error;
125
+ t10 = isDisabled;
126
+ t11 = submitsText ? state.inputValue === "" : chosen.length === 0;
127
+ t12 = isReadOnly;
128
+ t13 = isRequired;
129
+ t14 = name;
130
+ t15 = several ? chosen.map(String) : submitsText ? state.inputValue : String(chosen[0] ?? "");
131
+ $[0] = allowsCustomValue;
132
+ $[1] = error;
133
+ $[2] = formValue;
134
+ $[3] = isDisabled;
135
+ $[4] = isReadOnly;
136
+ $[5] = isRequired;
137
+ $[6] = name;
138
+ $[7] = state.inputValue;
139
+ $[8] = state.selectionManager.selectionMode;
140
+ $[9] = state.value;
141
+ $[10] = chosen;
142
+ $[11] = several;
143
+ $[12] = t10;
144
+ $[13] = t11;
145
+ $[14] = t12;
146
+ $[15] = t13;
147
+ $[16] = t14;
148
+ $[17] = t15;
149
+ $[18] = t16;
150
+ $[19] = t8;
151
+ $[20] = t9;
152
+ } else {
153
+ chosen = $[10];
154
+ several = $[11];
155
+ t10 = $[12];
156
+ t11 = $[13];
157
+ t12 = $[14];
158
+ t13 = $[15];
159
+ t14 = $[16];
160
+ t15 = $[17];
161
+ t16 = $[18];
162
+ t8 = $[19];
163
+ t9 = $[20];
164
+ }
165
+ let t17;
166
+ if ($[21] !== state) {
167
+ t17 = validationValueOf(state);
168
+ $[21] = state;
169
+ $[22] = t17;
170
+ } else t17 = $[22];
171
+ let t18;
172
+ if ($[23] !== t10 || $[24] !== t11 || $[25] !== t12 || $[26] !== t13 || $[27] !== t14 || $[28] !== t15 || $[29] !== t17 || $[30] !== t8 || $[31] !== t9 || $[32] !== validate) {
173
+ t18 = {
174
+ control: t8,
175
+ error: t9,
176
+ isDisabled: t10,
177
+ isEmpty: t11,
178
+ isReadOnly: t12,
179
+ isRequired: t13,
180
+ name: t14,
181
+ submitted: t15,
182
+ validate,
183
+ value: t17
184
+ };
185
+ $[23] = t10;
186
+ $[24] = t11;
187
+ $[25] = t12;
188
+ $[26] = t13;
189
+ $[27] = t14;
190
+ $[28] = t15;
191
+ $[29] = t17;
192
+ $[30] = t8;
193
+ $[31] = t9;
194
+ $[32] = validate;
195
+ $[33] = t18;
196
+ } else t18 = $[33];
197
+ const validation = t16(t18);
198
+ let t19;
199
+ if ($[34] !== state) {
200
+ t19 = () => {
201
+ state.setFocused(true);
202
+ };
203
+ $[34] = state;
204
+ $[35] = t19;
205
+ } else t19 = $[35];
206
+ const focus = useFieldFocus({
207
+ onBlur: () => {
208
+ state.setFocused(false);
209
+ validation.onBlur();
210
+ },
211
+ onFocus: t19
212
+ });
213
+ const shownError = validation.error;
214
+ let t20;
215
+ let t21;
216
+ if ($[36] === Symbol.for("react.memo_cache_sentinel")) {
217
+ t20 = () => control.current;
218
+ t21 = [];
219
+ $[36] = t20;
220
+ $[37] = t21;
221
+ } else {
222
+ t20 = $[36];
223
+ t21 = $[37];
224
+ }
225
+ useImperativeHandle(inputRef, t20, t21);
226
+ const T0 = View;
227
+ const T1 = FieldBox;
228
+ const t22 = focus.focused || state.isOpen;
229
+ const t23 = shownError !== void 0;
230
+ const t24 = state.inputValue !== "" || several && chosen.length > 0;
231
+ const t25 = isDisabled || isReadOnly;
232
+ const t26 = `${messages.showSuggestions} ${label}`;
233
+ let t27;
234
+ if ($[38] !== state) {
235
+ t27 = () => {
236
+ state.toggle(null, "manual");
237
+ };
238
+ $[38] = state;
239
+ $[39] = t27;
240
+ } else t27 = $[39];
241
+ let t28;
242
+ if ($[40] !== state || $[41] !== t25 || $[42] !== t26 || $[43] !== t27) {
243
+ t28 = toggleFor(state, {
244
+ isDisabled: t25,
245
+ label: t26,
246
+ onPress: t27
247
+ });
248
+ $[40] = state;
249
+ $[41] = t25;
250
+ $[42] = t26;
251
+ $[43] = t27;
252
+ $[44] = t28;
253
+ } else t28 = $[44];
254
+ const T2 = FieldInput;
255
+ const t29 = focus.handlers;
256
+ let t30;
257
+ if ($[45] !== locale || $[46] !== several || $[47] !== state.selectedItems) {
258
+ t30 = several ? listFor(state.selectedItems.map(_temp), locale) : void 0;
259
+ $[45] = locale;
260
+ $[46] = several;
261
+ $[47] = state.selectedItems;
262
+ $[48] = t30;
263
+ } else t30 = $[48];
264
+ const t31 = describedBy(id, {
265
+ description,
266
+ error: shownError
267
+ });
268
+ const t32 = !isDisabled && !isReadOnly;
269
+ const t33 = editOf(state, validation.onEdit);
270
+ let t34;
271
+ if ($[49] !== T2 || $[50] !== focus.handlers || $[51] !== label || $[52] !== state.inputValue || $[53] !== t30 || $[54] !== t31 || $[55] !== t32 || $[56] !== t33 || $[57] !== testID) {
272
+ t34 = /* @__PURE__ */ jsx(T2, {
273
+ ...t29,
274
+ "aria-label": label,
275
+ chosen: t30,
276
+ described: t31,
277
+ editable: t32,
278
+ onChangeText: t33,
279
+ ref: control,
280
+ testID,
281
+ value: state.inputValue
282
+ });
283
+ $[49] = T2;
284
+ $[50] = focus.handlers;
285
+ $[51] = label;
286
+ $[52] = state.inputValue;
287
+ $[53] = t30;
288
+ $[54] = t31;
289
+ $[55] = t32;
290
+ $[56] = t33;
291
+ $[57] = testID;
292
+ $[58] = t34;
293
+ } else t34 = $[58];
294
+ let t35;
295
+ if ($[59] !== T1 || $[60] !== floatingLabel || $[61] !== isDisabled || $[62] !== isRequired || $[63] !== label || $[64] !== leadingIcon || $[65] !== t22 || $[66] !== t23 || $[67] !== t24 || $[68] !== t28 || $[69] !== t34 || $[70] !== variant) {
296
+ t35 = /* @__PURE__ */ jsx(T1, {
297
+ control,
298
+ floatingLabel,
299
+ isDisabled,
300
+ isFocused: t22,
301
+ isInvalid: t23,
302
+ isPopulated: t24,
303
+ isRequired,
304
+ label,
305
+ leading: leadingIcon,
306
+ ref: box,
307
+ trailing: t28,
308
+ variant,
309
+ children: t34
310
+ });
311
+ $[59] = T1;
312
+ $[60] = floatingLabel;
313
+ $[61] = isDisabled;
314
+ $[62] = isRequired;
315
+ $[63] = label;
316
+ $[64] = leadingIcon;
317
+ $[65] = t22;
318
+ $[66] = t23;
319
+ $[67] = t24;
320
+ $[68] = t28;
321
+ $[69] = t34;
322
+ $[70] = variant;
323
+ $[71] = t35;
324
+ } else t35 = $[71];
325
+ let t36;
326
+ if ($[72] !== description || $[73] !== id || $[74] !== shownError) {
327
+ t36 = /* @__PURE__ */ jsx(FieldMessage, {
328
+ description,
329
+ error: shownError,
330
+ id
331
+ });
332
+ $[72] = description;
333
+ $[73] = id;
334
+ $[74] = shownError;
335
+ $[75] = t36;
336
+ } else t36 = $[75];
337
+ let t37;
338
+ if ($[76] !== state) {
339
+ t37 = state.isOpen ? rowCountOf(state) : null;
340
+ $[76] = state;
341
+ $[77] = t37;
342
+ } else t37 = $[77];
343
+ let t38;
344
+ if ($[78] !== t37) {
345
+ t38 = /* @__PURE__ */ jsx(ResultsStatus, { count: t37 });
346
+ $[78] = t37;
347
+ $[79] = t38;
348
+ } else t38 = $[79];
349
+ let t39;
350
+ if ($[80] !== label || $[81] !== openedBy || $[82] !== state) {
351
+ t39 = /* @__PURE__ */ jsx(ComboBoxPopup, {
352
+ anchor: box,
353
+ control,
354
+ label,
355
+ openedBy,
356
+ state
357
+ });
358
+ $[80] = label;
359
+ $[81] = openedBy;
360
+ $[82] = state;
361
+ $[83] = t39;
362
+ } else t39 = $[83];
363
+ let t40;
364
+ if ($[84] !== T0 || $[85] !== ref || $[86] !== style || $[87] !== t35 || $[88] !== t36 || $[89] !== t38 || $[90] !== t39) {
365
+ t40 = /* @__PURE__ */ jsxs(T0, {
366
+ ref,
367
+ style,
368
+ children: [
369
+ t35,
370
+ t36,
371
+ t38,
372
+ t39
373
+ ]
374
+ });
375
+ $[84] = T0;
376
+ $[85] = ref;
377
+ $[86] = style;
378
+ $[87] = t35;
379
+ $[88] = t36;
380
+ $[89] = t38;
381
+ $[90] = t39;
382
+ $[91] = t40;
383
+ } else t40 = $[91];
384
+ return t40;
385
+ }
386
+ /**
387
+ * The list, drawn in the overlay host above the screen and placed under the
388
+ * box: as wide as the box, flipped above it at the edge of the window, over
389
+ * a layer that closes it on a press anywhere but the list and the box.
390
+ */
391
+ function _temp(item) {
392
+ return item.textValue;
393
+ }
394
+ function ComboBoxList(t0) {
395
+ const $ = c(26);
396
+ const { anchor, control, isOpen, label, openedBy, setPresent, state } = t0;
397
+ const styles = stylesOf(useTheme());
398
+ const messages = useMessages();
399
+ let t1;
400
+ if ($[0] !== anchor) {
401
+ t1 = {
402
+ align: "start",
403
+ anchor
404
+ };
405
+ $[0] = anchor;
406
+ $[1] = t1;
407
+ } else t1 = $[1];
408
+ const placement = useAnchoredPlacement(t1);
409
+ const motion = usePanelMotion(isOpen, placement.placed, setPresent);
410
+ const [panel, setPanel] = useState(null);
411
+ const [option, setOption] = useState(null);
412
+ const sendsReader = openedBy === "manual";
413
+ const close = state.close;
414
+ useBackToClose(close, isOpen);
415
+ useFocusOnPlaced(sendsReader && isOpen && placement.placed, option ?? panel);
416
+ let t2;
417
+ if ($[2] !== close || $[3] !== control || $[4] !== isOpen || $[5] !== placement.anchorFrame) {
418
+ t2 = isOpen ? /* @__PURE__ */ jsx(DismissLayer, {
419
+ hole: placement.anchorFrame,
420
+ onPress: dismissOf(control, close)
421
+ }) : null;
422
+ $[2] = close;
423
+ $[3] = control;
424
+ $[4] = isOpen;
425
+ $[5] = placement.anchorFrame;
426
+ $[6] = t2;
427
+ } else t2 = $[6];
428
+ const t3 = Animated;
429
+ const t4 = placement.onLayout;
430
+ const t5 = composeStyles(styles.list, { width: placement.anchorWidth }, placement.style, { transformOrigin: PANEL_ORIGINS[placement.side] }, motion);
431
+ const t6 = `${messages.suggestions} ${label}`;
432
+ let t7;
433
+ if ($[7] !== sendsReader || $[8] !== state) {
434
+ t7 = sendsReader ? focusKeyOf(state) : null;
435
+ $[7] = sendsReader;
436
+ $[8] = state;
437
+ $[9] = t7;
438
+ } else t7 = $[9];
439
+ let t8;
440
+ if ($[10] !== placement.placed || $[11] !== setOption || $[12] !== state || $[13] !== t6 || $[14] !== t7) {
441
+ t8 = /* @__PURE__ */ jsx(CollectionView, {
442
+ "aria-label": t6,
443
+ focusKey: t7,
444
+ keyboardShouldPersistTaps: "handled",
445
+ kind: "listbox",
446
+ onFocusTarget: setOption,
447
+ revealFocus: placement.placed,
448
+ state,
449
+ style: SHRINKS
450
+ });
451
+ $[10] = placement.placed;
452
+ $[11] = setOption;
453
+ $[12] = state;
454
+ $[13] = t6;
455
+ $[14] = t7;
456
+ $[15] = t8;
457
+ } else t8 = $[15];
458
+ let t9;
459
+ if ($[16] !== close || $[17] !== placement.onLayout || $[18] !== setPanel || $[19] !== t3.View || $[20] !== t5 || $[21] !== t8) {
460
+ t9 = /* @__PURE__ */ jsx(t3.View, {
461
+ onAccessibilityEscape: close,
462
+ onLayout: t4,
463
+ ref: setPanel,
464
+ style: t5,
465
+ children: t8
466
+ });
467
+ $[16] = close;
468
+ $[17] = placement.onLayout;
469
+ $[18] = setPanel;
470
+ $[19] = t3.View;
471
+ $[20] = t5;
472
+ $[21] = t8;
473
+ $[22] = t9;
474
+ } else t9 = $[22];
475
+ let t10;
476
+ if ($[23] !== t2 || $[24] !== t9) {
477
+ t10 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t2, t9] });
478
+ $[23] = t2;
479
+ $[24] = t9;
480
+ $[25] = t10;
481
+ } else t10 = $[25];
482
+ return t10;
483
+ }
484
+ /**
485
+ * The list while it is open and while its exit runs: mounted the moment the
486
+ * field opens it, and kept until the list has faded out. A screen reader the
487
+ * chevron sent into the list goes back to the input once it has gone.
488
+ */
489
+ function ComboBoxPopup(t0) {
490
+ const $ = c(6);
491
+ const { anchor, control, label, openedBy, state } = t0;
492
+ const [present, setPresent] = useState(state.isOpen);
493
+ if (state.isOpen && !present) setPresent(true);
494
+ useReturnFocus(present, openedBy !== "manual", control);
495
+ if (!present) return null;
496
+ let t1;
497
+ if ($[0] !== anchor || $[1] !== control || $[2] !== label || $[3] !== openedBy || $[4] !== state) {
498
+ t1 = /* @__PURE__ */ jsx(Overlay, { children: /* @__PURE__ */ jsx(ComboBoxList, {
499
+ anchor,
500
+ control,
501
+ isOpen: state.isOpen,
502
+ label,
503
+ openedBy,
504
+ setPresent,
505
+ state
506
+ }) });
507
+ $[0] = anchor;
508
+ $[1] = control;
509
+ $[2] = label;
510
+ $[3] = openedBy;
511
+ $[4] = state;
512
+ $[5] = t1;
513
+ } else t1 = $[5];
514
+ return t1;
515
+ }
516
+ function copyOf(value) {
517
+ return typeof value === "object" && value !== null ? [...value] : value;
518
+ }
519
+ function dismissOf(control, close) {
520
+ return () => {
521
+ control.current?.blur();
522
+ close();
523
+ };
524
+ }
525
+ function editOf(state, onEdit) {
526
+ return (text) => {
527
+ state.setInputValue(text);
528
+ onEdit();
529
+ };
530
+ }
531
+ function keysOf(value) {
532
+ if (value === null) return [];
533
+ return typeof value === "object" ? value : [value];
534
+ }
535
+ /**
536
+ * The chevron as the button opening the list, named in React Aria's words
537
+ * before the field's label, saying whether the list is open, and drawing the
538
+ * ring a keyboard's focus draws. It takes its colour from the box's trailing
539
+ * slot, so it follows the field into its error and disabled states.
540
+ */
541
+ function Toggle(t0) {
542
+ const $ = c(12);
543
+ const { isDisabled, isOpen, label, onPress } = t0;
544
+ const theme = useTheme();
545
+ const styles = stylesOf(theme);
546
+ const feedback = usePressFeedback({
547
+ color: theme.colors.onSurfaceVariant,
548
+ corners: styles.toggle,
549
+ disabled: isDisabled,
550
+ disableRipple: true
551
+ });
552
+ const T0 = Pressable;
553
+ const t1 = feedback.handlers;
554
+ const t2 = TOGGLE_SLOP;
555
+ const t3 = "button";
556
+ const t4 = composeStyles(styles.toggle, feedback.ring);
557
+ let t5;
558
+ if ($[0] !== isOpen) {
559
+ t5 = /* @__PURE__ */ jsx(FieldChevron, { isOpen });
560
+ $[0] = isOpen;
561
+ $[1] = t5;
562
+ } else t5 = $[1];
563
+ let t6;
564
+ if ($[2] !== T0 || $[3] !== feedback.handlers || $[4] !== isDisabled || $[5] !== isOpen || $[6] !== label || $[7] !== onPress || $[8] !== t2 || $[9] !== t4 || $[10] !== t5) {
565
+ t6 = /* @__PURE__ */ jsx(T0, {
566
+ ...t1,
567
+ "aria-expanded": isOpen,
568
+ "aria-label": label,
569
+ disabled: isDisabled,
570
+ hitSlop: t2,
571
+ onPress,
572
+ role: t3,
573
+ style: t4,
574
+ children: t5
575
+ });
576
+ $[2] = T0;
577
+ $[3] = feedback.handlers;
578
+ $[4] = isDisabled;
579
+ $[5] = isOpen;
580
+ $[6] = label;
581
+ $[7] = onPress;
582
+ $[8] = t2;
583
+ $[9] = t4;
584
+ $[10] = t5;
585
+ $[11] = t6;
586
+ } else t6 = $[11];
587
+ return t6;
588
+ }
589
+ /**
590
+ * The chevron button for the box's trailing slot, which opens the list with
591
+ * every option in it, whatever has been typed, as web's does, and closes it
592
+ * again. A call rather than JSX written at the prop, which is what
593
+ * react-perf's jsx-no-jsx-as-prop is after.
594
+ */
595
+ function toggleFor(state, props) {
596
+ return /* @__PURE__ */ jsx(Toggle, {
597
+ ...props,
598
+ isOpen: state.isOpen
599
+ });
600
+ }
601
+ /**
602
+ * What `validate` is handed, as React Aria's ComboBox hands it on web: the
603
+ * text in the field and what is chosen, with the first chosen option's `id`
604
+ * under the older name.
605
+ */
606
+ function validationValueOf(state) {
607
+ return {
608
+ inputValue: state.inputValue,
609
+ selectedKey: state.selectedKey,
610
+ value: copyOf(state.value)
611
+ };
612
+ }
613
+ //#endregion
614
+ export { ComboBox };
615
+
616
+ //# sourceMappingURL=index.js.map