@kanso-labs/react-native-kanso-ui 0.8.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 (253) 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/badge/index.js +9 -70
  5. package/dist/badge/index.js.map +1 -1
  6. package/dist/button/group.d.ts +5 -0
  7. package/dist/button/group.js +115 -0
  8. package/dist/button/group.js.map +1 -0
  9. package/dist/button/index.d.ts +4 -1
  10. package/dist/button/index.js +45 -23
  11. package/dist/button/index.js.map +1 -1
  12. package/dist/button/palettes.d.ts +2 -0
  13. package/dist/button/slots.js +2 -1
  14. package/dist/button/slots.js.map +1 -1
  15. package/dist/calendar/index.js +351 -182
  16. package/dist/calendar/index.js.map +1 -1
  17. package/dist/calendar/styles.js +33 -2
  18. package/dist/calendar/styles.js.map +1 -1
  19. package/dist/carousel/arrangement.d.ts +5 -0
  20. package/dist/carousel/arrangement.js +123 -0
  21. package/dist/carousel/arrangement.js.map +1 -0
  22. package/dist/chequer/index.js +95 -0
  23. package/dist/chequer/index.js.map +1 -0
  24. package/dist/collection/index.d.ts +157 -0
  25. package/dist/collection/index.js +1331 -0
  26. package/dist/collection/index.js.map +1 -0
  27. package/dist/color-thumb/index.js +56 -0
  28. package/dist/color-thumb/index.js.map +1 -0
  29. package/dist/components/badge/index.d.ts +48 -0
  30. package/dist/components/badge/index.js +122 -0
  31. package/dist/components/badge/index.js.map +1 -0
  32. package/dist/{badge → components/badge}/styles.js +10 -6
  33. package/dist/components/badge/styles.js.map +1 -0
  34. package/dist/components/breadcrumbs/index.d.ts +66 -0
  35. package/dist/components/breadcrumbs/index.js +285 -0
  36. package/dist/components/breadcrumbs/index.js.map +1 -0
  37. package/dist/components/button/index.d.ts +4 -2
  38. package/dist/components/button/index.js +227 -188
  39. package/dist/components/button/index.js.map +1 -1
  40. package/dist/components/button-group/index.d.ts +87 -0
  41. package/dist/components/button-group/index.js +275 -0
  42. package/dist/components/button-group/index.js.map +1 -0
  43. package/dist/components/calendar/index.d.ts +11 -3
  44. package/dist/components/calendar/index.js +60 -45
  45. package/dist/components/calendar/index.js.map +1 -1
  46. package/dist/components/carousel/index.d.ts +72 -0
  47. package/dist/components/carousel/index.js +496 -0
  48. package/dist/components/carousel/index.js.map +1 -0
  49. package/dist/components/checkbox/index.d.ts +7 -1
  50. package/dist/components/checkbox/index.js +183 -138
  51. package/dist/components/checkbox/index.js.map +1 -1
  52. package/dist/components/checkbox-group/index.d.ts +92 -0
  53. package/dist/components/checkbox-group/index.js +306 -0
  54. package/dist/components/checkbox-group/index.js.map +1 -0
  55. package/dist/components/code/index.d.ts +25 -0
  56. package/dist/components/code/index.js +87 -0
  57. package/dist/components/code/index.js.map +1 -0
  58. package/dist/components/color-area/index.d.ts +85 -0
  59. package/dist/components/color-area/index.js +630 -0
  60. package/dist/components/color-area/index.js.map +1 -0
  61. package/dist/components/color-field/index.d.ts +144 -0
  62. package/dist/components/color-field/index.js +516 -0
  63. package/dist/components/color-field/index.js.map +1 -0
  64. package/dist/components/color-picker/index.d.ts +74 -0
  65. package/dist/components/color-picker/index.js +317 -0
  66. package/dist/components/color-picker/index.js.map +1 -0
  67. package/dist/components/color-slider/index.d.ts +82 -0
  68. package/dist/components/color-slider/index.js +456 -0
  69. package/dist/components/color-slider/index.js.map +1 -0
  70. package/dist/components/color-swatch/index.d.ts +46 -0
  71. package/dist/components/color-swatch/index.js +127 -0
  72. package/dist/components/color-swatch/index.js.map +1 -0
  73. package/dist/components/color-swatch-picker/index.d.ts +81 -0
  74. package/dist/components/color-swatch-picker/index.js +287 -0
  75. package/dist/components/color-swatch-picker/index.js.map +1 -0
  76. package/dist/components/color-wheel/index.d.ts +71 -0
  77. package/dist/components/color-wheel/index.js +407 -0
  78. package/dist/components/color-wheel/index.js.map +1 -0
  79. package/dist/components/combo-box/index.d.ts +193 -0
  80. package/dist/components/combo-box/index.js +616 -0
  81. package/dist/components/combo-box/index.js.map +1 -0
  82. package/dist/components/container/index.d.ts +47 -0
  83. package/dist/components/container/index.js +85 -0
  84. package/dist/components/container/index.js.map +1 -0
  85. package/dist/components/date-field/index.d.ts +120 -0
  86. package/dist/components/date-field/index.js +111 -0
  87. package/dist/components/date-field/index.js.map +1 -0
  88. package/dist/components/date-picker/index.d.ts +130 -0
  89. package/dist/components/date-picker/index.js +310 -0
  90. package/dist/components/date-picker/index.js.map +1 -0
  91. package/dist/components/date-range-picker/index.d.ts +139 -0
  92. package/dist/components/date-range-picker/index.js +421 -0
  93. package/dist/components/date-range-picker/index.js.map +1 -0
  94. package/dist/components/disclosure/index.d.ts +94 -0
  95. package/dist/components/disclosure/index.js +365 -0
  96. package/dist/components/disclosure/index.js.map +1 -0
  97. package/dist/components/disclosure-group/index.d.ts +61 -0
  98. package/dist/components/disclosure-group/index.js +100 -0
  99. package/dist/components/disclosure-group/index.js.map +1 -0
  100. package/dist/components/drop-zone/index.d.ts +113 -0
  101. package/dist/components/drop-zone/index.js +304 -0
  102. package/dist/components/drop-zone/index.js.map +1 -0
  103. package/dist/components/fab/index.d.ts +80 -0
  104. package/dist/components/fab/index.js +246 -0
  105. package/dist/components/fab/index.js.map +1 -0
  106. package/dist/components/fab-menu/index.d.ts +120 -0
  107. package/dist/components/fab-menu/index.js +640 -0
  108. package/dist/components/fab-menu/index.js.map +1 -0
  109. package/dist/components/feed/index.d.ts +57 -0
  110. package/dist/components/feed/index.js +167 -0
  111. package/dist/components/feed/index.js.map +1 -0
  112. package/dist/components/form/index.d.ts +3 -2
  113. package/dist/components/form/index.js.map +1 -1
  114. package/dist/components/icon-button/index.d.ts +4 -2
  115. package/dist/components/icon-button/index.js +204 -171
  116. package/dist/components/icon-button/index.js.map +1 -1
  117. package/dist/components/keycap/index.d.ts +27 -0
  118. package/dist/components/keycap/index.js +136 -0
  119. package/dist/components/keycap/index.js.map +1 -0
  120. package/dist/components/list/index.d.ts +15 -158
  121. package/dist/components/list/index.js +21 -1047
  122. package/dist/components/list/index.js.map +1 -1
  123. package/dist/components/list-box/index.d.ts +73 -0
  124. package/dist/components/list-box/index.js +82 -0
  125. package/dist/components/list-box/index.js.map +1 -0
  126. package/dist/components/loading-indicator/index.d.ts +32 -0
  127. package/dist/components/loading-indicator/index.js +174 -0
  128. package/dist/components/loading-indicator/index.js.map +1 -0
  129. package/dist/components/menu/index.js +1 -1
  130. package/dist/components/navigation-tree/index.d.ts +117 -0
  131. package/dist/components/navigation-tree/index.js +135 -0
  132. package/dist/components/navigation-tree/index.js.map +1 -0
  133. package/dist/components/number-field/index.js +132 -143
  134. package/dist/components/number-field/index.js.map +1 -1
  135. package/dist/components/range-calendar/index.d.ts +69 -0
  136. package/dist/components/range-calendar/index.js +144 -0
  137. package/dist/components/range-calendar/index.js.map +1 -0
  138. package/dist/components/search-view/index.d.ts +78 -0
  139. package/dist/components/search-view/index.js +570 -0
  140. package/dist/components/search-view/index.js.map +1 -0
  141. package/dist/components/select/index.d.ts +152 -0
  142. package/dist/components/select/index.js +419 -0
  143. package/dist/components/select/index.js.map +1 -0
  144. package/dist/components/separator/index.d.ts +3 -2
  145. package/dist/components/separator/index.js +29 -26
  146. package/dist/components/separator/index.js.map +1 -1
  147. package/dist/components/slider/index.d.ts +111 -0
  148. package/dist/components/slider/index.js +673 -0
  149. package/dist/components/slider/index.js.map +1 -0
  150. package/dist/components/split-button/index.d.ts +77 -0
  151. package/dist/components/split-button/index.js +354 -0
  152. package/dist/components/split-button/index.js.map +1 -0
  153. package/dist/components/supporting-pane/index.d.ts +44 -0
  154. package/dist/components/supporting-pane/index.js +109 -0
  155. package/dist/components/supporting-pane/index.js.map +1 -0
  156. package/dist/components/tabs/index.d.ts +196 -0
  157. package/dist/components/tabs/index.js +1137 -0
  158. package/dist/components/tabs/index.js.map +1 -0
  159. package/dist/components/text/index.d.ts +1 -1
  160. package/dist/components/text/index.js +49 -21
  161. package/dist/components/text/index.js.map +1 -1
  162. package/dist/components/text-area/index.d.ts +145 -0
  163. package/dist/components/text-area/index.js +231 -0
  164. package/dist/components/text-area/index.js.map +1 -0
  165. package/dist/components/time-field/index.d.ts +43 -0
  166. package/dist/components/time-field/index.js +107 -0
  167. package/dist/components/time-field/index.js.map +1 -0
  168. package/dist/components/time-picker/index.d.ts +65 -0
  169. package/dist/components/time-picker/index.js +1168 -0
  170. package/dist/components/time-picker/index.js.map +1 -0
  171. package/dist/components/toolbar/index.d.ts +53 -0
  172. package/dist/components/toolbar/index.js +185 -0
  173. package/dist/components/toolbar/index.js.map +1 -0
  174. package/dist/components/tooltip/index.d.ts +101 -0
  175. package/dist/components/tooltip/index.js +223 -0
  176. package/dist/components/tooltip/index.js.map +1 -0
  177. package/dist/components/tree/index.d.ts +112 -0
  178. package/dist/components/tree/index.js +157 -0
  179. package/dist/components/tree/index.js.map +1 -0
  180. package/dist/control/group.js +23 -0
  181. package/dist/control/group.js.map +1 -0
  182. package/dist/disclosure/chevron.js +75 -0
  183. package/dist/disclosure/chevron.js.map +1 -0
  184. package/dist/disclosure/index.js +7 -0
  185. package/dist/disclosure/index.js.map +1 -0
  186. package/dist/drop/index.d.ts +54 -0
  187. package/dist/drop/index.js +161 -0
  188. package/dist/drop/index.js.map +1 -0
  189. package/dist/fab/index.d.ts +19 -0
  190. package/dist/fab/index.js +147 -0
  191. package/dist/fab/index.js.map +1 -0
  192. package/dist/field/chevron.js +74 -0
  193. package/dist/field/chevron.js.map +1 -0
  194. package/dist/field/index.d.ts +2 -1
  195. package/dist/field/index.js +350 -153
  196. package/dist/field/index.js.map +1 -1
  197. package/dist/field/styles.js +27 -0
  198. package/dist/field/styles.js.map +1 -1
  199. package/dist/files/index.d.ts +18 -0
  200. package/dist/files/index.js +107 -0
  201. package/dist/files/index.js.map +1 -0
  202. package/dist/form/index.d.ts +6 -4
  203. package/dist/form/index.js +64 -85
  204. package/dist/form/index.js.map +1 -1
  205. package/dist/glyphs/index.js +92 -1
  206. package/dist/glyphs/index.js.map +1 -1
  207. package/dist/i18n/index.js +20 -1
  208. package/dist/i18n/index.js.map +1 -1
  209. package/dist/i18n/messages.js +1394 -34
  210. package/dist/i18n/messages.js.map +1 -1
  211. package/dist/index.d.ts +51 -6
  212. package/dist/index.js +47 -4
  213. package/dist/indicator/paths.js +23 -1
  214. package/dist/indicator/paths.js.map +1 -1
  215. package/dist/modal/index.js +96 -68
  216. package/dist/modal/index.js.map +1 -1
  217. package/dist/navigation/index.js +8 -5
  218. package/dist/navigation/index.js.map +1 -1
  219. package/dist/number/keyboard.js +16 -0
  220. package/dist/number/keyboard.js.map +1 -0
  221. package/dist/overlay/anchored.js +68 -38
  222. package/dist/overlay/anchored.js.map +1 -1
  223. package/dist/overlay/keyboard.js +57 -0
  224. package/dist/overlay/keyboard.js.map +1 -0
  225. package/dist/overlay/panel.js +173 -19
  226. package/dist/overlay/panel.js.map +1 -1
  227. package/dist/overlay/placement.js +16 -2
  228. package/dist/overlay/placement.js.map +1 -1
  229. package/dist/picker/index.js +322 -0
  230. package/dist/picker/index.js.map +1 -0
  231. package/dist/press/index.d.ts +2 -0
  232. package/dist/press/index.js +102 -100
  233. package/dist/press/index.js.map +1 -1
  234. package/dist/row/index.js +77 -69
  235. package/dist/row/index.js.map +1 -1
  236. package/dist/row/styles.js +13 -2
  237. package/dist/row/styles.js.map +1 -1
  238. package/dist/segments/field.js +277 -0
  239. package/dist/segments/field.js.map +1 -0
  240. package/dist/segments/index.js +574 -0
  241. package/dist/segments/index.js.map +1 -0
  242. package/dist/segments/styles.js +24 -0
  243. package/dist/segments/styles.js.map +1 -0
  244. package/dist/separator/index.js +7 -0
  245. package/dist/separator/index.js.map +1 -0
  246. package/dist/slider/index.js +145 -0
  247. package/dist/slider/index.js.map +1 -0
  248. package/dist/swatch/index.js +56 -0
  249. package/dist/swatch/index.js.map +1 -0
  250. package/dist/typography/size.js +14 -0
  251. package/dist/typography/size.js.map +1 -0
  252. package/package.json +11 -2
  253. package/dist/badge/styles.js.map +0 -1
@@ -0,0 +1,231 @@
1
+ import { useLocaleOf } from "../../i18n/provider.js";
2
+ import { useFieldValidation } from "../../form/index.js";
3
+ import { FieldBox, FieldInput, FieldMessage, describedBy, useFieldFocus } from "../../field/index.js";
4
+ import { c } from "react/compiler-runtime";
5
+ import { View } from "react-native";
6
+ import { useId, useImperativeHandle, useRef, useState } from "react";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ //#region src/components/text-area/index.tsx
9
+ function blurThen(onBlur, then) {
10
+ return (event) => {
11
+ onBlur();
12
+ then?.(event);
13
+ };
14
+ }
15
+ function editInto(setOwn, onChange, onEdit) {
16
+ return (text) => {
17
+ setOwn(text);
18
+ onEdit();
19
+ onChange?.(text);
20
+ };
21
+ }
22
+ /**
23
+ * A labelled multi-line input, the text fields page's filled or outlined
24
+ * field holding several lines. Pass `value` with `onChange` to control it, or
25
+ * `defaultValue` to let it keep its own; `onChange` is handed the string.
26
+ *
27
+ * It shows `rows` lines at the least and grows with what it holds, or holds
28
+ * at `rows` and scrolls with `autosize={false}`. The page's configurations
29
+ * are props: `leadingIcon` and `trailingIcon` at the box's ends, and
30
+ * `characterCount` opposite the supporting text, counting against
31
+ * `maxLength`. React Native's own `TextInput` props reach the control;
32
+ * `style` and `ref` are the field as a whole, and `inputRef` the control.
33
+ *
34
+ * ```tsx
35
+ * <TextArea label="Label" description="Supporting line" />
36
+ * ```
37
+ */
38
+ function TextArea(t0) {
39
+ const $ = c(59);
40
+ const { autosize: t1, characterCount: t2, characterLimitLabel, defaultValue: t3, description, error, floatingLabel: t4, inputRef, isDisabled: t5, isReadOnly: t6, isRequired: t7, label, leadingIcon, name, onBlur, onChange, onFocus, ref, rows: t8, style, trailingIcon, validate, value, variant: t9, ...props } = t0;
41
+ const autosize = t1 === void 0 ? true : t1;
42
+ const characterCount = t2 === void 0 ? false : t2;
43
+ const defaultValue = t3 === void 0 ? "" : t3;
44
+ const floatingLabel = t4 === void 0 ? true : t4;
45
+ const isDisabled = t5 === void 0 ? false : t5;
46
+ const isReadOnly = t6 === void 0 ? false : t6;
47
+ const isRequired = t7 === void 0 ? false : t7;
48
+ const rows = t8 === void 0 ? 3 : t8;
49
+ const variant = t9 === void 0 ? "filled" : t9;
50
+ const id = useId();
51
+ const control = useRef(null);
52
+ const [own, setOwn] = useState(defaultValue);
53
+ const current = value ?? own;
54
+ const t10 = current === "";
55
+ let t11;
56
+ if ($[0] !== current || $[1] !== error || $[2] !== isDisabled || $[3] !== isReadOnly || $[4] !== isRequired || $[5] !== name || $[6] !== t10 || $[7] !== validate) {
57
+ t11 = {
58
+ control,
59
+ error,
60
+ isDisabled,
61
+ isEmpty: t10,
62
+ isReadOnly,
63
+ isRequired,
64
+ name,
65
+ submitted: current,
66
+ validate,
67
+ value: current
68
+ };
69
+ $[0] = current;
70
+ $[1] = error;
71
+ $[2] = isDisabled;
72
+ $[3] = isReadOnly;
73
+ $[4] = isRequired;
74
+ $[5] = name;
75
+ $[6] = t10;
76
+ $[7] = validate;
77
+ $[8] = t11;
78
+ } else t11 = $[8];
79
+ const validation = useFieldValidation(t11);
80
+ let t12;
81
+ if ($[9] !== onBlur || $[10] !== validation.onBlur) {
82
+ t12 = blurThen(validation.onBlur, onBlur);
83
+ $[9] = onBlur;
84
+ $[10] = validation.onBlur;
85
+ $[11] = t12;
86
+ } else t12 = $[11];
87
+ let t13;
88
+ if ($[12] !== onFocus || $[13] !== t12) {
89
+ t13 = {
90
+ onBlur: t12,
91
+ onFocus
92
+ };
93
+ $[12] = onFocus;
94
+ $[13] = t12;
95
+ $[14] = t13;
96
+ } else t13 = $[14];
97
+ const focus = useFieldFocus(t13);
98
+ const shownError = validation.error;
99
+ const locale = useLocaleOf(void 0);
100
+ let t14;
101
+ let t15;
102
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
103
+ t14 = () => control.current;
104
+ t15 = [];
105
+ $[15] = t14;
106
+ $[16] = t15;
107
+ } else {
108
+ t14 = $[15];
109
+ t15 = $[16];
110
+ }
111
+ useImperativeHandle(inputRef, t14, t15);
112
+ const T0 = View;
113
+ const T1 = FieldBox;
114
+ const t16 = focus.focused;
115
+ const t17 = shownError !== void 0;
116
+ const t18 = current !== "";
117
+ const T2 = FieldInput;
118
+ const t19 = focus.handlers;
119
+ const t20 = describedBy(id, {
120
+ characterLimitLabel,
121
+ description,
122
+ error: shownError,
123
+ locale,
124
+ maxLength: props.maxLength
125
+ });
126
+ const t21 = !isDisabled && !isReadOnly;
127
+ let t22;
128
+ if ($[17] !== onChange || $[18] !== setOwn || $[19] !== validation.onEdit) {
129
+ t22 = editInto(setOwn, onChange, validation.onEdit);
130
+ $[17] = onChange;
131
+ $[18] = setOwn;
132
+ $[19] = validation.onEdit;
133
+ $[20] = t22;
134
+ } else t22 = $[20];
135
+ let t23;
136
+ if ($[21] !== T2 || $[22] !== autosize || $[23] !== current || $[24] !== focus.handlers || $[25] !== label || $[26] !== props || $[27] !== rows || $[28] !== t20 || $[29] !== t21 || $[30] !== t22) {
137
+ t23 = /* @__PURE__ */ jsx(T2, {
138
+ ...props,
139
+ ...t19,
140
+ "aria-label": label,
141
+ autosize,
142
+ described: t20,
143
+ editable: t21,
144
+ multiline: true,
145
+ onChangeText: t22,
146
+ ref: control,
147
+ rows,
148
+ value: current
149
+ });
150
+ $[21] = T2;
151
+ $[22] = autosize;
152
+ $[23] = current;
153
+ $[24] = focus.handlers;
154
+ $[25] = label;
155
+ $[26] = props;
156
+ $[27] = rows;
157
+ $[28] = t20;
158
+ $[29] = t21;
159
+ $[30] = t22;
160
+ $[31] = t23;
161
+ } else t23 = $[31];
162
+ let t24;
163
+ if ($[32] !== T1 || $[33] !== floatingLabel || $[34] !== focus.focused || $[35] !== isDisabled || $[36] !== isRequired || $[37] !== label || $[38] !== leadingIcon || $[39] !== t17 || $[40] !== t18 || $[41] !== t23 || $[42] !== trailingIcon || $[43] !== variant) {
164
+ t24 = /* @__PURE__ */ jsx(T1, {
165
+ control,
166
+ floatingLabel,
167
+ isDisabled,
168
+ isFocused: t16,
169
+ isInvalid: t17,
170
+ isPopulated: t18,
171
+ isRequired,
172
+ label,
173
+ leading: leadingIcon,
174
+ trailing: trailingIcon,
175
+ variant,
176
+ children: t23
177
+ });
178
+ $[32] = T1;
179
+ $[33] = floatingLabel;
180
+ $[34] = focus.focused;
181
+ $[35] = isDisabled;
182
+ $[36] = isRequired;
183
+ $[37] = label;
184
+ $[38] = leadingIcon;
185
+ $[39] = t17;
186
+ $[40] = t18;
187
+ $[41] = t23;
188
+ $[42] = trailingIcon;
189
+ $[43] = variant;
190
+ $[44] = t24;
191
+ } else t24 = $[44];
192
+ let t25;
193
+ if ($[45] !== characterCount || $[46] !== characterLimitLabel || $[47] !== current.length || $[48] !== description || $[49] !== id || $[50] !== props.maxLength || $[51] !== shownError) {
194
+ t25 = /* @__PURE__ */ jsx(FieldMessage, {
195
+ characterCount,
196
+ characterLimitLabel,
197
+ description,
198
+ error: shownError,
199
+ id,
200
+ length: current.length,
201
+ maxLength: props.maxLength
202
+ });
203
+ $[45] = characterCount;
204
+ $[46] = characterLimitLabel;
205
+ $[47] = current.length;
206
+ $[48] = description;
207
+ $[49] = id;
208
+ $[50] = props.maxLength;
209
+ $[51] = shownError;
210
+ $[52] = t25;
211
+ } else t25 = $[52];
212
+ let t26;
213
+ if ($[53] !== T0 || $[54] !== ref || $[55] !== style || $[56] !== t24 || $[57] !== t25) {
214
+ t26 = /* @__PURE__ */ jsxs(T0, {
215
+ ref,
216
+ style,
217
+ children: [t24, t25]
218
+ });
219
+ $[53] = T0;
220
+ $[54] = ref;
221
+ $[55] = style;
222
+ $[56] = t24;
223
+ $[57] = t25;
224
+ $[58] = t26;
225
+ } else t26 = $[58];
226
+ return t26;
227
+ }
228
+ //#endregion
229
+ export { TextArea };
230
+
231
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","StyleProp","TextInput","TextInputProps","ViewStyle","useId","useImperativeHandle","useRef","useState","View","FieldVariant","ValidationResult","describedBy","FieldBox","FieldInput","FieldMessage","useFieldFocus","useFieldValidation","useLocaleOf","TextAreaProps","Omit","autosize","characterCount","characterLimitLabel","defaultValue","description","error","floatingLabel","inputRef","isDisabled","isReadOnly","isRequired","label","leadingIcon","name","onChange","value","ref","rows","style","trailingIcon","validate","variant","blurThen","onBlur","then","event","editInto","setOwn","onEdit","text","TextArea","t0","$","_c","t1","t2","t3","t4","t5","t6","t7","onFocus","t8","t9","props","undefined","id","control","own","current","t10","t11","isEmpty","submitted","validation","t12","t13","focus","shownError","locale","t14","t15","Symbol","for","T0","T1","t16","focused","t17","t18","T2","t19","handlers","t20","maxLength","t21","t22","t23","t24","t25","length","t26","_c"],"sources":["../../../src/components/text-area/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n StyleProp,\n TextInput,\n TextInputProps,\n ViewStyle,\n} from 'react-native'\n\nimport { useId, useImperativeHandle, useRef, useState } from 'react'\nimport { View } from 'react-native'\n\nimport type { FieldVariant } from '../../field'\nimport type { ValidationResult } from '../../form'\n\nimport {\n describedBy,\n FieldBox,\n FieldInput,\n FieldMessage,\n useFieldFocus,\n} from '../../field'\nimport { useFieldValidation } from '../../form'\nimport { useLocaleOf } from '../../i18n/provider'\n\n// kanso-ui's TextArea, the text fields page's multi-line configuration of the\n// field: the same box, floating label, icons, rule and supporting line as\n// TextField, drawn through the field chrome in src/field, around a control\n// that holds several lines. The page gives the box 56dp at the least, with\n// 8dp above and below the text and the label resting on its first line; a box\n// holding more grows a line at a time, which the chrome's height floor\n// already does, and its icons stay centred in its height, as web's do. The\n// page draws no resize handle, and React Native draws none.\n//\n// Its own component rather than a prop of TextField, as on web, so `rows` and\n// `autosize` stay off TextField's type and `numeric`, `prefix` and `suffix`\n// off this one.\n//\n// The value is the field's own or the call site's, as TextField's is, and\n// `onChange` is handed the string. The error shown is `error`, or what the\n// field's `validate` and the `Form` around it say, which src/form decides.\n\ntype TextAreaProps = Omit<\n TextInputProps,\n | 'accessibilityHint'\n | 'accessibilityLabel'\n | 'aria-disabled'\n | 'aria-label'\n | 'children'\n | 'cursorColor'\n | 'defaultValue'\n | 'editable'\n | 'multiline'\n | 'numberOfLines'\n | 'onChange'\n | 'onChangeText'\n | 'placeholder'\n | 'placeholderTextColor'\n | 'readOnly'\n | 'rows'\n | 'selectionColor'\n | 'style'\n | 'underlineColorAndroid'\n | 'value'\n> & {\n /**\n * Whether the field grows with the text it holds, from `rows` up. `false`\n * keeps it at `rows` and scrolls the text inside.\n * @default true\n */\n readonly autosize?: boolean\n /**\n * Counts the characters the field holds at the end of the supporting line,\n * against `maxLength` where there is one, as the text fields page's\n * character counter does. The count is written in the digits of the\n * `I18nProvider`'s locale, or the device's outside one.\n * @default false\n */\n readonly characterCount?: boolean\n /**\n * How the limit is said to a screen reader, where there is a `maxLength`.\n * Read with the field rather than as the value changes, so it names the\n * limit and not what is left of it; the visible count is hidden from\n * screen readers, which is what this replaces. Left out, it is the\n * library's sentence in the `I18nProvider`'s locale, or the device's\n * outside one, in the plural form the limit takes there: \"Up to 20\n * characters\" in English, singular for a limit of one.\n */\n readonly characterLimitLabel?: string\n /** The value the field opens with, when it keeps its own. */\n readonly defaultValue?: string\n /**\n * A hint shown under the field. Replaced by `error` when there is one, so\n * the 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 field in its error state: the message, the error colours, and the\n * invalid state a screen reader reads all follow from it. The line under\n * the field arrives with the message, so the field grows when this does,\n * unless it is inside a `Form`, which keeps the line drawn. It wins over\n * what `validate` and the form say, and holds a `native` form back.\n */\n readonly error?: string\n /**\n * Whether the label sits in the empty box and floats to the top once the\n * field is focused or holds a value, as the text fields page draws it.\n * `false` keeps it small at the top in every state.\n * @default true\n */\n readonly floatingLabel?: boolean\n /**\n * A ref to the field's own `TextInput`, which is what a call site moves\n * focus to, after a server's error, say. `ref` is the field as a whole.\n */\n readonly inputRef?: Ref<ComponentRef<typeof TextInput>>\n /**\n * Draws the field disabled: it takes no focus and no input.\n * @default false\n */\n readonly isDisabled?: boolean\n /**\n * Shows the value and takes focus, but takes no input.\n * @default false\n */\n readonly isReadOnly?: boolean\n /**\n * Marks the label with an asterisk, as the text fields page marks a field\n * that must be filled.\n * @default false\n */\n readonly isRequired?: boolean\n /**\n * What the field is for, and the name a screen reader reads for it.\n * Required, since a text area with no label is a box nobody can name.\n */\n readonly label: string\n /**\n * An icon at the start of the box, before the label and the text: the\n * page's 24dp leading icon, in the muted role. The slot hands it that\n * colour and size through `useIconStyle()`.\n */\n readonly leadingIcon?: ReactNode\n /**\n * The name the value is submitted under by the `Form` around the field,\n * and the key its `validationErrors` reach the field by.\n */\n readonly name?: string\n /** Called with the new value as it is edited. */\n readonly onChange?: (value: string) => void\n readonly ref?: Ref<ComponentRef<typeof View>>\n /**\n * How many lines of text the field shows: the least it shows while it\n * grows, or all it shows when it does not.\n * @default 3\n */\n readonly rows?: number\n /** Positions and sizes the field as a whole. */\n readonly style?: StyleProp<ViewStyle>\n /**\n * An icon at the end of the box, after the text: the page's 24dp trailing\n * icon, in the muted role and the error role while the field has an\n * error. The slot hands it that colour and size through `useIconStyle()`.\n */\n readonly trailingIcon?: ReactNode\n /**\n * Checks the value, and returns its problem in words, or several, where\n * there is one, and `true`, `null` or `undefined` where there is none.\n * Under the default `aria` validation the error shows as the value\n * changes; inside a `native` form it shows once a submission is tried, or\n * once the field loses focus after an edit, and holds the form back.\n */\n readonly validate?: (value: string) => ValidationResult\n /** The value, when the call site keeps it. */\n readonly value?: string\n /**\n * The filled box, or the outlined one: no fill, an outline that thickens\n * and takes the primary role while focused, and the label cutting it once\n * it floats, the text fields page's two fields.\n * @default 'filled'\n */\n readonly variant?: FieldVariant\n}\n\n// The field's own blur handling, then the call site's.\nfunction blurThen(\n onBlur: () => void,\n then: TextInputProps['onBlur'],\n): TextInputProps['onBlur'] {\n return (event) => {\n onBlur()\n then?.(event)\n }\n}\n\n// Keeps an edit as the field's own value and reports it, so a field the call\n// site controls is told and one it does not still shows what was typed, and\n// tells the field's validation it was edited.\nfunction editInto(\n setOwn: (value: string) => void,\n onChange: ((value: string) => void) | undefined,\n onEdit: () => void,\n) {\n return (text: string) => {\n setOwn(text)\n onEdit()\n onChange?.(text)\n }\n}\n\n/**\n * A labelled multi-line input, the text fields page's filled or outlined\n * field holding several lines. Pass `value` with `onChange` to control it, or\n * `defaultValue` to let it keep its own; `onChange` is handed the string.\n *\n * It shows `rows` lines at the least and grows with what it holds, or holds\n * at `rows` and scrolls with `autosize={false}`. The page's configurations\n * are props: `leadingIcon` and `trailingIcon` at the box's ends, and\n * `characterCount` opposite the supporting text, counting against\n * `maxLength`. React Native's own `TextInput` props reach the control;\n * `style` and `ref` are the field as a whole, and `inputRef` the control.\n *\n * ```tsx\n * <TextArea label=\"Label\" description=\"Supporting line\" />\n * ```\n */\nfunction TextArea({\n autosize = true,\n characterCount = false,\n characterLimitLabel,\n defaultValue = '',\n description,\n error,\n floatingLabel = true,\n inputRef,\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n label,\n leadingIcon,\n name,\n onBlur,\n onChange,\n onFocus,\n ref,\n rows = 3,\n style,\n trailingIcon,\n validate,\n value,\n variant = 'filled',\n ...props\n}: TextAreaProps) {\n const id = useId()\n const control = useRef<ComponentRef<typeof TextInput>>(null)\n const [own, setOwn] = useState(defaultValue)\n const current = value ?? own\n const validation = useFieldValidation({\n control,\n error,\n isDisabled,\n isEmpty: current === '',\n isReadOnly,\n isRequired,\n name,\n submitted: current,\n validate,\n value: current,\n })\n const focus = useFieldFocus({\n onBlur: blurThen(validation.onBlur, onBlur),\n onFocus,\n })\n const shownError = validation.error\n const locale = useLocaleOf(undefined)\n\n useImperativeHandle<\n ComponentRef<typeof TextInput> | null,\n ComponentRef<typeof TextInput> | null\n >(inputRef, () => control.current, [])\n\n return (\n <View ref={ref} style={style}>\n <FieldBox\n control={control}\n floatingLabel={floatingLabel}\n isDisabled={isDisabled}\n isFocused={focus.focused}\n isInvalid={shownError !== undefined}\n isPopulated={current !== ''}\n isRequired={isRequired}\n label={label}\n leading={leadingIcon}\n trailing={trailingIcon}\n variant={variant}\n >\n <FieldInput\n {...props}\n {...focus.handlers}\n aria-label={label}\n autosize={autosize}\n described={describedBy(id, {\n characterLimitLabel,\n description,\n error: shownError,\n locale,\n maxLength: props.maxLength,\n })}\n editable={!isDisabled && !isReadOnly}\n multiline\n onChangeText={editInto(setOwn, onChange, validation.onEdit)}\n ref={control}\n rows={rows}\n value={current}\n />\n </FieldBox>\n <FieldMessage\n characterCount={characterCount}\n characterLimitLabel={characterLimitLabel}\n description={description}\n error={shownError}\n id={id}\n length={current.length}\n maxLength={props.maxLength}\n />\n </View>\n )\n}\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"mappings":";;;;;;;;AAyLA,SAAS6C,SACPC,QACAC,MAC0B;CAC1B,QAAQC,UAAU;EAChBF,OAAO;EACPC,OAAOC,KAAK;CACd;AACF;AAKA,SAASC,SACPC,QACAb,UACAc,QACA;CACA,QAAQC,SAAiB;EACvBF,OAAOE,IAAI;EACXD,OAAO;EACPd,WAAWe,IAAI;CACjB;AACF;;;;;;;;;;;;;;;;;AAkBA,SAAAC,SAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAkB,MAAA,EAAAjC,UAAAkC,IAAAjC,gBAAAkC,IAAAjC,qBAAAC,cAAAiC,IAAAhC,aAAAC,OAAAC,eAAA+B,IAAA9B,UAAAC,YAAA8B,IAAA7B,YAAA8B,IAAA7B,YAAA8B,IAAA7B,OAAAC,aAAAC,MAAAU,QAAAT,UAAA2B,SAAAzB,KAAAC,MAAAyB,IAAAxB,OAAAC,cAAAC,UAAAL,OAAAM,SAAAsB,IAAA,GAAAC,UAAAb;CAChB,MAAA/B,WAAAkC,OAAAW,KAAAA,IAAA,OAAAX;CACA,MAAAjC,iBAAAkC,OAAAU,KAAAA,IAAA,QAAAV;CAEA,MAAAhC,eAAAiC,OAAAS,KAAAA,IAAA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OAAAA,MAAAjD,EAAA;CAAA,OA3CPiD;AA2CO"}
@@ -0,0 +1,43 @@
1
+ import { DateFieldProps } from "../date-field/index.js";
2
+ import { TimeFieldStateOptions, TimeValue } from "react-stately/useTimeFieldState";
3
+ //#region src/components/time-field/index.d.ts
4
+ type TimeFieldProps<T extends TimeValue = TimeValue> = Omit<DateFieldProps, 'defaultValue' | 'granularity' | 'hideTimeZone' | 'hourCycle' | 'isDateUnavailable' | 'locale' | 'maxValue' | 'minValue' | 'name' | 'onChange' | 'placeholderValue' | 'shouldForceLeadingZeros' | 'validate' | 'value'> & Pick<TimeFieldStateOptions<T>, 'defaultValue' | 'granularity' | 'hideTimeZone' | 'hourCycle' | 'maxValue' | 'minValue' | 'onChange' | 'placeholderValue' | 'shouldForceLeadingZeros' | 'validate' | 'value'> & {
5
+ /**
6
+ * The BCP 47 locale the time is written and typed in: whether it has a
7
+ * day period and what that is called, its placeholders and its digits.
8
+ * Defaults to the `I18nProvider`'s, or the device's outside one.
9
+ */
10
+ readonly locale?: string;
11
+ /**
12
+ * The name the value is submitted under by the `Form` around the field,
13
+ * and the key its `validationErrors` reach the field by. The form submits
14
+ * the time written out as ISO 8601, such as `09:30:00`, and `''` for an
15
+ * empty field.
16
+ */
17
+ readonly name?: string;
18
+ };
19
+ /**
20
+ * A time typed rather than picked: one segment per part, typed into a digit
21
+ * at a time. The value is an `@internationalized/date` `Time`, as on web:
22
+ * pass `value` with `onChange` to control it, or `defaultValue` to let it
23
+ * keep its own.
24
+ *
25
+ * ```tsx
26
+ * import { Time } from '@internationalized/date'
27
+ *
28
+ * <TimeField defaultValue={new Time(9, 30)} label="Label" />
29
+ * ```
30
+ *
31
+ * Whether it shows a twelve or twenty-four hour clock is the locale's,
32
+ * through the `I18nProvider`. `granularity` takes it down to seconds or up
33
+ * to hours, and `minValue` and `maxValue` bound what may be typed, an error
34
+ * under the field saying so in React Aria's words where a time is outside
35
+ * them.
36
+ *
37
+ * The segments, the box, the label and the message are DateField's.
38
+ * `style`, `ref` and `testID` land on the field as a whole.
39
+ */
40
+ declare function TimeField<T extends TimeValue = TimeValue>({ isDisabled, isReadOnly, isRequired, locale, ...props }: TimeFieldProps<T>): import("react").JSX.Element;
41
+ //#endregion
42
+ export { TimeField, type TimeFieldProps };
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,107 @@
1
+ import { useLocaleOf } from "../../i18n/provider.js";
2
+ import { SegmentedField } from "../../segments/field.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { useTimeFieldState } from "react-stately/useTimeFieldState";
6
+ //#region src/components/time-field/index.tsx
7
+ /**
8
+ * A time typed rather than picked: one segment per part, typed into a digit
9
+ * at a time. The value is an `@internationalized/date` `Time`, as on web:
10
+ * pass `value` with `onChange` to control it, or `defaultValue` to let it
11
+ * keep its own.
12
+ *
13
+ * ```tsx
14
+ * import { Time } from '@internationalized/date'
15
+ *
16
+ * <TimeField defaultValue={new Time(9, 30)} label="Label" />
17
+ * ```
18
+ *
19
+ * Whether it shows a twelve or twenty-four hour clock is the locale's,
20
+ * through the `I18nProvider`. `granularity` takes it down to seconds or up
21
+ * to hours, and `minValue` and `maxValue` bound what may be typed, an error
22
+ * under the field saying so in React Aria's words where a time is outside
23
+ * them.
24
+ *
25
+ * The segments, the box, the label and the message are DateField's.
26
+ * `style`, `ref` and `testID` land on the field as a whole.
27
+ */
28
+ function TimeField(t0) {
29
+ const $ = c(24);
30
+ let locale;
31
+ let props;
32
+ let t1;
33
+ let t2;
34
+ let t3;
35
+ if ($[0] !== t0) {
36
+ ({isDisabled: t1, isReadOnly: t2, isRequired: t3, locale, ...props} = t0);
37
+ $[0] = t0;
38
+ $[1] = locale;
39
+ $[2] = props;
40
+ $[3] = t1;
41
+ $[4] = t2;
42
+ $[5] = t3;
43
+ } else {
44
+ locale = $[1];
45
+ props = $[2];
46
+ t1 = $[3];
47
+ t2 = $[4];
48
+ t3 = $[5];
49
+ }
50
+ const isDisabled = t1 === void 0 ? false : t1;
51
+ const isReadOnly = t2 === void 0 ? false : t2;
52
+ const isRequired = t3 === void 0 ? false : t3;
53
+ const writtenIn = useLocaleOf(locale);
54
+ let t4;
55
+ if ($[6] !== isDisabled || $[7] !== isReadOnly || $[8] !== isRequired || $[9] !== props || $[10] !== writtenIn) {
56
+ t4 = {
57
+ ...props,
58
+ isDisabled,
59
+ isReadOnly,
60
+ isRequired,
61
+ locale: writtenIn
62
+ };
63
+ $[6] = isDisabled;
64
+ $[7] = isReadOnly;
65
+ $[8] = isRequired;
66
+ $[9] = props;
67
+ $[10] = writtenIn;
68
+ $[11] = t4;
69
+ } else t4 = $[11];
70
+ const state = useTimeFieldState(t4);
71
+ const t5 = state.value === null;
72
+ let t6;
73
+ if ($[12] !== state.timeValue || $[13] !== state.value) {
74
+ t6 = state.value === null ? "" : state.timeValue.toString();
75
+ $[12] = state.timeValue;
76
+ $[13] = state.value;
77
+ $[14] = t6;
78
+ } else t6 = $[14];
79
+ let t7;
80
+ if ($[15] !== isDisabled || $[16] !== isReadOnly || $[17] !== isRequired || $[18] !== props || $[19] !== state || $[20] !== t5 || $[21] !== t6 || $[22] !== writtenIn) {
81
+ t7 = /* @__PURE__ */ jsx(SegmentedField, {
82
+ ...props,
83
+ errors: state.realtimeValidation.validationErrors,
84
+ isDisabled,
85
+ isEmpty: t5,
86
+ isReadOnly,
87
+ isRequired,
88
+ locale: writtenIn,
89
+ state,
90
+ submitted: t6
91
+ });
92
+ $[15] = isDisabled;
93
+ $[16] = isReadOnly;
94
+ $[17] = isRequired;
95
+ $[18] = props;
96
+ $[19] = state;
97
+ $[20] = t5;
98
+ $[21] = t6;
99
+ $[22] = writtenIn;
100
+ $[23] = t7;
101
+ } else t7 = $[23];
102
+ return t7;
103
+ }
104
+ //#endregion
105
+ export { TimeField };
106
+
107
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["TimeFieldStateOptions","TimeValue","useTimeFieldState","DateFieldProps","useLocaleOf","SegmentedField","TimeFieldProps","Omit","Pick","T","locale","name","TimeField","t0","$","_c","props","t1","t2","t3","isDisabled","isReadOnly","isRequired","undefined","writtenIn","t4","state","t5","value","t6","timeValue","toString","t7","realtimeValidation","validationErrors","_c"],"sources":["../../../src/components/time-field/index.tsx"],"sourcesContent":["import type {\n TimeFieldStateOptions,\n TimeValue,\n} from 'react-stately/useTimeFieldState'\n\nimport { useTimeFieldState } from 'react-stately/useTimeFieldState'\n\nimport type { DateFieldProps } from '../date-field'\n\nimport { useLocaleOf } from '../../i18n/provider'\nimport { SegmentedField } from '../../segments/field'\n\n// kanso-ui's TimeField: a time typed a segment at a time. Every part of it is\n// DateField's, from src/segments, the segments, the muted placeholders, the\n// filled focus and the punctuation between them, and the box around them, so\n// a time on a form and a date on the same form cannot come apart.\n//\n// What differs is the value it holds and nothing else. The time pickers page\n// gives its input the text field's own box, which is what the shared field\n// chrome already draws, so there is no measurement here that DateField's\n// comment does not already name.\n//\n// **Twelve or twenty-four hours is the locale's.** React Stately decides from\n// the locale whether there is a day-period segment at all, so a field under\n// `en-GB` shows a 24-hour clock and the same field under `en-US` shows AM and\n// PM, in the locale's own words for the two. `hourCycle` is React Stately's\n// own, for a screen that has to set the clock whatever the locale.\n\ntype TimeFieldProps<T extends TimeValue = TimeValue> = Omit<\n DateFieldProps,\n | 'defaultValue'\n | 'granularity'\n | 'hideTimeZone'\n | 'hourCycle'\n | 'isDateUnavailable'\n | 'locale'\n | 'maxValue'\n | 'minValue'\n | 'name'\n | 'onChange'\n | 'placeholderValue'\n | 'shouldForceLeadingZeros'\n | 'validate'\n | 'value'\n> &\n Pick<\n TimeFieldStateOptions<T>,\n | 'defaultValue'\n | 'granularity'\n | 'hideTimeZone'\n | 'hourCycle'\n | 'maxValue'\n | 'minValue'\n | 'onChange'\n | 'placeholderValue'\n | 'shouldForceLeadingZeros'\n | 'validate'\n | 'value'\n > & {\n /**\n * The BCP 47 locale the time is written and typed in: whether it has a\n * day period and what that is called, its placeholders and its digits.\n * Defaults to the `I18nProvider`'s, or the device's outside one.\n */\n readonly locale?: string\n /**\n * The name the value is submitted under by the `Form` around the field,\n * and the key its `validationErrors` reach the field by. The form submits\n * the time written out as ISO 8601, such as `09:30:00`, and `''` for an\n * empty field.\n */\n readonly name?: string\n }\n\n/**\n * A time typed rather than picked: one segment per part, typed into a digit\n * at a time. The value is an `@internationalized/date` `Time`, as on web:\n * pass `value` with `onChange` to control it, or `defaultValue` to let it\n * keep its own.\n *\n * ```tsx\n * import { Time } from '@internationalized/date'\n *\n * <TimeField defaultValue={new Time(9, 30)} label=\"Label\" />\n * ```\n *\n * Whether it shows a twelve or twenty-four hour clock is the locale's,\n * through the `I18nProvider`. `granularity` takes it down to seconds or up\n * to hours, and `minValue` and `maxValue` bound what may be typed, an error\n * under the field saying so in React Aria's words where a time is outside\n * them.\n *\n * The segments, the box, the label and the message are DateField's.\n * `style`, `ref` and `testID` land on the field as a whole.\n */\nfunction TimeField<T extends TimeValue = TimeValue>({\n isDisabled = false,\n isReadOnly = false,\n isRequired = false,\n locale,\n ...props\n}: TimeFieldProps<T>) {\n const writtenIn = useLocaleOf(locale)\n const state = useTimeFieldState<T>({\n ...props,\n isDisabled,\n isReadOnly,\n isRequired,\n locale: writtenIn,\n })\n\n return (\n <SegmentedField\n {...props}\n errors={state.realtimeValidation.validationErrors}\n isDisabled={isDisabled}\n isEmpty={state.value === null}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n locale={writtenIn}\n state={state}\n // The time alone, as web's field submits it, rather than the date and\n // time React Stately keeps it as underneath.\n submitted={state.value === null ? '' : state.timeValue.toString()}\n />\n )\n}\n\nexport type { TimeFieldProps }\n\nexport { TimeField }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,SAAAY,UAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAL;CAAA,IAAAM;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;C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IAAAlB,EAAA,QAAAM,cAAAN,EAAA,QAAAO,cAAAP,EAAA,QAAAQ,cAAAR,EAAA,QAAAE,SAAAF,EAAA,QAAAY,SAAAZ,EAAA,QAAAa,MAAAb,EAAA,QAAAe,MAAAf,EAAA,QAAAU,WAAA;EAXnEQ,KAAA,oBAAC,gBAAD;GAAe,GACThB;GACI,QAAAU,MAAKO,mBAAmBC;GACpBd;GACH,SAAAO;GACGN;GACAC;GACJE,QAAAA;GACDE;GAGI,WAAAG;EAAsD,CAAA;EACjEf,EAAA,MAAAM;EAAAN,EAAA,MAAAO;EAAAP,EAAA,MAAAQ;EAAAR,EAAA,MAAAE;EAAAF,EAAA,MAAAY;EAAAZ,EAAA,MAAAa;EAAAb,EAAA,MAAAe;EAAAf,EAAA,MAAAU;EAAAV,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,OAZFkB;AAYE"}
@@ -0,0 +1,65 @@
1
+ import { TimeFieldProps } from "../time-field/index.js";
2
+ import { TimeValue } from "react-stately/useTimeFieldState";
3
+ //#region src/components/time-picker/index.d.ts
4
+ /** Which of the time pickers page's two variants the modal shows. */
5
+ type TimePickerMode = 'dial' | 'input';
6
+ type TimePickerProps<T extends TimeValue = TimeValue> = Omit<TimeFieldProps<T>, 'trailingIcon'> & {
7
+ /**
8
+ * What the modal's dismissing action says. Left out, it is the word for it
9
+ * in the locale, "Cancel" in English.
10
+ */
11
+ readonly cancelLabel?: string;
12
+ /**
13
+ * What the modal's confirming action says. Left out, it is the word for it
14
+ * in the locale, "OK" in English.
15
+ */
16
+ readonly confirmLabel?: string;
17
+ /**
18
+ * Which variant the modal opens on: the dial, or the boxes as text fields
19
+ * to type into. The button at the modal's start switches between them.
20
+ * @default 'dial'
21
+ */
22
+ readonly defaultMode?: TimePickerMode;
23
+ /** Whether the modal starts open, when it keeps its own state. */
24
+ readonly defaultOpen?: boolean;
25
+ /**
26
+ * The input variant's headline, which also names the button that switches
27
+ * the dial to it. Left out, it is the locale's, "Enter time" in English.
28
+ */
29
+ readonly enterTimeLabel?: string;
30
+ /** Whether the modal is open, when the call site holds the state. */
31
+ readonly isOpen?: boolean;
32
+ /** Called with the modal's new state as it opens or closes. */
33
+ readonly onOpenChange?: (isOpen: boolean) => void;
34
+ /**
35
+ * The dial's headline, which also names the clock button that opens the
36
+ * modal, before the field's label, and the button that switches the input
37
+ * variant back. Left out, it is the locale's, "Select time" in English.
38
+ */
39
+ readonly selectTimeLabel?: string;
40
+ };
41
+ /**
42
+ * A time typed into a field, or picked in a modal behind the clock button at
43
+ * the field's end: on a dial, or typed into the modal's larger boxes. The
44
+ * value is an `@internationalized/date` value, as on web: pass `value` with
45
+ * `onChange` to control it, or `defaultValue` to let it keep its own.
46
+ *
47
+ * ```tsx
48
+ * import { Time } from '@internationalized/date'
49
+ *
50
+ * <TimePicker defaultValue={new Time(9, 30)} label="Label" />
51
+ * ```
52
+ *
53
+ * The field is TimeField's, so `granularity`, `hourCycle`, `minValue` and
54
+ * `maxValue` behave as they do there. The modal sets hours and minutes and
55
+ * keeps the seconds a value already has; a time it writes back is checked
56
+ * against the bounds as a typed one is. Whether it shows a twelve or
57
+ * twenty-four hour clock is the locale's, through the `I18nProvider`, unless
58
+ * `hourCycle` says otherwise.
59
+ *
60
+ * `style`, `ref` and `testID` land on the field as a whole.
61
+ */
62
+ declare function TimePicker<T extends TimeValue = TimeValue>({ cancelLabel, confirmLabel, defaultMode, defaultOpen, enterTimeLabel, isDisabled, isOpen, isReadOnly, isRequired, locale, onOpenChange, selectTimeLabel, ...props }: TimePickerProps<T>): import("react").JSX.Element;
63
+ //#endregion
64
+ export { TimePicker, type TimePickerMode, type TimePickerProps };
65
+ //# sourceMappingURL=index.d.ts.map