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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,442 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunkWDDXU3OHcjs = require('./chunk-WDDXU3OH.cjs');
4
+
5
+
6
+
7
+ var _chunkEKS3W46Mcjs = require('./chunk-EKS3W46M.cjs');
8
+
9
+
10
+ var _chunk7EIHHOHPcjs = require('./chunk-7EIHHOHP.cjs');
11
+
12
+
13
+ var _chunkTGMVEHV7cjs = require('./chunk-TGMVEHV7.cjs');
14
+
15
+
16
+ var _chunk7DPL3ZDScjs = require('./chunk-7DPL3ZDS.cjs');
17
+
18
+
19
+ var _chunk7GHM4GKLcjs = require('./chunk-7GHM4GKL.cjs');
20
+
21
+
22
+ var _chunkFNEUOBCVcjs = require('./chunk-FNEUOBCV.cjs');
23
+
24
+
25
+ var _chunk57SJ4LJFcjs = require('./chunk-57SJ4LJF.cjs');
26
+
27
+
28
+ var _chunkTK44VBIEcjs = require('./chunk-TK44VBIE.cjs');
29
+
30
+ // src/components/bottom-sheet/bottom-sheet-close.tsx
31
+ var _react = require('react');
32
+
33
+ // src/components/bottom-sheet/bottom-sheet.context.ts
34
+ var [BottomSheetProvider, useBottomSheet] = _chunk7GHM4GKLcjs.createSlotContext.call(void 0, "BottomSheet");
35
+
36
+ // src/components/bottom-sheet/bottom-sheet-close.tsx
37
+ var _jsxruntime = require('react/jsx-runtime');
38
+ var BottomSheetClose = _react.forwardRef.call(void 0,
39
+ function BottomSheetClose2({
40
+ children,
41
+ asChild = false,
42
+ accessibilityRole = "button",
43
+ style,
44
+ onPress,
45
+ onPressIn,
46
+ onPressOut,
47
+ ...props
48
+ }, ref) {
49
+ const { close } = useBottomSheet();
50
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
51
+ const [isPressed, press] = _chunk7DPL3ZDScjs.usePressState.call(void 0, { onPressIn, onPressOut });
52
+ const handlePress = _react.useCallback.call(void 0,
53
+ (event) => {
54
+ _optionalChain([onPress, 'optionalCall', _ => _(event)]);
55
+ close();
56
+ },
57
+ [close, onPress]
58
+ );
59
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
60
+ _chunkTGMVEHV7cjs.PressableFeedback,
61
+ {
62
+ ref,
63
+ isPressed,
64
+ asChild,
65
+ accessibilityRole,
66
+ ...rest,
67
+ style: [
68
+ styleProps,
69
+ typeof style === "function" ? style({ pressed: isPressed }) : style
70
+ ],
71
+ onPress: handlePress,
72
+ onPressIn: press.onPressIn,
73
+ onPressOut: press.onPressOut,
74
+ children
75
+ }
76
+ );
77
+ }
78
+ );
79
+ BottomSheetClose.displayName = "XAUI.BottomSheet.Close";
80
+
81
+ // src/components/bottom-sheet/bottom-sheet-content.tsx
82
+
83
+ var _reactnativegesturehandler = require('react-native-gesture-handler');
84
+
85
+
86
+
87
+
88
+
89
+ var _reactnativereanimated = require('react-native-reanimated'); var _reactnativereanimated2 = _interopRequireDefault(_reactnativereanimated);
90
+
91
+ // src/components/bottom-sheet/bottom-sheet.animation.ts
92
+ var SHEET_SPRING = { damping: 28, stiffness: 260, mass: 0.9 };
93
+ var DISMISS_VELOCITY = 900;
94
+
95
+ // src/components/bottom-sheet/bottom-sheet-content.tsx
96
+
97
+ function BottomSheetContent({
98
+ children,
99
+ isSwipeable = true,
100
+ accessibilityViewIsModal = true,
101
+ style,
102
+ onLayout,
103
+ ...props
104
+ }) {
105
+ const context = useBottomSheet();
106
+ const { contentStyle, isOpen, dismissThreshold, close } = context;
107
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
108
+ const [height, setHeight] = _react.useState.call(void 0, 0);
109
+ const offset = _reactnativereanimated.useSharedValue.call(void 0, OFFSCREEN);
110
+ const measure = _react.useCallback.call(void 0,
111
+ (event) => {
112
+ _optionalChain([onLayout, 'optionalCall', _2 => _2(event)]);
113
+ setHeight(event.nativeEvent.layout.height);
114
+ },
115
+ [onLayout]
116
+ );
117
+ _react.useEffect.call(void 0, () => {
118
+ if (height === 0) return;
119
+ offset.set(_reactnativereanimated.withSpring.call(void 0, isOpen ? 0 : height, SHEET_SPRING));
120
+ }, [height, isOpen, offset]);
121
+ const pan = _reactnativegesturehandler.Gesture.Pan().enabled(isSwipeable).onUpdate((event) => {
122
+ offset.set(Math.max(event.translationY, 0));
123
+ }).onEnd((event) => {
124
+ const farEnough = event.translationY > height * dismissThreshold;
125
+ const fastEnough = event.velocityY > DISMISS_VELOCITY;
126
+ if (farEnough || fastEnough) {
127
+ offset.set(_reactnativereanimated.withSpring.call(void 0, height, SHEET_SPRING));
128
+ _reactnativereanimated.runOnJS.call(void 0, close)();
129
+ return;
130
+ }
131
+ offset.set(_reactnativereanimated.withSpring.call(void 0, 0, SHEET_SPRING));
132
+ });
133
+ const slide = _reactnativereanimated.useAnimatedStyle.call(void 0, () => ({
134
+ transform: [{ translateY: offset.get() }]
135
+ }));
136
+ if (!isOpen) return null;
137
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWDDXU3OHcjs.Portal, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BottomSheetProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnativegesturehandler.GestureDetector, { gesture: pan, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
138
+ _reactnativereanimated2.default.View,
139
+ {
140
+ accessibilityViewIsModal,
141
+ onLayout: measure,
142
+ ...rest,
143
+ style: [contentStyle, slide, styleProps, style],
144
+ children
145
+ }
146
+ ) }) }) });
147
+ }
148
+ var OFFSCREEN = 2e3;
149
+ BottomSheetContent.displayName = "XAUI.BottomSheet.Content";
150
+
151
+ // src/components/bottom-sheet/bottom-sheet-description.tsx
152
+
153
+ var _reactnative = require('react-native');
154
+
155
+ var BottomSheetDescription = _react.forwardRef.call(void 0,
156
+ function BottomSheetDescription2({ children, style, ...props }, ref) {
157
+ const { descriptionStyle } = useBottomSheet();
158
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
159
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactnative.Text, { ref, ...rest, style: [descriptionStyle, styleProps, style], children });
160
+ }
161
+ );
162
+ BottomSheetDescription.displayName = "XAUI.BottomSheet.Description";
163
+
164
+ // src/components/bottom-sheet/bottom-sheet-handle.tsx
165
+
166
+
167
+
168
+ var BottomSheetHandle = _react.forwardRef.call(void 0,
169
+ function BottomSheetHandle2({ style, ...props }, ref) {
170
+ const { handleStyle } = useBottomSheet();
171
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
172
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
173
+ _reactnative.View,
174
+ {
175
+ ref,
176
+ accessibilityElementsHidden: true,
177
+ importantForAccessibility: "no-hide-descendants",
178
+ ...rest,
179
+ style: [handleStyle, styleProps, style]
180
+ }
181
+ );
182
+ }
183
+ );
184
+ BottomSheetHandle.displayName = "XAUI.BottomSheet.Handle";
185
+
186
+ // src/components/bottom-sheet/bottom-sheet-overlay.tsx
187
+
188
+
189
+
190
+
191
+ var AnimatedPressable = _reactnativereanimated2.default.createAnimatedComponent(_reactnative.Pressable);
192
+ var BottomSheetOverlay = _react.forwardRef.call(void 0,
193
+ function BottomSheetOverlay2({ children, isDismissable = true, style, ...props }, ref) {
194
+ const context = useBottomSheet();
195
+ const { overlayStyle, isOpen, close } = context;
196
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
197
+ if (!isOpen) return null;
198
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkWDDXU3OHcjs.Portal, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BottomSheetProvider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
199
+ AnimatedPressable,
200
+ {
201
+ ref,
202
+ entering: _chunkEKS3W46Mcjs.overlayEntering,
203
+ exiting: _chunkEKS3W46Mcjs.overlayExiting,
204
+ accessibilityRole: "none",
205
+ importantForAccessibility: "no",
206
+ onPress: isDismissable ? close : void 0,
207
+ ...rest,
208
+ style: [overlayStyle, styleProps, style],
209
+ children
210
+ }
211
+ ) }) });
212
+ }
213
+ );
214
+ BottomSheetOverlay.displayName = "XAUI.BottomSheet.Overlay";
215
+
216
+ // src/components/bottom-sheet/bottom-sheet-title.tsx
217
+
218
+
219
+
220
+ var BottomSheetTitle = _react.forwardRef.call(void 0,
221
+ function BottomSheetTitle2({ children, accessibilityRole = "header", style, ...props }, ref) {
222
+ const { titleStyle } = useBottomSheet();
223
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
224
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
225
+ _reactnative.Text,
226
+ {
227
+ ref,
228
+ accessibilityRole,
229
+ ...rest,
230
+ style: [titleStyle, styleProps, style],
231
+ children
232
+ }
233
+ );
234
+ }
235
+ );
236
+ BottomSheetTitle.displayName = "XAUI.BottomSheet.Title";
237
+
238
+ // src/components/bottom-sheet/bottom-sheet-trigger.tsx
239
+
240
+
241
+ var BottomSheetTrigger = _react.forwardRef.call(void 0,
242
+ function BottomSheetTrigger2({
243
+ children,
244
+ asChild = false,
245
+ accessibilityRole = "button",
246
+ accessibilityState,
247
+ style,
248
+ onPress,
249
+ onPressIn,
250
+ onPressOut,
251
+ ...props
252
+ }, ref) {
253
+ const { isOpen, isDisabled, toggle } = useBottomSheet();
254
+ const [styleProps, rest] = _chunkTK44VBIEcjs.useStyleProps.call(void 0, props);
255
+ const [isPressed, press] = _chunk7DPL3ZDScjs.usePressState.call(void 0, { onPressIn, onPressOut });
256
+ const handlePress = _react.useCallback.call(void 0,
257
+ (event) => {
258
+ _optionalChain([onPress, 'optionalCall', _3 => _3(event)]);
259
+ toggle();
260
+ },
261
+ [onPress, toggle]
262
+ );
263
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
264
+ _chunkTGMVEHV7cjs.PressableFeedback,
265
+ {
266
+ ref,
267
+ isPressed,
268
+ isDisabled,
269
+ asChild,
270
+ accessibilityRole,
271
+ accessibilityState: {
272
+ disabled: isDisabled,
273
+ expanded: isOpen,
274
+ ...accessibilityState
275
+ },
276
+ ...rest,
277
+ style: [
278
+ styleProps,
279
+ typeof style === "function" ? style({ pressed: isPressed }) : style
280
+ ],
281
+ onPress: handlePress,
282
+ onPressIn: press.onPressIn,
283
+ onPressOut: press.onPressOut,
284
+ children
285
+ }
286
+ );
287
+ }
288
+ );
289
+ BottomSheetTrigger.displayName = "XAUI.BottomSheet.Trigger";
290
+
291
+ // src/components/bottom-sheet/bottom-sheet.tsx
292
+
293
+
294
+ // src/components/bottom-sheet/bottom-sheet.recipe.ts
295
+ var SLOTS = ["overlay", "content", "handle", "title", "description"];
296
+ var HANDLE = { width: 36, height: 4 };
297
+ function topCorners(radius) {
298
+ return (theme) => ({
299
+ content: {
300
+ borderTopStartRadius: theme.radius[radius],
301
+ borderTopEndRadius: theme.radius[radius]
302
+ }
303
+ });
304
+ }
305
+ var RADII = [
306
+ "xs",
307
+ "sm",
308
+ "md",
309
+ "lg",
310
+ "xl",
311
+ "2xl",
312
+ "3xl",
313
+ "4xl",
314
+ "field",
315
+ "full"
316
+ ];
317
+ var bottomSheetRecipe = _chunkFNEUOBCVcjs.createRecipe.call(void 0, {
318
+ slots: SLOTS,
319
+ base: (theme) => ({
320
+ overlay: {
321
+ position: "absolute",
322
+ top: 0,
323
+ bottom: 0,
324
+ start: 0,
325
+ end: 0,
326
+ backgroundColor: theme.colors.backdrop
327
+ },
328
+ content: {
329
+ position: "absolute",
330
+ start: 0,
331
+ end: 0,
332
+ bottom: 0,
333
+ backgroundColor: theme.colors.overlay,
334
+ padding: theme.spacing(5),
335
+ gap: theme.spacing(2),
336
+ // HeroUI's `--radius-4xl` on a base of 8 is 32 points; the nearest on our base of 12
337
+ // is `3xl` at 36. A sheet's corner is the largest in the library because it is the
338
+ // only edge of it you can see.
339
+ borderTopStartRadius: theme.radius["3xl"],
340
+ borderTopEndRadius: theme.radius["3xl"],
341
+ borderCurve: "continuous",
342
+ ...theme.shadows.overlay
343
+ },
344
+ /**
345
+ * The grab bar. It is the only thing telling a reader the sheet can be dragged — the
346
+ * gesture has no other affordance, and a sheet without one reads as a panel that
347
+ * happens to have arrived from below.
348
+ */
349
+ handle: {
350
+ alignSelf: "center",
351
+ width: HANDLE.width,
352
+ height: HANDLE.height,
353
+ borderRadius: HANDLE.height / 2,
354
+ backgroundColor: theme.colors.separator
355
+ },
356
+ title: {
357
+ fontFamily: theme.fontFamilies.body,
358
+ fontWeight: theme.fontWeights.medium,
359
+ fontSize: theme.fontSizes.lg,
360
+ lineHeight: theme.lineHeights.lg,
361
+ color: theme.colors.overlayForeground
362
+ },
363
+ description: {
364
+ fontFamily: theme.fontFamilies.body,
365
+ fontSize: theme.fontSizes.md,
366
+ lineHeight: theme.lineHeights.md,
367
+ color: theme.colors.muted
368
+ }
369
+ }),
370
+ /** One variant: a sheet is the theme's floating surface, with no emphasis to report. */
371
+ variantTokens: { default: {} },
372
+ variants: {
373
+ radius: Object.fromEntries(RADII.map((r) => [r, topCorners(r)]))
374
+ },
375
+ defaultVariants: { variant: "default" }
376
+ });
377
+
378
+ // src/components/bottom-sheet/bottom-sheet.tsx
379
+
380
+ function BottomSheet({
381
+ children,
382
+ radius,
383
+ isOpen: controlledOpen,
384
+ defaultOpen = false,
385
+ onOpenChange,
386
+ isDisabled = false,
387
+ dismissThreshold = 0.35
388
+ }) {
389
+ const theme = _chunk57SJ4LJFcjs.useXAUITheme.call(void 0, );
390
+ const [isOpen, setOpen] = _chunk7EIHHOHPcjs.useControllableState.call(void 0, {
391
+ value: controlledOpen,
392
+ defaultValue: defaultOpen,
393
+ onChange: onOpenChange
394
+ });
395
+ const styles = bottomSheetRecipe.resolve({ theme, selection: { radius } });
396
+ const open = _react.useCallback.call(void 0, () => setOpen(true), [setOpen]);
397
+ const close = _react.useCallback.call(void 0, () => setOpen(false), [setOpen]);
398
+ const toggle = _react.useCallback.call(void 0, () => setOpen((current) => !current), [setOpen]);
399
+ const context = _react.useMemo.call(void 0,
400
+ () => ({
401
+ overlayStyle: styles.overlay,
402
+ contentStyle: styles.content,
403
+ handleStyle: styles.handle,
404
+ titleStyle: styles.title,
405
+ descriptionStyle: styles.description,
406
+ isOpen,
407
+ isDisabled,
408
+ dismissThreshold,
409
+ open,
410
+ close,
411
+ toggle
412
+ }),
413
+ [styles, isOpen, isDisabled, dismissThreshold, open, close, toggle]
414
+ );
415
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BottomSheetProvider, { value: context, children });
416
+ }
417
+ BottomSheet.displayName = "XAUI.BottomSheet.Root";
418
+
419
+ // src/components/bottom-sheet/index.ts
420
+ var BottomSheet2 = Object.assign(BottomSheet, {
421
+ Trigger: BottomSheetTrigger,
422
+ Overlay: BottomSheetOverlay,
423
+ Content: BottomSheetContent,
424
+ Handle: BottomSheetHandle,
425
+ Title: BottomSheetTitle,
426
+ Description: BottomSheetDescription,
427
+ Close: BottomSheetClose
428
+ });
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+ exports.useBottomSheet = useBottomSheet; exports.BottomSheetClose = BottomSheetClose; exports.BottomSheetContent = BottomSheetContent; exports.BottomSheetDescription = BottomSheetDescription; exports.BottomSheetHandle = BottomSheetHandle; exports.BottomSheetOverlay = BottomSheetOverlay; exports.BottomSheetTitle = BottomSheetTitle; exports.BottomSheetTrigger = BottomSheetTrigger; exports.bottomSheetRecipe = bottomSheetRecipe; exports.BottomSheet = BottomSheet; exports.BottomSheet2 = BottomSheet2;
@@ -0,0 +1,37 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+ var _chunkP2GKAAA3cjs = require('../../chunk-P2GKAAA3.cjs');
14
+ require('../../chunk-WDDXU3OH.cjs');
15
+ require('../../chunk-EKS3W46M.cjs');
16
+ require('../../chunk-7EIHHOHP.cjs');
17
+ require('../../chunk-TGMVEHV7.cjs');
18
+ require('../../chunk-7DPL3ZDS.cjs');
19
+ require('../../chunk-EJQCQPET.cjs');
20
+ require('../../chunk-7GHM4GKL.cjs');
21
+ require('../../chunk-H4E4HDEP.cjs');
22
+ require('../../chunk-FNEUOBCV.cjs');
23
+ require('../../chunk-57SJ4LJF.cjs');
24
+ require('../../chunk-TK44VBIE.cjs');
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+ exports.BottomSheet = _chunkP2GKAAA3cjs.BottomSheet2; exports.BottomSheetClose = _chunkP2GKAAA3cjs.BottomSheetClose; exports.BottomSheetContent = _chunkP2GKAAA3cjs.BottomSheetContent; exports.BottomSheetDescription = _chunkP2GKAAA3cjs.BottomSheetDescription; exports.BottomSheetHandle = _chunkP2GKAAA3cjs.BottomSheetHandle; exports.BottomSheetOverlay = _chunkP2GKAAA3cjs.BottomSheetOverlay; exports.BottomSheetRoot = _chunkP2GKAAA3cjs.BottomSheet; exports.BottomSheetTitle = _chunkP2GKAAA3cjs.BottomSheetTitle; exports.BottomSheetTrigger = _chunkP2GKAAA3cjs.BottomSheetTrigger; exports.bottomSheetRecipe = _chunkP2GKAAA3cjs.bottomSheetRecipe; exports.useBottomSheet = _chunkP2GKAAA3cjs.useBottomSheet;