@seed-design/lynx-react 0.2.0-alpha.2 → 0.2.0-alpha.3
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/components/ActionButton/ActionButton.d.ts +1 -0
- package/lib/components/ActionButton/ActionButton.d.ts.map +1 -1
- package/lib/components/ActionButton/ActionButton.jsx +4 -4
- package/lib/components/Checkbox/Checkbox.d.ts +1 -0
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/components/Checkbox/Checkbox.jsx +5 -5
- package/lib/components/RadioGroup/RadioGroup.d.ts +1 -0
- package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/lib/components/RadioGroup/RadioGroup.jsx +5 -5
- package/lib/components/Switch/Switch.jsx +2 -2
- package/lib/hooks/index.d.ts +3 -3
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/index.js +3 -3
- package/lib/hooks/{use-controllable-state.d.ts → useControllableState.d.ts} +1 -1
- package/lib/hooks/useControllableState.d.ts.map +1 -0
- package/lib/hooks/{use-icon-color.d.ts → useIconColor.d.ts} +4 -3
- package/lib/hooks/useIconColor.d.ts.map +1 -0
- package/lib/hooks/{use-icon-color.js → useIconColor.js} +10 -6
- package/lib/hooks/{use-press-tap.d.ts → usePressTap.d.ts} +1 -1
- package/lib/hooks/usePressTap.d.ts.map +1 -0
- package/package.json +1 -2
- package/src/components/ActionButton/ActionButton.tsx +5 -4
- package/src/components/Checkbox/Checkbox.tsx +6 -5
- package/src/components/RadioGroup/RadioGroup.tsx +6 -5
- package/src/components/Switch/Switch.tsx +2 -2
- package/src/hooks/__tests__/{use-controllable-state.test.ts → useControllableState.test.ts} +1 -1
- package/src/hooks/__tests__/useIconColor.test.ts +13 -0
- package/src/hooks/__tests__/{use-press-tap.test.ts → usePressTap.test.ts} +1 -1
- package/src/hooks/index.ts +3 -3
- package/src/hooks/{use-icon-color.ts → useIconColor.ts} +12 -6
- package/lib/hooks/use-controllable-state.d.ts.map +0 -1
- package/lib/hooks/use-icon-color.d.ts.map +0 -1
- package/lib/hooks/use-press-tap.d.ts.map +0 -1
- /package/lib/hooks/{use-controllable-state.js → useControllableState.js} +0 -0
- /package/lib/hooks/{use-press-tap.js → usePressTap.js} +0 -0
- /package/src/hooks/{use-controllable-state.ts → useControllableState.ts} +0 -0
- /package/src/hooks/{use-press-tap.ts → usePressTap.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionButton.d.ts","sourceRoot":"","sources":["../../../src/components/ActionButton/ActionButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAE5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAyC,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAsBjF,KAAK,gBAAgB,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionButton.d.ts","sourceRoot":"","sources":["../../../src/components/ActionButton/ActionButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAE5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAyC,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAsBjF,KAAK,gBAAgB,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;CACzC,CAAC;AAuLF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC7F,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACjC,IAAI,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAC5C,UAAU,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAED,eAAO,MAAM,YAAY,mFA4DvB,CAAC"}
|
|
@@ -3,8 +3,8 @@ import { actionButton as actionButtonVars } from "@seed-design/lynx-css/vars/com
|
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { cloneElement, isValidElement, useMemo } from "react";
|
|
6
|
-
import { useIconColor } from "../../hooks/
|
|
7
|
-
import { usePressTap } from "../../hooks/
|
|
6
|
+
import { useIconColor } from "../../hooks/useIconColor";
|
|
7
|
+
import { usePressTap } from "../../hooks/usePressTap";
|
|
8
8
|
import { createSlotRecipeContext } from "../../utils/create-slot-recipe-context";
|
|
9
9
|
import { capitalize, resolveRecipeToken } from "../../utils/resolve-recipe-token";
|
|
10
10
|
import { ProgressCircleRange, ProgressCircleRoot, } from "../ProgressCircle";
|
|
@@ -74,7 +74,7 @@ function resolveIconSize(variantProps, slot) {
|
|
|
74
74
|
function ActionButtonIconSlot({ icon, slot, }) {
|
|
75
75
|
const classNames = useClassNames();
|
|
76
76
|
const variantProps = useProps();
|
|
77
|
-
const
|
|
77
|
+
const iconColor = useIconColor([
|
|
78
78
|
variantProps?.variant ?? null,
|
|
79
79
|
variantProps?.disabled ?? false,
|
|
80
80
|
variantProps?.loading ?? false,
|
|
@@ -82,9 +82,9 @@ function ActionButtonIconSlot({ icon, slot, }) {
|
|
|
82
82
|
const sizeVar = resolveIconSize(variantProps, slot);
|
|
83
83
|
const childProps = icon.props;
|
|
84
84
|
return cloneElement(icon, {
|
|
85
|
+
...iconColor,
|
|
85
86
|
className: clsx(classNames[slot], childProps.className),
|
|
86
87
|
style: sizeVar != null ? { width: sizeVar, height: sizeVar, ...childProps.style } : childProps.style,
|
|
87
|
-
ref: ref,
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
function ActionButtonContent({ children, isIconOnly, icon, prefixIcon, suffixIcon, }) {
|
|
@@ -22,6 +22,7 @@ type IconElementProps = {
|
|
|
22
22
|
className?: string;
|
|
23
23
|
style?: CSSProperties;
|
|
24
24
|
ref?: React.Ref<MainThread.Element>;
|
|
25
|
+
"main-thread:binduiappear"?: () => void;
|
|
25
26
|
};
|
|
26
27
|
export interface CheckboxIndicatorProps {
|
|
27
28
|
/** Icon rendered when neither checked nor indeterminate. Optional. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.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,oBAAoB,EAAE,MAAM,wCAAwC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CAAC,gBAAgB,CAAC,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,0FA8C9D;yBA9Ce,iBAAiB;;;AAmDjC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,oFAcxB,CAAC;AAKH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,oFAaxB,CAAC"}
|
|
@@ -5,9 +5,9 @@ import { checkbox } from "@seed-design/lynx-css/recipes/checkbox";
|
|
|
5
5
|
import { checkmark } from "@seed-design/lynx-css/recipes/checkmark";
|
|
6
6
|
import { checkboxGroup } from "@seed-design/lynx-css/recipes/checkbox-group";
|
|
7
7
|
import { vars as checkmarkVars } from "@seed-design/lynx-css/vars/component/checkmark";
|
|
8
|
-
import { useControllableState } from "../../hooks/
|
|
9
|
-
import { useIconColor } from "../../hooks/
|
|
10
|
-
import { usePressTap } from "../../hooks/
|
|
8
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
9
|
+
import { useIconColor } from "../../hooks/useIconColor";
|
|
10
|
+
import { usePressTap } from "../../hooks/usePressTap";
|
|
11
11
|
import { capitalize, resolveRecipeToken } from "../../utils/resolve-recipe-token";
|
|
12
12
|
import { splitMultipleVariantsProps } from "../../utils/split-multiple-variants-props";
|
|
13
13
|
const CheckboxContext = React.createContext(null);
|
|
@@ -70,7 +70,7 @@ export function CheckboxIndicator(props) {
|
|
|
70
70
|
const { unchecked, checked: checkedIcon, indeterminate: indeterminateIcon, className, style, } = props;
|
|
71
71
|
const { checked, indeterminate, disabled, pressed, tone, variant, size } = useCheckboxContext("CheckboxIndicator");
|
|
72
72
|
const iconClassName = useCheckmarkIconClass("CheckboxIndicator");
|
|
73
|
-
const
|
|
73
|
+
const iconColor = useIconColor([
|
|
74
74
|
checked,
|
|
75
75
|
indeterminate,
|
|
76
76
|
disabled,
|
|
@@ -94,11 +94,11 @@ export function CheckboxIndicator(props) {
|
|
|
94
94
|
"size",
|
|
95
95
|
]);
|
|
96
96
|
return cloneElement(icon, {
|
|
97
|
+
...iconColor,
|
|
97
98
|
className: clsx(iconClassName, icon.props.className, className),
|
|
98
99
|
style: iconSize
|
|
99
100
|
? { width: iconSize, height: iconSize, ...icon.props.style, ...style }
|
|
100
101
|
: { ...icon.props.style, ...style },
|
|
101
|
-
ref: tintRef,
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
CheckboxIndicator.displayName = "CheckboxIndicator";
|
|
@@ -28,6 +28,7 @@ type IconElementProps = {
|
|
|
28
28
|
className?: string;
|
|
29
29
|
style?: CSSProperties;
|
|
30
30
|
ref?: React.Ref<MainThread.Element>;
|
|
31
|
+
"main-thread:binduiappear"?: () => void;
|
|
31
32
|
};
|
|
32
33
|
export interface RadioGroupItemIndicatorProps {
|
|
33
34
|
/** Icon rendered when not checked. Optional — falls back to default `<view>` dot when omitted. */
|
|
@@ -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,mB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CACzC,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,kGAAkG;IAClG,SAAS,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAC3C,0GAA0G;IAC1G,OAAO,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,qBAgC1E;yBAhCe,uBAAuB;;;AAqCvC,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,mBAAmB,0FAiB/B,CAAC"}
|
|
@@ -5,9 +5,9 @@ import { radio } from "@seed-design/lynx-css/recipes/radio";
|
|
|
5
5
|
import { radiomark } from "@seed-design/lynx-css/recipes/radiomark";
|
|
6
6
|
import { radioGroup } from "@seed-design/lynx-css/recipes/radio-group";
|
|
7
7
|
import { vars as radiomarkVars } from "@seed-design/lynx-css/vars/component/radiomark";
|
|
8
|
-
import { useControllableState } from "../../hooks/
|
|
9
|
-
import { useIconColor } from "../../hooks/
|
|
10
|
-
import { usePressTap } from "../../hooks/
|
|
8
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
9
|
+
import { useIconColor } from "../../hooks/useIconColor";
|
|
10
|
+
import { usePressTap } from "../../hooks/usePressTap";
|
|
11
11
|
import { capitalize, resolveRecipeToken } from "../../utils/resolve-recipe-token";
|
|
12
12
|
import { splitMultipleVariantsProps } from "../../utils/split-multiple-variants-props";
|
|
13
13
|
const RadioGroupContext = React.createContext(null);
|
|
@@ -107,7 +107,7 @@ export function RadioGroupItemIndicator(props) {
|
|
|
107
107
|
const { unchecked, checked: checkedIcon, className, style } = props;
|
|
108
108
|
const { checked, disabled, pressed, tone, size } = useRadioGroupItemContext("RadioGroupItemIndicator");
|
|
109
109
|
const iconClassName = useRadiomarkIconClass("RadioGroupItemIndicator");
|
|
110
|
-
const
|
|
110
|
+
const iconColor = useIconColor([checked, disabled, pressed, tone, size]);
|
|
111
111
|
const icon = checked ? checkedIcon : unchecked;
|
|
112
112
|
// 사용자가 custom icon 을 주지 않으면 default `<view>` 로 동그란 점을 그린다.
|
|
113
113
|
// radiomark.icon recipe 가 borderRadius/backgroundColor/width/height 를 적용해
|
|
@@ -124,11 +124,11 @@ export function RadioGroupItemIndicator(props) {
|
|
|
124
124
|
"size",
|
|
125
125
|
]);
|
|
126
126
|
return cloneElement(icon, {
|
|
127
|
+
...iconColor,
|
|
127
128
|
className: clsx(iconClassName, icon.props.className, className),
|
|
128
129
|
style: iconSize
|
|
129
130
|
? { width: iconSize, height: iconSize, ...icon.props.style, ...style }
|
|
130
131
|
: { ...icon.props.style, ...style },
|
|
131
|
-
ref: tintRef,
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
RadioGroupItemIndicator.displayName = "RadioGroupItemIndicator";
|
|
@@ -3,8 +3,8 @@ import clsx from "clsx";
|
|
|
3
3
|
import { switchStyle } from "@seed-design/lynx-css/recipes/switch";
|
|
4
4
|
import { switchmark } from "@seed-design/lynx-css/recipes/switchmark";
|
|
5
5
|
import { splitMultipleVariantsProps } from "../../utils/split-multiple-variants-props";
|
|
6
|
-
import { useControllableState } from "../../hooks/
|
|
7
|
-
import { usePressTap } from "../../hooks/
|
|
6
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
7
|
+
import { usePressTap } from "../../hooks/usePressTap";
|
|
8
8
|
const SwitchContext = React.createContext(null);
|
|
9
9
|
function useSwitchContext(consumer) {
|
|
10
10
|
const ctx = React.useContext(SwitchContext);
|
package/lib/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
1
|
+
export * from "./useControllableState";
|
|
2
|
+
export * from "./useIconColor";
|
|
3
|
+
export * from "./usePressTap";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/hooks/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
package/lib/hooks/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
1
|
+
export * from "./useControllableState";
|
|
2
|
+
export * from "./useIconColor";
|
|
3
|
+
export * from "./usePressTap";
|
|
@@ -12,4 +12,4 @@ export interface UseControllableStateProps<T> {
|
|
|
12
12
|
* - `onChange` fires in both modes.
|
|
13
13
|
*/
|
|
14
14
|
export declare function useControllableState<T>(props: UseControllableStateProps<T>): [T, (value: T) => void];
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=useControllableState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useControllableState.d.ts","sourceRoot":"","sources":["../../src/hooks/useControllableState.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,yBAAyB,CAAC,CAAC;IAC1C,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,YAAY,EAAE,CAAC,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,yBAAyB,CAAC,CAAC,CAAC,GAClC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAkBzB"}
|
|
@@ -5,11 +5,12 @@ import type { DependencyList, RefObject } from "react";
|
|
|
5
5
|
* `tint-color` attribute 로 mirror. `deps` 가 바뀌면 재동기화.
|
|
6
6
|
*
|
|
7
7
|
* ```tsx
|
|
8
|
-
* const
|
|
9
|
-
* return cloneElement(iconChild,
|
|
8
|
+
* const iconColorProps = useIconColor([variant, disabled, loading]);
|
|
9
|
+
* return cloneElement(iconChild, iconColorProps);
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
12
|
export declare function useIconColor(deps: DependencyList): {
|
|
13
13
|
ref: RefObject<MainThread.Element>;
|
|
14
|
+
"main-thread:binduiappear": () => void;
|
|
14
15
|
};
|
|
15
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=useIconColor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIconColor.d.ts","sourceRoot":"","sources":["../../src/hooks/useIconColor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA4BvD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG;IAClD,GAAG,EAAE,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,0BAA0B,EAAE,MAAM,IAAI,CAAC;CACxC,CAcA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { runOnMainThread, useEffect, useMainThreadRef } from "@lynx-js/react";
|
|
2
|
-
// Lynx `<image>` 의 `tint-color` attribute
|
|
3
|
-
// `color
|
|
4
|
-
//
|
|
2
|
+
// Lynx `<image>` 의 `tint-color` attribute 에 CSS variable 문자열을 직접 넣는 경로는
|
|
3
|
+
// 안정적으로 동작하지 않는다. CSS `color` 는 computed style 로 resolved color 를 읽을 수
|
|
4
|
+
// 있으므로 main-thread 에서 한 번 읽어 `tint-color` 로 mirror 한다.
|
|
5
5
|
function syncTintColor(ref) {
|
|
6
6
|
"main thread";
|
|
7
7
|
const el = ref.current;
|
|
@@ -23,15 +23,19 @@ function syncTintColor(ref) {
|
|
|
23
23
|
* `tint-color` attribute 로 mirror. `deps` 가 바뀌면 재동기화.
|
|
24
24
|
*
|
|
25
25
|
* ```tsx
|
|
26
|
-
* const
|
|
27
|
-
* return cloneElement(iconChild,
|
|
26
|
+
* const iconColorProps = useIconColor([variant, disabled, loading]);
|
|
27
|
+
* return cloneElement(iconChild, iconColorProps);
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
export function useIconColor(deps) {
|
|
31
31
|
const ref = useMainThreadRef(null);
|
|
32
|
+
function syncOnUiAppear() {
|
|
33
|
+
"main thread";
|
|
34
|
+
syncTintColor(ref);
|
|
35
|
+
}
|
|
32
36
|
// deps 는 caller 가 책임.
|
|
33
37
|
useEffect(() => {
|
|
34
38
|
runOnMainThread(syncTintColor)(ref);
|
|
35
39
|
}, deps);
|
|
36
|
-
return { ref };
|
|
40
|
+
return { ref, "main-thread:binduiappear": syncOnUiAppear };
|
|
37
41
|
}
|
|
@@ -21,4 +21,4 @@ export interface UsePressTapReturn {
|
|
|
21
21
|
* - `main-thread:bindtap` is conditionally included (only when enabled and provided).
|
|
22
22
|
*/
|
|
23
23
|
export declare function usePressTap(options?: UsePressTapOptions): UsePressTapReturn;
|
|
24
|
-
//# sourceMappingURL=
|
|
24
|
+
//# sourceMappingURL=usePressTap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePressTap.d.ts","sourceRoot":"","sources":["../../src/hooks/usePressTap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACjC,cAAc,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,eAAe,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,iBAAiB,CA0B/E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seed-design/lynx-react",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/daangn/seed-design.git",
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@lynx-js/lynx-ui-sheet": "^3.130.1",
|
|
50
50
|
"@lynx-js/lynx-ui-common": "^3.130.0",
|
|
51
|
-
"@seed-design/lynx-primitive": "workspace:*",
|
|
52
51
|
"clsx": "^2.1.1"
|
|
53
52
|
}
|
|
54
53
|
}
|
|
@@ -6,8 +6,8 @@ import clsx from "clsx";
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import { cloneElement, isValidElement, useMemo, type ReactElement } from "react";
|
|
8
8
|
|
|
9
|
-
import { useIconColor } from "../../hooks/
|
|
10
|
-
import { usePressTap, type UsePressTapReturn } from "../../hooks/
|
|
9
|
+
import { useIconColor } from "../../hooks/useIconColor";
|
|
10
|
+
import { usePressTap, type UsePressTapReturn } from "../../hooks/usePressTap";
|
|
11
11
|
import { createSlotRecipeContext } from "../../utils/create-slot-recipe-context";
|
|
12
12
|
import { capitalize, resolveRecipeToken } from "../../utils/resolve-recipe-token";
|
|
13
13
|
import {
|
|
@@ -30,6 +30,7 @@ type IconElementProps = {
|
|
|
30
30
|
className?: string;
|
|
31
31
|
style?: React.CSSProperties;
|
|
32
32
|
ref?: React.Ref<MainThread.Element>;
|
|
33
|
+
"main-thread:binduiappear"?: () => void;
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
type ActionButtonContentProps = {
|
|
@@ -150,7 +151,7 @@ function ActionButtonIconSlot({
|
|
|
150
151
|
}) {
|
|
151
152
|
const classNames = useClassNames();
|
|
152
153
|
const variantProps = useProps() as ActionButtonVariantProps | null;
|
|
153
|
-
const
|
|
154
|
+
const iconColor = useIconColor([
|
|
154
155
|
variantProps?.variant ?? null,
|
|
155
156
|
variantProps?.disabled ?? false,
|
|
156
157
|
variantProps?.loading ?? false,
|
|
@@ -158,10 +159,10 @@ function ActionButtonIconSlot({
|
|
|
158
159
|
const sizeVar = resolveIconSize(variantProps, slot);
|
|
159
160
|
const childProps = icon.props;
|
|
160
161
|
return cloneElement(icon, {
|
|
162
|
+
...iconColor,
|
|
161
163
|
className: clsx(classNames[slot], childProps.className),
|
|
162
164
|
style:
|
|
163
165
|
sizeVar != null ? { width: sizeVar, height: sizeVar, ...childProps.style } : childProps.style,
|
|
164
|
-
ref: ref as React.Ref<MainThread.Element>,
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
168
|
|
|
@@ -10,9 +10,9 @@ import type { CheckmarkVariantProps } from "@seed-design/lynx-css/recipes/checkm
|
|
|
10
10
|
import { checkboxGroup } from "@seed-design/lynx-css/recipes/checkbox-group";
|
|
11
11
|
import { vars as checkmarkVars } from "@seed-design/lynx-css/vars/component/checkmark";
|
|
12
12
|
|
|
13
|
-
import { useControllableState } from "../../hooks/
|
|
14
|
-
import { useIconColor } from "../../hooks/
|
|
15
|
-
import { usePressTap } from "../../hooks/
|
|
13
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
14
|
+
import { useIconColor } from "../../hooks/useIconColor";
|
|
15
|
+
import { usePressTap } from "../../hooks/usePressTap";
|
|
16
16
|
import { capitalize, resolveRecipeToken } from "../../utils/resolve-recipe-token";
|
|
17
17
|
import { splitMultipleVariantsProps } from "../../utils/split-multiple-variants-props";
|
|
18
18
|
|
|
@@ -181,6 +181,7 @@ type IconElementProps = {
|
|
|
181
181
|
className?: string;
|
|
182
182
|
style?: CSSProperties;
|
|
183
183
|
ref?: React.Ref<MainThread.Element>;
|
|
184
|
+
"main-thread:binduiappear"?: () => void;
|
|
184
185
|
};
|
|
185
186
|
|
|
186
187
|
export interface CheckboxIndicatorProps {
|
|
@@ -205,7 +206,7 @@ export function CheckboxIndicator(props: CheckboxIndicatorProps) {
|
|
|
205
206
|
const { checked, indeterminate, disabled, pressed, tone, variant, size } =
|
|
206
207
|
useCheckboxContext("CheckboxIndicator");
|
|
207
208
|
const iconClassName = useCheckmarkIconClass("CheckboxIndicator");
|
|
208
|
-
const
|
|
209
|
+
const iconColor = useIconColor([
|
|
209
210
|
checked,
|
|
210
211
|
indeterminate,
|
|
211
212
|
disabled,
|
|
@@ -234,11 +235,11 @@ export function CheckboxIndicator(props: CheckboxIndicatorProps) {
|
|
|
234
235
|
]);
|
|
235
236
|
|
|
236
237
|
return cloneElement(icon, {
|
|
238
|
+
...iconColor,
|
|
237
239
|
className: clsx(iconClassName, icon.props.className, className),
|
|
238
240
|
style: iconSize
|
|
239
241
|
? { width: iconSize, height: iconSize, ...icon.props.style, ...style }
|
|
240
242
|
: { ...icon.props.style, ...style },
|
|
241
|
-
ref: tintRef,
|
|
242
243
|
});
|
|
243
244
|
}
|
|
244
245
|
CheckboxIndicator.displayName = "CheckboxIndicator";
|
|
@@ -10,9 +10,9 @@ import type { RadiomarkVariantProps } from "@seed-design/lynx-css/recipes/radiom
|
|
|
10
10
|
import { radioGroup } from "@seed-design/lynx-css/recipes/radio-group";
|
|
11
11
|
import { vars as radiomarkVars } from "@seed-design/lynx-css/vars/component/radiomark";
|
|
12
12
|
|
|
13
|
-
import { useControllableState } from "../../hooks/
|
|
14
|
-
import { useIconColor } from "../../hooks/
|
|
15
|
-
import { usePressTap } from "../../hooks/
|
|
13
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
14
|
+
import { useIconColor } from "../../hooks/useIconColor";
|
|
15
|
+
import { usePressTap } from "../../hooks/usePressTap";
|
|
16
16
|
import { capitalize, resolveRecipeToken } from "../../utils/resolve-recipe-token";
|
|
17
17
|
import { splitMultipleVariantsProps } from "../../utils/split-multiple-variants-props";
|
|
18
18
|
|
|
@@ -264,6 +264,7 @@ type IconElementProps = {
|
|
|
264
264
|
className?: string;
|
|
265
265
|
style?: CSSProperties;
|
|
266
266
|
ref?: React.Ref<MainThread.Element>;
|
|
267
|
+
"main-thread:binduiappear"?: () => void;
|
|
267
268
|
};
|
|
268
269
|
|
|
269
270
|
export interface RadioGroupItemIndicatorProps {
|
|
@@ -280,7 +281,7 @@ export function RadioGroupItemIndicator(props: RadioGroupItemIndicatorProps) {
|
|
|
280
281
|
const { checked, disabled, pressed, tone, size } =
|
|
281
282
|
useRadioGroupItemContext("RadioGroupItemIndicator");
|
|
282
283
|
const iconClassName = useRadiomarkIconClass("RadioGroupItemIndicator");
|
|
283
|
-
const
|
|
284
|
+
const iconColor = useIconColor([checked, disabled, pressed, tone, size]);
|
|
284
285
|
|
|
285
286
|
const icon = checked ? checkedIcon : unchecked;
|
|
286
287
|
|
|
@@ -301,11 +302,11 @@ export function RadioGroupItemIndicator(props: RadioGroupItemIndicatorProps) {
|
|
|
301
302
|
]);
|
|
302
303
|
|
|
303
304
|
return cloneElement(icon, {
|
|
305
|
+
...iconColor,
|
|
304
306
|
className: clsx(iconClassName, icon.props.className, className),
|
|
305
307
|
style: iconSize
|
|
306
308
|
? { width: iconSize, height: iconSize, ...icon.props.style, ...style }
|
|
307
309
|
: { ...icon.props.style, ...style },
|
|
308
|
-
ref: tintRef,
|
|
309
310
|
});
|
|
310
311
|
}
|
|
311
312
|
RadioGroupItemIndicator.displayName = "RadioGroupItemIndicator";
|
|
@@ -7,8 +7,8 @@ import { switchmark } from "@seed-design/lynx-css/recipes/switchmark";
|
|
|
7
7
|
import type { SwitchmarkVariantProps } from "@seed-design/lynx-css/recipes/switchmark";
|
|
8
8
|
|
|
9
9
|
import { splitMultipleVariantsProps } from "../../utils/split-multiple-variants-props";
|
|
10
|
-
import { useControllableState } from "../../hooks/
|
|
11
|
-
import { usePressTap } from "../../hooks/
|
|
10
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
11
|
+
import { usePressTap } from "../../hooks/usePressTap";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @platform Lynx
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { act, renderHook } from "@lynx-js/react/testing-library";
|
|
2
2
|
import { describe, expect, it, vi } from "vitest";
|
|
3
|
-
import { useControllableState } from "../
|
|
3
|
+
import { useControllableState } from "../useControllableState";
|
|
4
4
|
|
|
5
5
|
describe("useControllableState", () => {
|
|
6
6
|
describe("uncontrolled mode", () => {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { renderHook } from "@lynx-js/react/testing-library";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { useIconColor } from "../useIconColor";
|
|
5
|
+
|
|
6
|
+
describe("useIconColor", () => {
|
|
7
|
+
it("returns icon tint sync props", () => {
|
|
8
|
+
const { result } = renderHook(() => useIconColor([]));
|
|
9
|
+
|
|
10
|
+
expect(result.current).toHaveProperty("ref");
|
|
11
|
+
expect(result.current["main-thread:binduiappear"]).toBeDefined();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { act, renderHook } from "@lynx-js/react/testing-library";
|
|
2
2
|
import { describe, expect, it, vi } from "vitest";
|
|
3
|
-
import { usePressTap } from "../
|
|
3
|
+
import { usePressTap } from "../usePressTap";
|
|
4
4
|
|
|
5
5
|
const fakeEvent = {} as Parameters<ReturnType<typeof usePressTap>["bindtap"]>[0];
|
|
6
6
|
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
1
|
+
export * from "./useControllableState";
|
|
2
|
+
export * from "./useIconColor";
|
|
3
|
+
export * from "./usePressTap";
|
|
@@ -7,9 +7,9 @@ type IconElement = MainThread.Element & {
|
|
|
7
7
|
getComputedCssProperty?: (name: string) => string;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
// Lynx `<image>` 의 `tint-color` attribute
|
|
11
|
-
// `color
|
|
12
|
-
//
|
|
10
|
+
// Lynx `<image>` 의 `tint-color` attribute 에 CSS variable 문자열을 직접 넣는 경로는
|
|
11
|
+
// 안정적으로 동작하지 않는다. CSS `color` 는 computed style 로 resolved color 를 읽을 수
|
|
12
|
+
// 있으므로 main-thread 에서 한 번 읽어 `tint-color` 로 mirror 한다.
|
|
13
13
|
function syncTintColor(ref: RefObject<IconElement>) {
|
|
14
14
|
"main thread";
|
|
15
15
|
|
|
@@ -33,19 +33,25 @@ function syncTintColor(ref: RefObject<IconElement>) {
|
|
|
33
33
|
* `tint-color` attribute 로 mirror. `deps` 가 바뀌면 재동기화.
|
|
34
34
|
*
|
|
35
35
|
* ```tsx
|
|
36
|
-
* const
|
|
37
|
-
* return cloneElement(iconChild,
|
|
36
|
+
* const iconColorProps = useIconColor([variant, disabled, loading]);
|
|
37
|
+
* return cloneElement(iconChild, iconColorProps);
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
export function useIconColor(deps: DependencyList): {
|
|
41
41
|
ref: RefObject<MainThread.Element>;
|
|
42
|
+
"main-thread:binduiappear": () => void;
|
|
42
43
|
} {
|
|
43
44
|
const ref = useMainThreadRef<IconElement>(null);
|
|
44
45
|
|
|
46
|
+
function syncOnUiAppear() {
|
|
47
|
+
"main thread";
|
|
48
|
+
syncTintColor(ref);
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
// deps 는 caller 가 책임.
|
|
46
52
|
useEffect(() => {
|
|
47
53
|
runOnMainThread(syncTintColor)(ref);
|
|
48
54
|
}, deps);
|
|
49
55
|
|
|
50
|
-
return { ref };
|
|
56
|
+
return { ref, "main-thread:binduiappear": syncOnUiAppear };
|
|
51
57
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-controllable-state.d.ts","sourceRoot":"","sources":["../../src/hooks/use-controllable-state.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,yBAAyB,CAAC,CAAC;IAC1C,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,YAAY,EAAE,CAAC,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,yBAAyB,CAAC,CAAC,CAAC,GAClC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,CAkBzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-icon-color.d.ts","sourceRoot":"","sources":["../../src/hooks/use-icon-color.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA4BvD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG;IAClD,GAAG,EAAE,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;CACpC,CASA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-press-tap.d.ts","sourceRoot":"","sources":["../../src/hooks/use-press-tap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACjC,cAAc,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,eAAe,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,iBAAiB,CA0B/E"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|