@xaui/native 0.0.16 → 0.0.18
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 +1 -1
- package/dist/accordion/index.js +5 -4
- package/dist/alert/index.js +352 -3
- package/dist/autocomplete/index.cjs +5 -11
- package/dist/autocomplete/index.js +1122 -5
- package/dist/avatar/index.js +276 -4
- package/dist/badge/index.js +193 -3
- package/dist/bottom-sheet/index.cjs +9 -20
- package/dist/bottom-sheet/index.js +364 -3
- package/dist/button/index.js +3 -2
- package/dist/card/index.cjs +429 -0
- package/dist/card/index.d.cts +186 -0
- package/dist/card/index.d.ts +186 -0
- package/dist/card/index.js +336 -0
- package/dist/carousel/index.cjs +458 -0
- package/dist/carousel/index.d.cts +147 -0
- package/dist/carousel/index.d.ts +147 -0
- package/dist/carousel/index.js +381 -0
- package/dist/checkbox/index.js +2 -1
- package/dist/chip/index.cjs +2 -8
- package/dist/chip/index.js +497 -5
- package/dist/chunk-DXXNBF5P.js +7 -0
- package/dist/{chunk-MKHBEJLO.js → chunk-F7WH4DMG.js} +1 -1
- package/dist/{chunk-II4QINLG.js → chunk-JEGEPGVU.js} +2 -2
- package/dist/{chunk-NBRASCX4.js → chunk-LTKYHG5V.js} +6 -13
- package/dist/{chunk-GNJIET26.js → chunk-LUBWRVI2.js} +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.js +5 -3
- package/dist/datepicker/index.js +1623 -3
- package/dist/divider/index.js +3 -2
- package/dist/fab/index.js +4 -3
- package/dist/fab-menu/index.cjs +4 -13
- package/dist/fab-menu/index.js +325 -6
- package/dist/index.cjs +0 -5709
- package/dist/index.d.cts +2 -17
- package/dist/index.d.ts +2 -17
- package/dist/index.js +0 -62
- package/dist/indicator/index.js +3 -2
- package/dist/menu/index.cjs +8 -7
- package/dist/menu/index.js +15 -9
- package/dist/progress/index.js +2 -1
- package/dist/segment-button/index.cjs +492 -0
- package/dist/segment-button/index.d.cts +141 -0
- package/dist/segment-button/index.d.ts +141 -0
- package/dist/segment-button/index.js +405 -0
- package/dist/select/index.js +2 -1
- package/dist/switch/index.js +2 -1
- package/dist/typography/index.js +146 -3
- package/dist/view/index.cjs +153 -78
- package/dist/view/index.d.cts +77 -1
- package/dist/view/index.d.ts +77 -1
- package/dist/view/index.js +125 -52
- package/package.json +16 -1
- package/dist/chunk-2T6FKPJW.js +0 -356
- package/dist/chunk-4LFRYVSR.js +0 -281
- package/dist/chunk-7OFTYKK4.js +0 -1627
- package/dist/chunk-EI5OMBFE.js +0 -338
- package/dist/chunk-GAOI4KIV.js +0 -379
- package/dist/chunk-NMZUPH3R.js +0 -1133
- package/dist/chunk-QLEQYKG5.js +0 -509
- package/dist/chunk-XJKA22BK.js +0 -197
- package/dist/chunk-ZYTBRHLJ.js +0 -150
package/dist/chip/index.js
CHANGED
|
@@ -1,9 +1,501 @@
|
|
|
1
|
+
import "../chunk-DXXNBF5P.js";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import "
|
|
3
|
+
useXUITheme
|
|
4
|
+
} from "../chunk-LTKYHG5V.js";
|
|
5
|
+
|
|
6
|
+
// src/components/chip/chip.tsx
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { Animated, Easing, Pressable, View } from "react-native";
|
|
9
|
+
|
|
10
|
+
// src/components/chip/chip.style.ts
|
|
11
|
+
import { StyleSheet } from "react-native";
|
|
12
|
+
var styles = StyleSheet.create({
|
|
13
|
+
chip: {
|
|
14
|
+
flexDirection: "row",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
alignSelf: "flex-start"
|
|
17
|
+
},
|
|
18
|
+
text: {
|
|
19
|
+
fontWeight: "500",
|
|
20
|
+
includeFontPadding: false,
|
|
21
|
+
textAlignVertical: "center"
|
|
22
|
+
},
|
|
23
|
+
disabled: {
|
|
24
|
+
opacity: 0.5
|
|
25
|
+
},
|
|
26
|
+
avatar: {
|
|
27
|
+
marginRight: 4
|
|
28
|
+
},
|
|
29
|
+
startContent: {
|
|
30
|
+
marginRight: 4
|
|
31
|
+
},
|
|
32
|
+
endContent: {
|
|
33
|
+
marginLeft: 4
|
|
34
|
+
},
|
|
35
|
+
closeButton: {
|
|
36
|
+
marginLeft: 4,
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
justifyContent: "center"
|
|
39
|
+
},
|
|
40
|
+
dot: {
|
|
41
|
+
borderRadius: 9999,
|
|
42
|
+
marginRight: 6
|
|
43
|
+
},
|
|
44
|
+
groupContainer: {
|
|
45
|
+
flexDirection: "row",
|
|
46
|
+
flexWrap: "wrap"
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// src/components/chip/chip.hook.ts
|
|
51
|
+
import { useMemo } from "react";
|
|
52
|
+
import { getSafeThemeColor, withOpacity } from "@xaui/core";
|
|
53
|
+
var sizeMap = {
|
|
54
|
+
sm: { height: 32, paddingH: 12, fontSize: 13 },
|
|
55
|
+
md: { height: 40, paddingH: 16, fontSize: 15 },
|
|
56
|
+
lg: { height: 44, paddingH: 18, fontSize: 17 }
|
|
57
|
+
};
|
|
58
|
+
var dotSizeMap = {
|
|
59
|
+
sm: 8,
|
|
60
|
+
md: 10,
|
|
61
|
+
lg: 11
|
|
62
|
+
};
|
|
63
|
+
var closeSizeMap = {
|
|
64
|
+
sm: 14,
|
|
65
|
+
md: 16,
|
|
66
|
+
lg: 17
|
|
67
|
+
};
|
|
68
|
+
function useChipSizeStyles(size) {
|
|
69
|
+
return useMemo(() => {
|
|
70
|
+
const { height, paddingH, fontSize } = sizeMap[size];
|
|
71
|
+
return { height, paddingHorizontal: paddingH, fontSize };
|
|
72
|
+
}, [size]);
|
|
73
|
+
}
|
|
74
|
+
function useChipDotSize(size) {
|
|
75
|
+
return useMemo(() => dotSizeMap[size], [size]);
|
|
76
|
+
}
|
|
77
|
+
function useChipCloseSize(size) {
|
|
78
|
+
return useMemo(() => closeSizeMap[size], [size]);
|
|
79
|
+
}
|
|
80
|
+
function useChipRadiusStyles(radius, height) {
|
|
81
|
+
const theme = useXUITheme();
|
|
82
|
+
return useMemo(() => {
|
|
83
|
+
if (radius === "full") {
|
|
84
|
+
return { borderRadius: height / 2 };
|
|
85
|
+
}
|
|
86
|
+
return { borderRadius: theme.borderRadius[radius] };
|
|
87
|
+
}, [height, radius, theme.borderRadius]);
|
|
88
|
+
}
|
|
89
|
+
function useChipVariantStyles(themeColor, variant) {
|
|
90
|
+
const theme = useXUITheme();
|
|
91
|
+
const safeColor = getSafeThemeColor(themeColor);
|
|
92
|
+
const colorScheme = theme.colors[safeColor];
|
|
93
|
+
return useMemo(() => {
|
|
94
|
+
switch (variant) {
|
|
95
|
+
case "bordered":
|
|
96
|
+
return {
|
|
97
|
+
backgroundColor: "transparent",
|
|
98
|
+
color: colorScheme.main,
|
|
99
|
+
borderWidth: 2,
|
|
100
|
+
borderColor: colorScheme.main
|
|
101
|
+
};
|
|
102
|
+
case "light":
|
|
103
|
+
return {
|
|
104
|
+
backgroundColor: "transparent",
|
|
105
|
+
color: colorScheme.main
|
|
106
|
+
};
|
|
107
|
+
case "flat":
|
|
108
|
+
return {
|
|
109
|
+
backgroundColor: colorScheme.background,
|
|
110
|
+
color: colorScheme.main
|
|
111
|
+
};
|
|
112
|
+
case "faded":
|
|
113
|
+
return {
|
|
114
|
+
backgroundColor: withOpacity(colorScheme.background, 0.7),
|
|
115
|
+
color: colorScheme.main,
|
|
116
|
+
borderWidth: 1,
|
|
117
|
+
borderColor: withOpacity(colorScheme.main, 0.3)
|
|
118
|
+
};
|
|
119
|
+
case "shadow":
|
|
120
|
+
return {
|
|
121
|
+
backgroundColor: colorScheme.main,
|
|
122
|
+
color: colorScheme.foreground,
|
|
123
|
+
shadow: theme.shadows.sm
|
|
124
|
+
};
|
|
125
|
+
case "dot":
|
|
126
|
+
return {
|
|
127
|
+
backgroundColor: colorScheme.background,
|
|
128
|
+
color: colorScheme.main,
|
|
129
|
+
dotColor: colorScheme.main
|
|
130
|
+
};
|
|
131
|
+
case "solid":
|
|
132
|
+
default:
|
|
133
|
+
return {
|
|
134
|
+
backgroundColor: colorScheme.main,
|
|
135
|
+
color: colorScheme.foreground
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}, [colorScheme, theme, variant]);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// src/components/chip/chip.tsx
|
|
142
|
+
var Chip = ({
|
|
143
|
+
children,
|
|
144
|
+
variant = "solid",
|
|
145
|
+
themeColor = "default",
|
|
146
|
+
size = "md",
|
|
147
|
+
radius = "full",
|
|
148
|
+
avatar,
|
|
149
|
+
startContent,
|
|
150
|
+
endContent,
|
|
151
|
+
isDisabled = false,
|
|
152
|
+
customAppearance,
|
|
153
|
+
onClose,
|
|
154
|
+
onPress
|
|
155
|
+
}) => {
|
|
156
|
+
const [isClosed, setIsClosed] = React.useState(false);
|
|
157
|
+
const [isClosing, setIsClosing] = React.useState(false);
|
|
158
|
+
const sizeStyles = useChipSizeStyles(size);
|
|
159
|
+
const radiusStyles = useChipRadiusStyles(radius, sizeStyles.height);
|
|
160
|
+
const variantStyles = useChipVariantStyles(themeColor, variant);
|
|
161
|
+
const dotSize = useChipDotSize(size);
|
|
162
|
+
const closeSize = useChipCloseSize(size);
|
|
163
|
+
const isDotVariant = variant === "dot";
|
|
164
|
+
const hasClose = onClose !== void 0;
|
|
165
|
+
const isInteractive = onPress !== void 0 || hasClose;
|
|
166
|
+
const scale = React.useRef(new Animated.Value(1)).current;
|
|
167
|
+
const opacity = React.useRef(new Animated.Value(1)).current;
|
|
168
|
+
const isClosingRef = React.useRef(false);
|
|
169
|
+
const colorProgress = React.useRef(new Animated.Value(1)).current;
|
|
170
|
+
const targetBackgroundColor = variantStyles.backgroundColor ?? "transparent";
|
|
171
|
+
const targetBorderColor = variantStyles.borderColor ?? "transparent";
|
|
172
|
+
const targetTextColor = variantStyles.color ?? "#000000";
|
|
173
|
+
const targetDotColor = variantStyles.dotColor ?? targetTextColor;
|
|
174
|
+
const previousColorsRef = React.useRef({
|
|
175
|
+
backgroundColor: targetBackgroundColor,
|
|
176
|
+
borderColor: targetBorderColor,
|
|
177
|
+
textColor: targetTextColor,
|
|
178
|
+
dotColor: targetDotColor
|
|
179
|
+
});
|
|
180
|
+
React.useEffect(() => {
|
|
181
|
+
if (previousColorsRef.current.backgroundColor === targetBackgroundColor && previousColorsRef.current.borderColor === targetBorderColor && previousColorsRef.current.textColor === targetTextColor && previousColorsRef.current.dotColor === targetDotColor) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
colorProgress.setValue(0);
|
|
185
|
+
Animated.timing(colorProgress, {
|
|
186
|
+
toValue: 1,
|
|
187
|
+
duration: 180,
|
|
188
|
+
easing: Easing.out(Easing.cubic),
|
|
189
|
+
useNativeDriver: false
|
|
190
|
+
}).start(() => {
|
|
191
|
+
previousColorsRef.current = {
|
|
192
|
+
backgroundColor: targetBackgroundColor,
|
|
193
|
+
borderColor: targetBorderColor,
|
|
194
|
+
textColor: targetTextColor,
|
|
195
|
+
dotColor: targetDotColor
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
}, [
|
|
199
|
+
colorProgress,
|
|
200
|
+
targetBackgroundColor,
|
|
201
|
+
targetBorderColor,
|
|
202
|
+
targetTextColor,
|
|
203
|
+
targetDotColor
|
|
204
|
+
]);
|
|
205
|
+
const animatedBackgroundColor = colorProgress.interpolate({
|
|
206
|
+
inputRange: [0, 1],
|
|
207
|
+
outputRange: [previousColorsRef.current.backgroundColor, targetBackgroundColor]
|
|
208
|
+
});
|
|
209
|
+
const animatedBorderColor = colorProgress.interpolate({
|
|
210
|
+
inputRange: [0, 1],
|
|
211
|
+
outputRange: [previousColorsRef.current.borderColor, targetBorderColor]
|
|
212
|
+
});
|
|
213
|
+
const animatedTextColor = colorProgress.interpolate({
|
|
214
|
+
inputRange: [0, 1],
|
|
215
|
+
outputRange: [previousColorsRef.current.textColor, targetTextColor]
|
|
216
|
+
});
|
|
217
|
+
const animatedDotColor = colorProgress.interpolate({
|
|
218
|
+
inputRange: [0, 1],
|
|
219
|
+
outputRange: [previousColorsRef.current.dotColor, targetDotColor]
|
|
220
|
+
});
|
|
221
|
+
const handlePressIn = React.useCallback(() => {
|
|
222
|
+
if (!isInteractive || isDisabled || isClosing || hasClose) return;
|
|
223
|
+
Animated.timing(scale, {
|
|
224
|
+
toValue: 0.97,
|
|
225
|
+
duration: 90,
|
|
226
|
+
easing: Easing.out(Easing.cubic),
|
|
227
|
+
useNativeDriver: true
|
|
228
|
+
}).start();
|
|
229
|
+
}, [hasClose, isInteractive, isClosing, isDisabled, scale]);
|
|
230
|
+
const handlePressOut = React.useCallback(() => {
|
|
231
|
+
if (!isInteractive || isDisabled || isClosing || hasClose) return;
|
|
232
|
+
Animated.timing(scale, {
|
|
233
|
+
toValue: 1,
|
|
234
|
+
duration: 120,
|
|
235
|
+
easing: Easing.out(Easing.cubic),
|
|
236
|
+
useNativeDriver: true
|
|
237
|
+
}).start();
|
|
238
|
+
}, [hasClose, isInteractive, isClosing, isDisabled, scale]);
|
|
239
|
+
const handleChipPress = React.useCallback(() => {
|
|
240
|
+
if (isDisabled || isClosing || isClosingRef.current) return;
|
|
241
|
+
if (hasClose && onClose) {
|
|
242
|
+
isClosingRef.current = true;
|
|
243
|
+
setIsClosing(true);
|
|
244
|
+
Animated.parallel([
|
|
245
|
+
Animated.timing(opacity, {
|
|
246
|
+
toValue: 0,
|
|
247
|
+
duration: 180,
|
|
248
|
+
easing: Easing.in(Easing.quad),
|
|
249
|
+
useNativeDriver: true
|
|
250
|
+
}),
|
|
251
|
+
Animated.timing(scale, {
|
|
252
|
+
toValue: 0.88,
|
|
253
|
+
duration: 180,
|
|
254
|
+
easing: Easing.in(Easing.quad),
|
|
255
|
+
useNativeDriver: true
|
|
256
|
+
})
|
|
257
|
+
]).start(() => {
|
|
258
|
+
setIsClosed(true);
|
|
259
|
+
onClose();
|
|
260
|
+
setIsClosing(false);
|
|
261
|
+
isClosingRef.current = false;
|
|
262
|
+
});
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
onPress?.();
|
|
266
|
+
}, [hasClose, isClosing, isDisabled, onClose, onPress, opacity, scale]);
|
|
267
|
+
if (isClosed) {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
const chipContent = /* @__PURE__ */ React.createElement(Animated.View, { style: { transform: [{ scale }], opacity } }, /* @__PURE__ */ React.createElement(
|
|
271
|
+
Animated.View,
|
|
272
|
+
{
|
|
273
|
+
style: [
|
|
274
|
+
styles.chip,
|
|
275
|
+
{
|
|
276
|
+
height: sizeStyles.height,
|
|
277
|
+
paddingHorizontal: sizeStyles.paddingHorizontal,
|
|
278
|
+
backgroundColor: animatedBackgroundColor,
|
|
279
|
+
borderWidth: variantStyles.borderWidth,
|
|
280
|
+
borderColor: animatedBorderColor
|
|
281
|
+
},
|
|
282
|
+
radiusStyles,
|
|
283
|
+
variantStyles.shadow,
|
|
284
|
+
isDisabled && styles.disabled,
|
|
285
|
+
customAppearance?.container
|
|
286
|
+
],
|
|
287
|
+
accessible: true,
|
|
288
|
+
accessibilityRole: "text"
|
|
289
|
+
},
|
|
290
|
+
isDotVariant && /* @__PURE__ */ React.createElement(
|
|
291
|
+
Animated.View,
|
|
292
|
+
{
|
|
293
|
+
style: [
|
|
294
|
+
styles.dot,
|
|
295
|
+
{
|
|
296
|
+
width: dotSize,
|
|
297
|
+
height: dotSize,
|
|
298
|
+
backgroundColor: animatedDotColor
|
|
299
|
+
},
|
|
300
|
+
customAppearance?.dot
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
avatar && /* @__PURE__ */ React.createElement(View, { style: styles.avatar }, avatar),
|
|
305
|
+
startContent && !avatar && /* @__PURE__ */ React.createElement(View, { style: styles.startContent }, startContent),
|
|
306
|
+
/* @__PURE__ */ React.createElement(
|
|
307
|
+
Animated.Text,
|
|
308
|
+
{
|
|
309
|
+
style: [
|
|
310
|
+
styles.text,
|
|
311
|
+
{ fontSize: sizeStyles.fontSize, color: animatedTextColor },
|
|
312
|
+
customAppearance?.text
|
|
313
|
+
]
|
|
314
|
+
},
|
|
315
|
+
children
|
|
316
|
+
),
|
|
317
|
+
endContent && !hasClose && /* @__PURE__ */ React.createElement(View, { style: styles.endContent }, endContent),
|
|
318
|
+
hasClose && /* @__PURE__ */ React.createElement(
|
|
319
|
+
View,
|
|
320
|
+
{
|
|
321
|
+
style: [
|
|
322
|
+
styles.closeButton,
|
|
323
|
+
{ width: closeSize, height: closeSize },
|
|
324
|
+
customAppearance?.closeButton
|
|
325
|
+
]
|
|
326
|
+
},
|
|
327
|
+
/* @__PURE__ */ React.createElement(
|
|
328
|
+
Animated.Text,
|
|
329
|
+
{
|
|
330
|
+
style: {
|
|
331
|
+
fontSize: closeSize - 2,
|
|
332
|
+
color: animatedTextColor,
|
|
333
|
+
lineHeight: closeSize
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
"\u2715"
|
|
337
|
+
)
|
|
338
|
+
)
|
|
339
|
+
));
|
|
340
|
+
if (isInteractive) {
|
|
341
|
+
return /* @__PURE__ */ React.createElement(
|
|
342
|
+
Pressable,
|
|
343
|
+
{
|
|
344
|
+
onPress: isDisabled || isClosing ? void 0 : handleChipPress,
|
|
345
|
+
onPressIn: handlePressIn,
|
|
346
|
+
onPressOut: handlePressOut,
|
|
347
|
+
disabled: isDisabled || isClosing
|
|
348
|
+
},
|
|
349
|
+
chipContent
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
return chipContent;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// src/components/chip/chip-group.tsx
|
|
356
|
+
import React2 from "react";
|
|
357
|
+
import { View as View2 } from "react-native";
|
|
358
|
+
|
|
359
|
+
// src/components/chip/chip-context.ts
|
|
360
|
+
import { createContext } from "react";
|
|
361
|
+
var ChipGroupContext = createContext(null);
|
|
362
|
+
|
|
363
|
+
// src/components/chip/chip-group.hook.ts
|
|
364
|
+
import { useCallback, useMemo as useMemo2, useState } from "react";
|
|
365
|
+
function useChipGroupSelection(selectMode, selectedValues, defaultSelectedValues, onSelectionChange) {
|
|
366
|
+
const [internalValues, setInternalValues] = useState(
|
|
367
|
+
defaultSelectedValues ?? []
|
|
368
|
+
);
|
|
369
|
+
const isControlled = selectedValues !== void 0;
|
|
370
|
+
const currentValues = isControlled ? selectedValues : internalValues;
|
|
371
|
+
const onToggle = useCallback(
|
|
372
|
+
(value) => {
|
|
373
|
+
const isSelected = currentValues.includes(value);
|
|
374
|
+
let nextValues;
|
|
375
|
+
if (selectMode === "single") {
|
|
376
|
+
nextValues = isSelected ? [] : [value];
|
|
377
|
+
} else {
|
|
378
|
+
nextValues = isSelected ? currentValues.filter((v) => v !== value) : [...currentValues, value];
|
|
379
|
+
}
|
|
380
|
+
if (!isControlled) {
|
|
381
|
+
setInternalValues(nextValues);
|
|
382
|
+
}
|
|
383
|
+
onSelectionChange?.(nextValues);
|
|
384
|
+
},
|
|
385
|
+
[currentValues, isControlled, onSelectionChange, selectMode]
|
|
386
|
+
);
|
|
387
|
+
return useMemo2(() => ({ currentValues, onToggle }), [currentValues, onToggle]);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// src/components/chip/chip-group.tsx
|
|
391
|
+
var ChipGroup = ({
|
|
392
|
+
children,
|
|
393
|
+
isSelectable = false,
|
|
394
|
+
selectMode = "single",
|
|
395
|
+
variant = "solid",
|
|
396
|
+
themeColor = "default",
|
|
397
|
+
size = "md",
|
|
398
|
+
radius = "full",
|
|
399
|
+
isDisabled = false,
|
|
400
|
+
selectedValues,
|
|
401
|
+
defaultSelectedValues,
|
|
402
|
+
onSelectionChange,
|
|
403
|
+
spacing = 8,
|
|
404
|
+
customAppearance
|
|
405
|
+
}) => {
|
|
406
|
+
const { currentValues, onToggle } = useChipGroupSelection(
|
|
407
|
+
selectMode,
|
|
408
|
+
selectedValues,
|
|
409
|
+
defaultSelectedValues,
|
|
410
|
+
onSelectionChange
|
|
411
|
+
);
|
|
412
|
+
const contextValue = React2.useMemo(
|
|
413
|
+
() => ({
|
|
414
|
+
variant,
|
|
415
|
+
themeColor,
|
|
416
|
+
size,
|
|
417
|
+
radius,
|
|
418
|
+
isDisabled,
|
|
419
|
+
isSelectable,
|
|
420
|
+
selectMode,
|
|
421
|
+
selectedValues: currentValues,
|
|
422
|
+
onToggle
|
|
423
|
+
}),
|
|
424
|
+
[
|
|
425
|
+
variant,
|
|
426
|
+
themeColor,
|
|
427
|
+
size,
|
|
428
|
+
radius,
|
|
429
|
+
isDisabled,
|
|
430
|
+
isSelectable,
|
|
431
|
+
selectMode,
|
|
432
|
+
currentValues,
|
|
433
|
+
onToggle
|
|
434
|
+
]
|
|
435
|
+
);
|
|
436
|
+
return /* @__PURE__ */ React2.createElement(ChipGroupContext.Provider, { value: contextValue }, /* @__PURE__ */ React2.createElement(
|
|
437
|
+
View2,
|
|
438
|
+
{
|
|
439
|
+
style: [
|
|
440
|
+
styles.groupContainer,
|
|
441
|
+
{ gap: spacing },
|
|
442
|
+
customAppearance?.container
|
|
443
|
+
],
|
|
444
|
+
accessible: true
|
|
445
|
+
},
|
|
446
|
+
children
|
|
447
|
+
));
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
// src/components/chip/chip-item.tsx
|
|
451
|
+
import React3, { useContext } from "react";
|
|
452
|
+
function getSelectableVariant(baseVariant, isSelected) {
|
|
453
|
+
if (isSelected) {
|
|
454
|
+
return baseVariant;
|
|
455
|
+
}
|
|
456
|
+
if (baseVariant === "solid" || baseVariant === "shadow") {
|
|
457
|
+
return "bordered";
|
|
458
|
+
}
|
|
459
|
+
return "light";
|
|
460
|
+
}
|
|
461
|
+
var ChipItem = ({
|
|
462
|
+
value,
|
|
463
|
+
children,
|
|
464
|
+
variant,
|
|
465
|
+
themeColor,
|
|
466
|
+
avatar,
|
|
467
|
+
startContent,
|
|
468
|
+
endContent,
|
|
469
|
+
isDisabled,
|
|
470
|
+
customAppearance
|
|
471
|
+
}) => {
|
|
472
|
+
const groupContext = useContext(ChipGroupContext);
|
|
473
|
+
if (!groupContext) {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
const resolvedVariant = variant ?? groupContext.variant;
|
|
477
|
+
const resolvedColor = themeColor ?? groupContext.themeColor;
|
|
478
|
+
const resolvedDisabled = isDisabled ?? groupContext.isDisabled;
|
|
479
|
+
const isSelected = groupContext.selectedValues.includes(value);
|
|
480
|
+
const chipVariant = groupContext.isSelectable ? getSelectableVariant(resolvedVariant, isSelected) : resolvedVariant;
|
|
481
|
+
const handlePress = groupContext.isSelectable ? () => groupContext.onToggle(value) : void 0;
|
|
482
|
+
return /* @__PURE__ */ React3.createElement(
|
|
483
|
+
Chip,
|
|
484
|
+
{
|
|
485
|
+
variant: chipVariant,
|
|
486
|
+
themeColor: resolvedColor,
|
|
487
|
+
size: groupContext.size,
|
|
488
|
+
radius: groupContext.radius,
|
|
489
|
+
isDisabled: resolvedDisabled,
|
|
490
|
+
avatar,
|
|
491
|
+
startContent,
|
|
492
|
+
endContent,
|
|
493
|
+
customAppearance,
|
|
494
|
+
onPress: handlePress
|
|
495
|
+
},
|
|
496
|
+
children
|
|
497
|
+
);
|
|
498
|
+
};
|
|
7
499
|
export {
|
|
8
500
|
Chip,
|
|
9
501
|
ChipGroup,
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// src/core/theme-context.tsx
|
|
2
|
-
import React3, { createContext as createContext2 } from "react";
|
|
3
|
-
import { useColorScheme } from "react-native";
|
|
4
|
-
import { defaultTheme } from "@xaui/core/theme";
|
|
5
|
-
import { colors } from "@xaui/core/palette";
|
|
6
|
-
|
|
7
1
|
// src/core/portal/portal.tsx
|
|
8
2
|
import { useContext, useEffect, useLayoutEffect, useRef } from "react";
|
|
9
3
|
|
|
@@ -57,6 +51,10 @@ var PortalHost = ({ children }) => {
|
|
|
57
51
|
};
|
|
58
52
|
|
|
59
53
|
// src/core/theme-context.tsx
|
|
54
|
+
import React3, { createContext as createContext2 } from "react";
|
|
55
|
+
import { useColorScheme } from "react-native";
|
|
56
|
+
import { defaultTheme } from "@xaui/core/theme";
|
|
57
|
+
import { colors } from "@xaui/core/palette";
|
|
60
58
|
var XUIThemeContext = createContext2(null);
|
|
61
59
|
function XUIProvider({
|
|
62
60
|
children,
|
|
@@ -67,7 +65,7 @@ function XUIProvider({
|
|
|
67
65
|
const theme = React3.useMemo(() => {
|
|
68
66
|
if (!darkTheme && !lightTheme) return defaultTheme;
|
|
69
67
|
const activeTheme = colorScheme === "dark" && darkTheme ? darkTheme : lightTheme;
|
|
70
|
-
const mode = colorScheme === "dark" ? "dark" : "light";
|
|
68
|
+
const mode = colorScheme === "dark" && darkTheme ? "dark" : "light";
|
|
71
69
|
if (!activeTheme) return defaultTheme;
|
|
72
70
|
return {
|
|
73
71
|
...defaultTheme,
|
|
@@ -128,9 +126,6 @@ function useBorderRadiusStyles(radius) {
|
|
|
128
126
|
return borderRadius;
|
|
129
127
|
}
|
|
130
128
|
|
|
131
|
-
// src/core/index.ts
|
|
132
|
-
import { defaultDarkTheme, defaultTheme as defaultTheme2 } from "@xaui/core/theme";
|
|
133
|
-
|
|
134
129
|
export {
|
|
135
130
|
Portal,
|
|
136
131
|
PortalHost,
|
|
@@ -139,7 +134,5 @@ export {
|
|
|
139
134
|
useXUITheme,
|
|
140
135
|
useXUIColors,
|
|
141
136
|
useXUIPalette,
|
|
142
|
-
useBorderRadiusStyles
|
|
143
|
-
defaultDarkTheme,
|
|
144
|
-
defaultTheme2 as defaultTheme
|
|
137
|
+
useBorderRadiusStyles
|
|
145
138
|
};
|
package/dist/core/index.cjs
CHANGED
|
@@ -110,7 +110,7 @@ function XUIProvider({
|
|
|
110
110
|
const theme = import_react4.default.useMemo(() => {
|
|
111
111
|
if (!darkTheme && !lightTheme) return import_theme.defaultTheme;
|
|
112
112
|
const activeTheme = colorScheme === "dark" && darkTheme ? darkTheme : lightTheme;
|
|
113
|
-
const mode = colorScheme === "dark" ? "dark" : "light";
|
|
113
|
+
const mode = colorScheme === "dark" && darkTheme ? "dark" : "light";
|
|
114
114
|
if (!activeTheme) return import_theme.defaultTheme;
|
|
115
115
|
return {
|
|
116
116
|
...import_theme.defaultTheme,
|
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,
|