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

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.
@@ -0,0 +1,407 @@
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
+ var _chunk7EIHHOHPcjs = require('./chunk-7EIHHOHP.cjs');
4
+
5
+
6
+ var _chunk3E7CDKFOcjs = require('./chunk-3E7CDKFO.cjs');
7
+
8
+
9
+ var _chunk7DPL3ZDScjs = require('./chunk-7DPL3ZDS.cjs');
10
+
11
+
12
+
13
+ var _chunkFNEUOBCVcjs = require('./chunk-FNEUOBCV.cjs');
14
+
15
+
16
+ var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
17
+
18
+
19
+
20
+ var _chunk7GHM4GKLcjs = require('./chunk-7GHM4GKL.cjs');
21
+
22
+
23
+ var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
24
+
25
+ // src/components/tabs/tabs-content.tsx
26
+ var _react = require('react');
27
+ var _reactnative = require('react-native');
28
+
29
+ // src/components/tabs/tabs.context.ts
30
+ var [TabsProvider, useTabs] = _chunk7GHM4GKLcjs.createSlotContext.call(void 0, "Tabs");
31
+ var [TabsTriggerProvider, useTabsTrigger] = _chunk7GHM4GKLcjs.createSlotContext.call(void 0, "Tabs.Trigger");
32
+
33
+ // src/components/tabs/tabs-content.tsx
34
+ var _jsxruntime = require('react/jsx-runtime');
35
+ var TabsContent = _react.forwardRef.call(void 0, function TabsContent2({ value, children, accessibilityRole = "tab", style, ...props }, ref) {
36
+ const { value: selected } = useTabs();
37
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
38
+ if (selected !== value) return null;
39
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
40
+ _reactnative.View,
41
+ {
42
+ ref,
43
+ accessibilityRole,
44
+ ...rest,
45
+ style: [styleProps, style],
46
+ children
47
+ }
48
+ );
49
+ });
50
+ TabsContent.displayName = "XAUI.Tabs.Content";
51
+
52
+ // src/components/tabs/tabs-indicator.tsx
53
+
54
+
55
+
56
+
57
+
58
+ var _reactnativereanimated = require('react-native-reanimated'); var _reactnativereanimated2 = _interopRequireDefault(_reactnativereanimated);
59
+
60
+ // src/components/tabs/tabs.animation.ts
61
+ var INDICATOR_SPRING = { damping: 20, stiffness: 220, mass: 0.6 };
62
+
63
+ // src/components/tabs/tabs-indicator.tsx
64
+
65
+ function TabsIndicator({ style, ...props }) {
66
+ const { indicatorStyle, value, rects } = useTabs();
67
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
68
+ const rect = value === void 0 ? void 0 : rects[value];
69
+ const x = _reactnativereanimated.useSharedValue.call(void 0, _nullishCoalesce(_optionalChain([rect, 'optionalAccess', _ => _.x]), () => ( 0)));
70
+ const width = _reactnativereanimated.useSharedValue.call(void 0, _nullishCoalesce(_optionalChain([rect, 'optionalAccess', _2 => _2.width]), () => ( 0)));
71
+ const hasArrived = _reactnativereanimated.useSharedValue.call(void 0, rect !== void 0);
72
+ _react.useEffect.call(void 0, () => {
73
+ if (rect === void 0) return;
74
+ if (hasArrived.get()) {
75
+ x.set(_reactnativereanimated.withSpring.call(void 0, rect.x, INDICATOR_SPRING));
76
+ width.set(_reactnativereanimated.withSpring.call(void 0, rect.width, INDICATOR_SPRING));
77
+ } else {
78
+ x.set(rect.x);
79
+ width.set(rect.width);
80
+ hasArrived.set(true);
81
+ }
82
+ }, [rect, hasArrived, width, x]);
83
+ const travel = _reactnativereanimated.useAnimatedStyle.call(void 0, () => ({
84
+ transform: [{ translateX: x.get() }],
85
+ width: width.get(),
86
+ opacity: hasArrived.get() ? 1 : 0
87
+ }));
88
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnativereanimated2.default.View, { ...rest, style: [indicatorStyle, travel, styleProps, style] });
89
+ }
90
+ TabsIndicator.displayName = "XAUI.Tabs.Indicator";
91
+
92
+ // src/components/tabs/tabs-label.tsx
93
+
94
+
95
+
96
+ var TabsLabel = _react.forwardRef.call(void 0, function TabsLabel2({ children, numberOfLines = 1, style, ...props }, ref) {
97
+ const { labelStyle, labelSelectedStyle } = useTabs();
98
+ const { isSelected } = useTabsTrigger();
99
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
100
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
101
+ _reactnative.Text,
102
+ {
103
+ ref,
104
+ numberOfLines,
105
+ ...rest,
106
+ style: [labelStyle, isSelected && labelSelectedStyle, styleProps, style],
107
+ children
108
+ }
109
+ );
110
+ });
111
+ TabsLabel.displayName = "XAUI.Tabs.Label";
112
+
113
+ // src/components/tabs/tabs-list.tsx
114
+
115
+
116
+
117
+ var TabsList = _react.forwardRef.call(void 0, function TabsList2({ children, accessibilityRole = "tablist", style, ...props }, ref) {
118
+ const { listStyle } = useTabs();
119
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
120
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
121
+ _reactnative.View,
122
+ {
123
+ ref,
124
+ accessibilityRole,
125
+ ...rest,
126
+ style: [listStyle, styleProps, style],
127
+ children
128
+ }
129
+ );
130
+ });
131
+ TabsList.displayName = "XAUI.Tabs.List";
132
+
133
+ // src/components/tabs/tabs-trigger.tsx
134
+
135
+
136
+ var TabsTrigger = _react.forwardRef.call(void 0, function TabsTrigger2({
137
+ value,
138
+ children,
139
+ isDisabled = false,
140
+ asChild = false,
141
+ accessibilityRole = "tab",
142
+ accessibilityState,
143
+ style,
144
+ onLayout,
145
+ onPress,
146
+ onPressIn,
147
+ onPressOut,
148
+ ...props
149
+ }, ref) {
150
+ const {
151
+ triggerStyle,
152
+ value: selected,
153
+ isDisabled: isRootDisabled,
154
+ select,
155
+ setRect
156
+ } = useTabs();
157
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
158
+ const [isPressed, press] = _chunk7DPL3ZDScjs.usePressState.call(void 0, { onPressIn, onPressOut });
159
+ const isSelected = selected === value;
160
+ const disabled = isRootDisabled || isDisabled;
161
+ const measure = _react.useCallback.call(void 0,
162
+ (event) => {
163
+ _optionalChain([onLayout, 'optionalCall', _3 => _3(event)]);
164
+ const { x, width } = event.nativeEvent.layout;
165
+ setRect(value, { x, width });
166
+ },
167
+ [onLayout, setRect, value]
168
+ );
169
+ const handlePress = _react.useCallback.call(void 0,
170
+ (event) => {
171
+ _optionalChain([onPress, 'optionalCall', _4 => _4(event)]);
172
+ select(value);
173
+ },
174
+ [onPress, select, value]
175
+ );
176
+ const context = _react.useMemo.call(void 0,
177
+ () => ({ isSelected, isPressed, isDisabled: disabled }),
178
+ [isSelected, isPressed, disabled]
179
+ );
180
+ const text = typeof children === "function" ? null : _chunk7GHM4GKLcjs.childrenToString.call(void 0, children);
181
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TabsTriggerProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
182
+ _chunk3E7CDKFOcjs.PressableFeedback,
183
+ {
184
+ ref,
185
+ isPressed,
186
+ isDisabled: disabled,
187
+ asChild,
188
+ accessibilityRole,
189
+ accessibilityState: {
190
+ disabled,
191
+ selected: isSelected,
192
+ ...accessibilityState
193
+ },
194
+ ...rest,
195
+ onLayout: measure,
196
+ style: [
197
+ triggerStyle,
198
+ styleProps,
199
+ typeof style === "function" ? style({ pressed: isPressed }) : style
200
+ ],
201
+ onPress: handlePress,
202
+ onPressIn: press.onPressIn,
203
+ onPressOut: press.onPressOut,
204
+ children: typeof children === "function" ? children(context) : text !== null ? (
205
+ // R3 — a stringifiable tab becomes its label, which is what makes the common
206
+ // case `<Tabs.Trigger value="all">Tout</Tabs.Trigger>`.
207
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TabsLabel, { children: text })
208
+ ) : children
209
+ }
210
+ ) });
211
+ });
212
+ TabsTrigger.displayName = "XAUI.Tabs.Trigger";
213
+
214
+ // src/components/tabs/tabs.tsx
215
+
216
+
217
+
218
+ // src/components/tabs/tabs.recipe.ts
219
+ var SLOTS = ["root", "list", "trigger", "label", "indicator", "content"];
220
+ var VARIANT_TOKENS = {
221
+ primary: { bg: "default", bgSelected: "segment", fgSelected: "segmentForeground" },
222
+ secondary: { bgSelected: "accent", fgSelected: "foreground" },
223
+ // The accent rather than the foreground: with nothing else moving, the colour is the
224
+ // whole signal, and a chosen tab in plain ink reads as one that is merely darker.
225
+ light: { fgSelected: "accent" }
226
+ };
227
+ var SIZES = {
228
+ sm: { paddingHorizontal: 2.5, paddingVertical: 1, gap: 1, label: "sm" },
229
+ md: { paddingHorizontal: 3, paddingVertical: 1.5, gap: 1.5, label: "md" },
230
+ lg: { paddingHorizontal: 4, paddingVertical: 2, gap: 2, label: "lg" }
231
+ };
232
+ var TRACK_INSET = 3;
233
+ function sizeAxis(step) {
234
+ const { paddingHorizontal, paddingVertical, gap, label } = step;
235
+ return (theme) => ({
236
+ trigger: {
237
+ paddingHorizontal: theme.spacing(paddingHorizontal),
238
+ paddingVertical: theme.spacing(paddingVertical),
239
+ gap: theme.spacing(gap)
240
+ },
241
+ label: {
242
+ fontSize: theme.fontSizes[label],
243
+ lineHeight: theme.lineHeights[label]
244
+ }
245
+ });
246
+ }
247
+ var tabsRecipe = _chunkFNEUOBCVcjs.createRecipe.call(void 0, {
248
+ slots: SLOTS,
249
+ base: (theme) => ({
250
+ root: { flexDirection: "column", gap: theme.spacing(2) },
251
+ list: {
252
+ // Hugs its tabs rather than filling the row. A tab bar as wide as the screen with
253
+ // three tabs in it is a segmented control pretending to be a navigation bar.
254
+ alignSelf: "flex-start",
255
+ flexDirection: "row",
256
+ alignItems: "center",
257
+ borderCurve: "continuous"
258
+ },
259
+ trigger: {
260
+ flexDirection: "row",
261
+ alignItems: "center",
262
+ justifyContent: "center"
263
+ },
264
+ label: {
265
+ fontFamily: theme.fontFamilies.body,
266
+ fontWeight: theme.fontWeights.medium,
267
+ color: theme.colors.muted
268
+ },
269
+ // Behind the triggers, not over them: it is the surface the chosen tab sits on.
270
+ indicator: { position: "absolute", zIndex: 0, borderCurve: "continuous" }
271
+ }),
272
+ variantTokens: VARIANT_TOKENS,
273
+ paint: (_theme, colors) => ({
274
+ list: { backgroundColor: colors.bg },
275
+ indicator: { backgroundColor: colors.bgSelected },
276
+ // Read by the root and handed to the chosen trigger's label alone, which is why it is
277
+ // on a slot the recipe otherwise leaves to `muted`.
278
+ content: { color: colors.fgSelected }
279
+ }),
280
+ variants: {
281
+ size: {
282
+ sm: sizeAxis(SIZES.sm),
283
+ md: sizeAxis(SIZES.md),
284
+ lg: sizeAxis(SIZES.lg)
285
+ },
286
+ radius: _chunkFNEUOBCVcjs.radiusAxis.call(void 0, "list", "indicator")
287
+ },
288
+ /**
289
+ * Where the shapes differ, and `light` is absent on purpose: the base gives the list no
290
+ * padding, no corner and no edge, so a shape that adds none of them is the base itself.
291
+ * `primary` is a pill inside a filled track, so the track is padded and both corners are
292
+ * round; `secondary` is a rule along a bottom edge, so the track carries a hairline and
293
+ * the indicator is that rule.
294
+ */
295
+ compoundVariants: [
296
+ {
297
+ when: { variant: "primary" },
298
+ style: (theme) => ({
299
+ list: { padding: TRACK_INSET, borderRadius: theme.radius["3xl"] },
300
+ indicator: {
301
+ top: TRACK_INSET,
302
+ bottom: TRACK_INSET,
303
+ borderRadius: theme.radius["3xl"],
304
+ ...theme.shadows.surface
305
+ }
306
+ })
307
+ },
308
+ {
309
+ when: { variant: "secondary" },
310
+ style: (theme) => ({
311
+ list: {
312
+ borderBottomWidth: theme.borderWidth.default,
313
+ borderColor: theme.colors.border
314
+ },
315
+ // Two points rather than a hairline: a rule that says which tab is chosen has to
316
+ // outweigh the one it sits on.
317
+ indicator: { bottom: 0, height: 2, borderRadius: 0 }
318
+ })
319
+ }
320
+ ],
321
+ states: {
322
+ disabled: (theme) => ({ list: { opacity: theme.opacity.disabled } })
323
+ },
324
+ defaultVariants: { variant: "primary", size: "md" }
325
+ });
326
+
327
+ // src/components/tabs/tabs.tsx
328
+
329
+ var TabsRoot = _react.forwardRef.call(void 0, function Tabs({
330
+ children,
331
+ variant,
332
+ size,
333
+ radius,
334
+ color,
335
+ value: controlledValue,
336
+ defaultValue,
337
+ onValueChange,
338
+ isDisabled = false,
339
+ style,
340
+ ...props
341
+ }, ref) {
342
+ const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
343
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
344
+ const [rects, setRects] = _react.useState.call(void 0, {});
345
+ const [value, setValue] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
346
+ value: controlledValue,
347
+ defaultValue,
348
+ onChange: onValueChange
349
+ });
350
+ const selection = { variant, size, radius };
351
+ const styles = tabsRecipe.resolve({
352
+ theme,
353
+ selection,
354
+ states: { disabled: isDisabled }
355
+ });
356
+ const tint = color ? tabsRecipe.tint({ theme, color, selection }) : void 0;
357
+ const select = _react.useCallback.call(void 0, (next) => setValue(next), [setValue]);
358
+ const setRect = _react.useCallback.call(void 0, (tab, rect) => {
359
+ setRects((current) => {
360
+ const previous = current[tab];
361
+ if (previous && previous.x === rect.x && previous.width === rect.width)
362
+ return current;
363
+ return { ...current, [tab]: rect };
364
+ });
365
+ }, []);
366
+ const context = _react.useMemo.call(void 0, () => {
367
+ const selected = _reactnative.StyleSheet.flatten([styles.content, _optionalChain([tint, 'optionalAccess', _5 => _5.content])]);
368
+ return {
369
+ listStyle: tint ? [styles.list, tint.list] : styles.list,
370
+ triggerStyle: styles.trigger,
371
+ labelStyle: styles.label,
372
+ labelSelectedStyle: { color: selected.color },
373
+ indicatorStyle: tint ? [styles.indicator, tint.indicator] : styles.indicator,
374
+ contentStyle: void 0,
375
+ variant: _nullishCoalesce(variant, () => ( "primary")),
376
+ value,
377
+ isDisabled,
378
+ select,
379
+ rects,
380
+ setRect
381
+ };
382
+ }, [styles, tint, variant, value, isDisabled, select, rects, setRect]);
383
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TabsProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.View, { ref, ...rest, style: [styles.root, styleProps, style], children }) });
384
+ });
385
+ TabsRoot.displayName = "XAUI.Tabs.Root";
386
+
387
+ // src/components/tabs/index.ts
388
+ var Tabs2 = Object.assign(TabsRoot, {
389
+ List: TabsList,
390
+ Trigger: TabsTrigger,
391
+ Label: TabsLabel,
392
+ Indicator: TabsIndicator,
393
+ Content: TabsContent
394
+ });
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+ exports.useTabs = useTabs; exports.useTabsTrigger = useTabsTrigger; exports.TabsContent = TabsContent; exports.TabsIndicator = TabsIndicator; exports.TabsLabel = TabsLabel; exports.TabsList = TabsList; exports.TabsTrigger = TabsTrigger; exports.tabsRecipe = tabsRecipe; exports.TabsRoot = TabsRoot; exports.Tabs = Tabs2;
@@ -0,0 +1,33 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ var _chunkVLKBESEVcjs = require('../../chunk-VLKBESEV.cjs');
13
+ require('../../chunk-7EIHHOHP.cjs');
14
+ require('../../chunk-3E7CDKFO.cjs');
15
+ require('../../chunk-7DPL3ZDS.cjs');
16
+ require('../../chunk-EJQCQPET.cjs');
17
+ require('../../chunk-FNEUOBCV.cjs');
18
+ require('../../chunk-57SJ4LJF.cjs');
19
+ require('../../chunk-7GHM4GKL.cjs');
20
+ require('../../chunk-H4E4HDEP.cjs');
21
+ require('../../chunk-TK44VBIE.cjs');
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+ exports.Tabs = _chunkVLKBESEVcjs.Tabs; exports.TabsContent = _chunkVLKBESEVcjs.TabsContent; exports.TabsIndicator = _chunkVLKBESEVcjs.TabsIndicator; exports.TabsLabel = _chunkVLKBESEVcjs.TabsLabel; exports.TabsList = _chunkVLKBESEVcjs.TabsList; exports.TabsRoot = _chunkVLKBESEVcjs.TabsRoot; exports.TabsTrigger = _chunkVLKBESEVcjs.TabsTrigger; exports.tabsRecipe = _chunkVLKBESEVcjs.tabsRecipe; exports.useTabs = _chunkVLKBESEVcjs.useTabs; exports.useTabsTrigger = _chunkVLKBESEVcjs.useTabsTrigger;