@seed-design/lynx-react 0.2.0-alpha.2 → 0.2.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.
Files changed (186) hide show
  1. package/lib/_virtual/_rolldown/runtime.js +13 -0
  2. package/lib/components/ActionButton/ActionButton.d.ts +26 -32
  3. package/lib/components/ActionButton/ActionButton.d.ts.map +1 -1
  4. package/lib/components/ActionButton/ActionButton.jsx +139 -120
  5. package/lib/components/ActionButton/index.d.ts +1 -1
  6. package/lib/components/AppBar/AppBar.d.ts +35 -0
  7. package/lib/components/AppBar/AppBar.d.ts.map +1 -0
  8. package/lib/components/AppBar/AppBar.jsx +132 -0
  9. package/lib/components/AppBar/AppBar.namespace.d.ts +2 -0
  10. package/lib/components/AppBar/AppBar.namespace.d.ts.map +1 -0
  11. package/lib/components/AppBar/AppBar.namespace.js +15 -0
  12. package/lib/components/AppBar/context.d.ts +13 -0
  13. package/lib/components/AppBar/context.d.ts.map +1 -0
  14. package/lib/components/AppBar/context.js +12 -0
  15. package/lib/components/AppBar/index.d.ts +3 -0
  16. package/lib/components/AppBar/index.d.ts.map +1 -0
  17. package/lib/components/AppBar/useAppBar.d.ts +15 -0
  18. package/lib/components/AppBar/useAppBar.d.ts.map +1 -0
  19. package/lib/components/AppBar/useAppBar.js +72 -0
  20. package/lib/components/Badge/Badge.d.ts +14 -0
  21. package/lib/components/Badge/Badge.d.ts.map +1 -0
  22. package/lib/components/Badge/Badge.jsx +15 -0
  23. package/lib/components/Badge/index.d.ts +2 -0
  24. package/lib/components/Badge/index.d.ts.map +1 -0
  25. package/lib/components/BottomSheet/BottomSheet.d.ts +22 -27
  26. package/lib/components/BottomSheet/BottomSheet.d.ts.map +1 -1
  27. package/lib/components/BottomSheet/BottomSheet.jsx +127 -142
  28. package/lib/components/BottomSheet/BottomSheet.namespace.d.ts +1 -1
  29. package/lib/components/BottomSheet/BottomSheet.namespace.js +18 -1
  30. package/lib/components/BottomSheet/index.d.ts +2 -2
  31. package/lib/components/Box/Box.d.ts +20 -0
  32. package/lib/components/Box/Box.d.ts.map +1 -0
  33. package/lib/components/Box/Box.jsx +14 -0
  34. package/lib/components/Box/index.d.ts +2 -0
  35. package/lib/components/Box/index.d.ts.map +1 -0
  36. package/lib/components/Checkbox/Checkbox.d.ts +14 -30
  37. package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
  38. package/lib/components/Checkbox/Checkbox.jsx +107 -98
  39. package/lib/components/Checkbox/Checkbox.namespace.d.ts +1 -1
  40. package/lib/components/Checkbox/Checkbox.namespace.js +12 -1
  41. package/lib/components/Checkbox/index.d.ts +2 -2
  42. package/lib/components/Icon/Icon.d.ts +37 -0
  43. package/lib/components/Icon/Icon.d.ts.map +1 -0
  44. package/lib/components/Icon/Icon.jsx +143 -0
  45. package/lib/components/Icon/index.d.ts +2 -0
  46. package/lib/components/Icon/index.d.ts.map +1 -0
  47. package/lib/components/ProgressCircle/ProgressCircle.d.ts +4 -8
  48. package/lib/components/ProgressCircle/ProgressCircle.d.ts.map +1 -1
  49. package/lib/components/ProgressCircle/ProgressCircle.jsx +255 -260
  50. package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts +1 -1
  51. package/lib/components/ProgressCircle/ProgressCircle.namespace.js +9 -1
  52. package/lib/components/ProgressCircle/index.d.ts +2 -2
  53. package/lib/components/RadioGroup/RadioGroup.d.ts +12 -28
  54. package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
  55. package/lib/components/RadioGroup/RadioGroup.jsx +134 -118
  56. package/lib/components/RadioGroup/RadioGroup.namespace.d.ts +1 -1
  57. package/lib/components/RadioGroup/RadioGroup.namespace.js +12 -1
  58. package/lib/components/RadioGroup/index.d.ts +2 -2
  59. package/lib/components/Stack/Stack.d.ts +33 -0
  60. package/lib/components/Stack/Stack.d.ts.map +1 -0
  61. package/lib/components/Stack/Stack.jsx +39 -0
  62. package/lib/components/Stack/index.d.ts +2 -0
  63. package/lib/components/Stack/index.d.ts.map +1 -0
  64. package/lib/components/Switch/Switch.d.ts +8 -14
  65. package/lib/components/Switch/Switch.d.ts.map +1 -1
  66. package/lib/components/Switch/Switch.jsx +82 -56
  67. package/lib/components/Switch/Switch.namespace.d.ts +1 -1
  68. package/lib/components/Switch/Switch.namespace.js +11 -1
  69. package/lib/components/Switch/index.d.ts +2 -2
  70. package/lib/components/TagGroup/TagGroup.d.ts +8 -14
  71. package/lib/components/TagGroup/TagGroup.d.ts.map +1 -1
  72. package/lib/components/TagGroup/TagGroup.jsx +42 -39
  73. package/lib/components/TagGroup/TagGroup.namespace.d.ts +1 -1
  74. package/lib/components/TagGroup/TagGroup.namespace.js +10 -1
  75. package/lib/components/TagGroup/index.d.ts +2 -2
  76. package/lib/components/Text/Text.d.ts +7 -0
  77. package/lib/components/Text/Text.d.ts.map +1 -0
  78. package/lib/components/Text/Text.jsx +28 -0
  79. package/lib/components/Text/index.d.ts +2 -0
  80. package/lib/components/Text/index.d.ts.map +1 -0
  81. package/lib/components/index.d.ts +13 -7
  82. package/lib/components/index.d.ts.map +1 -1
  83. package/lib/hooks/index.d.ts +4 -3
  84. package/lib/hooks/index.d.ts.map +1 -1
  85. package/lib/hooks/{use-controllable-state.d.ts → useControllableState.d.ts} +1 -1
  86. package/lib/hooks/useControllableState.d.ts.map +1 -0
  87. package/lib/hooks/useControllableState.js +27 -0
  88. package/lib/hooks/useIconColor.d.ts +19 -0
  89. package/lib/hooks/useIconColor.d.ts.map +1 -0
  90. package/lib/hooks/useIconColor.js +38 -0
  91. package/lib/hooks/{use-press-tap.d.ts → usePressTap.d.ts} +12 -9
  92. package/lib/hooks/usePressTap.d.ts.map +1 -0
  93. package/lib/hooks/usePressTap.js +35 -0
  94. package/lib/hooks/useSafeArea.d.ts +19 -0
  95. package/lib/hooks/useSafeArea.d.ts.map +1 -0
  96. package/lib/hooks/useSafeArea.js +33 -0
  97. package/lib/index.d.ts +4 -3
  98. package/lib/index.d.ts.map +1 -1
  99. package/lib/index.js +29 -3
  100. package/lib/types.d.ts +51 -0
  101. package/lib/types.d.ts.map +1 -0
  102. package/lib/utils/children.d.ts +3 -0
  103. package/lib/utils/children.d.ts.map +1 -0
  104. package/lib/utils/children.js +8 -0
  105. package/lib/utils/create-slot-recipe-context.d.ts +13 -12
  106. package/lib/utils/create-slot-recipe-context.d.ts.map +1 -1
  107. package/lib/utils/create-slot-recipe-context.jsx +88 -70
  108. package/lib/utils/get-seed-class-name.d.ts +6 -7
  109. package/lib/utils/get-seed-class-name.d.ts.map +1 -1
  110. package/lib/utils/get-seed-class-name.js +26 -37
  111. package/lib/utils/index.d.ts +4 -4
  112. package/lib/utils/resolve-recipe-token.js +45 -43
  113. package/lib/utils/split-multiple-variants-props.js +32 -32
  114. package/lib/utils/styled.d.ts +83 -0
  115. package/lib/utils/styled.d.ts.map +1 -0
  116. package/lib/utils/styled.js +144 -0
  117. package/package.json +9 -9
  118. package/src/components/ActionButton/ActionButton.test.tsx +167 -0
  119. package/src/components/ActionButton/ActionButton.tsx +210 -168
  120. package/src/components/AppBar/AppBar.namespace.ts +18 -0
  121. package/src/components/AppBar/AppBar.test.tsx +270 -0
  122. package/src/components/AppBar/AppBar.tsx +288 -0
  123. package/src/components/AppBar/context.ts +27 -0
  124. package/src/components/AppBar/index.ts +21 -0
  125. package/src/components/AppBar/useAppBar.ts +100 -0
  126. package/src/components/Badge/Badge.test.tsx +54 -0
  127. package/src/components/Badge/Badge.tsx +32 -0
  128. package/src/components/Badge/index.ts +1 -0
  129. package/src/components/BottomSheet/BottomSheet.test.tsx +219 -0
  130. package/src/components/BottomSheet/BottomSheet.tsx +120 -83
  131. package/src/components/Box/Box.test.tsx +85 -0
  132. package/src/components/Box/Box.tsx +39 -0
  133. package/src/components/Box/index.ts +1 -0
  134. package/src/components/Checkbox/Checkbox.tsx +108 -117
  135. package/src/components/Icon/Icon.tsx +265 -0
  136. package/src/components/Icon/index.ts +8 -0
  137. package/src/components/ProgressCircle/ProgressCircle.tsx +39 -25
  138. package/src/components/RadioGroup/RadioGroup.tsx +100 -118
  139. package/src/components/Stack/Stack.tsx +97 -0
  140. package/src/components/Stack/index.ts +1 -0
  141. package/src/components/Switch/Switch.tsx +61 -52
  142. package/src/components/TagGroup/TagGroup.tsx +27 -25
  143. package/src/components/Text/Text.tsx +64 -0
  144. package/src/components/Text/index.ts +1 -0
  145. package/src/components/index.ts +6 -0
  146. package/src/hooks/index.ts +4 -3
  147. package/src/hooks/{__tests__/use-controllable-state.test.ts → useControllableState.test.ts} +1 -1
  148. package/src/hooks/useIconColor.test.ts +13 -0
  149. package/src/hooks/useIconColor.ts +67 -0
  150. package/src/hooks/{__tests__/use-press-tap.test.ts → usePressTap.test.ts} +1 -1
  151. package/src/hooks/{use-press-tap.ts → usePressTap.ts} +14 -10
  152. package/src/hooks/useSafeArea.test.ts +83 -0
  153. package/src/hooks/useSafeArea.ts +56 -0
  154. package/src/index.ts +1 -0
  155. package/src/types.ts +76 -0
  156. package/src/utils/children.ts +13 -0
  157. package/src/utils/create-slot-recipe-context.test.tsx +96 -0
  158. package/src/utils/create-slot-recipe-context.tsx +55 -15
  159. package/src/utils/get-seed-class-name.ts +7 -12
  160. package/src/utils/{__tests__/split-multiple-variants-props.test.ts → split-multiple-variants-props.test.ts} +1 -1
  161. package/src/utils/styled.ts +442 -0
  162. package/lib/components/ActionButton/index.js +0 -1
  163. package/lib/components/BottomSheet/index.js +0 -2
  164. package/lib/components/Checkbox/index.js +0 -2
  165. package/lib/components/ProgressCircle/index.js +0 -2
  166. package/lib/components/RadioGroup/index.js +0 -2
  167. package/lib/components/Switch/index.js +0 -2
  168. package/lib/components/TagGroup/index.js +0 -2
  169. package/lib/components/index.js +0 -7
  170. package/lib/hooks/index.js +0 -3
  171. package/lib/hooks/use-controllable-state.d.ts.map +0 -1
  172. package/lib/hooks/use-controllable-state.js +0 -27
  173. package/lib/hooks/use-icon-color.d.ts +0 -15
  174. package/lib/hooks/use-icon-color.d.ts.map +0 -1
  175. package/lib/hooks/use-icon-color.js +0 -37
  176. package/lib/hooks/use-press-tap.d.ts.map +0 -1
  177. package/lib/hooks/use-press-tap.js +0 -35
  178. package/lib/utils/index.js +0 -4
  179. package/src/components/ActionButton/__tests__/ActionButton.test.tsx +0 -35
  180. package/src/components/BottomSheet/__tests__/BottomSheet.test.tsx +0 -119
  181. package/src/components/__tests__/ProgressCircle.test.ts +0 -33
  182. package/src/components/__tests__/exports.test.ts +0 -38
  183. package/src/components/__tests__/switch.test.ts +0 -34
  184. package/src/hooks/use-icon-color.ts +0 -51
  185. package/src/utils/__tests__/create-slot-recipe-context.test.tsx +0 -228
  186. /package/src/hooks/{use-controllable-state.ts → useControllableState.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../src/components/RadioGroup/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAgC,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AA6ErF,MAAM,WAAW,mBACf,SAAQ,iBAAiB,EACvB,IAAI,CAAC,qBAAqB,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IAC9D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,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,qFAsDzB,CAA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AyB,SAAQ,sBAAsB;CAAG;AAE3E,eAAO,MAAM,mBAAmB,0FAoB/B,CAAC"}
@@ -1,144 +1,160 @@
1
- import * as React from "react";
2
- import { cloneElement, isValidElement } from "react";
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
- import { vars as radiomarkVars } from "@seed-design/lynx-css/vars/component/radiomark";
8
- import { useControllableState } from "../../hooks/use-controllable-state";
9
- import { useIconColor } from "../../hooks/use-icon-color";
10
- import { usePressTap } from "../../hooks/use-press-tap";
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
- const ctx = React.useContext(RadioGroupContext);
16
- if (!ctx) {
17
- throw new Error(`<${consumer}/> must be rendered inside <RadioGroupRoot/>.`);
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
- const RadioGroupItemContext = React.createContext(null);
18
+ var RadioGroupItemContext = React.createContext(null);
22
19
  function useRadioGroupItemContext(consumer) {
23
- const ctx = React.useContext(RadioGroupItemContext);
24
- if (!ctx) {
25
- throw new Error(`<${consumer}/> must be rendered inside <RadioGroupItem/>.`);
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
- const RadiomarkIconClassContext = React.createContext(null);
30
- function useRadiomarkIconClass(consumer) {
31
- const ctx = React.useContext(RadiomarkIconClassContext);
32
- if (!ctx) {
33
- throw new Error(`<${consumer}/> must be rendered inside <RadioGroupItemControl/>.`);
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
- export const RadioGroupRoot = React.forwardRef((props, ref) => {
38
- const { children, className, value: valueProp, defaultValue, disabled = false, onValueChange, ...restProps } = props;
39
- const [{ radio: radioVariantProps, radiomark: radiomarkVariantProps }, nativeProps] = splitMultipleVariantsProps(restProps, { radio, radiomark });
40
- const weight = radioVariantProps.weight ?? "regular";
41
- const size = radioVariantProps.size ?? "medium";
42
- const tone = radiomarkVariantProps.tone ?? "brand";
43
- const handleChange = React.useCallback((next) => {
44
- if (next !== null)
45
- onValueChange?.(next);
46
- }, [onValueChange]);
47
- const [value, setValueInternal] = useControllableState({
48
- value: valueProp !== undefined ? valueProp : undefined,
49
- defaultValue: defaultValue ?? null,
50
- onChange: handleChange,
51
- });
52
- const setValue = React.useCallback((next) => {
53
- setValueInternal(next);
54
- }, [setValueInternal]);
55
- const rootClassName = radioGroup();
56
- const ctx = React.useMemo(() => ({ value, setValue, disabled, size, weight, tone }), [value, setValue, disabled, size, weight, tone]);
57
- return (<RadioGroupContext.Provider value={ctx}>
58
- <view {...(ref ? { ref: ref } : {})} className={clsx(rootClassName, className)} {...nativeProps}>
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
- export const RadioGroupItem = React.forwardRef((props, ref) => {
65
- const { value: itemValue, disabled: itemDisabled = false, children, className, ...nativeProps } = props;
66
- const { value: groupValue, setValue, disabled: groupDisabled, size, weight, tone, } = useRadioGroupContext("RadioGroupItem");
67
- const disabled = groupDisabled || itemDisabled;
68
- const checked = groupValue === itemValue;
69
- const { pressed, ...pressHandlers } = usePressTap({
70
- disabled,
71
- onTap: () => {
72
- if (checked)
73
- return;
74
- setValue(itemValue);
75
- },
76
- });
77
- const rootClassName = radio({ weight, size, disabled }).root;
78
- const itemCtx = React.useMemo(() => ({
79
- value: itemValue,
80
- checked,
81
- disabled,
82
- pressed,
83
- tone,
84
- size,
85
- }), [itemValue, checked, disabled, pressed, tone, size]);
86
- return (<RadioGroupItemContext.Provider value={itemCtx}>
87
- <view {...(ref ? { ref: ref } : {})} className={clsx(rootClassName, className)} {...pressHandlers} {...nativeProps}>
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
- export const RadioGroupItemControl = React.forwardRef((props, ref) => {
94
- const [variantProps, restProps] = radiomark.splitVariantProps(props);
95
- const { children, className, ...nativeProps } = restProps;
96
- const { checked, disabled, pressed, tone: ctxTone, size, } = useRadioGroupItemContext("RadioGroupItemControl");
97
- const tone = variantProps.tone ?? ctxTone;
98
- const classes = React.useMemo(() => radiomark({ tone, size, checked, disabled, pressed }), [tone, size, checked, disabled, pressed]);
99
- return (<RadiomarkIconClassContext.Provider value={classes.icon}>
100
- <view {...(ref ? { ref: ref } : {})} className={clsx(classes.root, className)} {...nativeProps}>
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
- </RadiomarkIconClassContext.Provider>);
129
+ </RadiomarkControlContext.Provider>;
104
130
  });
105
131
  RadioGroupItemControl.displayName = "RadioGroupItemControl";
106
- export function RadioGroupItemIndicator(props) {
107
- const { unchecked, checked: checkedIcon, className, style } = props;
108
- const { checked, disabled, pressed, tone, size } = useRadioGroupItemContext("RadioGroupItemIndicator");
109
- const iconClassName = useRadiomarkIconClass("RadioGroupItemIndicator");
110
- const { ref: tintRef } = useIconColor([checked, disabled, pressed, tone, size]);
111
- const icon = checked ? checkedIcon : unchecked;
112
- // 사용자가 custom icon 을 주지 않으면 default `<view>` 로 동그란 점을 그린다.
113
- // radiomark.icon recipe 가 borderRadius/backgroundColor/width/height 를 적용해
114
- // 라디오의 inner dot 모양을 재현. 웹 RadioGroup 의 default `<svg><circle/></svg>` 동작과 일치.
115
- if (!icon || !isValidElement(icon)) {
116
- return <view className={clsx(iconClassName, className)} style={style}/>;
117
- }
118
- // lynx-monochrome-icon 이 `<image style={{ width, height, ...style }}>` 로 자체 default size 를 박으므로
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
- className: clsx(iconClassName, icon.props.className, className),
128
- style: iconSize
129
- ? { width: iconSize, height: iconSize, ...icon.props.style, ...style }
130
- : { ...icon.props.style, ...style },
131
- ref: tintRef,
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
- export const RadioGroupItemLabel = React.forwardRef((props, ref) => {
136
- const { children, className, ...nativeProps } = props;
137
- const { disabled } = useRadioGroupItemContext("RadioGroupItemLabel");
138
- const { size, weight } = useRadioGroupContext("RadioGroupItemLabel");
139
- const labelClassName = radio({ weight, size, disabled }).label;
140
- return (<text {...(ref ? { ref: ref } : {})} className={clsx(labelClassName, className)} {...nativeProps}>
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 "./RadioGroup";
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
- export { RadioGroupItem as Item, RadioGroupItemControl as ItemControl, RadioGroupItemIndicator as ItemIndicator, RadioGroupItemLabel as ItemLabel, RadioGroupRoot as Root, } from "./RadioGroup";
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 "./RadioGroup";
2
- export * as RadioGroup from "./RadioGroup.namespace";
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,2 @@
1
+ export { HStack, type HStackProps, type StackProps, VStack, type VStackProps } from './Stack';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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 * as React from "react";
2
- import type { SwitchVariantProps } from "@seed-design/lynx-css/recipes/switch";
3
- import type { SwitchmarkVariantProps } from "@seed-design/lynx-css/recipes/switchmark";
4
- export interface SwitchRootProps extends SwitchVariantProps, Omit<SwitchmarkVariantProps, "size"> {
5
- children?: React.ReactNode;
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.ts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sC,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 * as React from "react";
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
- import { splitMultipleVariantsProps } from "../../utils/split-multiple-variants-props";
6
- import { useControllableState } from "../../hooks/use-controllable-state";
7
- import { usePressTap } from "../../hooks/use-press-tap";
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
- const ctx = React.useContext(SwitchContext);
11
- if (!ctx) {
12
- throw new Error(`<${consumer}/> must be rendered inside <SwitchRoot/>.`);
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
- const SwitchmarkThumbClassContext = React.createContext(null);
17
- function useSwitchmarkThumbClass(consumer) {
18
- const ctx = React.useContext(SwitchmarkThumbClassContext);
19
- if (!ctx) {
20
- throw new Error(`<${consumer}/> must be rendered inside <SwitchControl/>.`);
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
- export const SwitchRoot = React.forwardRef((props, ref) => {
25
- const { children, className, checked: checkedProp, defaultChecked = false, disabled = false, onCheckedChange, ...restProps } = props;
26
- const [{ switch: switchVariantProps, switchmark: switchmarkVariantProps }, nativeProps] = splitMultipleVariantsProps(restProps, { switch: switchStyle, switchmark });
27
- const size = switchVariantProps.size ?? "32";
28
- const tone = switchmarkVariantProps.tone ?? "brand";
29
- const [checked, setChecked] = useControllableState({
30
- value: checkedProp,
31
- defaultValue: defaultChecked,
32
- onChange: onCheckedChange,
33
- });
34
- const { pressed: _pressed, ...pressHandlers } = usePressTap({
35
- disabled,
36
- onTap: () => setChecked(!checked),
37
- });
38
- const rootClassName = switchStyle({ size }).root;
39
- const ctx = React.useMemo(() => ({ checked, disabled, size, tone }), [checked, disabled, size, tone]);
40
- return (<SwitchContext.Provider value={ctx}>
41
- <view {...(ref ? { ref: ref } : {})} className={clsx(rootClassName, className)} {...pressHandlers} {...nativeProps}>
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
- export const SwitchControl = React.forwardRef((props, ref) => {
48
- const [variantProps, restProps] = switchmark.splitVariantProps(props);
49
- const { children, className, ...nativeProps } = restProps;
50
- const { checked, disabled, tone: ctxTone, size: ctxSize } = useSwitchContext("SwitchControl");
51
- const tone = variantProps.tone ?? ctxTone;
52
- const size = variantProps.size ?? ctxSize;
53
- const classes = React.useMemo(() => switchmark({ tone, size, checked, disabled }), [tone, size, checked, disabled]);
54
- return (<SwitchmarkThumbClassContext.Provider value={classes.thumb}>
55
- <view {...(ref ? { ref: ref } : {})} className={clsx(classes.root, className)} {...nativeProps}>
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
- </SwitchmarkThumbClassContext.Provider>);
79
+ </SwitchmarkControlContext.Provider>;
59
80
  });
60
81
  SwitchControl.displayName = "SwitchControl";
61
- export const SwitchThumb = React.forwardRef((props, ref) => {
62
- const { className, ...nativeProps } = props;
63
- const thumbClassName = useSwitchmarkThumbClass("SwitchThumb");
64
- return (<view {...(ref ? { ref: ref } : {})} className={clsx(thumbClassName, className)} {...nativeProps}/>);
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
- export const SwitchLabel = React.forwardRef((props, ref) => {
68
- const { children, className, ...nativeProps } = props;
69
- const { disabled, size } = useSwitchContext("SwitchLabel");
70
- const labelClassName = switchStyle({ size, disabled }).label;
71
- return (<text {...(ref ? { ref: ref } : {})} className={clsx(labelClassName, className)} {...nativeProps}>
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 "./Switch";
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