@xaui/native 0.2.7 → 0.9.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-JDS6KGCM.cjs +791 -0
- package/dist/chunk-T3ZI2PZ6.js +791 -0
- package/dist/index.cjs +32 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +32 -0
- package/dist/theme/index.cjs +32 -0
- package/dist/theme/index.d.cts +669 -0
- package/dist/theme/index.d.ts +669 -0
- package/dist/theme/index.js +32 -0
- package/package.json +26 -249
- package/README.md +0 -178
- package/dist/alert/index.cjs +0 -356
- package/dist/alert/index.d.cts +0 -90
- package/dist/alert/index.d.ts +0 -90
- package/dist/alert/index.js +0 -356
- package/dist/app-bar/index.cjs +0 -148
- package/dist/app-bar/index.d.cts +0 -59
- package/dist/app-bar/index.d.ts +0 -59
- package/dist/app-bar/index.js +0 -148
- package/dist/autocomplete/index.cjs +0 -1122
- package/dist/autocomplete/index.d.cts +0 -88
- package/dist/autocomplete/index.d.ts +0 -88
- package/dist/autocomplete/index.js +0 -1122
- package/dist/avatar/index.cjs +0 -281
- package/dist/avatar/index.d.cts +0 -123
- package/dist/avatar/index.d.ts +0 -123
- package/dist/avatar/index.js +0 -281
- package/dist/badge/index.cjs +0 -197
- package/dist/badge/index.d.cts +0 -94
- package/dist/badge/index.d.ts +0 -94
- package/dist/badge/index.js +0 -197
- package/dist/bottom-sheet/index.cjs +0 -9
- package/dist/bottom-sheet/index.d.cts +0 -84
- package/dist/bottom-sheet/index.d.ts +0 -84
- package/dist/bottom-sheet/index.js +0 -9
- package/dist/bottom-tab-bar/index.cjs +0 -497
- package/dist/bottom-tab-bar/index.d.cts +0 -211
- package/dist/bottom-tab-bar/index.d.ts +0 -211
- package/dist/bottom-tab-bar/index.js +0 -497
- package/dist/button/index.cjs +0 -392
- package/dist/button/index.d.cts +0 -174
- package/dist/button/index.d.ts +0 -174
- package/dist/button/index.js +0 -392
- package/dist/button.type-j1ZdkkSl.d.cts +0 -4
- package/dist/button.type-j1ZdkkSl.d.ts +0 -4
- package/dist/card/index.cjs +0 -338
- package/dist/card/index.d.cts +0 -191
- package/dist/card/index.d.ts +0 -191
- package/dist/card/index.js +0 -338
- package/dist/carousel/index.cjs +0 -381
- package/dist/carousel/index.d.cts +0 -147
- package/dist/carousel/index.d.ts +0 -147
- package/dist/carousel/index.js +0 -381
- package/dist/chart/index.cjs +0 -1026
- package/dist/chart/index.d.cts +0 -218
- package/dist/chart/index.d.ts +0 -218
- package/dist/chart/index.js +0 -1026
- package/dist/checkbox/index.cjs +0 -443
- package/dist/checkbox/index.d.cts +0 -73
- package/dist/checkbox/index.d.ts +0 -73
- package/dist/checkbox/index.js +0 -443
- package/dist/chip/index.cjs +0 -503
- package/dist/chip/index.d.cts +0 -195
- package/dist/chip/index.d.ts +0 -195
- package/dist/chip/index.js +0 -503
- package/dist/chunk-4JFWQ5XT.js +0 -368
- package/dist/chunk-56RPWZD2.cjs +0 -9
- package/dist/chunk-7UFBLUMV.cjs +0 -136
- package/dist/chunk-A45TVXU5.js +0 -337
- package/dist/chunk-BYWUAPC4.cjs +0 -368
- package/dist/chunk-DECMUMCI.js +0 -0
- package/dist/chunk-DHSTKO3K.cjs +0 -19
- package/dist/chunk-DJ4Q37UT.cjs +0 -75
- package/dist/chunk-EUQDGTST.cjs +0 -1
- package/dist/chunk-GBHQCAKW.js +0 -19
- package/dist/chunk-RBSA4NH4.js +0 -136
- package/dist/chunk-SHBDANQN.js +0 -9
- package/dist/chunk-UGEINZM7.cjs +0 -290
- package/dist/chunk-UU4HHBDN.js +0 -290
- package/dist/chunk-VSZEXOUN.js +0 -384
- package/dist/chunk-YIEUN3G5.cjs +0 -384
- package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
- package/dist/chunk-ZY7IUTAT.js +0 -75
- package/dist/color-picker/index.cjs +0 -457
- package/dist/color-picker/index.d.cts +0 -124
- package/dist/color-picker/index.d.ts +0 -124
- package/dist/color-picker/index.js +0 -457
- package/dist/core/index.cjs +0 -24
- package/dist/core/index.d.cts +0 -28
- package/dist/core/index.d.ts +0 -28
- package/dist/core/index.js +0 -24
- package/dist/datepicker/index.cjs +0 -1625
- package/dist/datepicker/index.d.cts +0 -45
- package/dist/datepicker/index.d.ts +0 -45
- package/dist/datepicker/index.js +0 -1625
- package/dist/dialog/index.cjs +0 -372
- package/dist/dialog/index.d.cts +0 -151
- package/dist/dialog/index.d.ts +0 -151
- package/dist/dialog/index.js +0 -372
- package/dist/divider/index.cjs +0 -8
- package/dist/divider/index.d.cts +0 -30
- package/dist/divider/index.d.ts +0 -30
- package/dist/divider/index.js +0 -8
- package/dist/drawer/index.cjs +0 -237
- package/dist/drawer/index.d.cts +0 -58
- package/dist/drawer/index.d.ts +0 -58
- package/dist/drawer/index.js +0 -237
- package/dist/expansion-panel/index.cjs +0 -441
- package/dist/expansion-panel/index.d.cts +0 -153
- package/dist/expansion-panel/index.d.ts +0 -153
- package/dist/expansion-panel/index.js +0 -441
- package/dist/fab/index.cjs +0 -9
- package/dist/fab/index.d.cts +0 -10
- package/dist/fab/index.d.ts +0 -10
- package/dist/fab/index.js +0 -9
- package/dist/fab-menu/index.cjs +0 -330
- package/dist/fab-menu/index.d.cts +0 -125
- package/dist/fab-menu/index.d.ts +0 -125
- package/dist/fab-menu/index.js +0 -330
- package/dist/fab.type-CkUHmXU_.d.ts +0 -86
- package/dist/fab.type-DN0vtAh6.d.cts +0 -86
- package/dist/feature-discovery/index.cjs +0 -464
- package/dist/feature-discovery/index.d.cts +0 -82
- package/dist/feature-discovery/index.d.ts +0 -82
- package/dist/feature-discovery/index.js +0 -464
- package/dist/indicator/index.cjs +0 -8
- package/dist/indicator/index.d.cts +0 -47
- package/dist/indicator/index.d.ts +0 -47
- package/dist/indicator/index.js +0 -8
- package/dist/input/index.cjs +0 -1462
- package/dist/input/index.d.cts +0 -522
- package/dist/input/index.d.ts +0 -522
- package/dist/input/index.js +0 -1462
- package/dist/input-trigger/index.cjs +0 -197
- package/dist/input-trigger/index.d.cts +0 -11
- package/dist/input-trigger/index.d.ts +0 -11
- package/dist/input-trigger/index.js +0 -197
- package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
- package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
- package/dist/list/index.cjs +0 -395
- package/dist/list/index.d.cts +0 -188
- package/dist/list/index.d.ts +0 -188
- package/dist/list/index.js +0 -395
- package/dist/menu/index.cjs +0 -316
- package/dist/menu/index.d.cts +0 -115
- package/dist/menu/index.d.ts +0 -115
- package/dist/menu/index.js +0 -316
- package/dist/menubox/index.cjs +0 -297
- package/dist/menubox/index.d.cts +0 -98
- package/dist/menubox/index.d.ts +0 -98
- package/dist/menubox/index.js +0 -297
- package/dist/pager/index.cjs +0 -205
- package/dist/pager/index.d.cts +0 -93
- package/dist/pager/index.d.ts +0 -93
- package/dist/pager/index.js +0 -205
- package/dist/picker/index.cjs +0 -244
- package/dist/picker/index.d.cts +0 -121
- package/dist/picker/index.d.ts +0 -121
- package/dist/picker/index.js +0 -244
- package/dist/progress/index.cjs +0 -219
- package/dist/progress/index.d.cts +0 -47
- package/dist/progress/index.d.ts +0 -47
- package/dist/progress/index.js +0 -219
- package/dist/radio/index.cjs +0 -465
- package/dist/radio/index.d.cts +0 -145
- package/dist/radio/index.d.ts +0 -145
- package/dist/radio/index.js +0 -465
- package/dist/refresh-control/index.cjs +0 -45
- package/dist/refresh-control/index.d.cts +0 -55
- package/dist/refresh-control/index.d.ts +0 -55
- package/dist/refresh-control/index.js +0 -45
- package/dist/segment-button/index.cjs +0 -405
- package/dist/segment-button/index.d.cts +0 -141
- package/dist/segment-button/index.d.ts +0 -141
- package/dist/segment-button/index.js +0 -405
- package/dist/select/index.cjs +0 -878
- package/dist/select/index.d.cts +0 -192
- package/dist/select/index.d.ts +0 -192
- package/dist/select/index.js +0 -878
- package/dist/skeleton/index.cjs +0 -89
- package/dist/skeleton/index.d.cts +0 -45
- package/dist/skeleton/index.d.ts +0 -45
- package/dist/skeleton/index.js +0 -89
- package/dist/slider/index.cjs +0 -576
- package/dist/slider/index.d.cts +0 -171
- package/dist/slider/index.d.ts +0 -171
- package/dist/slider/index.js +0 -576
- package/dist/snackbar/index.cjs +0 -436
- package/dist/snackbar/index.d.cts +0 -174
- package/dist/snackbar/index.d.ts +0 -174
- package/dist/snackbar/index.js +0 -436
- package/dist/snippet/index.cjs +0 -314
- package/dist/snippet/index.d.cts +0 -95
- package/dist/snippet/index.d.ts +0 -95
- package/dist/snippet/index.js +0 -314
- package/dist/stepper/index.cjs +0 -550
- package/dist/stepper/index.d.cts +0 -137
- package/dist/stepper/index.d.ts +0 -137
- package/dist/stepper/index.js +0 -550
- package/dist/switch/index.cjs +0 -358
- package/dist/switch/index.d.cts +0 -28
- package/dist/switch/index.d.ts +0 -28
- package/dist/switch/index.js +0 -358
- package/dist/tabs/index.cjs +0 -440
- package/dist/tabs/index.d.cts +0 -180
- package/dist/tabs/index.d.ts +0 -180
- package/dist/tabs/index.js +0 -440
- package/dist/timepicker/index.cjs +0 -823
- package/dist/timepicker/index.d.cts +0 -215
- package/dist/timepicker/index.d.ts +0 -215
- package/dist/timepicker/index.js +0 -823
- package/dist/toolbar/index.cjs +0 -333
- package/dist/toolbar/index.d.cts +0 -100
- package/dist/toolbar/index.d.ts +0 -100
- package/dist/toolbar/index.js +0 -333
- package/dist/typography/index.cjs +0 -238
- package/dist/typography/index.d.cts +0 -113
- package/dist/typography/index.d.ts +0 -113
- package/dist/typography/index.js +0 -238
- package/dist/view/index.cjs +0 -1361
- package/dist/view/index.d.cts +0 -833
- package/dist/view/index.d.ts +0 -833
- package/dist/view/index.js +0 -1361
package/dist/chip/index.cjs
DELETED
|
@@ -1,503 +0,0 @@
|
|
|
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; }require('../chunk-56RPWZD2.cjs');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunk7UFBLUMVcjs = require('../chunk-7UFBLUMV.cjs');
|
|
5
|
-
|
|
6
|
-
// src/components/chip/chip.tsx
|
|
7
|
-
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
8
|
-
var _reactnative = require('react-native');
|
|
9
|
-
|
|
10
|
-
// src/components/chip/chip.style.ts
|
|
11
|
-
|
|
12
|
-
var styles = _reactnative.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
|
-
|
|
52
|
-
var _core = require('@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 _react.useMemo.call(void 0, () => {
|
|
70
|
-
const { height, paddingH, fontSize } = sizeMap[size];
|
|
71
|
-
return { height, paddingHorizontal: paddingH, fontSize };
|
|
72
|
-
}, [size]);
|
|
73
|
-
}
|
|
74
|
-
function useChipDotSize(size) {
|
|
75
|
-
return _react.useMemo.call(void 0, () => dotSizeMap[size], [size]);
|
|
76
|
-
}
|
|
77
|
-
function useChipCloseSize(size) {
|
|
78
|
-
return _react.useMemo.call(void 0, () => closeSizeMap[size], [size]);
|
|
79
|
-
}
|
|
80
|
-
function useChipRadiusStyles(radius, height) {
|
|
81
|
-
const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
|
|
82
|
-
return _react.useMemo.call(void 0, () => {
|
|
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 = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
|
|
91
|
-
const safeColor = _core.getSafeThemeColor.call(void 0, themeColor);
|
|
92
|
-
const colorScheme = theme.colors[safeColor];
|
|
93
|
-
return _react.useMemo.call(void 0, () => {
|
|
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.container,
|
|
110
|
-
color: colorScheme.onContainer
|
|
111
|
-
};
|
|
112
|
-
case "faded":
|
|
113
|
-
return {
|
|
114
|
-
backgroundColor: _core.withOpacity.call(void 0, colorScheme.container, 0.7),
|
|
115
|
-
color: colorScheme.onContainer,
|
|
116
|
-
borderWidth: 1,
|
|
117
|
-
borderColor: _core.withOpacity.call(void 0, colorScheme.main, 0.3)
|
|
118
|
-
};
|
|
119
|
-
case "shadow":
|
|
120
|
-
return {
|
|
121
|
-
backgroundColor: colorScheme.main,
|
|
122
|
-
color: colorScheme.onMain,
|
|
123
|
-
shadow: theme.shadows.sm
|
|
124
|
-
};
|
|
125
|
-
case "dot":
|
|
126
|
-
return {
|
|
127
|
-
backgroundColor: colorScheme.container,
|
|
128
|
-
color: colorScheme.onContainer,
|
|
129
|
-
dotColor: colorScheme.main
|
|
130
|
-
};
|
|
131
|
-
case "solid":
|
|
132
|
-
default:
|
|
133
|
-
return {
|
|
134
|
-
backgroundColor: colorScheme.main,
|
|
135
|
-
color: colorScheme.onMain
|
|
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] = _react2.default.useState(false);
|
|
157
|
-
const [isClosing, setIsClosing] = _react2.default.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 = _react2.default.useRef(new _reactnative.Animated.Value(1)).current;
|
|
167
|
-
const opacity = _react2.default.useRef(new _reactnative.Animated.Value(1)).current;
|
|
168
|
-
const isClosingRef = _react2.default.useRef(false);
|
|
169
|
-
const colorProgress = _react2.default.useRef(new _reactnative.Animated.Value(1)).current;
|
|
170
|
-
const targetBackgroundColor = _nullishCoalesce(variantStyles.backgroundColor, () => ( "transparent"));
|
|
171
|
-
const targetBorderColor = _nullishCoalesce(variantStyles.borderColor, () => ( "transparent"));
|
|
172
|
-
const targetTextColor = _nullishCoalesce(variantStyles.color, () => ( "#000000"));
|
|
173
|
-
const targetDotColor = _nullishCoalesce(variantStyles.dotColor, () => ( targetTextColor));
|
|
174
|
-
const previousColorsRef = _react2.default.useRef({
|
|
175
|
-
backgroundColor: targetBackgroundColor,
|
|
176
|
-
borderColor: targetBorderColor,
|
|
177
|
-
textColor: targetTextColor,
|
|
178
|
-
dotColor: targetDotColor
|
|
179
|
-
});
|
|
180
|
-
_react2.default.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
|
-
_reactnative.Animated.timing(colorProgress, {
|
|
186
|
-
toValue: 1,
|
|
187
|
-
duration: 180,
|
|
188
|
-
easing: _reactnative.Easing.out(_reactnative.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 = _react2.default.useCallback(() => {
|
|
222
|
-
if (!isInteractive || isDisabled || isClosing || hasClose) return;
|
|
223
|
-
_reactnative.Animated.timing(scale, {
|
|
224
|
-
toValue: 0.97,
|
|
225
|
-
duration: 90,
|
|
226
|
-
easing: _reactnative.Easing.out(_reactnative.Easing.cubic),
|
|
227
|
-
useNativeDriver: true
|
|
228
|
-
}).start();
|
|
229
|
-
}, [hasClose, isInteractive, isClosing, isDisabled, scale]);
|
|
230
|
-
const handlePressOut = _react2.default.useCallback(() => {
|
|
231
|
-
if (!isInteractive || isDisabled || isClosing || hasClose) return;
|
|
232
|
-
_reactnative.Animated.timing(scale, {
|
|
233
|
-
toValue: 1,
|
|
234
|
-
duration: 120,
|
|
235
|
-
easing: _reactnative.Easing.out(_reactnative.Easing.cubic),
|
|
236
|
-
useNativeDriver: true
|
|
237
|
-
}).start();
|
|
238
|
-
}, [hasClose, isInteractive, isClosing, isDisabled, scale]);
|
|
239
|
-
const handleChipPress = _react2.default.useCallback(() => {
|
|
240
|
-
if (isDisabled || isClosing || isClosingRef.current) return;
|
|
241
|
-
if (hasClose && onClose) {
|
|
242
|
-
isClosingRef.current = true;
|
|
243
|
-
setIsClosing(true);
|
|
244
|
-
_reactnative.Animated.parallel([
|
|
245
|
-
_reactnative.Animated.timing(opacity, {
|
|
246
|
-
toValue: 0,
|
|
247
|
-
duration: 180,
|
|
248
|
-
easing: _reactnative.Easing.in(_reactnative.Easing.quad),
|
|
249
|
-
useNativeDriver: true
|
|
250
|
-
}),
|
|
251
|
-
_reactnative.Animated.timing(scale, {
|
|
252
|
-
toValue: 0.88,
|
|
253
|
-
duration: 180,
|
|
254
|
-
easing: _reactnative.Easing.in(_reactnative.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
|
-
_optionalChain([onPress, 'optionalCall', _ => _()]);
|
|
266
|
-
}, [hasClose, isClosing, isDisabled, onClose, onPress, opacity, scale]);
|
|
267
|
-
if (isClosed) {
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
const chipContent = /* @__PURE__ */ _react2.default.createElement(_reactnative.Animated.View, { style: { transform: [{ scale }], opacity } }, /* @__PURE__ */ _react2.default.createElement(
|
|
271
|
-
_reactnative.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
|
-
_optionalChain([customAppearance, 'optionalAccess', _2 => _2.container])
|
|
286
|
-
],
|
|
287
|
-
accessible: true,
|
|
288
|
-
accessibilityRole: "text"
|
|
289
|
-
},
|
|
290
|
-
isDotVariant && /* @__PURE__ */ _react2.default.createElement(
|
|
291
|
-
_reactnative.Animated.View,
|
|
292
|
-
{
|
|
293
|
-
style: [
|
|
294
|
-
styles.dot,
|
|
295
|
-
{
|
|
296
|
-
width: dotSize,
|
|
297
|
-
height: dotSize,
|
|
298
|
-
backgroundColor: animatedDotColor
|
|
299
|
-
},
|
|
300
|
-
_optionalChain([customAppearance, 'optionalAccess', _3 => _3.dot])
|
|
301
|
-
]
|
|
302
|
-
}
|
|
303
|
-
),
|
|
304
|
-
avatar && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.avatar }, avatar),
|
|
305
|
-
startContent && !avatar && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.startContent }, startContent),
|
|
306
|
-
/* @__PURE__ */ _react2.default.createElement(
|
|
307
|
-
_reactnative.Animated.Text,
|
|
308
|
-
{
|
|
309
|
-
style: [
|
|
310
|
-
styles.text,
|
|
311
|
-
{ fontSize: sizeStyles.fontSize, color: animatedTextColor },
|
|
312
|
-
_optionalChain([customAppearance, 'optionalAccess', _4 => _4.text])
|
|
313
|
-
]
|
|
314
|
-
},
|
|
315
|
-
children
|
|
316
|
-
),
|
|
317
|
-
endContent && !hasClose && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.endContent }, endContent),
|
|
318
|
-
hasClose && /* @__PURE__ */ _react2.default.createElement(
|
|
319
|
-
_reactnative.View,
|
|
320
|
-
{
|
|
321
|
-
style: [
|
|
322
|
-
styles.closeButton,
|
|
323
|
-
{ width: closeSize, height: closeSize },
|
|
324
|
-
_optionalChain([customAppearance, 'optionalAccess', _5 => _5.closeButton])
|
|
325
|
-
]
|
|
326
|
-
},
|
|
327
|
-
/* @__PURE__ */ _react2.default.createElement(
|
|
328
|
-
_reactnative.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__ */ _react2.default.createElement(
|
|
342
|
-
_reactnative.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
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
// src/components/chip/chip-context.ts
|
|
360
|
-
|
|
361
|
-
var ChipGroupContext = _react.createContext.call(void 0, null);
|
|
362
|
-
|
|
363
|
-
// src/components/chip/chip-group.hook.ts
|
|
364
|
-
|
|
365
|
-
function useChipGroupSelection(selectMode, selectedValues, defaultSelectedValues, onSelectionChange) {
|
|
366
|
-
const [internalValues, setInternalValues] = _react.useState.call(void 0,
|
|
367
|
-
_nullishCoalesce(defaultSelectedValues, () => ( []))
|
|
368
|
-
);
|
|
369
|
-
const isControlled = selectedValues !== void 0;
|
|
370
|
-
const currentValues = isControlled ? selectedValues : internalValues;
|
|
371
|
-
const onToggle = _react.useCallback.call(void 0,
|
|
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
|
-
_optionalChain([onSelectionChange, 'optionalCall', _6 => _6(nextValues)]);
|
|
384
|
-
},
|
|
385
|
-
[currentValues, isControlled, onSelectionChange, selectMode]
|
|
386
|
-
);
|
|
387
|
-
return _react.useMemo.call(void 0, () => ({ 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.default.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.default.createElement(ChipGroupContext.Provider, { value: contextValue }, /* @__PURE__ */ _react2.default.createElement(
|
|
437
|
-
_reactnative.View,
|
|
438
|
-
{
|
|
439
|
-
style: [
|
|
440
|
-
styles.groupContainer,
|
|
441
|
-
{ gap: spacing },
|
|
442
|
-
_optionalChain([customAppearance, 'optionalAccess', _7 => _7.container])
|
|
443
|
-
],
|
|
444
|
-
accessible: true
|
|
445
|
-
},
|
|
446
|
-
children
|
|
447
|
-
));
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
// src/components/chip/chip-item.tsx
|
|
451
|
-
|
|
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 = _react.useContext.call(void 0, ChipGroupContext);
|
|
473
|
-
if (!groupContext) {
|
|
474
|
-
return null;
|
|
475
|
-
}
|
|
476
|
-
const resolvedVariant = _nullishCoalesce(variant, () => ( groupContext.variant));
|
|
477
|
-
const resolvedColor = _nullishCoalesce(themeColor, () => ( groupContext.themeColor));
|
|
478
|
-
const resolvedDisabled = _nullishCoalesce(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__ */ _react2.default.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
|
-
};
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
exports.Chip = Chip; exports.ChipGroup = ChipGroup; exports.ChipItem = ChipItem;
|
package/dist/chip/index.d.cts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { ViewStyle, TextStyle } from 'react-native';
|
|
3
|
-
import { ThemeColor } from '@xaui/core/types';
|
|
4
|
-
|
|
5
|
-
type ChipVariant = 'solid' | 'bordered' | 'light' | 'flat' | 'faded' | 'shadow' | 'dot';
|
|
6
|
-
type ChipSize = 'sm' | 'md' | 'lg';
|
|
7
|
-
type ChipRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
8
|
-
type ChipSelectMode = 'single' | 'multiple';
|
|
9
|
-
type ChipCustomAppearance = {
|
|
10
|
-
/**
|
|
11
|
-
* Custom styles for the chip container
|
|
12
|
-
*/
|
|
13
|
-
container?: ViewStyle;
|
|
14
|
-
/**
|
|
15
|
-
* Custom styles for the chip text
|
|
16
|
-
*/
|
|
17
|
-
text?: TextStyle;
|
|
18
|
-
/**
|
|
19
|
-
* Custom styles for the close button
|
|
20
|
-
*/
|
|
21
|
-
closeButton?: ViewStyle;
|
|
22
|
-
/**
|
|
23
|
-
* Custom styles for the dot indicator
|
|
24
|
-
*/
|
|
25
|
-
dot?: ViewStyle;
|
|
26
|
-
};
|
|
27
|
-
type ChipProps = {
|
|
28
|
-
/**
|
|
29
|
-
* The content to display inside the chip.
|
|
30
|
-
*/
|
|
31
|
-
children: ReactNode;
|
|
32
|
-
/**
|
|
33
|
-
* The visual variant of the chip.
|
|
34
|
-
* @default 'solid'
|
|
35
|
-
*/
|
|
36
|
-
variant?: ChipVariant;
|
|
37
|
-
/**
|
|
38
|
-
* The theme color of the chip.
|
|
39
|
-
* @default 'default'
|
|
40
|
-
*/
|
|
41
|
-
themeColor?: ThemeColor;
|
|
42
|
-
/**
|
|
43
|
-
* The size of the chip.
|
|
44
|
-
* @default 'md'
|
|
45
|
-
*/
|
|
46
|
-
size?: ChipSize;
|
|
47
|
-
/**
|
|
48
|
-
* The border radius of the chip.
|
|
49
|
-
* @default 'full'
|
|
50
|
-
*/
|
|
51
|
-
radius?: ChipRadius;
|
|
52
|
-
/**
|
|
53
|
-
* Avatar or image to display at the start.
|
|
54
|
-
*/
|
|
55
|
-
avatar?: ReactNode;
|
|
56
|
-
/**
|
|
57
|
-
* Content to display at the start of the chip.
|
|
58
|
-
*/
|
|
59
|
-
startContent?: ReactNode;
|
|
60
|
-
/**
|
|
61
|
-
* Content to display at the end of the chip.
|
|
62
|
-
*/
|
|
63
|
-
endContent?: ReactNode;
|
|
64
|
-
/**
|
|
65
|
-
* Whether the chip is disabled.
|
|
66
|
-
* @default false
|
|
67
|
-
*/
|
|
68
|
-
isDisabled?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Custom appearance styles for chip parts.
|
|
71
|
-
*/
|
|
72
|
-
customAppearance?: ChipCustomAppearance;
|
|
73
|
-
/**
|
|
74
|
-
* Callback fired when the close button is pressed.
|
|
75
|
-
* When provided, a close button is rendered.
|
|
76
|
-
*/
|
|
77
|
-
onClose?: () => void;
|
|
78
|
-
/**
|
|
79
|
-
* Callback fired when the chip is pressed.
|
|
80
|
-
*/
|
|
81
|
-
onPress?: () => void;
|
|
82
|
-
};
|
|
83
|
-
type ChipItemProps = {
|
|
84
|
-
/**
|
|
85
|
-
* Unique key for the chip item within a group.
|
|
86
|
-
*/
|
|
87
|
-
value: string;
|
|
88
|
-
/**
|
|
89
|
-
* The content to display inside the chip item.
|
|
90
|
-
*/
|
|
91
|
-
children: ReactNode;
|
|
92
|
-
/**
|
|
93
|
-
* The visual variant of the chip item.
|
|
94
|
-
* Overrides the group variant if set.
|
|
95
|
-
*/
|
|
96
|
-
variant?: ChipVariant;
|
|
97
|
-
/**
|
|
98
|
-
* The theme color of the chip item.
|
|
99
|
-
* Overrides the group color if set.
|
|
100
|
-
*/
|
|
101
|
-
themeColor?: ThemeColor;
|
|
102
|
-
/**
|
|
103
|
-
* Avatar or image to display at the start.
|
|
104
|
-
*/
|
|
105
|
-
avatar?: ReactNode;
|
|
106
|
-
/**
|
|
107
|
-
* Content to display at the start of the chip.
|
|
108
|
-
*/
|
|
109
|
-
startContent?: ReactNode;
|
|
110
|
-
/**
|
|
111
|
-
* Content to display at the end of the chip.
|
|
112
|
-
*/
|
|
113
|
-
endContent?: ReactNode;
|
|
114
|
-
/**
|
|
115
|
-
* Whether the chip item is disabled.
|
|
116
|
-
* @default false
|
|
117
|
-
*/
|
|
118
|
-
isDisabled?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Custom appearance styles for chip parts.
|
|
121
|
-
*/
|
|
122
|
-
customAppearance?: ChipCustomAppearance;
|
|
123
|
-
};
|
|
124
|
-
type ChipGroupProps = {
|
|
125
|
-
/**
|
|
126
|
-
* ChipItem children.
|
|
127
|
-
*/
|
|
128
|
-
children: ReactNode;
|
|
129
|
-
/**
|
|
130
|
-
* Whether chips in the group are selectable.
|
|
131
|
-
* @default false
|
|
132
|
-
*/
|
|
133
|
-
isSelectable?: boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Selection mode when isSelectable is true.
|
|
136
|
-
* @default 'single'
|
|
137
|
-
*/
|
|
138
|
-
selectMode?: ChipSelectMode;
|
|
139
|
-
/**
|
|
140
|
-
* The visual variant applied to all chips.
|
|
141
|
-
* @default 'solid'
|
|
142
|
-
*/
|
|
143
|
-
variant?: ChipVariant;
|
|
144
|
-
/**
|
|
145
|
-
* The theme color applied to all chips.
|
|
146
|
-
* @default 'default'
|
|
147
|
-
*/
|
|
148
|
-
themeColor?: ThemeColor;
|
|
149
|
-
/**
|
|
150
|
-
* The size applied to all chips.
|
|
151
|
-
* @default 'md'
|
|
152
|
-
*/
|
|
153
|
-
size?: ChipSize;
|
|
154
|
-
/**
|
|
155
|
-
* The border radius applied to all chips.
|
|
156
|
-
* @default 'full'
|
|
157
|
-
*/
|
|
158
|
-
radius?: ChipRadius;
|
|
159
|
-
/**
|
|
160
|
-
* Whether all chips in the group are disabled.
|
|
161
|
-
* @default false
|
|
162
|
-
*/
|
|
163
|
-
isDisabled?: boolean;
|
|
164
|
-
/**
|
|
165
|
-
* Controlled selected values.
|
|
166
|
-
*/
|
|
167
|
-
selectedValues?: string[];
|
|
168
|
-
/**
|
|
169
|
-
* Default selected values for uncontrolled mode.
|
|
170
|
-
*/
|
|
171
|
-
defaultSelectedValues?: string[];
|
|
172
|
-
/**
|
|
173
|
-
* Callback fired when the selection changes.
|
|
174
|
-
*/
|
|
175
|
-
onSelectionChange?: (values: string[]) => void;
|
|
176
|
-
/**
|
|
177
|
-
* Spacing between chips.
|
|
178
|
-
* @default 8
|
|
179
|
-
*/
|
|
180
|
-
spacing?: number;
|
|
181
|
-
/**
|
|
182
|
-
* Custom appearance styles for the group container.
|
|
183
|
-
*/
|
|
184
|
-
customAppearance?: {
|
|
185
|
-
container?: ViewStyle;
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
declare const Chip: React.FC<ChipProps>;
|
|
190
|
-
|
|
191
|
-
declare const ChipGroup: React.FC<ChipGroupProps>;
|
|
192
|
-
|
|
193
|
-
declare const ChipItem: React.FC<ChipItemProps>;
|
|
194
|
-
|
|
195
|
-
export { Chip, ChipGroup, type ChipGroupProps, ChipItem, type ChipItemProps, type ChipProps, type ChipRadius, type ChipSelectMode, type ChipSize, type ChipVariant };
|