@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.
- package/lib/_virtual/_rolldown/runtime.js +13 -0
- package/lib/components/ActionButton/ActionButton.d.ts +26 -32
- 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 -30
- 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 -28
- 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 +4 -3
- package/lib/hooks/index.d.ts.map +1 -1
- 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/useControllableState.js +27 -0
- package/lib/hooks/useIconColor.d.ts +19 -0
- package/lib/hooks/useIconColor.d.ts.map +1 -0
- package/lib/hooks/useIconColor.js +38 -0
- package/lib/hooks/{use-press-tap.d.ts → usePressTap.d.ts} +12 -9
- package/lib/hooks/usePressTap.d.ts.map +1 -0
- package/lib/hooks/usePressTap.js +35 -0
- 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/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +29 -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 +6 -7
- package/lib/utils/get-seed-class-name.d.ts.map +1 -1
- package/lib/utils/get-seed-class-name.js +26 -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 +9 -9
- package/src/components/ActionButton/ActionButton.test.tsx +167 -0
- package/src/components/ActionButton/ActionButton.tsx +210 -168
- 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 +108 -117
- 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 +100 -118
- package/src/components/Stack/Stack.tsx +97 -0
- package/src/components/Stack/index.ts +1 -0
- package/src/components/Switch/Switch.tsx +61 -52
- 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 +4 -3
- package/src/hooks/{__tests__/use-controllable-state.test.ts → useControllableState.test.ts} +1 -1
- package/src/hooks/useIconColor.test.ts +13 -0
- package/src/hooks/useIconColor.ts +67 -0
- package/src/hooks/{__tests__/use-press-tap.test.ts → usePressTap.test.ts} +1 -1
- package/src/hooks/{use-press-tap.ts → usePressTap.ts} +14 -10
- package/src/hooks/useSafeArea.test.ts +83 -0
- package/src/hooks/useSafeArea.ts +56 -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 +7 -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/hooks/use-controllable-state.d.ts.map +0 -1
- package/lib/hooks/use-controllable-state.js +0 -27
- package/lib/hooks/use-icon-color.d.ts +0 -15
- package/lib/hooks/use-icon-color.d.ts.map +0 -1
- package/lib/hooks/use-icon-color.js +0 -37
- package/lib/hooks/use-press-tap.d.ts.map +0 -1
- package/lib/hooks/use-press-tap.js +0 -35
- 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/hooks/use-icon-color.ts +0 -51
- package/src/utils/__tests__/create-slot-recipe-context.test.tsx +0 -228
- /package/src/hooks/{use-controllable-state.ts → useControllableState.ts} +0 -0
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ReactNode, Ref } from '@lynx-js/react';
|
|
2
|
+
import { CSSProperties, IntrinsicElements, MainThread, NodesRef, TextProps, ViewProps } from '@lynx-js/types';
|
|
3
|
+
export type LynxViewProps = IntrinsicElements["view"] & ViewProps;
|
|
4
|
+
export type LynxTextProps = IntrinsicElements["text"] & TextProps;
|
|
5
|
+
export type LynxViewRef = Ref<NodesRef>;
|
|
6
|
+
export type LynxTextRef = Ref<NodesRef>;
|
|
7
|
+
export type LynxMainThreadRef = Ref<MainThread.Element>;
|
|
8
|
+
export type LynxStyle = CSSProperties;
|
|
9
|
+
export interface LynxElementProps {
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
className?: LynxViewProps["className"];
|
|
12
|
+
}
|
|
13
|
+
export interface LynxStyledElementProps extends LynxElementProps {
|
|
14
|
+
style?: LynxStyle;
|
|
15
|
+
}
|
|
16
|
+
export interface LynxPressableProps {
|
|
17
|
+
bindtap?: LynxViewProps["bindtap"];
|
|
18
|
+
"main-thread:bindtap"?: LynxViewProps["main-thread:bindtap"];
|
|
19
|
+
}
|
|
20
|
+
export interface LynxTouchProps {
|
|
21
|
+
bindtap?: LynxViewProps["bindtap"];
|
|
22
|
+
bindtouchstart?: LynxViewProps["bindtouchstart"];
|
|
23
|
+
bindtouchend?: LynxViewProps["bindtouchend"];
|
|
24
|
+
bindtouchcancel?: LynxViewProps["bindtouchcancel"];
|
|
25
|
+
"main-thread:bindtap"?: LynxViewProps["main-thread:bindtap"];
|
|
26
|
+
}
|
|
27
|
+
export interface LynxIconElementProps {
|
|
28
|
+
className?: IntrinsicElements["image"]["className"];
|
|
29
|
+
style?: LynxStyle;
|
|
30
|
+
ref?: LynxMainThreadRef;
|
|
31
|
+
"main-thread:binduiappear"?: IntrinsicElements["image"]["main-thread:binduiappear"];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @platform Lynx
|
|
35
|
+
*
|
|
36
|
+
* native element(`<view>`/`<text>`/`<image>` 등)가 공유하는 접근성 속성 모음.
|
|
37
|
+
* `@lynx-js/types`의 StandardProps 접근성 속성을 표준화한 타입으로, 컴포넌트가
|
|
38
|
+
* 확장해 native element에 패스스루한다. 모든 native tag가 동일한 공통 속성을
|
|
39
|
+
* 가지며 tag별 차이는 없다.
|
|
40
|
+
*
|
|
41
|
+
* web ARIA 대응:
|
|
42
|
+
* - `accessibility-label` ← `aria-label`
|
|
43
|
+
* - `accessibility-role-description` ← `role` (switch/checkbox/progressbar)
|
|
44
|
+
* - `accessibility-value` ← `aria-checked` / `aria-valuenow`
|
|
45
|
+
* - `accessibility-elements-hidden` ← `aria-hidden`
|
|
46
|
+
*
|
|
47
|
+
* `accessibility-traits`는 단일 값이라 `selected`+`disabled` 동시 표현이 안 된다.
|
|
48
|
+
* 역할은 `accessibility-role-description`, 상태는 `accessibility-value`로 분담한다.
|
|
49
|
+
*/
|
|
50
|
+
export type LynxAccessibilityProps = Pick<LynxViewProps, "accessibility-label" | "accessibility-traits" | "accessibility-element" | "accessibility-value" | "accessibility-role-description" | "accessibility-elements-hidden" | "accessibility-heading" | "accessibility-actions" | "accessibility-exclusive-focus" | "ios-platform-accessibility-id">;
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,SAAS,EACV,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;AAClE,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ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B,uBAAuB,GACvB,qBAAqB,GACrB,gCAAgC,GAChC,+BAA+B,GAC/B,uBAAuB,GACvB,uBAAuB,GACvB,+BAA+B,GAC/B,+BAA+B,CAClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"children.d.ts","sourceRoot":"","sources":["../../src/utils/children.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,CAUxD"}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
+
import { ElementType, ForwardRefExoticComponent, PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from '@lynx-js/react';
|
|
1
2
|
type SlotRecipe<Props extends Record<string, string | boolean | undefined>, Classnames extends Record<string, string>> = ((props?: Props) => Classnames) & {
|
|
2
3
|
splitVariantProps: <T extends Props>(props: T) => [Props, Omit<T, keyof Props>];
|
|
3
4
|
};
|
|
4
5
|
export declare function createSlotRecipeContext<Props extends Record<string, string | boolean | undefined>, Classnames extends Record<string, string>>(recipe: SlotRecipe<Props, Classnames>): {
|
|
5
|
-
ClassNamesProvider: (
|
|
6
|
-
children:
|
|
6
|
+
ClassNamesProvider: (props: {
|
|
7
|
+
children: ReactNode;
|
|
7
8
|
value: Classnames;
|
|
8
|
-
}) =>
|
|
9
|
-
PropsProvider: (
|
|
10
|
-
children:
|
|
9
|
+
}) => ReactElement;
|
|
10
|
+
PropsProvider: (props: {
|
|
11
|
+
children: ReactNode;
|
|
11
12
|
value: Props;
|
|
12
|
-
}) =>
|
|
13
|
+
}) => ReactElement;
|
|
13
14
|
useClassNames: () => Classnames;
|
|
14
15
|
useProps: () => Props | null;
|
|
15
|
-
withRootProvider: <P>(Component:
|
|
16
|
+
withRootProvider: <P>(Component: ElementType<any>, options?: {
|
|
16
17
|
defaultProps?: Partial<P>;
|
|
17
|
-
}) =>
|
|
18
|
-
withProvider: <T, P>(Component:
|
|
18
|
+
}) => ForwardRefExoticComponent<PropsWithoutRef<P>>;
|
|
19
|
+
withProvider: <T, P>(Component: ElementType<any>, slot: keyof Classnames, options?: {
|
|
19
20
|
defaultProps?: Partial<P>;
|
|
20
|
-
}) =>
|
|
21
|
-
withContext: <T, P>(Component:
|
|
21
|
+
}) => ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
|
22
|
+
withContext: <T, P>(Component: ElementType<any>, slot?: keyof Classnames, options?: {
|
|
22
23
|
defaultProps?: Partial<P>;
|
|
23
|
-
}) =>
|
|
24
|
+
}) => ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
|
|
24
25
|
};
|
|
25
26
|
export {};
|
|
26
27
|
//# sourceMappingURL=create-slot-recipe-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-slot-recipe-context.d.ts","sourceRoot":"","sources":["../../src/utils/create-slot-recipe-context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-slot-recipe-context.d.ts","sourceRoot":"","sources":["../../src/utils/create-slot-recipe-context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,yBAAyB,EACzB,eAAe,EACf,YAAY,EACZ,SAAS,EACT,aAAa,EACd,MAAM,gBAAgB,CAAC;AAGxB,KAAK,UAAU,CACb,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,EAC1D,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IACvC,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,UAAU,CAAC,GAAG;IACpC,iBAAiB,EAAE,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC;CACjF,CAAC;AAUF,wBAAgB,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C;KAC3B,KACE,yBAAyB,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;CACvE,CAkIA"}
|
|
@@ -1,76 +1,94 @@
|
|
|
1
|
-
import { createContext, forwardRef, useContext } from "@lynx-js/react";
|
|
2
1
|
import clsx from "clsx";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
2
|
+
import { createContext, forwardRef, useContext } from "@lynx-js/react";
|
|
3
|
+
//#region src/utils/create-slot-recipe-context.tsx
|
|
4
|
+
function assertNotIntrinsicComponent(Component, caller) {
|
|
5
|
+
if (typeof Component !== "string") return;
|
|
6
|
+
throw new Error(`${caller} cannot wrap intrinsic tag "${Component}" in Lynx. Native <view>/<text> slots must be rendered as literal JSX in the component file; passing intrinsic strings through createSlotRecipeContext can cause BackgroundSnapshot not found errors.`);
|
|
7
|
+
}
|
|
8
|
+
function createSlotRecipeContext(recipe) {
|
|
9
|
+
const ClassNamesContext = createContext(null);
|
|
10
|
+
const PropsContext = createContext(null);
|
|
11
|
+
const ClassNamesProvider = ({ children, value }) => {
|
|
12
|
+
return <ClassNamesContext.Provider value={value}>{children}</ClassNamesContext.Provider>;
|
|
13
|
+
};
|
|
14
|
+
const PropsProvider = ({ children, value }) => {
|
|
15
|
+
return <PropsContext.Provider value={value}>{children}</PropsContext.Provider>;
|
|
16
|
+
};
|
|
17
|
+
function useClassNames() {
|
|
18
|
+
const context = useContext(ClassNamesContext);
|
|
19
|
+
if (context === null) throw new Error("useClassNames must be used within a ClassNamesProvider. Did you forget to wrap your component in a ClassNamesProvider?");
|
|
20
|
+
return context;
|
|
21
|
+
}
|
|
22
|
+
function useProps() {
|
|
23
|
+
return useContext(PropsContext);
|
|
24
|
+
}
|
|
25
|
+
const withRootProvider = (Component, options) => {
|
|
26
|
+
assertNotIntrinsicComponent(Component, "withRootProvider");
|
|
27
|
+
const { defaultProps } = options ?? {};
|
|
28
|
+
const StyledComponent = (innerProps) => {
|
|
29
|
+
const props = {
|
|
30
|
+
...defaultProps ?? {},
|
|
31
|
+
...useProps(),
|
|
32
|
+
...innerProps
|
|
33
|
+
};
|
|
34
|
+
const [variantProps, otherProps] = recipe.splitVariantProps(props);
|
|
35
|
+
const classNames = recipe(variantProps);
|
|
36
|
+
return <ClassNamesProvider value={classNames}>
|
|
29
37
|
<PropsProvider value={variantProps}>
|
|
30
|
-
<Component {...otherProps}/>
|
|
38
|
+
<Component {...otherProps} />
|
|
31
39
|
</PropsProvider>
|
|
32
|
-
</ClassNamesProvider
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
</ClassNamesProvider>;
|
|
41
|
+
};
|
|
42
|
+
StyledComponent.displayName = Component.displayName || Component.name;
|
|
43
|
+
return StyledComponent;
|
|
44
|
+
};
|
|
45
|
+
const withProvider = (Component, slot, options) => {
|
|
46
|
+
assertNotIntrinsicComponent(Component, "withProvider");
|
|
47
|
+
const { defaultProps } = options ?? {};
|
|
48
|
+
const StyledComponent = forwardRef((innerProps, ref) => {
|
|
49
|
+
const props = {
|
|
50
|
+
...defaultProps ?? {},
|
|
51
|
+
...useProps(),
|
|
52
|
+
...innerProps
|
|
53
|
+
};
|
|
54
|
+
const [variantProps, otherProps] = recipe.splitVariantProps(props);
|
|
55
|
+
const classNames = recipe(variantProps);
|
|
56
|
+
const slotClassName = classNames[slot];
|
|
57
|
+
const userClassName = props["className"];
|
|
58
|
+
return <ClassNamesProvider value={classNames}>
|
|
47
59
|
<PropsProvider value={variantProps}>
|
|
48
|
-
<Component {...
|
|
60
|
+
<Component {...ref ? { ref } : {}} {...otherProps} className={clsx(slotClassName, userClassName)} />
|
|
49
61
|
</PropsProvider>
|
|
50
|
-
</ClassNamesProvider
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
</ClassNamesProvider>;
|
|
63
|
+
});
|
|
64
|
+
StyledComponent.displayName = Component.displayName || Component.name;
|
|
65
|
+
return StyledComponent;
|
|
66
|
+
};
|
|
67
|
+
const withContext = (Component, slot, options) => {
|
|
68
|
+
assertNotIntrinsicComponent(Component, "withContext");
|
|
69
|
+
const { defaultProps } = options ?? {};
|
|
70
|
+
const StyledComponent = forwardRef((innerProps, ref) => {
|
|
71
|
+
const props = {
|
|
72
|
+
...defaultProps ?? {},
|
|
73
|
+
...innerProps
|
|
74
|
+
};
|
|
75
|
+
const classNames = useClassNames();
|
|
76
|
+
const slotClassName = slot ? classNames[slot] : void 0;
|
|
77
|
+
const userClassName = props["className"];
|
|
78
|
+
return <Component {...ref ? { ref } : {}} {...props} className={clsx(slotClassName, userClassName)} />;
|
|
79
|
+
});
|
|
80
|
+
StyledComponent.displayName = Component.displayName || Component.name;
|
|
81
|
+
return StyledComponent;
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
ClassNamesProvider,
|
|
85
|
+
PropsProvider,
|
|
86
|
+
useClassNames,
|
|
87
|
+
useProps,
|
|
88
|
+
withRootProvider,
|
|
89
|
+
withProvider,
|
|
90
|
+
withContext
|
|
91
|
+
};
|
|
76
92
|
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { createSlotRecipeContext };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
type ColorMode = "system" | "light-only" | "dark-only";
|
|
1
|
+
export type ColorMode = "system" | "light-only" | "dark-only";
|
|
2
|
+
export interface GetSeedClassNameOptions {
|
|
3
|
+
colorMode?: ColorMode;
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
6
|
* Lynx 앱의 root `<page>` 요소에 적용할 SEED Design className을 반환한다.
|
|
4
7
|
*
|
|
5
|
-
* 테마(dark/light)
|
|
6
|
-
* 렌더링 전에 올바른 CSS 변수가 적용되도록 한다.
|
|
8
|
+
* 테마(dark/light)를 자동 감지하여 렌더링 전에 올바른 CSS 변수가 적용되도록 한다.
|
|
7
9
|
*
|
|
8
10
|
* @example
|
|
9
11
|
* ```tsx
|
|
@@ -16,8 +18,5 @@ type ColorMode = "system" | "light-only" | "dark-only";
|
|
|
16
18
|
* );
|
|
17
19
|
* ```
|
|
18
20
|
*/
|
|
19
|
-
export declare function getSeedClassName(options?:
|
|
20
|
-
colorMode?: ColorMode;
|
|
21
|
-
}): string;
|
|
22
|
-
export {};
|
|
21
|
+
export declare function getSeedClassName(options?: GetSeedClassNameOptions): string;
|
|
23
22
|
//# sourceMappingURL=get-seed-class-name.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-seed-class-name.d.ts","sourceRoot":"","sources":["../../src/utils/get-seed-class-name.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-seed-class-name.d.ts","sourceRoot":"","sources":["../../src/utils/get-seed-class-name.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,YAAY,GAAG,WAAW,CAAC;AAE9D,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,MAAM,CAkB1E"}
|
|
@@ -1,39 +1,28 @@
|
|
|
1
|
+
//#region src/utils/get-seed-class-name.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
else if (colorMode === "dark-only") {
|
|
27
|
-
themeClass = "seed-user-color-scheme-dark";
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
themeClass =
|
|
31
|
-
systemTheme?.toLowerCase() === "dark"
|
|
32
|
-
? "seed-user-color-scheme-dark"
|
|
33
|
-
: "seed-user-color-scheme-light";
|
|
34
|
-
}
|
|
35
|
-
// Platform — SystemInfo.platform에서 디바이스 플랫폼 읽기
|
|
36
|
-
const platform = SystemInfo?.platform;
|
|
37
|
-
const platformClass = platform === "iOS" ? "seed-platform-ios" : "seed-platform-android";
|
|
38
|
-
return `${themeClass} ${platformClass}`;
|
|
3
|
+
* Lynx 앱의 root `<page>` 요소에 적용할 SEED Design className을 반환한다.
|
|
4
|
+
*
|
|
5
|
+
* 테마(dark/light)를 자동 감지하여 렌더링 전에 올바른 CSS 변수가 적용되도록 한다.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { getSeedClassName } from "@seed-design/lynx-react";
|
|
10
|
+
*
|
|
11
|
+
* root.render(
|
|
12
|
+
* <page className={getSeedClassName({ colorMode: "system" })}>
|
|
13
|
+
* <App />
|
|
14
|
+
* </page>
|
|
15
|
+
* );
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function getSeedClassName(options) {
|
|
19
|
+
const { colorMode = "system" } = options ?? {};
|
|
20
|
+
const systemTheme = lynx?.__globalProps?.["theme"];
|
|
21
|
+
let themeClass;
|
|
22
|
+
if (colorMode === "light-only") themeClass = "seed-user-color-scheme-light";
|
|
23
|
+
else if (colorMode === "dark-only") themeClass = "seed-user-color-scheme-dark";
|
|
24
|
+
else themeClass = systemTheme?.toLowerCase() === "dark" ? "seed-user-color-scheme-dark" : "seed-user-color-scheme-light";
|
|
25
|
+
return themeClass;
|
|
39
26
|
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { getSeedClassName };
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from './create-slot-recipe-context';
|
|
2
|
+
export * from './get-seed-class-name';
|
|
3
|
+
export * from './resolve-recipe-token';
|
|
4
|
+
export * from './split-multiple-variants-props';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,47 +1,49 @@
|
|
|
1
|
+
//#region src/utils/resolve-recipe-token.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return typeof cursor === "string" ? cursor : undefined;
|
|
3
|
+
* Rootage vars 객체에서 `path` 를 따라 token 값(주로 `"var(--seed-...)"` 스트링)을 꺼낸다.
|
|
4
|
+
*
|
|
5
|
+
* 쓰임새: Lynx `<image>` 의 `tint-color` / `width` / `height` 처럼 CSS 만으로는
|
|
6
|
+
* override 할 수 없거나(아이콘 패키지가 inline style 을 박는 경우 등) React 가
|
|
7
|
+
* recipe 와 같은 소스에서 꺼내 inline attribute 로 주입해야 하는 속성을 다룰 때.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { actionButton as actionButtonVars } from "@seed-design/lynx-css/vars/component";
|
|
11
|
+
* import { capitalize, resolveRecipeToken } from "@seed-design/lynx-react/utils/resolve-recipe-token";
|
|
12
|
+
*
|
|
13
|
+
* // variant × state × slot → color
|
|
14
|
+
* const color = resolveRecipeToken(actionButtonVars, [
|
|
15
|
+
* `variant${capitalize(variant)}`,
|
|
16
|
+
* state, // "enabled" | "disabled" | "loading" | "pressed"
|
|
17
|
+
* "prefixIcon",
|
|
18
|
+
* "color",
|
|
19
|
+
* ]);
|
|
20
|
+
*
|
|
21
|
+
* // size × layout → icon size
|
|
22
|
+
* const size = resolveRecipeToken(actionButtonVars, [
|
|
23
|
+
* `size${capitalize(size)}Layout${capitalize(layout)}`,
|
|
24
|
+
* "enabled",
|
|
25
|
+
* "prefixIcon",
|
|
26
|
+
* "size",
|
|
27
|
+
* ]);
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* recipe token 경로가 컴포넌트마다 조금씩 다르므로(variant/size/layout 조합 여부 등)
|
|
31
|
+
* 이 유틸은 "vars + path" 조합만 제공하고, 각 컴포넌트가 자기 path 를 만들어 호출한다.
|
|
32
|
+
*/
|
|
33
|
+
function resolveRecipeToken(vars, path) {
|
|
34
|
+
let cursor = vars;
|
|
35
|
+
for (const key of path) {
|
|
36
|
+
if (cursor == null || typeof cursor !== "object") return void 0;
|
|
37
|
+
cursor = cursor[key];
|
|
38
|
+
}
|
|
39
|
+
return typeof cursor === "string" ? cursor : void 0;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
* 첫 글자 대문자. recipe variant key 조립용
|
|
43
|
+
* (e.g. `variant` + `brandSolid` → `variantBrandSolid`).
|
|
44
|
+
*/
|
|
45
|
+
function capitalize(value) {
|
|
46
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
47
47
|
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { capitalize, resolveRecipeToken };
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
+
//#region src/utils/split-multiple-variants-props.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
remainingProps[propKey] = propsRecord[propKey];
|
|
32
|
-
}
|
|
33
|
-
return [multipleVariantsProps, remainingProps];
|
|
3
|
+
* Split `props` across multiple recipes' variant extractors in one pass.
|
|
4
|
+
*
|
|
5
|
+
* Given `recipesMap` of `{ [recipeKey]: recipe }`, returns:
|
|
6
|
+
* - A bucket per recipe key with that recipe's variant-only props.
|
|
7
|
+
* - `remainingProps` with every recipe variant key stripped out.
|
|
8
|
+
*
|
|
9
|
+
* Keys that appear in more than one recipe (e.g. shared `size`) are copied
|
|
10
|
+
* into each corresponding bucket. `remainingProps` never includes any key
|
|
11
|
+
* that any recipe claimed as a variant.
|
|
12
|
+
*
|
|
13
|
+
* Mirror of `packages/react/src/utils/splitMultipleVariantsProps` adapted
|
|
14
|
+
* to TypeScript for Lynx. Use when a single compound component composes two
|
|
15
|
+
* or more recipes (e.g. Switch's `switch` + `switchmark`).
|
|
16
|
+
*/
|
|
17
|
+
function splitMultipleVariantsProps(props, recipesMap) {
|
|
18
|
+
const multipleVariantsProps = {};
|
|
19
|
+
const extractedKeys = /* @__PURE__ */ new Set();
|
|
20
|
+
const propsRecord = props;
|
|
21
|
+
for (const recipeKey in recipesMap) {
|
|
22
|
+
const [variantProps] = recipesMap[recipeKey].splitVariantProps(propsRecord);
|
|
23
|
+
multipleVariantsProps[recipeKey] = variantProps;
|
|
24
|
+
for (const variantPropKey in variantProps) extractedKeys.add(variantPropKey);
|
|
25
|
+
}
|
|
26
|
+
const remainingProps = {};
|
|
27
|
+
for (const propKey in propsRecord) {
|
|
28
|
+
if (extractedKeys.has(propKey)) continue;
|
|
29
|
+
remainingProps[propKey] = propsRecord[propKey];
|
|
30
|
+
}
|
|
31
|
+
return [multipleVariantsProps, remainingProps];
|
|
34
32
|
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { splitMultipleVariantsProps };
|