@xaui/native 0.2.8 → 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 -340
- package/dist/alert/index.d.cts +0 -46
- package/dist/alert/index.d.ts +0 -46
- package/dist/alert/index.js +0 -340
- 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/checkbox/index.cjs
DELETED
|
@@ -1,443 +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/checkbox/checkbox.tsx
|
|
7
|
-
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
8
|
-
var _reactnative = require('react-native');
|
|
9
|
-
|
|
10
|
-
// src/components/checkbox/checkbox-icon.tsx
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _reactnativesvg = require('react-native-svg'); var _reactnativesvg2 = _interopRequireDefault(_reactnativesvg);
|
|
14
|
-
|
|
15
|
-
// src/components/checkbox/checkbox.animation.ts
|
|
16
|
-
|
|
17
|
-
var runCheckAnimation = (opacity, strokeDashoffset) => {
|
|
18
|
-
_reactnative.Animated.parallel([
|
|
19
|
-
_reactnative.Animated.timing(opacity, {
|
|
20
|
-
toValue: 1,
|
|
21
|
-
duration: 200,
|
|
22
|
-
useNativeDriver: false
|
|
23
|
-
}),
|
|
24
|
-
_reactnative.Animated.timing(strokeDashoffset, {
|
|
25
|
-
toValue: 44,
|
|
26
|
-
duration: 250,
|
|
27
|
-
useNativeDriver: false
|
|
28
|
-
})
|
|
29
|
-
]).start();
|
|
30
|
-
};
|
|
31
|
-
var runUncheckAnimation = (opacity, strokeDashoffset) => {
|
|
32
|
-
_reactnative.Animated.parallel([
|
|
33
|
-
_reactnative.Animated.timing(opacity, {
|
|
34
|
-
toValue: 0,
|
|
35
|
-
duration: 200,
|
|
36
|
-
useNativeDriver: false
|
|
37
|
-
}),
|
|
38
|
-
_reactnative.Animated.timing(strokeDashoffset, {
|
|
39
|
-
toValue: 66,
|
|
40
|
-
duration: 250,
|
|
41
|
-
useNativeDriver: false
|
|
42
|
-
})
|
|
43
|
-
]).start();
|
|
44
|
-
};
|
|
45
|
-
var runBackgroundInAnimation = (backgroundScale, backgroundOpacity) => {
|
|
46
|
-
_reactnative.Animated.parallel([
|
|
47
|
-
_reactnative.Animated.timing(backgroundScale, {
|
|
48
|
-
toValue: 1,
|
|
49
|
-
duration: 200,
|
|
50
|
-
useNativeDriver: true
|
|
51
|
-
}),
|
|
52
|
-
_reactnative.Animated.timing(backgroundOpacity, {
|
|
53
|
-
toValue: 1,
|
|
54
|
-
duration: 200,
|
|
55
|
-
useNativeDriver: true
|
|
56
|
-
})
|
|
57
|
-
]).start();
|
|
58
|
-
};
|
|
59
|
-
var runBackgroundOutAnimation = (backgroundScale, backgroundOpacity) => {
|
|
60
|
-
_reactnative.Animated.parallel([
|
|
61
|
-
_reactnative.Animated.timing(backgroundScale, {
|
|
62
|
-
toValue: 0.5,
|
|
63
|
-
duration: 200,
|
|
64
|
-
useNativeDriver: true
|
|
65
|
-
}),
|
|
66
|
-
_reactnative.Animated.timing(backgroundOpacity, {
|
|
67
|
-
toValue: 0,
|
|
68
|
-
duration: 200,
|
|
69
|
-
useNativeDriver: true
|
|
70
|
-
})
|
|
71
|
-
]).start();
|
|
72
|
-
};
|
|
73
|
-
var runPressInAnimation = (scale) => {
|
|
74
|
-
_reactnative.Animated.spring(scale, {
|
|
75
|
-
toValue: 0.95,
|
|
76
|
-
useNativeDriver: true
|
|
77
|
-
}).start();
|
|
78
|
-
};
|
|
79
|
-
var runPressOutAnimation = (scale) => {
|
|
80
|
-
_reactnative.Animated.spring(scale, {
|
|
81
|
-
toValue: 1,
|
|
82
|
-
useNativeDriver: true
|
|
83
|
-
}).start();
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// src/components/checkbox/checkbox-icon.tsx
|
|
87
|
-
var AnimatedSvg = _reactnative.Animated.createAnimatedComponent(_reactnativesvg2.default);
|
|
88
|
-
var AnimatedPolyline = _reactnative.Animated.createAnimatedComponent(_reactnativesvg.Polyline);
|
|
89
|
-
function CheckIcon({
|
|
90
|
-
isChecked,
|
|
91
|
-
color,
|
|
92
|
-
size
|
|
93
|
-
}) {
|
|
94
|
-
const opacity = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
|
|
95
|
-
const strokeDashoffset = _react.useRef.call(void 0, new _reactnative.Animated.Value(66)).current;
|
|
96
|
-
_react.useEffect.call(void 0, () => {
|
|
97
|
-
if (isChecked) {
|
|
98
|
-
runCheckAnimation(opacity, strokeDashoffset);
|
|
99
|
-
} else {
|
|
100
|
-
runUncheckAnimation(opacity, strokeDashoffset);
|
|
101
|
-
}
|
|
102
|
-
}, [isChecked, opacity, strokeDashoffset]);
|
|
103
|
-
return /* @__PURE__ */ _react2.default.createElement(
|
|
104
|
-
AnimatedSvg,
|
|
105
|
-
{
|
|
106
|
-
width: size,
|
|
107
|
-
height: size,
|
|
108
|
-
viewBox: "0 0 17 18",
|
|
109
|
-
fill: "none",
|
|
110
|
-
opacity
|
|
111
|
-
},
|
|
112
|
-
/* @__PURE__ */ _react2.default.createElement(
|
|
113
|
-
AnimatedPolyline,
|
|
114
|
-
{
|
|
115
|
-
points: "1 9 7 14 15 4",
|
|
116
|
-
stroke: color,
|
|
117
|
-
strokeWidth: 2,
|
|
118
|
-
strokeLinecap: "round",
|
|
119
|
-
strokeLinejoin: "round",
|
|
120
|
-
strokeDasharray: "22",
|
|
121
|
-
strokeDashoffset
|
|
122
|
-
}
|
|
123
|
-
)
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
function PlaceholderCheckIcon({ color, size }) {
|
|
127
|
-
return /* @__PURE__ */ _react2.default.createElement(_reactnativesvg2.default, { width: size, height: size, viewBox: "0 0 17 18" }, /* @__PURE__ */ _react2.default.createElement(
|
|
128
|
-
_reactnativesvg.Path,
|
|
129
|
-
{
|
|
130
|
-
d: "M 1 9 L 7 14 L 15 4",
|
|
131
|
-
stroke: color,
|
|
132
|
-
strokeWidth: 2,
|
|
133
|
-
strokeLinecap: "round",
|
|
134
|
-
strokeLinejoin: "round",
|
|
135
|
-
fill: "none"
|
|
136
|
-
}
|
|
137
|
-
));
|
|
138
|
-
}
|
|
139
|
-
function IndeterminateCheckIcon({
|
|
140
|
-
color,
|
|
141
|
-
size
|
|
142
|
-
}) {
|
|
143
|
-
return /* @__PURE__ */ _react2.default.createElement(_reactnativesvg2.default, { width: size, height: size, viewBox: "0 0 24 24" }, /* @__PURE__ */ _react2.default.createElement(_reactnativesvg.Line, { x1: "21", y1: "12", x2: "3", y2: "12", stroke: color, strokeWidth: 3 }));
|
|
144
|
-
}
|
|
145
|
-
function CheckboxIcon({
|
|
146
|
-
isIndeterminate,
|
|
147
|
-
variant,
|
|
148
|
-
...props
|
|
149
|
-
}) {
|
|
150
|
-
const BaseIcon = isIndeterminate ? IndeterminateCheckIcon : CheckIcon;
|
|
151
|
-
if (variant === "light" && !props.isChecked && !isIndeterminate) {
|
|
152
|
-
return /* @__PURE__ */ _react2.default.createElement(PlaceholderCheckIcon, { size: props.size, color: _nullishCoalesce(props.placeholderColor, () => ( "")) });
|
|
153
|
-
}
|
|
154
|
-
return /* @__PURE__ */ _react2.default.createElement(BaseIcon, { ...props });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// src/components/checkbox/checkbox.hook.ts
|
|
158
|
-
|
|
159
|
-
var _core = require('@xaui/core');
|
|
160
|
-
function useSizeStyles(size, variant) {
|
|
161
|
-
const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
|
|
162
|
-
const sizeStyles = _react.useMemo.call(void 0, () => {
|
|
163
|
-
const sizes = {
|
|
164
|
-
xs: {
|
|
165
|
-
checkboxSize: 14,
|
|
166
|
-
fontSize: theme.fontSizes.xs,
|
|
167
|
-
iconSize: variant === "light" ? 10 : 8
|
|
168
|
-
},
|
|
169
|
-
sm: {
|
|
170
|
-
checkboxSize: 18,
|
|
171
|
-
fontSize: theme.fontSizes.sm,
|
|
172
|
-
iconSize: variant === "light" ? 14 : 12
|
|
173
|
-
},
|
|
174
|
-
md: {
|
|
175
|
-
checkboxSize: 22,
|
|
176
|
-
fontSize: theme.fontSizes.md,
|
|
177
|
-
iconSize: variant === "light" ? 18 : 14
|
|
178
|
-
},
|
|
179
|
-
lg: {
|
|
180
|
-
checkboxSize: 26,
|
|
181
|
-
fontSize: theme.fontSizes.lg,
|
|
182
|
-
iconSize: variant === "light" ? 22 : 16
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
return sizes[size];
|
|
186
|
-
}, [size, variant, theme]);
|
|
187
|
-
return sizeStyles;
|
|
188
|
-
}
|
|
189
|
-
function useRadiusStyles(radius) {
|
|
190
|
-
const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
|
|
191
|
-
const radiusStyles = _react.useMemo.call(void 0, () => {
|
|
192
|
-
const radii = {
|
|
193
|
-
none: theme.borderRadius.none,
|
|
194
|
-
sm: theme.borderRadius.sm,
|
|
195
|
-
md: theme.borderRadius.md,
|
|
196
|
-
lg: theme.borderRadius.lg,
|
|
197
|
-
full: theme.borderRadius.full
|
|
198
|
-
};
|
|
199
|
-
return { borderRadius: radii[radius] };
|
|
200
|
-
}, [radius, theme]);
|
|
201
|
-
return radiusStyles;
|
|
202
|
-
}
|
|
203
|
-
function useCheckmarkColors(themeColor, variant, isActive) {
|
|
204
|
-
const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
|
|
205
|
-
const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
|
|
206
|
-
const colorScheme = theme.colors[safeThemeColor];
|
|
207
|
-
const checkmarkColors = _react.useMemo.call(void 0, () => {
|
|
208
|
-
if (variant === "filled") {
|
|
209
|
-
return {
|
|
210
|
-
checked: colorScheme.onMain,
|
|
211
|
-
unchecked: void 0
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
if (isActive) {
|
|
215
|
-
return {
|
|
216
|
-
checked: colorScheme.main,
|
|
217
|
-
unchecked: void 0
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
if (themeColor !== "default") {
|
|
221
|
-
return {
|
|
222
|
-
checked: colorScheme.onMain,
|
|
223
|
-
unchecked: colorScheme.container
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
return {
|
|
227
|
-
checked: theme.colors.foreground,
|
|
228
|
-
unchecked: colorScheme.container
|
|
229
|
-
};
|
|
230
|
-
}, [variant, colorScheme, isActive, themeColor, theme.colors]);
|
|
231
|
-
return checkmarkColors;
|
|
232
|
-
}
|
|
233
|
-
function useVariantStyles(themeColor, variant, isActive) {
|
|
234
|
-
const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
|
|
235
|
-
const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
|
|
236
|
-
const colorScheme = theme.colors[safeThemeColor];
|
|
237
|
-
const variantStyles = _react.useMemo.call(void 0, () => {
|
|
238
|
-
if (variant === "filled") {
|
|
239
|
-
return {
|
|
240
|
-
backgroundColor: isActive ? colorScheme.main : "transparent",
|
|
241
|
-
borderWidth: isActive ? 0 : theme.borderWidth.md,
|
|
242
|
-
borderColor: isActive ? "transparent" : colorScheme.main
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
return {
|
|
246
|
-
backgroundColor: "transparent",
|
|
247
|
-
borderWidth: 0,
|
|
248
|
-
borderColor: "transparent"
|
|
249
|
-
};
|
|
250
|
-
}, [variant, isActive, colorScheme, theme]);
|
|
251
|
-
return variantStyles;
|
|
252
|
-
}
|
|
253
|
-
function useContainerStyles(labelAlignment) {
|
|
254
|
-
const containerStyles = _react.useMemo.call(void 0, () => {
|
|
255
|
-
const isJustified = labelAlignment === "justify-left" || labelAlignment === "justify-right";
|
|
256
|
-
return {
|
|
257
|
-
flexDirection: labelAlignment === "left" || labelAlignment === "justify-left" ? "row-reverse" : "row",
|
|
258
|
-
justifyContent: isJustified ? "space-between" : "flex-start"
|
|
259
|
-
};
|
|
260
|
-
}, [labelAlignment]);
|
|
261
|
-
return containerStyles;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// src/components/checkbox/checkbox.style.ts
|
|
265
|
-
|
|
266
|
-
var styles = _reactnative.StyleSheet.create({
|
|
267
|
-
container: {
|
|
268
|
-
flexDirection: "row",
|
|
269
|
-
alignItems: "center",
|
|
270
|
-
gap: 10
|
|
271
|
-
},
|
|
272
|
-
fullWidth: {
|
|
273
|
-
flexShrink: 1,
|
|
274
|
-
flexBasis: "auto",
|
|
275
|
-
width: "100%"
|
|
276
|
-
},
|
|
277
|
-
checkbox: {
|
|
278
|
-
alignItems: "center",
|
|
279
|
-
justifyContent: "center",
|
|
280
|
-
overflow: "hidden",
|
|
281
|
-
position: "relative"
|
|
282
|
-
},
|
|
283
|
-
background: {
|
|
284
|
-
position: "absolute",
|
|
285
|
-
width: "100%",
|
|
286
|
-
height: "100%"
|
|
287
|
-
},
|
|
288
|
-
checkmarkContainer: {
|
|
289
|
-
alignItems: "center",
|
|
290
|
-
justifyContent: "center",
|
|
291
|
-
zIndex: 10
|
|
292
|
-
},
|
|
293
|
-
label: {
|
|
294
|
-
fontWeight: "400"
|
|
295
|
-
},
|
|
296
|
-
disabled: {
|
|
297
|
-
opacity: 0.5
|
|
298
|
-
},
|
|
299
|
-
disabledText: {
|
|
300
|
-
opacity: 0.7
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
// src/components/checkbox/checkbox.tsx
|
|
305
|
-
|
|
306
|
-
var Checkbox = ({
|
|
307
|
-
label,
|
|
308
|
-
labelAlignment = "right",
|
|
309
|
-
themeColor = "primary",
|
|
310
|
-
variant = "filled",
|
|
311
|
-
size = "md",
|
|
312
|
-
radius = "sm",
|
|
313
|
-
fullWidth = false,
|
|
314
|
-
isChecked: isCheckedProp,
|
|
315
|
-
isIndeterminate = false,
|
|
316
|
-
isDisabled = false,
|
|
317
|
-
labelStyle,
|
|
318
|
-
style,
|
|
319
|
-
onValueChange
|
|
320
|
-
}) => {
|
|
321
|
-
const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
|
|
322
|
-
const colorScheme = theme.colors[_core.getSafeThemeColor.call(void 0, themeColor)];
|
|
323
|
-
const isControlled = typeof isCheckedProp === "boolean";
|
|
324
|
-
const [internalChecked, setInternalChecked] = _react.useState.call(void 0, _nullishCoalesce(isCheckedProp, () => ( false)));
|
|
325
|
-
const isChecked = isControlled ? isCheckedProp : internalChecked;
|
|
326
|
-
const scale = _react.useRef.call(void 0, new _reactnative.Animated.Value(1)).current;
|
|
327
|
-
const backgroundScale = _react.useRef.call(void 0, new _reactnative.Animated.Value(0.5)).current;
|
|
328
|
-
const backgroundOpacity = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
|
|
329
|
-
const isActive = isChecked || isIndeterminate;
|
|
330
|
-
const sizeStyles = useSizeStyles(size, variant);
|
|
331
|
-
const radiusStyles = useRadiusStyles(radius);
|
|
332
|
-
const checkmarkColors = useCheckmarkColors(themeColor, variant, isActive);
|
|
333
|
-
const variantStyles = useVariantStyles(themeColor, variant, isActive);
|
|
334
|
-
const containerStyles = useContainerStyles(labelAlignment);
|
|
335
|
-
_react.useEffect.call(void 0, () => {
|
|
336
|
-
if (variant !== "filled") return;
|
|
337
|
-
if (isActive) {
|
|
338
|
-
runBackgroundInAnimation(backgroundScale, backgroundOpacity);
|
|
339
|
-
} else {
|
|
340
|
-
runBackgroundOutAnimation(backgroundScale, backgroundOpacity);
|
|
341
|
-
}
|
|
342
|
-
}, [isActive, variant, backgroundScale, backgroundOpacity]);
|
|
343
|
-
const handlePress = () => {
|
|
344
|
-
if (!isDisabled) {
|
|
345
|
-
const nextValue = isIndeterminate ? true : !isChecked;
|
|
346
|
-
_optionalChain([onValueChange, 'optionalCall', _ => _(nextValue)]);
|
|
347
|
-
if (!isControlled) {
|
|
348
|
-
setInternalChecked(nextValue);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
const handlePressIn = () => {
|
|
353
|
-
if (!isDisabled) {
|
|
354
|
-
runPressInAnimation(scale);
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
const handlePressOut = () => {
|
|
358
|
-
if (!isDisabled) {
|
|
359
|
-
runPressOutAnimation(scale);
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
const accessibilityChecked = isIndeterminate ? "mixed" : isChecked;
|
|
363
|
-
return /* @__PURE__ */ _react2.default.createElement(
|
|
364
|
-
_reactnative.Pressable,
|
|
365
|
-
{
|
|
366
|
-
onPress: handlePress,
|
|
367
|
-
onPressIn: handlePressIn,
|
|
368
|
-
onPressOut: handlePressOut,
|
|
369
|
-
disabled: isDisabled,
|
|
370
|
-
accessible: true,
|
|
371
|
-
accessibilityRole: "checkbox",
|
|
372
|
-
accessibilityLabel: label,
|
|
373
|
-
accessibilityState: {
|
|
374
|
-
disabled: isDisabled,
|
|
375
|
-
checked: accessibilityChecked
|
|
376
|
-
},
|
|
377
|
-
style: [
|
|
378
|
-
styles.container,
|
|
379
|
-
containerStyles,
|
|
380
|
-
fullWidth && styles.fullWidth,
|
|
381
|
-
isDisabled && styles.disabled,
|
|
382
|
-
style
|
|
383
|
-
]
|
|
384
|
-
},
|
|
385
|
-
/* @__PURE__ */ _react2.default.createElement(
|
|
386
|
-
_reactnative.Animated.View,
|
|
387
|
-
{
|
|
388
|
-
style: [
|
|
389
|
-
styles.checkbox,
|
|
390
|
-
{
|
|
391
|
-
width: sizeStyles.checkboxSize,
|
|
392
|
-
height: sizeStyles.checkboxSize,
|
|
393
|
-
...radiusStyles,
|
|
394
|
-
...variantStyles
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
transform: [{ scale }]
|
|
398
|
-
}
|
|
399
|
-
]
|
|
400
|
-
},
|
|
401
|
-
variant === "filled" && /* @__PURE__ */ _react2.default.createElement(
|
|
402
|
-
_reactnative.Animated.View,
|
|
403
|
-
{
|
|
404
|
-
style: [
|
|
405
|
-
styles.background,
|
|
406
|
-
radiusStyles,
|
|
407
|
-
{
|
|
408
|
-
backgroundColor: colorScheme.main,
|
|
409
|
-
transform: [{ scale: backgroundScale }],
|
|
410
|
-
opacity: backgroundOpacity
|
|
411
|
-
}
|
|
412
|
-
]
|
|
413
|
-
}
|
|
414
|
-
),
|
|
415
|
-
/* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.checkmarkContainer }, /* @__PURE__ */ _react2.default.createElement(
|
|
416
|
-
CheckboxIcon,
|
|
417
|
-
{
|
|
418
|
-
isChecked: isActive,
|
|
419
|
-
isIndeterminate,
|
|
420
|
-
color: checkmarkColors.checked,
|
|
421
|
-
size: sizeStyles.iconSize,
|
|
422
|
-
placeholderColor: checkmarkColors.unchecked,
|
|
423
|
-
variant
|
|
424
|
-
}
|
|
425
|
-
))
|
|
426
|
-
),
|
|
427
|
-
label && /* @__PURE__ */ _react2.default.createElement(
|
|
428
|
-
_reactnative.Text,
|
|
429
|
-
{
|
|
430
|
-
style: [
|
|
431
|
-
styles.label,
|
|
432
|
-
{ fontSize: sizeStyles.fontSize, color: theme.colors.foreground },
|
|
433
|
-
isDisabled && styles.disabledText,
|
|
434
|
-
labelStyle
|
|
435
|
-
]
|
|
436
|
-
},
|
|
437
|
-
label
|
|
438
|
-
)
|
|
439
|
-
);
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
exports.Checkbox = Checkbox;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TextStyle, ViewStyle } from 'react-native';
|
|
3
|
-
import { ThemeColor, Size, Radius } from '@xaui/core/types';
|
|
4
|
-
|
|
5
|
-
type CheckboxVariant = 'filled' | 'light';
|
|
6
|
-
type CheckboxLabelAlignment = 'left' | 'right' | 'justify-left' | 'justify-right';
|
|
7
|
-
type CheckboxProps = {
|
|
8
|
-
/**
|
|
9
|
-
* The label to display alongside the checkbox.
|
|
10
|
-
*/
|
|
11
|
-
label?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Alignment of the label relative to the checkbox.
|
|
14
|
-
* @default 'right'
|
|
15
|
-
*/
|
|
16
|
-
labelAlignment?: CheckboxLabelAlignment;
|
|
17
|
-
/**
|
|
18
|
-
* The theme color of the checkbox.
|
|
19
|
-
* @default 'default'
|
|
20
|
-
*/
|
|
21
|
-
themeColor?: ThemeColor;
|
|
22
|
-
/**
|
|
23
|
-
* The variant of the checkbox.
|
|
24
|
-
* @default 'filled'
|
|
25
|
-
*/
|
|
26
|
-
variant?: CheckboxVariant;
|
|
27
|
-
/**
|
|
28
|
-
* The size of the checkbox.
|
|
29
|
-
* @default 'md'
|
|
30
|
-
*/
|
|
31
|
-
size?: Size;
|
|
32
|
-
/**
|
|
33
|
-
* The border radius of the checkbox.
|
|
34
|
-
* @default 'sm'
|
|
35
|
-
*/
|
|
36
|
-
radius?: Radius;
|
|
37
|
-
/**
|
|
38
|
-
* Whether the checkbox should take the full width of its container.
|
|
39
|
-
* @default false
|
|
40
|
-
*/
|
|
41
|
-
fullWidth?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Whether the checkbox is checked.
|
|
44
|
-
* @default false
|
|
45
|
-
*/
|
|
46
|
-
isChecked?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Whether the checkbox is in an indeterminate state.
|
|
49
|
-
* @default false
|
|
50
|
-
*/
|
|
51
|
-
isIndeterminate?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Whether the checkbox is disabled.
|
|
54
|
-
* @default false
|
|
55
|
-
*/
|
|
56
|
-
isDisabled?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Custom style for the label text.
|
|
59
|
-
*/
|
|
60
|
-
labelStyle?: TextStyle;
|
|
61
|
-
/**
|
|
62
|
-
* Custom style for the checkbox container.
|
|
63
|
-
*/
|
|
64
|
-
style?: ViewStyle;
|
|
65
|
-
/**
|
|
66
|
-
* Callback fired when the checkbox value changes.
|
|
67
|
-
*/
|
|
68
|
-
onValueChange?: (isChecked: boolean) => void;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
declare const Checkbox: React.FC<CheckboxProps>;
|
|
72
|
-
|
|
73
|
-
export { Checkbox, type CheckboxLabelAlignment, type CheckboxProps, type CheckboxVariant };
|
package/dist/checkbox/index.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TextStyle, ViewStyle } from 'react-native';
|
|
3
|
-
import { ThemeColor, Size, Radius } from '@xaui/core/types';
|
|
4
|
-
|
|
5
|
-
type CheckboxVariant = 'filled' | 'light';
|
|
6
|
-
type CheckboxLabelAlignment = 'left' | 'right' | 'justify-left' | 'justify-right';
|
|
7
|
-
type CheckboxProps = {
|
|
8
|
-
/**
|
|
9
|
-
* The label to display alongside the checkbox.
|
|
10
|
-
*/
|
|
11
|
-
label?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Alignment of the label relative to the checkbox.
|
|
14
|
-
* @default 'right'
|
|
15
|
-
*/
|
|
16
|
-
labelAlignment?: CheckboxLabelAlignment;
|
|
17
|
-
/**
|
|
18
|
-
* The theme color of the checkbox.
|
|
19
|
-
* @default 'default'
|
|
20
|
-
*/
|
|
21
|
-
themeColor?: ThemeColor;
|
|
22
|
-
/**
|
|
23
|
-
* The variant of the checkbox.
|
|
24
|
-
* @default 'filled'
|
|
25
|
-
*/
|
|
26
|
-
variant?: CheckboxVariant;
|
|
27
|
-
/**
|
|
28
|
-
* The size of the checkbox.
|
|
29
|
-
* @default 'md'
|
|
30
|
-
*/
|
|
31
|
-
size?: Size;
|
|
32
|
-
/**
|
|
33
|
-
* The border radius of the checkbox.
|
|
34
|
-
* @default 'sm'
|
|
35
|
-
*/
|
|
36
|
-
radius?: Radius;
|
|
37
|
-
/**
|
|
38
|
-
* Whether the checkbox should take the full width of its container.
|
|
39
|
-
* @default false
|
|
40
|
-
*/
|
|
41
|
-
fullWidth?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Whether the checkbox is checked.
|
|
44
|
-
* @default false
|
|
45
|
-
*/
|
|
46
|
-
isChecked?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Whether the checkbox is in an indeterminate state.
|
|
49
|
-
* @default false
|
|
50
|
-
*/
|
|
51
|
-
isIndeterminate?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Whether the checkbox is disabled.
|
|
54
|
-
* @default false
|
|
55
|
-
*/
|
|
56
|
-
isDisabled?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Custom style for the label text.
|
|
59
|
-
*/
|
|
60
|
-
labelStyle?: TextStyle;
|
|
61
|
-
/**
|
|
62
|
-
* Custom style for the checkbox container.
|
|
63
|
-
*/
|
|
64
|
-
style?: ViewStyle;
|
|
65
|
-
/**
|
|
66
|
-
* Callback fired when the checkbox value changes.
|
|
67
|
-
*/
|
|
68
|
-
onValueChange?: (isChecked: boolean) => void;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
declare const Checkbox: React.FC<CheckboxProps>;
|
|
72
|
-
|
|
73
|
-
export { Checkbox, type CheckboxLabelAlignment, type CheckboxProps, type CheckboxVariant };
|