@xaui/native 0.0.21 → 0.0.24
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/README.md +195 -2
- package/dist/alert/index.js +1 -2
- package/dist/app-bar/index.cjs +217 -0
- package/dist/app-bar/index.d.cts +52 -0
- package/dist/app-bar/index.d.ts +52 -0
- package/dist/app-bar/index.js +142 -0
- package/dist/autocomplete/index.js +48 -36
- package/dist/avatar/index.js +1 -2
- package/dist/badge/index.js +1 -2
- package/dist/bottom-sheet/index.js +1 -2
- package/dist/bottom-tab-bar/index.cjs +571 -0
- package/dist/bottom-tab-bar/index.d.cts +211 -0
- package/dist/bottom-tab-bar/index.d.ts +211 -0
- package/dist/bottom-tab-bar/index.js +497 -0
- package/dist/button/index.d.cts +102 -5
- package/dist/button/index.d.ts +102 -5
- package/dist/button/index.js +2 -3
- package/dist/button.type-j1ZdkkSl.d.cts +4 -0
- package/dist/button.type-j1ZdkkSl.d.ts +4 -0
- package/dist/card/index.cjs +2 -0
- package/dist/card/index.d.cts +6 -1
- package/dist/card/index.d.ts +6 -1
- package/dist/card/index.js +4 -2
- package/dist/carousel/index.js +1 -1
- package/dist/chart/index.cjs +1067 -0
- package/dist/chart/index.d.cts +218 -0
- package/dist/chart/index.d.ts +218 -0
- package/dist/chart/index.js +1026 -0
- package/dist/checkbox/index.js +1 -2
- package/dist/chip/index.js +1 -2
- package/dist/chunk-3XSXTM3G.js +661 -0
- package/dist/chunk-4KSZLONZ.js +79 -0
- package/dist/{chunk-DXXNBF5P.js → chunk-CZFDZPAS.js} +0 -5
- package/dist/{chunk-LTKYHG5V.js → chunk-GHCVNQET.js} +12 -5
- package/dist/chunk-I4V5Y5GD.js +76 -0
- package/dist/{chunk-F7WH4DMG.js → chunk-UI5L26KD.js} +1 -1
- package/dist/{chunk-LUBWRVI2.js → chunk-ULJSCNPE.js} +1 -1
- package/dist/chunk-URBEEDFX.js +79 -0
- package/dist/core/index.js +3 -5
- package/dist/datepicker/index.js +1 -2
- package/dist/divider/index.js +2 -3
- package/dist/drawer/index.cjs +310 -0
- package/dist/drawer/index.d.cts +58 -0
- package/dist/drawer/index.d.ts +58 -0
- package/dist/drawer/index.js +236 -0
- package/dist/{accordion → expansion-panel}/index.cjs +45 -45
- package/dist/{accordion → expansion-panel}/index.d.cts +30 -30
- package/dist/{accordion → expansion-panel}/index.d.ts +30 -30
- package/dist/{accordion → expansion-panel}/index.js +40 -41
- package/dist/fab/index.d.cts +3 -3
- package/dist/fab/index.d.ts +3 -3
- package/dist/fab/index.js +3 -4
- package/dist/fab-menu/index.d.cts +2 -2
- package/dist/fab-menu/index.d.ts +2 -2
- package/dist/fab-menu/index.js +3 -4
- package/dist/{fab.type-Ba0QMprb.d.ts → fab.type-CgIYqQlT.d.ts} +1 -1
- package/dist/{fab.type-U09H8B7D.d.cts → fab.type-l2vjG8-p.d.cts} +1 -1
- package/dist/feature-discovery/index.cjs +531 -0
- package/dist/feature-discovery/index.d.cts +82 -0
- package/dist/feature-discovery/index.d.ts +82 -0
- package/dist/feature-discovery/index.js +464 -0
- package/dist/indicator/index.js +2 -3
- package/dist/input/index.cjs +258 -164
- package/dist/input/index.d.cts +15 -1
- package/dist/input/index.d.ts +15 -1
- package/dist/input/index.js +219 -126
- package/dist/list/index.js +1 -2
- package/dist/menu/index.js +2 -2
- package/dist/menubox/index.cjs +369 -0
- package/dist/menubox/index.d.cts +98 -0
- package/dist/menubox/index.d.ts +98 -0
- package/dist/menubox/index.js +296 -0
- package/dist/pager/index.cjs +243 -0
- package/dist/pager/index.d.cts +93 -0
- package/dist/pager/index.d.ts +93 -0
- package/dist/pager/index.js +205 -0
- package/dist/progress/index.js +1 -2
- package/dist/radio/index.cjs +537 -0
- package/dist/radio/index.d.cts +145 -0
- package/dist/radio/index.d.ts +145 -0
- package/dist/radio/index.js +464 -0
- package/dist/segment-button/index.js +2 -2
- package/dist/select/index.js +22 -10
- package/dist/skeleton/index.js +2 -2
- package/dist/slider/index.cjs +655 -0
- package/dist/slider/index.d.cts +171 -0
- package/dist/slider/index.d.ts +171 -0
- package/dist/slider/index.js +575 -0
- package/dist/stepper/index.cjs +624 -0
- package/dist/stepper/index.d.cts +137 -0
- package/dist/stepper/index.d.ts +137 -0
- package/dist/stepper/index.js +549 -0
- package/dist/switch/index.js +1 -2
- package/dist/tabs/index.cjs +523 -0
- package/dist/tabs/index.d.cts +176 -0
- package/dist/tabs/index.d.ts +176 -0
- package/dist/tabs/index.js +438 -0
- package/dist/timepicker/index.cjs +1280 -0
- package/dist/timepicker/index.d.cts +215 -0
- package/dist/timepicker/index.d.ts +215 -0
- package/dist/timepicker/index.js +1181 -0
- package/dist/toolbar/index.cjs +395 -0
- package/dist/toolbar/index.d.cts +100 -0
- package/dist/toolbar/index.d.ts +100 -0
- package/dist/toolbar/index.js +325 -0
- package/dist/typography/index.js +1 -2
- package/dist/view/index.cjs +16 -2
- package/dist/view/index.js +16 -2
- package/package.json +73 -8
- package/dist/button.type-D8tzEBo7.d.ts +0 -104
- package/dist/button.type-ikaWzhIg.d.cts +0 -104
- package/dist/chunk-GBHQCAKW.js +0 -19
- package/dist/chunk-JEGEPGVU.js +0 -287
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
import { T as ThemeColor } from '../index-BOw6tbkc.cjs';
|
|
4
|
+
|
|
5
|
+
type DrawerPosition = 'top' | 'left' | 'bottom' | 'right';
|
|
6
|
+
type DrawerProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Content to render inside the drawer.
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the drawer is visible.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Position of the drawer.
|
|
18
|
+
* @default 'left'
|
|
19
|
+
*/
|
|
20
|
+
position?: DrawerPosition;
|
|
21
|
+
/**
|
|
22
|
+
* The theme color of the drawer.
|
|
23
|
+
* @default 'default'
|
|
24
|
+
*/
|
|
25
|
+
themeColor?: ThemeColor;
|
|
26
|
+
/**
|
|
27
|
+
* Width of the drawer (for left/right position).
|
|
28
|
+
* @default 280
|
|
29
|
+
*/
|
|
30
|
+
width?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Height of the drawer (for top/bottom position).
|
|
33
|
+
* @default 280
|
|
34
|
+
*/
|
|
35
|
+
height?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to show overlay backdrop.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
showOverlay?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Callback fired when drawer should close (overlay tap or back button).
|
|
43
|
+
*/
|
|
44
|
+
onClose?: () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Custom styles for the drawer container.
|
|
47
|
+
*/
|
|
48
|
+
customStyle?: ViewStyle;
|
|
49
|
+
/**
|
|
50
|
+
* Disable slide animation.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
disableAnimation?: boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
declare const Drawer: React.FC<DrawerProps>;
|
|
57
|
+
|
|
58
|
+
export { Drawer, type DrawerPosition, type DrawerProps };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
|
+
import { T as ThemeColor } from '../index-BOw6tbkc.js';
|
|
4
|
+
|
|
5
|
+
type DrawerPosition = 'top' | 'left' | 'bottom' | 'right';
|
|
6
|
+
type DrawerProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Content to render inside the drawer.
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the drawer is visible.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Position of the drawer.
|
|
18
|
+
* @default 'left'
|
|
19
|
+
*/
|
|
20
|
+
position?: DrawerPosition;
|
|
21
|
+
/**
|
|
22
|
+
* The theme color of the drawer.
|
|
23
|
+
* @default 'default'
|
|
24
|
+
*/
|
|
25
|
+
themeColor?: ThemeColor;
|
|
26
|
+
/**
|
|
27
|
+
* Width of the drawer (for left/right position).
|
|
28
|
+
* @default 280
|
|
29
|
+
*/
|
|
30
|
+
width?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Height of the drawer (for top/bottom position).
|
|
33
|
+
* @default 280
|
|
34
|
+
*/
|
|
35
|
+
height?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to show overlay backdrop.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
showOverlay?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Callback fired when drawer should close (overlay tap or back button).
|
|
43
|
+
*/
|
|
44
|
+
onClose?: () => void;
|
|
45
|
+
/**
|
|
46
|
+
* Custom styles for the drawer container.
|
|
47
|
+
*/
|
|
48
|
+
customStyle?: ViewStyle;
|
|
49
|
+
/**
|
|
50
|
+
* Disable slide animation.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
disableAnimation?: boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
declare const Drawer: React.FC<DrawerProps>;
|
|
57
|
+
|
|
58
|
+
export { Drawer, type DrawerPosition, type DrawerProps };
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useXUITheme
|
|
3
|
+
} from "../chunk-URBEEDFX.js";
|
|
4
|
+
|
|
5
|
+
// src/components/drawer/drawer.tsx
|
|
6
|
+
import React, { useEffect, useMemo as useMemo2, useRef, useState } from "react";
|
|
7
|
+
import { Animated, Easing, Modal, Pressable, View } from "react-native";
|
|
8
|
+
|
|
9
|
+
// src/components/drawer/drawer.hook.ts
|
|
10
|
+
import { useMemo } from "react";
|
|
11
|
+
import { getSafeThemeColor } from "@xaui/core";
|
|
12
|
+
var useDrawerStyles = (themeColor, position, width, height) => {
|
|
13
|
+
const theme = useXUITheme();
|
|
14
|
+
return useMemo(() => {
|
|
15
|
+
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
16
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
17
|
+
const isDefaultThemeColor = safeThemeColor === "default";
|
|
18
|
+
const defaultBackgroundColor = theme.mode === "dark" ? theme.colors.default.background : "#FFFFFF";
|
|
19
|
+
const backgroundColor = isDefaultThemeColor ? defaultBackgroundColor : colorScheme.background;
|
|
20
|
+
const sizeStyle = position === "left" || position === "right" ? { width } : { height };
|
|
21
|
+
return {
|
|
22
|
+
backgroundColor,
|
|
23
|
+
...sizeStyle
|
|
24
|
+
};
|
|
25
|
+
}, [height, position, theme, themeColor, width]);
|
|
26
|
+
};
|
|
27
|
+
var getTranslateValue = (position, size) => {
|
|
28
|
+
switch (position) {
|
|
29
|
+
case "left":
|
|
30
|
+
return { x: -size, y: 0 };
|
|
31
|
+
case "right":
|
|
32
|
+
return { x: size, y: 0 };
|
|
33
|
+
case "top":
|
|
34
|
+
return { x: 0, y: -size };
|
|
35
|
+
case "bottom":
|
|
36
|
+
return { x: 0, y: size };
|
|
37
|
+
default:
|
|
38
|
+
return { x: -size, y: 0 };
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/components/drawer/drawer.style.ts
|
|
43
|
+
import { StyleSheet } from "react-native";
|
|
44
|
+
var styles = StyleSheet.create({
|
|
45
|
+
overlay: {
|
|
46
|
+
position: "absolute",
|
|
47
|
+
top: 0,
|
|
48
|
+
left: 0,
|
|
49
|
+
right: 0,
|
|
50
|
+
bottom: 0,
|
|
51
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)"
|
|
52
|
+
},
|
|
53
|
+
drawerContainer: {
|
|
54
|
+
position: "absolute",
|
|
55
|
+
backgroundColor: "#ffffff"
|
|
56
|
+
},
|
|
57
|
+
drawerLeft: {
|
|
58
|
+
top: 0,
|
|
59
|
+
left: 0,
|
|
60
|
+
bottom: 0
|
|
61
|
+
},
|
|
62
|
+
drawerRight: {
|
|
63
|
+
top: 0,
|
|
64
|
+
right: 0,
|
|
65
|
+
bottom: 0
|
|
66
|
+
},
|
|
67
|
+
drawerTop: {
|
|
68
|
+
top: 0,
|
|
69
|
+
left: 0,
|
|
70
|
+
right: 0
|
|
71
|
+
},
|
|
72
|
+
drawerBottom: {
|
|
73
|
+
bottom: 0,
|
|
74
|
+
left: 0,
|
|
75
|
+
right: 0
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// src/components/drawer/drawer.tsx
|
|
80
|
+
var Drawer = ({
|
|
81
|
+
children,
|
|
82
|
+
isOpen,
|
|
83
|
+
position = "left",
|
|
84
|
+
themeColor = "default",
|
|
85
|
+
width = 280,
|
|
86
|
+
height = 280,
|
|
87
|
+
showOverlay = true,
|
|
88
|
+
onClose,
|
|
89
|
+
customStyle,
|
|
90
|
+
disableAnimation = false
|
|
91
|
+
}) => {
|
|
92
|
+
const DRAWER_ANIMATION_DURATION = 250;
|
|
93
|
+
const [isModalMounted, setIsModalMounted] = useState(false);
|
|
94
|
+
const [isModalVisible, setIsModalVisible] = useState(false);
|
|
95
|
+
const isModalMountedRef = useRef(false);
|
|
96
|
+
const animationRef = useRef(null);
|
|
97
|
+
const size = position === "left" || position === "right" ? width : height;
|
|
98
|
+
const initialTranslateValues = useMemo2(
|
|
99
|
+
() => getTranslateValue(position, size),
|
|
100
|
+
[position, size]
|
|
101
|
+
);
|
|
102
|
+
const translateX = useRef(new Animated.Value(initialTranslateValues.x)).current;
|
|
103
|
+
const translateY = useRef(new Animated.Value(initialTranslateValues.y)).current;
|
|
104
|
+
const overlayOpacity = useRef(new Animated.Value(0)).current;
|
|
105
|
+
const containerStyle = useDrawerStyles(themeColor, position, width, height);
|
|
106
|
+
const positionStyle = position === "left" ? styles.drawerLeft : position === "right" ? styles.drawerRight : position === "top" ? styles.drawerTop : styles.drawerBottom;
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
const translateValues = getTranslateValue(position, size);
|
|
109
|
+
if (animationRef.current) {
|
|
110
|
+
animationRef.current.stop();
|
|
111
|
+
animationRef.current = null;
|
|
112
|
+
}
|
|
113
|
+
if (isOpen) {
|
|
114
|
+
if (!isModalMountedRef.current) {
|
|
115
|
+
translateX.setValue(translateValues.x);
|
|
116
|
+
translateY.setValue(translateValues.y);
|
|
117
|
+
overlayOpacity.setValue(0);
|
|
118
|
+
isModalMountedRef.current = true;
|
|
119
|
+
setIsModalMounted(true);
|
|
120
|
+
setIsModalVisible(true);
|
|
121
|
+
}
|
|
122
|
+
if (disableAnimation) {
|
|
123
|
+
translateX.setValue(0);
|
|
124
|
+
translateY.setValue(0);
|
|
125
|
+
overlayOpacity.setValue(1);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const animation2 = Animated.parallel([
|
|
129
|
+
Animated.timing(translateX, {
|
|
130
|
+
toValue: 0,
|
|
131
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
132
|
+
easing: Easing.out(Easing.cubic),
|
|
133
|
+
useNativeDriver: true
|
|
134
|
+
}),
|
|
135
|
+
Animated.timing(translateY, {
|
|
136
|
+
toValue: 0,
|
|
137
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
138
|
+
easing: Easing.out(Easing.cubic),
|
|
139
|
+
useNativeDriver: true
|
|
140
|
+
}),
|
|
141
|
+
Animated.timing(overlayOpacity, {
|
|
142
|
+
toValue: 1,
|
|
143
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
144
|
+
useNativeDriver: true
|
|
145
|
+
})
|
|
146
|
+
]);
|
|
147
|
+
animationRef.current = animation2;
|
|
148
|
+
animation2.start(() => {
|
|
149
|
+
if (animationRef.current === animation2) {
|
|
150
|
+
animationRef.current = null;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (!isModalMountedRef.current) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (disableAnimation) {
|
|
159
|
+
translateX.setValue(translateValues.x);
|
|
160
|
+
translateY.setValue(translateValues.y);
|
|
161
|
+
overlayOpacity.setValue(0);
|
|
162
|
+
isModalMountedRef.current = false;
|
|
163
|
+
setIsModalVisible(false);
|
|
164
|
+
setIsModalMounted(false);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const animation = Animated.parallel([
|
|
168
|
+
Animated.timing(translateX, {
|
|
169
|
+
toValue: translateValues.x,
|
|
170
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
171
|
+
easing: Easing.in(Easing.cubic),
|
|
172
|
+
useNativeDriver: true
|
|
173
|
+
}),
|
|
174
|
+
Animated.timing(translateY, {
|
|
175
|
+
toValue: translateValues.y,
|
|
176
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
177
|
+
easing: Easing.in(Easing.cubic),
|
|
178
|
+
useNativeDriver: true
|
|
179
|
+
}),
|
|
180
|
+
Animated.timing(overlayOpacity, {
|
|
181
|
+
toValue: 0,
|
|
182
|
+
duration: DRAWER_ANIMATION_DURATION,
|
|
183
|
+
useNativeDriver: true
|
|
184
|
+
})
|
|
185
|
+
]);
|
|
186
|
+
animationRef.current = animation;
|
|
187
|
+
animation.start(({ finished }) => {
|
|
188
|
+
if (animationRef.current === animation) {
|
|
189
|
+
animationRef.current = null;
|
|
190
|
+
}
|
|
191
|
+
if (finished) {
|
|
192
|
+
isModalMountedRef.current = false;
|
|
193
|
+
setIsModalVisible(false);
|
|
194
|
+
setIsModalMounted(false);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}, [
|
|
198
|
+
isOpen,
|
|
199
|
+
position,
|
|
200
|
+
size,
|
|
201
|
+
disableAnimation,
|
|
202
|
+
translateX,
|
|
203
|
+
translateY,
|
|
204
|
+
overlayOpacity
|
|
205
|
+
]);
|
|
206
|
+
if (!isModalMounted) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
return /* @__PURE__ */ React.createElement(
|
|
210
|
+
Modal,
|
|
211
|
+
{
|
|
212
|
+
transparent: true,
|
|
213
|
+
visible: isModalVisible,
|
|
214
|
+
animationType: "none",
|
|
215
|
+
onRequestClose: onClose
|
|
216
|
+
},
|
|
217
|
+
/* @__PURE__ */ React.createElement(View, { style: { flex: 1 } }, showOverlay && /* @__PURE__ */ React.createElement(Pressable, { onPress: onClose, style: { flex: 1 } }, /* @__PURE__ */ React.createElement(Animated.View, { style: [styles.overlay, { opacity: overlayOpacity }] })), /* @__PURE__ */ React.createElement(
|
|
218
|
+
Animated.View,
|
|
219
|
+
{
|
|
220
|
+
style: [
|
|
221
|
+
styles.drawerContainer,
|
|
222
|
+
positionStyle,
|
|
223
|
+
containerStyle,
|
|
224
|
+
{
|
|
225
|
+
transform: [{ translateX }, { translateY }]
|
|
226
|
+
},
|
|
227
|
+
customStyle
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
children
|
|
231
|
+
))
|
|
232
|
+
);
|
|
233
|
+
};
|
|
234
|
+
export {
|
|
235
|
+
Drawer
|
|
236
|
+
};
|
|
@@ -27,32 +27,32 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// src/components/
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
// src/components/expansion-panel/index.ts
|
|
31
|
+
var expansion_panel_exports = {};
|
|
32
|
+
__export(expansion_panel_exports, {
|
|
33
|
+
ExpansionPanel: () => ExpansionPanel,
|
|
34
|
+
ExpansionPanelItem: () => ExpansionPanelItem
|
|
35
35
|
});
|
|
36
|
-
module.exports = __toCommonJS(
|
|
36
|
+
module.exports = __toCommonJS(expansion_panel_exports);
|
|
37
37
|
|
|
38
|
-
// src/components/
|
|
38
|
+
// src/components/expansion-panel/expansion-panel.tsx
|
|
39
39
|
var import_react14 = __toESM(require("react"), 1);
|
|
40
40
|
var import_react_native9 = require("react-native");
|
|
41
41
|
|
|
42
|
-
// src/components/
|
|
42
|
+
// src/components/expansion-panel/expansion-panel-context.ts
|
|
43
43
|
var import_react = require("react");
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
);
|
|
47
|
-
var useAccordionContext = () => {
|
|
48
|
-
const context = (0, import_react.useContext)(AccordionContext);
|
|
44
|
+
var ExpansionPanelContext = (0, import_react.createContext)(void 0);
|
|
45
|
+
var useExpansionPanelContext = () => {
|
|
46
|
+
const context = (0, import_react.useContext)(ExpansionPanelContext);
|
|
49
47
|
if (!context) {
|
|
50
|
-
throw new Error(
|
|
48
|
+
throw new Error(
|
|
49
|
+
"ExpansionPanelItem must be used within an ExpansionPanel component"
|
|
50
|
+
);
|
|
51
51
|
}
|
|
52
52
|
return context;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
// src/components/
|
|
55
|
+
// src/components/expansion-panel/expansion-panel.hook.ts
|
|
56
56
|
var import_react7 = require("react");
|
|
57
57
|
|
|
58
58
|
// src/core/theme-context.tsx
|
|
@@ -98,8 +98,8 @@ function useXUIPalette() {
|
|
|
98
98
|
// src/core/index.ts
|
|
99
99
|
var import_theme2 = require("@xaui/core/theme");
|
|
100
100
|
|
|
101
|
-
// src/components/
|
|
102
|
-
var
|
|
101
|
+
// src/components/expansion-panel/expansion-panel.hook.ts
|
|
102
|
+
var useExpansionPanelStyles = ({
|
|
103
103
|
variant,
|
|
104
104
|
fullWidth
|
|
105
105
|
}) => {
|
|
@@ -125,7 +125,7 @@ var useAccordionStyles = ({
|
|
|
125
125
|
const dividerOpacity = variant === "bordered" ? 1 : 0.2;
|
|
126
126
|
return { containerStyles, dividerColor, dividerOpacity };
|
|
127
127
|
};
|
|
128
|
-
var
|
|
128
|
+
var useExpansionPanelSelection = ({
|
|
129
129
|
selectionMode,
|
|
130
130
|
expandedKeys,
|
|
131
131
|
defaultExpandedKeys,
|
|
@@ -147,8 +147,8 @@ var useAccordionSelection = ({
|
|
|
147
147
|
);
|
|
148
148
|
return { currentExpandedKeys, toggleItem };
|
|
149
149
|
};
|
|
150
|
-
var
|
|
151
|
-
const { currentExpandedKeys, toggleItem } =
|
|
150
|
+
var useExpansionPanelContextValue = (config) => {
|
|
151
|
+
const { currentExpandedKeys, toggleItem } = useExpansionPanelSelection({
|
|
152
152
|
selectionMode: config.selectionMode,
|
|
153
153
|
expandedKeys: config.expandedKeys,
|
|
154
154
|
defaultExpandedKeys: config.defaultExpandedKeys,
|
|
@@ -178,11 +178,11 @@ var useAccordionContextValue = (config) => {
|
|
|
178
178
|
);
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
-
// src/components/
|
|
181
|
+
// src/components/expansion-panel/expansion-panel-item.tsx
|
|
182
182
|
var import_react10 = __toESM(require("react"), 1);
|
|
183
183
|
var import_react_native6 = require("react-native");
|
|
184
184
|
|
|
185
|
-
// src/components/
|
|
185
|
+
// src/components/expansion-panel/expansion-panel-item.style.ts
|
|
186
186
|
var import_react_native4 = require("react-native");
|
|
187
187
|
var styles = import_react_native4.StyleSheet.create({
|
|
188
188
|
startContent: {
|
|
@@ -206,13 +206,13 @@ var styles = import_react_native4.StyleSheet.create({
|
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
208
|
|
|
209
|
-
// src/components/
|
|
209
|
+
// src/components/expansion-panel/expansion-panel-item.hook.ts
|
|
210
210
|
var import_react8 = require("react");
|
|
211
211
|
var import_react_native5 = require("react-native");
|
|
212
212
|
var import_palette2 = require("@xaui/core/palette");
|
|
213
213
|
var import_core3 = require("@xaui/core");
|
|
214
|
-
var
|
|
215
|
-
const context =
|
|
214
|
+
var useExpansionPanelItemState = (itemKey) => {
|
|
215
|
+
const context = useExpansionPanelContext();
|
|
216
216
|
const resolvedItemKey = itemKey ?? "";
|
|
217
217
|
const isExpanded = resolvedItemKey ? context.expandedKeys.includes(resolvedItemKey) : false;
|
|
218
218
|
const isDisabled = resolvedItemKey ? context.disabledKeys.includes(resolvedItemKey) : false;
|
|
@@ -222,7 +222,7 @@ var useAccordionItemState = (itemKey) => {
|
|
|
222
222
|
}, [isDisabled, resolvedItemKey, context]);
|
|
223
223
|
return { ...context, resolvedItemKey, isExpanded, isDisabled, handlePress };
|
|
224
224
|
};
|
|
225
|
-
var
|
|
225
|
+
var useExpansionPanelItemAnimation = (isExpanded, disableAnimation) => {
|
|
226
226
|
const [contentHeight, setContentHeight] = (0, import_react8.useState)(0);
|
|
227
227
|
const [isMeasured, setIsMeasured] = (0, import_react8.useState)(false);
|
|
228
228
|
const animatedHeight = (0, import_react8.useRef)(new import_react_native5.Animated.Value(isExpanded ? 1 : 0)).current;
|
|
@@ -359,7 +359,7 @@ var useForegroundColor = () => {
|
|
|
359
359
|
return theme.colors.foreground;
|
|
360
360
|
};
|
|
361
361
|
|
|
362
|
-
// src/components/
|
|
362
|
+
// src/components/expansion-panel/chevron-right-icon.tsx
|
|
363
363
|
var import_react9 = __toESM(require("react"), 1);
|
|
364
364
|
var import_react_native_svg = __toESM(require("react-native-svg"), 1);
|
|
365
365
|
var ChevronRightIcon = ({
|
|
@@ -378,8 +378,8 @@ var ChevronRightIcon = ({
|
|
|
378
378
|
));
|
|
379
379
|
};
|
|
380
380
|
|
|
381
|
-
// src/components/
|
|
382
|
-
var
|
|
381
|
+
// src/components/expansion-panel/expansion-panel-item.tsx
|
|
382
|
+
var ExpansionPanelItem = ({
|
|
383
383
|
itemKey,
|
|
384
384
|
children,
|
|
385
385
|
title,
|
|
@@ -397,12 +397,12 @@ var AccordionItem = ({
|
|
|
397
397
|
isExpanded,
|
|
398
398
|
isDisabled,
|
|
399
399
|
handlePress: togglePress
|
|
400
|
-
} =
|
|
400
|
+
} = useExpansionPanelItemState(itemKey);
|
|
401
401
|
const handlePress = () => {
|
|
402
402
|
togglePress();
|
|
403
403
|
onSelected?.(!isExpanded);
|
|
404
404
|
};
|
|
405
|
-
const { onContentLayout, heightInterpolation, rotationInterpolation } =
|
|
405
|
+
const { onContentLayout, heightInterpolation, rotationInterpolation } = useExpansionPanelItemAnimation(isExpanded, disableAnimation);
|
|
406
406
|
const baseStyles = useBaseStyles(variant, isDisabled);
|
|
407
407
|
const triggerStyles = useTriggerStyles(variant, isCompact);
|
|
408
408
|
const titleTextStyle = useTitleTextStyle(isCompact);
|
|
@@ -449,9 +449,9 @@ var AccordionItem = ({
|
|
|
449
449
|
/* @__PURE__ */ import_react10.default.createElement(import_react_native6.View, { style: [contentContainerStyle, customAppearance?.content] }, children)
|
|
450
450
|
));
|
|
451
451
|
};
|
|
452
|
-
|
|
452
|
+
ExpansionPanelItem.displayName = "ExpansionPanelItem";
|
|
453
453
|
|
|
454
|
-
// src/components/
|
|
454
|
+
// src/components/expansion-panel/expansion-panel.utils.ts
|
|
455
455
|
var import_react11 = __toESM(require("react"), 1);
|
|
456
456
|
var getItemKey = (value, fallback) => {
|
|
457
457
|
if (value === null || value === void 0) return String(fallback);
|
|
@@ -462,8 +462,8 @@ var normalizeElementKey = (value) => {
|
|
|
462
462
|
if (typeof value !== "string") return value;
|
|
463
463
|
return value.startsWith(".$") ? value.slice(2) : value.startsWith(".") ? value.slice(1) : value;
|
|
464
464
|
};
|
|
465
|
-
var
|
|
466
|
-
var
|
|
465
|
+
var isExpansionPanelItem = (value) => import_react11.default.isValidElement(value) && (value.type === ExpansionPanelItem || typeof value.type === "function" && value.type.displayName === "ExpansionPanelItem");
|
|
466
|
+
var buildExpansionPanelContextParams = (props) => {
|
|
467
467
|
return {
|
|
468
468
|
variant: props.variant || "light",
|
|
469
469
|
hideIndicator: Boolean(props.hideIndicator),
|
|
@@ -546,8 +546,8 @@ var Divider = ({
|
|
|
546
546
|
);
|
|
547
547
|
};
|
|
548
548
|
|
|
549
|
-
// src/components/
|
|
550
|
-
var
|
|
549
|
+
// src/components/expansion-panel/expansion-panel.tsx
|
|
550
|
+
var ExpansionPanel = (props) => {
|
|
551
551
|
const {
|
|
552
552
|
children,
|
|
553
553
|
variant = "light",
|
|
@@ -555,28 +555,28 @@ var Accordion = (props) => {
|
|
|
555
555
|
fullWidth = true,
|
|
556
556
|
customAppearance
|
|
557
557
|
} = props;
|
|
558
|
-
const { containerStyles, dividerColor } =
|
|
558
|
+
const { containerStyles, dividerColor } = useExpansionPanelStyles({
|
|
559
559
|
variant,
|
|
560
560
|
fullWidth
|
|
561
561
|
});
|
|
562
|
-
const contextParams =
|
|
563
|
-
const contextValue =
|
|
562
|
+
const contextParams = buildExpansionPanelContextParams(props);
|
|
563
|
+
const contextValue = useExpansionPanelContextValue(contextParams);
|
|
564
564
|
const childrenArray = import_react14.default.Children.toArray(children);
|
|
565
|
-
return /* @__PURE__ */ import_react14.default.createElement(
|
|
565
|
+
return /* @__PURE__ */ import_react14.default.createElement(ExpansionPanelContext.Provider, { value: contextValue }, /* @__PURE__ */ import_react14.default.createElement(import_react_native9.View, { style: [containerStyles, customAppearance?.container] }, childrenArray.map((child, index) => {
|
|
566
566
|
const isLast = index === childrenArray.length - 1;
|
|
567
567
|
const showBottomDivider = (showDivider || variant === "bordered") && !isLast && variant !== "splitted";
|
|
568
|
-
const resolvedChildKey =
|
|
568
|
+
const resolvedChildKey = isExpansionPanelItem(child) ? getItemKey(
|
|
569
569
|
child.props.itemKey ?? normalizeElementKey(child.key),
|
|
570
570
|
index
|
|
571
571
|
) : getItemKey(
|
|
572
572
|
import_react14.default.isValidElement(child) ? normalizeElementKey(child.key) : void 0,
|
|
573
573
|
index
|
|
574
574
|
);
|
|
575
|
-
return /* @__PURE__ */ import_react14.default.createElement(import_react_native9.View, { key: resolvedChildKey, style: customAppearance?.item },
|
|
575
|
+
return /* @__PURE__ */ import_react14.default.createElement(import_react_native9.View, { key: resolvedChildKey, style: customAppearance?.item }, isExpansionPanelItem(child) ? import_react14.default.cloneElement(child, { itemKey: resolvedChildKey }) : child, showBottomDivider && /* @__PURE__ */ import_react14.default.createElement(Divider, { color: dividerColor, size: 2 }));
|
|
576
576
|
})));
|
|
577
577
|
};
|
|
578
578
|
// Annotate the CommonJS export names for ESM import in node:
|
|
579
579
|
0 && (module.exports = {
|
|
580
|
-
|
|
581
|
-
|
|
580
|
+
ExpansionPanel,
|
|
581
|
+
ExpansionPanelItem
|
|
582
582
|
});
|