@seed-design/lynx-react 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,4 +2,5 @@ export * from './useControllableState';
2
2
  export * from './useIconColor';
3
3
  export * from './usePressTap';
4
4
  export * from './useSafeArea';
5
+ export * from './useSeedClassName';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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;AAC9B,cAAc,eAAe,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;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { GetSeedClassNameOptions } from '../utils/get-seed-class-name';
2
+ /**
3
+ * Lynx 앱의 root `<page>` 요소에 적용할 SEED Design className을 반환하는 훅이다.
4
+ *
5
+ * `getSeedClassName()`의 reactive 버전으로, `useGlobalProps()`를 통해
6
+ * `lynx.__globalProps.theme` 변경을 구독한다. host가 테마를 변경하면 이 훅을
7
+ * 사용하는 컴포넌트가 리렌더되어 className이 갱신된다.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { root } from "@lynx-js/react";
12
+ * import { useSeedClassName } from "@seed-design/lynx-react";
13
+ *
14
+ * function Root() {
15
+ * const seedClassName = useSeedClassName({ colorMode: "system" });
16
+ * return (
17
+ * <page className={seedClassName}>
18
+ * <App />
19
+ * </page>
20
+ * );
21
+ * }
22
+ *
23
+ * root.render(<Root />);
24
+ * ```
25
+ */
26
+ export declare function useSeedClassName(options?: GetSeedClassNameOptions): string;
27
+ //# sourceMappingURL=useSeedClassName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSeedClassName.d.ts","sourceRoot":"","sources":["../../src/hooks/useSeedClassName.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,MAAM,CAM1E"}
@@ -0,0 +1,32 @@
1
+ import { getSeedClassName } from "../utils/get-seed-class-name.js";
2
+ import { useGlobalProps, useMemo } from "@lynx-js/react";
3
+ //#region src/hooks/useSeedClassName.ts
4
+ /**
5
+ * Lynx 앱의 root `<page>` 요소에 적용할 SEED Design className을 반환하는 훅이다.
6
+ *
7
+ * `getSeedClassName()`의 reactive 버전으로, `useGlobalProps()`를 통해
8
+ * `lynx.__globalProps.theme` 변경을 구독한다. host가 테마를 변경하면 이 훅을
9
+ * 사용하는 컴포넌트가 리렌더되어 className이 갱신된다.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * import { root } from "@lynx-js/react";
14
+ * import { useSeedClassName } from "@seed-design/lynx-react";
15
+ *
16
+ * function Root() {
17
+ * const seedClassName = useSeedClassName({ colorMode: "system" });
18
+ * return (
19
+ * <page className={seedClassName}>
20
+ * <App />
21
+ * </page>
22
+ * );
23
+ * }
24
+ *
25
+ * root.render(<Root />);
26
+ * ```
27
+ */
28
+ function useSeedClassName(options) {
29
+ return useMemo(() => getSeedClassName(options), [useGlobalProps().theme, options?.colorMode]);
30
+ }
31
+ //#endregion
32
+ export { useSeedClassName };
package/lib/index.js CHANGED
@@ -26,4 +26,5 @@ import { TagGroupItem, TagGroupItemLabel, TagGroupRoot } from "./components/TagG
26
26
  import { TagGroup_namespace_exports } from "./components/TagGroup/TagGroup.namespace.js";
27
27
  import { Text } from "./components/Text/Text.jsx";
28
28
  import { getSeedClassName } from "./utils/get-seed-class-name.js";
29
- export { ActionButton, AppBar_namespace_exports as AppBar, AppBarIconButton, AppBarLeft, AppBarMain, AppBarRight, AppBarRoot, AppBarSlot, AppBarSubtitle, AppBarTitle, Badge, BottomSheet_namespace_exports as BottomSheet, BottomSheetBackdrop, BottomSheetBody, BottomSheetContent, BottomSheetDescription, BottomSheetFooter, BottomSheetHandle, BottomSheetHeader, BottomSheetPositioner, BottomSheetRoot, BottomSheetTitle, BottomSheetTrigger, Box, Checkbox_namespace_exports as Checkbox, CheckboxControl, CheckboxGroup, CheckboxIndicator, CheckboxLabel, CheckboxRoot, HStack, Icon, PrefixIcon, ProgressCircle_namespace_exports as ProgressCircle, ProgressCircleRange, ProgressCircleRoot, RadioGroup_namespace_exports as RadioGroup, RadioGroupItem, RadioGroupItemControl, RadioGroupItemIndicator, RadioGroupItemLabel, RadioGroupRoot, SuffixIcon, Switch_namespace_exports as Switch, SwitchControl, SwitchLabel, SwitchRoot, SwitchThumb, TagGroup_namespace_exports as TagGroup, TagGroupItem, TagGroupItemLabel, TagGroupRoot, Text, VStack, capitalize, createSlotRecipeContext, getSeedClassName, resolveRecipeToken, splitMultipleVariantsProps, useControllableState, useIconColor, usePressTap, useSafeArea };
29
+ import { useSeedClassName } from "./hooks/useSeedClassName.js";
30
+ export { ActionButton, AppBar_namespace_exports as AppBar, AppBarIconButton, AppBarLeft, AppBarMain, AppBarRight, AppBarRoot, AppBarSlot, AppBarSubtitle, AppBarTitle, Badge, BottomSheet_namespace_exports as BottomSheet, BottomSheetBackdrop, BottomSheetBody, BottomSheetContent, BottomSheetDescription, BottomSheetFooter, BottomSheetHandle, BottomSheetHeader, BottomSheetPositioner, BottomSheetRoot, BottomSheetTitle, BottomSheetTrigger, Box, Checkbox_namespace_exports as Checkbox, CheckboxControl, CheckboxGroup, CheckboxIndicator, CheckboxLabel, CheckboxRoot, HStack, Icon, PrefixIcon, ProgressCircle_namespace_exports as ProgressCircle, ProgressCircleRange, ProgressCircleRoot, RadioGroup_namespace_exports as RadioGroup, RadioGroupItem, RadioGroupItemControl, RadioGroupItemIndicator, RadioGroupItemLabel, RadioGroupRoot, SuffixIcon, Switch_namespace_exports as Switch, SwitchControl, SwitchLabel, SwitchRoot, SwitchThumb, TagGroup_namespace_exports as TagGroup, TagGroupItem, TagGroupItemLabel, TagGroupRoot, Text, VStack, capitalize, createSlotRecipeContext, getSeedClassName, resolveRecipeToken, splitMultipleVariantsProps, useControllableState, useIconColor, usePressTap, useSafeArea, useSeedClassName };
@@ -7,6 +7,9 @@ export interface GetSeedClassNameOptions {
7
7
  *
8
8
  * 테마(dark/light)를 자동 감지하여 렌더링 전에 올바른 CSS 변수가 적용되도록 한다.
9
9
  *
10
+ * 호출 시점의 테마를 한 번만 읽는 순수 함수다. 런타임 테마 변경에 반응해야 하면
11
+ * reactive 버전인 `useSeedClassName` 훅을 사용한다.
12
+ *
10
13
  * @example
11
14
  * ```tsx
12
15
  * import { getSeedClassName } from "@seed-design/lynx-react";
@@ -1 +1 @@
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
+ {"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;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,MAAM,CAkB1E"}
@@ -4,6 +4,9 @@
4
4
  *
5
5
  * 테마(dark/light)를 자동 감지하여 렌더링 전에 올바른 CSS 변수가 적용되도록 한다.
6
6
  *
7
+ * 호출 시점의 테마를 한 번만 읽는 순수 함수다. 런타임 테마 변경에 반응해야 하면
8
+ * reactive 버전인 `useSeedClassName` 훅을 사용한다.
9
+ *
7
10
  * @example
8
11
  * ```tsx
9
12
  * import { getSeedClassName } from "@seed-design/lynx-react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/lynx-react",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -29,14 +29,14 @@
29
29
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit"
30
30
  },
31
31
  "peerDependencies": {
32
- "@lynx-js/react": ">=0.100.0",
32
+ "@lynx-js/react": ">=0.117.0",
33
33
  "@lynx-js/types": ">=3.7.0",
34
34
  "@seed-design/lynx-css": "0.0.0 || >=0.1.0 <1.0.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@lynx-js/react": "^0.116.3",
37
+ "@lynx-js/react": "^0.117.0",
38
38
  "@lynx-js/types": "^3.7.0",
39
- "@seed-design/lynx-css": "0.2.0",
39
+ "@seed-design/lynx-css": "0.4.1",
40
40
  "@testing-library/jest-dom": "^6.9.1",
41
41
  "jsdom": "^29.0.2",
42
42
  "vite": "^8.0.0",
@@ -2,3 +2,4 @@ export * from "./useControllableState";
2
2
  export * from "./useIconColor";
3
3
  export * from "./usePressTap";
4
4
  export * from "./useSafeArea";
5
+ export * from "./useSeedClassName";
@@ -0,0 +1,35 @@
1
+ import { useGlobalProps, useMemo } from "@lynx-js/react";
2
+
3
+ import { getSeedClassName, type GetSeedClassNameOptions } from "../utils/get-seed-class-name";
4
+
5
+ /**
6
+ * Lynx 앱의 root `<page>` 요소에 적용할 SEED Design className을 반환하는 훅이다.
7
+ *
8
+ * `getSeedClassName()`의 reactive 버전으로, `useGlobalProps()`를 통해
9
+ * `lynx.__globalProps.theme` 변경을 구독한다. host가 테마를 변경하면 이 훅을
10
+ * 사용하는 컴포넌트가 리렌더되어 className이 갱신된다.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { root } from "@lynx-js/react";
15
+ * import { useSeedClassName } from "@seed-design/lynx-react";
16
+ *
17
+ * function Root() {
18
+ * const seedClassName = useSeedClassName({ colorMode: "system" });
19
+ * return (
20
+ * <page className={seedClassName}>
21
+ * <App />
22
+ * </page>
23
+ * );
24
+ * }
25
+ *
26
+ * root.render(<Root />);
27
+ * ```
28
+ */
29
+ export function useSeedClassName(options?: GetSeedClassNameOptions): string {
30
+ // useGlobalProps()로 lynx.__globalProps를 구독한다.
31
+ // host가 theme을 변경하면 이 훅을 사용하는 컴포넌트가 리렌더되어 className이 갱신된다.
32
+ const globalProps = useGlobalProps() as { theme?: unknown };
33
+
34
+ return useMemo(() => getSeedClassName(options), [globalProps.theme, options?.colorMode]);
35
+ }
@@ -15,6 +15,9 @@ export interface GetSeedClassNameOptions {
15
15
  *
16
16
  * 테마(dark/light)를 자동 감지하여 렌더링 전에 올바른 CSS 변수가 적용되도록 한다.
17
17
  *
18
+ * 호출 시점의 테마를 한 번만 읽는 순수 함수다. 런타임 테마 변경에 반응해야 하면
19
+ * reactive 버전인 `useSeedClassName` 훅을 사용한다.
20
+ *
18
21
  * @example
19
22
  * ```tsx
20
23
  * import { getSeedClassName } from "@seed-design/lynx-react";