@seed-design/lynx-react 0.2.0-alpha.3 → 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.
Files changed (179) hide show
  1. package/lib/_virtual/_rolldown/runtime.js +13 -0
  2. package/lib/components/ActionButton/ActionButton.d.ts +26 -33
  3. package/lib/components/ActionButton/ActionButton.d.ts.map +1 -1
  4. package/lib/components/ActionButton/ActionButton.jsx +139 -120
  5. package/lib/components/ActionButton/index.d.ts +1 -1
  6. package/lib/components/AppBar/AppBar.d.ts +35 -0
  7. package/lib/components/AppBar/AppBar.d.ts.map +1 -0
  8. package/lib/components/AppBar/AppBar.jsx +132 -0
  9. package/lib/components/AppBar/AppBar.namespace.d.ts +2 -0
  10. package/lib/components/AppBar/AppBar.namespace.d.ts.map +1 -0
  11. package/lib/components/AppBar/AppBar.namespace.js +15 -0
  12. package/lib/components/AppBar/context.d.ts +13 -0
  13. package/lib/components/AppBar/context.d.ts.map +1 -0
  14. package/lib/components/AppBar/context.js +12 -0
  15. package/lib/components/AppBar/index.d.ts +3 -0
  16. package/lib/components/AppBar/index.d.ts.map +1 -0
  17. package/lib/components/AppBar/useAppBar.d.ts +15 -0
  18. package/lib/components/AppBar/useAppBar.d.ts.map +1 -0
  19. package/lib/components/AppBar/useAppBar.js +72 -0
  20. package/lib/components/Badge/Badge.d.ts +14 -0
  21. package/lib/components/Badge/Badge.d.ts.map +1 -0
  22. package/lib/components/Badge/Badge.jsx +15 -0
  23. package/lib/components/Badge/index.d.ts +2 -0
  24. package/lib/components/Badge/index.d.ts.map +1 -0
  25. package/lib/components/BottomSheet/BottomSheet.d.ts +22 -27
  26. package/lib/components/BottomSheet/BottomSheet.d.ts.map +1 -1
  27. package/lib/components/BottomSheet/BottomSheet.jsx +127 -142
  28. package/lib/components/BottomSheet/BottomSheet.namespace.d.ts +1 -1
  29. package/lib/components/BottomSheet/BottomSheet.namespace.js +18 -1
  30. package/lib/components/BottomSheet/index.d.ts +2 -2
  31. package/lib/components/Box/Box.d.ts +20 -0
  32. package/lib/components/Box/Box.d.ts.map +1 -0
  33. package/lib/components/Box/Box.jsx +14 -0
  34. package/lib/components/Box/index.d.ts +2 -0
  35. package/lib/components/Box/index.d.ts.map +1 -0
  36. package/lib/components/Checkbox/Checkbox.d.ts +14 -31
  37. package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
  38. package/lib/components/Checkbox/Checkbox.jsx +107 -98
  39. package/lib/components/Checkbox/Checkbox.namespace.d.ts +1 -1
  40. package/lib/components/Checkbox/Checkbox.namespace.js +12 -1
  41. package/lib/components/Checkbox/index.d.ts +2 -2
  42. package/lib/components/Icon/Icon.d.ts +37 -0
  43. package/lib/components/Icon/Icon.d.ts.map +1 -0
  44. package/lib/components/Icon/Icon.jsx +143 -0
  45. package/lib/components/Icon/index.d.ts +2 -0
  46. package/lib/components/Icon/index.d.ts.map +1 -0
  47. package/lib/components/ProgressCircle/ProgressCircle.d.ts +4 -8
  48. package/lib/components/ProgressCircle/ProgressCircle.d.ts.map +1 -1
  49. package/lib/components/ProgressCircle/ProgressCircle.jsx +255 -260
  50. package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts +1 -1
  51. package/lib/components/ProgressCircle/ProgressCircle.namespace.js +9 -1
  52. package/lib/components/ProgressCircle/index.d.ts +2 -2
  53. package/lib/components/RadioGroup/RadioGroup.d.ts +12 -29
  54. package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
  55. package/lib/components/RadioGroup/RadioGroup.jsx +134 -118
  56. package/lib/components/RadioGroup/RadioGroup.namespace.d.ts +1 -1
  57. package/lib/components/RadioGroup/RadioGroup.namespace.js +12 -1
  58. package/lib/components/RadioGroup/index.d.ts +2 -2
  59. package/lib/components/Stack/Stack.d.ts +33 -0
  60. package/lib/components/Stack/Stack.d.ts.map +1 -0
  61. package/lib/components/Stack/Stack.jsx +39 -0
  62. package/lib/components/Stack/index.d.ts +2 -0
  63. package/lib/components/Stack/index.d.ts.map +1 -0
  64. package/lib/components/Switch/Switch.d.ts +8 -14
  65. package/lib/components/Switch/Switch.d.ts.map +1 -1
  66. package/lib/components/Switch/Switch.jsx +82 -56
  67. package/lib/components/Switch/Switch.namespace.d.ts +1 -1
  68. package/lib/components/Switch/Switch.namespace.js +11 -1
  69. package/lib/components/Switch/index.d.ts +2 -2
  70. package/lib/components/TagGroup/TagGroup.d.ts +8 -14
  71. package/lib/components/TagGroup/TagGroup.d.ts.map +1 -1
  72. package/lib/components/TagGroup/TagGroup.jsx +42 -39
  73. package/lib/components/TagGroup/TagGroup.namespace.d.ts +1 -1
  74. package/lib/components/TagGroup/TagGroup.namespace.js +10 -1
  75. package/lib/components/TagGroup/index.d.ts +2 -2
  76. package/lib/components/Text/Text.d.ts +7 -0
  77. package/lib/components/Text/Text.d.ts.map +1 -0
  78. package/lib/components/Text/Text.jsx +28 -0
  79. package/lib/components/Text/index.d.ts +2 -0
  80. package/lib/components/Text/index.d.ts.map +1 -0
  81. package/lib/components/index.d.ts +13 -7
  82. package/lib/components/index.d.ts.map +1 -1
  83. package/lib/hooks/index.d.ts +5 -3
  84. package/lib/hooks/index.d.ts.map +1 -1
  85. package/lib/hooks/useControllableState.js +23 -23
  86. package/lib/hooks/useIconColor.d.ts +6 -3
  87. package/lib/hooks/useIconColor.d.ts.map +1 -1
  88. package/lib/hooks/useIconColor.js +34 -37
  89. package/lib/hooks/usePressTap.d.ts +11 -8
  90. package/lib/hooks/usePressTap.d.ts.map +1 -1
  91. package/lib/hooks/usePressTap.js +31 -31
  92. package/lib/hooks/useSafeArea.d.ts +19 -0
  93. package/lib/hooks/useSafeArea.d.ts.map +1 -0
  94. package/lib/hooks/useSafeArea.js +33 -0
  95. package/lib/hooks/useSeedClassName.d.ts +27 -0
  96. package/lib/hooks/useSeedClassName.d.ts.map +1 -0
  97. package/lib/hooks/useSeedClassName.js +32 -0
  98. package/lib/index.d.ts +4 -3
  99. package/lib/index.d.ts.map +1 -1
  100. package/lib/index.js +30 -3
  101. package/lib/types.d.ts +51 -0
  102. package/lib/types.d.ts.map +1 -0
  103. package/lib/utils/children.d.ts +3 -0
  104. package/lib/utils/children.d.ts.map +1 -0
  105. package/lib/utils/children.js +8 -0
  106. package/lib/utils/create-slot-recipe-context.d.ts +13 -12
  107. package/lib/utils/create-slot-recipe-context.d.ts.map +1 -1
  108. package/lib/utils/create-slot-recipe-context.jsx +88 -70
  109. package/lib/utils/get-seed-class-name.d.ts +9 -7
  110. package/lib/utils/get-seed-class-name.d.ts.map +1 -1
  111. package/lib/utils/get-seed-class-name.js +29 -37
  112. package/lib/utils/index.d.ts +4 -4
  113. package/lib/utils/resolve-recipe-token.js +45 -43
  114. package/lib/utils/split-multiple-variants-props.js +32 -32
  115. package/lib/utils/styled.d.ts +83 -0
  116. package/lib/utils/styled.d.ts.map +1 -0
  117. package/lib/utils/styled.js +144 -0
  118. package/package.json +10 -9
  119. package/src/components/ActionButton/ActionButton.test.tsx +167 -0
  120. package/src/components/ActionButton/ActionButton.tsx +210 -169
  121. package/src/components/AppBar/AppBar.namespace.ts +18 -0
  122. package/src/components/AppBar/AppBar.test.tsx +270 -0
  123. package/src/components/AppBar/AppBar.tsx +288 -0
  124. package/src/components/AppBar/context.ts +27 -0
  125. package/src/components/AppBar/index.ts +21 -0
  126. package/src/components/AppBar/useAppBar.ts +100 -0
  127. package/src/components/Badge/Badge.test.tsx +54 -0
  128. package/src/components/Badge/Badge.tsx +32 -0
  129. package/src/components/Badge/index.ts +1 -0
  130. package/src/components/BottomSheet/BottomSheet.test.tsx +219 -0
  131. package/src/components/BottomSheet/BottomSheet.tsx +120 -83
  132. package/src/components/Box/Box.test.tsx +85 -0
  133. package/src/components/Box/Box.tsx +39 -0
  134. package/src/components/Box/index.ts +1 -0
  135. package/src/components/Checkbox/Checkbox.tsx +106 -116
  136. package/src/components/Icon/Icon.tsx +265 -0
  137. package/src/components/Icon/index.ts +8 -0
  138. package/src/components/ProgressCircle/ProgressCircle.tsx +39 -25
  139. package/src/components/RadioGroup/RadioGroup.tsx +98 -117
  140. package/src/components/Stack/Stack.tsx +97 -0
  141. package/src/components/Stack/index.ts +1 -0
  142. package/src/components/Switch/Switch.tsx +59 -50
  143. package/src/components/TagGroup/TagGroup.tsx +27 -25
  144. package/src/components/Text/Text.tsx +64 -0
  145. package/src/components/Text/index.ts +1 -0
  146. package/src/components/index.ts +6 -0
  147. package/src/hooks/index.ts +2 -0
  148. package/src/hooks/{__tests__/useControllableState.test.ts → useControllableState.test.ts} +1 -1
  149. package/src/hooks/{__tests__/useIconColor.test.ts → useIconColor.test.ts} +1 -1
  150. package/src/hooks/useIconColor.ts +22 -12
  151. package/src/hooks/{__tests__/usePressTap.test.ts → usePressTap.test.ts} +1 -1
  152. package/src/hooks/usePressTap.ts +14 -10
  153. package/src/hooks/useSafeArea.test.ts +83 -0
  154. package/src/hooks/useSafeArea.ts +56 -0
  155. package/src/hooks/useSeedClassName.ts +35 -0
  156. package/src/index.ts +1 -0
  157. package/src/types.ts +76 -0
  158. package/src/utils/children.ts +13 -0
  159. package/src/utils/create-slot-recipe-context.test.tsx +96 -0
  160. package/src/utils/create-slot-recipe-context.tsx +55 -15
  161. package/src/utils/get-seed-class-name.ts +10 -12
  162. package/src/utils/{__tests__/split-multiple-variants-props.test.ts → split-multiple-variants-props.test.ts} +1 -1
  163. package/src/utils/styled.ts +442 -0
  164. package/lib/components/ActionButton/index.js +0 -1
  165. package/lib/components/BottomSheet/index.js +0 -2
  166. package/lib/components/Checkbox/index.js +0 -2
  167. package/lib/components/ProgressCircle/index.js +0 -2
  168. package/lib/components/RadioGroup/index.js +0 -2
  169. package/lib/components/Switch/index.js +0 -2
  170. package/lib/components/TagGroup/index.js +0 -2
  171. package/lib/components/index.js +0 -7
  172. package/lib/hooks/index.js +0 -3
  173. package/lib/utils/index.js +0 -4
  174. package/src/components/ActionButton/__tests__/ActionButton.test.tsx +0 -35
  175. package/src/components/BottomSheet/__tests__/BottomSheet.test.tsx +0 -119
  176. package/src/components/__tests__/ProgressCircle.test.ts +0 -33
  177. package/src/components/__tests__/exports.test.ts +0 -38
  178. package/src/components/__tests__/switch.test.ts +0 -34
  179. package/src/utils/__tests__/create-slot-recipe-context.test.tsx +0 -228
@@ -1,34 +1,34 @@
1
+ //#region src/utils/split-multiple-variants-props.ts
1
2
  /**
2
- * Split `props` across multiple recipes' variant extractors in one pass.
3
- *
4
- * Given `recipesMap` of `{ [recipeKey]: recipe }`, returns:
5
- * - A bucket per recipe key with that recipe's variant-only props.
6
- * - `remainingProps` with every recipe variant key stripped out.
7
- *
8
- * Keys that appear in more than one recipe (e.g. shared `size`) are copied
9
- * into each corresponding bucket. `remainingProps` never includes any key
10
- * that any recipe claimed as a variant.
11
- *
12
- * Mirror of `packages/react/src/utils/splitMultipleVariantsProps` adapted
13
- * to TypeScript for Lynx. Use when a single compound component composes two
14
- * or more recipes (e.g. Switch's `switch` + `switchmark`).
15
- */
16
- export function splitMultipleVariantsProps(props, recipesMap) {
17
- const multipleVariantsProps = {};
18
- const extractedKeys = new Set();
19
- const propsRecord = props;
20
- for (const recipeKey in recipesMap) {
21
- const [variantProps] = recipesMap[recipeKey].splitVariantProps(propsRecord);
22
- multipleVariantsProps[recipeKey] = variantProps;
23
- for (const variantPropKey in variantProps) {
24
- extractedKeys.add(variantPropKey);
25
- }
26
- }
27
- const remainingProps = {};
28
- for (const propKey in propsRecord) {
29
- if (extractedKeys.has(propKey))
30
- continue;
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 };
@@ -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,wB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C,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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/lynx-react",
3
- "version": "0.2.0-alpha.3",
3
+ "version": "0.3.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -23,23 +23,24 @@
23
23
  ],
24
24
  "scripts": {
25
25
  "clean": "rm -rf lib",
26
- "build": "tsc",
26
+ "build": "vite build",
27
27
  "lint:publish": "bun publint",
28
28
  "test": "vitest run",
29
- "test:watch": "vitest"
29
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit"
30
30
  },
31
31
  "peerDependencies": {
32
- "@seed-design/css": ">=1.1.17",
33
- "@seed-design/lynx-css": ">=0.1.1-alpha.0 <0.2.0 || >=0.2.0-alpha.0 <1.0.0",
34
- "@lynx-js/react": ">=0.100.0"
32
+ "@lynx-js/react": ">=0.117.0",
33
+ "@lynx-js/types": ">=3.7.0",
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.4.1",
39
40
  "@testing-library/jest-dom": "^6.9.1",
40
- "@types/react": "^19.2.2",
41
41
  "jsdom": "^29.0.2",
42
- "react": "^19.1.0",
42
+ "vite": "^8.0.0",
43
+ "vite-plugin-dts": "^4.5.4",
43
44
  "vitest": "^3.2.4"
44
45
  },
45
46
  "publishConfig": {
@@ -0,0 +1,167 @@
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
+ function getActionButtonRoot() {
35
+ const root = getRenderedRoot();
36
+
37
+ if (root.classList.contains("seed-action-button__root")) {
38
+ return root;
39
+ }
40
+
41
+ const actionButtonRoot = root.querySelector<HTMLElement>(".seed-action-button__root");
42
+
43
+ if (!actionButtonRoot) {
44
+ throw new Error("Expected ActionButton root to exist.");
45
+ }
46
+
47
+ return actionButtonRoot;
48
+ }
49
+
50
+ const MockIcon = React.forwardRef<MainThread.Element, LynxIconElementProps>((props, ref) => {
51
+ const { className, style, ...rest } = props;
52
+
53
+ return (
54
+ <image
55
+ {...rest}
56
+ {...(ref ? { "main-thread:ref": ref as React.Ref<MainThread.Element> } : {})}
57
+ className={className}
58
+ style={style}
59
+ />
60
+ );
61
+ });
62
+ MockIcon.displayName = "MockIcon";
63
+
64
+ describe("ActionButton", () => {
65
+ it("keeps the original label in the text slot while loading", () => {
66
+ render(<ActionButton loading>Submit</ActionButton>);
67
+
68
+ const { getByText } = getRenderedQueries();
69
+ const label = getByText("Submit");
70
+ const root = getRenderedRoot();
71
+
72
+ expect(label).toHaveClass("seed-action-button__text");
73
+ expect(label).toHaveClass("seed-action-button__text--size_medium-layout_withText");
74
+ expect(root.querySelector(".seed-action-button__content")).toBeInTheDocument();
75
+ expect(root.querySelector(".seed-action-button__loadingIndicator")).toBeInTheDocument();
76
+ expect(root.querySelector(".seed-progress-circle__root")).toBeInTheDocument();
77
+ });
78
+
79
+ it("applies action button slot classes to child icon slots", () => {
80
+ render(
81
+ <ActionButton variant="brandSolid">
82
+ <PrefixIcon icon={<MockIcon />} />
83
+ Submit
84
+ <SuffixIcon icon={<MockIcon />} />
85
+ </ActionButton>,
86
+ );
87
+
88
+ const { getByText } = getRenderedQueries();
89
+ const root = getRenderedRoot();
90
+
91
+ expect(root.querySelector(".seed-prefix-icon")).toHaveClass("seed-action-button__prefixIcon");
92
+ expect(root.querySelector(".seed-suffix-icon")).toHaveClass("seed-action-button__suffixIcon");
93
+ expect(root.querySelector(".seed-prefix-icon image")).toHaveStyle({
94
+ width: "100%",
95
+ height: "100%",
96
+ });
97
+ expect(getByText("Submit")).toHaveClass("seed-action-button__text");
98
+ });
99
+
100
+ it("keeps existing icon props compatible with the new slot wrapper", () => {
101
+ render(
102
+ <ActionButton prefixIcon={<MockIcon />} suffixIcon={<MockIcon />}>
103
+ Submit
104
+ </ActionButton>,
105
+ );
106
+
107
+ const root = getRenderedRoot();
108
+
109
+ expect(root.querySelector(".seed-prefix-icon")).toHaveClass("seed-action-button__prefixIcon");
110
+ expect(root.querySelector(".seed-suffix-icon")).toHaveClass("seed-action-button__suffixIcon");
111
+ });
112
+
113
+ it("supports icon-only child slot", () => {
114
+ render(
115
+ <ActionButton layout="iconOnly" accessibility-label="Add">
116
+ <Icon icon={<MockIcon />} />
117
+ </ActionButton>,
118
+ );
119
+
120
+ const root = getRenderedRoot();
121
+
122
+ expect(root.querySelector(".seed-icon")).toHaveClass("seed-action-button__icon");
123
+ });
124
+
125
+ it("maps accessibility props to the root view", () => {
126
+ render(
127
+ <ActionButton layout="iconOnly" accessibility-label="Add">
128
+ <Icon icon={<MockIcon />} />
129
+ </ActionButton>,
130
+ );
131
+
132
+ const root = getActionButtonRoot();
133
+
134
+ expect(root).toHaveAttribute("accessibility-label", "Add");
135
+ expect(root).toHaveAttribute("accessibility-element", "true");
136
+ expect(root).toHaveAttribute("accessibility-traits", "button");
137
+ });
138
+
139
+ it("keeps existing icon prop compatible with icon-only validation", () => {
140
+ render(<ActionButton layout="iconOnly" accessibility-label="Add" icon={<MockIcon />} />);
141
+
142
+ const root = getRenderedRoot();
143
+
144
+ expect(root.querySelector(".seed-icon")).toHaveClass("seed-action-button__icon");
145
+ });
146
+
147
+ it("throws in development when icon-only layout has no Icon child", () => {
148
+ expect(() => {
149
+ render(
150
+ <ActionButton layout="iconOnly" accessibility-label="Add">
151
+ Add
152
+ </ActionButton>,
153
+ );
154
+ }).toThrow(/must render <Icon \/> as a child/);
155
+ });
156
+
157
+ it("throws in development when icon-only layout has multiple Icon children", () => {
158
+ expect(() => {
159
+ render(
160
+ <ActionButton layout="iconOnly" accessibility-label="Add">
161
+ <Icon icon={<MockIcon />} />
162
+ <Icon icon={<MockIcon />} />
163
+ </ActionButton>,
164
+ );
165
+ }).toThrow(/must render only one <Icon \/>/);
166
+ });
167
+ });