@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.
- package/dist/chunk-J5WXI5NU.js +520 -0
- package/dist/chunk-P2GKAAA3.cjs +442 -0
- package/dist/components/bottom-sheet/index.cjs +37 -0
- package/dist/components/bottom-sheet/index.d.cts +230 -0
- package/dist/components/bottom-sheet/index.d.ts +230 -0
- package/dist/components/bottom-sheet/index.js +37 -0
- package/dist/index.cjs +49 -25
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +73 -49
- package/dist/system/index.cjs +5 -5
- package/dist/system/index.js +7 -7
- package/package.json +11 -1
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import { Portal } from "./chunk-2PMXMKS5.js";
|
|
2
|
+
import { overlayEntering, overlayExiting } from "./chunk-64MXEVT3.js";
|
|
3
|
+
import { useControllableState } from "./chunk-F6W3JQ7K.js";
|
|
4
|
+
import { PressableFeedback } from "./chunk-LIUO6D3D.js";
|
|
5
|
+
import { usePressState } from "./chunk-423RQBOX.js";
|
|
6
|
+
import { createSlotContext } from "./chunk-K72UDPVN.js";
|
|
7
|
+
import { createRecipe } from "./chunk-4GTAZM2C.js";
|
|
8
|
+
import { useXAUITheme } from "./chunk-A3EGFI6T.js";
|
|
9
|
+
import { useStyleProps } from "./chunk-M63GFNKV.js";
|
|
10
|
+
|
|
11
|
+
// src/components/bottom-sheet/bottom-sheet-close.tsx
|
|
12
|
+
import { forwardRef, useCallback } from "react";
|
|
13
|
+
|
|
14
|
+
// src/components/bottom-sheet/bottom-sheet.context.ts
|
|
15
|
+
var [BottomSheetProvider, useBottomSheet] = createSlotContext("BottomSheet");
|
|
16
|
+
|
|
17
|
+
// src/components/bottom-sheet/bottom-sheet-close.tsx
|
|
18
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
|
+
var BottomSheetClose = forwardRef(function BottomSheetClose2({
|
|
20
|
+
children,
|
|
21
|
+
asChild = false,
|
|
22
|
+
accessibilityRole = "button",
|
|
23
|
+
style,
|
|
24
|
+
onPress,
|
|
25
|
+
onPressIn,
|
|
26
|
+
onPressOut,
|
|
27
|
+
...props
|
|
28
|
+
}, ref) {
|
|
29
|
+
const {
|
|
30
|
+
close
|
|
31
|
+
} = useBottomSheet();
|
|
32
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
33
|
+
const [isPressed, press] = usePressState({
|
|
34
|
+
onPressIn,
|
|
35
|
+
onPressOut
|
|
36
|
+
});
|
|
37
|
+
const handlePress = useCallback(event => {
|
|
38
|
+
onPress?.(event);
|
|
39
|
+
close();
|
|
40
|
+
}, [close, onPress]);
|
|
41
|
+
return /* @__PURE__ */jsx(PressableFeedback, {
|
|
42
|
+
ref,
|
|
43
|
+
isPressed,
|
|
44
|
+
asChild,
|
|
45
|
+
accessibilityRole,
|
|
46
|
+
...rest,
|
|
47
|
+
style: [styleProps, typeof style === "function" ? style({
|
|
48
|
+
pressed: isPressed
|
|
49
|
+
}) : style],
|
|
50
|
+
onPress: handlePress,
|
|
51
|
+
onPressIn: press.onPressIn,
|
|
52
|
+
onPressOut: press.onPressOut,
|
|
53
|
+
children
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
BottomSheetClose.displayName = "XAUI.BottomSheet.Close";
|
|
57
|
+
|
|
58
|
+
// src/components/bottom-sheet/bottom-sheet-content.tsx
|
|
59
|
+
import { useCallback as useCallback2, useEffect, useState } from "react";
|
|
60
|
+
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
61
|
+
import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withSpring } from "react-native-reanimated";
|
|
62
|
+
|
|
63
|
+
// src/components/bottom-sheet/bottom-sheet.animation.ts
|
|
64
|
+
var SHEET_SPRING = {
|
|
65
|
+
damping: 28,
|
|
66
|
+
stiffness: 260,
|
|
67
|
+
mass: 0.9
|
|
68
|
+
};
|
|
69
|
+
var DISMISS_VELOCITY = 900;
|
|
70
|
+
|
|
71
|
+
// src/components/bottom-sheet/bottom-sheet-content.tsx
|
|
72
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
73
|
+
const _worklet_77790971326_init_data = {
|
|
74
|
+
code: "function chunkJ5WXI5NUJs1(event){const{height,dismissThreshold,DISMISS_VELOCITY,offset,withSpring,SHEET_SPRING,runOnJS,close}=this.__closure;const farEnough=event.translationY>height*dismissThreshold;const fastEnough=event.velocityY>DISMISS_VELOCITY;if(farEnough||fastEnough){offset.set(withSpring(height,SHEET_SPRING));runOnJS(close)();return;}offset.set(withSpring(0,SHEET_SPRING));}",
|
|
75
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-J5WXI5NU.js",
|
|
76
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkJ5WXI5NUJs1\",\"event\",\"height\",\"dismissThreshold\",\"DISMISS_VELOCITY\",\"offset\",\"withSpring\",\"SHEET_SPRING\",\"runOnJS\",\"close\",\"__closure\",\"farEnough\",\"translationY\",\"fastEnough\",\"velocityY\",\"set\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-J5WXI5NU.js\"],\"mappings\":\"AA0HY,SAAAA,gBAAUA,CAAAC,KAAA,QAAAC,MAAA,CAAAC,gBAAA,CAAAC,gBAAA,CAAAC,MAAA,CAAAC,UAAA,CAAAC,YAAA,CAAAC,OAAA,CAAAC,KAAA,OAAAC,SAAA,CAClB,KAAM,CAAAC,SAAS,CAAGV,KAAK,CAACW,YAAY,CAAGV,MAAM,CAAGC,gBAAgB,CAChE,KAAM,CAAAU,UAAU,CAAGZ,KAAK,CAACa,SAAS,CAAGV,gBAAgB,CACrD,GAAIO,SAAS,EAAIE,UAAU,CAAE,CAC3BR,MAAM,CAACU,GAAG,CAACT,UAAU,CAACJ,MAAM,CAAEK,YAAY,CAAC,CAAC,CAC5CC,OAAO,CAACC,KAAK,CAAC,CAAC,CAAC,CAChB,OACF,CACAJ,MAAM,CAACU,GAAG,CAACT,UAAU,CAAC,CAAC,CAAEC,YAAY,CAAC,CAAC,CACzC\",\"ignoreList\":[]}"
|
|
77
|
+
};
|
|
78
|
+
const _worklet_12195044952804_init_data = {
|
|
79
|
+
code: "function chunkJ5WXI5NUJs2(event){const{offset}=this.__closure;offset.set(Math.max(event.translationY,0));}",
|
|
80
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-J5WXI5NU.js",
|
|
81
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkJ5WXI5NUJs2\",\"event\",\"offset\",\"__closure\",\"set\",\"Math\",\"max\",\"translationY\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-J5WXI5NU.js\"],\"mappings\":\"AAwH2D,SAAAA,gBAAUA,CAAAC,KAAA,QAAAC,MAAA,OAAAC,SAAA,CACjED,MAAM,CAACE,GAAG,CAACC,IAAI,CAACC,GAAG,CAACL,KAAK,CAACM,YAAY,CAAE,CAAC,CAAC,CAAC,CAC7C\",\"ignoreList\":[]}"
|
|
82
|
+
};
|
|
83
|
+
const _worklet_15404457517253_init_data = {
|
|
84
|
+
code: "function chunkJ5WXI5NUJs3(){const{offset}=this.__closure;return{transform:[{translateY:offset.get()}]};}",
|
|
85
|
+
location: "/home/runner/work/xaui/xaui/packages/native/dist/chunk-J5WXI5NU.js",
|
|
86
|
+
sourceMap: "{\"version\":3,\"names\":[\"chunkJ5WXI5NUJs3\",\"offset\",\"__closure\",\"transform\",\"translateY\",\"get\"],\"sources\":[\"/home/runner/work/xaui/xaui/packages/native/dist/chunk-J5WXI5NU.js\"],\"mappings\":\"AAoIiC,SAAAA,iBAAA,QAAAC,MAAA,OAAAC,SAAA,OAAO,CACpCC,SAAS,CAAE,CAAC,CAAEC,UAAU,CAAEH,MAAM,CAACI,GAAG,CAAC,CAAE,CAAC,CAC1C,CAAC\",\"ignoreList\":[]}"
|
|
87
|
+
};
|
|
88
|
+
function BottomSheetContent({
|
|
89
|
+
children,
|
|
90
|
+
isSwipeable = true,
|
|
91
|
+
accessibilityViewIsModal = true,
|
|
92
|
+
style,
|
|
93
|
+
onLayout,
|
|
94
|
+
...props
|
|
95
|
+
}) {
|
|
96
|
+
const context = useBottomSheet();
|
|
97
|
+
const {
|
|
98
|
+
contentStyle,
|
|
99
|
+
isOpen,
|
|
100
|
+
dismissThreshold,
|
|
101
|
+
close
|
|
102
|
+
} = context;
|
|
103
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
104
|
+
const [height, setHeight] = useState(0);
|
|
105
|
+
const offset = useSharedValue(OFFSCREEN);
|
|
106
|
+
const measure = useCallback2(event => {
|
|
107
|
+
onLayout?.(event);
|
|
108
|
+
setHeight(event.nativeEvent.layout.height);
|
|
109
|
+
}, [onLayout]);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (height === 0) return;
|
|
112
|
+
offset.set(withSpring(isOpen ? 0 : height, SHEET_SPRING));
|
|
113
|
+
}, [height, isOpen, offset]);
|
|
114
|
+
const pan = Gesture.Pan().enabled(isSwipeable).onUpdate(function chunkJ5WXI5NUJs2Factory({
|
|
115
|
+
_worklet_12195044952804_init_data,
|
|
116
|
+
offset
|
|
117
|
+
}) {
|
|
118
|
+
const _e = [new global.Error(), -2, -27];
|
|
119
|
+
const chunkJ5WXI5NUJs2 = function (event) {
|
|
120
|
+
offset.set(Math.max(event.translationY, 0));
|
|
121
|
+
};
|
|
122
|
+
chunkJ5WXI5NUJs2.__closure = {
|
|
123
|
+
offset
|
|
124
|
+
};
|
|
125
|
+
chunkJ5WXI5NUJs2.__workletHash = 12195044952804;
|
|
126
|
+
chunkJ5WXI5NUJs2.__pluginVersion = "0.7.4";
|
|
127
|
+
chunkJ5WXI5NUJs2.__initData = _worklet_12195044952804_init_data;
|
|
128
|
+
chunkJ5WXI5NUJs2.__stackDetails = _e;
|
|
129
|
+
return chunkJ5WXI5NUJs2;
|
|
130
|
+
}({
|
|
131
|
+
_worklet_12195044952804_init_data,
|
|
132
|
+
offset
|
|
133
|
+
})).onEnd(function chunkJ5WXI5NUJs1Factory({
|
|
134
|
+
_worklet_77790971326_init_data,
|
|
135
|
+
height,
|
|
136
|
+
dismissThreshold,
|
|
137
|
+
DISMISS_VELOCITY,
|
|
138
|
+
offset,
|
|
139
|
+
withSpring,
|
|
140
|
+
SHEET_SPRING,
|
|
141
|
+
runOnJS,
|
|
142
|
+
close
|
|
143
|
+
}) {
|
|
144
|
+
const _e = [new global.Error(), -9, -27];
|
|
145
|
+
const chunkJ5WXI5NUJs1 = function (event) {
|
|
146
|
+
const farEnough = event.translationY > height * dismissThreshold;
|
|
147
|
+
const fastEnough = event.velocityY > DISMISS_VELOCITY;
|
|
148
|
+
if (farEnough || fastEnough) {
|
|
149
|
+
offset.set(withSpring(height, SHEET_SPRING));
|
|
150
|
+
runOnJS(close)();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
offset.set(withSpring(0, SHEET_SPRING));
|
|
154
|
+
};
|
|
155
|
+
chunkJ5WXI5NUJs1.__closure = {
|
|
156
|
+
height,
|
|
157
|
+
dismissThreshold,
|
|
158
|
+
DISMISS_VELOCITY,
|
|
159
|
+
offset,
|
|
160
|
+
withSpring,
|
|
161
|
+
SHEET_SPRING,
|
|
162
|
+
runOnJS,
|
|
163
|
+
close
|
|
164
|
+
};
|
|
165
|
+
chunkJ5WXI5NUJs1.__workletHash = 77790971326;
|
|
166
|
+
chunkJ5WXI5NUJs1.__pluginVersion = "0.7.4";
|
|
167
|
+
chunkJ5WXI5NUJs1.__initData = _worklet_77790971326_init_data;
|
|
168
|
+
chunkJ5WXI5NUJs1.__stackDetails = _e;
|
|
169
|
+
return chunkJ5WXI5NUJs1;
|
|
170
|
+
}({
|
|
171
|
+
_worklet_77790971326_init_data,
|
|
172
|
+
height,
|
|
173
|
+
dismissThreshold,
|
|
174
|
+
DISMISS_VELOCITY,
|
|
175
|
+
offset,
|
|
176
|
+
withSpring,
|
|
177
|
+
SHEET_SPRING,
|
|
178
|
+
runOnJS,
|
|
179
|
+
close
|
|
180
|
+
}));
|
|
181
|
+
const slide = useAnimatedStyle(function chunkJ5WXI5NUJs3Factory({
|
|
182
|
+
_worklet_15404457517253_init_data,
|
|
183
|
+
offset
|
|
184
|
+
}) {
|
|
185
|
+
const _e = [new global.Error(), -2, -27];
|
|
186
|
+
const chunkJ5WXI5NUJs3 = () => ({
|
|
187
|
+
transform: [{
|
|
188
|
+
translateY: offset.get()
|
|
189
|
+
}]
|
|
190
|
+
});
|
|
191
|
+
chunkJ5WXI5NUJs3.__closure = {
|
|
192
|
+
offset
|
|
193
|
+
};
|
|
194
|
+
chunkJ5WXI5NUJs3.__workletHash = 15404457517253;
|
|
195
|
+
chunkJ5WXI5NUJs3.__pluginVersion = "0.7.4";
|
|
196
|
+
chunkJ5WXI5NUJs3.__initData = _worklet_15404457517253_init_data;
|
|
197
|
+
chunkJ5WXI5NUJs3.__stackDetails = _e;
|
|
198
|
+
return chunkJ5WXI5NUJs3;
|
|
199
|
+
}({
|
|
200
|
+
_worklet_15404457517253_init_data,
|
|
201
|
+
offset
|
|
202
|
+
}));
|
|
203
|
+
if (!isOpen) return null;
|
|
204
|
+
return /* @__PURE__ */jsx2(Portal, {
|
|
205
|
+
children: /* @__PURE__ */jsx2(BottomSheetProvider, {
|
|
206
|
+
value: context,
|
|
207
|
+
children: /* @__PURE__ */jsx2(GestureDetector, {
|
|
208
|
+
gesture: pan,
|
|
209
|
+
children: /* @__PURE__ */jsx2(Animated.View, {
|
|
210
|
+
accessibilityViewIsModal,
|
|
211
|
+
onLayout: measure,
|
|
212
|
+
...rest,
|
|
213
|
+
style: [contentStyle, slide, styleProps, style],
|
|
214
|
+
children
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
var OFFSCREEN = 2e3;
|
|
221
|
+
BottomSheetContent.displayName = "XAUI.BottomSheet.Content";
|
|
222
|
+
|
|
223
|
+
// src/components/bottom-sheet/bottom-sheet-description.tsx
|
|
224
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
225
|
+
import { Text } from "react-native";
|
|
226
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
227
|
+
var BottomSheetDescription = forwardRef2(function BottomSheetDescription2({
|
|
228
|
+
children,
|
|
229
|
+
style,
|
|
230
|
+
...props
|
|
231
|
+
}, ref) {
|
|
232
|
+
const {
|
|
233
|
+
descriptionStyle
|
|
234
|
+
} = useBottomSheet();
|
|
235
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
236
|
+
return /* @__PURE__ */jsx3(Text, {
|
|
237
|
+
ref,
|
|
238
|
+
...rest,
|
|
239
|
+
style: [descriptionStyle, styleProps, style],
|
|
240
|
+
children
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
BottomSheetDescription.displayName = "XAUI.BottomSheet.Description";
|
|
244
|
+
|
|
245
|
+
// src/components/bottom-sheet/bottom-sheet-handle.tsx
|
|
246
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
247
|
+
import { View } from "react-native";
|
|
248
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
249
|
+
var BottomSheetHandle = forwardRef3(function BottomSheetHandle2({
|
|
250
|
+
style,
|
|
251
|
+
...props
|
|
252
|
+
}, ref) {
|
|
253
|
+
const {
|
|
254
|
+
handleStyle
|
|
255
|
+
} = useBottomSheet();
|
|
256
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
257
|
+
return /* @__PURE__ */jsx4(View, {
|
|
258
|
+
ref,
|
|
259
|
+
accessibilityElementsHidden: true,
|
|
260
|
+
importantForAccessibility: "no-hide-descendants",
|
|
261
|
+
...rest,
|
|
262
|
+
style: [handleStyle, styleProps, style]
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
BottomSheetHandle.displayName = "XAUI.BottomSheet.Handle";
|
|
266
|
+
|
|
267
|
+
// src/components/bottom-sheet/bottom-sheet-overlay.tsx
|
|
268
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
269
|
+
import { Pressable } from "react-native";
|
|
270
|
+
import Animated2 from "react-native-reanimated";
|
|
271
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
272
|
+
var AnimatedPressable = Animated2.createAnimatedComponent(Pressable);
|
|
273
|
+
var BottomSheetOverlay = forwardRef4(function BottomSheetOverlay2({
|
|
274
|
+
children,
|
|
275
|
+
isDismissable = true,
|
|
276
|
+
style,
|
|
277
|
+
...props
|
|
278
|
+
}, ref) {
|
|
279
|
+
const context = useBottomSheet();
|
|
280
|
+
const {
|
|
281
|
+
overlayStyle,
|
|
282
|
+
isOpen,
|
|
283
|
+
close
|
|
284
|
+
} = context;
|
|
285
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
286
|
+
if (!isOpen) return null;
|
|
287
|
+
return /* @__PURE__ */jsx5(Portal, {
|
|
288
|
+
children: /* @__PURE__ */jsx5(BottomSheetProvider, {
|
|
289
|
+
value: context,
|
|
290
|
+
children: /* @__PURE__ */jsx5(AnimatedPressable, {
|
|
291
|
+
ref,
|
|
292
|
+
entering: overlayEntering,
|
|
293
|
+
exiting: overlayExiting,
|
|
294
|
+
accessibilityRole: "none",
|
|
295
|
+
importantForAccessibility: "no",
|
|
296
|
+
onPress: isDismissable ? close : void 0,
|
|
297
|
+
...rest,
|
|
298
|
+
style: [overlayStyle, styleProps, style],
|
|
299
|
+
children
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
BottomSheetOverlay.displayName = "XAUI.BottomSheet.Overlay";
|
|
305
|
+
|
|
306
|
+
// src/components/bottom-sheet/bottom-sheet-title.tsx
|
|
307
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
308
|
+
import { Text as Text2 } from "react-native";
|
|
309
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
310
|
+
var BottomSheetTitle = forwardRef5(function BottomSheetTitle2({
|
|
311
|
+
children,
|
|
312
|
+
accessibilityRole = "header",
|
|
313
|
+
style,
|
|
314
|
+
...props
|
|
315
|
+
}, ref) {
|
|
316
|
+
const {
|
|
317
|
+
titleStyle
|
|
318
|
+
} = useBottomSheet();
|
|
319
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
320
|
+
return /* @__PURE__ */jsx6(Text2, {
|
|
321
|
+
ref,
|
|
322
|
+
accessibilityRole,
|
|
323
|
+
...rest,
|
|
324
|
+
style: [titleStyle, styleProps, style],
|
|
325
|
+
children
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
BottomSheetTitle.displayName = "XAUI.BottomSheet.Title";
|
|
329
|
+
|
|
330
|
+
// src/components/bottom-sheet/bottom-sheet-trigger.tsx
|
|
331
|
+
import { forwardRef as forwardRef6, useCallback as useCallback3 } from "react";
|
|
332
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
333
|
+
var BottomSheetTrigger = forwardRef6(function BottomSheetTrigger2({
|
|
334
|
+
children,
|
|
335
|
+
asChild = false,
|
|
336
|
+
accessibilityRole = "button",
|
|
337
|
+
accessibilityState,
|
|
338
|
+
style,
|
|
339
|
+
onPress,
|
|
340
|
+
onPressIn,
|
|
341
|
+
onPressOut,
|
|
342
|
+
...props
|
|
343
|
+
}, ref) {
|
|
344
|
+
const {
|
|
345
|
+
isOpen,
|
|
346
|
+
isDisabled,
|
|
347
|
+
toggle
|
|
348
|
+
} = useBottomSheet();
|
|
349
|
+
const [styleProps, rest] = useStyleProps(props);
|
|
350
|
+
const [isPressed, press] = usePressState({
|
|
351
|
+
onPressIn,
|
|
352
|
+
onPressOut
|
|
353
|
+
});
|
|
354
|
+
const handlePress = useCallback3(event => {
|
|
355
|
+
onPress?.(event);
|
|
356
|
+
toggle();
|
|
357
|
+
}, [onPress, toggle]);
|
|
358
|
+
return /* @__PURE__ */jsx7(PressableFeedback, {
|
|
359
|
+
ref,
|
|
360
|
+
isPressed,
|
|
361
|
+
isDisabled,
|
|
362
|
+
asChild,
|
|
363
|
+
accessibilityRole,
|
|
364
|
+
accessibilityState: {
|
|
365
|
+
disabled: isDisabled,
|
|
366
|
+
expanded: isOpen,
|
|
367
|
+
...accessibilityState
|
|
368
|
+
},
|
|
369
|
+
...rest,
|
|
370
|
+
style: [styleProps, typeof style === "function" ? style({
|
|
371
|
+
pressed: isPressed
|
|
372
|
+
}) : style],
|
|
373
|
+
onPress: handlePress,
|
|
374
|
+
onPressIn: press.onPressIn,
|
|
375
|
+
onPressOut: press.onPressOut,
|
|
376
|
+
children
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
BottomSheetTrigger.displayName = "XAUI.BottomSheet.Trigger";
|
|
380
|
+
|
|
381
|
+
// src/components/bottom-sheet/bottom-sheet.tsx
|
|
382
|
+
import { useCallback as useCallback4, useMemo } from "react";
|
|
383
|
+
|
|
384
|
+
// src/components/bottom-sheet/bottom-sheet.recipe.ts
|
|
385
|
+
var SLOTS = ["overlay", "content", "handle", "title", "description"];
|
|
386
|
+
var HANDLE = {
|
|
387
|
+
width: 36,
|
|
388
|
+
height: 4
|
|
389
|
+
};
|
|
390
|
+
function topCorners(radius) {
|
|
391
|
+
return theme => ({
|
|
392
|
+
content: {
|
|
393
|
+
borderTopStartRadius: theme.radius[radius],
|
|
394
|
+
borderTopEndRadius: theme.radius[radius]
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
var RADII = ["xs", "sm", "md", "lg", "xl", "2xl", "3xl", "4xl", "field", "full"];
|
|
399
|
+
var bottomSheetRecipe = createRecipe({
|
|
400
|
+
slots: SLOTS,
|
|
401
|
+
base: theme => ({
|
|
402
|
+
overlay: {
|
|
403
|
+
position: "absolute",
|
|
404
|
+
top: 0,
|
|
405
|
+
bottom: 0,
|
|
406
|
+
start: 0,
|
|
407
|
+
end: 0,
|
|
408
|
+
backgroundColor: theme.colors.backdrop
|
|
409
|
+
},
|
|
410
|
+
content: {
|
|
411
|
+
position: "absolute",
|
|
412
|
+
start: 0,
|
|
413
|
+
end: 0,
|
|
414
|
+
bottom: 0,
|
|
415
|
+
backgroundColor: theme.colors.overlay,
|
|
416
|
+
padding: theme.spacing(5),
|
|
417
|
+
gap: theme.spacing(2),
|
|
418
|
+
// HeroUI's `--radius-4xl` on a base of 8 is 32 points; the nearest on our base of 12
|
|
419
|
+
// is `3xl` at 36. A sheet's corner is the largest in the library because it is the
|
|
420
|
+
// only edge of it you can see.
|
|
421
|
+
borderTopStartRadius: theme.radius["3xl"],
|
|
422
|
+
borderTopEndRadius: theme.radius["3xl"],
|
|
423
|
+
borderCurve: "continuous",
|
|
424
|
+
...theme.shadows.overlay
|
|
425
|
+
},
|
|
426
|
+
/**
|
|
427
|
+
* The grab bar. It is the only thing telling a reader the sheet can be dragged — the
|
|
428
|
+
* gesture has no other affordance, and a sheet without one reads as a panel that
|
|
429
|
+
* happens to have arrived from below.
|
|
430
|
+
*/
|
|
431
|
+
handle: {
|
|
432
|
+
alignSelf: "center",
|
|
433
|
+
width: HANDLE.width,
|
|
434
|
+
height: HANDLE.height,
|
|
435
|
+
borderRadius: HANDLE.height / 2,
|
|
436
|
+
backgroundColor: theme.colors.separator
|
|
437
|
+
},
|
|
438
|
+
title: {
|
|
439
|
+
fontFamily: theme.fontFamilies.body,
|
|
440
|
+
fontWeight: theme.fontWeights.medium,
|
|
441
|
+
fontSize: theme.fontSizes.lg,
|
|
442
|
+
lineHeight: theme.lineHeights.lg,
|
|
443
|
+
color: theme.colors.overlayForeground
|
|
444
|
+
},
|
|
445
|
+
description: {
|
|
446
|
+
fontFamily: theme.fontFamilies.body,
|
|
447
|
+
fontSize: theme.fontSizes.md,
|
|
448
|
+
lineHeight: theme.lineHeights.md,
|
|
449
|
+
color: theme.colors.muted
|
|
450
|
+
}
|
|
451
|
+
}),
|
|
452
|
+
/** One variant: a sheet is the theme's floating surface, with no emphasis to report. */
|
|
453
|
+
variantTokens: {
|
|
454
|
+
default: {}
|
|
455
|
+
},
|
|
456
|
+
variants: {
|
|
457
|
+
radius: Object.fromEntries(RADII.map(r => [r, topCorners(r)]))
|
|
458
|
+
},
|
|
459
|
+
defaultVariants: {
|
|
460
|
+
variant: "default"
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
// src/components/bottom-sheet/bottom-sheet.tsx
|
|
465
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
466
|
+
function BottomSheet({
|
|
467
|
+
children,
|
|
468
|
+
radius,
|
|
469
|
+
isOpen: controlledOpen,
|
|
470
|
+
defaultOpen = false,
|
|
471
|
+
onOpenChange,
|
|
472
|
+
isDisabled = false,
|
|
473
|
+
dismissThreshold = 0.35
|
|
474
|
+
}) {
|
|
475
|
+
const theme = useXAUITheme();
|
|
476
|
+
const [isOpen, setOpen] = useControllableState({
|
|
477
|
+
value: controlledOpen,
|
|
478
|
+
defaultValue: defaultOpen,
|
|
479
|
+
onChange: onOpenChange
|
|
480
|
+
});
|
|
481
|
+
const styles = bottomSheetRecipe.resolve({
|
|
482
|
+
theme,
|
|
483
|
+
selection: {
|
|
484
|
+
radius
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
const open = useCallback4(() => setOpen(true), [setOpen]);
|
|
488
|
+
const close = useCallback4(() => setOpen(false), [setOpen]);
|
|
489
|
+
const toggle = useCallback4(() => setOpen(current => !current), [setOpen]);
|
|
490
|
+
const context = useMemo(() => ({
|
|
491
|
+
overlayStyle: styles.overlay,
|
|
492
|
+
contentStyle: styles.content,
|
|
493
|
+
handleStyle: styles.handle,
|
|
494
|
+
titleStyle: styles.title,
|
|
495
|
+
descriptionStyle: styles.description,
|
|
496
|
+
isOpen,
|
|
497
|
+
isDisabled,
|
|
498
|
+
dismissThreshold,
|
|
499
|
+
open,
|
|
500
|
+
close,
|
|
501
|
+
toggle
|
|
502
|
+
}), [styles, isOpen, isDisabled, dismissThreshold, open, close, toggle]);
|
|
503
|
+
return /* @__PURE__ */jsx8(BottomSheetProvider, {
|
|
504
|
+
value: context,
|
|
505
|
+
children
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
BottomSheet.displayName = "XAUI.BottomSheet.Root";
|
|
509
|
+
|
|
510
|
+
// src/components/bottom-sheet/index.ts
|
|
511
|
+
var BottomSheet2 = Object.assign(BottomSheet, {
|
|
512
|
+
Trigger: BottomSheetTrigger,
|
|
513
|
+
Overlay: BottomSheetOverlay,
|
|
514
|
+
Content: BottomSheetContent,
|
|
515
|
+
Handle: BottomSheetHandle,
|
|
516
|
+
Title: BottomSheetTitle,
|
|
517
|
+
Description: BottomSheetDescription,
|
|
518
|
+
Close: BottomSheetClose
|
|
519
|
+
});
|
|
520
|
+
export { useBottomSheet, BottomSheetClose, BottomSheetContent, BottomSheetDescription, BottomSheetHandle, BottomSheetOverlay, BottomSheetTitle, BottomSheetTrigger, bottomSheetRecipe, BottomSheet, BottomSheet2 };
|