@xaui/native 0.0.4 → 0.0.6
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/accordion/index.cjs +556 -0
- package/dist/accordion/index.d.cts +141 -0
- package/dist/accordion/index.d.ts +141 -0
- package/dist/accordion/index.js +434 -0
- package/dist/button/index.cjs +8 -0
- package/dist/button/index.js +4 -2
- package/dist/checkbox/index.cjs +7 -1
- package/dist/checkbox/index.js +4 -2
- package/dist/{chunk-52PIZF2Z.js → chunk-B2VGVZ3J.js} +3 -1
- package/dist/{chunk-DNJWBME5.js → chunk-ORMNMNOK.js} +16 -2
- package/dist/chunk-R34CVLCX.js +75 -0
- package/dist/core/index.cjs +12 -1
- package/dist/core/index.d.cts +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +5 -1
- package/dist/divider/index.cjs +130 -0
- package/dist/divider/index.d.cts +30 -0
- package/dist/divider/index.d.ts +30 -0
- package/dist/divider/index.js +7 -0
- package/dist/index.cjs +78 -2
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -3
- package/dist/indicator/index.cjs +6 -0
- package/dist/indicator/index.js +2 -2
- package/dist/progress/index.cjs +6 -0
- package/dist/progress/index.js +3 -1
- package/dist/select/index.cjs +919 -0
- package/dist/select/index.d.cts +192 -0
- package/dist/select/index.d.ts +192 -0
- package/dist/select/index.js +874 -0
- package/package.json +17 -2
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ViewStyle, TextStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type AccordionVariant = 'light' | 'bordered' | 'splitted';
|
|
5
|
+
type AccordionSelectionMode = 'toggle' | 'multiple';
|
|
6
|
+
type AccordionEvents = {
|
|
7
|
+
onSelectionChange?: (selectedKeys: string[]) => void;
|
|
8
|
+
};
|
|
9
|
+
type AccordionProps = {
|
|
10
|
+
/**
|
|
11
|
+
* List of AccordionItem components
|
|
12
|
+
*/
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Visual variant of the accordion
|
|
16
|
+
* @default 'light'
|
|
17
|
+
*/
|
|
18
|
+
variant?: AccordionVariant;
|
|
19
|
+
/**
|
|
20
|
+
* Selection behavior mode
|
|
21
|
+
* - toggle: Only one accordion item can be expanded at a time
|
|
22
|
+
* - multiple: Multiple accordion items can be expanded simultaneously
|
|
23
|
+
* @default 'toggle'
|
|
24
|
+
*/
|
|
25
|
+
selectionMode?: AccordionSelectionMode;
|
|
26
|
+
/**
|
|
27
|
+
* Show dividers between accordion items
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
showDivider?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Hide the collapse/expand indicator
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
hideIndicator?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the accordion should take full width
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
fullWidth?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Controlled expanded keys
|
|
43
|
+
*/
|
|
44
|
+
expandedKeys?: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Default expanded keys for uncontrolled mode
|
|
47
|
+
* Items with these keys will be expanded by default
|
|
48
|
+
*/
|
|
49
|
+
defaultExpandedKeys?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* Keys of disabled accordion items
|
|
52
|
+
*/
|
|
53
|
+
disabledKeys?: string[];
|
|
54
|
+
/**
|
|
55
|
+
* Disable animations
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
disableAnimation?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Make the accordion items more compact
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
isCompact?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Custom styles for the container
|
|
66
|
+
*/
|
|
67
|
+
containerStyle?: ViewStyle;
|
|
68
|
+
/**
|
|
69
|
+
* Custom styles for individual items
|
|
70
|
+
*/
|
|
71
|
+
itemStyle?: ViewStyle;
|
|
72
|
+
} & AccordionEvents;
|
|
73
|
+
|
|
74
|
+
declare const Accordion: React.FC<AccordionProps>;
|
|
75
|
+
|
|
76
|
+
type AccordionItemEvents = {
|
|
77
|
+
onSelected?: (isSelected: boolean) => void;
|
|
78
|
+
};
|
|
79
|
+
type AccordionItemProps = {
|
|
80
|
+
/**
|
|
81
|
+
* Unique key for the accordion item
|
|
82
|
+
*/
|
|
83
|
+
itemKey?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Content to display when accordion item is expanded
|
|
86
|
+
*/
|
|
87
|
+
children: ReactNode;
|
|
88
|
+
/**
|
|
89
|
+
* Title displayed in the accordion header
|
|
90
|
+
*/
|
|
91
|
+
title: ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* Optional subtitle displayed below the title
|
|
94
|
+
*/
|
|
95
|
+
subtitle?: ReactNode;
|
|
96
|
+
/**
|
|
97
|
+
* Content displayed at the start of the header (left side)
|
|
98
|
+
*/
|
|
99
|
+
startContent?: ReactNode;
|
|
100
|
+
/**
|
|
101
|
+
* Custom indicator for the expanded/collapsed state
|
|
102
|
+
* @default ChevronRight icon
|
|
103
|
+
*/
|
|
104
|
+
indicator?: ReactNode;
|
|
105
|
+
/**
|
|
106
|
+
* Custom styles for the base container
|
|
107
|
+
*/
|
|
108
|
+
baseStyle?: ViewStyle;
|
|
109
|
+
/**
|
|
110
|
+
* Custom styles for the header container
|
|
111
|
+
*/
|
|
112
|
+
headingStyle?: ViewStyle;
|
|
113
|
+
/**
|
|
114
|
+
* Custom styles for the trigger button
|
|
115
|
+
*/
|
|
116
|
+
triggerStyle?: ViewStyle;
|
|
117
|
+
/**
|
|
118
|
+
* Custom styles for the title text
|
|
119
|
+
*/
|
|
120
|
+
titleStyle?: TextStyle;
|
|
121
|
+
/**
|
|
122
|
+
* Custom styles for the subtitle text
|
|
123
|
+
*/
|
|
124
|
+
subtitleStyle?: TextStyle;
|
|
125
|
+
/**
|
|
126
|
+
* Custom styles for the content container
|
|
127
|
+
*/
|
|
128
|
+
contentStyle?: ViewStyle;
|
|
129
|
+
/**
|
|
130
|
+
* Custom styles for the start content container
|
|
131
|
+
*/
|
|
132
|
+
startContentStyle?: ViewStyle;
|
|
133
|
+
/**
|
|
134
|
+
* Custom styles for the indicator
|
|
135
|
+
*/
|
|
136
|
+
indicatorStyle?: ViewStyle;
|
|
137
|
+
} & AccordionItemEvents;
|
|
138
|
+
|
|
139
|
+
declare const AccordionItem: React.FC<AccordionItemProps>;
|
|
140
|
+
|
|
141
|
+
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionSelectionMode, type AccordionVariant };
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Divider
|
|
3
|
+
} from "../chunk-R34CVLCX.js";
|
|
4
|
+
import {
|
|
5
|
+
useXUIPalette,
|
|
6
|
+
useXUITheme
|
|
7
|
+
} from "../chunk-ORMNMNOK.js";
|
|
8
|
+
|
|
9
|
+
// src/components/accordion/accordion.tsx
|
|
10
|
+
import React4 from "react";
|
|
11
|
+
import { View as View2 } from "react-native";
|
|
12
|
+
|
|
13
|
+
// src/components/accordion/accordion-context.ts
|
|
14
|
+
import { createContext, useContext } from "react";
|
|
15
|
+
var AccordionContext = createContext(void 0);
|
|
16
|
+
var useAccordionContext = () => {
|
|
17
|
+
const context = useContext(AccordionContext);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error("AccordionItem must be used within an Accordion component");
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/components/accordion/accordion.hook.ts
|
|
25
|
+
import { useState, useCallback, useMemo } from "react";
|
|
26
|
+
var useAccordionStyles = ({ variant, fullWidth }) => {
|
|
27
|
+
const theme = useXUITheme();
|
|
28
|
+
const palette2 = useXUIPalette();
|
|
29
|
+
const containerStyles = useMemo(() => {
|
|
30
|
+
const base = {};
|
|
31
|
+
if (fullWidth) {
|
|
32
|
+
base.width = "100%";
|
|
33
|
+
}
|
|
34
|
+
if (variant === "bordered") {
|
|
35
|
+
base.borderWidth = theme.borderWidth.md;
|
|
36
|
+
base.borderColor = theme.mode === "dark" ? palette2.gray[800] : theme.palette.gray[200];
|
|
37
|
+
base.borderRadius = theme.borderRadius.md;
|
|
38
|
+
base.marginHorizontal = theme.spacing.sm;
|
|
39
|
+
base.overflow = "hidden";
|
|
40
|
+
} else if (variant === "light") {
|
|
41
|
+
base.paddingHorizontal = theme.spacing.sm;
|
|
42
|
+
}
|
|
43
|
+
return base;
|
|
44
|
+
}, [variant, fullWidth, theme]);
|
|
45
|
+
const dividerColor = variant === "bordered" ? containerStyles.borderColor : theme.mode === "dark" ? palette2.gray[800] : theme.palette.gray[200];
|
|
46
|
+
const dividerOpacity = variant === "bordered" ? 1 : 0.2;
|
|
47
|
+
return { containerStyles, dividerColor, dividerOpacity };
|
|
48
|
+
};
|
|
49
|
+
var useAccordionSelection = ({
|
|
50
|
+
selectionMode,
|
|
51
|
+
expandedKeys,
|
|
52
|
+
defaultExpandedKeys,
|
|
53
|
+
onSelectionChange
|
|
54
|
+
}) => {
|
|
55
|
+
const [internalExpandedKeys, setInternalExpandedKeys] = useState(defaultExpandedKeys);
|
|
56
|
+
const isControlled = expandedKeys !== void 0;
|
|
57
|
+
const currentExpandedKeys = isControlled ? expandedKeys : internalExpandedKeys;
|
|
58
|
+
const toggleItem = useCallback(
|
|
59
|
+
(key) => {
|
|
60
|
+
const isExpanded = currentExpandedKeys.includes(key);
|
|
61
|
+
const newExpandedKeys = selectionMode === "toggle" ? isExpanded ? [] : [key] : isExpanded ? currentExpandedKeys.filter((k) => k !== key) : [...currentExpandedKeys, key];
|
|
62
|
+
if (!isControlled) {
|
|
63
|
+
setInternalExpandedKeys(newExpandedKeys);
|
|
64
|
+
}
|
|
65
|
+
onSelectionChange?.(newExpandedKeys);
|
|
66
|
+
},
|
|
67
|
+
[selectionMode, currentExpandedKeys, isControlled, onSelectionChange]
|
|
68
|
+
);
|
|
69
|
+
return { currentExpandedKeys, toggleItem };
|
|
70
|
+
};
|
|
71
|
+
var useAccordionContextValue = (config) => {
|
|
72
|
+
const { currentExpandedKeys, toggleItem } = useAccordionSelection({
|
|
73
|
+
selectionMode: config.selectionMode,
|
|
74
|
+
expandedKeys: config.expandedKeys,
|
|
75
|
+
defaultExpandedKeys: config.defaultExpandedKeys,
|
|
76
|
+
onSelectionChange: config.onSelectionChange
|
|
77
|
+
});
|
|
78
|
+
return useMemo(
|
|
79
|
+
() => ({
|
|
80
|
+
variant: config.variant,
|
|
81
|
+
hideIndicator: config.hideIndicator,
|
|
82
|
+
disableAnimation: config.disableAnimation,
|
|
83
|
+
isCompact: config.isCompact,
|
|
84
|
+
showDivider: config.showDivider,
|
|
85
|
+
expandedKeys: currentExpandedKeys,
|
|
86
|
+
disabledKeys: config.disabledKeys,
|
|
87
|
+
toggleItem
|
|
88
|
+
}),
|
|
89
|
+
[
|
|
90
|
+
config.variant,
|
|
91
|
+
config.hideIndicator,
|
|
92
|
+
config.disableAnimation,
|
|
93
|
+
config.isCompact,
|
|
94
|
+
config.showDivider,
|
|
95
|
+
currentExpandedKeys,
|
|
96
|
+
config.disabledKeys,
|
|
97
|
+
toggleItem
|
|
98
|
+
]
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/components/accordion/accordion-item.tsx
|
|
103
|
+
import React2 from "react";
|
|
104
|
+
import { View, Text, Pressable, Animated as Animated2 } from "react-native";
|
|
105
|
+
|
|
106
|
+
// src/components/accordion/accordion-item.style.ts
|
|
107
|
+
import { StyleSheet } from "react-native";
|
|
108
|
+
var styles = StyleSheet.create({
|
|
109
|
+
startContent: {
|
|
110
|
+
flexShrink: 0
|
|
111
|
+
},
|
|
112
|
+
titleWrapper: {
|
|
113
|
+
flex: 1
|
|
114
|
+
},
|
|
115
|
+
indicator: {
|
|
116
|
+
flexShrink: 0
|
|
117
|
+
},
|
|
118
|
+
hiddenMeasure: {
|
|
119
|
+
position: "absolute",
|
|
120
|
+
opacity: 0,
|
|
121
|
+
left: 0,
|
|
122
|
+
right: 0,
|
|
123
|
+
zIndex: -999
|
|
124
|
+
},
|
|
125
|
+
contentOverflow: {
|
|
126
|
+
overflow: "hidden"
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// src/components/accordion/accordion-item.hook.ts
|
|
131
|
+
import { useRef, useEffect, useState as useState2, useMemo as useMemo2, useCallback as useCallback2 } from "react";
|
|
132
|
+
import {
|
|
133
|
+
Animated,
|
|
134
|
+
Easing
|
|
135
|
+
} from "react-native";
|
|
136
|
+
import { colors as palette } from "@xaui/core/palette";
|
|
137
|
+
var useAccordionItemState = (itemKey) => {
|
|
138
|
+
const context = useAccordionContext();
|
|
139
|
+
const resolvedItemKey = itemKey ?? "";
|
|
140
|
+
const isExpanded = resolvedItemKey ? context.expandedKeys.includes(resolvedItemKey) : false;
|
|
141
|
+
const isDisabled = resolvedItemKey ? context.disabledKeys.includes(resolvedItemKey) : false;
|
|
142
|
+
const handlePress = useCallback2(() => {
|
|
143
|
+
if (isDisabled || !resolvedItemKey) return;
|
|
144
|
+
context.toggleItem(resolvedItemKey);
|
|
145
|
+
}, [isDisabled, resolvedItemKey, context]);
|
|
146
|
+
return { ...context, resolvedItemKey, isExpanded, isDisabled, handlePress };
|
|
147
|
+
};
|
|
148
|
+
var useAccordionItemAnimation = (isExpanded, disableAnimation) => {
|
|
149
|
+
const [contentHeight, setContentHeight] = useState2(0);
|
|
150
|
+
const [isMeasured, setIsMeasured] = useState2(false);
|
|
151
|
+
const animatedHeight = useRef(new Animated.Value(isExpanded ? 1 : 0)).current;
|
|
152
|
+
const animatedRotation = useRef(new Animated.Value(isExpanded ? 1 : 0)).current;
|
|
153
|
+
const prevContentHeight = useRef(contentHeight);
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (disableAnimation) {
|
|
156
|
+
animatedHeight.setValue(isExpanded ? 1 : 0);
|
|
157
|
+
animatedRotation.setValue(isExpanded ? 1 : 0);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
Animated.parallel([
|
|
161
|
+
Animated.timing(animatedHeight, {
|
|
162
|
+
toValue: isExpanded ? 1 : 0,
|
|
163
|
+
duration: 300,
|
|
164
|
+
easing: Easing.bezier(0.4, 0, 0.2, 1),
|
|
165
|
+
useNativeDriver: false
|
|
166
|
+
}),
|
|
167
|
+
Animated.timing(animatedRotation, {
|
|
168
|
+
toValue: isExpanded ? 1 : 0,
|
|
169
|
+
duration: 300,
|
|
170
|
+
easing: Easing.bezier(0.4, 0, 0.2, 1),
|
|
171
|
+
useNativeDriver: true
|
|
172
|
+
})
|
|
173
|
+
]).start();
|
|
174
|
+
}, [isExpanded, disableAnimation, animatedHeight, animatedRotation]);
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
if (contentHeight <= 0 || contentHeight === prevContentHeight.current || !isExpanded)
|
|
177
|
+
return;
|
|
178
|
+
prevContentHeight.current = contentHeight;
|
|
179
|
+
if (!disableAnimation && isMeasured) {
|
|
180
|
+
Animated.timing(animatedHeight, {
|
|
181
|
+
toValue: 1,
|
|
182
|
+
duration: 200,
|
|
183
|
+
easing: Easing.out(Easing.ease),
|
|
184
|
+
useNativeDriver: false
|
|
185
|
+
}).start();
|
|
186
|
+
}
|
|
187
|
+
}, [contentHeight, isExpanded, disableAnimation, isMeasured, animatedHeight]);
|
|
188
|
+
const onContentLayout = useCallback2((event) => {
|
|
189
|
+
const height = event.nativeEvent.layout.height;
|
|
190
|
+
if (height > 0) {
|
|
191
|
+
setContentHeight(height);
|
|
192
|
+
setIsMeasured(true);
|
|
193
|
+
}
|
|
194
|
+
}, []);
|
|
195
|
+
const heightInterpolation = animatedHeight.interpolate({
|
|
196
|
+
inputRange: [0, 1],
|
|
197
|
+
outputRange: [0, contentHeight]
|
|
198
|
+
});
|
|
199
|
+
const rotationInterpolation = animatedRotation.interpolate({
|
|
200
|
+
inputRange: [0, 1],
|
|
201
|
+
outputRange: ["0deg", "90deg"]
|
|
202
|
+
});
|
|
203
|
+
return {
|
|
204
|
+
onContentLayout,
|
|
205
|
+
heightInterpolation,
|
|
206
|
+
rotationInterpolation,
|
|
207
|
+
contentHeight
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
var useBaseStyles = (variant, isDisabled) => {
|
|
211
|
+
const theme = useXUITheme();
|
|
212
|
+
const baseStyles = useMemo2(() => {
|
|
213
|
+
const base = { overflow: "hidden" };
|
|
214
|
+
if (variant === "splitted") {
|
|
215
|
+
base.paddingHorizontal = theme.spacing.md;
|
|
216
|
+
base.backgroundColor = theme.colors.default.background;
|
|
217
|
+
base.borderRadius = theme.borderRadius.md;
|
|
218
|
+
base.marginBottom = theme.spacing.sm;
|
|
219
|
+
} else if (variant === "bordered") {
|
|
220
|
+
base.paddingHorizontal = theme.spacing.md;
|
|
221
|
+
}
|
|
222
|
+
if (isDisabled) {
|
|
223
|
+
base.opacity = 0.4;
|
|
224
|
+
}
|
|
225
|
+
return base;
|
|
226
|
+
}, [variant, isDisabled, theme]);
|
|
227
|
+
return baseStyles;
|
|
228
|
+
};
|
|
229
|
+
var useTriggerStyles = (variant, isCompact) => {
|
|
230
|
+
const theme = useXUITheme();
|
|
231
|
+
const triggerStyles = useMemo2(() => {
|
|
232
|
+
const trigger = {
|
|
233
|
+
flexDirection: "row",
|
|
234
|
+
alignItems: "center",
|
|
235
|
+
paddingVertical: isCompact ? theme.spacing.xs : theme.spacing.md,
|
|
236
|
+
gap: theme.spacing.md
|
|
237
|
+
};
|
|
238
|
+
if (variant === "light") {
|
|
239
|
+
trigger.paddingHorizontal = theme.spacing.sm;
|
|
240
|
+
}
|
|
241
|
+
return trigger;
|
|
242
|
+
}, [variant, isCompact, theme]);
|
|
243
|
+
return triggerStyles;
|
|
244
|
+
};
|
|
245
|
+
var useTitleTextStyle = (isCompact) => {
|
|
246
|
+
const theme = useXUITheme();
|
|
247
|
+
const titleTextStyle = useMemo2(
|
|
248
|
+
() => ({
|
|
249
|
+
fontSize: isCompact ? theme.fontSizes.md : theme.fontSizes.lg,
|
|
250
|
+
fontWeight: theme.fontWeights.medium,
|
|
251
|
+
color: theme.colors.foreground
|
|
252
|
+
}),
|
|
253
|
+
[isCompact, theme]
|
|
254
|
+
);
|
|
255
|
+
return titleTextStyle;
|
|
256
|
+
};
|
|
257
|
+
var useSubtitleTextStyle = () => {
|
|
258
|
+
const theme = useXUITheme();
|
|
259
|
+
const subtitleTextStyle = useMemo2(
|
|
260
|
+
() => ({
|
|
261
|
+
fontSize: theme.fontSizes.sm,
|
|
262
|
+
color: palette.gray[500],
|
|
263
|
+
marginTop: theme.spacing.xs
|
|
264
|
+
}),
|
|
265
|
+
[theme]
|
|
266
|
+
);
|
|
267
|
+
return subtitleTextStyle;
|
|
268
|
+
};
|
|
269
|
+
var useContentContainerStyle = (isCompact, variant) => {
|
|
270
|
+
const theme = useXUITheme();
|
|
271
|
+
const contentContainerStyle = useMemo2(
|
|
272
|
+
() => ({
|
|
273
|
+
paddingBottom: isCompact ? theme.spacing.sm : theme.spacing.md,
|
|
274
|
+
paddingHorizontal: variant === "light" ? theme.spacing.sm : 0
|
|
275
|
+
}),
|
|
276
|
+
[isCompact, variant, theme]
|
|
277
|
+
);
|
|
278
|
+
return contentContainerStyle;
|
|
279
|
+
};
|
|
280
|
+
var useForegroundColor = () => {
|
|
281
|
+
const theme = useXUITheme();
|
|
282
|
+
return theme.colors.foreground;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// src/components/accordion/chevron-right-icon.tsx
|
|
286
|
+
import React from "react";
|
|
287
|
+
import Svg, { Path } from "react-native-svg";
|
|
288
|
+
var ChevronRightIcon = ({
|
|
289
|
+
color = "#000",
|
|
290
|
+
size = 20
|
|
291
|
+
}) => {
|
|
292
|
+
return /* @__PURE__ */ React.createElement(Svg, { width: size, height: size, viewBox: "0 0 24 24", fill: "none" }, /* @__PURE__ */ React.createElement(
|
|
293
|
+
Path,
|
|
294
|
+
{
|
|
295
|
+
d: "M9 18l6-6-6-6",
|
|
296
|
+
stroke: color,
|
|
297
|
+
strokeWidth: 2,
|
|
298
|
+
strokeLinecap: "round",
|
|
299
|
+
strokeLinejoin: "round"
|
|
300
|
+
}
|
|
301
|
+
));
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// src/components/accordion/accordion-item.tsx
|
|
305
|
+
var AccordionItem = ({
|
|
306
|
+
itemKey,
|
|
307
|
+
children,
|
|
308
|
+
title,
|
|
309
|
+
subtitle,
|
|
310
|
+
startContent,
|
|
311
|
+
indicator,
|
|
312
|
+
baseStyle,
|
|
313
|
+
headingStyle,
|
|
314
|
+
triggerStyle,
|
|
315
|
+
titleStyle,
|
|
316
|
+
subtitleStyle,
|
|
317
|
+
contentStyle,
|
|
318
|
+
startContentStyle,
|
|
319
|
+
indicatorStyle,
|
|
320
|
+
onSelected
|
|
321
|
+
}) => {
|
|
322
|
+
const {
|
|
323
|
+
variant,
|
|
324
|
+
hideIndicator,
|
|
325
|
+
disableAnimation,
|
|
326
|
+
isCompact,
|
|
327
|
+
isExpanded,
|
|
328
|
+
isDisabled,
|
|
329
|
+
handlePress: togglePress
|
|
330
|
+
} = useAccordionItemState(itemKey);
|
|
331
|
+
const handlePress = () => {
|
|
332
|
+
togglePress();
|
|
333
|
+
onSelected?.(!isExpanded);
|
|
334
|
+
};
|
|
335
|
+
const { onContentLayout, heightInterpolation, rotationInterpolation } = useAccordionItemAnimation(isExpanded, disableAnimation);
|
|
336
|
+
const baseStyles = useBaseStyles(variant, isDisabled);
|
|
337
|
+
const triggerStyles = useTriggerStyles(variant, isCompact);
|
|
338
|
+
const titleTextStyle = useTitleTextStyle(isCompact);
|
|
339
|
+
const subtitleTextStyle = useSubtitleTextStyle();
|
|
340
|
+
const contentContainerStyle = useContentContainerStyle(isCompact, variant);
|
|
341
|
+
const foregroundColor = useForegroundColor();
|
|
342
|
+
return /* @__PURE__ */ React2.createElement(View, { style: [baseStyles, baseStyle] }, /* @__PURE__ */ React2.createElement(View, { style: headingStyle }, /* @__PURE__ */ React2.createElement(
|
|
343
|
+
Pressable,
|
|
344
|
+
{
|
|
345
|
+
style: [triggerStyles, triggerStyle],
|
|
346
|
+
onPress: handlePress,
|
|
347
|
+
disabled: isDisabled,
|
|
348
|
+
accessibilityRole: "button",
|
|
349
|
+
accessibilityState: { expanded: isExpanded, disabled: isDisabled }
|
|
350
|
+
},
|
|
351
|
+
startContent && /* @__PURE__ */ React2.createElement(View, { style: [styles.startContent, startContentStyle] }, startContent),
|
|
352
|
+
/* @__PURE__ */ React2.createElement(View, { style: styles.titleWrapper }, typeof title === "string" ? /* @__PURE__ */ React2.createElement(Text, { style: [titleTextStyle, titleStyle] }, title) : title, subtitle && (typeof subtitle === "string" ? /* @__PURE__ */ React2.createElement(Text, { style: [subtitleTextStyle, subtitleStyle] }, subtitle) : subtitle)),
|
|
353
|
+
!hideIndicator && /* @__PURE__ */ React2.createElement(
|
|
354
|
+
Animated2.View,
|
|
355
|
+
{
|
|
356
|
+
style: [
|
|
357
|
+
styles.indicator,
|
|
358
|
+
indicatorStyle,
|
|
359
|
+
{ transform: [{ rotate: rotationInterpolation }] }
|
|
360
|
+
]
|
|
361
|
+
},
|
|
362
|
+
indicator || /* @__PURE__ */ React2.createElement(ChevronRightIcon, { color: foregroundColor })
|
|
363
|
+
)
|
|
364
|
+
)), /* @__PURE__ */ React2.createElement(View, { style: styles.hiddenMeasure, pointerEvents: "none" }, /* @__PURE__ */ React2.createElement(View, { onLayout: onContentLayout, style: [contentContainerStyle, contentStyle] }, children)), /* @__PURE__ */ React2.createElement(
|
|
365
|
+
Animated2.View,
|
|
366
|
+
{
|
|
367
|
+
style: [
|
|
368
|
+
styles.contentOverflow,
|
|
369
|
+
disableAnimation ? { height: isExpanded ? void 0 : 0 } : { height: heightInterpolation }
|
|
370
|
+
]
|
|
371
|
+
},
|
|
372
|
+
/* @__PURE__ */ React2.createElement(View, { style: [contentContainerStyle, contentStyle] }, children)
|
|
373
|
+
));
|
|
374
|
+
};
|
|
375
|
+
AccordionItem.displayName = "AccordionItem";
|
|
376
|
+
|
|
377
|
+
// src/components/accordion/accordion.utils.ts
|
|
378
|
+
import React3 from "react";
|
|
379
|
+
var getItemKey = (value, fallback) => {
|
|
380
|
+
if (value === null || value === void 0) return String(fallback);
|
|
381
|
+
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
382
|
+
return String(fallback);
|
|
383
|
+
};
|
|
384
|
+
var normalizeElementKey = (value) => {
|
|
385
|
+
if (typeof value !== "string") return value;
|
|
386
|
+
return value.startsWith(".$") ? value.slice(2) : value.startsWith(".") ? value.slice(1) : value;
|
|
387
|
+
};
|
|
388
|
+
var isAccordionItem = (value) => React3.isValidElement(value) && (value.type === AccordionItem || typeof value.type === "function" && value.type.displayName === "AccordionItem");
|
|
389
|
+
var buildAccordionContextParams = (props) => {
|
|
390
|
+
return {
|
|
391
|
+
variant: props.variant || "light",
|
|
392
|
+
hideIndicator: Boolean(props.hideIndicator),
|
|
393
|
+
disableAnimation: Boolean(props.disableAnimation),
|
|
394
|
+
isCompact: Boolean(props.isCompact),
|
|
395
|
+
showDivider: Boolean(props.showDivider),
|
|
396
|
+
expandedKeys: props.expandedKeys,
|
|
397
|
+
defaultExpandedKeys: props.defaultExpandedKeys || [],
|
|
398
|
+
disabledKeys: props.disabledKeys || [],
|
|
399
|
+
selectionMode: props.selectionMode || "toggle",
|
|
400
|
+
onSelectionChange: props.onSelectionChange
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
// src/components/accordion/accordion.tsx
|
|
405
|
+
var Accordion = (props) => {
|
|
406
|
+
const {
|
|
407
|
+
children,
|
|
408
|
+
variant = "light",
|
|
409
|
+
showDivider = false,
|
|
410
|
+
fullWidth = true,
|
|
411
|
+
containerStyle,
|
|
412
|
+
itemStyle
|
|
413
|
+
} = props;
|
|
414
|
+
const { containerStyles, dividerColor } = useAccordionStyles({
|
|
415
|
+
variant,
|
|
416
|
+
fullWidth
|
|
417
|
+
});
|
|
418
|
+
const contextParams = buildAccordionContextParams(props);
|
|
419
|
+
const contextValue = useAccordionContextValue(contextParams);
|
|
420
|
+
const childrenArray = React4.Children.toArray(children);
|
|
421
|
+
return /* @__PURE__ */ React4.createElement(AccordionContext.Provider, { value: contextValue }, /* @__PURE__ */ React4.createElement(View2, { style: [containerStyles, containerStyle] }, childrenArray.map((child, index) => {
|
|
422
|
+
const isLast = index === childrenArray.length - 1;
|
|
423
|
+
const showBottomDivider = (showDivider || variant === "bordered") && !isLast && variant !== "splitted";
|
|
424
|
+
const resolvedChildKey = isAccordionItem(child) ? getItemKey(child.props.itemKey ?? normalizeElementKey(child.key), index) : getItemKey(
|
|
425
|
+
React4.isValidElement(child) ? normalizeElementKey(child.key) : void 0,
|
|
426
|
+
index
|
|
427
|
+
);
|
|
428
|
+
return /* @__PURE__ */ React4.createElement(View2, { key: resolvedChildKey, style: itemStyle }, isAccordionItem(child) ? React4.cloneElement(child, { itemKey: resolvedChildKey }) : child, showBottomDivider && /* @__PURE__ */ React4.createElement(Divider, { color: dividerColor, size: 2 }));
|
|
429
|
+
})));
|
|
430
|
+
};
|
|
431
|
+
export {
|
|
432
|
+
Accordion,
|
|
433
|
+
AccordionItem
|
|
434
|
+
};
|
package/dist/button/index.cjs
CHANGED
|
@@ -46,6 +46,7 @@ var import_react_native6 = require("react-native");
|
|
|
46
46
|
var import_react = __toESM(require("react"), 1);
|
|
47
47
|
var import_react_native = require("react-native");
|
|
48
48
|
var import_theme = require("@xaui/core/theme");
|
|
49
|
+
var import_palette = require("@xaui/core/palette");
|
|
49
50
|
var XUIThemeContext = (0, import_react.createContext)(null);
|
|
50
51
|
|
|
51
52
|
// src/core/theme-hooks.ts
|
|
@@ -73,6 +74,9 @@ function useBorderRadiusStyles(radius) {
|
|
|
73
74
|
return borderRadius;
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
// src/core/index.ts
|
|
78
|
+
var import_theme2 = require("@xaui/core/theme");
|
|
79
|
+
|
|
76
80
|
// src/components/indicator/circular-activity-indicator.tsx
|
|
77
81
|
var import_react3 = __toESM(require("react"), 1);
|
|
78
82
|
var import_react_native4 = require("react-native");
|
|
@@ -81,6 +85,8 @@ var import_react_native4 = require("react-native");
|
|
|
81
85
|
var import_react_native3 = require("react-native");
|
|
82
86
|
var styles = import_react_native3.StyleSheet.create({
|
|
83
87
|
container: {
|
|
88
|
+
flexShrink: 1,
|
|
89
|
+
flexBasis: "auto",
|
|
84
90
|
width: "100%",
|
|
85
91
|
justifyContent: "center"
|
|
86
92
|
},
|
|
@@ -459,6 +465,8 @@ var styles2 = import_react_native7.StyleSheet.create({
|
|
|
459
465
|
marginHorizontal: 4
|
|
460
466
|
},
|
|
461
467
|
fullWidth: {
|
|
468
|
+
flexShrink: 1,
|
|
469
|
+
flexBasis: "auto",
|
|
462
470
|
width: "100%"
|
|
463
471
|
},
|
|
464
472
|
disabled: {
|
package/dist/button/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ActivityIndicator
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-B2VGVZ3J.js";
|
|
4
4
|
import {
|
|
5
5
|
useBorderRadiusStyles,
|
|
6
6
|
useXUITheme
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-ORMNMNOK.js";
|
|
8
8
|
|
|
9
9
|
// src/components/button/button.tsx
|
|
10
10
|
import React from "react";
|
|
@@ -39,6 +39,8 @@ var styles = StyleSheet.create({
|
|
|
39
39
|
marginHorizontal: 4
|
|
40
40
|
},
|
|
41
41
|
fullWidth: {
|
|
42
|
+
flexShrink: 1,
|
|
43
|
+
flexBasis: "auto",
|
|
42
44
|
width: "100%"
|
|
43
45
|
},
|
|
44
46
|
disabled: {
|
package/dist/checkbox/index.cjs
CHANGED
|
@@ -189,6 +189,7 @@ var import_core = require("@xaui/core");
|
|
|
189
189
|
var import_react2 = __toESM(require("react"), 1);
|
|
190
190
|
var import_react_native3 = require("react-native");
|
|
191
191
|
var import_theme = require("@xaui/core/theme");
|
|
192
|
+
var import_palette = require("@xaui/core/palette");
|
|
192
193
|
var XUIThemeContext = (0, import_react2.createContext)(null);
|
|
193
194
|
|
|
194
195
|
// src/core/theme-hooks.ts
|
|
@@ -202,6 +203,9 @@ function useXUITheme() {
|
|
|
202
203
|
return theme;
|
|
203
204
|
}
|
|
204
205
|
|
|
206
|
+
// src/core/index.ts
|
|
207
|
+
var import_theme2 = require("@xaui/core/theme");
|
|
208
|
+
|
|
205
209
|
// src/components/checkbox/checkbox.hook.ts
|
|
206
210
|
function useSizeStyles(size, variant) {
|
|
207
211
|
const theme = useXUITheme();
|
|
@@ -271,7 +275,7 @@ function useCheckmarkColors(themeColor, variant, isActive) {
|
|
|
271
275
|
}
|
|
272
276
|
return {
|
|
273
277
|
checked: theme.colors.foreground,
|
|
274
|
-
unchecked:
|
|
278
|
+
unchecked: colorScheme.background
|
|
275
279
|
};
|
|
276
280
|
}, [variant, colorScheme, isActive, themeColor, theme.colors]);
|
|
277
281
|
return checkmarkColors;
|
|
@@ -316,6 +320,8 @@ var styles = import_react_native5.StyleSheet.create({
|
|
|
316
320
|
gap: 10
|
|
317
321
|
},
|
|
318
322
|
fullWidth: {
|
|
323
|
+
flexShrink: 1,
|
|
324
|
+
flexBasis: "auto",
|
|
319
325
|
width: "100%"
|
|
320
326
|
},
|
|
321
327
|
checkbox: {
|
package/dist/checkbox/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useXUITheme
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-ORMNMNOK.js";
|
|
4
4
|
|
|
5
5
|
// src/components/checkbox/checkbox.tsx
|
|
6
6
|
import React2, { useEffect as useEffect2, useRef as useRef2, useState } from "react";
|
|
@@ -220,7 +220,7 @@ function useCheckmarkColors(themeColor, variant, isActive) {
|
|
|
220
220
|
}
|
|
221
221
|
return {
|
|
222
222
|
checked: theme.colors.foreground,
|
|
223
|
-
unchecked:
|
|
223
|
+
unchecked: colorScheme.background
|
|
224
224
|
};
|
|
225
225
|
}, [variant, colorScheme, isActive, themeColor, theme.colors]);
|
|
226
226
|
return checkmarkColors;
|
|
@@ -265,6 +265,8 @@ var styles = StyleSheet.create({
|
|
|
265
265
|
gap: 10
|
|
266
266
|
},
|
|
267
267
|
fullWidth: {
|
|
268
|
+
flexShrink: 1,
|
|
269
|
+
flexBasis: "auto",
|
|
268
270
|
width: "100%"
|
|
269
271
|
},
|
|
270
272
|
checkbox: {
|