@xaui/native 0.9.1-alpha.91 → 0.9.1-alpha.93

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 (86) hide show
  1. package/dist/chunk-2SHWOFQV.js +495 -0
  2. package/dist/chunk-3A5RK2R7.js +40 -0
  3. package/dist/chunk-6JAGPPZU.cjs +788 -0
  4. package/dist/chunk-7NQL5DXY.js +302 -0
  5. package/dist/chunk-FTPPUTWL.cjs +40 -0
  6. package/dist/chunk-GGP2ERSV.js +487 -0
  7. package/dist/chunk-LKRQUQZQ.cjs +487 -0
  8. package/dist/chunk-OPLPLFGK.cjs +493 -0
  9. package/dist/{chunk-LIEXFWTN.js → chunk-P5M5URAB.js} +29 -126
  10. package/dist/chunk-XWIPLZTD.cjs +302 -0
  11. package/dist/components/carousel/index.cjs +3 -2
  12. package/dist/components/carousel/index.js +2 -1
  13. package/dist/components/index.d.cts +3 -0
  14. package/dist/components/index.d.ts +3 -0
  15. package/dist/components/number-pad/index.cjs +40 -0
  16. package/dist/components/number-pad/index.d.cts +60 -0
  17. package/dist/components/number-pad/index.d.ts +60 -0
  18. package/dist/components/number-pad/index.js +40 -0
  19. package/dist/components/number-pad/number-pad-action.d.cts +24 -0
  20. package/dist/components/number-pad/number-pad-action.d.ts +24 -0
  21. package/dist/components/number-pad/number-pad-backspace.d.cts +18 -0
  22. package/dist/components/number-pad/number-pad-backspace.d.ts +18 -0
  23. package/dist/components/number-pad/number-pad-cell.d.cts +7 -0
  24. package/dist/components/number-pad/number-pad-cell.d.ts +7 -0
  25. package/dist/components/number-pad/number-pad-icon.d.cts +13 -0
  26. package/dist/components/number-pad/number-pad-icon.d.ts +13 -0
  27. package/dist/components/number-pad/number-pad-key.d.cts +24 -0
  28. package/dist/components/number-pad/number-pad-key.d.ts +24 -0
  29. package/dist/components/number-pad/number-pad-label.d.cts +14 -0
  30. package/dist/components/number-pad/number-pad-label.d.ts +14 -0
  31. package/dist/components/number-pad/number-pad.context.d.cts +18 -0
  32. package/dist/components/number-pad/number-pad.context.d.ts +18 -0
  33. package/dist/components/number-pad/number-pad.d.cts +57 -0
  34. package/dist/components/number-pad/number-pad.d.ts +57 -0
  35. package/dist/components/number-pad/number-pad.recipe.d.cts +11 -0
  36. package/dist/components/number-pad/number-pad.recipe.d.ts +11 -0
  37. package/dist/components/number-pad/number-pad.style.d.cts +13 -0
  38. package/dist/components/number-pad/number-pad.style.d.ts +13 -0
  39. package/dist/components/number-pad/number-pad.type.d.cts +135 -0
  40. package/dist/components/number-pad/number-pad.type.d.ts +135 -0
  41. package/dist/components/number-pad/number-pad.utils.d.cts +34 -0
  42. package/dist/components/number-pad/number-pad.utils.d.ts +34 -0
  43. package/dist/components/pager/index.cjs +33 -0
  44. package/dist/components/pager/index.d.cts +60 -0
  45. package/dist/components/pager/index.d.ts +60 -0
  46. package/dist/components/pager/index.js +33 -0
  47. package/dist/components/pager/pager-content.d.cts +24 -0
  48. package/dist/components/pager/pager-content.d.ts +24 -0
  49. package/dist/components/pager/pager-indicator.d.cts +47 -0
  50. package/dist/components/pager/pager-indicator.d.ts +47 -0
  51. package/dist/components/pager/pager-page.d.cts +16 -0
  52. package/dist/components/pager/pager-page.d.ts +16 -0
  53. package/dist/components/pager/pager.context.d.cts +7 -0
  54. package/dist/components/pager/pager.context.d.ts +7 -0
  55. package/dist/components/pager/pager.d.cts +70 -0
  56. package/dist/components/pager/pager.d.ts +70 -0
  57. package/dist/components/pager/pager.recipe.d.cts +33 -0
  58. package/dist/components/pager/pager.recipe.d.ts +33 -0
  59. package/dist/components/pager/pager.type.d.cts +107 -0
  60. package/dist/components/pager/pager.type.d.ts +107 -0
  61. package/dist/components/rating/index.cjs +30 -0
  62. package/dist/components/rating/index.d.cts +41 -0
  63. package/dist/components/rating/index.d.ts +41 -0
  64. package/dist/components/rating/index.js +30 -0
  65. package/dist/components/rating/rating-icon.d.cts +16 -0
  66. package/dist/components/rating/rating-icon.d.ts +16 -0
  67. package/dist/components/rating/rating-item.d.cts +23 -0
  68. package/dist/components/rating/rating-item.d.ts +23 -0
  69. package/dist/components/rating/rating-star.d.cts +19 -0
  70. package/dist/components/rating/rating-star.d.ts +19 -0
  71. package/dist/components/rating/rating.context.d.cts +16 -0
  72. package/dist/components/rating/rating.context.d.ts +16 -0
  73. package/dist/components/rating/rating.d.cts +59 -0
  74. package/dist/components/rating/rating.d.ts +59 -0
  75. package/dist/components/rating/rating.recipe.d.cts +11 -0
  76. package/dist/components/rating/rating.recipe.d.ts +11 -0
  77. package/dist/components/rating/rating.style.d.cts +24 -0
  78. package/dist/components/rating/rating.style.d.ts +24 -0
  79. package/dist/components/rating/rating.type.d.cts +108 -0
  80. package/dist/components/rating/rating.type.d.ts +108 -0
  81. package/dist/components/rating/rating.utils.d.cts +28 -0
  82. package/dist/components/rating/rating.utils.d.ts +28 -0
  83. package/dist/index.cjs +91 -28
  84. package/dist/index.js +148 -85
  85. package/package.json +31 -1
  86. package/dist/chunk-K5UO3HBW.cjs +0 -1007
@@ -0,0 +1,495 @@
1
+ import { indexFromOffset, progressFromOffset } from "./chunk-3A5RK2R7.js";
2
+ import { useMergedRef } from "./chunk-NCTOTTVW.js";
3
+ import { useControllableState } from "./chunk-F6W3JQ7K.js";
4
+ import { createRecipe } from "./chunk-DKVXTMIJ.js";
5
+ import { createSlotContext } from "./chunk-TTZOIXKE.js";
6
+ import { useXAUITheme } from "./chunk-Z6JBWRPL.js";
7
+ import { useStyleProps } from "./chunk-M63GFNKV.js";
8
+
9
+ // src/components/pager/pager-content.tsx
10
+ import { Children, forwardRef, useEffect } from "react";
11
+ import Animated, { runOnJS, useAnimatedScrollHandler, useSharedValue } from "react-native-reanimated";
12
+
13
+ // src/components/pager/pager.context.ts
14
+ var [PagerProvider, usePager] = createSlotContext("Pager");
15
+
16
+ // src/components/pager/pager-content.tsx
17
+ import { jsx } from "react/jsx-runtime";
18
+ const _worklet_10605200666301_init_data = {
19
+ code: "function chunk2SHWOFQVJs1(event){const{isHorizontal,offset,indexFromOffset,step,count,settled,runOnJS,onSettle}=this.__closure;const travelled=isHorizontal?event.contentOffset.x:event.contentOffset.y;offset.set(travelled);const next=indexFromOffset(travelled,step,count);if(next!==settled.get()){settled.set(next);runOnJS(onSettle)(next);}}",
20
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-2SHWOFQV.js",
21
+ sourceMap: "{\"version\":3,\"names\":[\"chunk2SHWOFQVJs1\",\"event\",\"isHorizontal\",\"offset\",\"indexFromOffset\",\"step\",\"count\",\"settled\",\"runOnJS\",\"onSettle\",\"__closure\",\"travelled\",\"contentOffset\",\"x\",\"y\",\"set\",\"next\",\"get\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-2SHWOFQV.js\"],\"mappings\":\"AAiE6C,SAAAA,gBAAUA,CAAAC,KAAA,QAAAC,YAAA,CAAAC,MAAA,CAAAC,eAAA,CAAAC,IAAA,CAAAC,KAAA,CAAAC,OAAA,CAAAC,OAAA,CAAAC,QAAA,OAAAC,SAAA,CACjD,KAAM,CAAAC,SAAS,CAAGT,YAAY,CAAGD,KAAK,CAACW,aAAa,CAACC,CAAC,CAAGZ,KAAK,CAACW,aAAa,CAACE,CAAC,CAC9EX,MAAM,CAACY,GAAG,CAACJ,SAAS,CAAC,CACrB,KAAM,CAAAK,IAAI,CAAGZ,eAAe,CAACO,SAAS,CAAEN,IAAI,CAAEC,KAAK,CAAC,CACpD,GAAIU,IAAI,GAAKT,OAAO,CAACU,GAAG,CAAC,CAAC,CAAE,CAC1BV,OAAO,CAACQ,GAAG,CAACC,IAAI,CAAC,CACjBR,OAAO,CAACC,QAAQ,CAAC,CAACO,IAAI,CAAC,CACzB,CACF\",\"ignoreList\":[]}"
22
+ };
23
+ var PagerContent = forwardRef(function PagerContent2({
24
+ children,
25
+ style,
26
+ onLayout,
27
+ ...props
28
+ }, ref) {
29
+ const {
30
+ contentStyle,
31
+ orientation,
32
+ step,
33
+ track,
34
+ setTrack,
35
+ count,
36
+ setCount,
37
+ offset,
38
+ trackRef,
39
+ isDisabled,
40
+ onSettle
41
+ } = usePager();
42
+ const [styleProps, rest] = useStyleProps(props);
43
+ const scroller = useMergedRef(ref, trackRef);
44
+ const given = Children.count(children);
45
+ useEffect(() => {
46
+ if (given !== count) setCount(given);
47
+ }, [count, given, setCount]);
48
+ const handleLayout = event => {
49
+ onLayout?.(event);
50
+ const {
51
+ width,
52
+ height
53
+ } = event.nativeEvent.layout;
54
+ if (width !== track.width || height !== track.height) setTrack({
55
+ width,
56
+ height
57
+ });
58
+ };
59
+ const settled = useSharedValue(0);
60
+ const isHorizontal = orientation === "horizontal";
61
+ const scroll = useAnimatedScrollHandler(function chunk2SHWOFQVJs1Factory({
62
+ _worklet_10605200666301_init_data,
63
+ isHorizontal,
64
+ offset,
65
+ indexFromOffset,
66
+ step,
67
+ count,
68
+ settled,
69
+ runOnJS,
70
+ onSettle
71
+ }) {
72
+ const _e = [new global.Error(), -9, -27];
73
+ const chunk2SHWOFQVJs1 = function (event) {
74
+ const travelled = isHorizontal ? event.contentOffset.x : event.contentOffset.y;
75
+ offset.set(travelled);
76
+ const next = indexFromOffset(travelled, step, count);
77
+ if (next !== settled.get()) {
78
+ settled.set(next);
79
+ runOnJS(onSettle)(next);
80
+ }
81
+ };
82
+ chunk2SHWOFQVJs1.__closure = {
83
+ isHorizontal,
84
+ offset,
85
+ indexFromOffset,
86
+ step,
87
+ count,
88
+ settled,
89
+ runOnJS,
90
+ onSettle
91
+ };
92
+ chunk2SHWOFQVJs1.__workletHash = 10605200666301;
93
+ chunk2SHWOFQVJs1.__pluginVersion = "0.7.4";
94
+ chunk2SHWOFQVJs1.__initData = _worklet_10605200666301_init_data;
95
+ chunk2SHWOFQVJs1.__stackDetails = _e;
96
+ return chunk2SHWOFQVJs1;
97
+ }({
98
+ _worklet_10605200666301_init_data,
99
+ isHorizontal,
100
+ offset,
101
+ indexFromOffset,
102
+ step,
103
+ count,
104
+ settled,
105
+ runOnJS,
106
+ onSettle
107
+ }));
108
+ return /* @__PURE__ */jsx(Animated.ScrollView, {
109
+ ref: scroller,
110
+ horizontal: isHorizontal,
111
+ pagingEnabled: true,
112
+ showsHorizontalScrollIndicator: false,
113
+ showsVerticalScrollIndicator: false,
114
+ scrollEnabled: !isDisabled,
115
+ decelerationRate: "fast",
116
+ scrollEventThrottle: 16,
117
+ ...rest,
118
+ style: [contentStyle, styleProps, style],
119
+ onLayout: handleLayout,
120
+ onScroll: scroll,
121
+ children: step > 0 ? children : null
122
+ });
123
+ });
124
+ PagerContent.displayName = "XAUI.Pager.Content";
125
+
126
+ // src/components/pager/pager-indicator.tsx
127
+ import { forwardRef as forwardRef2 } from "react";
128
+ import { Pressable, View } from "react-native";
129
+ import Animated2, { interpolate, useAnimatedStyle } from "react-native-reanimated";
130
+
131
+ // src/components/pager/pager.recipe.ts
132
+ var SLOTS = ["root", "content", "page", "indicator", "dot"];
133
+ var VARIANT_TOKENS = {
134
+ primary: {
135
+ bgSelected: "accent"
136
+ },
137
+ // The page's own ink, for an indicator that has to read as chrome rather than as accent.
138
+ secondary: {
139
+ bgSelected: "foreground"
140
+ },
141
+ // The raised ground — white on a light theme. A pager over a *photograph* wants
142
+ // `color="#ffffff"` instead: a photograph is a photograph in both colour modes, and this
143
+ // token flips with the theme.
144
+ tertiary: {
145
+ bgSelected: "surface"
146
+ }
147
+ };
148
+ var DOT_REST_OPACITY = 0.3;
149
+ var SIZES = {
150
+ xs: {
151
+ dot: 5,
152
+ gap: 1
153
+ },
154
+ sm: {
155
+ dot: 6,
156
+ gap: 1.5
157
+ },
158
+ md: {
159
+ dot: 7,
160
+ gap: 1.5
161
+ },
162
+ lg: {
163
+ dot: 8,
164
+ gap: 2
165
+ }
166
+ };
167
+ function sizeAxis(step) {
168
+ const {
169
+ dot,
170
+ gap
171
+ } = step;
172
+ return theme => ({
173
+ indicator: {
174
+ gap: theme.spacing(gap)
175
+ },
176
+ dot: {
177
+ width: dot,
178
+ height: dot,
179
+ borderRadius: dot / 2
180
+ }
181
+ });
182
+ }
183
+ function orientationAxis(direction) {
184
+ return () => ({
185
+ indicator: {
186
+ flexDirection: direction
187
+ }
188
+ });
189
+ }
190
+ var pagerRecipe = createRecipe({
191
+ slots: SLOTS,
192
+ base: () => ({
193
+ /**
194
+ * **The root has no size of its own**, and that is deliberate rather than missing.
195
+ *
196
+ * `flex: 1` here would have been the convenient default and it is a trap: React Native
197
+ * expands it to a zero flex-basis, which **overrides an explicit `height`** — so
198
+ * `<Pager height={240}>` would collapse to the height of its dots, and the prop the
199
+ * caller reached for would silently do nothing. It is the same reason there is no
200
+ * `fullWidth` on a `Button`: RN's own behaviour is the answer, and the caller says which
201
+ * of the two they want — `flex={1}` to fill a screen, `height={320}` inside a scroll
202
+ * view.
203
+ *
204
+ * The track keeps its `flex: 1`, so it takes whatever the root was given less the dots.
205
+ * Nothing sizes it from outside, which is why it is safe there and not here.
206
+ */
207
+ content: {
208
+ flex: 1
209
+ },
210
+ // A page is the size of the track on both axes, and that number is measured rather than
211
+ // named, so it arrives as an inline style instead of from here.
212
+ page: {
213
+ overflow: "hidden"
214
+ },
215
+ indicator: {
216
+ alignItems: "center",
217
+ justifyContent: "center"
218
+ }
219
+ }),
220
+ variantTokens: VARIANT_TOKENS,
221
+ /**
222
+ * Every dot takes the same colour. What separates the current one from the rest is its
223
+ * opacity, animated on the UI thread — so this is a plain style rather than a value the
224
+ * root has to flatten and hand to a worklet.
225
+ */
226
+ paint: (_theme, colors) => ({
227
+ dot: {
228
+ backgroundColor: colors.bgSelected
229
+ }
230
+ }),
231
+ variants: {
232
+ size: {
233
+ xs: sizeAxis(SIZES.xs),
234
+ sm: sizeAxis(SIZES.sm),
235
+ md: sizeAxis(SIZES.md),
236
+ lg: sizeAxis(SIZES.lg)
237
+ },
238
+ orientation: {
239
+ horizontal: orientationAxis("row"),
240
+ vertical: orientationAxis("column")
241
+ }
242
+ },
243
+ states: {
244
+ disabled: theme => ({
245
+ indicator: {
246
+ opacity: theme.opacity.disabled
247
+ }
248
+ })
249
+ },
250
+ defaultVariants: {
251
+ variant: "primary",
252
+ size: "md",
253
+ orientation: "horizontal"
254
+ }
255
+ });
256
+
257
+ // src/components/pager/pager-indicator.tsx
258
+ import { jsx as jsx2 } from "react/jsx-runtime";
259
+ var HIT_SLOP = 8;
260
+ var AnimatedPressable = Animated2.createAnimatedComponent(Pressable);
261
+ var PagerIndicator = forwardRef2(function PagerIndicator2({
262
+ children,
263
+ style,
264
+ ...props
265
+ }, ref) {
266
+ const {
267
+ indicatorStyle,
268
+ count
269
+ } = usePager();
270
+ const [styleProps, rest] = useStyleProps(props);
271
+ return /* @__PURE__ */jsx2(View, {
272
+ ref,
273
+ ...rest,
274
+ style: [indicatorStyle, styleProps, style],
275
+ children: children ?? Array.from({
276
+ length: count
277
+ }, (_, index) => /* @__PURE__ */jsx2(PagerDot, {
278
+ index
279
+ }, index))
280
+ });
281
+ });
282
+ PagerIndicator.displayName = "XAUI.Pager.Indicator";
283
+ const _worklet_15861153305546_init_data = {
284
+ code: "function chunk2SHWOFQVJs2(){const{progressFromOffset,offset,step,count,index,interpolate,DOT_REST_OPACITY}=this.__closure;const distance=Math.abs(progressFromOffset(offset.get(),step,count)-index);const nearness=Math.max(0,1-distance);return{opacity:interpolate(nearness,[0,1],[DOT_REST_OPACITY,1])};}",
285
+ location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-2SHWOFQV.js",
286
+ sourceMap: "{\"version\":3,\"names\":[\"chunk2SHWOFQVJs2\",\"progressFromOffset\",\"offset\",\"step\",\"count\",\"index\",\"interpolate\",\"DOT_REST_OPACITY\",\"__closure\",\"distance\",\"Math\",\"abs\",\"get\",\"nearness\",\"max\",\"opacity\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-2SHWOFQV.js\"],\"mappings\":\"AA4MkC,SAAAA,gBAAMA,CAAA,QAAAC,kBAAA,CAAAC,MAAA,CAAAC,IAAA,CAAAC,KAAA,CAAAC,KAAA,CAAAC,WAAA,CAAAC,gBAAA,OAAAC,SAAA,CAEpC,KAAM,CAAAC,QAAQ,CAAGC,IAAI,CAACC,GAAG,CAACV,kBAAkB,CAACC,MAAM,CAACU,GAAG,CAAC,CAAC,CAAET,IAAI,CAAEC,KAAK,CAAC,CAAGC,KAAK,CAAC,CAChF,KAAM,CAAAQ,QAAQ,CAAGH,IAAI,CAACI,GAAG,CAAC,CAAC,CAAE,CAAC,CAAGL,QAAQ,CAAC,CAC1C,MAAO,CAAEM,OAAO,CAAET,WAAW,CAACO,QAAQ,CAAE,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,CAACN,gBAAgB,CAAE,CAAC,CAAC,CAAE,CAAC,CAC1E\",\"ignoreList\":[]}"
287
+ };
288
+ var PagerDot = forwardRef2(function PagerDot2({
289
+ index,
290
+ children,
291
+ style,
292
+ ...props
293
+ }, ref) {
294
+ const {
295
+ dotStyle,
296
+ offset,
297
+ step,
298
+ count,
299
+ index: current,
300
+ isDisabled,
301
+ goTo
302
+ } = usePager();
303
+ const [styleProps, rest] = useStyleProps(props);
304
+ const travel = useAnimatedStyle(function chunk2SHWOFQVJs2Factory({
305
+ _worklet_15861153305546_init_data,
306
+ progressFromOffset,
307
+ offset,
308
+ step,
309
+ count,
310
+ index,
311
+ interpolate,
312
+ DOT_REST_OPACITY
313
+ }) {
314
+ const _e = [new global.Error(), -8, -27];
315
+ const chunk2SHWOFQVJs2 = function () {
316
+ const distance = Math.abs(progressFromOffset(offset.get(), step, count) - index);
317
+ const nearness = Math.max(0, 1 - distance);
318
+ return {
319
+ opacity: interpolate(nearness, [0, 1], [DOT_REST_OPACITY, 1])
320
+ };
321
+ };
322
+ chunk2SHWOFQVJs2.__closure = {
323
+ progressFromOffset,
324
+ offset,
325
+ step,
326
+ count,
327
+ index,
328
+ interpolate,
329
+ DOT_REST_OPACITY
330
+ };
331
+ chunk2SHWOFQVJs2.__workletHash = 15861153305546;
332
+ chunk2SHWOFQVJs2.__pluginVersion = "0.7.4";
333
+ chunk2SHWOFQVJs2.__initData = _worklet_15861153305546_init_data;
334
+ chunk2SHWOFQVJs2.__stackDetails = _e;
335
+ return chunk2SHWOFQVJs2;
336
+ }({
337
+ _worklet_15861153305546_init_data,
338
+ progressFromOffset,
339
+ offset,
340
+ step,
341
+ count,
342
+ index,
343
+ interpolate,
344
+ DOT_REST_OPACITY
345
+ }), [offset, step, count, index]);
346
+ return /* @__PURE__ */jsx2(AnimatedPressable, {
347
+ ref,
348
+ accessibilityRole: "button",
349
+ accessibilityState: {
350
+ selected: index === current,
351
+ disabled: isDisabled
352
+ },
353
+ accessibilityValue: {
354
+ now: index + 1,
355
+ min: 1,
356
+ max: count
357
+ },
358
+ disabled: isDisabled,
359
+ hitSlop: HIT_SLOP,
360
+ ...rest,
361
+ style: [dotStyle, travel, styleProps, style],
362
+ onPress: () => goTo(index),
363
+ children
364
+ });
365
+ });
366
+ PagerDot.displayName = "XAUI.Pager.Dot";
367
+
368
+ // src/components/pager/pager-page.tsx
369
+ import { forwardRef as forwardRef3 } from "react";
370
+ import { View as View2 } from "react-native";
371
+ import { jsx as jsx3 } from "react/jsx-runtime";
372
+ var PagerPage = forwardRef3(function PagerPage2({
373
+ children,
374
+ style,
375
+ ...props
376
+ }, ref) {
377
+ const {
378
+ pageStyle,
379
+ track
380
+ } = usePager();
381
+ const [styleProps, rest] = useStyleProps(props);
382
+ return /* @__PURE__ */jsx3(View2, {
383
+ ref,
384
+ ...rest,
385
+ style: [pageStyle, {
386
+ width: track.width,
387
+ height: track.height
388
+ }, styleProps, style],
389
+ children
390
+ });
391
+ });
392
+ PagerPage.displayName = "XAUI.Pager.Page";
393
+
394
+ // src/components/pager/pager.tsx
395
+ import { forwardRef as forwardRef4, useCallback, useMemo, useState } from "react";
396
+ import { View as View3 } from "react-native";
397
+ import { useAnimatedRef, useSharedValue as useSharedValue2 } from "react-native-reanimated";
398
+ import { jsx as jsx4 } from "react/jsx-runtime";
399
+ var PagerRoot = forwardRef4(function Pager({
400
+ children,
401
+ variant,
402
+ size,
403
+ color,
404
+ orientation = "horizontal",
405
+ index: indexProp,
406
+ defaultIndex = 0,
407
+ onIndexChange,
408
+ isDisabled = false,
409
+ style,
410
+ ...props
411
+ }, ref) {
412
+ const theme = useXAUITheme();
413
+ const [styleProps, rest] = useStyleProps(props);
414
+ const [index, setIndex] = useControllableState({
415
+ value: indexProp,
416
+ defaultValue: defaultIndex,
417
+ onChange: onIndexChange
418
+ });
419
+ const [track, setTrack] = useState({
420
+ width: 0,
421
+ height: 0
422
+ });
423
+ const [count, setCount] = useState(0);
424
+ const trackRef = useAnimatedRef();
425
+ const offset = useSharedValue2(0);
426
+ const selection = {
427
+ variant,
428
+ size,
429
+ orientation
430
+ };
431
+ const states = {
432
+ disabled: isDisabled
433
+ };
434
+ const styles = pagerRecipe.resolve({
435
+ theme,
436
+ selection,
437
+ states
438
+ });
439
+ const tint = color ? pagerRecipe.tint({
440
+ theme,
441
+ color,
442
+ selection,
443
+ states
444
+ }) : void 0;
445
+ const step = orientation === "horizontal" ? track.width : track.height;
446
+ const goTo = useCallback(next => {
447
+ const distance = next * step;
448
+ trackRef.current?.scrollTo({
449
+ x: orientation === "horizontal" ? distance : 0,
450
+ y: orientation === "horizontal" ? 0 : distance,
451
+ animated: true
452
+ });
453
+ setIndex(next);
454
+ }, [orientation, setIndex, step, trackRef]);
455
+ const context = useMemo(() => ({
456
+ contentStyle: styles.content,
457
+ pageStyle: styles.page,
458
+ indicatorStyle: styles.indicator,
459
+ // One colour for every dot; the current one is told apart by its opacity, which the dot
460
+ // animates itself. Nothing here has to be flattened into a value for a worklet.
461
+ dotStyle: tint ? [styles.dot, tint.dot] : styles.dot,
462
+ orientation,
463
+ index,
464
+ count,
465
+ setCount,
466
+ track,
467
+ setTrack,
468
+ step,
469
+ offset,
470
+ goTo,
471
+ onSettle: setIndex,
472
+ trackRef,
473
+ isDisabled
474
+ }), [styles, tint, orientation, index, count, track, setTrack, step, offset, goTo, setIndex, trackRef, isDisabled]);
475
+ const rootStyle = [styles.root, tint?.root, styleProps, style];
476
+ return /* @__PURE__ */jsx4(PagerProvider, {
477
+ value: context,
478
+ children: /* @__PURE__ */jsx4(View3, {
479
+ ref,
480
+ ...rest,
481
+ style: rootStyle,
482
+ children
483
+ })
484
+ });
485
+ });
486
+ PagerRoot.displayName = "XAUI.Pager.Root";
487
+
488
+ // src/components/pager/index.ts
489
+ var Pager2 = Object.assign(PagerRoot, {
490
+ Content: PagerContent,
491
+ Page: PagerPage,
492
+ Indicator: PagerIndicator,
493
+ Dot: PagerDot
494
+ });
495
+ export { usePager, PagerContent, DOT_REST_OPACITY, pagerRecipe, PagerIndicator, PagerDot, PagerPage, PagerRoot, Pager2 as Pager };
@@ -0,0 +1,40 @@
1
+ // src/utils/carousel.ts
2
+ function clamp(value, low, high) {
3
+ "worklet";
4
+ return Math.min(Math.max(value, low), high);
5
+ }
6
+ function carouselMetrics({
7
+ width,
8
+ itemsPerView,
9
+ gap,
10
+ peek
11
+ }) {
12
+ const perView = Math.max(1, Math.floor(itemsPerView));
13
+ const inset = peek > 0 ? peek + gap : 0;
14
+ const between = gap * (perView - 1);
15
+ const itemWidth = Math.max(0, (width - 2 * inset - between) / perView);
16
+ return { itemWidth, step: itemWidth + gap, gap, inset };
17
+ }
18
+ function indexFromOffset(offset, step, count) {
19
+ "worklet";
20
+ if (step <= 0 || count <= 0) return 0;
21
+ return clamp(Math.round(offset / step), 0, count - 1);
22
+ }
23
+ function progressFromOffset(offset, step, count) {
24
+ "worklet";
25
+ if (step <= 0 || count <= 0) return 0;
26
+ return clamp(offset / step, 0, count - 1);
27
+ }
28
+ function stepIndex(index, delta, count, hasLoop) {
29
+ if (count <= 0) return 0;
30
+ const next = index + delta;
31
+ if (hasLoop) return (next % count + count) % count;
32
+ return clamp(next, 0, count - 1);
33
+ }
34
+
35
+ export {
36
+ carouselMetrics,
37
+ indexFromOffset,
38
+ progressFromOffset,
39
+ stepIndex
40
+ };