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

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-3A5RK2R7.js +40 -0
  2. package/dist/chunk-6JAGPPZU.cjs +788 -0
  3. package/dist/chunk-7NQL5DXY.js +302 -0
  4. package/dist/chunk-FTPPUTWL.cjs +40 -0
  5. package/dist/chunk-GGP2ERSV.js +487 -0
  6. package/dist/chunk-KPKEZWZM.js +517 -0
  7. package/dist/chunk-LKRQUQZQ.cjs +487 -0
  8. package/dist/{chunk-LIEXFWTN.js → chunk-P5M5URAB.js} +29 -126
  9. package/dist/chunk-UR37LVPU.cjs +382 -0
  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 +31 -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 +31 -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 +71 -0
  56. package/dist/components/pager/pager.d.ts +71 -0
  57. package/dist/components/pager/pager.recipe.d.cts +15 -0
  58. package/dist/components/pager/pager.recipe.d.ts +15 -0
  59. package/dist/components/pager/pager.type.d.cts +108 -0
  60. package/dist/components/pager/pager.type.d.ts +108 -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 +90 -29
  84. package/dist/index.js +146 -85
  85. package/package.json +31 -1
  86. package/dist/chunk-K5UO3HBW.cjs +0 -1007
@@ -0,0 +1,788 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+ var _chunkFTPPUTWLcjs = require('./chunk-FTPPUTWL.cjs');
7
+
8
+
9
+ var _chunkWFEMJCXOcjs = require('./chunk-WFEMJCXO.cjs');
10
+
11
+
12
+ var _chunk7EIHHOHPcjs = require('./chunk-7EIHHOHP.cjs');
13
+
14
+
15
+ var _chunkOW4N2C3Mcjs = require('./chunk-OW4N2C3M.cjs');
16
+
17
+
18
+ var _chunk7DPL3ZDScjs = require('./chunk-7DPL3ZDS.cjs');
19
+
20
+
21
+
22
+ var _chunkSL3V7R2Ycjs = require('./chunk-SL3V7R2Y.cjs');
23
+
24
+
25
+
26
+ var _chunkCDRGTUYFcjs = require('./chunk-CDRGTUYF.cjs');
27
+
28
+
29
+ var _chunkEJQCQPETcjs = require('./chunk-EJQCQPET.cjs');
30
+
31
+
32
+ var _chunkIIAQISBGcjs = require('./chunk-IIAQISBG.cjs');
33
+
34
+
35
+ var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
36
+
37
+ // src/components/carousel/carousel-content.tsx
38
+ var _react = require('react');
39
+
40
+
41
+
42
+
43
+ var _reactnativereanimated = require('react-native-reanimated'); var _reactnativereanimated2 = _interopRequireDefault(_reactnativereanimated);
44
+
45
+ // src/components/carousel/carousel.context.ts
46
+ var [CarouselProvider, useCarousel] = _chunkCDRGTUYFcjs.createSlotContext.call(void 0, "Carousel");
47
+
48
+ // src/components/carousel/carousel-content.tsx
49
+ var _jsxruntime = require('react/jsx-runtime');
50
+ var CarouselContent = _react.forwardRef.call(void 0,
51
+ function CarouselContent2({ children, style, onLayout, ...props }, ref) {
52
+ const {
53
+ contentStyle,
54
+ metrics,
55
+ width,
56
+ count,
57
+ setCount,
58
+ offset,
59
+ trackRef,
60
+ isDisabled,
61
+ onInteract,
62
+ onSettle,
63
+ setTrackHeight
64
+ } = useCarousel();
65
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
66
+ const track = _chunkWFEMJCXOcjs.useMergedRef.call(void 0, ref, trackRef);
67
+ const given = _react.Children.count(children);
68
+ _react.useEffect.call(void 0, () => {
69
+ if (given !== count) setCount(given);
70
+ }, [count, given, setCount]);
71
+ const handleLayout = (event) => {
72
+ _optionalChain([onLayout, 'optionalCall', _2 => _2(event)]);
73
+ setTrackHeight(event.nativeEvent.layout.height);
74
+ };
75
+ const settled = _reactnativereanimated.useSharedValue.call(void 0, 0);
76
+ const { step } = metrics;
77
+ const scroll = _reactnativereanimated.useAnimatedScrollHandler.call(void 0, (event) => {
78
+ offset.set(event.contentOffset.x);
79
+ const next = _chunkFTPPUTWLcjs.indexFromOffset.call(void 0, event.contentOffset.x, step, count);
80
+ if (next !== settled.get()) {
81
+ settled.set(next);
82
+ _reactnativereanimated.runOnJS.call(void 0, onSettle)(next);
83
+ }
84
+ });
85
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
86
+ _reactnativereanimated2.default.ScrollView,
87
+ {
88
+ ref: track,
89
+ horizontal: true,
90
+ showsHorizontalScrollIndicator: false,
91
+ scrollEnabled: !isDisabled,
92
+ snapToInterval: metrics.step,
93
+ decelerationRate: "fast",
94
+ disableIntervalMomentum: true,
95
+ scrollEventThrottle: 16,
96
+ ...rest,
97
+ contentContainerStyle: [
98
+ { gap: metrics.gap },
99
+ // R13 — the inset is the same at both ends, so one key rather than two, and no
100
+ // side to get the wrong way round in a right-to-left layout.
101
+ { paddingHorizontal: metrics.inset }
102
+ ],
103
+ style: [contentStyle, styleProps, style],
104
+ onLayout: handleLayout,
105
+ onScroll: scroll,
106
+ onScrollBeginDrag: onInteract,
107
+ children: width > 0 ? children : null
108
+ }
109
+ );
110
+ }
111
+ );
112
+ CarouselContent.displayName = "XAUI.Carousel.Content";
113
+
114
+ // src/components/carousel/carousel-counter.tsx
115
+
116
+ var _reactnative = require('react-native');
117
+
118
+ var CarouselCounter = _react.forwardRef.call(void 0,
119
+ function CarouselCounter2({ children, style, ...props }, ref) {
120
+ const { counterStyle, index, count } = useCarousel();
121
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
122
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.Text, { ref, ...rest, style: [counterStyle, styleProps, style], children: _nullishCoalesce(children, () => ( `${count === 0 ? 0 : index + 1} / ${count}`)) });
123
+ }
124
+ );
125
+ CarouselCounter.displayName = "XAUI.Carousel.Counter";
126
+
127
+ // src/components/carousel/carousel-indicator.tsx
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+ var HIT_SLOP = 8;
136
+ var AnimatedPressable = _reactnativereanimated2.default.createAnimatedComponent(_reactnative.Pressable);
137
+ var CarouselIndicator = _react.forwardRef.call(void 0,
138
+ function CarouselIndicator2({ children, style, ...props }, ref) {
139
+ const { indicatorStyle, count } = useCarousel();
140
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
141
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { ref, ...rest, style: [indicatorStyle, styleProps, style], children: _nullishCoalesce(children, () => ( Array.from({ length: count }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CarouselDot, { index }, index)))) });
142
+ }
143
+ );
144
+ CarouselIndicator.displayName = "XAUI.Carousel.Indicator";
145
+ var CarouselDot = _react.forwardRef.call(void 0, function CarouselDot2({ index, children, style, ...props }, ref) {
146
+ const {
147
+ dotStyle,
148
+ dotInk,
149
+ offset,
150
+ metrics,
151
+ count,
152
+ index: current,
153
+ isDisabled,
154
+ goTo,
155
+ onInteract
156
+ } = useCarousel();
157
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
158
+ const { step } = metrics;
159
+ const { rest: restColor, active, width, pill } = dotInk;
160
+ const grow = _reactnativereanimated.useAnimatedStyle.call(void 0, () => {
161
+ const distance = Math.abs(_chunkFTPPUTWLcjs.progressFromOffset.call(void 0, offset.get(), step, count) - index);
162
+ const nearness = Math.max(0, 1 - distance);
163
+ return {
164
+ width: width + (pill - width) * nearness,
165
+ backgroundColor: _reactnativereanimated.interpolateColor.call(void 0, nearness, [0, 1], [restColor, active])
166
+ };
167
+ });
168
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
169
+ AnimatedPressable,
170
+ {
171
+ ref,
172
+ accessibilityRole: "button",
173
+ accessibilityState: { selected: index === current, disabled: isDisabled },
174
+ accessibilityValue: { now: index + 1, min: 1, max: count },
175
+ disabled: isDisabled,
176
+ hitSlop: HIT_SLOP,
177
+ ...rest,
178
+ style: [dotStyle, grow, styleProps, style],
179
+ onPress: () => {
180
+ onInteract();
181
+ goTo(index);
182
+ },
183
+ children
184
+ }
185
+ );
186
+ });
187
+ CarouselDot.displayName = "XAUI.Carousel.Dot";
188
+
189
+ // src/components/carousel/carousel-item.tsx
190
+
191
+
192
+
193
+ var CarouselItem = _react.forwardRef.call(void 0,
194
+ function CarouselItem2({ children, style, ...props }, ref) {
195
+ const { itemStyle, metrics } = useCarousel();
196
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
197
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
198
+ _reactnative.View,
199
+ {
200
+ ref,
201
+ ...rest,
202
+ style: [itemStyle, { width: metrics.itemWidth }, styleProps, style],
203
+ children
204
+ }
205
+ );
206
+ }
207
+ );
208
+ CarouselItem.displayName = "XAUI.Carousel.Item";
209
+
210
+ // src/components/carousel/carousel-control.tsx
211
+
212
+
213
+
214
+ // src/components/carousel/carousel.style.ts
215
+
216
+ var QUARTER = _reactnative.I18nManager.isRTL ? "-45deg" : "45deg";
217
+ var carouselSheet = _reactnative.StyleSheet.create({
218
+ /** Towards the end of the series — pointing right in a left-to-right layout. */
219
+ chevronForward: {
220
+ borderStartWidth: 0,
221
+ borderBottomWidth: 0,
222
+ transform: [{ rotate: QUARTER }]
223
+ },
224
+ /** And back the other way. */
225
+ chevronBack: {
226
+ borderEndWidth: 0,
227
+ borderTopWidth: 0,
228
+ transform: [{ rotate: QUARTER }]
229
+ }
230
+ });
231
+
232
+ // src/components/carousel/carousel-control.tsx
233
+
234
+ function control({ delta, displayName, edge, turn }) {
235
+ const Component = _react.forwardRef.call(void 0, function CarouselControl({ children, asChild = false, style, onPressIn, onPressOut, ...props }, ref) {
236
+ const {
237
+ controlStyle,
238
+ controlInactiveStyle,
239
+ chevronStyle,
240
+ controlBox,
241
+ trackHeight,
242
+ index,
243
+ count,
244
+ hasLoop,
245
+ isDisabled,
246
+ moveBy,
247
+ onInteract
248
+ } = useCarousel();
249
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
250
+ const [isPressed, press] = _chunk7DPL3ZDScjs.usePressState.call(void 0, { onPressIn, onPressOut });
251
+ if (!asChild && !rest.accessibilityLabel && !rest["aria-label"]) {
252
+ _chunkEJQCQPETcjs.warnDev.call(void 0,
253
+ `${displayName}: a carousel arrow needs an \`accessibilityLabel\` \u2014 a chevron is not text, and there is nothing beside it that names the action.`
254
+ );
255
+ }
256
+ const atEnd = delta > 0 ? index >= count - 1 : index <= 0;
257
+ const isInactive = isDisabled || !hasLoop && atEnd;
258
+ const place = {
259
+ // Half a button above the track's middle. Zero until the track has been measured,
260
+ // which puts the arrow at the top for one frame and nowhere wrong after it.
261
+ top: Math.max(0, (trackHeight - controlBox.size) / 2),
262
+ [edge]: controlBox.inset
263
+ };
264
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
265
+ _chunkOW4N2C3Mcjs.PressableFeedback,
266
+ {
267
+ ref,
268
+ isPressed,
269
+ asChild,
270
+ accessibilityRole: "button",
271
+ accessibilityState: { disabled: isInactive },
272
+ isDisabled: isInactive,
273
+ ...rest,
274
+ style: [
275
+ controlStyle,
276
+ isInactive ? controlInactiveStyle : null,
277
+ place,
278
+ styleProps,
279
+ typeof style === "function" ? style({ pressed: isPressed }) : style
280
+ ],
281
+ onPress: () => {
282
+ onInteract();
283
+ moveBy(delta);
284
+ },
285
+ onPressIn: press.onPressIn,
286
+ onPressOut: press.onPressOut,
287
+ children: _nullishCoalesce(children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { style: [chevronStyle, carouselSheet[turn]] })))
288
+ }
289
+ );
290
+ });
291
+ Component.displayName = displayName;
292
+ return Component;
293
+ }
294
+ var CarouselPrevious = control({
295
+ delta: -1,
296
+ displayName: "XAUI.Carousel.Previous",
297
+ edge: "start",
298
+ turn: "chevronBack"
299
+ });
300
+ var CarouselNext = control({
301
+ delta: 1,
302
+ displayName: "XAUI.Carousel.Next",
303
+ edge: "end",
304
+ turn: "chevronForward"
305
+ });
306
+
307
+ // src/components/carousel/carousel.tsx
308
+
309
+
310
+
311
+
312
+ // src/components/carousel/carousel.recipe.ts
313
+ var SLOTS = [
314
+ "root",
315
+ "content",
316
+ "item",
317
+ "control",
318
+ "controlInactive",
319
+ "chevron",
320
+ "indicator",
321
+ "dot",
322
+ "dotActive",
323
+ "counter",
324
+ "thumbnails",
325
+ "thumbnail",
326
+ "thumbnailActive"
327
+ ];
328
+ var VARIANT_TOKENS = {
329
+ // The arrows sit **on** the slide, so their ground is the raised one rather than the
330
+ // page's: a control the same colour as the page vanishes over a pale photograph.
331
+ primary: {
332
+ bg: "surface",
333
+ fg: "foreground",
334
+ bgSelected: "accent",
335
+ fgSelected: "foreground"
336
+ },
337
+ secondary: {
338
+ bg: "default",
339
+ fg: "defaultForeground",
340
+ bgSelected: "defaultForeground",
341
+ fgSelected: "defaultForeground"
342
+ },
343
+ tertiary: {
344
+ bg: "surface",
345
+ fg: "foreground",
346
+ border: "border",
347
+ bgSelected: "foreground",
348
+ fgSelected: "foreground"
349
+ },
350
+ // No ground at all: the chevron is drawn straight on the slide, which is what a carousel
351
+ // over a dark photograph wants and what a carousel over a white one must not use.
352
+ ghost: { fg: "foreground", bgSelected: "accent", fgSelected: "foreground" }
353
+ };
354
+ var SIZES = {
355
+ xs: {
356
+ control: 24,
357
+ chevron: 6,
358
+ stroke: 1.5,
359
+ dot: 5,
360
+ pill: 14,
361
+ gap: 1.5,
362
+ thumbnail: 40,
363
+ counter: "xs"
364
+ },
365
+ sm: {
366
+ control: 30,
367
+ chevron: 7,
368
+ stroke: 1.5,
369
+ dot: 6,
370
+ pill: 18,
371
+ gap: 2,
372
+ thumbnail: 48,
373
+ counter: "xs"
374
+ },
375
+ md: {
376
+ control: 36,
377
+ chevron: 8,
378
+ stroke: 2,
379
+ dot: 7,
380
+ pill: 22,
381
+ gap: 2.5,
382
+ thumbnail: 60,
383
+ counter: "sm"
384
+ },
385
+ lg: {
386
+ control: 44,
387
+ chevron: 10,
388
+ stroke: 2,
389
+ dot: 8,
390
+ pill: 26,
391
+ gap: 3,
392
+ thumbnail: 72,
393
+ counter: "md"
394
+ }
395
+ };
396
+ function carouselGap(theme, size) {
397
+ return theme.spacing(SIZES[size].gap);
398
+ }
399
+ function carouselControlBox(theme, size) {
400
+ return { size: SIZES[size].control, inset: theme.spacing(2) };
401
+ }
402
+ function sizeAxis(step) {
403
+ const { control: control2, chevron, stroke, dot, pill, gap, thumbnail, counter } = step;
404
+ return (theme) => ({
405
+ control: { width: control2, height: control2, borderRadius: control2 / 2 },
406
+ chevron: { width: chevron, height: chevron, borderWidth: stroke },
407
+ indicator: { gap: theme.spacing(gap) * 0.5, height: dot },
408
+ dot: { width: dot, height: dot, borderRadius: dot / 2 },
409
+ /**
410
+ * The chosen dot, **read as values and never applied as a style**: the width and the
411
+ * colour are interpolated on the UI thread, and a worklet cannot read a `StyleSheet`
412
+ * id. The root flattens this slot into `dotInk`, so the recipe still owns both numbers.
413
+ *
414
+ * A pill, not a wider dot: the corner stays the dot's own, so the shape grows sideways
415
+ * out of the circle it was rather than turning into a different one.
416
+ */
417
+ dotActive: { width: pill, height: dot, borderRadius: dot / 2 },
418
+ thumbnails: { gap: theme.spacing(gap) * 0.75 },
419
+ thumbnail: { width: thumbnail, height: thumbnail },
420
+ thumbnailActive: { width: thumbnail, height: thumbnail },
421
+ counter: {
422
+ fontSize: theme.fontSizes[counter],
423
+ lineHeight: theme.lineHeights[counter]
424
+ }
425
+ });
426
+ }
427
+ var carouselRecipe = _chunkSL3V7R2Ycjs.createRecipe.call(void 0, {
428
+ slots: SLOTS,
429
+ base: (theme) => ({
430
+ root: { flexDirection: "column", gap: theme.spacing(2), position: "relative" },
431
+ content: { flexGrow: 0 },
432
+ item: {
433
+ borderCurve: "continuous",
434
+ overflow: "hidden",
435
+ // A slide is exactly as wide as `carouselMetrics` said and never less. In a row it
436
+ // is a flex item, and a flex item with a width still *shrinks* to fit its container
437
+ // — so five slides in a track one slide wide would each squeeze down to a fifth, the
438
+ // content would stop overflowing, and a carousel with nowhere to scroll to would sit
439
+ // there showing all five at once and ignoring its own arrows.
440
+ flexShrink: 0
441
+ },
442
+ /**
443
+ * An arrow at the end of a series that does not loop. It stays in place and stays
444
+ * legible — a control that disappears at the last slide takes its width with it and
445
+ * shifts everything beside it.
446
+ *
447
+ * A slot rather than a state, because the engine's states are a fixed set and this is
448
+ * not one of them: the carousel is not disabled, one of its two arrows is.
449
+ */
450
+ controlInactive: { opacity: theme.opacity.disabled },
451
+ control: {
452
+ // Over the slides rather than beside them: an arrow in the flow would move the track
453
+ // it belongs to, and the two would disagree about where the middle is.
454
+ position: "absolute",
455
+ alignItems: "center",
456
+ justifyContent: "center",
457
+ borderCurve: "continuous",
458
+ ...theme.shadows.surface
459
+ },
460
+ // The box and the stroke only. Which two of the four edges are actually drawn is
461
+ // `carousel.style.ts`'s — it is geometry, and it differs between the two arrows.
462
+ chevron: {},
463
+ indicator: {
464
+ flexDirection: "row",
465
+ alignItems: "center",
466
+ justifyContent: "center"
467
+ },
468
+ // A neutral fill rather than a faint version of the active one: the dots sit under
469
+ // the slides, on the page, and a pale tint of the accent there reads as a control that
470
+ // has half failed to load. `color` reaches the pill, which is the thing it should move.
471
+ dot: { backgroundColor: theme.colors.default },
472
+ counter: {
473
+ fontFamily: theme.fontFamilies.body,
474
+ color: theme.colors.muted
475
+ },
476
+ thumbnails: { flexGrow: 0, flexDirection: "row" },
477
+ thumbnail: {
478
+ borderCurve: "continuous",
479
+ overflow: "hidden",
480
+ // The strip is a row too, and the same squeeze applies to it.
481
+ flexShrink: 0,
482
+ // The ring is always there and only its colour moves, so choosing a thumbnail does
483
+ // not resize it — a border that appears on selection nudges every thumbnail after it.
484
+ borderWidth: theme.borderWidth.field,
485
+ borderColor: "transparent"
486
+ },
487
+ thumbnailActive: {
488
+ borderCurve: "continuous",
489
+ overflow: "hidden",
490
+ flexShrink: 0,
491
+ borderWidth: theme.borderWidth.field
492
+ }
493
+ }),
494
+ variantTokens: VARIANT_TOKENS,
495
+ paint: (theme, colors) => ({
496
+ control: {
497
+ backgroundColor: colors.bg,
498
+ borderColor: colors.border,
499
+ borderWidth: colors.border ? theme.borderWidth.default : 0
500
+ },
501
+ chevron: { borderColor: colors.fg },
502
+ dotActive: { backgroundColor: colors.bgSelected },
503
+ thumbnailActive: { borderColor: colors.bgSelected }
504
+ }),
505
+ variants: {
506
+ size: {
507
+ xs: sizeAxis(SIZES.xs),
508
+ sm: sizeAxis(SIZES.sm),
509
+ md: sizeAxis(SIZES.md),
510
+ lg: sizeAxis(SIZES.lg)
511
+ },
512
+ /** The slides' corner, and the thumbnails'. The arrows stay round. */
513
+ radius: _chunkSL3V7R2Ycjs.radiusAxis.call(void 0, "item", "thumbnail", "thumbnailActive")
514
+ },
515
+ states: {
516
+ disabled: (theme) => ({ root: { opacity: theme.opacity.disabled } })
517
+ },
518
+ defaultVariants: { variant: "primary", size: "md", radius: "2xl" }
519
+ });
520
+
521
+ // src/components/carousel/carousel.tsx
522
+
523
+ function setTrackOffset(track, x) {
524
+ _optionalChain([track, 'access', _3 => _3.current, 'optionalAccess', _4 => _4.scrollTo, 'call', _5 => _5({ x, y: 0, animated: false })]);
525
+ }
526
+ var GLIDE_MS = 420;
527
+ var GLIDE_FRAME_MS = 16;
528
+ function easeOutCubic(t) {
529
+ return 1 - (1 - t) ** 3;
530
+ }
531
+ var CarouselRoot = _react.forwardRef.call(void 0, function Carousel({
532
+ children,
533
+ variant,
534
+ size = "md",
535
+ color,
536
+ radius,
537
+ index: indexProp,
538
+ defaultIndex = 0,
539
+ onIndexChange,
540
+ itemsPerView = 1,
541
+ peek = 0,
542
+ gap,
543
+ hasLoop = false,
544
+ autoPlayInterval,
545
+ isDisabled = false,
546
+ asChild = false,
547
+ style,
548
+ onLayout,
549
+ ...props
550
+ }, ref) {
551
+ const theme = _chunkIIAQISBGcjs.useXAUITheme.call(void 0, );
552
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
553
+ const [index, setIndex] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
554
+ value: indexProp,
555
+ defaultValue: defaultIndex,
556
+ onChange: onIndexChange
557
+ });
558
+ const [width, setWidth] = _react.useState.call(void 0, 0);
559
+ const [trackHeight, setTrackHeight] = _react.useState.call(void 0, 0);
560
+ const [count, setCount] = _react.useState.call(void 0, 0);
561
+ const hasInteracted = _react.useRef.call(void 0, false);
562
+ const trackRef = _reactnativereanimated.useAnimatedRef.call(void 0, );
563
+ const offset = _reactnativereanimated.useSharedValue.call(void 0, 0);
564
+ const glideTimer = _react.useRef.call(void 0, null);
565
+ const selection = { variant, size, radius };
566
+ const styles = carouselRecipe.resolve({
567
+ theme,
568
+ selection,
569
+ states: { disabled: isDisabled }
570
+ });
571
+ const tint = color ? carouselRecipe.tint({ theme, color, selection }) : void 0;
572
+ const dotInk = _react.useMemo.call(void 0, () => {
573
+ const at = _reactnative.StyleSheet.flatten([styles.dot]);
574
+ const on = _reactnative.StyleSheet.flatten([styles.dotActive, _optionalChain([tint, 'optionalAccess', _6 => _6.dotActive])]);
575
+ return {
576
+ rest: typeof at.backgroundColor === "string" ? at.backgroundColor : theme.colors.default,
577
+ active: typeof on.backgroundColor === "string" ? on.backgroundColor : theme.colors.accent,
578
+ width: typeof at.width === "number" ? at.width : 0,
579
+ pill: typeof on.width === "number" ? on.width : 0
580
+ };
581
+ }, [styles, tint, theme]);
582
+ const resolvedGap = _nullishCoalesce(gap, () => ( carouselGap(theme, size)));
583
+ const controlBox = _react.useMemo.call(void 0, () => carouselControlBox(theme, size), [theme, size]);
584
+ const metrics = _react.useMemo.call(void 0,
585
+ () => _chunkFTPPUTWLcjs.carouselMetrics.call(void 0, { width, itemsPerView, gap: resolvedGap, peek }),
586
+ [width, itemsPerView, resolvedGap, peek]
587
+ );
588
+ const handleLayout = (event) => {
589
+ _optionalChain([onLayout, 'optionalCall', _7 => _7(event)]);
590
+ setWidth(event.nativeEvent.layout.width);
591
+ };
592
+ const stopGlide = _react.useCallback.call(void 0, () => {
593
+ if (glideTimer.current !== null) {
594
+ clearInterval(glideTimer.current);
595
+ glideTimer.current = null;
596
+ }
597
+ }, []);
598
+ const glideTo = _react.useCallback.call(void 0,
599
+ (x) => {
600
+ stopGlide();
601
+ const from = offset.get();
602
+ const distance = x - from;
603
+ if (Math.abs(distance) < 1) {
604
+ setTrackOffset(trackRef, x);
605
+ return;
606
+ }
607
+ const start = Date.now();
608
+ glideTimer.current = setInterval(() => {
609
+ const t = Math.min(1, (Date.now() - start) / GLIDE_MS);
610
+ setTrackOffset(trackRef, from + distance * easeOutCubic(t));
611
+ if (t >= 1) stopGlide();
612
+ }, GLIDE_FRAME_MS);
613
+ },
614
+ [offset, stopGlide, trackRef]
615
+ );
616
+ const goTo = _react.useCallback.call(void 0,
617
+ (next) => {
618
+ glideTo(next * metrics.step);
619
+ setIndex(next);
620
+ },
621
+ [glideTo, metrics.step, setIndex]
622
+ );
623
+ const moveBy = _react.useCallback.call(void 0,
624
+ (delta) => goTo(_chunkFTPPUTWLcjs.stepIndex.call(void 0, index, delta, count, hasLoop)),
625
+ [count, goTo, hasLoop, index]
626
+ );
627
+ const onInteract = _react.useCallback.call(void 0, () => {
628
+ hasInteracted.current = true;
629
+ stopGlide();
630
+ }, [stopGlide]);
631
+ _react.useEffect.call(void 0, () => stopGlide, [stopGlide]);
632
+ _react.useEffect.call(void 0, () => {
633
+ if (!autoPlayInterval || isDisabled || count < 2) return;
634
+ const timer = setInterval(() => {
635
+ if (hasInteracted.current) {
636
+ clearInterval(timer);
637
+ return;
638
+ }
639
+ setIndex((current) => {
640
+ const next = _chunkFTPPUTWLcjs.stepIndex.call(void 0, current, 1, count, true);
641
+ glideTo(next * metrics.step);
642
+ return next;
643
+ });
644
+ }, autoPlayInterval);
645
+ return () => clearInterval(timer);
646
+ }, [autoPlayInterval, count, isDisabled, glideTo, metrics.step, setIndex]);
647
+ const context = _react.useMemo.call(void 0,
648
+ () => ({
649
+ contentStyle: styles.content,
650
+ itemStyle: styles.item,
651
+ controlStyle: [styles.control, _optionalChain([tint, 'optionalAccess', _8 => _8.control])],
652
+ controlInactiveStyle: [styles.control, _optionalChain([tint, 'optionalAccess', _9 => _9.control]), styles.controlInactive],
653
+ chevronStyle: [styles.chevron, _optionalChain([tint, 'optionalAccess', _10 => _10.chevron])],
654
+ indicatorStyle: styles.indicator,
655
+ dotStyle: styles.dot,
656
+ dotInk,
657
+ counterStyle: styles.counter,
658
+ thumbnailsStyle: styles.thumbnails,
659
+ thumbnailStyle: styles.thumbnail,
660
+ thumbnailActiveStyle: [styles.thumbnailActive, _optionalChain([tint, 'optionalAccess', _11 => _11.thumbnailActive])],
661
+ index,
662
+ count,
663
+ setCount,
664
+ metrics,
665
+ width,
666
+ trackHeight,
667
+ setTrackHeight,
668
+ controlBox,
669
+ hasLoop,
670
+ isDisabled,
671
+ offset,
672
+ trackRef,
673
+ goTo,
674
+ moveBy,
675
+ onInteract,
676
+ onSettle: setIndex
677
+ }),
678
+ [
679
+ styles,
680
+ tint,
681
+ dotInk,
682
+ index,
683
+ count,
684
+ metrics,
685
+ width,
686
+ trackHeight,
687
+ setTrackHeight,
688
+ controlBox,
689
+ hasLoop,
690
+ isDisabled,
691
+ offset,
692
+ goTo,
693
+ moveBy,
694
+ onInteract,
695
+ setIndex
696
+ ]
697
+ );
698
+ const rootStyle = [styles.root, styleProps, style];
699
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CarouselProvider, { value: context, children: asChild ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCDRGTUYFcjs.Slot, { ref, ...rest, onLayout: handleLayout, style: rootStyle, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { ref, ...rest, onLayout: handleLayout, style: rootStyle, children }) });
700
+ });
701
+ CarouselRoot.displayName = "XAUI.Carousel.Root";
702
+
703
+ // src/components/carousel/carousel-thumbnails.tsx
704
+
705
+
706
+
707
+ var CarouselThumbnails = _react.forwardRef.call(void 0,
708
+ function CarouselThumbnails2({ children, style, ...props }, ref) {
709
+ const { thumbnailsStyle } = useCarousel();
710
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
711
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
712
+ _reactnative.ScrollView,
713
+ {
714
+ ref,
715
+ horizontal: true,
716
+ showsHorizontalScrollIndicator: false,
717
+ ...rest,
718
+ style: [thumbnailsStyle, styleProps, style],
719
+ contentContainerStyle: CONTENT,
720
+ children
721
+ }
722
+ );
723
+ }
724
+ );
725
+ CarouselThumbnails.displayName = "XAUI.Carousel.Thumbnails";
726
+ var CONTENT = { flexDirection: "row", gap: 8 };
727
+ var CarouselThumbnail = _react.forwardRef.call(void 0,
728
+ function CarouselThumbnail2({ index, children, style, ...props }, ref) {
729
+ const {
730
+ thumbnailStyle,
731
+ thumbnailActiveStyle,
732
+ index: current,
733
+ count,
734
+ isDisabled,
735
+ goTo,
736
+ onInteract
737
+ } = useCarousel();
738
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
739
+ const isActive = index === current;
740
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
741
+ _reactnative.Pressable,
742
+ {
743
+ ref,
744
+ accessibilityRole: "button",
745
+ accessibilityState: { selected: isActive, disabled: isDisabled },
746
+ accessibilityValue: { now: index + 1, min: 1, max: count },
747
+ disabled: isDisabled,
748
+ ...rest,
749
+ style: [isActive ? thumbnailActiveStyle : thumbnailStyle, styleProps, style],
750
+ onPress: () => {
751
+ onInteract();
752
+ goTo(index);
753
+ },
754
+ children
755
+ }
756
+ );
757
+ }
758
+ );
759
+ CarouselThumbnail.displayName = "XAUI.Carousel.Thumbnail";
760
+
761
+ // src/components/carousel/index.ts
762
+ var Carousel2 = Object.assign(CarouselRoot, {
763
+ Content: CarouselContent,
764
+ Item: CarouselItem,
765
+ Previous: CarouselPrevious,
766
+ Next: CarouselNext,
767
+ Indicator: CarouselIndicator,
768
+ Dot: CarouselDot,
769
+ Counter: CarouselCounter,
770
+ Thumbnails: CarouselThumbnails,
771
+ Thumbnail: CarouselThumbnail
772
+ });
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+
785
+
786
+
787
+
788
+ exports.useCarousel = useCarousel; exports.CarouselContent = CarouselContent; exports.CarouselCounter = CarouselCounter; exports.CarouselIndicator = CarouselIndicator; exports.CarouselDot = CarouselDot; exports.CarouselItem = CarouselItem; exports.CarouselPrevious = CarouselPrevious; exports.CarouselNext = CarouselNext; exports.carouselRecipe = carouselRecipe; exports.CarouselRoot = CarouselRoot; exports.CarouselThumbnails = CarouselThumbnails; exports.CarouselThumbnail = CarouselThumbnail; exports.Carousel = Carousel2;