@xaui/native 0.0.6 → 0.0.8
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 +1 -1
- package/dist/button/index.js +1 -1
- package/dist/checkbox/index.cjs +1 -1
- package/dist/checkbox/index.js +1 -1
- package/dist/switch/index.cjs +413 -0
- package/dist/switch/index.d.cts +28 -0
- package/dist/switch/index.d.ts +28 -0
- package/dist/switch/index.js +357 -0
- package/dist/view/index.cjs +960 -0
- package/dist/view/index.d.cts +517 -0
- package/dist/view/index.d.ts +517 -0
- package/dist/view/index.js +917 -0
- package/package.json +11 -1
package/dist/button/index.cjs
CHANGED
|
@@ -611,7 +611,7 @@ var runPressOutAnimation = (animatedScale, animatedOpacity) => {
|
|
|
611
611
|
// src/components/button/button.tsx
|
|
612
612
|
var Button = ({
|
|
613
613
|
children,
|
|
614
|
-
themeColor = "
|
|
614
|
+
themeColor = "primary",
|
|
615
615
|
variant = "solid",
|
|
616
616
|
size = "md",
|
|
617
617
|
radius = "md",
|
package/dist/button/index.js
CHANGED
|
@@ -185,7 +185,7 @@ var runPressOutAnimation = (animatedScale, animatedOpacity) => {
|
|
|
185
185
|
// src/components/button/button.tsx
|
|
186
186
|
var Button = ({
|
|
187
187
|
children,
|
|
188
|
-
themeColor = "
|
|
188
|
+
themeColor = "primary",
|
|
189
189
|
variant = "solid",
|
|
190
190
|
size = "md",
|
|
191
191
|
radius = "md",
|
package/dist/checkbox/index.cjs
CHANGED
package/dist/checkbox/index.js
CHANGED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/components/switch/index.ts
|
|
31
|
+
var switch_exports = {};
|
|
32
|
+
__export(switch_exports, {
|
|
33
|
+
Switch: () => Switch
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(switch_exports);
|
|
36
|
+
|
|
37
|
+
// src/components/switch/switch.tsx
|
|
38
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
39
|
+
var import_react_native5 = require("react-native");
|
|
40
|
+
|
|
41
|
+
// src/components/switch/switch.hook.ts
|
|
42
|
+
var import_react3 = require("react");
|
|
43
|
+
var import_core = require("@xaui/core");
|
|
44
|
+
|
|
45
|
+
// src/core/theme-context.tsx
|
|
46
|
+
var import_react = __toESM(require("react"), 1);
|
|
47
|
+
var import_react_native = require("react-native");
|
|
48
|
+
var import_theme = require("@xaui/core/theme");
|
|
49
|
+
var import_palette = require("@xaui/core/palette");
|
|
50
|
+
var XUIThemeContext = (0, import_react.createContext)(null);
|
|
51
|
+
|
|
52
|
+
// src/core/theme-hooks.ts
|
|
53
|
+
var import_react2 = require("react");
|
|
54
|
+
var import_react_native2 = require("react-native");
|
|
55
|
+
function useXUITheme() {
|
|
56
|
+
const theme = (0, import_react2.useContext)(XUIThemeContext);
|
|
57
|
+
if (!theme) {
|
|
58
|
+
throw new Error("useXUITheme must be used within XUIProvider");
|
|
59
|
+
}
|
|
60
|
+
return theme;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/core/index.ts
|
|
64
|
+
var import_theme2 = require("@xaui/core/theme");
|
|
65
|
+
|
|
66
|
+
// src/components/switch/switch.hook.ts
|
|
67
|
+
var useSwitchColorScheme = (themeColor) => {
|
|
68
|
+
const theme = useXUITheme();
|
|
69
|
+
const safeThemeColor = (0, import_core.getSafeThemeColor)(themeColor);
|
|
70
|
+
return theme.colors[safeThemeColor];
|
|
71
|
+
};
|
|
72
|
+
var useSwitchSizeStyles = (variant, size) => {
|
|
73
|
+
const theme = useXUITheme();
|
|
74
|
+
const sizeStyles = (0, import_react3.useMemo)(() => {
|
|
75
|
+
if (variant === "overlap") {
|
|
76
|
+
const sizes2 = {
|
|
77
|
+
sm: {
|
|
78
|
+
trackWidth: 40,
|
|
79
|
+
trackHeight: 16,
|
|
80
|
+
thumbSize: 22,
|
|
81
|
+
fontSize: theme.fontSizes.sm,
|
|
82
|
+
padding: 0
|
|
83
|
+
},
|
|
84
|
+
md: {
|
|
85
|
+
trackWidth: 48,
|
|
86
|
+
trackHeight: 18,
|
|
87
|
+
thumbSize: 26,
|
|
88
|
+
fontSize: theme.fontSizes.md,
|
|
89
|
+
padding: 0
|
|
90
|
+
},
|
|
91
|
+
lg: {
|
|
92
|
+
trackWidth: 56,
|
|
93
|
+
trackHeight: 20,
|
|
94
|
+
thumbSize: 30,
|
|
95
|
+
fontSize: theme.fontSizes.lg,
|
|
96
|
+
padding: 0
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return sizes2[size];
|
|
100
|
+
}
|
|
101
|
+
const sizes = {
|
|
102
|
+
sm: {
|
|
103
|
+
trackWidth: 40,
|
|
104
|
+
trackHeight: 24,
|
|
105
|
+
thumbSize: 18,
|
|
106
|
+
fontSize: theme.fontSizes.sm,
|
|
107
|
+
padding: 3
|
|
108
|
+
},
|
|
109
|
+
md: {
|
|
110
|
+
trackWidth: 48,
|
|
111
|
+
trackHeight: 28,
|
|
112
|
+
thumbSize: 22,
|
|
113
|
+
fontSize: theme.fontSizes.md,
|
|
114
|
+
padding: 3
|
|
115
|
+
},
|
|
116
|
+
lg: {
|
|
117
|
+
trackWidth: 56,
|
|
118
|
+
trackHeight: 32,
|
|
119
|
+
thumbSize: 26,
|
|
120
|
+
fontSize: theme.fontSizes.lg,
|
|
121
|
+
padding: 3
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return sizes[size];
|
|
125
|
+
}, [size, theme, variant]);
|
|
126
|
+
return sizeStyles;
|
|
127
|
+
};
|
|
128
|
+
var useSwitchRadiusStyles = (radius) => {
|
|
129
|
+
const theme = useXUITheme();
|
|
130
|
+
const radiusStyles = (0, import_react3.useMemo)(() => {
|
|
131
|
+
const radii = {
|
|
132
|
+
none: theme.borderRadius.none,
|
|
133
|
+
sm: theme.borderRadius.sm,
|
|
134
|
+
md: theme.borderRadius.md,
|
|
135
|
+
lg: theme.borderRadius.lg,
|
|
136
|
+
full: theme.borderRadius.full
|
|
137
|
+
};
|
|
138
|
+
return { borderRadius: radii[radius] };
|
|
139
|
+
}, [radius, theme]);
|
|
140
|
+
const thumbRadius = (0, import_react3.useMemo)(() => {
|
|
141
|
+
const radii = {
|
|
142
|
+
none: theme.borderRadius.none,
|
|
143
|
+
sm: theme.borderRadius.sm,
|
|
144
|
+
md: theme.borderRadius.md,
|
|
145
|
+
lg: theme.borderRadius.lg,
|
|
146
|
+
full: theme.borderRadius.full
|
|
147
|
+
};
|
|
148
|
+
return radii[radius];
|
|
149
|
+
}, [radius, theme]);
|
|
150
|
+
return { radiusStyles, thumbRadius };
|
|
151
|
+
};
|
|
152
|
+
var useSwitchTrackStyles = ({
|
|
153
|
+
colorScheme,
|
|
154
|
+
isSelected,
|
|
155
|
+
variant,
|
|
156
|
+
sizeStyles,
|
|
157
|
+
radiusStyles
|
|
158
|
+
}) => {
|
|
159
|
+
const theme = useXUITheme();
|
|
160
|
+
const trackStyles = (0, import_react3.useMemo)(() => {
|
|
161
|
+
const backgroundColor = isSelected ? variant === "overlap" ? colorScheme.background : colorScheme.main : theme.colors.default.background;
|
|
162
|
+
return {
|
|
163
|
+
width: sizeStyles.trackWidth,
|
|
164
|
+
height: sizeStyles.trackHeight,
|
|
165
|
+
backgroundColor,
|
|
166
|
+
paddingHorizontal: sizeStyles.padding,
|
|
167
|
+
...radiusStyles
|
|
168
|
+
};
|
|
169
|
+
}, [colorScheme, isSelected, radiusStyles, sizeStyles, theme, variant]);
|
|
170
|
+
return trackStyles;
|
|
171
|
+
};
|
|
172
|
+
var useSwitchThumbStyles = ({
|
|
173
|
+
colorScheme,
|
|
174
|
+
isSelected,
|
|
175
|
+
variant,
|
|
176
|
+
sizeStyles,
|
|
177
|
+
thumbRadius
|
|
178
|
+
}) => {
|
|
179
|
+
const theme = useXUITheme();
|
|
180
|
+
const thumbStyles = (0, import_react3.useMemo)(() => {
|
|
181
|
+
const baseStyle = {
|
|
182
|
+
width: sizeStyles.thumbSize,
|
|
183
|
+
height: sizeStyles.thumbSize,
|
|
184
|
+
borderRadius: thumbRadius,
|
|
185
|
+
backgroundColor: variant === "overlap" && isSelected ? colorScheme.main : theme.colors.background
|
|
186
|
+
};
|
|
187
|
+
if (variant !== "overlap") return baseStyle;
|
|
188
|
+
return {
|
|
189
|
+
...baseStyle,
|
|
190
|
+
...theme.shadows.sm
|
|
191
|
+
};
|
|
192
|
+
}, [colorScheme, isSelected, sizeStyles, theme, thumbRadius, variant]);
|
|
193
|
+
return thumbStyles;
|
|
194
|
+
};
|
|
195
|
+
var useSwitchContainerStyles = (labelAlignment) => {
|
|
196
|
+
const containerStyles = (0, import_react3.useMemo)(() => {
|
|
197
|
+
const isJustified = labelAlignment === "justify-left" || labelAlignment === "justify-right";
|
|
198
|
+
return {
|
|
199
|
+
flexDirection: labelAlignment === "left" || labelAlignment === "justify-left" ? "row-reverse" : "row",
|
|
200
|
+
justifyContent: isJustified ? "space-between" : "flex-start"
|
|
201
|
+
};
|
|
202
|
+
}, [labelAlignment]);
|
|
203
|
+
return containerStyles;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// src/components/switch/switch.animation.ts
|
|
207
|
+
var import_react_native3 = require("react-native");
|
|
208
|
+
var runThumbPositionAnimation = (thumbPosition, isSelected) => {
|
|
209
|
+
import_react_native3.Animated.spring(thumbPosition, {
|
|
210
|
+
toValue: isSelected ? 1 : 0,
|
|
211
|
+
useNativeDriver: true,
|
|
212
|
+
damping: 15,
|
|
213
|
+
stiffness: 150
|
|
214
|
+
}).start();
|
|
215
|
+
};
|
|
216
|
+
var runSwitchPressInAnimation = (animatedScale, animatedThumbScale, isOverlap) => {
|
|
217
|
+
import_react_native3.Animated.parallel([
|
|
218
|
+
import_react_native3.Animated.spring(animatedScale, {
|
|
219
|
+
toValue: 0.95,
|
|
220
|
+
useNativeDriver: true
|
|
221
|
+
}),
|
|
222
|
+
import_react_native3.Animated.spring(animatedThumbScale, {
|
|
223
|
+
toValue: isOverlap ? 1.1 : 1.2,
|
|
224
|
+
useNativeDriver: true
|
|
225
|
+
})
|
|
226
|
+
]).start();
|
|
227
|
+
};
|
|
228
|
+
var runSwitchPressOutAnimation = (animatedScale, animatedThumbScale) => {
|
|
229
|
+
import_react_native3.Animated.parallel([
|
|
230
|
+
import_react_native3.Animated.spring(animatedScale, {
|
|
231
|
+
toValue: 1,
|
|
232
|
+
useNativeDriver: true
|
|
233
|
+
}),
|
|
234
|
+
import_react_native3.Animated.spring(animatedThumbScale, {
|
|
235
|
+
toValue: 1,
|
|
236
|
+
useNativeDriver: true
|
|
237
|
+
})
|
|
238
|
+
]).start();
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// src/components/switch/switch.style.ts
|
|
242
|
+
var import_react_native4 = require("react-native");
|
|
243
|
+
var styles = import_react_native4.StyleSheet.create({
|
|
244
|
+
container: {
|
|
245
|
+
flexDirection: "row",
|
|
246
|
+
alignItems: "center",
|
|
247
|
+
gap: 8
|
|
248
|
+
},
|
|
249
|
+
fullWidth: {
|
|
250
|
+
width: "100%"
|
|
251
|
+
},
|
|
252
|
+
track: {
|
|
253
|
+
justifyContent: "center",
|
|
254
|
+
position: "relative"
|
|
255
|
+
},
|
|
256
|
+
thumbContainer: {
|
|
257
|
+
position: "relative",
|
|
258
|
+
width: "100%",
|
|
259
|
+
height: "100%",
|
|
260
|
+
alignItems: "center",
|
|
261
|
+
justifyContent: "center"
|
|
262
|
+
},
|
|
263
|
+
thumb: {
|
|
264
|
+
position: "absolute",
|
|
265
|
+
left: 0
|
|
266
|
+
},
|
|
267
|
+
label: {
|
|
268
|
+
fontWeight: "400"
|
|
269
|
+
},
|
|
270
|
+
disabled: {
|
|
271
|
+
opacity: 0.5
|
|
272
|
+
},
|
|
273
|
+
disabledText: {
|
|
274
|
+
opacity: 0.7
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// src/components/switch/switch.tsx
|
|
279
|
+
var Switch = ({
|
|
280
|
+
label,
|
|
281
|
+
labelAlignment = "right",
|
|
282
|
+
themeColor = "primary",
|
|
283
|
+
variant = "inside",
|
|
284
|
+
size = "md",
|
|
285
|
+
radius = "full",
|
|
286
|
+
fullWidth = false,
|
|
287
|
+
isSelected: isSelectedProp,
|
|
288
|
+
isDisabled = false,
|
|
289
|
+
labelStyle,
|
|
290
|
+
style,
|
|
291
|
+
onValueChange
|
|
292
|
+
}) => {
|
|
293
|
+
const theme = useXUITheme();
|
|
294
|
+
const isControlled = typeof isSelectedProp === "boolean";
|
|
295
|
+
const [internalSelected, setInternalSelected] = (0, import_react4.useState)(isSelectedProp ?? false);
|
|
296
|
+
const isSelected = isControlled ? isSelectedProp : internalSelected;
|
|
297
|
+
const scale = (0, import_react4.useRef)(new import_react_native5.Animated.Value(1)).current;
|
|
298
|
+
const thumbPosition = (0, import_react4.useRef)(new import_react_native5.Animated.Value(isSelected ? 1 : 0)).current;
|
|
299
|
+
const thumbScale = (0, import_react4.useRef)(new import_react_native5.Animated.Value(1)).current;
|
|
300
|
+
const colorScheme = useSwitchColorScheme(themeColor);
|
|
301
|
+
const sizeStyles = useSwitchSizeStyles(variant, size);
|
|
302
|
+
const { radiusStyles, thumbRadius } = useSwitchRadiusStyles(radius);
|
|
303
|
+
const trackStyles = useSwitchTrackStyles({
|
|
304
|
+
colorScheme,
|
|
305
|
+
isSelected,
|
|
306
|
+
variant,
|
|
307
|
+
sizeStyles,
|
|
308
|
+
radiusStyles
|
|
309
|
+
});
|
|
310
|
+
const thumbStyles = useSwitchThumbStyles({
|
|
311
|
+
colorScheme,
|
|
312
|
+
isSelected,
|
|
313
|
+
variant,
|
|
314
|
+
sizeStyles,
|
|
315
|
+
thumbRadius
|
|
316
|
+
});
|
|
317
|
+
const containerStyles = useSwitchContainerStyles(labelAlignment);
|
|
318
|
+
const maxTranslateX = (0, import_react4.useMemo)(() => {
|
|
319
|
+
if (variant === "overlap") {
|
|
320
|
+
return sizeStyles.trackWidth - sizeStyles.thumbSize;
|
|
321
|
+
}
|
|
322
|
+
return sizeStyles.trackWidth - sizeStyles.thumbSize - sizeStyles.padding * 2;
|
|
323
|
+
}, [sizeStyles, variant]);
|
|
324
|
+
const translateX = (0, import_react4.useMemo)(
|
|
325
|
+
() => thumbPosition.interpolate({
|
|
326
|
+
inputRange: [0, 1],
|
|
327
|
+
outputRange: [0, maxTranslateX]
|
|
328
|
+
}),
|
|
329
|
+
[maxTranslateX, thumbPosition]
|
|
330
|
+
);
|
|
331
|
+
(0, import_react4.useEffect)(() => {
|
|
332
|
+
runThumbPositionAnimation(thumbPosition, isSelected);
|
|
333
|
+
}, [isSelected, thumbPosition]);
|
|
334
|
+
const handlePress = () => {
|
|
335
|
+
if (isDisabled) return;
|
|
336
|
+
const nextValue = !isSelected;
|
|
337
|
+
onValueChange?.(nextValue);
|
|
338
|
+
if (!isControlled) {
|
|
339
|
+
setInternalSelected(nextValue);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
const handlePressIn = () => {
|
|
343
|
+
if (isDisabled) return;
|
|
344
|
+
runSwitchPressInAnimation(scale, thumbScale, variant === "overlap");
|
|
345
|
+
};
|
|
346
|
+
const handlePressOut = () => {
|
|
347
|
+
if (isDisabled) return;
|
|
348
|
+
runSwitchPressOutAnimation(scale, thumbScale);
|
|
349
|
+
};
|
|
350
|
+
return /* @__PURE__ */ import_react4.default.createElement(
|
|
351
|
+
import_react_native5.Pressable,
|
|
352
|
+
{
|
|
353
|
+
onPress: handlePress,
|
|
354
|
+
onPressIn: handlePressIn,
|
|
355
|
+
onPressOut: handlePressOut,
|
|
356
|
+
disabled: isDisabled,
|
|
357
|
+
accessible: true,
|
|
358
|
+
accessibilityRole: "switch",
|
|
359
|
+
accessibilityLabel: label,
|
|
360
|
+
accessibilityState: {
|
|
361
|
+
disabled: isDisabled,
|
|
362
|
+
checked: isSelected
|
|
363
|
+
},
|
|
364
|
+
style: [
|
|
365
|
+
styles.container,
|
|
366
|
+
containerStyles,
|
|
367
|
+
fullWidth && styles.fullWidth,
|
|
368
|
+
isDisabled && styles.disabled,
|
|
369
|
+
style
|
|
370
|
+
]
|
|
371
|
+
},
|
|
372
|
+
/* @__PURE__ */ import_react4.default.createElement(
|
|
373
|
+
import_react_native5.Animated.View,
|
|
374
|
+
{
|
|
375
|
+
style: [
|
|
376
|
+
styles.track,
|
|
377
|
+
trackStyles,
|
|
378
|
+
{
|
|
379
|
+
transform: [{ scale }]
|
|
380
|
+
}
|
|
381
|
+
]
|
|
382
|
+
},
|
|
383
|
+
/* @__PURE__ */ import_react4.default.createElement(import_react_native5.View, { style: styles.thumbContainer }, /* @__PURE__ */ import_react4.default.createElement(
|
|
384
|
+
import_react_native5.Animated.View,
|
|
385
|
+
{
|
|
386
|
+
style: [
|
|
387
|
+
styles.thumb,
|
|
388
|
+
thumbStyles,
|
|
389
|
+
{
|
|
390
|
+
transform: [{ translateX }, { scale: thumbScale }]
|
|
391
|
+
}
|
|
392
|
+
]
|
|
393
|
+
}
|
|
394
|
+
))
|
|
395
|
+
),
|
|
396
|
+
label && /* @__PURE__ */ import_react4.default.createElement(
|
|
397
|
+
import_react_native5.Text,
|
|
398
|
+
{
|
|
399
|
+
style: [
|
|
400
|
+
styles.label,
|
|
401
|
+
{ fontSize: sizeStyles.fontSize, color: theme.colors.foreground },
|
|
402
|
+
isDisabled && styles.disabledText,
|
|
403
|
+
labelStyle
|
|
404
|
+
]
|
|
405
|
+
},
|
|
406
|
+
label
|
|
407
|
+
)
|
|
408
|
+
);
|
|
409
|
+
};
|
|
410
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
411
|
+
0 && (module.exports = {
|
|
412
|
+
Switch
|
|
413
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
import { T as ThemeColor } from '../index-BOw6tbkc.cjs';
|
|
4
|
+
|
|
5
|
+
type SwitchVariant = 'inside' | 'overlap';
|
|
6
|
+
type SwitchSize = 'sm' | 'md' | 'lg';
|
|
7
|
+
type SwitchRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
8
|
+
type SwitchLabelAlignment = 'left' | 'right' | 'justify-left' | 'justify-right';
|
|
9
|
+
type SwitchEvents = {
|
|
10
|
+
onValueChange?: (isSelected: boolean) => void;
|
|
11
|
+
};
|
|
12
|
+
type SwitchProps = {
|
|
13
|
+
label?: string;
|
|
14
|
+
labelAlignment?: SwitchLabelAlignment;
|
|
15
|
+
themeColor?: ThemeColor;
|
|
16
|
+
variant?: SwitchVariant;
|
|
17
|
+
size?: SwitchSize;
|
|
18
|
+
radius?: SwitchRadius;
|
|
19
|
+
fullWidth?: boolean;
|
|
20
|
+
isSelected?: boolean;
|
|
21
|
+
isDisabled?: boolean;
|
|
22
|
+
labelStyle?: TextStyle;
|
|
23
|
+
style?: ViewStyle;
|
|
24
|
+
} & SwitchEvents;
|
|
25
|
+
|
|
26
|
+
declare const Switch: React.FC<SwitchProps>;
|
|
27
|
+
|
|
28
|
+
export { Switch, type SwitchLabelAlignment, type SwitchProps, type SwitchRadius, type SwitchSize, type SwitchVariant };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
import { T as ThemeColor } from '../index-BOw6tbkc.js';
|
|
4
|
+
|
|
5
|
+
type SwitchVariant = 'inside' | 'overlap';
|
|
6
|
+
type SwitchSize = 'sm' | 'md' | 'lg';
|
|
7
|
+
type SwitchRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
8
|
+
type SwitchLabelAlignment = 'left' | 'right' | 'justify-left' | 'justify-right';
|
|
9
|
+
type SwitchEvents = {
|
|
10
|
+
onValueChange?: (isSelected: boolean) => void;
|
|
11
|
+
};
|
|
12
|
+
type SwitchProps = {
|
|
13
|
+
label?: string;
|
|
14
|
+
labelAlignment?: SwitchLabelAlignment;
|
|
15
|
+
themeColor?: ThemeColor;
|
|
16
|
+
variant?: SwitchVariant;
|
|
17
|
+
size?: SwitchSize;
|
|
18
|
+
radius?: SwitchRadius;
|
|
19
|
+
fullWidth?: boolean;
|
|
20
|
+
isSelected?: boolean;
|
|
21
|
+
isDisabled?: boolean;
|
|
22
|
+
labelStyle?: TextStyle;
|
|
23
|
+
style?: ViewStyle;
|
|
24
|
+
} & SwitchEvents;
|
|
25
|
+
|
|
26
|
+
declare const Switch: React.FC<SwitchProps>;
|
|
27
|
+
|
|
28
|
+
export { Switch, type SwitchLabelAlignment, type SwitchProps, type SwitchRadius, type SwitchSize, type SwitchVariant };
|