@seed-design/lynx-react 0.1.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 (168) hide show
  1. package/lib/_virtual/_rolldown/runtime.js +13 -0
  2. package/lib/components/ActionButton/ActionButton.d.ts +44 -0
  3. package/lib/components/ActionButton/ActionButton.d.ts.map +1 -0
  4. package/lib/components/ActionButton/ActionButton.jsx +158 -0
  5. package/lib/components/ActionButton/index.d.ts +2 -0
  6. package/lib/components/ActionButton/index.d.ts.map +1 -0
  7. package/lib/components/BottomSheet/BottomSheet.d.ts +87 -0
  8. package/lib/components/BottomSheet/BottomSheet.d.ts.map +1 -0
  9. package/lib/components/BottomSheet/BottomSheet.jsx +150 -0
  10. package/lib/components/BottomSheet/BottomSheet.namespace.d.ts +2 -0
  11. package/lib/components/BottomSheet/BottomSheet.namespace.d.ts.map +1 -0
  12. package/lib/components/BottomSheet/BottomSheet.namespace.js +18 -0
  13. package/lib/components/BottomSheet/index.d.ts +3 -0
  14. package/lib/components/BottomSheet/index.d.ts.map +1 -0
  15. package/lib/components/Box/Box.d.ts +20 -0
  16. package/lib/components/Box/Box.d.ts.map +1 -0
  17. package/lib/components/Box/Box.jsx +14 -0
  18. package/lib/components/Box/index.d.ts +2 -0
  19. package/lib/components/Box/index.d.ts.map +1 -0
  20. package/lib/components/Checkbox/Checkbox.d.ts +35 -0
  21. package/lib/components/Checkbox/Checkbox.d.ts.map +1 -0
  22. package/lib/components/Checkbox/Checkbox.jsx +130 -0
  23. package/lib/components/Checkbox/Checkbox.namespace.d.ts +2 -0
  24. package/lib/components/Checkbox/Checkbox.namespace.d.ts.map +1 -0
  25. package/lib/components/Checkbox/Checkbox.namespace.js +12 -0
  26. package/lib/components/Checkbox/index.d.ts +3 -0
  27. package/lib/components/Checkbox/index.d.ts.map +1 -0
  28. package/lib/components/Icon/Icon.d.ts +37 -0
  29. package/lib/components/Icon/Icon.d.ts.map +1 -0
  30. package/lib/components/Icon/Icon.jsx +143 -0
  31. package/lib/components/Icon/index.d.ts +2 -0
  32. package/lib/components/Icon/index.d.ts.map +1 -0
  33. package/lib/components/ProgressCircle/ProgressCircle.d.ts +25 -0
  34. package/lib/components/ProgressCircle/ProgressCircle.d.ts.map +1 -0
  35. package/lib/components/ProgressCircle/ProgressCircle.jsx +281 -0
  36. package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts +2 -0
  37. package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts.map +1 -0
  38. package/lib/components/ProgressCircle/ProgressCircle.namespace.js +9 -0
  39. package/lib/components/ProgressCircle/index.d.ts +3 -0
  40. package/lib/components/ProgressCircle/index.d.ts.map +1 -0
  41. package/lib/components/RadioGroup/RadioGroup.d.ts +34 -0
  42. package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -0
  43. package/lib/components/RadioGroup/RadioGroup.jsx +160 -0
  44. package/lib/components/RadioGroup/RadioGroup.namespace.d.ts +2 -0
  45. package/lib/components/RadioGroup/RadioGroup.namespace.d.ts.map +1 -0
  46. package/lib/components/RadioGroup/RadioGroup.namespace.js +12 -0
  47. package/lib/components/RadioGroup/index.d.ts +3 -0
  48. package/lib/components/RadioGroup/index.d.ts.map +1 -0
  49. package/lib/components/Stack/Stack.d.ts +33 -0
  50. package/lib/components/Stack/Stack.d.ts.map +1 -0
  51. package/lib/components/Stack/Stack.jsx +39 -0
  52. package/lib/components/Stack/index.d.ts +2 -0
  53. package/lib/components/Stack/index.d.ts.map +1 -0
  54. package/lib/components/Switch/Switch.d.ts +21 -0
  55. package/lib/components/Switch/Switch.d.ts.map +1 -0
  56. package/lib/components/Switch/Switch.jsx +101 -0
  57. package/lib/components/Switch/Switch.namespace.d.ts +2 -0
  58. package/lib/components/Switch/Switch.namespace.d.ts.map +1 -0
  59. package/lib/components/Switch/Switch.namespace.js +11 -0
  60. package/lib/components/Switch/index.d.ts +3 -0
  61. package/lib/components/Switch/index.d.ts.map +1 -0
  62. package/lib/components/TagGroup/TagGroup.d.ts +34 -0
  63. package/lib/components/TagGroup/TagGroup.d.ts.map +1 -0
  64. package/lib/components/TagGroup/TagGroup.jsx +57 -0
  65. package/lib/components/TagGroup/TagGroup.namespace.d.ts +2 -0
  66. package/lib/components/TagGroup/TagGroup.namespace.d.ts.map +1 -0
  67. package/lib/components/TagGroup/TagGroup.namespace.js +10 -0
  68. package/lib/components/TagGroup/index.d.ts +3 -0
  69. package/lib/components/TagGroup/index.d.ts.map +1 -0
  70. package/lib/components/Text/Text.d.ts +7 -0
  71. package/lib/components/Text/Text.d.ts.map +1 -0
  72. package/lib/components/Text/Text.jsx +28 -0
  73. package/lib/components/Text/index.d.ts +2 -0
  74. package/lib/components/Text/index.d.ts.map +1 -0
  75. package/lib/components/index.d.ts +12 -0
  76. package/lib/components/index.d.ts.map +1 -0
  77. package/lib/hooks/index.d.ts +5 -0
  78. package/lib/hooks/index.d.ts.map +1 -0
  79. package/lib/hooks/useControllableState.d.ts +15 -0
  80. package/lib/hooks/useControllableState.d.ts.map +1 -0
  81. package/lib/hooks/useControllableState.js +27 -0
  82. package/lib/hooks/useIconColor.d.ts +19 -0
  83. package/lib/hooks/useIconColor.d.ts.map +1 -0
  84. package/lib/hooks/useIconColor.js +38 -0
  85. package/lib/hooks/usePressTap.d.ts +27 -0
  86. package/lib/hooks/usePressTap.d.ts.map +1 -0
  87. package/lib/hooks/usePressTap.js +35 -0
  88. package/lib/hooks/useSafeArea.d.ts +19 -0
  89. package/lib/hooks/useSafeArea.d.ts.map +1 -0
  90. package/lib/hooks/useSafeArea.js +33 -0
  91. package/lib/index.d.ts +5 -0
  92. package/lib/index.d.ts.map +1 -0
  93. package/lib/index.js +26 -0
  94. package/lib/types.d.ts +33 -0
  95. package/lib/types.d.ts.map +1 -0
  96. package/lib/utils/children.d.ts +3 -0
  97. package/lib/utils/children.d.ts.map +1 -0
  98. package/lib/utils/children.js +8 -0
  99. package/lib/utils/create-slot-recipe-context.d.ts +27 -0
  100. package/lib/utils/create-slot-recipe-context.d.ts.map +1 -0
  101. package/lib/utils/create-slot-recipe-context.jsx +94 -0
  102. package/lib/utils/get-seed-class-name.d.ts +22 -0
  103. package/lib/utils/get-seed-class-name.d.ts.map +1 -0
  104. package/lib/utils/get-seed-class-name.js +28 -0
  105. package/lib/utils/index.d.ts +5 -0
  106. package/lib/utils/index.d.ts.map +1 -0
  107. package/lib/utils/resolve-recipe-token.d.ts +38 -0
  108. package/lib/utils/resolve-recipe-token.d.ts.map +1 -0
  109. package/lib/utils/resolve-recipe-token.js +49 -0
  110. package/lib/utils/split-multiple-variants-props.d.ts +29 -0
  111. package/lib/utils/split-multiple-variants-props.d.ts.map +1 -0
  112. package/lib/utils/split-multiple-variants-props.js +34 -0
  113. package/lib/utils/styled.d.ts +83 -0
  114. package/lib/utils/styled.d.ts.map +1 -0
  115. package/lib/utils/styled.js +144 -0
  116. package/package.json +54 -0
  117. package/src/components/ActionButton/ActionButton.test.tsx +137 -0
  118. package/src/components/ActionButton/ActionButton.tsx +340 -0
  119. package/src/components/ActionButton/index.ts +1 -0
  120. package/src/components/BottomSheet/BottomSheet.namespace.ts +24 -0
  121. package/src/components/BottomSheet/BottomSheet.test.tsx +153 -0
  122. package/src/components/BottomSheet/BottomSheet.tsx +397 -0
  123. package/src/components/BottomSheet/index.ts +27 -0
  124. package/src/components/Box/Box.test.tsx +85 -0
  125. package/src/components/Box/Box.tsx +39 -0
  126. package/src/components/Box/index.ts +1 -0
  127. package/src/components/Checkbox/Checkbox.namespace.ts +12 -0
  128. package/src/components/Checkbox/Checkbox.tsx +282 -0
  129. package/src/components/Checkbox/index.ts +14 -0
  130. package/src/components/Icon/Icon.tsx +265 -0
  131. package/src/components/Icon/index.ts +8 -0
  132. package/src/components/ProgressCircle/ProgressCircle.namespace.ts +5 -0
  133. package/src/components/ProgressCircle/ProgressCircle.tsx +424 -0
  134. package/src/components/ProgressCircle/index.ts +9 -0
  135. package/src/components/RadioGroup/RadioGroup.namespace.ts +12 -0
  136. package/src/components/RadioGroup/RadioGroup.tsx +320 -0
  137. package/src/components/RadioGroup/index.ts +14 -0
  138. package/src/components/Stack/Stack.tsx +97 -0
  139. package/src/components/Stack/index.ts +1 -0
  140. package/src/components/Switch/Switch.namespace.ts +10 -0
  141. package/src/components/Switch/Switch.tsx +200 -0
  142. package/src/components/Switch/index.ts +12 -0
  143. package/src/components/TagGroup/TagGroup.namespace.ts +8 -0
  144. package/src/components/TagGroup/TagGroup.tsx +127 -0
  145. package/src/components/TagGroup/index.ts +10 -0
  146. package/src/components/Text/Text.tsx +64 -0
  147. package/src/components/Text/index.ts +1 -0
  148. package/src/components/index.ts +11 -0
  149. package/src/hooks/index.ts +4 -0
  150. package/src/hooks/useControllableState.test.ts +120 -0
  151. package/src/hooks/useControllableState.ts +38 -0
  152. package/src/hooks/useIconColor.test.ts +13 -0
  153. package/src/hooks/useIconColor.ts +67 -0
  154. package/src/hooks/usePressTap.test.ts +129 -0
  155. package/src/hooks/usePressTap.ts +58 -0
  156. package/src/hooks/useSafeArea.test.ts +83 -0
  157. package/src/hooks/useSafeArea.ts +56 -0
  158. package/src/index.ts +4 -0
  159. package/src/types.ts +45 -0
  160. package/src/utils/children.ts +13 -0
  161. package/src/utils/create-slot-recipe-context.test.tsx +96 -0
  162. package/src/utils/create-slot-recipe-context.tsx +187 -0
  163. package/src/utils/get-seed-class-name.ts +47 -0
  164. package/src/utils/index.ts +4 -0
  165. package/src/utils/resolve-recipe-token.ts +47 -0
  166. package/src/utils/split-multiple-variants-props.test.ts +61 -0
  167. package/src/utils/split-multiple-variants-props.ts +59 -0
  168. package/src/utils/styled.ts +442 -0
@@ -0,0 +1,49 @@
1
+ //#region src/utils/resolve-recipe-token.ts
2
+ /**
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
+ }
41
+ /**
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
+ }
48
+ //#endregion
49
+ export { capitalize, resolveRecipeToken };
@@ -0,0 +1,29 @@
1
+ type RecipeLike = {
2
+ splitVariantProps: (props: Record<string, unknown>) => [Record<string, unknown>, unknown];
3
+ };
4
+ type ExtractVariantProps<T> = T extends {
5
+ splitVariantProps: (...args: never[]) => [infer V, unknown];
6
+ } ? V : never;
7
+ type ExtractAllVariantKeys<R> = {
8
+ [K in keyof R]: ExtractVariantProps<R[K]> extends infer V ? V extends Record<string, unknown> ? keyof V : never : never;
9
+ }[keyof R];
10
+ /**
11
+ * Split `props` across multiple recipes' variant extractors in one pass.
12
+ *
13
+ * Given `recipesMap` of `{ [recipeKey]: recipe }`, returns:
14
+ * - A bucket per recipe key with that recipe's variant-only props.
15
+ * - `remainingProps` with every recipe variant key stripped out.
16
+ *
17
+ * Keys that appear in more than one recipe (e.g. shared `size`) are copied
18
+ * into each corresponding bucket. `remainingProps` never includes any key
19
+ * that any recipe claimed as a variant.
20
+ *
21
+ * Mirror of `packages/react/src/utils/splitMultipleVariantsProps` adapted
22
+ * to TypeScript for Lynx. Use when a single compound component composes two
23
+ * or more recipes (e.g. Switch's `switch` + `switchmark`).
24
+ */
25
+ export declare function splitMultipleVariantsProps<R extends Record<string, RecipeLike>, P>(props: P, recipesMap: R): [{
26
+ [K in keyof R]: ExtractVariantProps<R[K]>;
27
+ }, Omit<P, ExtractAllVariantKeys<R>>];
28
+ export {};
29
+ //# sourceMappingURL=split-multiple-variants-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split-multiple-variants-props.d.ts","sourceRoot":"","sources":["../../src/utils/split-multiple-variants-props.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG;IAChB,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;CAC3F,CAAC;AAEF,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS;IACtC,iBAAiB,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;CAC7D,GACG,CAAC,GACD,KAAK,CAAC;AAEV,KAAK,qBAAqB,CAAC,CAAC,IAAI;KAC7B,CAAC,IAAI,MAAM,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,GACrD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,GACP,KAAK,GACP,KAAK;CACV,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,EAChF,KAAK,EAAE,CAAC,EACR,UAAU,EAAE,CAAC,GACZ,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,EAAE,IAAI,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAsBpF"}
@@ -0,0 +1,34 @@
1
+ //#region src/utils/split-multiple-variants-props.ts
2
+ /**
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];
32
+ }
33
+ //#endregion
34
+ export { splitMultipleVariantsProps };
@@ -0,0 +1,83 @@
1
+ import { CSSProperties } from '@lynx-js/types';
2
+ import { Dimension, FontSize, FontWeight, LineHeight, Radius, ScopedColorBanner, ScopedColorBg, ScopedColorFg, ScopedColorPalette, ScopedColorStroke, SpacingX, SpacingY } from '@seed-design/lynx-css/vars';
3
+ export declare function handleColor(color: string | undefined): any;
4
+ export declare function handleDimension(dimension: number | string | undefined): string | undefined;
5
+ export declare function resolveFlexValue(value: number | string | boolean | undefined): number | string | undefined;
6
+ export declare function handlePaddingWithSafeArea(padding: string | 0 | undefined, safeAreaInset: string): string | undefined;
7
+ export declare function handleRadius(radius: string | 0 | undefined): any;
8
+ export declare function handleFontWeight(fontWeight: string | undefined): any;
9
+ export declare function handleFontSize(size: string | undefined): any;
10
+ export declare function handleLineHeight(lineHeight: string | undefined): any;
11
+ export interface StyleProps {
12
+ bg?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
13
+ background?: ScopedColorBg | ScopedColorPalette | ScopedColorBanner | (string & {});
14
+ color?: ScopedColorFg | ScopedColorPalette | (string & {});
15
+ borderColor?: ScopedColorStroke | ScopedColorPalette | (string & {});
16
+ borderWidth?: 0 | 1 | (string & {});
17
+ borderTopWidth?: 0 | 1 | (string & {});
18
+ borderRightWidth?: 0 | 1 | (string & {});
19
+ borderBottomWidth?: 0 | 1 | (string & {});
20
+ borderLeftWidth?: 0 | 1 | (string & {});
21
+ borderRadius?: Radius | 0 | (string & {});
22
+ borderTopLeftRadius?: Radius | 0 | (string & {});
23
+ borderTopRightRadius?: Radius | 0 | (string & {});
24
+ borderBottomRightRadius?: Radius | 0 | (string & {});
25
+ borderBottomLeftRadius?: Radius | 0 | (string & {});
26
+ width?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
27
+ minWidth?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
28
+ maxWidth?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
29
+ height?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
30
+ minHeight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
31
+ maxHeight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | "full" | (string & {});
32
+ top?: 0 | (string & {});
33
+ left?: 0 | (string & {});
34
+ right?: 0 | (string & {});
35
+ bottom?: 0 | (string & {});
36
+ padding?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
37
+ p?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
38
+ paddingX?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
39
+ px?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
40
+ paddingY?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
41
+ py?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
42
+ paddingTop?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
43
+ pt?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
44
+ paddingRight?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
45
+ pr?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
46
+ paddingBottom?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
47
+ pb?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | "safeArea" | (string & {});
48
+ paddingLeft?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
49
+ pl?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
50
+ display?: "flex" | "none" | (string & {});
51
+ position?: "relative" | "absolute" | "fixed" | (string & {});
52
+ overflowX?: "visible" | "hidden" | (string & {});
53
+ overflowY?: "visible" | "hidden" | (string & {});
54
+ zIndex?: CSSProperties["zIndex"];
55
+ flexGrow?: CSSProperties["flexGrow"] | boolean;
56
+ flexShrink?: CSSProperties["flexShrink"] | boolean;
57
+ flexDirection?: "row" | "column" | "rowReverse" | "columnReverse" | (string & {});
58
+ flexWrap?: "nowrap" | "wrap" | boolean;
59
+ justifyContent?: "flexStart" | "flexEnd" | "center" | "spaceBetween" | "spaceAround" | (string & {});
60
+ justifySelf?: CSSProperties["justifySelf"];
61
+ alignItems?: "flexStart" | "flexEnd" | "center" | "stretch" | (string & {});
62
+ alignContent?: "flexStart" | "flexEnd" | "center" | "stretch" | (string & {});
63
+ alignSelf?: "flexStart" | "flexEnd" | "center" | "stretch" | (string & {});
64
+ gap?: Dimension | `spacingX.${SpacingX}` | `spacingY.${SpacingY}` | 0 | (string & {});
65
+ }
66
+ interface UseStyleProps extends StyleProps {
67
+ style?: CSSProperties;
68
+ }
69
+ export declare function useStyleProps<T extends UseStyleProps>(props: T): {
70
+ style: CSSProperties;
71
+ restProps: Omit<T, keyof UseStyleProps>;
72
+ };
73
+ export type TextStyle = "screenTitle" | "articleBody" | "articleNote" | "t1Regular" | "t1Medium" | "t1Bold" | "t2Regular" | "t2Medium" | "t2Bold" | "t3Regular" | "t3Medium" | "t3Bold" | "t4Regular" | "t4Medium" | "t4Bold" | "t5Regular" | "t5Medium" | "t5Bold" | "t6Regular" | "t6Medium" | "t6Bold" | "t7Regular" | "t7Medium" | "t7Bold" | "t8Bold" | "t9Bold" | "t10Bold" | "t1StaticRegular" | "t1StaticMedium" | "t1StaticBold" | "t2StaticRegular" | "t2StaticMedium" | "t2StaticBold" | "t3StaticRegular" | "t3StaticMedium" | "t3StaticBold" | "t4StaticRegular" | "t4StaticMedium" | "t4StaticBold" | "t5StaticRegular" | "t5StaticMedium" | "t5StaticBold" | "t6StaticRegular" | "t6StaticMedium" | "t6StaticBold" | "t7StaticRegular" | "t7StaticMedium" | "t7StaticBold" | "t8StaticBold" | "t9StaticBold" | "t10StaticBold";
74
+ export interface TextStyleProps {
75
+ color?: ScopedColorFg | ScopedColorPalette | (string & {});
76
+ fontSize?: FontSize | (string & {});
77
+ lineHeight?: LineHeight | (string & {});
78
+ fontWeight?: FontWeight;
79
+ textStyle?: TextStyle;
80
+ align?: "left" | "center" | "right";
81
+ }
82
+ export {};
83
+ //# sourceMappingURL=styled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../src/utils/styled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EACV,MAAM,EACN,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACT,MAAM,4BAA4B,CAAC;AAKpC,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,OAOpD;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAiB1F;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAC3C,MAAM,GAAG,MAAM,GAAG,SAAS,CAI7B;AAcD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,EAC/B,aAAa,EAAE,MAAM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AAC,CAAC,EAAE,MAAM,aAAa,CAAC,CAAC;CACzC,CA+HA;AAED,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,aAAa,GACb,aAAa,GACb,WAAW,GACX,UAAU,GACV,QAAQ,GACR,WAAW,GACX,UAAU,GACV,QAAQ,GACR,WAAW,GACX,UAAU,GACV,QAAQ,GACR,WAAW,GACX,UAAU,GACV,QAAQ,GACR,WAAW,GACX,UAAU,GACV,QAAQ,GACR,WAAW,GACX,UAAU,GACV,QAAQ,GACR,WAAW,GACX,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,cAAc,GACd,eAAe,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,aAAa,GAAG,kBAAkB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAC3D,QAAQ,CAAC,EAAE,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACpC,UAAU,CAAC,EAAE,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACxC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC"}
@@ -0,0 +1,144 @@
1
+ import { useSafeArea } from "../hooks/useSafeArea.js";
2
+ import { vars } from "@seed-design/lynx-css/vars";
3
+ //#region src/utils/styled.ts
4
+ function handleColor(color) {
5
+ if (!color) return;
6
+ const [type, value] = color.split(".");
7
+ return vars.$color[type]?.[value] ?? color;
8
+ }
9
+ function handleDimension(dimension) {
10
+ if (dimension == null) return;
11
+ if (typeof dimension === "number") return `${dimension}px`;
12
+ if (dimension === "full") return "100%";
13
+ const [type, value] = dimension.split(".");
14
+ return vars.$dimension[dimension] ?? vars.$dimension[type]?.[value] ?? dimension;
15
+ }
16
+ function resolveFlexValue(value) {
17
+ if (value === true) return 1;
18
+ if (value === false) return 0;
19
+ return value;
20
+ }
21
+ function handleBorderWidth(width) {
22
+ if (width == null) return;
23
+ if (typeof width === "number") return `${width}px`;
24
+ return width;
25
+ }
26
+ function handlePaddingWithSafeArea(padding, safeAreaInset) {
27
+ if (padding === "safeArea") return safeAreaInset;
28
+ return handleDimension(padding);
29
+ }
30
+ function handleRadius(radius) {
31
+ if (radius == null) return;
32
+ return vars.$radius[radius] ?? radius;
33
+ }
34
+ function handleDisplay(display) {
35
+ if (!display) return;
36
+ return {
37
+ flex: "flex",
38
+ none: "none"
39
+ }[display] ?? display;
40
+ }
41
+ function handleFlexDirection(flexDirection) {
42
+ if (!flexDirection) return;
43
+ return {
44
+ row: "row",
45
+ column: "column",
46
+ rowReverse: "row-reverse",
47
+ columnReverse: "column-reverse"
48
+ }[flexDirection] ?? flexDirection;
49
+ }
50
+ function handleJustifyContent(justifyContent) {
51
+ if (!justifyContent) return;
52
+ return {
53
+ flexStart: "flex-start",
54
+ flexEnd: "flex-end",
55
+ center: "center",
56
+ spaceBetween: "space-between",
57
+ spaceAround: "space-around"
58
+ }[justifyContent] ?? justifyContent;
59
+ }
60
+ function handleAlignItems(alignItems) {
61
+ if (!alignItems) return;
62
+ return {
63
+ flexStart: "flex-start",
64
+ flexEnd: "flex-end",
65
+ center: "center",
66
+ stretch: "stretch"
67
+ }[alignItems] ?? alignItems;
68
+ }
69
+ function handleFontWeight(fontWeight) {
70
+ if (!fontWeight) return;
71
+ return vars.$fontWeight[fontWeight] ?? fontWeight;
72
+ }
73
+ function handleFontSize(size) {
74
+ if (!size) return;
75
+ return vars.$fontSize[size] ?? size;
76
+ }
77
+ function handleLineHeight(lineHeight) {
78
+ if (!lineHeight) return;
79
+ return vars.$lineHeight[lineHeight] ?? lineHeight;
80
+ }
81
+ function useStyleProps(props) {
82
+ const { background, bg, color, borderColor, borderWidth, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth, borderRadius, borderTopLeftRadius, borderTopRightRadius, borderBottomRightRadius, borderBottomLeftRadius, width, minWidth, maxWidth, height, minHeight, maxHeight, padding, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft, p, px, py, pt, pr, pb, pl, bottom, left, right, top, display, position, overflowX, overflowY, zIndex, flexGrow, flexShrink, flexDirection, flexWrap, justifyContent, justifySelf, alignItems, alignContent, alignSelf, gap, style, ...restProps } = props;
83
+ const { safeAreaInsetTop, safeAreaInsetBottom } = useSafeArea();
84
+ const backgroundValue = handleColor(background ?? bg);
85
+ const paddingValue = handleDimension(padding ?? p);
86
+ const paddingXValue = handleDimension(paddingX ?? px) ?? paddingValue;
87
+ const paddingYValue = handleDimension(paddingY ?? py) ?? paddingValue;
88
+ const paddingTopValue = handlePaddingWithSafeArea(paddingTop ?? pt, safeAreaInsetTop) ?? paddingYValue;
89
+ const paddingRightValue = handleDimension(paddingRight ?? pr) ?? paddingXValue;
90
+ const paddingBottomValue = handlePaddingWithSafeArea(paddingBottom ?? pb, safeAreaInsetBottom) ?? paddingYValue;
91
+ const paddingLeftValue = handleDimension(paddingLeft ?? pl) ?? paddingXValue;
92
+ const hasBorderStyle = borderColor != null || borderWidth != null || borderTopWidth != null || borderRightWidth != null || borderBottomWidth != null || borderLeftWidth != null;
93
+ return {
94
+ style: {
95
+ background: backgroundValue,
96
+ color: handleColor(color),
97
+ borderStyle: hasBorderStyle ? "solid" : void 0,
98
+ borderColor: handleColor(borderColor),
99
+ borderWidth: handleBorderWidth(borderWidth),
100
+ borderTopWidth: handleBorderWidth(borderTopWidth),
101
+ borderRightWidth: handleBorderWidth(borderRightWidth),
102
+ borderBottomWidth: handleBorderWidth(borderBottomWidth),
103
+ borderLeftWidth: handleBorderWidth(borderLeftWidth),
104
+ borderRadius: handleRadius(borderRadius),
105
+ borderTopLeftRadius: handleRadius(borderTopLeftRadius),
106
+ borderTopRightRadius: handleRadius(borderTopRightRadius),
107
+ borderBottomRightRadius: handleRadius(borderBottomRightRadius),
108
+ borderBottomLeftRadius: handleRadius(borderBottomLeftRadius),
109
+ width: handleDimension(width),
110
+ minWidth: handleDimension(minWidth),
111
+ maxWidth: handleDimension(maxWidth),
112
+ height: handleDimension(height),
113
+ minHeight: handleDimension(minHeight),
114
+ maxHeight: handleDimension(maxHeight),
115
+ paddingTop: paddingTopValue,
116
+ paddingRight: paddingRightValue,
117
+ paddingBottom: paddingBottomValue,
118
+ paddingLeft: paddingLeftValue,
119
+ top: handleDimension(top),
120
+ left: handleDimension(left),
121
+ right: handleDimension(right),
122
+ bottom: handleDimension(bottom),
123
+ gap: handleDimension(gap),
124
+ display: handleDisplay(display),
125
+ position,
126
+ overflowX,
127
+ overflowY,
128
+ zIndex,
129
+ flexGrow: resolveFlexValue(flexGrow),
130
+ flexShrink: resolveFlexValue(flexShrink),
131
+ flexDirection: handleFlexDirection(flexDirection),
132
+ flexWrap: flexWrap === true ? "wrap" : flexWrap === false ? "nowrap" : flexWrap,
133
+ justifyContent: handleJustifyContent(justifyContent),
134
+ justifySelf,
135
+ alignItems: handleAlignItems(alignItems),
136
+ alignContent: handleAlignItems(alignContent),
137
+ alignSelf: handleAlignItems(alignSelf),
138
+ ...style
139
+ },
140
+ restProps
141
+ };
142
+ }
143
+ //#endregion
144
+ export { handleColor, handleDimension, handleFontSize, handleFontWeight, handleLineHeight, resolveFlexValue, useStyleProps };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@seed-design/lynx-react",
3
+ "version": "0.1.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/daangn/seed-design.git",
7
+ "directory": "packages/lynx-react"
8
+ },
9
+ "sideEffects": [
10
+ "*.css"
11
+ ],
12
+ "type": "module",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./lib/index.d.ts",
16
+ "import": "./lib/index.js"
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "lib",
22
+ "src"
23
+ ],
24
+ "scripts": {
25
+ "clean": "rm -rf lib",
26
+ "build": "vite build",
27
+ "lint:publish": "bun publint",
28
+ "test": "vitest run",
29
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit"
30
+ },
31
+ "peerDependencies": {
32
+ "@lynx-js/react": ">=0.100.0",
33
+ "@lynx-js/types": ">=3.7.0",
34
+ "@seed-design/lynx-css": "0.0.0 || >=0.1.0 <1.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@lynx-js/react": "^0.116.3",
38
+ "@lynx-js/types": "^3.7.0",
39
+ "@seed-design/lynx-css": "0.1.0",
40
+ "@testing-library/jest-dom": "^6.9.1",
41
+ "jsdom": "^29.0.2",
42
+ "vite": "^8.0.0",
43
+ "vite-plugin-dts": "^4.5.4",
44
+ "vitest": "^3.2.4"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "dependencies": {
50
+ "@lynx-js/lynx-ui-sheet": "^3.130.1",
51
+ "@lynx-js/lynx-ui-common": "^3.130.0",
52
+ "clsx": "^2.1.1"
53
+ }
54
+ }
@@ -0,0 +1,137 @@
1
+ import "@testing-library/jest-dom";
2
+ import { getQueriesForElement, render } from "@lynx-js/react/testing-library";
3
+ import type { MainThread } from "@lynx-js/types";
4
+ import * as React from "@lynx-js/react";
5
+ import { describe, expect, it, vi } from "vitest";
6
+
7
+ import type { LynxIconElementProps } from "../../types";
8
+ import { Icon, PrefixIcon, SuffixIcon } from "../Icon";
9
+ import { ActionButton } from "./ActionButton";
10
+
11
+ vi.mock("@lynx-js/react", async (importOriginal) => {
12
+ const actual = await importOriginal<typeof import("@lynx-js/react")>();
13
+
14
+ return {
15
+ ...actual,
16
+ runOnMainThread: () => () => undefined,
17
+ };
18
+ });
19
+
20
+ function getRenderedQueries() {
21
+ return getQueriesForElement(getRenderedRoot());
22
+ }
23
+
24
+ function getRenderedRoot() {
25
+ const root = elementTree.root;
26
+
27
+ if (!root) {
28
+ throw new Error("Expected Lynx render root to exist.");
29
+ }
30
+
31
+ return root;
32
+ }
33
+
34
+ const MockIcon = React.forwardRef<MainThread.Element, LynxIconElementProps>((props, ref) => {
35
+ const { className, style, ...rest } = props;
36
+
37
+ return (
38
+ <image
39
+ {...rest}
40
+ {...(ref ? { "main-thread:ref": ref as React.Ref<MainThread.Element> } : {})}
41
+ className={className}
42
+ style={style}
43
+ />
44
+ );
45
+ });
46
+ MockIcon.displayName = "MockIcon";
47
+
48
+ describe("ActionButton", () => {
49
+ it("keeps the original label in the text slot while loading", () => {
50
+ render(<ActionButton loading>Submit</ActionButton>);
51
+
52
+ const { getByText } = getRenderedQueries();
53
+ const label = getByText("Submit");
54
+ const root = getRenderedRoot();
55
+
56
+ expect(label).toHaveClass("seed-action-button__text");
57
+ expect(label).toHaveClass("seed-action-button__text--size_medium-layout_withText");
58
+ expect(root.querySelector(".seed-action-button__content")).toBeInTheDocument();
59
+ expect(root.querySelector(".seed-action-button__loadingIndicator")).toBeInTheDocument();
60
+ expect(root.querySelector(".seed-progress-circle__root")).toBeInTheDocument();
61
+ });
62
+
63
+ it("applies action button slot classes to child icon slots", () => {
64
+ render(
65
+ <ActionButton variant="brandSolid">
66
+ <PrefixIcon icon={<MockIcon />} />
67
+ Submit
68
+ <SuffixIcon icon={<MockIcon />} />
69
+ </ActionButton>,
70
+ );
71
+
72
+ const { getByText } = getRenderedQueries();
73
+ const root = getRenderedRoot();
74
+
75
+ expect(root.querySelector(".seed-prefix-icon")).toHaveClass("seed-action-button__prefixIcon");
76
+ expect(root.querySelector(".seed-suffix-icon")).toHaveClass("seed-action-button__suffixIcon");
77
+ expect(root.querySelector(".seed-prefix-icon image")).toHaveStyle({
78
+ width: "100%",
79
+ height: "100%",
80
+ });
81
+ expect(getByText("Submit")).toHaveClass("seed-action-button__text");
82
+ });
83
+
84
+ it("keeps existing icon props compatible with the new slot wrapper", () => {
85
+ render(
86
+ <ActionButton prefixIcon={<MockIcon />} suffixIcon={<MockIcon />}>
87
+ Submit
88
+ </ActionButton>,
89
+ );
90
+
91
+ const root = getRenderedRoot();
92
+
93
+ expect(root.querySelector(".seed-prefix-icon")).toHaveClass("seed-action-button__prefixIcon");
94
+ expect(root.querySelector(".seed-suffix-icon")).toHaveClass("seed-action-button__suffixIcon");
95
+ });
96
+
97
+ it("supports icon-only child slot", () => {
98
+ render(
99
+ <ActionButton layout="iconOnly" aria-label="Add">
100
+ <Icon icon={<MockIcon />} />
101
+ </ActionButton>,
102
+ );
103
+
104
+ const root = getRenderedRoot();
105
+
106
+ expect(root.querySelector(".seed-icon")).toHaveClass("seed-action-button__icon");
107
+ });
108
+
109
+ it("keeps existing icon prop compatible with icon-only validation", () => {
110
+ render(<ActionButton layout="iconOnly" aria-label="Add" icon={<MockIcon />} />);
111
+
112
+ const root = getRenderedRoot();
113
+
114
+ expect(root.querySelector(".seed-icon")).toHaveClass("seed-action-button__icon");
115
+ });
116
+
117
+ it("throws in development when icon-only layout has no Icon child", () => {
118
+ expect(() => {
119
+ render(
120
+ <ActionButton layout="iconOnly" aria-label="Add">
121
+ Add
122
+ </ActionButton>,
123
+ );
124
+ }).toThrow(/must render <Icon \/> as a child/);
125
+ });
126
+
127
+ it("throws in development when icon-only layout has multiple Icon children", () => {
128
+ expect(() => {
129
+ render(
130
+ <ActionButton layout="iconOnly" aria-label="Add">
131
+ <Icon icon={<MockIcon />} />
132
+ <Icon icon={<MockIcon />} />
133
+ </ActionButton>,
134
+ );
135
+ }).toThrow(/must render only one <Icon \/>/);
136
+ });
137
+ });