@xaui/native 0.0.3 → 0.0.4
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/button/index.cjs +3 -3
- package/dist/button/index.d.cts +1 -1
- package/dist/button/index.d.ts +1 -1
- package/dist/button/index.js +3 -3
- package/dist/checkbox/index.cjs +206 -134
- package/dist/checkbox/index.d.cts +4 -6
- package/dist/checkbox/index.d.ts +4 -6
- package/dist/checkbox/index.js +199 -127
- package/dist/{index-BDSvmsTU.d.cts → index-BOw6tbkc.d.cts} +2 -1
- package/dist/{index-BDSvmsTU.d.ts → index-BOw6tbkc.d.ts} +2 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/indicator/index.d.cts +1 -1
- package/dist/indicator/index.d.ts +1 -1
- package/dist/progress/index.d.cts +1 -1
- package/dist/progress/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/button/index.cjs
CHANGED
|
@@ -480,7 +480,7 @@ var useTextStyles = (themeColor, variant) => {
|
|
|
480
480
|
if (variant === "solid" || variant === "elevated") {
|
|
481
481
|
return colorScheme.foreground;
|
|
482
482
|
}
|
|
483
|
-
return colorScheme.
|
|
483
|
+
return colorScheme.main;
|
|
484
484
|
}, [variant, colorScheme]);
|
|
485
485
|
return {
|
|
486
486
|
textColor
|
|
@@ -557,9 +557,9 @@ function useVariantSizesStyles(themeColor, variant) {
|
|
|
557
557
|
...theme.shadows.md
|
|
558
558
|
},
|
|
559
559
|
faded: {
|
|
560
|
-
backgroundColor: `${colorScheme.background}
|
|
560
|
+
backgroundColor: `${colorScheme.background}95`,
|
|
561
561
|
borderWidth: theme.borderWidth.md,
|
|
562
|
-
borderColor: colorScheme.main
|
|
562
|
+
borderColor: `${colorScheme.main}90`
|
|
563
563
|
}
|
|
564
564
|
};
|
|
565
565
|
return styles3[variant];
|
package/dist/button/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { TextStyle, ViewStyle, GestureResponderEvent } from 'react-native';
|
|
3
|
-
import { T as ThemeColor, S as Size } from '../index-
|
|
3
|
+
import { T as ThemeColor, S as Size } from '../index-BOw6tbkc.cjs';
|
|
4
4
|
|
|
5
5
|
type ButtonVariant = 'solid' | 'outlined' | 'flat' | 'light' | 'elevated' | 'faded';
|
|
6
6
|
type ButtonRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
package/dist/button/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { TextStyle, ViewStyle, GestureResponderEvent } from 'react-native';
|
|
3
|
-
import { T as ThemeColor, S as Size } from '../index-
|
|
3
|
+
import { T as ThemeColor, S as Size } from '../index-BOw6tbkc.js';
|
|
4
4
|
|
|
5
5
|
type ButtonVariant = 'solid' | 'outlined' | 'flat' | 'light' | 'elevated' | 'faded';
|
|
6
6
|
type ButtonRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
package/dist/button/index.js
CHANGED
|
@@ -60,7 +60,7 @@ var useTextStyles = (themeColor, variant) => {
|
|
|
60
60
|
if (variant === "solid" || variant === "elevated") {
|
|
61
61
|
return colorScheme.foreground;
|
|
62
62
|
}
|
|
63
|
-
return colorScheme.
|
|
63
|
+
return colorScheme.main;
|
|
64
64
|
}, [variant, colorScheme]);
|
|
65
65
|
return {
|
|
66
66
|
textColor
|
|
@@ -137,9 +137,9 @@ function useVariantSizesStyles(themeColor, variant) {
|
|
|
137
137
|
...theme.shadows.md
|
|
138
138
|
},
|
|
139
139
|
faded: {
|
|
140
|
-
backgroundColor: `${colorScheme.background}
|
|
140
|
+
backgroundColor: `${colorScheme.background}95`,
|
|
141
141
|
borderWidth: theme.borderWidth.md,
|
|
142
|
-
borderColor: colorScheme.main
|
|
142
|
+
borderColor: `${colorScheme.main}90`
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
145
|
return styles2[variant];
|
package/dist/checkbox/index.cjs
CHANGED
|
@@ -36,67 +36,148 @@ module.exports = __toCommonJS(checkbox_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/components/checkbox/checkbox.tsx
|
|
38
38
|
var import_react5 = __toESM(require("react"), 1);
|
|
39
|
-
var
|
|
39
|
+
var import_react_native6 = require("react-native");
|
|
40
40
|
|
|
41
41
|
// src/components/checkbox/checkbox-icon.tsx
|
|
42
42
|
var import_react = __toESM(require("react"), 1);
|
|
43
|
-
var
|
|
43
|
+
var import_react_native2 = require("react-native");
|
|
44
44
|
var import_react_native_svg = __toESM(require("react-native-svg"), 1);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
|
|
46
|
+
// src/components/checkbox/checkbox.animation.ts
|
|
47
|
+
var import_react_native = require("react-native");
|
|
48
|
+
var runCheckAnimation = (opacity, strokeDashoffset) => {
|
|
49
|
+
import_react_native.Animated.parallel([
|
|
50
|
+
import_react_native.Animated.timing(opacity, {
|
|
51
|
+
toValue: 1,
|
|
52
|
+
duration: 200,
|
|
53
|
+
useNativeDriver: false
|
|
54
|
+
}),
|
|
55
|
+
import_react_native.Animated.timing(strokeDashoffset, {
|
|
56
|
+
toValue: 44,
|
|
57
|
+
duration: 250,
|
|
58
|
+
useNativeDriver: false
|
|
59
|
+
})
|
|
60
|
+
]).start();
|
|
61
|
+
};
|
|
62
|
+
var runUncheckAnimation = (opacity, strokeDashoffset) => {
|
|
63
|
+
import_react_native.Animated.parallel([
|
|
64
|
+
import_react_native.Animated.timing(opacity, {
|
|
65
|
+
toValue: 0,
|
|
66
|
+
duration: 200,
|
|
67
|
+
useNativeDriver: false
|
|
68
|
+
}),
|
|
69
|
+
import_react_native.Animated.timing(strokeDashoffset, {
|
|
70
|
+
toValue: 66,
|
|
71
|
+
duration: 250,
|
|
72
|
+
useNativeDriver: false
|
|
73
|
+
})
|
|
74
|
+
]).start();
|
|
75
|
+
};
|
|
76
|
+
var runBackgroundInAnimation = (backgroundScale, backgroundOpacity) => {
|
|
77
|
+
import_react_native.Animated.parallel([
|
|
78
|
+
import_react_native.Animated.timing(backgroundScale, {
|
|
79
|
+
toValue: 1,
|
|
80
|
+
duration: 200,
|
|
81
|
+
useNativeDriver: true
|
|
82
|
+
}),
|
|
83
|
+
import_react_native.Animated.timing(backgroundOpacity, {
|
|
84
|
+
toValue: 1,
|
|
85
|
+
duration: 200,
|
|
86
|
+
useNativeDriver: true
|
|
87
|
+
})
|
|
88
|
+
]).start();
|
|
89
|
+
};
|
|
90
|
+
var runBackgroundOutAnimation = (backgroundScale, backgroundOpacity) => {
|
|
91
|
+
import_react_native.Animated.parallel([
|
|
92
|
+
import_react_native.Animated.timing(backgroundScale, {
|
|
93
|
+
toValue: 0.5,
|
|
94
|
+
duration: 200,
|
|
95
|
+
useNativeDriver: true
|
|
96
|
+
}),
|
|
97
|
+
import_react_native.Animated.timing(backgroundOpacity, {
|
|
98
|
+
toValue: 0,
|
|
99
|
+
duration: 200,
|
|
100
|
+
useNativeDriver: true
|
|
101
|
+
})
|
|
102
|
+
]).start();
|
|
103
|
+
};
|
|
104
|
+
var runPressInAnimation = (scale) => {
|
|
105
|
+
import_react_native.Animated.spring(scale, {
|
|
106
|
+
toValue: 0.95,
|
|
107
|
+
useNativeDriver: true
|
|
108
|
+
}).start();
|
|
109
|
+
};
|
|
110
|
+
var runPressOutAnimation = (scale) => {
|
|
111
|
+
import_react_native.Animated.spring(scale, {
|
|
112
|
+
toValue: 1,
|
|
113
|
+
useNativeDriver: true
|
|
114
|
+
}).start();
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/components/checkbox/checkbox-icon.tsx
|
|
118
|
+
var AnimatedSvg = import_react_native2.Animated.createAnimatedComponent(import_react_native_svg.default);
|
|
119
|
+
var AnimatedPolyline = import_react_native2.Animated.createAnimatedComponent(import_react_native_svg.Polyline);
|
|
120
|
+
function CheckIcon({
|
|
121
|
+
isChecked,
|
|
122
|
+
color,
|
|
123
|
+
size
|
|
124
|
+
}) {
|
|
125
|
+
const opacity = (0, import_react.useRef)(new import_react_native2.Animated.Value(0)).current;
|
|
126
|
+
const strokeDashoffset = (0, import_react.useRef)(new import_react_native2.Animated.Value(66)).current;
|
|
50
127
|
(0, import_react.useEffect)(() => {
|
|
51
128
|
if (isChecked) {
|
|
52
|
-
|
|
53
|
-
import_react_native.Animated.timing(opacity, {
|
|
54
|
-
toValue: 1,
|
|
55
|
-
duration: 200,
|
|
56
|
-
useNativeDriver: false
|
|
57
|
-
}),
|
|
58
|
-
import_react_native.Animated.timing(strokeDashoffset, {
|
|
59
|
-
toValue: 44,
|
|
60
|
-
duration: 250,
|
|
61
|
-
useNativeDriver: false
|
|
62
|
-
})
|
|
63
|
-
]).start();
|
|
129
|
+
runCheckAnimation(opacity, strokeDashoffset);
|
|
64
130
|
} else {
|
|
65
|
-
|
|
66
|
-
import_react_native.Animated.timing(opacity, {
|
|
67
|
-
toValue: 0,
|
|
68
|
-
duration: 200,
|
|
69
|
-
useNativeDriver: false
|
|
70
|
-
}),
|
|
71
|
-
import_react_native.Animated.timing(strokeDashoffset, {
|
|
72
|
-
toValue: 66,
|
|
73
|
-
duration: 250,
|
|
74
|
-
useNativeDriver: false
|
|
75
|
-
})
|
|
76
|
-
]).start();
|
|
131
|
+
runUncheckAnimation(opacity, strokeDashoffset);
|
|
77
132
|
}
|
|
78
133
|
}, [isChecked, opacity, strokeDashoffset]);
|
|
79
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
80
|
-
|
|
134
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
135
|
+
AnimatedSvg,
|
|
136
|
+
{
|
|
137
|
+
width: size,
|
|
138
|
+
height: size,
|
|
139
|
+
viewBox: "0 0 17 18",
|
|
140
|
+
fill: "none",
|
|
141
|
+
opacity
|
|
142
|
+
},
|
|
143
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
144
|
+
AnimatedPolyline,
|
|
145
|
+
{
|
|
146
|
+
points: "1 9 7 14 15 4",
|
|
147
|
+
stroke: color,
|
|
148
|
+
strokeWidth: 2,
|
|
149
|
+
strokeLinecap: "round",
|
|
150
|
+
strokeLinejoin: "round",
|
|
151
|
+
strokeDasharray: "22",
|
|
152
|
+
strokeDashoffset
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function PlaceholderCheckIcon({ color, size }) {
|
|
158
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react_native_svg.default, { width: size, height: size, viewBox: "0 0 17 18" }, /* @__PURE__ */ import_react.default.createElement(
|
|
159
|
+
import_react_native_svg.Path,
|
|
81
160
|
{
|
|
82
|
-
|
|
161
|
+
d: "M 1 9 L 7 14 L 15 4",
|
|
83
162
|
stroke: color,
|
|
84
163
|
strokeWidth: 2,
|
|
85
164
|
strokeLinecap: "round",
|
|
86
165
|
strokeLinejoin: "round",
|
|
87
|
-
|
|
88
|
-
strokeDashoffset
|
|
166
|
+
fill: "none"
|
|
89
167
|
}
|
|
90
168
|
));
|
|
91
169
|
}
|
|
92
|
-
function
|
|
170
|
+
function IndeterminateCheckIcon({
|
|
93
171
|
color,
|
|
94
172
|
size
|
|
95
173
|
}) {
|
|
96
174
|
return /* @__PURE__ */ import_react.default.createElement(import_react_native_svg.default, { width: size, height: size, viewBox: "0 0 24 24" }, /* @__PURE__ */ import_react.default.createElement(import_react_native_svg.Line, { x1: "21", y1: "12", x2: "3", y2: "12", stroke: color, strokeWidth: 3 }));
|
|
97
175
|
}
|
|
98
|
-
function CheckboxIcon({ isIndeterminate, ...props }) {
|
|
99
|
-
const BaseIcon = isIndeterminate ?
|
|
176
|
+
function CheckboxIcon({ isIndeterminate, variant, ...props }) {
|
|
177
|
+
const BaseIcon = isIndeterminate ? IndeterminateCheckIcon : CheckIcon;
|
|
178
|
+
if (variant === "light" && !props.isChecked && !isIndeterminate) {
|
|
179
|
+
return /* @__PURE__ */ import_react.default.createElement(PlaceholderCheckIcon, { size: props.size, color: props.placeholderColor ?? "" });
|
|
180
|
+
}
|
|
100
181
|
return /* @__PURE__ */ import_react.default.createElement(BaseIcon, { ...props });
|
|
101
182
|
}
|
|
102
183
|
|
|
@@ -106,13 +187,13 @@ var import_core = require("@xaui/core");
|
|
|
106
187
|
|
|
107
188
|
// src/core/theme-context.tsx
|
|
108
189
|
var import_react2 = __toESM(require("react"), 1);
|
|
109
|
-
var
|
|
190
|
+
var import_react_native3 = require("react-native");
|
|
110
191
|
var import_theme = require("@xaui/core/theme");
|
|
111
192
|
var XUIThemeContext = (0, import_react2.createContext)(null);
|
|
112
193
|
|
|
113
194
|
// src/core/theme-hooks.ts
|
|
114
195
|
var import_react3 = require("react");
|
|
115
|
-
var
|
|
196
|
+
var import_react_native4 = require("react-native");
|
|
116
197
|
function useXUITheme() {
|
|
117
198
|
const theme = (0, import_react3.useContext)(XUIThemeContext);
|
|
118
199
|
if (!theme) {
|
|
@@ -122,12 +203,15 @@ function useXUITheme() {
|
|
|
122
203
|
}
|
|
123
204
|
|
|
124
205
|
// src/components/checkbox/checkbox.hook.ts
|
|
125
|
-
|
|
206
|
+
function useSizeStyles(size, variant) {
|
|
126
207
|
const theme = useXUITheme();
|
|
127
|
-
const safeThemeColor = (0, import_core.getSafeThemeColor)(themeColor);
|
|
128
|
-
const colorScheme = theme.colors[safeThemeColor];
|
|
129
208
|
const sizeStyles = (0, import_react4.useMemo)(() => {
|
|
130
209
|
const sizes = {
|
|
210
|
+
xs: {
|
|
211
|
+
checkboxSize: 14,
|
|
212
|
+
fontSize: theme.fontSizes.xs,
|
|
213
|
+
iconSize: variant === "light" ? 10 : 8
|
|
214
|
+
},
|
|
131
215
|
sm: {
|
|
132
216
|
checkboxSize: 18,
|
|
133
217
|
fontSize: theme.fontSizes.sm,
|
|
@@ -145,7 +229,11 @@ var useCheckboxStyles = (themeColor, variant, size, radius, labelAlignment, isAc
|
|
|
145
229
|
}
|
|
146
230
|
};
|
|
147
231
|
return sizes[size];
|
|
148
|
-
}, [size,
|
|
232
|
+
}, [size, variant, theme]);
|
|
233
|
+
return sizeStyles;
|
|
234
|
+
}
|
|
235
|
+
function useRadiusStyles(radius) {
|
|
236
|
+
const theme = useXUITheme();
|
|
149
237
|
const radiusStyles = (0, import_react4.useMemo)(() => {
|
|
150
238
|
const radii = {
|
|
151
239
|
none: theme.borderRadius.none,
|
|
@@ -156,39 +244,59 @@ var useCheckboxStyles = (themeColor, variant, size, radius, labelAlignment, isAc
|
|
|
156
244
|
};
|
|
157
245
|
return { borderRadius: radii[radius] };
|
|
158
246
|
}, [radius, theme]);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
247
|
+
return radiusStyles;
|
|
248
|
+
}
|
|
249
|
+
function useCheckmarkColors(themeColor, variant, isActive) {
|
|
250
|
+
const theme = useXUITheme();
|
|
251
|
+
const safeThemeColor = (0, import_core.getSafeThemeColor)(themeColor);
|
|
252
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
253
|
+
const checkmarkColors = (0, import_react4.useMemo)(() => {
|
|
254
|
+
if (variant === "filled") {
|
|
255
|
+
return {
|
|
256
|
+
checked: colorScheme.foreground,
|
|
257
|
+
unchecked: void 0
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
if (isActive) {
|
|
261
|
+
return {
|
|
262
|
+
checked: colorScheme.main,
|
|
263
|
+
unchecked: void 0
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
if (themeColor !== "default") {
|
|
267
|
+
return {
|
|
268
|
+
checked: colorScheme.foreground,
|
|
269
|
+
unchecked: colorScheme.background
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
checked: theme.colors.foreground,
|
|
274
|
+
unchecked: theme.colors.background
|
|
164
275
|
};
|
|
276
|
+
}, [variant, colorScheme, isActive, themeColor, theme.colors]);
|
|
277
|
+
return checkmarkColors;
|
|
278
|
+
}
|
|
279
|
+
function useVariantStyles(themeColor, variant, isActive) {
|
|
280
|
+
const theme = useXUITheme();
|
|
281
|
+
const safeThemeColor = (0, import_core.getSafeThemeColor)(themeColor);
|
|
282
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
283
|
+
const variantStyles = (0, import_react4.useMemo)(() => {
|
|
165
284
|
if (variant === "filled") {
|
|
166
285
|
return {
|
|
167
|
-
...baseStyle,
|
|
168
286
|
backgroundColor: "transparent",
|
|
169
287
|
borderWidth: isActive ? 0 : theme.borderWidth.md,
|
|
170
288
|
borderColor: isActive ? "transparent" : colorScheme.main
|
|
171
289
|
};
|
|
172
290
|
}
|
|
173
291
|
return {
|
|
174
|
-
...baseStyle,
|
|
175
292
|
backgroundColor: "transparent",
|
|
176
293
|
borderWidth: 0,
|
|
177
294
|
borderColor: "transparent"
|
|
178
295
|
};
|
|
179
|
-
}, [variant, isActive, colorScheme,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
if (isActive) {
|
|
185
|
-
return colorScheme.main;
|
|
186
|
-
}
|
|
187
|
-
if (themeColor !== "default") {
|
|
188
|
-
return colorScheme.background;
|
|
189
|
-
}
|
|
190
|
-
return theme.colors.foreground;
|
|
191
|
-
}, [variant, colorScheme, isActive, themeColor, theme.colors.foreground]);
|
|
296
|
+
}, [variant, isActive, colorScheme, theme]);
|
|
297
|
+
return variantStyles;
|
|
298
|
+
}
|
|
299
|
+
function useContainerStyles(labelAlignment) {
|
|
192
300
|
const containerStyles = (0, import_react4.useMemo)(() => {
|
|
193
301
|
const isJustified = labelAlignment === "justify-left" || labelAlignment === "justify-right";
|
|
194
302
|
return {
|
|
@@ -196,19 +304,12 @@ var useCheckboxStyles = (themeColor, variant, size, radius, labelAlignment, isAc
|
|
|
196
304
|
justifyContent: isJustified ? "space-between" : "flex-start"
|
|
197
305
|
};
|
|
198
306
|
}, [labelAlignment]);
|
|
199
|
-
return
|
|
200
|
-
|
|
201
|
-
sizeStyles,
|
|
202
|
-
radiusStyles,
|
|
203
|
-
checkboxStyles,
|
|
204
|
-
checkmarkColor,
|
|
205
|
-
containerStyles
|
|
206
|
-
};
|
|
207
|
-
};
|
|
307
|
+
return containerStyles;
|
|
308
|
+
}
|
|
208
309
|
|
|
209
310
|
// src/components/checkbox/checkbox.style.ts
|
|
210
|
-
var
|
|
211
|
-
var styles =
|
|
311
|
+
var import_react_native5 = require("react-native");
|
|
312
|
+
var styles = import_react_native5.StyleSheet.create({
|
|
212
313
|
container: {
|
|
213
314
|
flexDirection: "row",
|
|
214
315
|
alignItems: "center",
|
|
@@ -245,6 +346,7 @@ var styles = import_react_native4.StyleSheet.create({
|
|
|
245
346
|
});
|
|
246
347
|
|
|
247
348
|
// src/components/checkbox/checkbox.tsx
|
|
349
|
+
var import_core4 = require("@xaui/core");
|
|
248
350
|
var Checkbox = ({
|
|
249
351
|
label,
|
|
250
352
|
labelAlignment = "right",
|
|
@@ -261,56 +363,25 @@ var Checkbox = ({
|
|
|
261
363
|
onValueChange
|
|
262
364
|
}) => {
|
|
263
365
|
const theme = useXUITheme();
|
|
366
|
+
const colorScheme = theme.colors[(0, import_core4.getSafeThemeColor)(themeColor)];
|
|
264
367
|
const isControlled = typeof isCheckedProp === "boolean";
|
|
265
368
|
const [internalChecked, setInternalChecked] = (0, import_react5.useState)(isCheckedProp ?? false);
|
|
266
369
|
const isChecked = isControlled ? isCheckedProp : internalChecked;
|
|
267
|
-
const scale = (0, import_react5.useRef)(new
|
|
268
|
-
const backgroundScale = (0, import_react5.useRef)(new
|
|
269
|
-
const backgroundOpacity = (0, import_react5.useRef)(new
|
|
370
|
+
const scale = (0, import_react5.useRef)(new import_react_native6.Animated.Value(1)).current;
|
|
371
|
+
const backgroundScale = (0, import_react5.useRef)(new import_react_native6.Animated.Value(0.5)).current;
|
|
372
|
+
const backgroundOpacity = (0, import_react5.useRef)(new import_react_native6.Animated.Value(0)).current;
|
|
270
373
|
const isActive = isChecked || isIndeterminate;
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
checkmarkColor,
|
|
277
|
-
containerStyles
|
|
278
|
-
} = useCheckboxStyles(
|
|
279
|
-
themeColor,
|
|
280
|
-
variant,
|
|
281
|
-
size,
|
|
282
|
-
radius,
|
|
283
|
-
labelAlignment,
|
|
284
|
-
isActive
|
|
285
|
-
);
|
|
374
|
+
const sizeStyles = useSizeStyles(size, variant);
|
|
375
|
+
const radiusStyles = useRadiusStyles(radius);
|
|
376
|
+
const checkmarkColors = useCheckmarkColors(themeColor, variant, isActive);
|
|
377
|
+
const variantStyles = useVariantStyles(themeColor, variant, isActive);
|
|
378
|
+
const containerStyles = useContainerStyles(labelAlignment);
|
|
286
379
|
(0, import_react5.useEffect)(() => {
|
|
287
380
|
if (variant !== "filled") return;
|
|
288
381
|
if (isActive) {
|
|
289
|
-
|
|
290
|
-
import_react_native5.Animated.timing(backgroundScale, {
|
|
291
|
-
toValue: 1,
|
|
292
|
-
duration: 200,
|
|
293
|
-
useNativeDriver: true
|
|
294
|
-
}),
|
|
295
|
-
import_react_native5.Animated.timing(backgroundOpacity, {
|
|
296
|
-
toValue: 1,
|
|
297
|
-
duration: 200,
|
|
298
|
-
useNativeDriver: true
|
|
299
|
-
})
|
|
300
|
-
]).start();
|
|
382
|
+
runBackgroundInAnimation(backgroundScale, backgroundOpacity);
|
|
301
383
|
} else {
|
|
302
|
-
|
|
303
|
-
import_react_native5.Animated.timing(backgroundScale, {
|
|
304
|
-
toValue: 0.5,
|
|
305
|
-
duration: 200,
|
|
306
|
-
useNativeDriver: true
|
|
307
|
-
}),
|
|
308
|
-
import_react_native5.Animated.timing(backgroundOpacity, {
|
|
309
|
-
toValue: 0,
|
|
310
|
-
duration: 200,
|
|
311
|
-
useNativeDriver: true
|
|
312
|
-
})
|
|
313
|
-
]).start();
|
|
384
|
+
runBackgroundOutAnimation(backgroundScale, backgroundOpacity);
|
|
314
385
|
}
|
|
315
386
|
}, [isActive, variant, backgroundScale, backgroundOpacity]);
|
|
316
387
|
const handlePress = () => {
|
|
@@ -324,23 +395,17 @@ var Checkbox = ({
|
|
|
324
395
|
};
|
|
325
396
|
const handlePressIn = () => {
|
|
326
397
|
if (!isDisabled) {
|
|
327
|
-
|
|
328
|
-
toValue: 0.95,
|
|
329
|
-
useNativeDriver: true
|
|
330
|
-
}).start();
|
|
398
|
+
runPressInAnimation(scale);
|
|
331
399
|
}
|
|
332
400
|
};
|
|
333
401
|
const handlePressOut = () => {
|
|
334
402
|
if (!isDisabled) {
|
|
335
|
-
|
|
336
|
-
toValue: 1,
|
|
337
|
-
useNativeDriver: true
|
|
338
|
-
}).start();
|
|
403
|
+
runPressOutAnimation(scale);
|
|
339
404
|
}
|
|
340
405
|
};
|
|
341
406
|
const accessibilityChecked = isIndeterminate ? "mixed" : isChecked;
|
|
342
407
|
return /* @__PURE__ */ import_react5.default.createElement(
|
|
343
|
-
|
|
408
|
+
import_react_native6.Pressable,
|
|
344
409
|
{
|
|
345
410
|
onPress: handlePress,
|
|
346
411
|
onPressIn: handlePressIn,
|
|
@@ -362,18 +427,23 @@ var Checkbox = ({
|
|
|
362
427
|
]
|
|
363
428
|
},
|
|
364
429
|
/* @__PURE__ */ import_react5.default.createElement(
|
|
365
|
-
|
|
430
|
+
import_react_native6.Animated.View,
|
|
366
431
|
{
|
|
367
432
|
style: [
|
|
368
433
|
styles.checkbox,
|
|
369
|
-
|
|
434
|
+
{
|
|
435
|
+
width: sizeStyles.checkboxSize,
|
|
436
|
+
height: sizeStyles.checkboxSize,
|
|
437
|
+
...radiusStyles,
|
|
438
|
+
...variantStyles
|
|
439
|
+
},
|
|
370
440
|
{
|
|
371
441
|
transform: [{ scale }]
|
|
372
442
|
}
|
|
373
443
|
]
|
|
374
444
|
},
|
|
375
445
|
variant === "filled" && /* @__PURE__ */ import_react5.default.createElement(
|
|
376
|
-
|
|
446
|
+
import_react_native6.Animated.View,
|
|
377
447
|
{
|
|
378
448
|
style: [
|
|
379
449
|
styles.background,
|
|
@@ -386,18 +456,20 @@ var Checkbox = ({
|
|
|
386
456
|
]
|
|
387
457
|
}
|
|
388
458
|
),
|
|
389
|
-
/* @__PURE__ */ import_react5.default.createElement(
|
|
459
|
+
/* @__PURE__ */ import_react5.default.createElement(import_react_native6.View, { style: styles.checkmarkContainer }, /* @__PURE__ */ import_react5.default.createElement(
|
|
390
460
|
CheckboxIcon,
|
|
391
461
|
{
|
|
392
462
|
isChecked: isActive,
|
|
393
463
|
isIndeterminate,
|
|
394
|
-
color:
|
|
395
|
-
size: sizeStyles.iconSize
|
|
464
|
+
color: checkmarkColors.checked,
|
|
465
|
+
size: sizeStyles.iconSize,
|
|
466
|
+
placeholderColor: checkmarkColors.unchecked,
|
|
467
|
+
variant
|
|
396
468
|
}
|
|
397
469
|
))
|
|
398
470
|
),
|
|
399
471
|
label && /* @__PURE__ */ import_react5.default.createElement(
|
|
400
|
-
|
|
472
|
+
import_react_native6.Text,
|
|
401
473
|
{
|
|
402
474
|
style: [
|
|
403
475
|
styles.label,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TextStyle, ViewStyle } from 'react-native';
|
|
3
|
-
import { T as ThemeColor } from '../index-
|
|
3
|
+
import { T as ThemeColor, S as Size, R as Radius } from '../index-BOw6tbkc.cjs';
|
|
4
4
|
|
|
5
5
|
type CheckboxVariant = 'filled' | 'light';
|
|
6
|
-
type CheckboxSize = 'sm' | 'md' | 'lg';
|
|
7
|
-
type CheckboxRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
8
6
|
type CheckboxLabelAlignment = 'left' | 'right' | 'justify-left' | 'justify-right';
|
|
9
7
|
type CheckboxProps = {
|
|
10
8
|
/**
|
|
@@ -30,12 +28,12 @@ type CheckboxProps = {
|
|
|
30
28
|
* The size of the checkbox.
|
|
31
29
|
* @default 'md'
|
|
32
30
|
*/
|
|
33
|
-
size?:
|
|
31
|
+
size?: Size;
|
|
34
32
|
/**
|
|
35
33
|
* The border radius of the checkbox.
|
|
36
34
|
* @default 'sm'
|
|
37
35
|
*/
|
|
38
|
-
radius?:
|
|
36
|
+
radius?: Radius;
|
|
39
37
|
/**
|
|
40
38
|
* Whether the checkbox should take the full width of its container.
|
|
41
39
|
* @default false
|
|
@@ -72,4 +70,4 @@ type CheckboxProps = {
|
|
|
72
70
|
|
|
73
71
|
declare const Checkbox: React.FC<CheckboxProps>;
|
|
74
72
|
|
|
75
|
-
export { Checkbox, type CheckboxLabelAlignment, type CheckboxProps, type
|
|
73
|
+
export { Checkbox, type CheckboxLabelAlignment, type CheckboxProps, type CheckboxVariant };
|
package/dist/checkbox/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TextStyle, ViewStyle } from 'react-native';
|
|
3
|
-
import { T as ThemeColor } from '../index-
|
|
3
|
+
import { T as ThemeColor, S as Size, R as Radius } from '../index-BOw6tbkc.js';
|
|
4
4
|
|
|
5
5
|
type CheckboxVariant = 'filled' | 'light';
|
|
6
|
-
type CheckboxSize = 'sm' | 'md' | 'lg';
|
|
7
|
-
type CheckboxRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
8
6
|
type CheckboxLabelAlignment = 'left' | 'right' | 'justify-left' | 'justify-right';
|
|
9
7
|
type CheckboxProps = {
|
|
10
8
|
/**
|
|
@@ -30,12 +28,12 @@ type CheckboxProps = {
|
|
|
30
28
|
* The size of the checkbox.
|
|
31
29
|
* @default 'md'
|
|
32
30
|
*/
|
|
33
|
-
size?:
|
|
31
|
+
size?: Size;
|
|
34
32
|
/**
|
|
35
33
|
* The border radius of the checkbox.
|
|
36
34
|
* @default 'sm'
|
|
37
35
|
*/
|
|
38
|
-
radius?:
|
|
36
|
+
radius?: Radius;
|
|
39
37
|
/**
|
|
40
38
|
* Whether the checkbox should take the full width of its container.
|
|
41
39
|
* @default false
|
|
@@ -72,4 +70,4 @@ type CheckboxProps = {
|
|
|
72
70
|
|
|
73
71
|
declare const Checkbox: React.FC<CheckboxProps>;
|
|
74
72
|
|
|
75
|
-
export { Checkbox, type CheckboxLabelAlignment, type CheckboxProps, type
|
|
73
|
+
export { Checkbox, type CheckboxLabelAlignment, type CheckboxProps, type CheckboxVariant };
|
package/dist/checkbox/index.js
CHANGED
|
@@ -4,79 +4,163 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/components/checkbox/checkbox.tsx
|
|
6
6
|
import React2, { useEffect as useEffect2, useRef as useRef2, useState } from "react";
|
|
7
|
-
import { Animated as
|
|
7
|
+
import { Animated as Animated3, Pressable, Text, View } from "react-native";
|
|
8
8
|
|
|
9
9
|
// src/components/checkbox/checkbox-icon.tsx
|
|
10
10
|
import React, { useEffect, useRef } from "react";
|
|
11
|
+
import { Animated as Animated2 } from "react-native";
|
|
12
|
+
import Svg, { Polyline, Line, Path } from "react-native-svg";
|
|
13
|
+
|
|
14
|
+
// src/components/checkbox/checkbox.animation.ts
|
|
11
15
|
import { Animated } from "react-native";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
var runCheckAnimation = (opacity, strokeDashoffset) => {
|
|
17
|
+
Animated.parallel([
|
|
18
|
+
Animated.timing(opacity, {
|
|
19
|
+
toValue: 1,
|
|
20
|
+
duration: 200,
|
|
21
|
+
useNativeDriver: false
|
|
22
|
+
}),
|
|
23
|
+
Animated.timing(strokeDashoffset, {
|
|
24
|
+
toValue: 44,
|
|
25
|
+
duration: 250,
|
|
26
|
+
useNativeDriver: false
|
|
27
|
+
})
|
|
28
|
+
]).start();
|
|
29
|
+
};
|
|
30
|
+
var runUncheckAnimation = (opacity, strokeDashoffset) => {
|
|
31
|
+
Animated.parallel([
|
|
32
|
+
Animated.timing(opacity, {
|
|
33
|
+
toValue: 0,
|
|
34
|
+
duration: 200,
|
|
35
|
+
useNativeDriver: false
|
|
36
|
+
}),
|
|
37
|
+
Animated.timing(strokeDashoffset, {
|
|
38
|
+
toValue: 66,
|
|
39
|
+
duration: 250,
|
|
40
|
+
useNativeDriver: false
|
|
41
|
+
})
|
|
42
|
+
]).start();
|
|
43
|
+
};
|
|
44
|
+
var runBackgroundInAnimation = (backgroundScale, backgroundOpacity) => {
|
|
45
|
+
Animated.parallel([
|
|
46
|
+
Animated.timing(backgroundScale, {
|
|
47
|
+
toValue: 1,
|
|
48
|
+
duration: 200,
|
|
49
|
+
useNativeDriver: true
|
|
50
|
+
}),
|
|
51
|
+
Animated.timing(backgroundOpacity, {
|
|
52
|
+
toValue: 1,
|
|
53
|
+
duration: 200,
|
|
54
|
+
useNativeDriver: true
|
|
55
|
+
})
|
|
56
|
+
]).start();
|
|
57
|
+
};
|
|
58
|
+
var runBackgroundOutAnimation = (backgroundScale, backgroundOpacity) => {
|
|
59
|
+
Animated.parallel([
|
|
60
|
+
Animated.timing(backgroundScale, {
|
|
61
|
+
toValue: 0.5,
|
|
62
|
+
duration: 200,
|
|
63
|
+
useNativeDriver: true
|
|
64
|
+
}),
|
|
65
|
+
Animated.timing(backgroundOpacity, {
|
|
66
|
+
toValue: 0,
|
|
67
|
+
duration: 200,
|
|
68
|
+
useNativeDriver: true
|
|
69
|
+
})
|
|
70
|
+
]).start();
|
|
71
|
+
};
|
|
72
|
+
var runPressInAnimation = (scale) => {
|
|
73
|
+
Animated.spring(scale, {
|
|
74
|
+
toValue: 0.95,
|
|
75
|
+
useNativeDriver: true
|
|
76
|
+
}).start();
|
|
77
|
+
};
|
|
78
|
+
var runPressOutAnimation = (scale) => {
|
|
79
|
+
Animated.spring(scale, {
|
|
80
|
+
toValue: 1,
|
|
81
|
+
useNativeDriver: true
|
|
82
|
+
}).start();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/components/checkbox/checkbox-icon.tsx
|
|
86
|
+
var AnimatedSvg = Animated2.createAnimatedComponent(Svg);
|
|
87
|
+
var AnimatedPolyline = Animated2.createAnimatedComponent(Polyline);
|
|
88
|
+
function CheckIcon({
|
|
89
|
+
isChecked,
|
|
90
|
+
color,
|
|
91
|
+
size
|
|
92
|
+
}) {
|
|
93
|
+
const opacity = useRef(new Animated2.Value(0)).current;
|
|
94
|
+
const strokeDashoffset = useRef(new Animated2.Value(66)).current;
|
|
18
95
|
useEffect(() => {
|
|
19
96
|
if (isChecked) {
|
|
20
|
-
|
|
21
|
-
Animated.timing(opacity, {
|
|
22
|
-
toValue: 1,
|
|
23
|
-
duration: 200,
|
|
24
|
-
useNativeDriver: false
|
|
25
|
-
}),
|
|
26
|
-
Animated.timing(strokeDashoffset, {
|
|
27
|
-
toValue: 44,
|
|
28
|
-
duration: 250,
|
|
29
|
-
useNativeDriver: false
|
|
30
|
-
})
|
|
31
|
-
]).start();
|
|
97
|
+
runCheckAnimation(opacity, strokeDashoffset);
|
|
32
98
|
} else {
|
|
33
|
-
|
|
34
|
-
Animated.timing(opacity, {
|
|
35
|
-
toValue: 0,
|
|
36
|
-
duration: 200,
|
|
37
|
-
useNativeDriver: false
|
|
38
|
-
}),
|
|
39
|
-
Animated.timing(strokeDashoffset, {
|
|
40
|
-
toValue: 66,
|
|
41
|
-
duration: 250,
|
|
42
|
-
useNativeDriver: false
|
|
43
|
-
})
|
|
44
|
-
]).start();
|
|
99
|
+
runUncheckAnimation(opacity, strokeDashoffset);
|
|
45
100
|
}
|
|
46
101
|
}, [isChecked, opacity, strokeDashoffset]);
|
|
47
|
-
return /* @__PURE__ */ React.createElement(
|
|
48
|
-
|
|
102
|
+
return /* @__PURE__ */ React.createElement(
|
|
103
|
+
AnimatedSvg,
|
|
49
104
|
{
|
|
50
|
-
|
|
105
|
+
width: size,
|
|
106
|
+
height: size,
|
|
107
|
+
viewBox: "0 0 17 18",
|
|
108
|
+
fill: "none",
|
|
109
|
+
opacity
|
|
110
|
+
},
|
|
111
|
+
/* @__PURE__ */ React.createElement(
|
|
112
|
+
AnimatedPolyline,
|
|
113
|
+
{
|
|
114
|
+
points: "1 9 7 14 15 4",
|
|
115
|
+
stroke: color,
|
|
116
|
+
strokeWidth: 2,
|
|
117
|
+
strokeLinecap: "round",
|
|
118
|
+
strokeLinejoin: "round",
|
|
119
|
+
strokeDasharray: "22",
|
|
120
|
+
strokeDashoffset
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
function PlaceholderCheckIcon({ color, size }) {
|
|
126
|
+
return /* @__PURE__ */ React.createElement(Svg, { width: size, height: size, viewBox: "0 0 17 18" }, /* @__PURE__ */ React.createElement(
|
|
127
|
+
Path,
|
|
128
|
+
{
|
|
129
|
+
d: "M 1 9 L 7 14 L 15 4",
|
|
51
130
|
stroke: color,
|
|
52
131
|
strokeWidth: 2,
|
|
53
132
|
strokeLinecap: "round",
|
|
54
133
|
strokeLinejoin: "round",
|
|
55
|
-
|
|
56
|
-
strokeDashoffset
|
|
134
|
+
fill: "none"
|
|
57
135
|
}
|
|
58
136
|
));
|
|
59
137
|
}
|
|
60
|
-
function
|
|
138
|
+
function IndeterminateCheckIcon({
|
|
61
139
|
color,
|
|
62
140
|
size
|
|
63
141
|
}) {
|
|
64
142
|
return /* @__PURE__ */ React.createElement(Svg, { width: size, height: size, viewBox: "0 0 24 24" }, /* @__PURE__ */ React.createElement(Line, { x1: "21", y1: "12", x2: "3", y2: "12", stroke: color, strokeWidth: 3 }));
|
|
65
143
|
}
|
|
66
|
-
function CheckboxIcon({ isIndeterminate, ...props }) {
|
|
67
|
-
const BaseIcon = isIndeterminate ?
|
|
144
|
+
function CheckboxIcon({ isIndeterminate, variant, ...props }) {
|
|
145
|
+
const BaseIcon = isIndeterminate ? IndeterminateCheckIcon : CheckIcon;
|
|
146
|
+
if (variant === "light" && !props.isChecked && !isIndeterminate) {
|
|
147
|
+
return /* @__PURE__ */ React.createElement(PlaceholderCheckIcon, { size: props.size, color: props.placeholderColor ?? "" });
|
|
148
|
+
}
|
|
68
149
|
return /* @__PURE__ */ React.createElement(BaseIcon, { ...props });
|
|
69
150
|
}
|
|
70
151
|
|
|
71
152
|
// src/components/checkbox/checkbox.hook.ts
|
|
72
153
|
import { useMemo } from "react";
|
|
73
154
|
import { getSafeThemeColor } from "@xaui/core";
|
|
74
|
-
|
|
155
|
+
function useSizeStyles(size, variant) {
|
|
75
156
|
const theme = useXUITheme();
|
|
76
|
-
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
77
|
-
const colorScheme = theme.colors[safeThemeColor];
|
|
78
157
|
const sizeStyles = useMemo(() => {
|
|
79
158
|
const sizes = {
|
|
159
|
+
xs: {
|
|
160
|
+
checkboxSize: 14,
|
|
161
|
+
fontSize: theme.fontSizes.xs,
|
|
162
|
+
iconSize: variant === "light" ? 10 : 8
|
|
163
|
+
},
|
|
80
164
|
sm: {
|
|
81
165
|
checkboxSize: 18,
|
|
82
166
|
fontSize: theme.fontSizes.sm,
|
|
@@ -94,7 +178,11 @@ var useCheckboxStyles = (themeColor, variant, size, radius, labelAlignment, isAc
|
|
|
94
178
|
}
|
|
95
179
|
};
|
|
96
180
|
return sizes[size];
|
|
97
|
-
}, [size,
|
|
181
|
+
}, [size, variant, theme]);
|
|
182
|
+
return sizeStyles;
|
|
183
|
+
}
|
|
184
|
+
function useRadiusStyles(radius) {
|
|
185
|
+
const theme = useXUITheme();
|
|
98
186
|
const radiusStyles = useMemo(() => {
|
|
99
187
|
const radii = {
|
|
100
188
|
none: theme.borderRadius.none,
|
|
@@ -105,39 +193,59 @@ var useCheckboxStyles = (themeColor, variant, size, radius, labelAlignment, isAc
|
|
|
105
193
|
};
|
|
106
194
|
return { borderRadius: radii[radius] };
|
|
107
195
|
}, [radius, theme]);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
196
|
+
return radiusStyles;
|
|
197
|
+
}
|
|
198
|
+
function useCheckmarkColors(themeColor, variant, isActive) {
|
|
199
|
+
const theme = useXUITheme();
|
|
200
|
+
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
201
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
202
|
+
const checkmarkColors = useMemo(() => {
|
|
203
|
+
if (variant === "filled") {
|
|
204
|
+
return {
|
|
205
|
+
checked: colorScheme.foreground,
|
|
206
|
+
unchecked: void 0
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (isActive) {
|
|
210
|
+
return {
|
|
211
|
+
checked: colorScheme.main,
|
|
212
|
+
unchecked: void 0
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
if (themeColor !== "default") {
|
|
216
|
+
return {
|
|
217
|
+
checked: colorScheme.foreground,
|
|
218
|
+
unchecked: colorScheme.background
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
checked: theme.colors.foreground,
|
|
223
|
+
unchecked: theme.colors.background
|
|
113
224
|
};
|
|
225
|
+
}, [variant, colorScheme, isActive, themeColor, theme.colors]);
|
|
226
|
+
return checkmarkColors;
|
|
227
|
+
}
|
|
228
|
+
function useVariantStyles(themeColor, variant, isActive) {
|
|
229
|
+
const theme = useXUITheme();
|
|
230
|
+
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
231
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
232
|
+
const variantStyles = useMemo(() => {
|
|
114
233
|
if (variant === "filled") {
|
|
115
234
|
return {
|
|
116
|
-
...baseStyle,
|
|
117
235
|
backgroundColor: "transparent",
|
|
118
236
|
borderWidth: isActive ? 0 : theme.borderWidth.md,
|
|
119
237
|
borderColor: isActive ? "transparent" : colorScheme.main
|
|
120
238
|
};
|
|
121
239
|
}
|
|
122
240
|
return {
|
|
123
|
-
...baseStyle,
|
|
124
241
|
backgroundColor: "transparent",
|
|
125
242
|
borderWidth: 0,
|
|
126
243
|
borderColor: "transparent"
|
|
127
244
|
};
|
|
128
|
-
}, [variant, isActive, colorScheme,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
if (isActive) {
|
|
134
|
-
return colorScheme.main;
|
|
135
|
-
}
|
|
136
|
-
if (themeColor !== "default") {
|
|
137
|
-
return colorScheme.background;
|
|
138
|
-
}
|
|
139
|
-
return theme.colors.foreground;
|
|
140
|
-
}, [variant, colorScheme, isActive, themeColor, theme.colors.foreground]);
|
|
245
|
+
}, [variant, isActive, colorScheme, theme]);
|
|
246
|
+
return variantStyles;
|
|
247
|
+
}
|
|
248
|
+
function useContainerStyles(labelAlignment) {
|
|
141
249
|
const containerStyles = useMemo(() => {
|
|
142
250
|
const isJustified = labelAlignment === "justify-left" || labelAlignment === "justify-right";
|
|
143
251
|
return {
|
|
@@ -145,15 +253,8 @@ var useCheckboxStyles = (themeColor, variant, size, radius, labelAlignment, isAc
|
|
|
145
253
|
justifyContent: isJustified ? "space-between" : "flex-start"
|
|
146
254
|
};
|
|
147
255
|
}, [labelAlignment]);
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
sizeStyles,
|
|
151
|
-
radiusStyles,
|
|
152
|
-
checkboxStyles,
|
|
153
|
-
checkmarkColor,
|
|
154
|
-
containerStyles
|
|
155
|
-
};
|
|
156
|
-
};
|
|
256
|
+
return containerStyles;
|
|
257
|
+
}
|
|
157
258
|
|
|
158
259
|
// src/components/checkbox/checkbox.style.ts
|
|
159
260
|
import { StyleSheet } from "react-native";
|
|
@@ -194,6 +295,7 @@ var styles = StyleSheet.create({
|
|
|
194
295
|
});
|
|
195
296
|
|
|
196
297
|
// src/components/checkbox/checkbox.tsx
|
|
298
|
+
import { getSafeThemeColor as getSafeThemeColor2 } from "@xaui/core";
|
|
197
299
|
var Checkbox = ({
|
|
198
300
|
label,
|
|
199
301
|
labelAlignment = "right",
|
|
@@ -210,56 +312,25 @@ var Checkbox = ({
|
|
|
210
312
|
onValueChange
|
|
211
313
|
}) => {
|
|
212
314
|
const theme = useXUITheme();
|
|
315
|
+
const colorScheme = theme.colors[getSafeThemeColor2(themeColor)];
|
|
213
316
|
const isControlled = typeof isCheckedProp === "boolean";
|
|
214
317
|
const [internalChecked, setInternalChecked] = useState(isCheckedProp ?? false);
|
|
215
318
|
const isChecked = isControlled ? isCheckedProp : internalChecked;
|
|
216
|
-
const scale = useRef2(new
|
|
217
|
-
const backgroundScale = useRef2(new
|
|
218
|
-
const backgroundOpacity = useRef2(new
|
|
319
|
+
const scale = useRef2(new Animated3.Value(1)).current;
|
|
320
|
+
const backgroundScale = useRef2(new Animated3.Value(0.5)).current;
|
|
321
|
+
const backgroundOpacity = useRef2(new Animated3.Value(0)).current;
|
|
219
322
|
const isActive = isChecked || isIndeterminate;
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
checkmarkColor,
|
|
226
|
-
containerStyles
|
|
227
|
-
} = useCheckboxStyles(
|
|
228
|
-
themeColor,
|
|
229
|
-
variant,
|
|
230
|
-
size,
|
|
231
|
-
radius,
|
|
232
|
-
labelAlignment,
|
|
233
|
-
isActive
|
|
234
|
-
);
|
|
323
|
+
const sizeStyles = useSizeStyles(size, variant);
|
|
324
|
+
const radiusStyles = useRadiusStyles(radius);
|
|
325
|
+
const checkmarkColors = useCheckmarkColors(themeColor, variant, isActive);
|
|
326
|
+
const variantStyles = useVariantStyles(themeColor, variant, isActive);
|
|
327
|
+
const containerStyles = useContainerStyles(labelAlignment);
|
|
235
328
|
useEffect2(() => {
|
|
236
329
|
if (variant !== "filled") return;
|
|
237
330
|
if (isActive) {
|
|
238
|
-
|
|
239
|
-
Animated2.timing(backgroundScale, {
|
|
240
|
-
toValue: 1,
|
|
241
|
-
duration: 200,
|
|
242
|
-
useNativeDriver: true
|
|
243
|
-
}),
|
|
244
|
-
Animated2.timing(backgroundOpacity, {
|
|
245
|
-
toValue: 1,
|
|
246
|
-
duration: 200,
|
|
247
|
-
useNativeDriver: true
|
|
248
|
-
})
|
|
249
|
-
]).start();
|
|
331
|
+
runBackgroundInAnimation(backgroundScale, backgroundOpacity);
|
|
250
332
|
} else {
|
|
251
|
-
|
|
252
|
-
Animated2.timing(backgroundScale, {
|
|
253
|
-
toValue: 0.5,
|
|
254
|
-
duration: 200,
|
|
255
|
-
useNativeDriver: true
|
|
256
|
-
}),
|
|
257
|
-
Animated2.timing(backgroundOpacity, {
|
|
258
|
-
toValue: 0,
|
|
259
|
-
duration: 200,
|
|
260
|
-
useNativeDriver: true
|
|
261
|
-
})
|
|
262
|
-
]).start();
|
|
333
|
+
runBackgroundOutAnimation(backgroundScale, backgroundOpacity);
|
|
263
334
|
}
|
|
264
335
|
}, [isActive, variant, backgroundScale, backgroundOpacity]);
|
|
265
336
|
const handlePress = () => {
|
|
@@ -273,18 +344,12 @@ var Checkbox = ({
|
|
|
273
344
|
};
|
|
274
345
|
const handlePressIn = () => {
|
|
275
346
|
if (!isDisabled) {
|
|
276
|
-
|
|
277
|
-
toValue: 0.95,
|
|
278
|
-
useNativeDriver: true
|
|
279
|
-
}).start();
|
|
347
|
+
runPressInAnimation(scale);
|
|
280
348
|
}
|
|
281
349
|
};
|
|
282
350
|
const handlePressOut = () => {
|
|
283
351
|
if (!isDisabled) {
|
|
284
|
-
|
|
285
|
-
toValue: 1,
|
|
286
|
-
useNativeDriver: true
|
|
287
|
-
}).start();
|
|
352
|
+
runPressOutAnimation(scale);
|
|
288
353
|
}
|
|
289
354
|
};
|
|
290
355
|
const accessibilityChecked = isIndeterminate ? "mixed" : isChecked;
|
|
@@ -311,18 +376,23 @@ var Checkbox = ({
|
|
|
311
376
|
]
|
|
312
377
|
},
|
|
313
378
|
/* @__PURE__ */ React2.createElement(
|
|
314
|
-
|
|
379
|
+
Animated3.View,
|
|
315
380
|
{
|
|
316
381
|
style: [
|
|
317
382
|
styles.checkbox,
|
|
318
|
-
|
|
383
|
+
{
|
|
384
|
+
width: sizeStyles.checkboxSize,
|
|
385
|
+
height: sizeStyles.checkboxSize,
|
|
386
|
+
...radiusStyles,
|
|
387
|
+
...variantStyles
|
|
388
|
+
},
|
|
319
389
|
{
|
|
320
390
|
transform: [{ scale }]
|
|
321
391
|
}
|
|
322
392
|
]
|
|
323
393
|
},
|
|
324
394
|
variant === "filled" && /* @__PURE__ */ React2.createElement(
|
|
325
|
-
|
|
395
|
+
Animated3.View,
|
|
326
396
|
{
|
|
327
397
|
style: [
|
|
328
398
|
styles.background,
|
|
@@ -340,8 +410,10 @@ var Checkbox = ({
|
|
|
340
410
|
{
|
|
341
411
|
isChecked: isActive,
|
|
342
412
|
isIndeterminate,
|
|
343
|
-
color:
|
|
344
|
-
size: sizeStyles.iconSize
|
|
413
|
+
color: checkmarkColors.checked,
|
|
414
|
+
size: sizeStyles.iconSize,
|
|
415
|
+
placeholderColor: checkmarkColors.unchecked,
|
|
416
|
+
variant
|
|
345
417
|
}
|
|
346
418
|
))
|
|
347
419
|
),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
type ThemeColor = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'success' | 'default';
|
|
2
2
|
type Size = 'xs' | 'sm' | 'md' | 'lg';
|
|
3
|
+
type Radius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
3
4
|
|
|
4
|
-
export type { Size as S, ThemeColor as T };
|
|
5
|
+
export type { Radius as R, Size as S, ThemeColor as T };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
type ThemeColor = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'success' | 'default';
|
|
2
2
|
type Size = 'xs' | 'sm' | 'md' | 'lg';
|
|
3
|
+
type Radius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
3
4
|
|
|
4
|
-
export type { Size as S, ThemeColor as T };
|
|
5
|
+
export type { Radius as R, Size as S, ThemeColor as T };
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/progress/index.d.ts
CHANGED