@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,673 @@
1
+ import { IconStyleContext } from "../../glyphs/icon-style.js";
2
+ import { useTheme } from "../../theme/scope.js";
3
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
4
+ import { useTypeRole } from "../../typography/roles.js";
5
+ import { withOpacity } from "../../theme/color.js";
6
+ import { useLocaleOf } from "../../i18n/provider.js";
7
+ import { ADJUSTABLE, adjustOf, lengthTo, percentOf, seatPlaceOf, seats, useTrackGesture } from "../../slider/index.js";
8
+ import { c } from "react/compiler-runtime";
9
+ import { StyleSheet, Text, View } from "react-native";
10
+ import Animated, { Easing, useAnimatedStyle, useReducedMotion, withTiming } from "react-native-reanimated";
11
+ import { useState } from "react";
12
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
+ import { NumberFormatter } from "@internationalized/number";
14
+ import { GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler";
15
+ import { useSliderState } from "react-stately/useSliderState";
16
+ //#region src/components/slider/index.tsx
17
+ const GAP = 6;
18
+ const HANDLE_WIDTH = 4;
19
+ /** The handle's width while it is dragged. */
20
+ const HANDLE_PRESSED = 2;
21
+ /** How far a part stops short of a handle's centre. */
22
+ const CLEAR = 8;
23
+ /** A stop's size. */
24
+ const STOP = 4;
25
+ /** The corner a part turns to a handle. */
26
+ const INNER_CORNER = 2;
27
+ /** MDC-Android's padding either side of the inset icon. */
28
+ const ICON_PADDING = 10;
29
+ /** The value indicator's height and its narrowest width. */
30
+ const INDICATOR_HEIGHT = 44;
31
+ const INDICATOR_MIN_WIDTH = 48;
32
+ /** A vertical slider's height when the call site gives it none. */
33
+ const VERTICAL_HEIGHT = 240;
34
+ const SIZES = {
35
+ lg: {
36
+ corner: "lg",
37
+ handle: 68,
38
+ icon: 24,
39
+ track: 56
40
+ },
41
+ md: {
42
+ corner: "md",
43
+ handle: 52,
44
+ icon: 24,
45
+ track: 40
46
+ },
47
+ sm: {
48
+ corner: "sm",
49
+ handle: 44,
50
+ track: 24
51
+ },
52
+ xl: {
53
+ corner: "xl",
54
+ handle: 108,
55
+ icon: 32,
56
+ track: 96
57
+ },
58
+ xs: {
59
+ corner: "sm",
60
+ handle: 44,
61
+ track: 16
62
+ }
63
+ };
64
+ const AT_END = {
65
+ fraction: 0,
66
+ px: 0
67
+ };
68
+ const NO_STEPS = [];
69
+ const styles = StyleSheet.create({
70
+ area: { flexGrow: 1 },
71
+ indicator: {
72
+ alignItems: "center",
73
+ height: INDICATOR_HEIGHT,
74
+ justifyContent: "center",
75
+ minWidth: INDICATOR_MIN_WIDTH,
76
+ position: "absolute"
77
+ },
78
+ indicatorHorizontal: { bottom: "100%" },
79
+ indicatorVertical: { end: "100%" },
80
+ innerEnd: {
81
+ borderBottomEndRadius: INNER_CORNER,
82
+ borderTopEndRadius: INNER_CORNER
83
+ },
84
+ innerEndVertical: {
85
+ borderTopEndRadius: INNER_CORNER,
86
+ borderTopStartRadius: INNER_CORNER
87
+ },
88
+ innerStart: {
89
+ borderBottomStartRadius: INNER_CORNER,
90
+ borderTopStartRadius: INNER_CORNER
91
+ },
92
+ innerStartVertical: {
93
+ borderBottomEndRadius: INNER_CORNER,
94
+ borderBottomStartRadius: INNER_CORNER
95
+ },
96
+ part: {
97
+ overflow: "hidden",
98
+ position: "absolute"
99
+ },
100
+ root: { width: "100%" },
101
+ rootVertical: {
102
+ alignItems: "flex-start",
103
+ height: VERTICAL_HEIGHT
104
+ },
105
+ stop: {
106
+ height: STOP,
107
+ position: "absolute",
108
+ width: STOP
109
+ },
110
+ stopEnd: { end: GAP },
111
+ stopEndVertical: { top: GAP },
112
+ stopStart: { start: GAP },
113
+ stopStartVertical: { bottom: GAP }
114
+ });
115
+ const stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) => {
116
+ const disabledContent = withOpacity(colors.onSurface, stateLayerOpacity.disabledContent);
117
+ return StyleSheet.create({
118
+ active: { backgroundColor: colors.primary },
119
+ activeDisabled: { backgroundColor: disabledContent },
120
+ handle: {
121
+ backgroundColor: colors.primary,
122
+ borderRadius: radii.pill
123
+ },
124
+ handleDisabled: { backgroundColor: disabledContent },
125
+ inactive: { backgroundColor: colors.secondaryContainer },
126
+ inactiveDisabled: { backgroundColor: withOpacity(colors.onSurface, stateLayerOpacity.disabledContainer) },
127
+ indicator: {
128
+ backgroundColor: colors.inverseSurface,
129
+ borderRadius: radii.pill,
130
+ marginBottom: spacing.md,
131
+ paddingHorizontal: spacing.md
132
+ },
133
+ indicatorText: {
134
+ color: colors.inverseOnSurface,
135
+ textAlign: "center"
136
+ },
137
+ indicatorVertical: {
138
+ marginBottom: 0,
139
+ marginEnd: spacing.md
140
+ },
141
+ label: { color: colors.onSurfaceVariant },
142
+ root: { gap: spacing.xs },
143
+ stop: {
144
+ backgroundColor: colors.onSecondaryContainer,
145
+ borderRadius: radii.circle
146
+ },
147
+ stopActive: { backgroundColor: colors.onPrimary },
148
+ stopActiveDisabled: { backgroundColor: colors.inverseOnSurface },
149
+ stopDisabled: { backgroundColor: disabledContent }
150
+ });
151
+ });
152
+ function after(fraction) {
153
+ return {
154
+ fraction,
155
+ px: CLEAR
156
+ };
157
+ }
158
+ function before(fraction) {
159
+ return {
160
+ fraction: 1 - fraction,
161
+ px: CLEAR
162
+ };
163
+ }
164
+ function Handle(t0) {
165
+ const $ = c(23);
166
+ const { index, metrics, name, state, vertical } = t0;
167
+ const own = stylesOf(useTheme());
168
+ const labelRole = useTypeRole("labelLarge");
169
+ let t1;
170
+ if ($[0] !== index || $[1] !== state) {
171
+ t1 = state.isThumbDragging(index);
172
+ $[0] = index;
173
+ $[1] = state;
174
+ $[2] = t1;
175
+ } else t1 = $[2];
176
+ const dragging = t1;
177
+ const narrowing = useHandleMotion(dragging, vertical);
178
+ const t2 = state.isDisabled;
179
+ let t3;
180
+ if ($[3] !== index || $[4] !== state) {
181
+ t3 = state.getThumbMaxValue(index);
182
+ $[3] = index;
183
+ $[4] = state;
184
+ $[5] = t3;
185
+ } else t3 = $[5];
186
+ let t4;
187
+ if ($[6] !== index || $[7] !== state) {
188
+ t4 = state.getThumbMinValue(index);
189
+ $[6] = index;
190
+ $[7] = state;
191
+ $[8] = t4;
192
+ } else t4 = $[8];
193
+ let t5;
194
+ if ($[9] !== index || $[10] !== state) {
195
+ t5 = state.getThumbValue(index);
196
+ $[9] = index;
197
+ $[10] = state;
198
+ $[11] = t5;
199
+ } else t5 = $[11];
200
+ let t6;
201
+ if ($[12] !== index || $[13] !== state) {
202
+ t6 = state.getThumbValueLabel(index);
203
+ $[12] = index;
204
+ $[13] = state;
205
+ $[14] = t6;
206
+ } else t6 = $[14];
207
+ let t7;
208
+ if ($[15] !== index || $[16] !== state) {
209
+ t7 = adjustOf(state, index);
210
+ $[15] = index;
211
+ $[16] = state;
212
+ $[17] = t7;
213
+ } else t7 = $[17];
214
+ const t8 = vertical ? seats.seatVertical : seats.seat;
215
+ let t9;
216
+ if ($[18] !== index || $[19] !== state || $[20] !== t8 || $[21] !== vertical) {
217
+ t9 = composeStyles(t8, seatPlaceOf(state.getThumbPercent(index), vertical));
218
+ $[18] = index;
219
+ $[19] = state;
220
+ $[20] = t8;
221
+ $[21] = vertical;
222
+ $[22] = t9;
223
+ } else t9 = $[22];
224
+ return /* @__PURE__ */ jsxs(View, {
225
+ accessibilityActions: ADJUSTABLE,
226
+ accessible: true,
227
+ "aria-disabled": t2,
228
+ "aria-label": name,
229
+ "aria-valuemax": t3,
230
+ "aria-valuemin": t4,
231
+ "aria-valuenow": t5,
232
+ "aria-valuetext": t6,
233
+ onAccessibilityAction: t7,
234
+ role: "slider",
235
+ style: t9,
236
+ children: [/* @__PURE__ */ jsx(Animated.View, { style: composeStyles(own.handle, handleLengthOf(metrics, vertical), state.isDisabled ? own.handleDisabled : void 0, narrowing) }), dragging ? /* @__PURE__ */ jsx(View, {
237
+ "aria-hidden": true,
238
+ style: composeStyles(styles.indicator, vertical ? styles.indicatorVertical : styles.indicatorHorizontal, own.indicator, vertical ? own.indicatorVertical : void 0),
239
+ children: /* @__PURE__ */ jsx(Text, {
240
+ numberOfLines: 1,
241
+ style: composeStyles(labelRole, own.indicatorText),
242
+ children: state.getThumbValueLabel(index)
243
+ })
244
+ }) : null]
245
+ });
246
+ }
247
+ function handleLengthOf({ handle }, vertical) {
248
+ return vertical ? { width: handle } : { height: handle };
249
+ }
250
+ function iconPlaceOf({ track }, size, vertical) {
251
+ const across = (track - size) / 2;
252
+ return {
253
+ alignItems: "center",
254
+ height: size,
255
+ justifyContent: "center",
256
+ position: "absolute",
257
+ width: size,
258
+ ...vertical ? {
259
+ bottom: ICON_PADDING,
260
+ start: across
261
+ } : {
262
+ start: ICON_PADDING,
263
+ top: across
264
+ }
265
+ };
266
+ }
267
+ function iconStyleOf(color, size) {
268
+ return {
269
+ color,
270
+ size
271
+ };
272
+ }
273
+ function innerCornersOf(part, vertical) {
274
+ const start = vertical ? styles.innerStartVertical : styles.innerStart;
275
+ const end = vertical ? styles.innerEndVertical : styles.innerEnd;
276
+ return composeStyles(part.start === AT_END ? void 0 : start, part.end === AT_END ? void 0 : end);
277
+ }
278
+ function InsetIcon(t0) {
279
+ const $ = c(13);
280
+ const { icon, isDisabled, length, metrics, part, vertical } = t0;
281
+ const { colors } = useTheme();
282
+ const size = metrics.icon ?? 0;
283
+ const t1 = isDisabled ? colors.inverseOnSurface : colors.onPrimary;
284
+ let t2;
285
+ if ($[0] !== size || $[1] !== t1) {
286
+ t2 = iconStyleOf(t1, size);
287
+ $[0] = size;
288
+ $[1] = t1;
289
+ $[2] = t2;
290
+ } else t2 = $[2];
291
+ const slot = t2;
292
+ if (lengthOf(part, length) < size + 20) return null;
293
+ let t3;
294
+ if ($[3] !== metrics || $[4] !== size || $[5] !== vertical) {
295
+ t3 = iconPlaceOf(metrics, size, vertical);
296
+ $[3] = metrics;
297
+ $[4] = size;
298
+ $[5] = vertical;
299
+ $[6] = t3;
300
+ } else t3 = $[6];
301
+ let t4;
302
+ if ($[7] !== icon || $[8] !== slot) {
303
+ t4 = /* @__PURE__ */ jsx(IconStyleContext, {
304
+ value: slot,
305
+ children: icon
306
+ });
307
+ $[7] = icon;
308
+ $[8] = slot;
309
+ $[9] = t4;
310
+ } else t4 = $[9];
311
+ let t5;
312
+ if ($[10] !== t3 || $[11] !== t4) {
313
+ t5 = /* @__PURE__ */ jsx(View, {
314
+ style: t3,
315
+ children: t4
316
+ });
317
+ $[10] = t3;
318
+ $[11] = t4;
319
+ $[12] = t5;
320
+ } else t5 = $[12];
321
+ return t5;
322
+ }
323
+ function lengthOf({ end, start }, length) {
324
+ return (1 - start.fraction - end.fraction) * length - start.px - end.px;
325
+ }
326
+ function nameOf(own, group) {
327
+ const words = [own, group].filter((each) => each !== void 0 && each !== "");
328
+ return words.length === 0 ? void 0 : words.join(" ");
329
+ }
330
+ function partColourOf(own, active, isDisabled) {
331
+ if (active) return isDisabled ? own.activeDisabled : own.active;
332
+ return isDisabled ? own.inactiveDisabled : own.inactive;
333
+ }
334
+ function partOf({ corner, handle, track }, { radii }, vertical) {
335
+ const across = (handle - track) / 2;
336
+ return vertical ? {
337
+ borderRadius: radii[corner],
338
+ start: across,
339
+ width: track
340
+ } : {
341
+ borderRadius: radii[corner],
342
+ height: track,
343
+ top: across
344
+ };
345
+ }
346
+ function partsOf(state) {
347
+ const fractions = state.values.map((_, index) => state.getThumbPercent(index));
348
+ const first = fractions[0] ?? 0;
349
+ const last = fractions.at(-1) ?? 0;
350
+ const range = fractions.length > 1;
351
+ const active = {
352
+ active: true,
353
+ end: before(last),
354
+ name: "active",
355
+ start: range ? after(first) : AT_END
356
+ };
357
+ const afterLast = {
358
+ active: false,
359
+ end: AT_END,
360
+ name: "after",
361
+ start: after(last)
362
+ };
363
+ if (!range) return [active, afterLast];
364
+ return [
365
+ {
366
+ active: false,
367
+ end: before(first),
368
+ name: "before",
369
+ start: AT_END
370
+ },
371
+ active,
372
+ afterLast
373
+ ];
374
+ }
375
+ function placementOf({ end, start }, vertical) {
376
+ return vertical ? {
377
+ bottom: percentOf(start.fraction),
378
+ marginBottom: start.px,
379
+ marginTop: end.px,
380
+ top: percentOf(end.fraction)
381
+ } : {
382
+ end: percentOf(end.fraction),
383
+ marginEnd: end.px,
384
+ marginStart: start.px,
385
+ start: percentOf(start.fraction)
386
+ };
387
+ }
388
+ /**
389
+ * A slider for one value, or for a range when the value is an array. Its
390
+ * state is React Stately's, as web's is: pass `value` with `onChange` to
391
+ * control it, or `defaultValue` to let it keep its own, with `minValue`,
392
+ * `maxValue` and `step` to shape it and `formatOptions` to say how it reads.
393
+ *
394
+ * ```tsx
395
+ * <Slider defaultValue={40} label="Label" />
396
+ * ```
397
+ *
398
+ * A press on the track moves the nearest handle there, and a drag carries
399
+ * it. A screen reader hears each handle as an adjustable control named by the
400
+ * label, which it moves a step at a time. `style`, `ref` and `testID` land on
401
+ * the slider as a whole, which is the view a layout positions and the one
402
+ * that gives a vertical slider its height. With a `testID`, the drag and the
403
+ * press are registered with Gesture Handler as `<testID>-pan` and
404
+ * `<testID>-tap`, which its `getByGestureTestId` finds in a test.
405
+ */
406
+ function Slider(t0) {
407
+ const $ = c(55);
408
+ const { "aria-label": ariaLabel, defaultValue, formatOptions, icon, isDisabled: t1, label, maxValue, minValue, onChange, onChangeEnd, orientation: t2, ref, showStops: t3, size: t4, step, style, testID, thumbLabels, value } = t0;
409
+ const isDisabled = t1 === void 0 ? false : t1;
410
+ const orientation = t2 === void 0 ? "horizontal" : t2;
411
+ const showStops = t3 === void 0 ? false : t3;
412
+ const size = t4 === void 0 ? "xs" : t4;
413
+ const theme = useTheme();
414
+ const own = stylesOf(theme);
415
+ const locale = useLocaleOf(void 0);
416
+ let t5;
417
+ if ($[0] !== formatOptions || $[1] !== locale) {
418
+ t5 = new NumberFormatter(locale, formatOptions);
419
+ $[0] = formatOptions;
420
+ $[1] = locale;
421
+ $[2] = t5;
422
+ } else t5 = $[2];
423
+ let t6;
424
+ if ($[3] !== defaultValue || $[4] !== isDisabled || $[5] !== maxValue || $[6] !== minValue || $[7] !== onChange || $[8] !== onChangeEnd || $[9] !== orientation || $[10] !== step || $[11] !== t5 || $[12] !== value) {
425
+ t6 = {
426
+ defaultValue,
427
+ isDisabled,
428
+ maxValue,
429
+ minValue,
430
+ numberFormatter: t5,
431
+ onChange,
432
+ onChangeEnd,
433
+ orientation,
434
+ step,
435
+ value
436
+ };
437
+ $[3] = defaultValue;
438
+ $[4] = isDisabled;
439
+ $[5] = maxValue;
440
+ $[6] = minValue;
441
+ $[7] = onChange;
442
+ $[8] = onChangeEnd;
443
+ $[9] = orientation;
444
+ $[10] = step;
445
+ $[11] = t5;
446
+ $[12] = value;
447
+ $[13] = t6;
448
+ } else t6 = $[13];
449
+ const state = useSliderState(t6);
450
+ const labelRole = useTypeRole("labelLarge");
451
+ const [length, setLength] = useState(0);
452
+ const vertical = orientation === "vertical";
453
+ const metrics = SIZES[size];
454
+ let t7;
455
+ if ($[14] !== isDisabled || $[15] !== length || $[16] !== state || $[17] !== testID || $[18] !== vertical) {
456
+ t7 = {
457
+ isDisabled,
458
+ length,
459
+ state,
460
+ testID,
461
+ vertical
462
+ };
463
+ $[14] = isDisabled;
464
+ $[15] = length;
465
+ $[16] = state;
466
+ $[17] = testID;
467
+ $[18] = vertical;
468
+ $[19] = t7;
469
+ } else t7 = $[19];
470
+ const gesture = useTrackGesture(t7);
471
+ const parts = partsOf(state);
472
+ let t8;
473
+ if ($[20] !== showStops || $[21] !== state) {
474
+ t8 = showStops ? stepsOf(state) : NO_STEPS;
475
+ $[20] = showStops;
476
+ $[21] = state;
477
+ $[22] = t8;
478
+ } else t8 = $[22];
479
+ const steps = t8;
480
+ const hasIcon = icon !== void 0 && icon !== null && metrics.icon !== void 0 && parts.length === 2;
481
+ const group = label ?? ariaLabel;
482
+ const T0 = View;
483
+ const t9 = composeStyles(styles.root, vertical ? styles.rootVertical : void 0, own.root, style);
484
+ const t10 = label === void 0 ? null : /* @__PURE__ */ jsx(Text, {
485
+ "aria-hidden": true,
486
+ style: composeStyles(labelRole, own.label),
487
+ children: label
488
+ });
489
+ const T1 = GestureHandlerRootView;
490
+ let t11;
491
+ if ($[23] !== metrics || $[24] !== vertical) {
492
+ t11 = trackOf(metrics, vertical);
493
+ $[23] = metrics;
494
+ $[24] = vertical;
495
+ $[25] = t11;
496
+ } else t11 = $[25];
497
+ const T2 = GestureDetector;
498
+ const T3 = View;
499
+ let t12;
500
+ if ($[26] !== vertical) {
501
+ t12 = lengthTo(setLength, vertical);
502
+ $[26] = vertical;
503
+ $[27] = t12;
504
+ } else t12 = $[27];
505
+ const t13 = styles;
506
+ const t14 = parts.map((part) => /* @__PURE__ */ jsxs(View, {
507
+ style: composeStyles(styles.part, partOf(metrics, theme, vertical), partColourOf(own, part.active, isDisabled), innerCornersOf(part, vertical), placementOf(part, vertical)),
508
+ children: [part.active && hasIcon ? /* @__PURE__ */ jsx(InsetIcon, {
509
+ icon,
510
+ isDisabled,
511
+ length,
512
+ metrics,
513
+ part,
514
+ vertical
515
+ }) : null, /* @__PURE__ */ jsx(Stops, {
516
+ isDisabled,
517
+ length,
518
+ metrics,
519
+ part,
520
+ showStops,
521
+ steps,
522
+ vertical
523
+ })]
524
+ }, part.name));
525
+ let t15;
526
+ if ($[28] !== group || $[29] !== metrics || $[30] !== state || $[31] !== thumbLabels || $[32] !== vertical) {
527
+ t15 = state.values.map((_, index) => /* @__PURE__ */ jsx(Handle, {
528
+ index,
529
+ metrics,
530
+ name: nameOf(thumbLabels?.[index], group),
531
+ state,
532
+ vertical
533
+ }, index));
534
+ $[28] = group;
535
+ $[29] = metrics;
536
+ $[30] = state;
537
+ $[31] = thumbLabels;
538
+ $[32] = vertical;
539
+ $[33] = t15;
540
+ } else t15 = $[33];
541
+ let t16;
542
+ if ($[34] !== T3 || $[35] !== t12 || $[36] !== t13.area || $[37] !== t14 || $[38] !== t15) {
543
+ t16 = /* @__PURE__ */ jsxs(T3, {
544
+ onLayout: t12,
545
+ style: t13.area,
546
+ children: [t14, t15]
547
+ });
548
+ $[34] = T3;
549
+ $[35] = t12;
550
+ $[36] = t13.area;
551
+ $[37] = t14;
552
+ $[38] = t15;
553
+ $[39] = t16;
554
+ } else t16 = $[39];
555
+ let t17;
556
+ if ($[40] !== T2 || $[41] !== gesture || $[42] !== t16) {
557
+ t17 = /* @__PURE__ */ jsx(T2, {
558
+ gesture,
559
+ children: t16
560
+ });
561
+ $[40] = T2;
562
+ $[41] = gesture;
563
+ $[42] = t16;
564
+ $[43] = t17;
565
+ } else t17 = $[43];
566
+ let t18;
567
+ if ($[44] !== T1 || $[45] !== t11 || $[46] !== t17) {
568
+ t18 = /* @__PURE__ */ jsx(T1, {
569
+ style: t11,
570
+ children: t17
571
+ });
572
+ $[44] = T1;
573
+ $[45] = t11;
574
+ $[46] = t17;
575
+ $[47] = t18;
576
+ } else t18 = $[47];
577
+ let t19;
578
+ if ($[48] !== T0 || $[49] !== ref || $[50] !== t10 || $[51] !== t18 || $[52] !== t9 || $[53] !== testID) {
579
+ t19 = /* @__PURE__ */ jsxs(T0, {
580
+ ref,
581
+ style: t9,
582
+ testID,
583
+ children: [t10, t18]
584
+ });
585
+ $[48] = T0;
586
+ $[49] = ref;
587
+ $[50] = t10;
588
+ $[51] = t18;
589
+ $[52] = t9;
590
+ $[53] = testID;
591
+ $[54] = t19;
592
+ } else t19 = $[54];
593
+ return t19;
594
+ }
595
+ function stepsOf(state) {
596
+ const min = state.getThumbMinValue(0);
597
+ const max = state.getThumbMaxValue(state.values.length - 1);
598
+ const fractions = [];
599
+ if (state.step <= 0) return fractions;
600
+ for (let index = 1; min + index * state.step < max; index++) fractions.push(state.getValuePercent(min + index * state.step));
601
+ return fractions;
602
+ }
603
+ function stopColourOf(own, active, isDisabled) {
604
+ if (active) return isDisabled ? own.stopActiveDisabled : own.stopActive;
605
+ return isDisabled ? own.stopDisabled : void 0;
606
+ }
607
+ function stopOffsetOf({ start }, fraction, length) {
608
+ return (fraction - start.fraction) * length - start.px - STOP / 2;
609
+ }
610
+ function stopPlaceOf({ track }, vertical, offset) {
611
+ const across = (track - STOP) / 2;
612
+ return vertical ? {
613
+ bottom: offset,
614
+ start: across
615
+ } : {
616
+ start: offset,
617
+ top: across
618
+ };
619
+ }
620
+ function Stops(t0) {
621
+ const $ = c(4);
622
+ const { isDisabled, length, metrics, part, showStops, steps, vertical } = t0;
623
+ const own = stylesOf(useTheme());
624
+ const colour = stopColourOf(own, part.active, isDisabled);
625
+ const across = (metrics.track - STOP) / 2;
626
+ const from = part.start.fraction;
627
+ const to = 1 - part.end.fraction;
628
+ const inside = showStops && length > 0 && to > from ? steps.filter((fraction) => fraction >= from && fraction <= to) : [];
629
+ const atStart = part.start === AT_END;
630
+ const atEnd = part.end === AT_END;
631
+ const centred = vertical ? { start: across } : { top: across };
632
+ const t1 = showStops && atStart ? /* @__PURE__ */ jsx(View, { style: composeStyles(styles.stop, own.stop, colour, centred, vertical ? styles.stopStartVertical : styles.stopStart) }) : null;
633
+ const t2 = inside.map((fraction_0) => /* @__PURE__ */ jsx(View, { style: composeStyles(styles.stop, own.stop, colour, stopPlaceOf(metrics, vertical, stopOffsetOf(part, fraction_0, length))) }, fraction_0));
634
+ const t3 = atEnd ? /* @__PURE__ */ jsx(View, { style: composeStyles(styles.stop, own.stop, colour, centred, vertical ? styles.stopEndVertical : styles.stopEnd) }) : null;
635
+ let t4;
636
+ if ($[0] !== t1 || $[1] !== t2 || $[2] !== t3) {
637
+ t4 = /* @__PURE__ */ jsxs(Fragment$1, { children: [
638
+ t1,
639
+ t2,
640
+ t3
641
+ ] });
642
+ $[0] = t1;
643
+ $[1] = t2;
644
+ $[2] = t3;
645
+ $[3] = t4;
646
+ } else t4 = $[3];
647
+ return t4;
648
+ }
649
+ function trackOf({ handle }, vertical) {
650
+ return vertical ? {
651
+ flexGrow: 1,
652
+ minHeight: 0,
653
+ width: handle
654
+ } : { height: handle };
655
+ }
656
+ function useHandleMotion(dragging, vertical) {
657
+ const { motion } = useTheme();
658
+ const reduceMotion = useReducedMotion();
659
+ const thickness = dragging ? HANDLE_PRESSED : HANDLE_WIDTH;
660
+ const timing = {
661
+ duration: motion.durationShort2,
662
+ easing: Easing.bezier(...motion.easingStandard)
663
+ };
664
+ return useAnimatedStyle(() => {
665
+ "worklet";
666
+ const to = reduceMotion ? thickness : withTiming(thickness, timing);
667
+ return vertical ? { height: to } : { width: to };
668
+ });
669
+ }
670
+ //#endregion
671
+ export { Slider };
672
+
673
+ //# sourceMappingURL=index.js.map