@xaui/native 0.9.1-alpha.92 → 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.
- package/dist/{chunk-KPKEZWZM.js → chunk-2SHWOFQV.js} +188 -210
- package/dist/chunk-OPLPLFGK.cjs +493 -0
- package/dist/components/pager/index.cjs +4 -2
- package/dist/components/pager/index.d.cts +2 -2
- package/dist/components/pager/index.d.ts +2 -2
- package/dist/components/pager/index.js +3 -1
- package/dist/components/pager/pager.d.cts +3 -4
- package/dist/components/pager/pager.d.ts +3 -4
- package/dist/components/pager/pager.recipe.d.cts +19 -1
- package/dist/components/pager/pager.recipe.d.ts +19 -1
- package/dist/components/pager/pager.type.d.cts +5 -6
- package/dist/components/pager/pager.type.d.ts +5 -6
- package/dist/index.cjs +4 -2
- package/dist/index.js +3 -1
- package/package.json +1 -1
- package/dist/chunk-UR37LVPU.cjs +0 -382
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _interopRequireDefault(obj) {
|
|
7
|
+
return obj && obj.__esModule ? obj : {
|
|
8
|
+
default: obj
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function _nullishCoalesce(lhs, rhsFn) {
|
|
12
|
+
if (lhs != null) {
|
|
13
|
+
return lhs;
|
|
14
|
+
} else {
|
|
15
|
+
return rhsFn();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function _optionalChain(ops) {
|
|
19
|
+
let lastAccessLHS = undefined;
|
|
20
|
+
let value = ops[0];
|
|
21
|
+
let i = 1;
|
|
22
|
+
while (i < ops.length) {
|
|
23
|
+
const op = ops[i];
|
|
24
|
+
const fn = ops[i + 1];
|
|
25
|
+
i += 2;
|
|
26
|
+
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
if (op === 'access' || op === 'optionalAccess') {
|
|
30
|
+
lastAccessLHS = value;
|
|
31
|
+
value = fn(value);
|
|
32
|
+
} else if (op === 'call' || op === 'optionalCall') {
|
|
33
|
+
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
34
|
+
lastAccessLHS = undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
var _chunkFTPPUTWLcjs = require('./chunk-FTPPUTWL.cjs');
|
|
40
|
+
var _chunkWFEMJCXOcjs = require('./chunk-WFEMJCXO.cjs');
|
|
41
|
+
var _chunk7EIHHOHPcjs = require('./chunk-7EIHHOHP.cjs');
|
|
42
|
+
var _chunkSL3V7R2Ycjs = require('./chunk-SL3V7R2Y.cjs');
|
|
43
|
+
var _chunkCDRGTUYFcjs = require('./chunk-CDRGTUYF.cjs');
|
|
44
|
+
var _chunkIIAQISBGcjs = require('./chunk-IIAQISBG.cjs');
|
|
45
|
+
var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
|
|
46
|
+
|
|
47
|
+
// src/components/pager/pager-content.tsx
|
|
48
|
+
var _react = require('react');
|
|
49
|
+
var _reactnativereanimated = require('react-native-reanimated');
|
|
50
|
+
var _reactnativereanimated2 = _interopRequireDefault(_reactnativereanimated);
|
|
51
|
+
|
|
52
|
+
// src/components/pager/pager.context.ts
|
|
53
|
+
var [PagerProvider, usePager] = _chunkCDRGTUYFcjs.createSlotContext.call(void 0, "Pager");
|
|
54
|
+
|
|
55
|
+
// src/components/pager/pager-content.tsx
|
|
56
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
57
|
+
var PagerContent = _react.forwardRef.call(void 0, function PagerContent2({
|
|
58
|
+
children,
|
|
59
|
+
style,
|
|
60
|
+
onLayout,
|
|
61
|
+
...props
|
|
62
|
+
}, ref) {
|
|
63
|
+
const {
|
|
64
|
+
contentStyle,
|
|
65
|
+
orientation,
|
|
66
|
+
step,
|
|
67
|
+
track,
|
|
68
|
+
setTrack,
|
|
69
|
+
count,
|
|
70
|
+
setCount,
|
|
71
|
+
offset,
|
|
72
|
+
trackRef,
|
|
73
|
+
isDisabled,
|
|
74
|
+
onSettle
|
|
75
|
+
} = usePager();
|
|
76
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
77
|
+
const scroller = _chunkWFEMJCXOcjs.useMergedRef.call(void 0, ref, trackRef);
|
|
78
|
+
const given = _react.Children.count(children);
|
|
79
|
+
_react.useEffect.call(void 0, () => {
|
|
80
|
+
if (given !== count) setCount(given);
|
|
81
|
+
}, [count, given, setCount]);
|
|
82
|
+
const handleLayout = event => {
|
|
83
|
+
_optionalChain([onLayout, 'optionalCall', _2 => _2(event)]);
|
|
84
|
+
const {
|
|
85
|
+
width,
|
|
86
|
+
height
|
|
87
|
+
} = event.nativeEvent.layout;
|
|
88
|
+
if (width !== track.width || height !== track.height) setTrack({
|
|
89
|
+
width,
|
|
90
|
+
height
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const settled = _reactnativereanimated.useSharedValue.call(void 0, 0);
|
|
94
|
+
const isHorizontal = orientation === "horizontal";
|
|
95
|
+
const scroll = _reactnativereanimated.useAnimatedScrollHandler.call(void 0, event => {
|
|
96
|
+
const travelled = isHorizontal ? event.contentOffset.x : event.contentOffset.y;
|
|
97
|
+
offset.set(travelled);
|
|
98
|
+
const next = _chunkFTPPUTWLcjs.indexFromOffset.call(void 0, travelled, step, count);
|
|
99
|
+
if (next !== settled.get()) {
|
|
100
|
+
settled.set(next);
|
|
101
|
+
_reactnativereanimated.runOnJS.call(void 0, onSettle)(next);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnativereanimated2.default.ScrollView, {
|
|
105
|
+
ref: scroller,
|
|
106
|
+
horizontal: isHorizontal,
|
|
107
|
+
pagingEnabled: true,
|
|
108
|
+
showsHorizontalScrollIndicator: false,
|
|
109
|
+
showsVerticalScrollIndicator: false,
|
|
110
|
+
scrollEnabled: !isDisabled,
|
|
111
|
+
decelerationRate: "fast",
|
|
112
|
+
scrollEventThrottle: 16,
|
|
113
|
+
...rest,
|
|
114
|
+
style: [contentStyle, styleProps, style],
|
|
115
|
+
onLayout: handleLayout,
|
|
116
|
+
onScroll: scroll,
|
|
117
|
+
children: step > 0 ? children : null
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
PagerContent.displayName = "XAUI.Pager.Content";
|
|
121
|
+
|
|
122
|
+
// src/components/pager/pager-indicator.tsx
|
|
123
|
+
|
|
124
|
+
var _reactnative = require('react-native');
|
|
125
|
+
|
|
126
|
+
// src/components/pager/pager.recipe.ts
|
|
127
|
+
var SLOTS = ["root", "content", "page", "indicator", "dot"];
|
|
128
|
+
var VARIANT_TOKENS = {
|
|
129
|
+
primary: {
|
|
130
|
+
bgSelected: "accent"
|
|
131
|
+
},
|
|
132
|
+
// The page's own ink, for an indicator that has to read as chrome rather than as accent.
|
|
133
|
+
secondary: {
|
|
134
|
+
bgSelected: "foreground"
|
|
135
|
+
},
|
|
136
|
+
// The raised ground — white on a light theme. A pager over a *photograph* wants
|
|
137
|
+
// `color="#ffffff"` instead: a photograph is a photograph in both colour modes, and this
|
|
138
|
+
// token flips with the theme.
|
|
139
|
+
tertiary: {
|
|
140
|
+
bgSelected: "surface"
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
var DOT_REST_OPACITY = 0.3;
|
|
144
|
+
var SIZES = {
|
|
145
|
+
xs: {
|
|
146
|
+
dot: 5,
|
|
147
|
+
gap: 1
|
|
148
|
+
},
|
|
149
|
+
sm: {
|
|
150
|
+
dot: 6,
|
|
151
|
+
gap: 1.5
|
|
152
|
+
},
|
|
153
|
+
md: {
|
|
154
|
+
dot: 7,
|
|
155
|
+
gap: 1.5
|
|
156
|
+
},
|
|
157
|
+
lg: {
|
|
158
|
+
dot: 8,
|
|
159
|
+
gap: 2
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
function sizeAxis(step) {
|
|
163
|
+
const {
|
|
164
|
+
dot,
|
|
165
|
+
gap
|
|
166
|
+
} = step;
|
|
167
|
+
return theme => ({
|
|
168
|
+
indicator: {
|
|
169
|
+
gap: theme.spacing(gap)
|
|
170
|
+
},
|
|
171
|
+
dot: {
|
|
172
|
+
width: dot,
|
|
173
|
+
height: dot,
|
|
174
|
+
borderRadius: dot / 2
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function orientationAxis(direction) {
|
|
179
|
+
return () => ({
|
|
180
|
+
indicator: {
|
|
181
|
+
flexDirection: direction
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
var pagerRecipe = _chunkSL3V7R2Ycjs.createRecipe.call(void 0, {
|
|
186
|
+
slots: SLOTS,
|
|
187
|
+
base: () => ({
|
|
188
|
+
/**
|
|
189
|
+
* **The root has no size of its own**, and that is deliberate rather than missing.
|
|
190
|
+
*
|
|
191
|
+
* `flex: 1` here would have been the convenient default and it is a trap: React Native
|
|
192
|
+
* expands it to a zero flex-basis, which **overrides an explicit `height`** — so
|
|
193
|
+
* `<Pager height={240}>` would collapse to the height of its dots, and the prop the
|
|
194
|
+
* caller reached for would silently do nothing. It is the same reason there is no
|
|
195
|
+
* `fullWidth` on a `Button`: RN's own behaviour is the answer, and the caller says which
|
|
196
|
+
* of the two they want — `flex={1}` to fill a screen, `height={320}` inside a scroll
|
|
197
|
+
* view.
|
|
198
|
+
*
|
|
199
|
+
* The track keeps its `flex: 1`, so it takes whatever the root was given less the dots.
|
|
200
|
+
* Nothing sizes it from outside, which is why it is safe there and not here.
|
|
201
|
+
*/
|
|
202
|
+
content: {
|
|
203
|
+
flex: 1
|
|
204
|
+
},
|
|
205
|
+
// A page is the size of the track on both axes, and that number is measured rather than
|
|
206
|
+
// named, so it arrives as an inline style instead of from here.
|
|
207
|
+
page: {
|
|
208
|
+
overflow: "hidden"
|
|
209
|
+
},
|
|
210
|
+
indicator: {
|
|
211
|
+
alignItems: "center",
|
|
212
|
+
justifyContent: "center"
|
|
213
|
+
}
|
|
214
|
+
}),
|
|
215
|
+
variantTokens: VARIANT_TOKENS,
|
|
216
|
+
/**
|
|
217
|
+
* Every dot takes the same colour. What separates the current one from the rest is its
|
|
218
|
+
* opacity, animated on the UI thread — so this is a plain style rather than a value the
|
|
219
|
+
* root has to flatten and hand to a worklet.
|
|
220
|
+
*/
|
|
221
|
+
paint: (_theme, colors) => ({
|
|
222
|
+
dot: {
|
|
223
|
+
backgroundColor: colors.bgSelected
|
|
224
|
+
}
|
|
225
|
+
}),
|
|
226
|
+
variants: {
|
|
227
|
+
size: {
|
|
228
|
+
xs: sizeAxis(SIZES.xs),
|
|
229
|
+
sm: sizeAxis(SIZES.sm),
|
|
230
|
+
md: sizeAxis(SIZES.md),
|
|
231
|
+
lg: sizeAxis(SIZES.lg)
|
|
232
|
+
},
|
|
233
|
+
orientation: {
|
|
234
|
+
horizontal: orientationAxis("row"),
|
|
235
|
+
vertical: orientationAxis("column")
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
states: {
|
|
239
|
+
disabled: theme => ({
|
|
240
|
+
indicator: {
|
|
241
|
+
opacity: theme.opacity.disabled
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
},
|
|
245
|
+
defaultVariants: {
|
|
246
|
+
variant: "primary",
|
|
247
|
+
size: "md",
|
|
248
|
+
orientation: "horizontal"
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// src/components/pager/pager-indicator.tsx
|
|
253
|
+
|
|
254
|
+
var HIT_SLOP = 8;
|
|
255
|
+
var AnimatedPressable = _reactnativereanimated2.default.createAnimatedComponent(_reactnative.Pressable);
|
|
256
|
+
var PagerIndicator = _react.forwardRef.call(void 0, function PagerIndicator2({
|
|
257
|
+
children,
|
|
258
|
+
style,
|
|
259
|
+
...props
|
|
260
|
+
}, ref) {
|
|
261
|
+
const {
|
|
262
|
+
indicatorStyle,
|
|
263
|
+
count
|
|
264
|
+
} = usePager();
|
|
265
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
266
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnative.View, {
|
|
267
|
+
ref,
|
|
268
|
+
...rest,
|
|
269
|
+
style: [indicatorStyle, styleProps, style],
|
|
270
|
+
children: _nullishCoalesce(children, () => Array.from({
|
|
271
|
+
length: count
|
|
272
|
+
}, (_, index) => /* @__PURE__ */_jsxruntime.jsx.call(void 0, PagerDot, {
|
|
273
|
+
index
|
|
274
|
+
}, index)))
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
PagerIndicator.displayName = "XAUI.Pager.Indicator";
|
|
278
|
+
const _worklet_9864592886974_init_data = {
|
|
279
|
+
code: "function chunkOPLPLFGKCjs1(){const{_chunkFTPPUTWLcjs,offset,step,count,index,_reactnativereanimated,DOT_REST_OPACITY}=this.__closure;const distance=Math.abs(_chunkFTPPUTWLcjs.progressFromOffset.call(void 0,offset.get(),step,count)-index);const nearness=Math.max(0,1-distance);return{opacity:_reactnativereanimated.interpolate.call(void 0,nearness,[0,1],[DOT_REST_OPACITY,1])};}",
|
|
280
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-OPLPLFGK.cjs",
|
|
281
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkOPLPLFGKCjs1\",\"_chunkFTPPUTWLcjs\",\"offset\",\"step\",\"count\",\"index\",\"_reactnativereanimated\",\"DOT_REST_OPACITY\",\"__closure\",\"distance\",\"Math\",\"abs\",\"progressFromOffset\",\"call\",\"get\",\"nearness\",\"max\",\"opacity\",\"interpolate\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-OPLPLFGK.cjs\"],\"mappings\":\"AA4MsE,SAAAA,iBAAMA,CAAA,QAAAC,iBAAA,CAAAC,MAAA,CAAAC,IAAA,CAAAC,KAAA,CAAAC,KAAA,CAAAC,sBAAA,CAAAC,gBAAA,OAAAC,SAAA,CAExE,KAAM,CAAAC,QAAQ,CAAGC,IAAI,CAACC,GAAG,CAACV,iBAAiB,CAACW,kBAAkB,CAACC,IAAI,CAAC,IAAK,EAAC,CAAEX,MAAM,CAACY,GAAG,CAAC,CAAC,CAAEX,IAAI,CAAEC,KAAK,CAAC,CAAGC,KAAK,CAAC,CAC/G,KAAM,CAAAU,QAAQ,CAAGL,IAAI,CAACM,GAAG,CAAC,CAAC,CAAE,CAAC,CAAGP,QAAQ,CAAC,CAC1C,MAAO,CAAEQ,OAAO,CAAEX,sBAAsB,CAACY,WAAW,CAACL,IAAI,CAAC,IAAK,EAAC,CAAEE,QAAQ,CAAE,CAAC,CAAC,CAAE,CAAC,CAAC,CAAE,CAACR,gBAAgB,CAAE,CAAC,CAAC,CAAE,CAAC,CAC9G\",\"ignoreList\":[]}"
|
|
282
|
+
};
|
|
283
|
+
var PagerDot = _react.forwardRef.call(void 0, function PagerDot2({
|
|
284
|
+
index,
|
|
285
|
+
children,
|
|
286
|
+
style,
|
|
287
|
+
...props
|
|
288
|
+
}, ref) {
|
|
289
|
+
const {
|
|
290
|
+
dotStyle,
|
|
291
|
+
offset,
|
|
292
|
+
step,
|
|
293
|
+
count,
|
|
294
|
+
index: current,
|
|
295
|
+
isDisabled,
|
|
296
|
+
goTo
|
|
297
|
+
} = usePager();
|
|
298
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
299
|
+
const travel = _reactnativereanimated.useAnimatedStyle.call(void 0, function chunkOPLPLFGKCjs1Factory({
|
|
300
|
+
_worklet_9864592886974_init_data,
|
|
301
|
+
_chunkFTPPUTWLcjs,
|
|
302
|
+
offset,
|
|
303
|
+
step,
|
|
304
|
+
count,
|
|
305
|
+
index,
|
|
306
|
+
_reactnativereanimated,
|
|
307
|
+
DOT_REST_OPACITY
|
|
308
|
+
}) {
|
|
309
|
+
const _e = [new global.Error(), -8, -27];
|
|
310
|
+
const chunkOPLPLFGKCjs1 = function () {
|
|
311
|
+
const distance = Math.abs(_chunkFTPPUTWLcjs.progressFromOffset.call(void 0, offset.get(), step, count) - index);
|
|
312
|
+
const nearness = Math.max(0, 1 - distance);
|
|
313
|
+
return {
|
|
314
|
+
opacity: _reactnativereanimated.interpolate.call(void 0, nearness, [0, 1], [DOT_REST_OPACITY, 1])
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
chunkOPLPLFGKCjs1.__closure = {
|
|
318
|
+
_chunkFTPPUTWLcjs,
|
|
319
|
+
offset,
|
|
320
|
+
step,
|
|
321
|
+
count,
|
|
322
|
+
index,
|
|
323
|
+
_reactnativereanimated,
|
|
324
|
+
DOT_REST_OPACITY
|
|
325
|
+
};
|
|
326
|
+
chunkOPLPLFGKCjs1.__workletHash = 9864592886974;
|
|
327
|
+
chunkOPLPLFGKCjs1.__pluginVersion = "0.7.4";
|
|
328
|
+
chunkOPLPLFGKCjs1.__initData = _worklet_9864592886974_init_data;
|
|
329
|
+
chunkOPLPLFGKCjs1.__stackDetails = _e;
|
|
330
|
+
return chunkOPLPLFGKCjs1;
|
|
331
|
+
}({
|
|
332
|
+
_worklet_9864592886974_init_data,
|
|
333
|
+
_chunkFTPPUTWLcjs,
|
|
334
|
+
offset,
|
|
335
|
+
step,
|
|
336
|
+
count,
|
|
337
|
+
index,
|
|
338
|
+
_reactnativereanimated,
|
|
339
|
+
DOT_REST_OPACITY
|
|
340
|
+
}), [offset, step, count, index]);
|
|
341
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, AnimatedPressable, {
|
|
342
|
+
ref,
|
|
343
|
+
accessibilityRole: "button",
|
|
344
|
+
accessibilityState: {
|
|
345
|
+
selected: index === current,
|
|
346
|
+
disabled: isDisabled
|
|
347
|
+
},
|
|
348
|
+
accessibilityValue: {
|
|
349
|
+
now: index + 1,
|
|
350
|
+
min: 1,
|
|
351
|
+
max: count
|
|
352
|
+
},
|
|
353
|
+
disabled: isDisabled,
|
|
354
|
+
hitSlop: HIT_SLOP,
|
|
355
|
+
...rest,
|
|
356
|
+
style: [dotStyle, travel, styleProps, style],
|
|
357
|
+
onPress: () => goTo(index),
|
|
358
|
+
children
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
PagerDot.displayName = "XAUI.Pager.Dot";
|
|
362
|
+
|
|
363
|
+
// src/components/pager/pager-page.tsx
|
|
364
|
+
|
|
365
|
+
var PagerPage = _react.forwardRef.call(void 0, function PagerPage2({
|
|
366
|
+
children,
|
|
367
|
+
style,
|
|
368
|
+
...props
|
|
369
|
+
}, ref) {
|
|
370
|
+
const {
|
|
371
|
+
pageStyle,
|
|
372
|
+
track
|
|
373
|
+
} = usePager();
|
|
374
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
375
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnative.View, {
|
|
376
|
+
ref,
|
|
377
|
+
...rest,
|
|
378
|
+
style: [pageStyle, {
|
|
379
|
+
width: track.width,
|
|
380
|
+
height: track.height
|
|
381
|
+
}, styleProps, style],
|
|
382
|
+
children
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
PagerPage.displayName = "XAUI.Pager.Page";
|
|
386
|
+
|
|
387
|
+
// src/components/pager/pager.tsx
|
|
388
|
+
|
|
389
|
+
var PagerRoot = _react.forwardRef.call(void 0, function Pager({
|
|
390
|
+
children,
|
|
391
|
+
variant,
|
|
392
|
+
size,
|
|
393
|
+
color,
|
|
394
|
+
orientation = "horizontal",
|
|
395
|
+
index: indexProp,
|
|
396
|
+
defaultIndex = 0,
|
|
397
|
+
onIndexChange,
|
|
398
|
+
isDisabled = false,
|
|
399
|
+
style,
|
|
400
|
+
...props
|
|
401
|
+
}, ref) {
|
|
402
|
+
const theme = _chunkIIAQISBGcjs.useXAUITheme.call(void 0);
|
|
403
|
+
const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
|
|
404
|
+
const [index, setIndex] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
|
|
405
|
+
value: indexProp,
|
|
406
|
+
defaultValue: defaultIndex,
|
|
407
|
+
onChange: onIndexChange
|
|
408
|
+
});
|
|
409
|
+
const [track, setTrack] = _react.useState.call(void 0, {
|
|
410
|
+
width: 0,
|
|
411
|
+
height: 0
|
|
412
|
+
});
|
|
413
|
+
const [count, setCount] = _react.useState.call(void 0, 0);
|
|
414
|
+
const trackRef = _reactnativereanimated.useAnimatedRef.call(void 0);
|
|
415
|
+
const offset = _reactnativereanimated.useSharedValue.call(void 0, 0);
|
|
416
|
+
const selection = {
|
|
417
|
+
variant,
|
|
418
|
+
size,
|
|
419
|
+
orientation
|
|
420
|
+
};
|
|
421
|
+
const states = {
|
|
422
|
+
disabled: isDisabled
|
|
423
|
+
};
|
|
424
|
+
const styles = pagerRecipe.resolve({
|
|
425
|
+
theme,
|
|
426
|
+
selection,
|
|
427
|
+
states
|
|
428
|
+
});
|
|
429
|
+
const tint = color ? pagerRecipe.tint({
|
|
430
|
+
theme,
|
|
431
|
+
color,
|
|
432
|
+
selection,
|
|
433
|
+
states
|
|
434
|
+
}) : void 0;
|
|
435
|
+
const step = orientation === "horizontal" ? track.width : track.height;
|
|
436
|
+
const goTo = _react.useCallback.call(void 0, next => {
|
|
437
|
+
const distance = next * step;
|
|
438
|
+
_optionalChain([trackRef, 'access', _3 => _3.current, 'optionalAccess', _4 => _4.scrollTo, 'call', _5 => _5({
|
|
439
|
+
x: orientation === "horizontal" ? distance : 0,
|
|
440
|
+
y: orientation === "horizontal" ? 0 : distance,
|
|
441
|
+
animated: true
|
|
442
|
+
})]);
|
|
443
|
+
setIndex(next);
|
|
444
|
+
}, [orientation, setIndex, step, trackRef]);
|
|
445
|
+
const context = _react.useMemo.call(void 0, () => ({
|
|
446
|
+
contentStyle: styles.content,
|
|
447
|
+
pageStyle: styles.page,
|
|
448
|
+
indicatorStyle: styles.indicator,
|
|
449
|
+
// One colour for every dot; the current one is told apart by its opacity, which the dot
|
|
450
|
+
// animates itself. Nothing here has to be flattened into a value for a worklet.
|
|
451
|
+
dotStyle: tint ? [styles.dot, tint.dot] : styles.dot,
|
|
452
|
+
orientation,
|
|
453
|
+
index,
|
|
454
|
+
count,
|
|
455
|
+
setCount,
|
|
456
|
+
track,
|
|
457
|
+
setTrack,
|
|
458
|
+
step,
|
|
459
|
+
offset,
|
|
460
|
+
goTo,
|
|
461
|
+
onSettle: setIndex,
|
|
462
|
+
trackRef,
|
|
463
|
+
isDisabled
|
|
464
|
+
}), [styles, tint, orientation, index, count, track, setTrack, step, offset, goTo, setIndex, trackRef, isDisabled]);
|
|
465
|
+
const rootStyle = [styles.root, _optionalChain([tint, 'optionalAccess', _6 => _6.root]), styleProps, style];
|
|
466
|
+
return /* @__PURE__ */_jsxruntime.jsx.call(void 0, PagerProvider, {
|
|
467
|
+
value: context,
|
|
468
|
+
children: /* @__PURE__ */_jsxruntime.jsx.call(void 0, _reactnative.View, {
|
|
469
|
+
ref,
|
|
470
|
+
...rest,
|
|
471
|
+
style: rootStyle,
|
|
472
|
+
children
|
|
473
|
+
})
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
PagerRoot.displayName = "XAUI.Pager.Root";
|
|
477
|
+
|
|
478
|
+
// src/components/pager/index.ts
|
|
479
|
+
var Pager2 = Object.assign(PagerRoot, {
|
|
480
|
+
Content: PagerContent,
|
|
481
|
+
Page: PagerPage,
|
|
482
|
+
Indicator: PagerIndicator,
|
|
483
|
+
Dot: PagerDot
|
|
484
|
+
});
|
|
485
|
+
exports.usePager = usePager;
|
|
486
|
+
exports.PagerContent = PagerContent;
|
|
487
|
+
exports.DOT_REST_OPACITY = DOT_REST_OPACITY;
|
|
488
|
+
exports.pagerRecipe = pagerRecipe;
|
|
489
|
+
exports.PagerIndicator = PagerIndicator;
|
|
490
|
+
exports.PagerDot = PagerDot;
|
|
491
|
+
exports.PagerPage = PagerPage;
|
|
492
|
+
exports.PagerRoot = PagerRoot;
|
|
493
|
+
exports.Pager = Pager2;
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
var _chunkOPLPLFGKcjs = require('../../chunk-OPLPLFGK.cjs');
|
|
11
12
|
require('../../chunk-FTPPUTWL.cjs');
|
|
12
13
|
require('../../chunk-WFEMJCXO.cjs');
|
|
13
14
|
require('../../chunk-7EIHHOHP.cjs');
|
|
@@ -28,4 +29,5 @@ require('../../chunk-TK44VBIE.cjs');
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
|
|
33
|
+
exports.DOT_REST_OPACITY = _chunkOPLPLFGKcjs.DOT_REST_OPACITY; exports.Pager = _chunkOPLPLFGKcjs.Pager; exports.PagerContent = _chunkOPLPLFGKcjs.PagerContent; exports.PagerDot = _chunkOPLPLFGKcjs.PagerDot; exports.PagerIndicator = _chunkOPLPLFGKcjs.PagerIndicator; exports.PagerPage = _chunkOPLPLFGKcjs.PagerPage; exports.PagerRoot = _chunkOPLPLFGKcjs.PagerRoot; exports.pagerRecipe = _chunkOPLPLFGKcjs.pagerRecipe; exports.usePager = _chunkOPLPLFGKcjs.usePager;
|
|
@@ -56,5 +56,5 @@ export { PagerContent } from './pager-content';
|
|
|
56
56
|
export { PagerDot, PagerIndicator } from './pager-indicator';
|
|
57
57
|
export { PagerPage } from './pager-page';
|
|
58
58
|
export { usePager } from './pager.context';
|
|
59
|
-
export { pagerRecipe } from './pager.recipe';
|
|
60
|
-
export type { PagerContentProps, PagerContextValue,
|
|
59
|
+
export { DOT_REST_OPACITY, pagerRecipe } from './pager.recipe';
|
|
60
|
+
export type { PagerContentProps, PagerContextValue, PagerDotProps, PagerOrientation, PagerProps, PagerSize, PagerSlot, PagerTrackSize, PagerVariant, PagerViewSlotProps, } from './pager.type';
|
|
@@ -56,5 +56,5 @@ export { PagerContent } from './pager-content';
|
|
|
56
56
|
export { PagerDot, PagerIndicator } from './pager-indicator';
|
|
57
57
|
export { PagerPage } from './pager-page';
|
|
58
58
|
export { usePager } from './pager.context';
|
|
59
|
-
export { pagerRecipe } from './pager.recipe';
|
|
60
|
-
export type { PagerContentProps, PagerContextValue,
|
|
59
|
+
export { DOT_REST_OPACITY, pagerRecipe } from './pager.recipe';
|
|
60
|
+
export type { PagerContentProps, PagerContextValue, PagerDotProps, PagerOrientation, PagerProps, PagerSize, PagerSlot, PagerTrackSize, PagerVariant, PagerViewSlotProps, } from './pager.type';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DOT_REST_OPACITY,
|
|
2
3
|
Pager,
|
|
3
4
|
PagerContent,
|
|
4
5
|
PagerDot,
|
|
@@ -7,7 +8,7 @@ import {
|
|
|
7
8
|
PagerRoot,
|
|
8
9
|
pagerRecipe,
|
|
9
10
|
usePager
|
|
10
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-2SHWOFQV.js";
|
|
11
12
|
import "../../chunk-3A5RK2R7.js";
|
|
12
13
|
import "../../chunk-NCTOTTVW.js";
|
|
13
14
|
import "../../chunk-F6W3JQ7K.js";
|
|
@@ -20,6 +21,7 @@ import "../../chunk-EGLLDKN6.js";
|
|
|
20
21
|
import "../../chunk-Z6JBWRPL.js";
|
|
21
22
|
import "../../chunk-M63GFNKV.js";
|
|
22
23
|
export {
|
|
24
|
+
DOT_REST_OPACITY,
|
|
23
25
|
Pager,
|
|
24
26
|
PagerContent,
|
|
25
27
|
PagerDot,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
|
-
import type { ViewStyle } from 'react-native';
|
|
3
2
|
/**
|
|
4
3
|
* Whole pages, one at a time — the onboarding flow, the full-screen feed, the gallery a
|
|
5
4
|
* reader swipes through.
|
|
@@ -44,7 +43,7 @@ export declare const PagerRoot: import("react").ForwardRefExoticComponent<{
|
|
|
44
43
|
defaultIndex?: number;
|
|
45
44
|
onIndexChange?: (index: number) => void;
|
|
46
45
|
isDisabled?: boolean;
|
|
47
|
-
style?: import("react-native").StyleProp<ViewStyle>;
|
|
46
|
+
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
48
47
|
children?: import("react").ReactNode;
|
|
49
48
|
} & Omit<import("react-native").ViewProps, keyof {
|
|
50
49
|
variant?: import("./pager.type").PagerVariant;
|
|
@@ -55,7 +54,7 @@ export declare const PagerRoot: import("react").ForwardRefExoticComponent<{
|
|
|
55
54
|
defaultIndex?: number;
|
|
56
55
|
onIndexChange?: (index: number) => void;
|
|
57
56
|
isDisabled?: boolean;
|
|
58
|
-
style?: import("react-native").StyleProp<ViewStyle>;
|
|
57
|
+
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
59
58
|
children?: import("react").ReactNode;
|
|
60
59
|
}> & Omit<import("../..").ViewStyleProps, keyof {
|
|
61
60
|
variant?: import("./pager.type").PagerVariant;
|
|
@@ -66,6 +65,6 @@ export declare const PagerRoot: import("react").ForwardRefExoticComponent<{
|
|
|
66
65
|
defaultIndex?: number;
|
|
67
66
|
onIndexChange?: (index: number) => void;
|
|
68
67
|
isDisabled?: boolean;
|
|
69
|
-
style?: import("react-native").StyleProp<ViewStyle>;
|
|
68
|
+
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
70
69
|
children?: import("react").ReactNode;
|
|
71
70
|
}> & import("react").RefAttributes<View>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
|
-
import type { ViewStyle } from 'react-native';
|
|
3
2
|
/**
|
|
4
3
|
* Whole pages, one at a time — the onboarding flow, the full-screen feed, the gallery a
|
|
5
4
|
* reader swipes through.
|
|
@@ -44,7 +43,7 @@ export declare const PagerRoot: import("react").ForwardRefExoticComponent<{
|
|
|
44
43
|
defaultIndex?: number;
|
|
45
44
|
onIndexChange?: (index: number) => void;
|
|
46
45
|
isDisabled?: boolean;
|
|
47
|
-
style?: import("react-native").StyleProp<ViewStyle>;
|
|
46
|
+
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
48
47
|
children?: import("react").ReactNode;
|
|
49
48
|
} & Omit<import("react-native").ViewProps, keyof {
|
|
50
49
|
variant?: import("./pager.type").PagerVariant;
|
|
@@ -55,7 +54,7 @@ export declare const PagerRoot: import("react").ForwardRefExoticComponent<{
|
|
|
55
54
|
defaultIndex?: number;
|
|
56
55
|
onIndexChange?: (index: number) => void;
|
|
57
56
|
isDisabled?: boolean;
|
|
58
|
-
style?: import("react-native").StyleProp<ViewStyle>;
|
|
57
|
+
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
59
58
|
children?: import("react").ReactNode;
|
|
60
59
|
}> & Omit<import("../..").ViewStyleProps, keyof {
|
|
61
60
|
variant?: import("./pager.type").PagerVariant;
|
|
@@ -66,6 +65,6 @@ export declare const PagerRoot: import("react").ForwardRefExoticComponent<{
|
|
|
66
65
|
defaultIndex?: number;
|
|
67
66
|
onIndexChange?: (index: number) => void;
|
|
68
67
|
isDisabled?: boolean;
|
|
69
|
-
style?: import("react-native").StyleProp<ViewStyle>;
|
|
68
|
+
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
70
69
|
children?: import("react").ReactNode;
|
|
71
70
|
}> & import("react").RefAttributes<View>>;
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import type { SlotStyles } from '../../system/recipe';
|
|
2
2
|
import type { XAUITheme } from '../../theme/theme.type';
|
|
3
3
|
import type { PagerSlot, PagerVariant } from './pager.type';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* How far behind the current dot the others sit.
|
|
6
|
+
*
|
|
7
|
+
* **Opacity, not a second colour**, and this is the load-bearing decision in the file. A
|
|
8
|
+
* neutral fill for the unfilled dots — the `Carousel`'s answer, which this copied first — has
|
|
9
|
+
* to contrast with whatever the current one happens to be, and it cannot: `tertiary` puts
|
|
10
|
+
* `surface` against `default`, which is `#ffffff` on `#e4e4e7` in light and two
|
|
11
|
+
* near-identical greys in dark. The variant that exists for a pager over an image was the one
|
|
12
|
+
* whose indicator could not be read.
|
|
13
|
+
*
|
|
14
|
+
* One colour at two opacities cannot collapse like that, whatever the variant, whichever the
|
|
15
|
+
* colour mode, and for any raw `color` a caller invents. It is also what iOS's own page
|
|
16
|
+
* control does.
|
|
17
|
+
*
|
|
18
|
+
* 0.3 rather than 0.5: the dots are seven points across, and at half strength a small mark
|
|
19
|
+
* reads as the current one seen through something rather than as a mark behind it.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DOT_REST_OPACITY = 0.3;
|
|
22
|
+
export declare const pagerRecipe: import("../..").Recipe<"content" | "root" | "dot" | "indicator" | "page", PagerVariant, {
|
|
5
23
|
readonly size: {
|
|
6
24
|
readonly xs: (theme: XAUITheme) => SlotStyles<PagerSlot>;
|
|
7
25
|
readonly sm: (theme: XAUITheme) => SlotStyles<PagerSlot>;
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import type { SlotStyles } from '../../system/recipe';
|
|
2
2
|
import type { XAUITheme } from '../../theme/theme.type';
|
|
3
3
|
import type { PagerSlot, PagerVariant } from './pager.type';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* How far behind the current dot the others sit.
|
|
6
|
+
*
|
|
7
|
+
* **Opacity, not a second colour**, and this is the load-bearing decision in the file. A
|
|
8
|
+
* neutral fill for the unfilled dots — the `Carousel`'s answer, which this copied first — has
|
|
9
|
+
* to contrast with whatever the current one happens to be, and it cannot: `tertiary` puts
|
|
10
|
+
* `surface` against `default`, which is `#ffffff` on `#e4e4e7` in light and two
|
|
11
|
+
* near-identical greys in dark. The variant that exists for a pager over an image was the one
|
|
12
|
+
* whose indicator could not be read.
|
|
13
|
+
*
|
|
14
|
+
* One colour at two opacities cannot collapse like that, whatever the variant, whichever the
|
|
15
|
+
* colour mode, and for any raw `color` a caller invents. It is also what iOS's own page
|
|
16
|
+
* control does.
|
|
17
|
+
*
|
|
18
|
+
* 0.3 rather than 0.5: the dots are seven points across, and at half strength a small mark
|
|
19
|
+
* reads as the current one seen through something rather than as a mark behind it.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DOT_REST_OPACITY = 0.3;
|
|
22
|
+
export declare const pagerRecipe: import("../..").Recipe<"content" | "root" | "dot" | "indicator" | "page", PagerVariant, {
|
|
5
23
|
readonly size: {
|
|
6
24
|
readonly xs: (theme: XAUITheme) => SlotStyles<PagerSlot>;
|
|
7
25
|
readonly sm: (theme: XAUITheme) => SlotStyles<PagerSlot>;
|