@xaui/native 0.9.1-alpha.41 → 0.9.1-alpha.43

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 (105) hide show
  1. package/dist/{chunk-TJ74XVZN.cjs → chunk-3JXI2IHV.cjs} +8 -8
  2. package/dist/{chunk-C5YLPCFC.cjs → chunk-4KSKQD37.cjs} +5 -5
  3. package/dist/{chunk-DA3OKXHV.cjs → chunk-54CWXA34.cjs} +59 -59
  4. package/dist/{chunk-XV735BSA.cjs → chunk-66FOASTP.cjs} +6 -6
  5. package/dist/{chunk-UFTCTTKK.js → chunk-6CO6FM67.js} +15 -15
  6. package/dist/{chunk-RU7JCMWC.cjs → chunk-76XDVA24.cjs} +6 -6
  7. package/dist/{chunk-G7P3ERYF.cjs → chunk-7KLBTMXV.cjs} +5 -5
  8. package/dist/{chunk-NWGLP6JX.cjs → chunk-7TOG4TVU.cjs} +15 -15
  9. package/dist/{chunk-ZFOOJK37.cjs → chunk-AAVCMCJ3.cjs} +2 -2
  10. package/dist/{chunk-T5FV5F7A.cjs → chunk-C5LONNXT.cjs} +6 -6
  11. package/dist/{chunk-XFPQFCEK.js → chunk-DY3SUG5P.js} +6 -6
  12. package/dist/{chunk-KCMYU7WF.js → chunk-EYD4H4X6.js} +1 -1
  13. package/dist/{chunk-DHGLGSH6.js → chunk-FBCWNXZC.js} +58 -58
  14. package/dist/{chunk-2XPG2243.js → chunk-GJSFKH4L.js} +16 -16
  15. package/dist/{chunk-DD4276RF.js → chunk-HA6BFY3A.js} +6 -6
  16. package/dist/{chunk-GFUZ3MUT.cjs → chunk-HOI5425P.cjs} +6 -6
  17. package/dist/chunk-J5WXI5NU.js +520 -0
  18. package/dist/{chunk-LRN3RNDO.js → chunk-JKP4TPIL.js} +16 -16
  19. package/dist/{chunk-6UEZJRVI.js → chunk-LIUO6D3D.js} +75 -75
  20. package/dist/{chunk-DIBUQ46Y.js → chunk-MXGER5PI.js} +5 -5
  21. package/dist/{chunk-EZEYMLO3.js → chunk-N5AEXTUM.js} +4 -4
  22. package/dist/chunk-NA262TF2.js +724 -0
  23. package/dist/{chunk-R73XQK7X.cjs → chunk-NCCRQK3P.cjs} +5 -5
  24. package/dist/{chunk-5VKYNBNA.js → chunk-NHZRQM5J.js} +4 -4
  25. package/dist/chunk-P2GKAAA3.cjs +442 -0
  26. package/dist/{chunk-VLKBESEV.cjs → chunk-QWMVMLSU.cjs} +5 -5
  27. package/dist/{chunk-GA6PBWNT.js → chunk-QZ24MZRX.js} +1 -1
  28. package/dist/{chunk-YVHT2UVW.js → chunk-R7BU4CPS.js} +1 -1
  29. package/dist/{chunk-6DOLGZVV.cjs → chunk-S4QUM4EE.cjs} +4 -4
  30. package/dist/{chunk-DG2I4PJG.js → chunk-SACDOFGF.js} +15 -15
  31. package/dist/{chunk-ABAGZTXZ.cjs → chunk-SIP5J7HU.cjs} +15 -15
  32. package/dist/{chunk-3E7CDKFO.cjs → chunk-TGMVEHV7.cjs} +61 -61
  33. package/dist/{chunk-YGYYJ3LQ.js → chunk-TRETQZEW.js} +5 -5
  34. package/dist/{chunk-UAWBAD4E.cjs → chunk-URA25DU4.cjs} +5 -5
  35. package/dist/{chunk-BRRXFOBY.js → chunk-USF6EWYR.js} +7 -7
  36. package/dist/{chunk-5R26NM4M.cjs → chunk-VPQPFLT5.cjs} +6 -6
  37. package/dist/{chunk-G3CCT4EY.js → chunk-VT34G7RT.js} +16 -16
  38. package/dist/{chunk-7YF5NAHQ.cjs → chunk-VZK3NLBH.cjs} +7 -7
  39. package/dist/{chunk-N3KTZMPG.js → chunk-XNMZQSY5.js} +5 -5
  40. package/dist/chunk-ZTBA7CNK.cjs +510 -0
  41. package/dist/components/accordion/index.cjs +5 -5
  42. package/dist/components/accordion/index.js +4 -4
  43. package/dist/components/alert/index.cjs +6 -6
  44. package/dist/components/alert/index.js +5 -5
  45. package/dist/components/avatar/index.cjs +4 -4
  46. package/dist/components/avatar/index.js +3 -3
  47. package/dist/components/badge/index.cjs +4 -4
  48. package/dist/components/badge/index.js +3 -3
  49. package/dist/components/bottom-sheet/index.cjs +37 -0
  50. package/dist/components/bottom-sheet/index.d.cts +230 -0
  51. package/dist/components/bottom-sheet/index.d.ts +230 -0
  52. package/dist/components/bottom-sheet/index.js +37 -0
  53. package/dist/components/button/index.cjs +5 -5
  54. package/dist/components/button/index.js +4 -4
  55. package/dist/components/card/index.cjs +5 -5
  56. package/dist/components/card/index.js +4 -4
  57. package/dist/components/checkbox/index.cjs +5 -5
  58. package/dist/components/checkbox/index.js +4 -4
  59. package/dist/components/chip/index.cjs +6 -6
  60. package/dist/components/chip/index.js +5 -5
  61. package/dist/components/divider/index.cjs +4 -4
  62. package/dist/components/divider/index.js +3 -3
  63. package/dist/components/field-group/index.cjs +5 -5
  64. package/dist/components/field-group/index.js +4 -4
  65. package/dist/components/input-otp/index.cjs +4 -4
  66. package/dist/components/input-otp/index.js +3 -3
  67. package/dist/components/menu/index.cjs +5 -5
  68. package/dist/components/menu/index.js +4 -4
  69. package/dist/components/popover/index.cjs +5 -5
  70. package/dist/components/popover/index.js +4 -4
  71. package/dist/components/radio/index.cjs +5 -5
  72. package/dist/components/radio/index.js +4 -4
  73. package/dist/components/select/index.cjs +5 -5
  74. package/dist/components/select/index.js +4 -4
  75. package/dist/components/slider/index.cjs +33 -0
  76. package/dist/components/slider/index.d.cts +284 -0
  77. package/dist/components/slider/index.d.ts +284 -0
  78. package/dist/components/slider/index.js +33 -0
  79. package/dist/components/spinner/index.cjs +1 -1
  80. package/dist/components/spinner/index.js +1 -1
  81. package/dist/components/switch/index.cjs +5 -5
  82. package/dist/components/switch/index.js +4 -4
  83. package/dist/components/tabs/index.cjs +5 -5
  84. package/dist/components/tabs/index.js +4 -4
  85. package/dist/components/text-area/index.cjs +5 -5
  86. package/dist/components/text-area/index.js +4 -4
  87. package/dist/components/text-field/index.cjs +4 -4
  88. package/dist/components/text-field/index.js +3 -3
  89. package/dist/components/typography/index.cjs +4 -4
  90. package/dist/components/typography/index.js +3 -3
  91. package/dist/index.cjs +85 -37
  92. package/dist/index.d.cts +2 -0
  93. package/dist/index.d.ts +2 -0
  94. package/dist/index.js +132 -84
  95. package/dist/system/index.cjs +11 -11
  96. package/dist/system/index.js +13 -13
  97. package/package.json +21 -1
  98. package/dist/{chunk-4CUZZWFW.js → chunk-26OGEFQI.js} +3 -3
  99. package/dist/{chunk-H7DS4IO7.js → chunk-346QBNUD.js} +4 -4
  100. package/dist/{chunk-J3MB4PI5.cjs → chunk-A7YB7YWX.cjs} +3 -3
  101. package/dist/{chunk-AMCSSOJT.cjs → chunk-BNFIFRQA.cjs} +3 -3
  102. package/dist/{chunk-6L2TS2R3.cjs → chunk-KSUV74BE.cjs} +3 -3
  103. package/dist/{chunk-HDVVZG4S.cjs → chunk-RKCWYUGA.cjs} +3 -3
  104. package/dist/{chunk-2NRZKJG7.js → chunk-S2WNWMNT.js} +4 -4
  105. package/dist/{chunk-73RKQC5X.js → chunk-SZLXPF3G.js} +3 -3
@@ -0,0 +1,724 @@
1
+ import { useControllableState } from "./chunk-F6W3JQ7K.js";
2
+ import { createSlotContext } from "./chunk-K72UDPVN.js";
3
+ import { createRecipe, radiusAxis } from "./chunk-4GTAZM2C.js";
4
+ import { alpha, useXAUITheme } from "./chunk-A3EGFI6T.js";
5
+ import { useStyleProps } from "./chunk-M63GFNKV.js";
6
+
7
+ // src/components/slider/slider-fill.tsx
8
+ import { forwardRef } from "react";
9
+ import { View } from "react-native";
10
+
11
+ // src/components/slider/slider.context.ts
12
+ var [SliderProvider, useSlider] = createSlotContext("Slider");
13
+
14
+ // src/components/slider/slider-fill.tsx
15
+ import { jsx } from "react/jsx-runtime";
16
+ var SliderFill = forwardRef(function SliderFill2({
17
+ style,
18
+ ...props
19
+ }, ref) {
20
+ const {
21
+ fillStyle,
22
+ fractions,
23
+ trackLength,
24
+ thumbSize,
25
+ orientation
26
+ } = useSlider();
27
+ const [styleProps, rest] = useStyleProps(props);
28
+ const travel = Math.max(trackLength - thumbSize, 0);
29
+ const half = thumbSize / 2;
30
+ const from = fractions.length > 1 ? fractions[0] * travel + half : 0;
31
+ const to = fractions[fractions.length - 1] * travel + half;
32
+ const vertical = orientation === "vertical";
33
+ return /* @__PURE__ */jsx(View, {
34
+ ref,
35
+ ...rest,
36
+ style: [fillStyle, vertical ? {
37
+ bottom: from,
38
+ height: to - from,
39
+ top: void 0
40
+ } : {
41
+ start: from,
42
+ width: to - from,
43
+ end: void 0
44
+ }, styleProps, style]
45
+ });
46
+ });
47
+ SliderFill.displayName = "XAUI.Slider.Fill";
48
+
49
+ // src/components/slider/slider-output.tsx
50
+ import { forwardRef as forwardRef2 } from "react";
51
+ import { Text } from "react-native";
52
+ import { jsx as jsx2 } from "react/jsx-runtime";
53
+ var SliderOutput = forwardRef2(function SliderOutput2({
54
+ children,
55
+ style,
56
+ ...props
57
+ }, ref) {
58
+ const {
59
+ outputStyle,
60
+ values
61
+ } = useSlider();
62
+ const [styleProps, rest] = useStyleProps(props);
63
+ const value = values.length > 1 ? [values[0], values[1]] : values[0];
64
+ const text = values.length > 1 ? `${values[0]} \u2013 ${values[1]}` : String(values[0]);
65
+ return /* @__PURE__ */jsx2(Text, {
66
+ ref,
67
+ ...rest,
68
+ style: [outputStyle, styleProps, style],
69
+ children: typeof children === "function" ? children(value) : children ?? text
70
+ });
71
+ });
72
+ SliderOutput.displayName = "XAUI.Slider.Output";
73
+
74
+ // src/components/slider/slider-thumb.tsx
75
+ import { useCallback } from "react";
76
+ import { Gesture, GestureDetector } from "react-native-gesture-handler";
77
+ import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withSpring } from "react-native-reanimated";
78
+
79
+ // src/components/slider/slider.animation.ts
80
+ var THUMB_PRESSED_SCALE = 1.15;
81
+ var THUMB_SPRING = {
82
+ damping: 18,
83
+ stiffness: 320,
84
+ mass: 0.5
85
+ };
86
+
87
+ // src/components/slider/slider-thumb.tsx
88
+ import { jsx as jsx3 } from "react/jsx-runtime";
89
+ const _worklet_13955987328420_init_data = {
90
+ code: "function chunkNA262TF2Js1(){const{pressed,withSpring,THUMB_SPRING,runOnJS,commit}=this.__closure;pressed.set(withSpring(0,THUMB_SPRING));runOnJS(commit)();}",
91
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-NA262TF2.js",
92
+ sourceMap: "{\"version\":3,\"names\":[\"chunkNA262TF2Js1\",\"pressed\",\"withSpring\",\"THUMB_SPRING\",\"runOnJS\",\"commit\",\"__closure\",\"set\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-NA262TF2.js\"],\"mappings\":\"AAwHgB,SAAAA,gBAAMA,CAAA,QAAAC,OAAA,CAAAC,UAAA,CAAAC,YAAA,CAAAC,OAAA,CAAAC,MAAA,OAAAC,SAAA,CAClBL,OAAO,CAACM,GAAG,CAACL,UAAU,CAAC,CAAC,CAAEC,YAAY,CAAC,CAAC,CACxCC,OAAO,CAACC,MAAM,CAAC,CAAC,CAAC,CACnB\",\"ignoreList\":[]}"
93
+ };
94
+ const _worklet_11881772404790_init_data = {
95
+ code: "function chunkNA262TF2Js2(event){const{runOnJS,move,start,vertical}=this.__closure;runOnJS(move)(start.get()+(vertical?-event.translationY:event.translationX));}",
96
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-NA262TF2.js",
97
+ sourceMap: "{\"version\":3,\"names\":[\"chunkNA262TF2Js2\",\"event\",\"runOnJS\",\"move\",\"start\",\"vertical\",\"__closure\",\"get\",\"translationY\",\"translationX\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-NA262TF2.js\"],\"mappings\":\"AAoHe,SAAAA,gBAAUA,CAAAC,KAAA,QAAAC,OAAA,CAAAC,IAAA,CAAAC,KAAA,CAAAC,QAAA,OAAAC,SAAA,CACrBJ,OAAO,CAACC,IAAI,CAAC,CACXC,KAAK,CAACG,GAAG,CAAC,CAAC,EAAIF,QAAQ,CAAG,CAACJ,KAAK,CAACO,YAAY,CAAGP,KAAK,CAACQ,YAAY,CACpE,CAAC,CACH\",\"ignoreList\":[]}"
98
+ };
99
+ const _worklet_16385302688620_init_data = {
100
+ code: "function chunkNA262TF2Js3(){const{start,fraction,travel,pressed,withSpring,THUMB_SPRING}=this.__closure;start.set(fraction*travel);pressed.set(withSpring(1,THUMB_SPRING));}",
101
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-NA262TF2.js",
102
+ sourceMap: "{\"version\":3,\"names\":[\"chunkNA262TF2Js3\",\"start\",\"fraction\",\"travel\",\"pressed\",\"withSpring\",\"THUMB_SPRING\",\"__closure\",\"set\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-NA262TF2.js\"],\"mappings\":\"AAiHyD,SAAAA,gBAAMA,CAAA,QAAAC,KAAA,CAAAC,QAAA,CAAAC,MAAA,CAAAC,OAAA,CAAAC,UAAA,CAAAC,YAAA,OAAAC,SAAA,CAC3DN,KAAK,CAACO,GAAG,CAACN,QAAQ,CAAGC,MAAM,CAAC,CAC5BC,OAAO,CAACI,GAAG,CAACH,UAAU,CAAC,CAAC,CAAEC,YAAY,CAAC,CAAC,CAC1C\",\"ignoreList\":[]}"
103
+ };
104
+ const _worklet_5964515333194_init_data = {
105
+ code: "function chunkNA262TF2Js4(){const{pressed,THUMB_PRESSED_SCALE}=this.__closure;return{transform:[{scale:1+pressed.get()*(THUMB_PRESSED_SCALE-1)}]};}",
106
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-NA262TF2.js",
107
+ sourceMap: "{\"version\":3,\"names\":[\"chunkNA262TF2Js4\",\"pressed\",\"THUMB_PRESSED_SCALE\",\"__closure\",\"transform\",\"scale\",\"get\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-NA262TF2.js\"],\"mappings\":\"AA4HiC,SAAAA,iBAAA,QAAAC,OAAA,CAAAC,mBAAA,OAAAC,SAAA,OAAO,CACpCC,SAAS,CAAE,CAAC,CAAEC,KAAK,CAAE,CAAC,CAAGJ,OAAO,CAACK,GAAG,CAAC,CAAC,EAAIJ,mBAAmB,CAAG,CAAC,CAAE,CAAC,CACtE,CAAC\",\"ignoreList\":[]}"
108
+ };
109
+ function SliderThumb({
110
+ index = 0,
111
+ accessibilityValueText,
112
+ style,
113
+ ...props
114
+ }) {
115
+ const {
116
+ thumbStyle,
117
+ values,
118
+ min,
119
+ max,
120
+ step,
121
+ isDisabled,
122
+ fractions,
123
+ trackLength,
124
+ thumbSize,
125
+ orientation,
126
+ slideTo,
127
+ commit
128
+ } = useSlider();
129
+ const [styleProps, rest] = useStyleProps(props);
130
+ const pressed = useSharedValue(0);
131
+ const vertical = orientation === "vertical";
132
+ const travel = Math.max(trackLength - thumbSize, 0);
133
+ const value = values[index] ?? values[0];
134
+ const fraction = fractions[index] ?? fractions[0];
135
+ const start = useSharedValue(0);
136
+ const move = useCallback(along => slideTo(index, travel === 0 ? 0 : along / travel), [index, slideTo, travel]);
137
+ const pan = Gesture.Pan().enabled(!isDisabled).onBegin(function chunkNA262TF2Js3Factory({
138
+ _worklet_16385302688620_init_data,
139
+ start,
140
+ fraction,
141
+ travel,
142
+ pressed,
143
+ withSpring,
144
+ THUMB_SPRING
145
+ }) {
146
+ const _e = [new global.Error(), -7, -27];
147
+ const chunkNA262TF2Js3 = function () {
148
+ start.set(fraction * travel);
149
+ pressed.set(withSpring(1, THUMB_SPRING));
150
+ };
151
+ chunkNA262TF2Js3.__closure = {
152
+ start,
153
+ fraction,
154
+ travel,
155
+ pressed,
156
+ withSpring,
157
+ THUMB_SPRING
158
+ };
159
+ chunkNA262TF2Js3.__workletHash = 16385302688620;
160
+ chunkNA262TF2Js3.__pluginVersion = "0.7.4";
161
+ chunkNA262TF2Js3.__initData = _worklet_16385302688620_init_data;
162
+ chunkNA262TF2Js3.__stackDetails = _e;
163
+ return chunkNA262TF2Js3;
164
+ }({
165
+ _worklet_16385302688620_init_data,
166
+ start,
167
+ fraction,
168
+ travel,
169
+ pressed,
170
+ withSpring,
171
+ THUMB_SPRING
172
+ })).onUpdate(function chunkNA262TF2Js2Factory({
173
+ _worklet_11881772404790_init_data,
174
+ runOnJS,
175
+ move,
176
+ start,
177
+ vertical
178
+ }) {
179
+ const _e = [new global.Error(), -5, -27];
180
+ const chunkNA262TF2Js2 = function (event) {
181
+ runOnJS(move)(start.get() + (vertical ? -event.translationY : event.translationX));
182
+ };
183
+ chunkNA262TF2Js2.__closure = {
184
+ runOnJS,
185
+ move,
186
+ start,
187
+ vertical
188
+ };
189
+ chunkNA262TF2Js2.__workletHash = 11881772404790;
190
+ chunkNA262TF2Js2.__pluginVersion = "0.7.4";
191
+ chunkNA262TF2Js2.__initData = _worklet_11881772404790_init_data;
192
+ chunkNA262TF2Js2.__stackDetails = _e;
193
+ return chunkNA262TF2Js2;
194
+ }({
195
+ _worklet_11881772404790_init_data,
196
+ runOnJS,
197
+ move,
198
+ start,
199
+ vertical
200
+ })).onFinalize(function chunkNA262TF2Js1Factory({
201
+ _worklet_13955987328420_init_data,
202
+ pressed,
203
+ withSpring,
204
+ THUMB_SPRING,
205
+ runOnJS,
206
+ commit
207
+ }) {
208
+ const _e = [new global.Error(), -6, -27];
209
+ const chunkNA262TF2Js1 = function () {
210
+ pressed.set(withSpring(0, THUMB_SPRING));
211
+ runOnJS(commit)();
212
+ };
213
+ chunkNA262TF2Js1.__closure = {
214
+ pressed,
215
+ withSpring,
216
+ THUMB_SPRING,
217
+ runOnJS,
218
+ commit
219
+ };
220
+ chunkNA262TF2Js1.__workletHash = 13955987328420;
221
+ chunkNA262TF2Js1.__pluginVersion = "0.7.4";
222
+ chunkNA262TF2Js1.__initData = _worklet_13955987328420_init_data;
223
+ chunkNA262TF2Js1.__stackDetails = _e;
224
+ return chunkNA262TF2Js1;
225
+ }({
226
+ _worklet_13955987328420_init_data,
227
+ pressed,
228
+ withSpring,
229
+ THUMB_SPRING,
230
+ runOnJS,
231
+ commit
232
+ }));
233
+ const scale = useAnimatedStyle(function chunkNA262TF2Js4Factory({
234
+ _worklet_5964515333194_init_data,
235
+ pressed,
236
+ THUMB_PRESSED_SCALE
237
+ }) {
238
+ const _e = [new global.Error(), -3, -27];
239
+ const chunkNA262TF2Js4 = () => ({
240
+ transform: [{
241
+ scale: 1 + pressed.get() * (THUMB_PRESSED_SCALE - 1)
242
+ }]
243
+ });
244
+ chunkNA262TF2Js4.__closure = {
245
+ pressed,
246
+ THUMB_PRESSED_SCALE
247
+ };
248
+ chunkNA262TF2Js4.__workletHash = 5964515333194;
249
+ chunkNA262TF2Js4.__pluginVersion = "0.7.4";
250
+ chunkNA262TF2Js4.__initData = _worklet_5964515333194_init_data;
251
+ chunkNA262TF2Js4.__stackDetails = _e;
252
+ return chunkNA262TF2Js4;
253
+ }({
254
+ _worklet_5964515333194_init_data,
255
+ pressed,
256
+ THUMB_PRESSED_SCALE
257
+ }));
258
+ return /* @__PURE__ */jsx3(GestureDetector, {
259
+ gesture: pan,
260
+ children: /* @__PURE__ */jsx3(Animated.View, {
261
+ accessibilityRole: "adjustable",
262
+ accessibilityValue: {
263
+ min,
264
+ max,
265
+ now: value,
266
+ text: accessibilityValueText?.(value)
267
+ },
268
+ accessibilityActions: [{
269
+ name: "increment"
270
+ }, {
271
+ name: "decrement"
272
+ }],
273
+ onAccessibilityAction: event => {
274
+ const delta = event.nativeEvent.actionName === "increment" ? step : -step;
275
+ const next = value + (step === 0 ? (max - min) / 10 : delta);
276
+ slideTo(index, max === min ? 0 : (next - min) / (max - min));
277
+ commit();
278
+ },
279
+ "aria-disabled": isDisabled || void 0,
280
+ ...rest,
281
+ style: [thumbStyle, vertical ? {
282
+ bottom: fraction * travel
283
+ } : {
284
+ start: fraction * travel
285
+ }, scale, styleProps, style]
286
+ })
287
+ });
288
+ }
289
+ SliderThumb.displayName = "XAUI.Slider.Thumb";
290
+
291
+ // src/components/slider/slider-track.tsx
292
+ import { forwardRef as forwardRef3, useCallback as useCallback2 } from "react";
293
+ import { Pressable } from "react-native";
294
+ import { jsx as jsx4 } from "react/jsx-runtime";
295
+ var SliderTrack = forwardRef3(function SliderTrack2({
296
+ children,
297
+ style,
298
+ onLayout,
299
+ ...props
300
+ }, ref) {
301
+ const {
302
+ trackStyle,
303
+ trackLength,
304
+ thumbSize,
305
+ orientation,
306
+ isDisabled,
307
+ setTrackLength,
308
+ slideTo,
309
+ thumbFor,
310
+ commit
311
+ } = useSlider();
312
+ const [styleProps, rest] = useStyleProps(props);
313
+ const vertical = orientation === "vertical";
314
+ const measure = useCallback2(event => {
315
+ onLayout?.(event);
316
+ const {
317
+ width,
318
+ height
319
+ } = event.nativeEvent.layout;
320
+ setTrackLength(vertical ? height : width);
321
+ }, [onLayout, setTrackLength, vertical]);
322
+ const handlePress = useCallback2(event => {
323
+ const travel = Math.max(trackLength - thumbSize, 1);
324
+ const along = vertical ?
325
+ // Counted from the bottom: a press near the floor of a vertical rail is a small
326
+ // value, not a large one.
327
+ trackLength - event.nativeEvent.locationY : event.nativeEvent.locationX;
328
+ const fraction = (along - thumbSize / 2) / travel;
329
+ slideTo(thumbFor(fraction), fraction);
330
+ commit();
331
+ }, [commit, slideTo, thumbFor, thumbSize, trackLength, vertical]);
332
+ return /* @__PURE__ */jsx4(Pressable, {
333
+ ref,
334
+ disabled: isDisabled,
335
+ onPress: handlePress,
336
+ ...rest,
337
+ onLayout: measure,
338
+ style: [trackStyle, styleProps, style],
339
+ children
340
+ });
341
+ });
342
+ SliderTrack.displayName = "XAUI.Slider.Track";
343
+
344
+ // src/components/slider/slider.tsx
345
+ import { forwardRef as forwardRef4, useCallback as useCallback3, useMemo, useState } from "react";
346
+ import { StyleSheet, View as View2 } from "react-native";
347
+
348
+ // src/components/slider/slider.recipe.ts
349
+ var SLOTS = ["root", "output", "track", "fill", "thumb"];
350
+ var VARIANT_TOKENS = {
351
+ default: {
352
+ bg: "default",
353
+ bgSelected: "accent"
354
+ }
355
+ };
356
+ var FILL_ALPHA = 0.35;
357
+ var SIZES = {
358
+ sm: {
359
+ track: 6,
360
+ thumb: 16,
361
+ output: "xs"
362
+ },
363
+ md: {
364
+ track: 8,
365
+ thumb: 20,
366
+ output: "sm"
367
+ },
368
+ lg: {
369
+ track: 10,
370
+ thumb: 24,
371
+ output: "md"
372
+ }
373
+ };
374
+ var VERTICAL_LENGTH = 220;
375
+ function rail(step, orientation) {
376
+ const {
377
+ track,
378
+ thumb,
379
+ output
380
+ } = step;
381
+ const vertical = orientation === "vertical";
382
+ const overhang = (thumb - track) / 2;
383
+ return theme => ({
384
+ root: vertical ? {
385
+ flexDirection: "row",
386
+ alignItems: "center"
387
+ } : {
388
+ flexDirection: "column",
389
+ width: "100%"
390
+ },
391
+ track: vertical ? {
392
+ width: track,
393
+ height: VERTICAL_LENGTH,
394
+ alignItems: "center",
395
+ // The room the knob needs, reserved by the rail rather than by a box around it.
396
+ // Without it the knob overhangs into whatever is beside the slider, and the
397
+ // layout has no idea the control is wider than its rail.
398
+ marginHorizontal: overhang
399
+ } : {
400
+ height: track,
401
+ width: "100%",
402
+ justifyContent: "center",
403
+ marginVertical: overhang
404
+ },
405
+ // Pulled back by the overhang so its centre sits on the rail's centre line.
406
+ thumb: vertical ? {
407
+ width: thumb,
408
+ height: thumb,
409
+ borderRadius: thumb / 2,
410
+ start: -overhang
411
+ } : {
412
+ width: thumb,
413
+ height: thumb,
414
+ borderRadius: thumb / 2,
415
+ top: -overhang
416
+ },
417
+ fill: vertical ? {
418
+ start: 0,
419
+ end: 0,
420
+ bottom: 0
421
+ } : {
422
+ top: 0,
423
+ bottom: 0,
424
+ start: 0
425
+ },
426
+ output: {
427
+ fontSize: theme.fontSizes[output],
428
+ lineHeight: theme.lineHeights[output]
429
+ }
430
+ });
431
+ }
432
+ var sliderRecipe = createRecipe({
433
+ slots: SLOTS,
434
+ base: theme => ({
435
+ root: {
436
+ gap: theme.spacing(2)
437
+ },
438
+ output: {
439
+ fontFamily: theme.fontFamilies.body,
440
+ fontWeight: theme.fontWeights.medium,
441
+ color: theme.colors.muted
442
+ },
443
+ // `full` rather than a step of the radius scale: a rail's ends are semicircles at every
444
+ // thickness, and any fixed number is wrong for two of the three sizes.
445
+ track: {
446
+ borderRadius: theme.radius.full
447
+ },
448
+ fill: {
449
+ position: "absolute",
450
+ borderRadius: theme.radius.full
451
+ },
452
+ /**
453
+ * The knob: a solid disc of the fill's own colour, lifted off the rail by a shadow.
454
+ *
455
+ * That is Material's slider thumb rather than the legacy component's, which drew a
456
+ * ring — the page's colour inside a two-point border. A ring reads as weak at sixteen
457
+ * points and disappears against a busy background, and its border is the same two
458
+ * points whether the knob is 16 or 24, so the smallest size is proportionally the
459
+ * thinnest. The disc is the same shape at every size, and it never has to fight the
460
+ * fill for contrast because the fill is a softened version of it.
461
+ */
462
+ thumb: {
463
+ position: "absolute",
464
+ ...theme.shadows.surface
465
+ }
466
+ }),
467
+ variantTokens: VARIANT_TOKENS,
468
+ /**
469
+ * Three steps of one colour, not two.
470
+ *
471
+ * The rail is the theme's neutral; the reach is the colour at `FILL_ALPHA`; the knob is
472
+ * the colour at full. Read left to right that is grey, then a wash of the colour, then
473
+ * the colour — so the eye lands on the knob, which is the value, rather than on the bar
474
+ * behind it, which is only how far the value has come.
475
+ *
476
+ * Material's slider is the same relationship with the steps assigned differently: their
477
+ * inactive track is the soft one and their active track is full. Moving the soft step
478
+ * onto the *reach* rather than the remainder is where this stops being theirs — a filled
479
+ * bar at full strength competes with the handle for the eye, and the handle is the part
480
+ * you can move.
481
+ *
482
+ * Both the reach and the knob come off the same role, so a raw `color` moves all three
483
+ * steps at once and none of them can drift from the others.
484
+ */
485
+ paint: (_theme, colors) => ({
486
+ track: {
487
+ backgroundColor: colors.bg
488
+ },
489
+ fill: {
490
+ backgroundColor: colors.bgSelected ? alpha(colors.bgSelected, FILL_ALPHA) : void 0
491
+ },
492
+ thumb: {
493
+ backgroundColor: colors.bgSelected
494
+ }
495
+ }),
496
+ variants: {
497
+ // The axes select; the compound below is what paints. Both are declared so `size` and
498
+ // `orientation` are part of the cache key and a press still allocates nothing.
499
+ size: {
500
+ sm: () => ({}),
501
+ md: () => ({}),
502
+ lg: () => ({})
503
+ },
504
+ orientation: {
505
+ horizontal: () => ({}),
506
+ vertical: () => ({})
507
+ },
508
+ radius: radiusAxis("track", "fill")
509
+ },
510
+ compoundVariants: ["sm", "md", "lg"].flatMap(size => ["horizontal", "vertical"].map(orientation => ({
511
+ when: {
512
+ size,
513
+ orientation
514
+ },
515
+ style: rail(SIZES[size], orientation)
516
+ }))),
517
+ states: {
518
+ /**
519
+ * Grey, and the colour goes entirely. A disabled slider still reports a value, so the
520
+ * bar has to stay legible — dimming the accent would leave a pale lavender that reads
521
+ * as an enabled slider seen through fog, where a neutral one reads as switched off.
522
+ */
523
+ disabled: theme => ({
524
+ root: {
525
+ opacity: theme.opacity.disabled
526
+ },
527
+ fill: {
528
+ backgroundColor: theme.colors.defaultSoft
529
+ },
530
+ thumb: {
531
+ backgroundColor: theme.colors.muted
532
+ }
533
+ })
534
+ },
535
+ defaultVariants: {
536
+ variant: "default",
537
+ size: "md",
538
+ orientation: "horizontal"
539
+ }
540
+ });
541
+
542
+ // src/components/slider/slider.utils.ts
543
+ function toFraction(value, {
544
+ min,
545
+ max
546
+ }) {
547
+ if (max === min) return 0;
548
+ return clamp((value - min) / (max - min), 0, 1);
549
+ }
550
+ function fromFraction(fraction, range) {
551
+ const {
552
+ min,
553
+ max
554
+ } = range;
555
+ return snap(min + clamp(fraction, 0, 1) * (max - min), range);
556
+ }
557
+ function snap(value, {
558
+ min,
559
+ max,
560
+ step
561
+ }) {
562
+ if (step <= 0) return clamp(value, min, max);
563
+ const steps = Math.round((clamp(value, min, max) - min) / step);
564
+ return clamp(round(min + steps * step, min, step), min, max);
565
+ }
566
+ function round(value, min, step) {
567
+ const factor = 10 ** Math.max(decimalsOf(step), decimalsOf(min));
568
+ return Math.round(value * factor) / factor;
569
+ }
570
+ function decimalsOf(step) {
571
+ const text = String(step);
572
+ const dot = text.indexOf(".");
573
+ return dot === -1 ? 0 : text.length - dot - 1;
574
+ }
575
+ function clamp(value, min, max) {
576
+ return Math.min(Math.max(value, min), max);
577
+ }
578
+ function toValues(value, range) {
579
+ return Array.isArray(value) ? [snap(value[0], range), snap(value[1], range)] : [snap(value, range)];
580
+ }
581
+ function fromValues(values) {
582
+ return values.length > 1 ? [values[0], values[1]] : values[0];
583
+ }
584
+ function withThumbAt(values, index, value, range) {
585
+ const next = [...values];
586
+ const lower = index > 0 ? values[index - 1] : range.min;
587
+ const upper = index < values.length - 1 ? values[index + 1] : range.max;
588
+ next[index] = snap(Math.min(Math.max(value, lower), upper), range);
589
+ return next;
590
+ }
591
+ function nearestThumb(values, value) {
592
+ let best = 0;
593
+ let distance = Math.abs(values[0] - value);
594
+ for (let i = 1; i < values.length; i += 1) {
595
+ const d = Math.abs(values[i] - value);
596
+ if (d < distance) {
597
+ best = i;
598
+ distance = d;
599
+ }
600
+ }
601
+ return best;
602
+ }
603
+
604
+ // src/components/slider/slider.tsx
605
+ import { jsx as jsx5 } from "react/jsx-runtime";
606
+ var SliderRoot = forwardRef4(function Slider({
607
+ children,
608
+ size,
609
+ orientation = "horizontal",
610
+ radius,
611
+ color,
612
+ value: controlledValue,
613
+ defaultValue = 0,
614
+ onValueChange,
615
+ onValueCommit,
616
+ min = 0,
617
+ max = 100,
618
+ step = 1,
619
+ isDisabled = false,
620
+ style,
621
+ ...props
622
+ }, ref) {
623
+ const theme = useXAUITheme();
624
+ const [styleProps, rest] = useStyleProps(props);
625
+ const [trackLength, setTrackLength] = useState(0);
626
+ const range = {
627
+ min,
628
+ max,
629
+ step
630
+ };
631
+ const [raw, setValue] = useControllableState({
632
+ value: controlledValue,
633
+ defaultValue,
634
+ onChange: onValueChange
635
+ });
636
+ const values = toValues(raw, range);
637
+ const selection = {
638
+ size,
639
+ orientation,
640
+ radius
641
+ };
642
+ const styles = sliderRecipe.resolve({
643
+ theme,
644
+ selection,
645
+ states: {
646
+ disabled: isDisabled
647
+ }
648
+ });
649
+ const tint = color ? sliderRecipe.tint({
650
+ theme,
651
+ color,
652
+ selection
653
+ }) : void 0;
654
+ const slideTo = useCallback3((index, fraction) => {
655
+ const at = fromFraction(fraction, {
656
+ min,
657
+ max,
658
+ step
659
+ });
660
+ setValue(current => fromValues(withThumbAt(toValues(current, {
661
+ min,
662
+ max,
663
+ step
664
+ }), index, at, {
665
+ min,
666
+ max,
667
+ step
668
+ })));
669
+ }, [max, min, setValue, step]);
670
+ const thumbFor = useCallback3(fraction => nearestThumb(values, fromFraction(fraction, {
671
+ min,
672
+ max,
673
+ step
674
+ })), [max, min, step, values]);
675
+ const commit = useCallback3(() => onValueCommit?.(fromValues(values)), [onValueCommit, values]);
676
+ const context = useMemo(() => {
677
+ const thumb = StyleSheet.flatten([styles.thumb]);
678
+ return {
679
+ outputStyle: styles.output,
680
+ trackStyle: tint ? [styles.track, tint.track] : styles.track,
681
+ fillStyle: tint ? [styles.fill, tint.fill] : styles.fill,
682
+ thumbStyle: tint ? [styles.thumb, tint.thumb] : styles.thumb,
683
+ orientation,
684
+ values,
685
+ min,
686
+ max,
687
+ step,
688
+ isDisabled,
689
+ fractions: values.map(v => toFraction(v, {
690
+ min,
691
+ max,
692
+ step
693
+ })),
694
+ trackLength,
695
+ setTrackLength,
696
+ // Read off the resolved style rather than recomputed: the knob's diameter is what
697
+ // the rail insets its travel by, and both have to be the same number or the knob
698
+ // overhangs the end.
699
+ thumbSize: typeof thumb.width === "number" ? thumb.width : 0,
700
+ slideTo,
701
+ thumbFor,
702
+ commit
703
+ };
704
+ }, [styles, tint, values, min, max, step, isDisabled, orientation, trackLength, slideTo, thumbFor, commit]);
705
+ return /* @__PURE__ */jsx5(SliderProvider, {
706
+ value: context,
707
+ children: /* @__PURE__ */jsx5(View2, {
708
+ ref,
709
+ ...rest,
710
+ style: [styles.root, styleProps, style],
711
+ children
712
+ })
713
+ });
714
+ });
715
+ SliderRoot.displayName = "XAUI.Slider.Root";
716
+
717
+ // src/components/slider/index.ts
718
+ var Slider2 = Object.assign(SliderRoot, {
719
+ Output: SliderOutput,
720
+ Track: SliderTrack,
721
+ Fill: SliderFill,
722
+ Thumb: SliderThumb
723
+ });
724
+ export { useSlider, SliderFill, SliderOutput, SliderThumb, SliderTrack, sliderRecipe, toFraction, fromFraction, snap, SliderRoot, Slider2 as Slider };