@xaui/native 0.0.26 → 0.0.28
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/LICENSE +21 -0
- package/README.md +105 -228
- package/dist/alert/index.cjs +92 -166
- package/dist/alert/index.js +2 -1
- package/dist/app-bar/index.cjs +24 -98
- package/dist/app-bar/index.js +2 -1
- package/dist/autocomplete/index.cjs +192 -281
- package/dist/autocomplete/index.js +36 -48
- package/dist/avatar/index.cjs +59 -133
- package/dist/avatar/index.js +2 -1
- package/dist/badge/index.cjs +26 -99
- package/dist/badge/index.js +2 -1
- package/dist/bottom-sheet/index.cjs +5 -456
- package/dist/bottom-sheet/index.js +4 -363
- package/dist/bottom-tab-bar/index.cjs +93 -167
- package/dist/bottom-tab-bar/index.js +2 -2
- package/dist/button/index.cjs +73 -525
- package/dist/button/index.js +3 -2
- package/dist/card/index.cjs +76 -169
- package/dist/card/index.js +2 -2
- package/dist/carousel/index.cjs +68 -145
- package/dist/carousel/index.js +1 -1
- package/dist/chart/index.cjs +132 -173
- package/dist/checkbox/index.cjs +70 -143
- package/dist/checkbox/index.js +2 -1
- package/dist/chip/index.cjs +89 -164
- package/dist/chip/index.js +2 -1
- package/dist/chunk-BD72HIPR.cjs +75 -0
- package/dist/chunk-DHSTKO3K.cjs +19 -0
- package/dist/{chunk-CZFDZPAS.js → chunk-DXXNBF5P.js} +5 -0
- package/dist/{chunk-UI5L26KD.js → chunk-F7WH4DMG.js} +1 -1
- package/dist/chunk-GBHQCAKW.js +19 -0
- package/dist/chunk-HC2SSHNU.js +368 -0
- package/dist/chunk-HSPTLUFA.cjs +7 -0
- package/dist/chunk-JEGEPGVU.js +287 -0
- package/dist/chunk-KTLGDLCB.cjs +287 -0
- package/dist/{chunk-GHCVNQET.js → chunk-LTKYHG5V.js} +5 -12
- package/dist/{chunk-ULJSCNPE.js → chunk-LUBWRVI2.js} +1 -1
- package/dist/chunk-OQ2BLOOG.cjs +138 -0
- package/dist/chunk-QMYWIWSX.cjs +384 -0
- package/dist/chunk-XFPPR2VB.cjs +368 -0
- package/dist/core/index.cjs +22 -168
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +5 -3
- package/dist/datepicker/index.cjs +239 -320
- package/dist/datepicker/index.js +2 -1
- package/dist/divider/index.cjs +5 -145
- package/dist/divider/index.js +3 -2
- package/dist/drawer/index.cjs +39 -112
- package/dist/drawer/index.js +2 -1
- package/dist/expansion-panel/index.cjs +91 -230
- package/dist/expansion-panel/index.js +3 -2
- package/dist/fab/index.cjs +6 -722
- package/dist/fab/index.js +4 -3
- package/dist/fab-menu/index.cjs +81 -814
- package/dist/fab-menu/index.js +4 -3
- package/dist/feature-discovery/index.cjs +72 -139
- package/dist/feature-discovery/index.js +2 -2
- package/dist/index.cjs +1 -18
- package/dist/indicator/index.cjs +5 -445
- package/dist/indicator/index.js +3 -2
- package/dist/input/index.cjs +214 -282
- package/dist/input/index.js +2 -2
- package/dist/list/index.cjs +71 -146
- package/dist/list/index.js +2 -1
- package/dist/menu/index.cjs +59 -127
- package/dist/menu/index.js +2 -2
- package/dist/menubox/index.cjs +60 -132
- package/dist/menubox/index.js +2 -1
- package/dist/pager/index.cjs +42 -80
- package/dist/progress/index.cjs +43 -114
- package/dist/progress/index.js +2 -1
- package/dist/radio/index.cjs +82 -154
- package/dist/radio/index.js +2 -1
- package/dist/segment-button/index.cjs +60 -147
- package/dist/segment-button/index.js +2 -2
- package/dist/select/index.cjs +149 -224
- package/dist/select/index.js +10 -22
- package/dist/skeleton/index.cjs +23 -94
- package/dist/skeleton/index.js +2 -2
- package/dist/slider/index.cjs +77 -156
- package/dist/slider/index.js +2 -1
- package/dist/snackbar/index.cjs +420 -0
- package/dist/snackbar/index.d.cts +175 -0
- package/dist/snackbar/index.d.ts +175 -0
- package/dist/snackbar/index.js +420 -0
- package/dist/stepper/index.cjs +121 -195
- package/dist/stepper/index.js +2 -1
- package/dist/switch/index.cjs +48 -121
- package/dist/switch/index.js +2 -1
- package/dist/tabs/index.cjs +67 -151
- package/dist/tabs/index.js +2 -1
- package/dist/timepicker/index.cjs +135 -593
- package/dist/timepicker/index.js +24 -383
- package/dist/toolbar/index.cjs +59 -128
- package/dist/toolbar/index.js +2 -1
- package/dist/typography/index.cjs +37 -92
- package/dist/typography/index.d.cts +1 -1
- package/dist/typography/index.d.ts +1 -1
- package/dist/typography/index.js +20 -1
- package/dist/view/index.cjs +178 -223
- package/package.json +7 -1
- package/dist/chunk-3XSXTM3G.js +0 -661
- package/dist/chunk-4KSZLONZ.js +0 -79
- package/dist/chunk-I4V5Y5GD.js +0 -76
- package/dist/chunk-URBEEDFX.js +0 -79
|
@@ -0,0 +1,368 @@
|
|
|
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
|
+
var _chunkOQ2BLOOGcjs = require('./chunk-OQ2BLOOG.cjs');
|
|
5
|
+
|
|
6
|
+
// src/components/bottom-sheet/bottom-sheet.tsx
|
|
7
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
8
|
+
var _reactnative = require('react-native');
|
|
9
|
+
|
|
10
|
+
// src/components/bottom-sheet/bottom-sheet.hook.ts
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _core = require('@xaui/core');
|
|
14
|
+
|
|
15
|
+
// src/components/bottom-sheet/bottom-sheet.animation.ts
|
|
16
|
+
|
|
17
|
+
var SPRING_CONFIG = {
|
|
18
|
+
useNativeDriver: true,
|
|
19
|
+
speed: 14,
|
|
20
|
+
bounciness: 4
|
|
21
|
+
};
|
|
22
|
+
var TIMING_CONFIG = {
|
|
23
|
+
duration: 280,
|
|
24
|
+
easing: _reactnative.Easing.bezier(0.2, 0, 0, 1),
|
|
25
|
+
useNativeDriver: true
|
|
26
|
+
};
|
|
27
|
+
var runOpenAnimation = (translateY, backdropOpacity, targetTranslateY) => {
|
|
28
|
+
const animation = _reactnative.Animated.parallel([
|
|
29
|
+
_reactnative.Animated.spring(translateY, {
|
|
30
|
+
...SPRING_CONFIG,
|
|
31
|
+
toValue: targetTranslateY
|
|
32
|
+
}),
|
|
33
|
+
_reactnative.Animated.timing(backdropOpacity, {
|
|
34
|
+
...TIMING_CONFIG,
|
|
35
|
+
toValue: 1
|
|
36
|
+
})
|
|
37
|
+
]);
|
|
38
|
+
animation.start();
|
|
39
|
+
return animation;
|
|
40
|
+
};
|
|
41
|
+
var runCloseAnimation = (translateY, backdropOpacity, screenHeight, onComplete) => {
|
|
42
|
+
const animation = _reactnative.Animated.parallel([
|
|
43
|
+
_reactnative.Animated.timing(translateY, {
|
|
44
|
+
...TIMING_CONFIG,
|
|
45
|
+
toValue: screenHeight
|
|
46
|
+
}),
|
|
47
|
+
_reactnative.Animated.timing(backdropOpacity, {
|
|
48
|
+
...TIMING_CONFIG,
|
|
49
|
+
toValue: 0
|
|
50
|
+
})
|
|
51
|
+
]);
|
|
52
|
+
animation.start(({ finished }) => {
|
|
53
|
+
if (finished && onComplete) {
|
|
54
|
+
onComplete();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return animation;
|
|
58
|
+
};
|
|
59
|
+
var runSnapAnimation = (translateY, targetTranslateY) => {
|
|
60
|
+
const animation = _reactnative.Animated.spring(translateY, {
|
|
61
|
+
...SPRING_CONFIG,
|
|
62
|
+
toValue: targetTranslateY
|
|
63
|
+
});
|
|
64
|
+
animation.start();
|
|
65
|
+
return animation;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/components/bottom-sheet/bottom-sheet.hook.ts
|
|
69
|
+
var DISMISS_VELOCITY_THRESHOLD = 0.5;
|
|
70
|
+
var DISMISS_DISTANCE_FRACTION = 0.3;
|
|
71
|
+
var SCREEN_HEIGHT = _reactnative.Dimensions.get("window").height;
|
|
72
|
+
var getTranslateYForSnap = (snapFraction) => SCREEN_HEIGHT * (1 - snapFraction);
|
|
73
|
+
var useBottomSheetAnimation = ({
|
|
74
|
+
isOpen,
|
|
75
|
+
snapPoints,
|
|
76
|
+
initialSnapIndex,
|
|
77
|
+
enableSwipeToDismiss,
|
|
78
|
+
disableAnimation,
|
|
79
|
+
onClose,
|
|
80
|
+
onSnapChange
|
|
81
|
+
}) => {
|
|
82
|
+
const [shouldRender, setShouldRender] = _react.useState.call(void 0, false);
|
|
83
|
+
const currentSnapIndex = _react.useRef.call(void 0, initialSnapIndex);
|
|
84
|
+
const animationRef = _react.useRef.call(void 0, null);
|
|
85
|
+
const translateY = _react.useRef.call(void 0, new _reactnative.Animated.Value(SCREEN_HEIGHT)).current;
|
|
86
|
+
const backdropOpacity = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
|
|
87
|
+
const sortedSnapPoints = _react.useMemo.call(void 0,
|
|
88
|
+
() => [...snapPoints].sort((a, b) => a - b),
|
|
89
|
+
[snapPoints]
|
|
90
|
+
);
|
|
91
|
+
const snapTranslateValues = _react.useMemo.call(void 0,
|
|
92
|
+
() => sortedSnapPoints.map(getTranslateYForSnap),
|
|
93
|
+
[sortedSnapPoints]
|
|
94
|
+
);
|
|
95
|
+
const open = _react.useCallback.call(void 0, () => {
|
|
96
|
+
setShouldRender(true);
|
|
97
|
+
const targetIndex = Math.min(initialSnapIndex, sortedSnapPoints.length - 1);
|
|
98
|
+
currentSnapIndex.current = targetIndex;
|
|
99
|
+
if (disableAnimation) {
|
|
100
|
+
translateY.setValue(snapTranslateValues[targetIndex]);
|
|
101
|
+
backdropOpacity.setValue(1);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
translateY.setValue(SCREEN_HEIGHT);
|
|
105
|
+
backdropOpacity.setValue(0);
|
|
106
|
+
_optionalChain([animationRef, 'access', _2 => _2.current, 'optionalAccess', _3 => _3.stop, 'call', _4 => _4()]);
|
|
107
|
+
animationRef.current = runOpenAnimation(
|
|
108
|
+
translateY,
|
|
109
|
+
backdropOpacity,
|
|
110
|
+
snapTranslateValues[targetIndex]
|
|
111
|
+
);
|
|
112
|
+
}, [
|
|
113
|
+
initialSnapIndex,
|
|
114
|
+
sortedSnapPoints,
|
|
115
|
+
snapTranslateValues,
|
|
116
|
+
disableAnimation,
|
|
117
|
+
translateY,
|
|
118
|
+
backdropOpacity
|
|
119
|
+
]);
|
|
120
|
+
const close = _react.useCallback.call(void 0, () => {
|
|
121
|
+
if (disableAnimation) {
|
|
122
|
+
translateY.setValue(SCREEN_HEIGHT);
|
|
123
|
+
backdropOpacity.setValue(0);
|
|
124
|
+
setShouldRender(false);
|
|
125
|
+
_optionalChain([onClose, 'optionalCall', _5 => _5()]);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
_optionalChain([animationRef, 'access', _6 => _6.current, 'optionalAccess', _7 => _7.stop, 'call', _8 => _8()]);
|
|
129
|
+
animationRef.current = runCloseAnimation(
|
|
130
|
+
translateY,
|
|
131
|
+
backdropOpacity,
|
|
132
|
+
SCREEN_HEIGHT,
|
|
133
|
+
() => {
|
|
134
|
+
setShouldRender(false);
|
|
135
|
+
_optionalChain([onClose, 'optionalCall', _9 => _9()]);
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}, [disableAnimation, translateY, backdropOpacity, onClose]);
|
|
139
|
+
const snapTo = _react.useCallback.call(void 0,
|
|
140
|
+
(index) => {
|
|
141
|
+
const clampedIndex = Math.max(0, Math.min(index, sortedSnapPoints.length - 1));
|
|
142
|
+
currentSnapIndex.current = clampedIndex;
|
|
143
|
+
_optionalChain([onSnapChange, 'optionalCall', _10 => _10(clampedIndex)]);
|
|
144
|
+
if (disableAnimation) {
|
|
145
|
+
translateY.setValue(snapTranslateValues[clampedIndex]);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
_optionalChain([animationRef, 'access', _11 => _11.current, 'optionalAccess', _12 => _12.stop, 'call', _13 => _13()]);
|
|
149
|
+
animationRef.current = runSnapAnimation(
|
|
150
|
+
translateY,
|
|
151
|
+
snapTranslateValues[clampedIndex]
|
|
152
|
+
);
|
|
153
|
+
},
|
|
154
|
+
[
|
|
155
|
+
sortedSnapPoints,
|
|
156
|
+
snapTranslateValues,
|
|
157
|
+
disableAnimation,
|
|
158
|
+
translateY,
|
|
159
|
+
onSnapChange
|
|
160
|
+
]
|
|
161
|
+
);
|
|
162
|
+
_react.useEffect.call(void 0, () => {
|
|
163
|
+
if (isOpen) {
|
|
164
|
+
open();
|
|
165
|
+
} else if (shouldRender) {
|
|
166
|
+
close();
|
|
167
|
+
}
|
|
168
|
+
}, [isOpen]);
|
|
169
|
+
const panResponder = _react.useMemo.call(void 0,
|
|
170
|
+
() => _reactnative.PanResponder.create({
|
|
171
|
+
onStartShouldSetPanResponder: () => true,
|
|
172
|
+
onMoveShouldSetPanResponder: (_, gestureState) => Math.abs(gestureState.dy) > 5,
|
|
173
|
+
onPanResponderMove: (_, gestureState) => {
|
|
174
|
+
const currentTranslate = snapTranslateValues[currentSnapIndex.current];
|
|
175
|
+
const newTranslateY = currentTranslate + gestureState.dy;
|
|
176
|
+
const maxExpanded = snapTranslateValues[snapTranslateValues.length - 1];
|
|
177
|
+
const clamped = Math.max(maxExpanded, newTranslateY);
|
|
178
|
+
translateY.setValue(clamped);
|
|
179
|
+
},
|
|
180
|
+
onPanResponderRelease: (_, gestureState) => {
|
|
181
|
+
const currentTranslate = snapTranslateValues[currentSnapIndex.current];
|
|
182
|
+
const finalPosition = currentTranslate + gestureState.dy;
|
|
183
|
+
if (enableSwipeToDismiss && (gestureState.vy > DISMISS_VELOCITY_THRESHOLD || finalPosition > SCREEN_HEIGHT * (1 - sortedSnapPoints[0] * DISMISS_DISTANCE_FRACTION))) {
|
|
184
|
+
close();
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (gestureState.vy < -DISMISS_VELOCITY_THRESHOLD) {
|
|
188
|
+
const nextIndex = Math.min(
|
|
189
|
+
currentSnapIndex.current + 1,
|
|
190
|
+
sortedSnapPoints.length - 1
|
|
191
|
+
);
|
|
192
|
+
snapTo(nextIndex);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (gestureState.vy > DISMISS_VELOCITY_THRESHOLD) {
|
|
196
|
+
const prevIndex = Math.max(currentSnapIndex.current - 1, 0);
|
|
197
|
+
if (prevIndex === currentSnapIndex.current && enableSwipeToDismiss) {
|
|
198
|
+
close();
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
snapTo(prevIndex);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
let closestIndex = 0;
|
|
205
|
+
let minDistance = Infinity;
|
|
206
|
+
snapTranslateValues.forEach((snapVal, index) => {
|
|
207
|
+
const distance = Math.abs(finalPosition - snapVal);
|
|
208
|
+
if (distance < minDistance) {
|
|
209
|
+
minDistance = distance;
|
|
210
|
+
closestIndex = index;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
snapTo(closestIndex);
|
|
214
|
+
}
|
|
215
|
+
}),
|
|
216
|
+
[
|
|
217
|
+
snapTranslateValues,
|
|
218
|
+
sortedSnapPoints,
|
|
219
|
+
enableSwipeToDismiss,
|
|
220
|
+
translateY,
|
|
221
|
+
close,
|
|
222
|
+
snapTo
|
|
223
|
+
]
|
|
224
|
+
);
|
|
225
|
+
return {
|
|
226
|
+
shouldRender,
|
|
227
|
+
translateY,
|
|
228
|
+
backdropOpacity,
|
|
229
|
+
panResponder,
|
|
230
|
+
close,
|
|
231
|
+
snapTo,
|
|
232
|
+
screenHeight: SCREEN_HEIGHT
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
var useBottomSheetStyles = (themeColor, radius) => {
|
|
236
|
+
const theme = _chunkOQ2BLOOGcjs.useXUITheme.call(void 0, );
|
|
237
|
+
const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
|
|
238
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
239
|
+
const sheetStyles = _react.useMemo.call(void 0,
|
|
240
|
+
() => ({
|
|
241
|
+
backgroundColor: _nullishCoalesce(_nullishCoalesce(colorScheme.background, () => ( theme.colors.background)), () => ( "#ffffff")),
|
|
242
|
+
borderTopLeftRadius: theme.borderRadius[radius],
|
|
243
|
+
borderTopRightRadius: theme.borderRadius[radius]
|
|
244
|
+
}),
|
|
245
|
+
[theme, colorScheme, radius]
|
|
246
|
+
);
|
|
247
|
+
const handleIndicatorColor = _react.useMemo.call(void 0,
|
|
248
|
+
() => theme.mode === "dark" ? `${colorScheme.main}60` : `${colorScheme.main}40`,
|
|
249
|
+
[theme, colorScheme]
|
|
250
|
+
);
|
|
251
|
+
return { sheetStyles, handleIndicatorColor };
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// src/components/bottom-sheet/bottom-sheet.style.ts
|
|
255
|
+
|
|
256
|
+
var styles = _reactnative.StyleSheet.create({
|
|
257
|
+
backdrop: {
|
|
258
|
+
position: "absolute",
|
|
259
|
+
top: 0,
|
|
260
|
+
left: 0,
|
|
261
|
+
right: 0,
|
|
262
|
+
bottom: 0,
|
|
263
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
264
|
+
},
|
|
265
|
+
container: {
|
|
266
|
+
position: "absolute",
|
|
267
|
+
left: 0,
|
|
268
|
+
right: 0,
|
|
269
|
+
bottom: 0
|
|
270
|
+
},
|
|
271
|
+
sheet: {
|
|
272
|
+
overflow: "hidden"
|
|
273
|
+
},
|
|
274
|
+
handle: {
|
|
275
|
+
alignItems: "center",
|
|
276
|
+
justifyContent: "center",
|
|
277
|
+
paddingVertical: 10
|
|
278
|
+
},
|
|
279
|
+
handleIndicator: {
|
|
280
|
+
width: 36,
|
|
281
|
+
height: 4,
|
|
282
|
+
borderRadius: 2
|
|
283
|
+
},
|
|
284
|
+
content: {
|
|
285
|
+
flex: 1
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// src/components/bottom-sheet/bottom-sheet.tsx
|
|
290
|
+
var BottomSheet = ({
|
|
291
|
+
children,
|
|
292
|
+
isOpen,
|
|
293
|
+
snapPoints = [0.4, 0.9],
|
|
294
|
+
initialSnapIndex = 0,
|
|
295
|
+
themeColor = "default",
|
|
296
|
+
radius = "lg",
|
|
297
|
+
showBackdrop = true,
|
|
298
|
+
closeOnBackdropPress = true,
|
|
299
|
+
enableSwipeToDismiss = true,
|
|
300
|
+
showHandle = true,
|
|
301
|
+
disableAnimation = false,
|
|
302
|
+
style,
|
|
303
|
+
handleContent,
|
|
304
|
+
onClose,
|
|
305
|
+
onSnapChange
|
|
306
|
+
}) => {
|
|
307
|
+
const {
|
|
308
|
+
shouldRender,
|
|
309
|
+
translateY,
|
|
310
|
+
backdropOpacity,
|
|
311
|
+
panResponder,
|
|
312
|
+
close,
|
|
313
|
+
screenHeight
|
|
314
|
+
} = useBottomSheetAnimation({
|
|
315
|
+
isOpen,
|
|
316
|
+
snapPoints,
|
|
317
|
+
initialSnapIndex,
|
|
318
|
+
enableSwipeToDismiss,
|
|
319
|
+
disableAnimation,
|
|
320
|
+
onClose,
|
|
321
|
+
onSnapChange
|
|
322
|
+
});
|
|
323
|
+
const { sheetStyles, handleIndicatorColor } = useBottomSheetStyles(
|
|
324
|
+
themeColor,
|
|
325
|
+
radius
|
|
326
|
+
);
|
|
327
|
+
if (!shouldRender) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
const handleBackdropPress = () => {
|
|
331
|
+
if (closeOnBackdropPress) {
|
|
332
|
+
close();
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
return /* @__PURE__ */ _react2.default.createElement(_chunkOQ2BLOOGcjs.Portal, null, showBackdrop && /* @__PURE__ */ _react2.default.createElement(_reactnative.Animated.View, { style: [styles.backdrop, { opacity: backdropOpacity }] }, /* @__PURE__ */ _react2.default.createElement(_reactnative.Pressable, { style: styles.backdrop, onPress: handleBackdropPress })), /* @__PURE__ */ _react2.default.createElement(
|
|
336
|
+
_reactnative.Animated.View,
|
|
337
|
+
{
|
|
338
|
+
style: [
|
|
339
|
+
styles.container,
|
|
340
|
+
{
|
|
341
|
+
height: screenHeight,
|
|
342
|
+
transform: [{ translateY }]
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
},
|
|
346
|
+
/* @__PURE__ */ _react2.default.createElement(
|
|
347
|
+
_reactnative.View,
|
|
348
|
+
{
|
|
349
|
+
style: [styles.sheet, { height: screenHeight }, sheetStyles, style],
|
|
350
|
+
...panResponder.panHandlers
|
|
351
|
+
},
|
|
352
|
+
showHandle && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.handle }, _nullishCoalesce(handleContent, () => ( /* @__PURE__ */ _react2.default.createElement(
|
|
353
|
+
_reactnative.View,
|
|
354
|
+
{
|
|
355
|
+
style: [
|
|
356
|
+
styles.handleIndicator,
|
|
357
|
+
{ backgroundColor: handleIndicatorColor }
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
)))),
|
|
361
|
+
/* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.content }, children)
|
|
362
|
+
)
|
|
363
|
+
));
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
exports.BottomSheet = BottomSheet;
|
package/dist/core/index.cjs
CHANGED
|
@@ -1,168 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/core/index.ts
|
|
31
|
-
var core_exports = {};
|
|
32
|
-
__export(core_exports, {
|
|
33
|
-
Portal: () => Portal,
|
|
34
|
-
PortalHost: () => PortalHost,
|
|
35
|
-
XUIProvider: () => XUIProvider,
|
|
36
|
-
defaultDarkTheme: () => import_theme2.defaultDarkTheme,
|
|
37
|
-
defaultTheme: () => import_theme2.defaultTheme,
|
|
38
|
-
useColorMode: () => useColorMode,
|
|
39
|
-
useXUIColors: () => useXUIColors,
|
|
40
|
-
useXUITheme: () => useXUITheme
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(core_exports);
|
|
43
|
-
|
|
44
|
-
// src/core/theme-context.tsx
|
|
45
|
-
var import_react4 = __toESM(require("react"), 1);
|
|
46
|
-
var import_react_native2 = require("react-native");
|
|
47
|
-
var import_theme = require("@xaui/core/theme");
|
|
48
|
-
var import_palette = require("@xaui/core/palette");
|
|
49
|
-
|
|
50
|
-
// src/core/portal/portal.tsx
|
|
51
|
-
var import_react2 = require("react");
|
|
52
|
-
|
|
53
|
-
// src/core/portal/portal-context.ts
|
|
54
|
-
var import_react = require("react");
|
|
55
|
-
var PortalContext = (0, import_react.createContext)(null);
|
|
56
|
-
|
|
57
|
-
// src/core/portal/portal.tsx
|
|
58
|
-
var portalId = 0;
|
|
59
|
-
var Portal = ({ children }) => {
|
|
60
|
-
const context = (0, import_react2.useContext)(PortalContext);
|
|
61
|
-
const keyRef = (0, import_react2.useRef)(`portal-${++portalId}`);
|
|
62
|
-
(0, import_react2.useLayoutEffect)(() => {
|
|
63
|
-
if (!context) return;
|
|
64
|
-
context.addPortal(keyRef.current, children);
|
|
65
|
-
}, [children, context]);
|
|
66
|
-
(0, import_react2.useEffect)(() => {
|
|
67
|
-
if (!context) return;
|
|
68
|
-
const key = keyRef.current;
|
|
69
|
-
return () => {
|
|
70
|
-
context.removePortal(key);
|
|
71
|
-
};
|
|
72
|
-
}, [context]);
|
|
73
|
-
return null;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// src/core/portal/portal-host.tsx
|
|
77
|
-
var import_react3 = __toESM(require("react"), 1);
|
|
78
|
-
var import_react_native = require("react-native");
|
|
79
|
-
var hostStyles = import_react_native.StyleSheet.create({
|
|
80
|
-
container: {
|
|
81
|
-
flex: 1
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
var PortalHost = ({ children }) => {
|
|
85
|
-
const portals = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
86
|
-
const [, forceUpdate] = (0, import_react3.useState)(0);
|
|
87
|
-
const addPortal = (0, import_react3.useCallback)((key, element) => {
|
|
88
|
-
portals.current.set(key, element);
|
|
89
|
-
forceUpdate((n) => n + 1);
|
|
90
|
-
}, []);
|
|
91
|
-
const removePortal = (0, import_react3.useCallback)((key) => {
|
|
92
|
-
portals.current.delete(key);
|
|
93
|
-
forceUpdate((n) => n + 1);
|
|
94
|
-
}, []);
|
|
95
|
-
const contextValue = (0, import_react3.useMemo)(
|
|
96
|
-
() => ({ addPortal, removePortal }),
|
|
97
|
-
[addPortal, removePortal]
|
|
98
|
-
);
|
|
99
|
-
return /* @__PURE__ */ import_react3.default.createElement(PortalContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react3.default.createElement(import_react_native.View, { style: hostStyles.container }, children, Array.from(portals.current.entries()).map(([key, element]) => /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, { key }, element))));
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// src/core/theme-context.tsx
|
|
103
|
-
var XUIThemeContext = (0, import_react4.createContext)(null);
|
|
104
|
-
function XUIProvider({
|
|
105
|
-
children,
|
|
106
|
-
theme: lightTheme,
|
|
107
|
-
darkTheme
|
|
108
|
-
}) {
|
|
109
|
-
const colorScheme = (0, import_react_native2.useColorScheme)() ?? "light";
|
|
110
|
-
const theme = import_react4.default.useMemo(() => {
|
|
111
|
-
if (!darkTheme && !lightTheme) return import_theme.defaultTheme;
|
|
112
|
-
const activeTheme = colorScheme === "dark" && darkTheme ? darkTheme : lightTheme;
|
|
113
|
-
const mode = colorScheme === "dark" && darkTheme ? "dark" : "light";
|
|
114
|
-
if (!activeTheme) return import_theme.defaultTheme;
|
|
115
|
-
return {
|
|
116
|
-
...import_theme.defaultTheme,
|
|
117
|
-
...activeTheme,
|
|
118
|
-
mode,
|
|
119
|
-
colors: {
|
|
120
|
-
...import_theme.defaultTheme.colors,
|
|
121
|
-
...activeTheme.colors
|
|
122
|
-
},
|
|
123
|
-
fontFamilies: {
|
|
124
|
-
...import_theme.defaultTheme.fontFamilies,
|
|
125
|
-
...activeTheme.fontFamilies
|
|
126
|
-
},
|
|
127
|
-
fontSizes: {
|
|
128
|
-
...import_theme.defaultTheme.fontSizes,
|
|
129
|
-
...activeTheme.fontSizes
|
|
130
|
-
},
|
|
131
|
-
palette: import_palette.colors
|
|
132
|
-
};
|
|
133
|
-
}, [lightTheme, darkTheme, colorScheme]);
|
|
134
|
-
return /* @__PURE__ */ import_react4.default.createElement(XUIThemeContext.Provider, { value: theme }, /* @__PURE__ */ import_react4.default.createElement(PortalHost, null, children));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// src/core/theme-hooks.ts
|
|
138
|
-
var import_react5 = require("react");
|
|
139
|
-
var import_react_native3 = require("react-native");
|
|
140
|
-
function useColorMode() {
|
|
141
|
-
const nativeScheme = (0, import_react_native3.useColorScheme)();
|
|
142
|
-
return nativeScheme ?? "light";
|
|
143
|
-
}
|
|
144
|
-
function useXUITheme() {
|
|
145
|
-
const theme = (0, import_react5.useContext)(XUIThemeContext);
|
|
146
|
-
if (!theme) {
|
|
147
|
-
throw new Error("useXUITheme must be used within XUIProvider");
|
|
148
|
-
}
|
|
149
|
-
return theme;
|
|
150
|
-
}
|
|
151
|
-
function useXUIColors() {
|
|
152
|
-
const theme = useXUITheme();
|
|
153
|
-
return theme.colors;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// src/core/index.ts
|
|
157
|
-
var import_theme2 = require("@xaui/core/theme");
|
|
158
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
-
0 && (module.exports = {
|
|
160
|
-
Portal,
|
|
161
|
-
PortalHost,
|
|
162
|
-
XUIProvider,
|
|
163
|
-
defaultDarkTheme,
|
|
164
|
-
defaultTheme,
|
|
165
|
-
useColorMode,
|
|
166
|
-
useXUIColors,
|
|
167
|
-
useXUITheme
|
|
168
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkHSPTLUFAcjs = require('../chunk-HSPTLUFA.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkOQ2BLOOGcjs = require('../chunk-OQ2BLOOG.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
exports.Portal = _chunkOQ2BLOOGcjs.Portal; exports.PortalHost = _chunkOQ2BLOOGcjs.PortalHost; exports.XUIProvider = _chunkOQ2BLOOGcjs.XUIProvider; exports.defaultDarkTheme = _chunkHSPTLUFAcjs.defaultDarkTheme; exports.defaultTheme = _chunkHSPTLUFAcjs.defaultTheme; exports.useColorMode = _chunkOQ2BLOOGcjs.useColorMode; exports.useXUIColors = _chunkOQ2BLOOGcjs.useXUIColors; exports.useXUITheme = _chunkOQ2BLOOGcjs.useXUITheme;
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { XUITheme } from '@xaui/core/theme';
|
|
3
|
-
export { defaultDarkTheme, defaultTheme } from '@xaui/core/theme';
|
|
3
|
+
export { PartialXUITheme as XUITheme, defaultDarkTheme, defaultTheme } from '@xaui/core/theme';
|
|
4
4
|
|
|
5
5
|
type DeepPartial<T> = {
|
|
6
6
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { XUITheme } from '@xaui/core/theme';
|
|
3
|
-
export { defaultDarkTheme, defaultTheme } from '@xaui/core/theme';
|
|
3
|
+
export { PartialXUITheme as XUITheme, defaultDarkTheme, defaultTheme } from '@xaui/core/theme';
|
|
4
4
|
|
|
5
5
|
type DeepPartial<T> = {
|
|
6
6
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
package/dist/core/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultDarkTheme,
|
|
3
|
+
defaultTheme
|
|
4
|
+
} from "../chunk-DXXNBF5P.js";
|
|
1
5
|
import {
|
|
2
6
|
Portal,
|
|
3
7
|
PortalHost,
|
|
4
8
|
XUIProvider,
|
|
5
|
-
defaultDarkTheme,
|
|
6
|
-
defaultTheme,
|
|
7
9
|
useColorMode,
|
|
8
10
|
useXUIColors,
|
|
9
11
|
useXUITheme
|
|
10
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-LTKYHG5V.js";
|
|
11
13
|
export {
|
|
12
14
|
Portal,
|
|
13
15
|
PortalHost,
|