@seed-design/lynx-react 0.2.0-alpha.3 → 0.3.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/lib/_virtual/_rolldown/runtime.js +13 -0
- package/lib/components/ActionButton/ActionButton.d.ts +26 -33
- package/lib/components/ActionButton/ActionButton.d.ts.map +1 -1
- package/lib/components/ActionButton/ActionButton.jsx +139 -120
- package/lib/components/ActionButton/index.d.ts +1 -1
- package/lib/components/AppBar/AppBar.d.ts +35 -0
- package/lib/components/AppBar/AppBar.d.ts.map +1 -0
- package/lib/components/AppBar/AppBar.jsx +132 -0
- package/lib/components/AppBar/AppBar.namespace.d.ts +2 -0
- package/lib/components/AppBar/AppBar.namespace.d.ts.map +1 -0
- package/lib/components/AppBar/AppBar.namespace.js +15 -0
- package/lib/components/AppBar/context.d.ts +13 -0
- package/lib/components/AppBar/context.d.ts.map +1 -0
- package/lib/components/AppBar/context.js +12 -0
- package/lib/components/AppBar/index.d.ts +3 -0
- package/lib/components/AppBar/index.d.ts.map +1 -0
- package/lib/components/AppBar/useAppBar.d.ts +15 -0
- package/lib/components/AppBar/useAppBar.d.ts.map +1 -0
- package/lib/components/AppBar/useAppBar.js +72 -0
- package/lib/components/Badge/Badge.d.ts +14 -0
- package/lib/components/Badge/Badge.d.ts.map +1 -0
- package/lib/components/Badge/Badge.jsx +15 -0
- package/lib/components/Badge/index.d.ts +2 -0
- package/lib/components/Badge/index.d.ts.map +1 -0
- package/lib/components/BottomSheet/BottomSheet.d.ts +22 -27
- package/lib/components/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/lib/components/BottomSheet/BottomSheet.jsx +127 -142
- package/lib/components/BottomSheet/BottomSheet.namespace.d.ts +1 -1
- package/lib/components/BottomSheet/BottomSheet.namespace.js +18 -1
- package/lib/components/BottomSheet/index.d.ts +2 -2
- package/lib/components/Box/Box.d.ts +20 -0
- package/lib/components/Box/Box.d.ts.map +1 -0
- package/lib/components/Box/Box.jsx +14 -0
- package/lib/components/Box/index.d.ts +2 -0
- package/lib/components/Box/index.d.ts.map +1 -0
- package/lib/components/Checkbox/Checkbox.d.ts +14 -31
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/components/Checkbox/Checkbox.jsx +107 -98
- package/lib/components/Checkbox/Checkbox.namespace.d.ts +1 -1
- package/lib/components/Checkbox/Checkbox.namespace.js +12 -1
- package/lib/components/Checkbox/index.d.ts +2 -2
- package/lib/components/Icon/Icon.d.ts +37 -0
- package/lib/components/Icon/Icon.d.ts.map +1 -0
- package/lib/components/Icon/Icon.jsx +143 -0
- package/lib/components/Icon/index.d.ts +2 -0
- package/lib/components/Icon/index.d.ts.map +1 -0
- package/lib/components/ProgressCircle/ProgressCircle.d.ts +4 -8
- package/lib/components/ProgressCircle/ProgressCircle.d.ts.map +1 -1
- package/lib/components/ProgressCircle/ProgressCircle.jsx +255 -260
- package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts +1 -1
- package/lib/components/ProgressCircle/ProgressCircle.namespace.js +9 -1
- package/lib/components/ProgressCircle/index.d.ts +2 -2
- package/lib/components/RadioGroup/RadioGroup.d.ts +12 -29
- package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/lib/components/RadioGroup/RadioGroup.jsx +134 -118
- package/lib/components/RadioGroup/RadioGroup.namespace.d.ts +1 -1
- package/lib/components/RadioGroup/RadioGroup.namespace.js +12 -1
- package/lib/components/RadioGroup/index.d.ts +2 -2
- package/lib/components/Stack/Stack.d.ts +33 -0
- package/lib/components/Stack/Stack.d.ts.map +1 -0
- package/lib/components/Stack/Stack.jsx +39 -0
- package/lib/components/Stack/index.d.ts +2 -0
- package/lib/components/Stack/index.d.ts.map +1 -0
- package/lib/components/Switch/Switch.d.ts +8 -14
- package/lib/components/Switch/Switch.d.ts.map +1 -1
- package/lib/components/Switch/Switch.jsx +82 -56
- package/lib/components/Switch/Switch.namespace.d.ts +1 -1
- package/lib/components/Switch/Switch.namespace.js +11 -1
- package/lib/components/Switch/index.d.ts +2 -2
- package/lib/components/TagGroup/TagGroup.d.ts +8 -14
- package/lib/components/TagGroup/TagGroup.d.ts.map +1 -1
- package/lib/components/TagGroup/TagGroup.jsx +42 -39
- package/lib/components/TagGroup/TagGroup.namespace.d.ts +1 -1
- package/lib/components/TagGroup/TagGroup.namespace.js +10 -1
- package/lib/components/TagGroup/index.d.ts +2 -2
- package/lib/components/Text/Text.d.ts +7 -0
- package/lib/components/Text/Text.d.ts.map +1 -0
- package/lib/components/Text/Text.jsx +28 -0
- package/lib/components/Text/index.d.ts +2 -0
- package/lib/components/Text/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +13 -7
- package/lib/components/index.d.ts.map +1 -1
- package/lib/hooks/index.d.ts +5 -3
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/useControllableState.js +23 -23
- package/lib/hooks/useIconColor.d.ts +6 -3
- package/lib/hooks/useIconColor.d.ts.map +1 -1
- package/lib/hooks/useIconColor.js +34 -37
- package/lib/hooks/usePressTap.d.ts +11 -8
- package/lib/hooks/usePressTap.d.ts.map +1 -1
- package/lib/hooks/usePressTap.js +31 -31
- package/lib/hooks/useSafeArea.d.ts +19 -0
- package/lib/hooks/useSafeArea.d.ts.map +1 -0
- package/lib/hooks/useSafeArea.js +33 -0
- package/lib/hooks/useSeedClassName.d.ts +27 -0
- package/lib/hooks/useSeedClassName.d.ts.map +1 -0
- package/lib/hooks/useSeedClassName.js +32 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +30 -3
- package/lib/types.d.ts +51 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/utils/children.d.ts +3 -0
- package/lib/utils/children.d.ts.map +1 -0
- package/lib/utils/children.js +8 -0
- package/lib/utils/create-slot-recipe-context.d.ts +13 -12
- package/lib/utils/create-slot-recipe-context.d.ts.map +1 -1
- package/lib/utils/create-slot-recipe-context.jsx +88 -70
- package/lib/utils/get-seed-class-name.d.ts +9 -7
- package/lib/utils/get-seed-class-name.d.ts.map +1 -1
- package/lib/utils/get-seed-class-name.js +29 -37
- package/lib/utils/index.d.ts +4 -4
- package/lib/utils/resolve-recipe-token.js +45 -43
- package/lib/utils/split-multiple-variants-props.js +32 -32
- package/lib/utils/styled.d.ts +83 -0
- package/lib/utils/styled.d.ts.map +1 -0
- package/lib/utils/styled.js +144 -0
- package/package.json +10 -9
- package/src/components/ActionButton/ActionButton.test.tsx +167 -0
- package/src/components/ActionButton/ActionButton.tsx +210 -169
- package/src/components/AppBar/AppBar.namespace.ts +18 -0
- package/src/components/AppBar/AppBar.test.tsx +270 -0
- package/src/components/AppBar/AppBar.tsx +288 -0
- package/src/components/AppBar/context.ts +27 -0
- package/src/components/AppBar/index.ts +21 -0
- package/src/components/AppBar/useAppBar.ts +100 -0
- package/src/components/Badge/Badge.test.tsx +54 -0
- package/src/components/Badge/Badge.tsx +32 -0
- package/src/components/Badge/index.ts +1 -0
- package/src/components/BottomSheet/BottomSheet.test.tsx +219 -0
- package/src/components/BottomSheet/BottomSheet.tsx +120 -83
- package/src/components/Box/Box.test.tsx +85 -0
- package/src/components/Box/Box.tsx +39 -0
- package/src/components/Box/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.tsx +106 -116
- package/src/components/Icon/Icon.tsx +265 -0
- package/src/components/Icon/index.ts +8 -0
- package/src/components/ProgressCircle/ProgressCircle.tsx +39 -25
- package/src/components/RadioGroup/RadioGroup.tsx +98 -117
- package/src/components/Stack/Stack.tsx +97 -0
- package/src/components/Stack/index.ts +1 -0
- package/src/components/Switch/Switch.tsx +59 -50
- package/src/components/TagGroup/TagGroup.tsx +27 -25
- package/src/components/Text/Text.tsx +64 -0
- package/src/components/Text/index.ts +1 -0
- package/src/components/index.ts +6 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/{__tests__/useControllableState.test.ts → useControllableState.test.ts} +1 -1
- package/src/hooks/{__tests__/useIconColor.test.ts → useIconColor.test.ts} +1 -1
- package/src/hooks/useIconColor.ts +22 -12
- package/src/hooks/{__tests__/usePressTap.test.ts → usePressTap.test.ts} +1 -1
- package/src/hooks/usePressTap.ts +14 -10
- package/src/hooks/useSafeArea.test.ts +83 -0
- package/src/hooks/useSafeArea.ts +56 -0
- package/src/hooks/useSeedClassName.ts +35 -0
- package/src/index.ts +1 -0
- package/src/types.ts +76 -0
- package/src/utils/children.ts +13 -0
- package/src/utils/create-slot-recipe-context.test.tsx +96 -0
- package/src/utils/create-slot-recipe-context.tsx +55 -15
- package/src/utils/get-seed-class-name.ts +10 -12
- package/src/utils/{__tests__/split-multiple-variants-props.test.ts → split-multiple-variants-props.test.ts} +1 -1
- package/src/utils/styled.ts +442 -0
- package/lib/components/ActionButton/index.js +0 -1
- package/lib/components/BottomSheet/index.js +0 -2
- package/lib/components/Checkbox/index.js +0 -2
- package/lib/components/ProgressCircle/index.js +0 -2
- package/lib/components/RadioGroup/index.js +0 -2
- package/lib/components/Switch/index.js +0 -2
- package/lib/components/TagGroup/index.js +0 -2
- package/lib/components/index.js +0 -7
- package/lib/hooks/index.js +0 -3
- package/lib/utils/index.js +0 -4
- package/src/components/ActionButton/__tests__/ActionButton.test.tsx +0 -35
- package/src/components/BottomSheet/__tests__/BottomSheet.test.tsx +0 -119
- package/src/components/__tests__/ProgressCircle.test.ts +0 -33
- package/src/components/__tests__/exports.test.ts +0 -38
- package/src/components/__tests__/switch.test.ts +0 -34
- package/src/utils/__tests__/create-slot-recipe-context.test.tsx +0 -228
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../src/components/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../src/components/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAInE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAKrF,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EAGvB,MAAM,aAAa,CAAC;AAsErB,MAAM,WAAW,mBACf,SAAQ,iBAAiB,EACvB,IAAI,CAAC,qBAAqB,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC,EAC5D,sBAAsB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,eAAO,MAAM,cAAc,qFAyDzB,CAAC;AAKH,MAAM,WAAW,mBAAoB,SAAQ,sBAAsB;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,cAAc,qFA+CzB,CAAC;AAKH,MAAM,WAAW,0BACf,SAAQ,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,EACzC,sBAAsB;CAAG;AAE7B,eAAO,MAAM,qBAAqB,4FA6BjC,CAAC;AAKF,MAAM,WAAW,4BACf,SAAQ,IAAI,CAAC,sBAAsB,EAAE,WAAW,GAAG,OAAO,CAAC;IAC3D,kGAAkG;IAClG,SAAS,CAAC,EAAE,YAAY,CAAC,oBAAoB,CAAC,CAAC;IAC/C,0GAA0G;IAC1G,OAAO,CAAC,EAAE,YAAY,CAAC,oBAAoB,CAAC,CAAC;CAC9C;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,qBA6B1E;yBA7Be,uBAAuB;;;AAkCvC,MAAM,WAAW,wBAAyB,SAAQ,sBAAsB;CAAG;AAE3E,eAAO,MAAM,mBAAmB,0FAoB/B,CAAC"}
|
|
@@ -1,144 +1,160 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { usePressTap } from "../../hooks/usePressTap.js";
|
|
2
|
+
import { InternalIcon } from "../Icon/Icon.jsx";
|
|
3
|
+
import { useControllableState } from "../../hooks/useControllableState.js";
|
|
4
|
+
import { splitMultipleVariantsProps } from "../../utils/split-multiple-variants-props.js";
|
|
3
5
|
import clsx from "clsx";
|
|
6
|
+
import * as React from "@lynx-js/react";
|
|
7
|
+
import { isValidElement } from "@lynx-js/react";
|
|
4
8
|
import { radio } from "@seed-design/lynx-css/recipes/radio";
|
|
5
9
|
import { radiomark } from "@seed-design/lynx-css/recipes/radiomark";
|
|
6
10
|
import { radioGroup } from "@seed-design/lynx-css/recipes/radio-group";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { useIconColor } from "../../hooks/useIconColor";
|
|
10
|
-
import { usePressTap } from "../../hooks/usePressTap";
|
|
11
|
-
import { capitalize, resolveRecipeToken } from "../../utils/resolve-recipe-token";
|
|
12
|
-
import { splitMultipleVariantsProps } from "../../utils/split-multiple-variants-props";
|
|
13
|
-
const RadioGroupContext = React.createContext(null);
|
|
11
|
+
//#region src/components/RadioGroup/RadioGroup.tsx
|
|
12
|
+
var RadioGroupContext = React.createContext(null);
|
|
14
13
|
function useRadioGroupContext(consumer) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
return ctx;
|
|
14
|
+
const ctx = React.useContext(RadioGroupContext);
|
|
15
|
+
if (!ctx) throw new Error(`<${consumer}/> must be rendered inside <RadioGroupRoot/>.`);
|
|
16
|
+
return ctx;
|
|
20
17
|
}
|
|
21
|
-
|
|
18
|
+
var RadioGroupItemContext = React.createContext(null);
|
|
22
19
|
function useRadioGroupItemContext(consumer) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
return ctx;
|
|
20
|
+
const ctx = React.useContext(RadioGroupItemContext);
|
|
21
|
+
if (!ctx) throw new Error(`<${consumer}/> must be rendered inside <RadioGroupItem/>.`);
|
|
22
|
+
return ctx;
|
|
28
23
|
}
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
return ctx;
|
|
24
|
+
var RadiomarkControlContext = React.createContext(null);
|
|
25
|
+
function useRadiomarkControlContext(consumer) {
|
|
26
|
+
const ctx = React.useContext(RadiomarkControlContext);
|
|
27
|
+
if (!ctx) throw new Error(`<${consumer}/> must be rendered inside <RadioGroupItemControl/>.`);
|
|
28
|
+
return ctx;
|
|
36
29
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
30
|
+
var RadioGroupRoot = React.forwardRef((props, ref) => {
|
|
31
|
+
const { children, className, value: valueProp, defaultValue, disabled = false, onValueChange, ...restProps } = props;
|
|
32
|
+
const [{ radio: radioVariantProps, radiomark: radiomarkVariantProps }, nativeProps] = splitMultipleVariantsProps(restProps, {
|
|
33
|
+
radio,
|
|
34
|
+
radiomark
|
|
35
|
+
});
|
|
36
|
+
const handleChange = React.useCallback((next) => {
|
|
37
|
+
if (next !== null) onValueChange?.(next);
|
|
38
|
+
}, [onValueChange]);
|
|
39
|
+
const [value, setValueInternal] = useControllableState({
|
|
40
|
+
value: valueProp !== void 0 ? valueProp : void 0,
|
|
41
|
+
defaultValue: defaultValue ?? null,
|
|
42
|
+
onChange: handleChange
|
|
43
|
+
});
|
|
44
|
+
const setValue = React.useCallback((next) => {
|
|
45
|
+
setValueInternal(next);
|
|
46
|
+
}, [setValueInternal]);
|
|
47
|
+
const rootClassName = radioGroup().root;
|
|
48
|
+
const contextValue = React.useMemo(() => ({
|
|
49
|
+
value,
|
|
50
|
+
setValue,
|
|
51
|
+
disabled,
|
|
52
|
+
radioVariantProps,
|
|
53
|
+
radiomarkVariantProps
|
|
54
|
+
}), [
|
|
55
|
+
value,
|
|
56
|
+
setValue,
|
|
57
|
+
disabled,
|
|
58
|
+
radioVariantProps,
|
|
59
|
+
radiomarkVariantProps
|
|
60
|
+
]);
|
|
61
|
+
return <RadioGroupContext.Provider value={contextValue}>
|
|
62
|
+
<view {...ref ? { ref } : {}} className={clsx(rootClassName, className)} {...nativeProps}>
|
|
59
63
|
{children}
|
|
60
64
|
</view>
|
|
61
|
-
</RadioGroupContext.Provider
|
|
65
|
+
</RadioGroupContext.Provider>;
|
|
62
66
|
});
|
|
63
67
|
RadioGroupRoot.displayName = "RadioGroupRoot";
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
68
|
+
var RadioGroupItem = React.forwardRef((props, ref) => {
|
|
69
|
+
const { value: itemValue, disabled: itemDisabled = false, children, className, ...nativeProps } = props;
|
|
70
|
+
const groupContext = useRadioGroupContext("RadioGroupItem");
|
|
71
|
+
const disabled = groupContext.disabled || itemDisabled;
|
|
72
|
+
const checked = groupContext.value === itemValue;
|
|
73
|
+
const select = React.useCallback(() => {
|
|
74
|
+
if (checked) return;
|
|
75
|
+
groupContext.setValue(itemValue);
|
|
76
|
+
}, [
|
|
77
|
+
checked,
|
|
78
|
+
groupContext,
|
|
79
|
+
itemValue
|
|
80
|
+
]);
|
|
81
|
+
const { pressed, ...pressHandlers } = usePressTap({
|
|
82
|
+
disabled,
|
|
83
|
+
onTap: select
|
|
84
|
+
});
|
|
85
|
+
const rootClassName = radio({
|
|
86
|
+
...groupContext.radioVariantProps,
|
|
87
|
+
disabled
|
|
88
|
+
}).root;
|
|
89
|
+
const itemContextValue = React.useMemo(() => ({
|
|
90
|
+
value: itemValue,
|
|
91
|
+
checked,
|
|
92
|
+
disabled,
|
|
93
|
+
pressed,
|
|
94
|
+
select
|
|
95
|
+
}), [
|
|
96
|
+
itemValue,
|
|
97
|
+
checked,
|
|
98
|
+
disabled,
|
|
99
|
+
pressed,
|
|
100
|
+
select
|
|
101
|
+
]);
|
|
102
|
+
return <RadioGroupItemContext.Provider value={itemContextValue}>
|
|
103
|
+
<view {...ref ? { ref } : {}} className={clsx(rootClassName, className)} {...pressHandlers} {...nativeProps}>
|
|
88
104
|
{children}
|
|
89
105
|
</view>
|
|
90
|
-
</RadioGroupItemContext.Provider
|
|
106
|
+
</RadioGroupItemContext.Provider>;
|
|
91
107
|
});
|
|
92
108
|
RadioGroupItem.displayName = "RadioGroupItem";
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
var RadioGroupItemControl = React.forwardRef((props, ref) => {
|
|
110
|
+
const [variantProps, restProps] = radiomark.splitVariantProps(props);
|
|
111
|
+
const { children, className, ...nativeProps } = restProps;
|
|
112
|
+
const groupContext = useRadioGroupContext("RadioGroupItemControl");
|
|
113
|
+
const itemContext = useRadioGroupItemContext("RadioGroupItemControl");
|
|
114
|
+
const radiomarkVariantProps = {
|
|
115
|
+
...groupContext.radiomarkVariantProps,
|
|
116
|
+
...variantProps,
|
|
117
|
+
checked: itemContext.checked,
|
|
118
|
+
disabled: itemContext.disabled,
|
|
119
|
+
pressed: itemContext.pressed
|
|
120
|
+
};
|
|
121
|
+
const classes = radiomark(radiomarkVariantProps);
|
|
122
|
+
return <RadiomarkControlContext.Provider value={{
|
|
123
|
+
iconClassName: classes.icon,
|
|
124
|
+
radiomarkVariantProps
|
|
125
|
+
}}>
|
|
126
|
+
<view {...ref ? { ref } : {}} className={clsx(classes.root, className)} {...nativeProps}>
|
|
101
127
|
{children}
|
|
102
128
|
</view>
|
|
103
|
-
</
|
|
129
|
+
</RadiomarkControlContext.Provider>;
|
|
104
130
|
});
|
|
105
131
|
RadioGroupItemControl.displayName = "RadioGroupItemControl";
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// recipe 토큰에서 꺼낸 사이즈를 inline 으로 주입해 덮는다.
|
|
120
|
-
const iconSize = resolveRecipeToken(radiomarkVars, [
|
|
121
|
-
`size${capitalize(size)}`,
|
|
122
|
-
disabled ? "disabled" : "enabled",
|
|
123
|
-
"icon",
|
|
124
|
-
"size",
|
|
125
|
-
]);
|
|
126
|
-
return cloneElement(icon, {
|
|
127
|
-
...iconColor,
|
|
128
|
-
className: clsx(iconClassName, icon.props.className, className),
|
|
129
|
-
style: iconSize
|
|
130
|
-
? { width: iconSize, height: iconSize, ...icon.props.style, ...style }
|
|
131
|
-
: { ...icon.props.style, ...style },
|
|
132
|
-
});
|
|
132
|
+
function RadioGroupItemIndicator(props) {
|
|
133
|
+
const { unchecked, checked: checkedIcon, className, style } = props;
|
|
134
|
+
const itemContext = useRadioGroupItemContext("RadioGroupItemIndicator");
|
|
135
|
+
const { iconClassName, radiomarkVariantProps } = useRadiomarkControlContext("RadioGroupItemIndicator");
|
|
136
|
+
const icon = itemContext.checked ? checkedIcon : unchecked;
|
|
137
|
+
if (!icon || !isValidElement(icon)) return <view className={clsx(iconClassName, className)} style={style} />;
|
|
138
|
+
return <InternalIcon icon={icon} className={clsx(iconClassName, className)} style={style} deps={[
|
|
139
|
+
itemContext.checked,
|
|
140
|
+
itemContext.disabled,
|
|
141
|
+
itemContext.pressed,
|
|
142
|
+
radiomarkVariantProps.tone,
|
|
143
|
+
radiomarkVariantProps.size
|
|
144
|
+
]} />;
|
|
133
145
|
}
|
|
134
146
|
RadioGroupItemIndicator.displayName = "RadioGroupItemIndicator";
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
var RadioGroupItemLabel = React.forwardRef((props, ref) => {
|
|
148
|
+
const { children, className, ...nativeProps } = props;
|
|
149
|
+
const itemContext = useRadioGroupItemContext("RadioGroupItemLabel");
|
|
150
|
+
const labelClassName = radio({
|
|
151
|
+
...useRadioGroupContext("RadioGroupItemLabel").radioVariantProps,
|
|
152
|
+
disabled: itemContext.disabled
|
|
153
|
+
}).label;
|
|
154
|
+
return <text {...ref ? { ref } : {}} className={clsx(labelClassName, className)} {...nativeProps}>
|
|
141
155
|
{children}
|
|
142
|
-
</text
|
|
156
|
+
</text>;
|
|
143
157
|
});
|
|
144
158
|
RadioGroupItemLabel.displayName = "RadioGroupItemLabel";
|
|
159
|
+
//#endregion
|
|
160
|
+
export { RadioGroupItem, RadioGroupItemControl, RadioGroupItemIndicator, RadioGroupItemLabel, RadioGroupRoot };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { RadioGroupItem as Item, RadioGroupItemControl as ItemControl, RadioGroupItemIndicator as ItemIndicator, RadioGroupItemLabel as ItemLabel, RadioGroupRoot as Root, type RadioGroupItemControlProps as ItemControlProps, type RadioGroupItemIndicatorProps as ItemIndicatorProps, type RadioGroupItemLabelProps as ItemLabelProps, type RadioGroupItemProps as ItemProps, type RadioGroupRootProps as RootProps, } from
|
|
1
|
+
export { RadioGroupItem as Item, RadioGroupItemControl as ItemControl, RadioGroupItemIndicator as ItemIndicator, RadioGroupItemLabel as ItemLabel, RadioGroupRoot as Root, type RadioGroupItemControlProps as ItemControlProps, type RadioGroupItemIndicatorProps as ItemIndicatorProps, type RadioGroupItemLabelProps as ItemLabelProps, type RadioGroupItemProps as ItemProps, type RadioGroupRootProps as RootProps, } from './RadioGroup';
|
|
2
2
|
//# sourceMappingURL=RadioGroup.namespace.d.ts.map
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { RadioGroupItem, RadioGroupItemControl, RadioGroupItemIndicator, RadioGroupItemLabel, RadioGroupRoot } from "./RadioGroup.jsx";
|
|
3
|
+
//#region src/components/RadioGroup/RadioGroup.namespace.ts
|
|
4
|
+
var RadioGroup_namespace_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
Item: () => RadioGroupItem,
|
|
6
|
+
ItemControl: () => RadioGroupItemControl,
|
|
7
|
+
ItemIndicator: () => RadioGroupItemIndicator,
|
|
8
|
+
ItemLabel: () => RadioGroupItemLabel,
|
|
9
|
+
Root: () => RadioGroupRoot
|
|
10
|
+
});
|
|
11
|
+
//#endregion
|
|
12
|
+
export { RadioGroup_namespace_exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { RadioGroupRoot, RadioGroupItem, RadioGroupItemControl, RadioGroupItemIndicator, RadioGroupItemLabel, type RadioGroupRootProps, type RadioGroupItemProps, type RadioGroupItemControlProps, type RadioGroupItemIndicatorProps, type RadioGroupItemLabelProps, } from
|
|
2
|
-
export * as RadioGroup from
|
|
1
|
+
export { RadioGroupRoot, RadioGroupItem, RadioGroupItemControl, RadioGroupItemIndicator, RadioGroupItemLabel, type RadioGroupRootProps, type RadioGroupItemProps, type RadioGroupItemControlProps, type RadioGroupItemIndicatorProps, type RadioGroupItemLabelProps, } from './RadioGroup';
|
|
2
|
+
export * as RadioGroup from './RadioGroup.namespace';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LynxPressableProps, LynxStyledElementProps } from '../../types';
|
|
2
|
+
import { StyleProps } from '../../utils/styled';
|
|
3
|
+
import * as React from "@lynx-js/react";
|
|
4
|
+
type StackStyleProps = "display" | "flexDirection" | "alignItems" | "justifyContent" | "flexWrap" | "flexGrow" | "flexShrink";
|
|
5
|
+
interface StackBaseProps extends StyleProps, LynxStyledElementProps, LynxPressableProps {
|
|
6
|
+
bindtouchstart?: () => void;
|
|
7
|
+
bindtouchend?: () => void;
|
|
8
|
+
bindtouchcancel?: () => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @platform Lynx
|
|
12
|
+
*
|
|
13
|
+
* `VStack`과 `HStack`은 native `<view>`를 직접 렌더링하고 stack 방향에 필요한
|
|
14
|
+
* 최소 flex style만 적용합니다. 앱 코드에서 성능에 민감한 반복 레이아웃을 만들
|
|
15
|
+
* 때는 native `<view>`/`<text>`와 Tailwind utility className을 우선 고려하세요.
|
|
16
|
+
* 패키지 컴포넌트 내부에서는 `Box`를 합성하지 않고 native tag와 recipe className을
|
|
17
|
+
* 사용해 primitive 컴포넌트 비용이 누적되지 않도록 합니다.
|
|
18
|
+
*/
|
|
19
|
+
export interface StackProps extends Omit<StackBaseProps, StackStyleProps> {
|
|
20
|
+
align?: StackBaseProps["alignItems"];
|
|
21
|
+
justify?: StackBaseProps["justifyContent"];
|
|
22
|
+
wrap?: StackBaseProps["flexWrap"];
|
|
23
|
+
grow?: StackBaseProps["flexGrow"];
|
|
24
|
+
shrink?: StackBaseProps["flexShrink"];
|
|
25
|
+
}
|
|
26
|
+
export interface VStackProps extends StackProps {
|
|
27
|
+
}
|
|
28
|
+
export interface HStackProps extends StackProps {
|
|
29
|
+
}
|
|
30
|
+
export declare const VStack: React.ForwardRefExoticComponent<VStackProps & React.RefAttributes<unknown>>;
|
|
31
|
+
export declare const HStack: React.ForwardRefExoticComponent<HStackProps & React.RefAttributes<unknown>>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=Stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stack.d.ts","sourceRoot":"","sources":["../../../src/components/Stack/Stack.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAExC,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAe,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEpE,KAAK,eAAe,GAChB,SAAS,GACT,eAAe,GACf,YAAY,GACZ,gBAAgB,GAChB,UAAU,GACV,UAAU,GACV,YAAY,CAAC;AAEjB,UAAU,cAAe,SAAQ,UAAU,EAAE,sBAAsB,EAAE,kBAAkB;IACrF,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC;IACvE,KAAK,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAC3C,IAAI,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAClC,IAAI,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;CAAG;AAElD,MAAM,WAAW,WAAY,SAAQ,UAAU;CAAG;AA0ClD,eAAO,MAAM,MAAM,6EAIjB,CAAC;AAIH,eAAO,MAAM,MAAM,6EAIjB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useStyleProps } from "../../utils/styled.js";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import * as React from "@lynx-js/react";
|
|
4
|
+
//#region src/components/Stack/Stack.tsx
|
|
5
|
+
function getStackProps(props) {
|
|
6
|
+
const { align, justify, wrap, grow, shrink, ...restProps } = props;
|
|
7
|
+
return {
|
|
8
|
+
alignItems: align,
|
|
9
|
+
justifyContent: justify,
|
|
10
|
+
flexWrap: wrap,
|
|
11
|
+
flexGrow: grow,
|
|
12
|
+
flexShrink: shrink,
|
|
13
|
+
...restProps
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function useStackStyleProps(props, flexDirection) {
|
|
17
|
+
return useStyleProps({
|
|
18
|
+
display: "flex",
|
|
19
|
+
flexDirection,
|
|
20
|
+
...getStackProps(props)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function renderStackView(stackStyleProps, ref) {
|
|
24
|
+
const { style, restProps } = stackStyleProps;
|
|
25
|
+
const { children, className, ...nativeProps } = restProps;
|
|
26
|
+
return <view {...ref ? { ref } : {}} {...nativeProps} className={clsx(className)} style={style}>
|
|
27
|
+
{children}
|
|
28
|
+
</view>;
|
|
29
|
+
}
|
|
30
|
+
var VStack = React.forwardRef((props, ref) => {
|
|
31
|
+
return renderStackView(useStackStyleProps(props, "column"), ref);
|
|
32
|
+
});
|
|
33
|
+
VStack.displayName = "VStack";
|
|
34
|
+
var HStack = React.forwardRef((props, ref) => {
|
|
35
|
+
return renderStackView(useStackStyleProps(props, "row"), ref);
|
|
36
|
+
});
|
|
37
|
+
HStack.displayName = "HStack";
|
|
38
|
+
//#endregion
|
|
39
|
+
export { HStack, VStack };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Stack/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
className?: string;
|
|
1
|
+
import { SwitchVariantProps } from '@seed-design/lynx-css/recipes/switch';
|
|
2
|
+
import { SwitchmarkVariantProps } from '@seed-design/lynx-css/recipes/switchmark';
|
|
3
|
+
import { LynxStyledElementProps } from '../../types';
|
|
4
|
+
import * as React from "@lynx-js/react";
|
|
5
|
+
export interface SwitchRootProps extends SwitchVariantProps, Omit<SwitchmarkVariantProps, "size">, LynxStyledElementProps {
|
|
7
6
|
checked?: boolean;
|
|
8
7
|
defaultChecked?: boolean;
|
|
9
8
|
disabled?: boolean;
|
|
10
9
|
onCheckedChange?: (checked: boolean) => void;
|
|
11
10
|
}
|
|
12
11
|
export declare const SwitchRoot: React.ForwardRefExoticComponent<SwitchRootProps & React.RefAttributes<unknown>>;
|
|
13
|
-
export interface SwitchControlProps extends Pick<SwitchmarkVariantProps, "tone" | "size"
|
|
14
|
-
children?: React.ReactNode;
|
|
15
|
-
className?: string;
|
|
12
|
+
export interface SwitchControlProps extends Pick<SwitchmarkVariantProps, "tone" | "size">, LynxStyledElementProps {
|
|
16
13
|
}
|
|
17
14
|
export declare const SwitchControl: React.ForwardRefExoticComponent<SwitchControlProps & React.RefAttributes<unknown>>;
|
|
18
|
-
export interface SwitchThumbProps {
|
|
19
|
-
className?: string;
|
|
15
|
+
export interface SwitchThumbProps extends Pick<LynxStyledElementProps, "className" | "style"> {
|
|
20
16
|
}
|
|
21
17
|
export declare const SwitchThumb: React.ForwardRefExoticComponent<SwitchThumbProps & React.RefAttributes<unknown>>;
|
|
22
|
-
export interface SwitchLabelProps {
|
|
23
|
-
children?: React.ReactNode;
|
|
24
|
-
className?: string;
|
|
18
|
+
export interface SwitchLabelProps extends LynxStyledElementProps {
|
|
25
19
|
}
|
|
26
20
|
export declare const SwitchLabel: React.ForwardRefExoticComponent<SwitchLabelProps & React.RefAttributes<unknown>>;
|
|
27
21
|
//# sourceMappingURL=Switch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/components/Switch/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/components/Switch/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAIxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAKvF,OAAO,KAAK,EAAE,sBAAsB,EAA4B,MAAM,aAAa,CAAC;AAkDpF,MAAM,WAAW,eACf,SAAQ,kBAAkB,EACxB,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC,EACpC,sBAAsB;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED,eAAO,MAAM,UAAU,iFAmDrB,CAAC;AAKH,MAAM,WAAW,kBACf,SAAQ,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,MAAM,CAAC,EACnD,sBAAsB;CAAG;AAE7B,eAAO,MAAM,aAAa,oFAyBxB,CAAC;AAKH,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,sBAAsB,EAAE,WAAW,GAAG,OAAO,CAAC;CAAG;AAEhG,eAAO,MAAM,WAAW,kFAWtB,CAAC;AAKH,MAAM,WAAW,gBAAiB,SAAQ,sBAAsB;CAAG;AAEnE,eAAO,MAAM,WAAW,kFAiBtB,CAAC"}
|
|
@@ -1,75 +1,101 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { usePressTap } from "../../hooks/usePressTap.js";
|
|
2
|
+
import { useControllableState } from "../../hooks/useControllableState.js";
|
|
3
|
+
import { splitMultipleVariantsProps } from "../../utils/split-multiple-variants-props.js";
|
|
2
4
|
import clsx from "clsx";
|
|
5
|
+
import * as React from "@lynx-js/react";
|
|
3
6
|
import { switchStyle } from "@seed-design/lynx-css/recipes/switch";
|
|
4
7
|
import { switchmark } from "@seed-design/lynx-css/recipes/switchmark";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { usePressTap } from "../../hooks/usePressTap";
|
|
8
|
-
const SwitchContext = React.createContext(null);
|
|
8
|
+
//#region src/components/Switch/Switch.tsx
|
|
9
|
+
var SwitchContext = React.createContext(null);
|
|
9
10
|
function useSwitchContext(consumer) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
return ctx;
|
|
11
|
+
const ctx = React.useContext(SwitchContext);
|
|
12
|
+
if (!ctx) throw new Error(`<${consumer}/> must be rendered inside <SwitchRoot/>.`);
|
|
13
|
+
return ctx;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
return ctx;
|
|
15
|
+
var SwitchmarkControlContext = React.createContext(null);
|
|
16
|
+
function useSwitchmarkControlContext(consumer) {
|
|
17
|
+
const ctx = React.useContext(SwitchmarkControlContext);
|
|
18
|
+
if (!ctx) throw new Error(`<${consumer}/> must be rendered inside <SwitchControl/>.`);
|
|
19
|
+
return ctx;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
var SwitchRoot = React.forwardRef((props, ref) => {
|
|
22
|
+
const { children, className, checked: checkedProp, defaultChecked = false, disabled = false, onCheckedChange, ...restProps } = props;
|
|
23
|
+
const [{ switch: switchVariantProps, switchmark: switchmarkVariantProps }, nativeProps] = splitMultipleVariantsProps(restProps, {
|
|
24
|
+
switch: switchStyle,
|
|
25
|
+
switchmark
|
|
26
|
+
});
|
|
27
|
+
const [checked, setChecked] = useControllableState({
|
|
28
|
+
value: checkedProp,
|
|
29
|
+
defaultValue: defaultChecked,
|
|
30
|
+
onChange: onCheckedChange
|
|
31
|
+
});
|
|
32
|
+
const toggle = React.useCallback(() => setChecked(!checked), [checked, setChecked]);
|
|
33
|
+
const { pressed: _pressed, ...pressHandlers } = usePressTap({
|
|
34
|
+
disabled,
|
|
35
|
+
onTap: toggle
|
|
36
|
+
});
|
|
37
|
+
const rootClassName = switchStyle({
|
|
38
|
+
...switchVariantProps,
|
|
39
|
+
disabled
|
|
40
|
+
}).root;
|
|
41
|
+
const contextValue = React.useMemo(() => ({
|
|
42
|
+
checked,
|
|
43
|
+
disabled,
|
|
44
|
+
switchVariantProps,
|
|
45
|
+
switchmarkVariantProps,
|
|
46
|
+
toggle
|
|
47
|
+
}), [
|
|
48
|
+
checked,
|
|
49
|
+
disabled,
|
|
50
|
+
switchVariantProps,
|
|
51
|
+
switchmarkVariantProps,
|
|
52
|
+
toggle
|
|
53
|
+
]);
|
|
54
|
+
return <SwitchContext.Provider value={contextValue}>
|
|
55
|
+
<view {...ref ? { ref } : {}} className={clsx(rootClassName, className)} {...pressHandlers} {...nativeProps}>
|
|
42
56
|
{children}
|
|
43
57
|
</view>
|
|
44
|
-
</SwitchContext.Provider
|
|
58
|
+
</SwitchContext.Provider>;
|
|
45
59
|
});
|
|
46
60
|
SwitchRoot.displayName = "SwitchRoot";
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
var SwitchControl = React.forwardRef((props, ref) => {
|
|
62
|
+
const [variantProps, restProps] = switchmark.splitVariantProps(props);
|
|
63
|
+
const { children, className, ...nativeProps } = restProps;
|
|
64
|
+
const context = useSwitchContext("SwitchControl");
|
|
65
|
+
const switchmarkVariantProps = {
|
|
66
|
+
...context.switchmarkVariantProps,
|
|
67
|
+
...variantProps,
|
|
68
|
+
checked: context.checked,
|
|
69
|
+
disabled: context.disabled
|
|
70
|
+
};
|
|
71
|
+
const classes = switchmark(switchmarkVariantProps);
|
|
72
|
+
return <SwitchmarkControlContext.Provider value={{
|
|
73
|
+
thumbClassName: classes.thumb,
|
|
74
|
+
switchmarkVariantProps
|
|
75
|
+
}}>
|
|
76
|
+
<view {...ref ? { ref } : {}} className={clsx(classes.root, className)} {...nativeProps}>
|
|
56
77
|
{children}
|
|
57
78
|
</view>
|
|
58
|
-
</
|
|
79
|
+
</SwitchmarkControlContext.Provider>;
|
|
59
80
|
});
|
|
60
81
|
SwitchControl.displayName = "SwitchControl";
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
var SwitchThumb = React.forwardRef((props, ref) => {
|
|
83
|
+
const { className, ...nativeProps } = props;
|
|
84
|
+
const { thumbClassName } = useSwitchmarkControlContext("SwitchThumb");
|
|
85
|
+
return <view {...ref ? { ref } : {}} className={clsx(thumbClassName, className)} {...nativeProps} />;
|
|
65
86
|
});
|
|
66
87
|
SwitchThumb.displayName = "SwitchThumb";
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
88
|
+
var SwitchLabel = React.forwardRef((props, ref) => {
|
|
89
|
+
const { children, className, ...nativeProps } = props;
|
|
90
|
+
const context = useSwitchContext("SwitchLabel");
|
|
91
|
+
const labelClassName = switchStyle({
|
|
92
|
+
...context.switchVariantProps,
|
|
93
|
+
disabled: context.disabled
|
|
94
|
+
}).label;
|
|
95
|
+
return <text {...ref ? { ref } : {}} className={clsx(labelClassName, className)} {...nativeProps}>
|
|
72
96
|
{children}
|
|
73
|
-
</text
|
|
97
|
+
</text>;
|
|
74
98
|
});
|
|
75
99
|
SwitchLabel.displayName = "SwitchLabel";
|
|
100
|
+
//#endregion
|
|
101
|
+
export { SwitchControl, SwitchLabel, SwitchRoot, SwitchThumb };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { SwitchControl as Control, SwitchLabel as Label, SwitchRoot as Root, SwitchThumb as Thumb, type SwitchControlProps as ControlProps, type SwitchLabelProps as LabelProps, type SwitchRootProps as RootProps, type SwitchThumbProps as ThumbProps, } from
|
|
1
|
+
export { SwitchControl as Control, SwitchLabel as Label, SwitchRoot as Root, SwitchThumb as Thumb, type SwitchControlProps as ControlProps, type SwitchLabelProps as LabelProps, type SwitchRootProps as RootProps, type SwitchThumbProps as ThumbProps, } from './Switch';
|
|
2
2
|
//# sourceMappingURL=Switch.namespace.d.ts.map
|