@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.
Files changed (186) hide show
  1. package/lib/_virtual/_rolldown/runtime.js +13 -0
  2. package/lib/components/ActionButton/ActionButton.d.ts +26 -32
  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 -30
  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 -28
  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 +4 -3
  84. package/lib/hooks/index.d.ts.map +1 -1
  85. package/lib/hooks/{use-controllable-state.d.ts → useControllableState.d.ts} +1 -1
  86. package/lib/hooks/useControllableState.d.ts.map +1 -0
  87. package/lib/hooks/useControllableState.js +27 -0
  88. package/lib/hooks/useIconColor.d.ts +19 -0
  89. package/lib/hooks/useIconColor.d.ts.map +1 -0
  90. package/lib/hooks/useIconColor.js +38 -0
  91. package/lib/hooks/{use-press-tap.d.ts → usePressTap.d.ts} +12 -9
  92. package/lib/hooks/usePressTap.d.ts.map +1 -0
  93. package/lib/hooks/usePressTap.js +35 -0
  94. package/lib/hooks/useSafeArea.d.ts +19 -0
  95. package/lib/hooks/useSafeArea.d.ts.map +1 -0
  96. package/lib/hooks/useSafeArea.js +33 -0
  97. package/lib/index.d.ts +4 -3
  98. package/lib/index.d.ts.map +1 -1
  99. package/lib/index.js +29 -3
  100. package/lib/types.d.ts +51 -0
  101. package/lib/types.d.ts.map +1 -0
  102. package/lib/utils/children.d.ts +3 -0
  103. package/lib/utils/children.d.ts.map +1 -0
  104. package/lib/utils/children.js +8 -0
  105. package/lib/utils/create-slot-recipe-context.d.ts +13 -12
  106. package/lib/utils/create-slot-recipe-context.d.ts.map +1 -1
  107. package/lib/utils/create-slot-recipe-context.jsx +88 -70
  108. package/lib/utils/get-seed-class-name.d.ts +6 -7
  109. package/lib/utils/get-seed-class-name.d.ts.map +1 -1
  110. package/lib/utils/get-seed-class-name.js +26 -37
  111. package/lib/utils/index.d.ts +4 -4
  112. package/lib/utils/resolve-recipe-token.js +45 -43
  113. package/lib/utils/split-multiple-variants-props.js +32 -32
  114. package/lib/utils/styled.d.ts +83 -0
  115. package/lib/utils/styled.d.ts.map +1 -0
  116. package/lib/utils/styled.js +144 -0
  117. package/package.json +9 -9
  118. package/src/components/ActionButton/ActionButton.test.tsx +167 -0
  119. package/src/components/ActionButton/ActionButton.tsx +210 -168
  120. package/src/components/AppBar/AppBar.namespace.ts +18 -0
  121. package/src/components/AppBar/AppBar.test.tsx +270 -0
  122. package/src/components/AppBar/AppBar.tsx +288 -0
  123. package/src/components/AppBar/context.ts +27 -0
  124. package/src/components/AppBar/index.ts +21 -0
  125. package/src/components/AppBar/useAppBar.ts +100 -0
  126. package/src/components/Badge/Badge.test.tsx +54 -0
  127. package/src/components/Badge/Badge.tsx +32 -0
  128. package/src/components/Badge/index.ts +1 -0
  129. package/src/components/BottomSheet/BottomSheet.test.tsx +219 -0
  130. package/src/components/BottomSheet/BottomSheet.tsx +120 -83
  131. package/src/components/Box/Box.test.tsx +85 -0
  132. package/src/components/Box/Box.tsx +39 -0
  133. package/src/components/Box/index.ts +1 -0
  134. package/src/components/Checkbox/Checkbox.tsx +108 -117
  135. package/src/components/Icon/Icon.tsx +265 -0
  136. package/src/components/Icon/index.ts +8 -0
  137. package/src/components/ProgressCircle/ProgressCircle.tsx +39 -25
  138. package/src/components/RadioGroup/RadioGroup.tsx +100 -118
  139. package/src/components/Stack/Stack.tsx +97 -0
  140. package/src/components/Stack/index.ts +1 -0
  141. package/src/components/Switch/Switch.tsx +61 -52
  142. package/src/components/TagGroup/TagGroup.tsx +27 -25
  143. package/src/components/Text/Text.tsx +64 -0
  144. package/src/components/Text/index.ts +1 -0
  145. package/src/components/index.ts +6 -0
  146. package/src/hooks/index.ts +4 -3
  147. package/src/hooks/{__tests__/use-controllable-state.test.ts → useControllableState.test.ts} +1 -1
  148. package/src/hooks/useIconColor.test.ts +13 -0
  149. package/src/hooks/useIconColor.ts +67 -0
  150. package/src/hooks/{__tests__/use-press-tap.test.ts → usePressTap.test.ts} +1 -1
  151. package/src/hooks/{use-press-tap.ts → usePressTap.ts} +14 -10
  152. package/src/hooks/useSafeArea.test.ts +83 -0
  153. package/src/hooks/useSafeArea.ts +56 -0
  154. package/src/index.ts +1 -0
  155. package/src/types.ts +76 -0
  156. package/src/utils/children.ts +13 -0
  157. package/src/utils/create-slot-recipe-context.test.tsx +96 -0
  158. package/src/utils/create-slot-recipe-context.tsx +55 -15
  159. package/src/utils/get-seed-class-name.ts +7 -12
  160. package/src/utils/{__tests__/split-multiple-variants-props.test.ts → split-multiple-variants-props.test.ts} +1 -1
  161. package/src/utils/styled.ts +442 -0
  162. package/lib/components/ActionButton/index.js +0 -1
  163. package/lib/components/BottomSheet/index.js +0 -2
  164. package/lib/components/Checkbox/index.js +0 -2
  165. package/lib/components/ProgressCircle/index.js +0 -2
  166. package/lib/components/RadioGroup/index.js +0 -2
  167. package/lib/components/Switch/index.js +0 -2
  168. package/lib/components/TagGroup/index.js +0 -2
  169. package/lib/components/index.js +0 -7
  170. package/lib/hooks/index.js +0 -3
  171. package/lib/hooks/use-controllable-state.d.ts.map +0 -1
  172. package/lib/hooks/use-controllable-state.js +0 -27
  173. package/lib/hooks/use-icon-color.d.ts +0 -15
  174. package/lib/hooks/use-icon-color.d.ts.map +0 -1
  175. package/lib/hooks/use-icon-color.js +0 -37
  176. package/lib/hooks/use-press-tap.d.ts.map +0 -1
  177. package/lib/hooks/use-press-tap.js +0 -35
  178. package/lib/utils/index.js +0 -4
  179. package/src/components/ActionButton/__tests__/ActionButton.test.tsx +0 -35
  180. package/src/components/BottomSheet/__tests__/BottomSheet.test.tsx +0 -119
  181. package/src/components/__tests__/ProgressCircle.test.ts +0 -33
  182. package/src/components/__tests__/exports.test.ts +0 -38
  183. package/src/components/__tests__/switch.test.ts +0 -34
  184. package/src/hooks/use-icon-color.ts +0 -51
  185. package/src/utils/__tests__/create-slot-recipe-context.test.tsx +0 -228
  186. /package/src/hooks/{use-controllable-state.ts → useControllableState.ts} +0 -0
@@ -1,286 +1,281 @@
1
- import { createContext, runOnMainThread, useContext, useEffect, useMemo, useMainThreadRef, } from "@lynx-js/react";
2
- import clsx from "clsx";
3
1
  import { progressCircle } from "@seed-design/lynx-css/recipes/progress-circle";
4
- const ProgressCircleContext = createContext(null);
5
- function useProgressCircleCtx() {
6
- const ctx = useContext(ProgressCircleContext);
7
- if (!ctx) {
8
- throw new Error("ProgressCircle compound components must be used within ProgressCircle.Root");
9
- }
10
- return ctx;
2
+ import clsx from "clsx";
3
+ import { createContext, forwardRef, runOnMainThread, useContext, useEffect, useMainThreadRef, useMemo } from "@lynx-js/react";
4
+ //#region src/components/ProgressCircle/ProgressCircle.tsx
5
+ var ProgressCircleContext = createContext(null);
6
+ function useProgressCircleContext() {
7
+ const ctx = useContext(ProgressCircleContext);
8
+ if (!ctx) throw new Error("ProgressCircle compound components must be used within ProgressCircle.Root");
9
+ return ctx;
11
10
  }
12
- // --- Background-thread-only utilities (for initial render) ---
13
11
  function computeRingGeometry(numSize) {
14
- const halfSize = numSize / 2;
15
- const innerR = 0.53 * Math.SQRT2 * halfSize;
16
- const ringCenterR = (halfSize + innerR) / 2;
17
- const capSize = halfSize - innerR;
18
- return { halfSize, innerR, ringCenterR, capSize };
12
+ const halfSize = numSize / 2;
13
+ const innerR = .53 * Math.SQRT2 * halfSize;
14
+ return {
15
+ halfSize,
16
+ innerR,
17
+ ringCenterR: (halfSize + innerR) / 2,
18
+ capSize: halfSize - innerR
19
+ };
19
20
  }
20
21
  function bgPieClipPath(size, angleDeg) {
21
- if (angleDeg >= 360)
22
- return undefined;
23
- if (angleDeg <= 0)
24
- return 'path("M 0 0 Z")';
25
- const c = size / 2;
26
- const r = c + 1;
27
- const rad = (angleDeg * Math.PI) / 180;
28
- const endX = c + r * Math.sin(rad);
29
- const endY = c - r * Math.cos(rad);
30
- const largeArc = angleDeg > 180 ? 1 : 0;
31
- return `path("M ${c} ${c} L ${c} ${c - r} A ${r} ${r} 0 ${largeArc} 1 ${endX} ${endY} Z")`;
22
+ if (angleDeg >= 360) return void 0;
23
+ if (angleDeg <= 0) return "path(\"M 0 0 Z\")";
24
+ const c = size / 2;
25
+ const r = c + 1;
26
+ const rad = angleDeg * Math.PI / 180;
27
+ const endX = c + r * Math.sin(rad);
28
+ const endY = c - r * Math.cos(rad);
29
+ const largeArc = angleDeg > 180 ? 1 : 0;
30
+ return `path("M ${c} ${c} L ${c} ${c - r} A ${r} ${r} 0 ${largeArc} 1 ${endX} ${endY} Z")`;
32
31
  }
33
- // --- Main-thread-only utilities (for animations) ---
34
- // Compiled into the main thread bundle. Must NOT be called from render code.
35
32
  function cubicBezier(rawT, x1, y1, x2, y2) {
36
- "main thread";
37
- const t = Math.max(0, Math.min(1, rawT));
38
- const cx = 3 * x1;
39
- const bx = 3 * (x2 - x1) - cx;
40
- const ax = 1 - cx - bx;
41
- let currentT = t;
42
- for (let i = 0; i < 8; i++) {
43
- const currentX = ((ax * currentT + bx) * currentT + cx) * currentT - t;
44
- const currentDx = (3 * ax * currentT + 2 * bx) * currentT + cx;
45
- if (Math.abs(currentDx) < 1e-6)
46
- break;
47
- currentT = currentT - currentX / currentDx;
48
- }
49
- const cy = 3 * y1;
50
- const by = 3 * (y2 - y1) - cy;
51
- const ay = 1 - cy - by;
52
- return ((ay * currentT + by) * currentT + cy) * currentT;
33
+ "main thread";
34
+ const t = Math.max(0, Math.min(1, rawT));
35
+ const cx = 3 * x1;
36
+ const bx = 3 * (x2 - x1) - cx;
37
+ const ax = 1 - cx - bx;
38
+ let currentT = t;
39
+ for (let i = 0; i < 8; i++) {
40
+ const currentX = ((ax * currentT + bx) * currentT + cx) * currentT - t;
41
+ const currentDx = (3 * ax * currentT + 2 * bx) * currentT + cx;
42
+ if (Math.abs(currentDx) < 1e-6) break;
43
+ currentT = currentT - currentX / currentDx;
44
+ }
45
+ const cy = 3 * y1;
46
+ const by = 3 * (y2 - y1) - cy;
47
+ return (((1 - cy - by) * currentT + by) * currentT + cy) * currentT;
53
48
  }
54
49
  function pieClipPath(size, angleDeg) {
55
- "main thread";
56
- if (angleDeg >= 360)
57
- return undefined;
58
- if (angleDeg <= 0)
59
- return 'path("M 0 0 Z")';
60
- const c = size / 2;
61
- const r = c + 1;
62
- const rad = (angleDeg * Math.PI) / 180;
63
- const endX = c + r * Math.sin(rad);
64
- const endY = c - r * Math.cos(rad);
65
- const largeArc = angleDeg > 180 ? 1 : 0;
66
- return `path("M ${c} ${c} L ${c} ${c - r} A ${r} ${r} 0 ${largeArc} 1 ${endX} ${endY} Z")`;
50
+ "main thread";
51
+ if (angleDeg >= 360) return void 0;
52
+ if (angleDeg <= 0) return "path(\"M 0 0 Z\")";
53
+ const c = size / 2;
54
+ const r = c + 1;
55
+ const rad = angleDeg * Math.PI / 180;
56
+ const endX = c + r * Math.sin(rad);
57
+ const endY = c - r * Math.cos(rad);
58
+ const largeArc = angleDeg > 180 ? 1 : 0;
59
+ return `path("M ${c} ${c} L ${c} ${c - r} A ${r} ${r} 0 ${largeArc} 1 ${endX} ${endY} Z")`;
67
60
  }
68
61
  function sampleIndeterminate(t) {
69
- "main thread";
70
- const containerEased = cubicBezier(t, 0.35, 0.25, 0.65, 0.75);
71
- const headEased = cubicBezier(t, 0.35, 0, 0.65, 1);
72
- const tailEased = cubicBezier(t, 0.35, 0, 0.65, 0.6);
73
- const headLength = headEased <= 0.75 ? (headEased / 0.75) * 360 : 360;
74
- const tailOffset = tailEased <= 1 / 3 ? 0 : ((tailEased - 1 / 3) / (2 / 3)) * 360;
75
- const arcLength = Math.max(0, headLength - tailOffset);
76
- const containerDeg = containerEased * 360 + tailOffset;
77
- return { containerDeg, arcLength };
62
+ "main thread";
63
+ const containerEased = cubicBezier(t, .35, .25, .65, .75);
64
+ const headEased = cubicBezier(t, .35, 0, .65, 1);
65
+ const tailEased = cubicBezier(t, .35, 0, .65, .6);
66
+ const headLength = headEased <= .75 ? headEased / .75 * 360 : 360;
67
+ const tailOffset = tailEased <= 1 / 3 ? 0 : (tailEased - 1 / 3) / (2 / 3) * 360;
68
+ const arcLength = Math.max(0, headLength - tailOffset);
69
+ return {
70
+ containerDeg: containerEased * 360 + tailOffset,
71
+ arcLength
72
+ };
78
73
  }
79
- // --- Animation constants ---
80
- const INDETERMINATE_DURATION = 1200;
81
- const TRANSITION_DURATION = 300;
74
+ var INDETERMINATE_DURATION = 1200;
75
+ var TRANSITION_DURATION = 300;
82
76
  /**
83
- * Lynx에서 SVG를 사용할 수 없어 CSS clip-path 기반 pie sector로 구현.
84
- *
85
- * **Known Issues:**
86
- * - clip-path가 Lynx에서 animatable이 아니라 JS RAF로 매 프레임 SVG path 생성
87
- * - Lynx main thread에서 모듈 레벨 Map 미지원으로 인스턴스 간 RAF 공유 불가
88
- * - 다수 인스턴스 동시 렌더링 시 성능 저하 가능
89
- *
90
- * Lynx SVG + stroke-dasharray 지원 시 CSS-only 애니메이션으로 전환 예정.
91
- */
92
- export const ProgressCircleRoot = (props) => {
93
- const size = props.size ?? "40";
94
- const tone = props.tone ?? "neutral";
95
- const numSize = Number(size);
96
- const isDeterminate = props.minValue !== undefined && props.maxValue !== undefined && props.value !== undefined;
97
- const range = (props.maxValue ?? 1) - (props.minValue ?? 0);
98
- const progress = isDeterminate
99
- ? range === 0
100
- ? 0
101
- : ((props.value ?? 0) - (props.minValue ?? 0)) / range
102
- : 0;
103
- const classes = progressCircle({ tone, size });
104
- const ctx = useMemo(() => ({ tone, numSize, isDeterminate, progress, classes }), [tone, numSize, isDeterminate, progress, classes]);
105
- return (<ProgressCircleContext.Provider value={ctx}>
106
- <view className={clsx(classes.root, props.className)} style={{ width: `${numSize}px`, height: `${numSize}px` }}>
107
- {props.children}
77
+ * Lynx에서 SVG를 사용할 수 없어 CSS clip-path 기반 pie sector로 구현.
78
+ *
79
+ * **Known Issues:**
80
+ * - clip-path가 Lynx에서 animatable이 아니라 JS RAF로 매 프레임 SVG path 생성
81
+ * - Lynx main thread에서 모듈 레벨 Map 미지원으로 인스턴스 간 RAF 공유 불가
82
+ * - 다수 인스턴스 동시 렌더링 시 성능 저하 가능
83
+ *
84
+ * Lynx SVG + stroke-dasharray 지원 시 CSS-only 애니메이션으로 전환 예정.
85
+ */
86
+ var ProgressCircleRoot = forwardRef((props, ref) => {
87
+ const [variantProps, otherProps] = progressCircle.splitVariantProps(props);
88
+ const { children, className, style, minValue, maxValue, value } = otherProps;
89
+ const size = variantProps.size ?? "40";
90
+ const tone = variantProps.tone ?? "neutral";
91
+ const numSize = Number(size);
92
+ const isDeterminate = minValue !== void 0 && maxValue !== void 0 && value !== void 0;
93
+ const range = (maxValue ?? 1) - (minValue ?? 0);
94
+ const progress = isDeterminate ? range === 0 ? 0 : ((value ?? 0) - (minValue ?? 0)) / range : 0;
95
+ const classes = progressCircle({
96
+ tone,
97
+ size
98
+ });
99
+ const ctx = useMemo(() => ({
100
+ numSize,
101
+ isDeterminate,
102
+ progress,
103
+ classes
104
+ }), [
105
+ numSize,
106
+ isDeterminate,
107
+ progress,
108
+ classes
109
+ ]);
110
+ return <ProgressCircleContext.Provider value={ctx}>
111
+ <view {...ref ? { ref } : {}} className={clsx(classes.root, className)} style={{
112
+ ...style,
113
+ width: `${numSize}px`,
114
+ height: `${numSize}px`
115
+ }}>
116
+ {children}
108
117
  </view>
109
- </ProgressCircleContext.Provider>);
110
- };
111
- export const ProgressCircleRange = () => {
112
- const { numSize, isDeterminate, progress, classes } = useProgressCircleCtx();
113
- if (!isDeterminate) {
114
- return <IndeterminateRange numSize={numSize} classes={classes}/>;
115
- }
116
- return <DeterminateRange numSize={numSize} progress={progress} classes={classes}/>;
118
+ </ProgressCircleContext.Provider>;
119
+ });
120
+ var ProgressCircleRange = () => {
121
+ const { numSize, isDeterminate, progress, classes } = useProgressCircleContext();
122
+ if (!isDeterminate) return <IndeterminateRange numSize={numSize} classes={classes} />;
123
+ return <DeterminateRange numSize={numSize} progress={progress} classes={classes} />;
117
124
  };
118
- function DeterminateRange({ numSize, progress, classes, }) {
119
- const rangeRef = useMainThreadRef(null);
120
- const startCapRef = useMainThreadRef(null);
121
- const endCapRef = useMainThreadRef(null);
122
- const prevProgressRef = useMainThreadRef(progress);
123
- const cancelRef = useMainThreadRef(0);
124
- const { halfSize, ringCenterR, capSize } = computeRingGeometry(numSize);
125
- const initialAngle = progress * 360;
126
- const initialClipPath = bgPieClipPath(numSize, initialAngle);
127
- const initialEndRad = (initialAngle * Math.PI) / 180;
128
- function startAnimation(newProgress) {
129
- "main thread";
130
- if (cancelRef.current) {
131
- cancelAnimationFrame(cancelRef.current);
132
- cancelRef.current = 0;
133
- }
134
- const from = prevProgressRef.current ?? 0;
135
- prevProgressRef.current = newProgress;
136
- if (from === newProgress)
137
- return;
138
- const rangeEl = rangeRef.current;
139
- const endCapEl = endCapRef.current;
140
- let startTs = 0;
141
- function applyProgress(p) {
142
- const angleDeg = p * 360;
143
- const cp = pieClipPath(numSize, angleDeg);
144
- if (cp) {
145
- rangeEl?.setStyleProperty("clip-path", cp);
146
- }
147
- else {
148
- rangeEl?.setStyleProperty("clip-path", "none");
149
- }
150
- const rad = (angleDeg * Math.PI) / 180;
151
- endCapEl?.setStyleProperties({
152
- left: `${halfSize + ringCenterR * Math.sin(rad) - capSize / 2}px`,
153
- top: `${halfSize - ringCenterR * Math.cos(rad) - capSize / 2}px`,
154
- });
155
- }
156
- function step(ts) {
157
- if (!startTs)
158
- startTs = Number(ts);
159
- const elapsed = ts - startTs;
160
- if (elapsed >= TRANSITION_DURATION) {
161
- applyProgress(newProgress);
162
- cancelRef.current = 0;
163
- return;
164
- }
165
- const t = elapsed / TRANSITION_DURATION;
166
- const eased = cubicBezier(t, 0, 0, 0.15, 1);
167
- applyProgress(from + (newProgress - from) * eased);
168
- cancelRef.current = requestAnimationFrame(step);
169
- }
170
- applyProgress(from);
171
- cancelRef.current = requestAnimationFrame(step);
172
- }
173
- function cancelAnimation() {
174
- "main thread";
175
- if (cancelRef.current) {
176
- cancelAnimationFrame(cancelRef.current);
177
- cancelRef.current = 0;
178
- }
179
- }
180
- useEffect(() => {
181
- runOnMainThread(startAnimation)(progress);
182
- return () => {
183
- runOnMainThread(cancelAnimation)();
184
- };
185
- }, [progress, numSize]);
186
- return (<>
125
+ function DeterminateRange({ numSize, progress, classes }) {
126
+ const rangeRef = useMainThreadRef(null);
127
+ const startCapRef = useMainThreadRef(null);
128
+ const endCapRef = useMainThreadRef(null);
129
+ const prevProgressRef = useMainThreadRef(progress);
130
+ const cancelRef = useMainThreadRef(0);
131
+ const { halfSize, ringCenterR, capSize } = computeRingGeometry(numSize);
132
+ const initialAngle = progress * 360;
133
+ const initialClipPath = bgPieClipPath(numSize, initialAngle);
134
+ const initialEndRad = initialAngle * Math.PI / 180;
135
+ function startAnimation(newProgress) {
136
+ "main thread";
137
+ if (cancelRef.current) {
138
+ cancelAnimationFrame(cancelRef.current);
139
+ cancelRef.current = 0;
140
+ }
141
+ const from = prevProgressRef.current ?? 0;
142
+ prevProgressRef.current = newProgress;
143
+ if (from === newProgress) return;
144
+ const rangeEl = rangeRef.current;
145
+ const endCapEl = endCapRef.current;
146
+ let startTs = 0;
147
+ function applyProgress(p) {
148
+ const angleDeg = p * 360;
149
+ const cp = pieClipPath(numSize, angleDeg);
150
+ if (cp) rangeEl?.setStyleProperty("clip-path", cp);
151
+ else rangeEl?.setStyleProperty("clip-path", "none");
152
+ const rad = angleDeg * Math.PI / 180;
153
+ endCapEl?.setStyleProperties({
154
+ left: `${halfSize + ringCenterR * Math.sin(rad) - capSize / 2}px`,
155
+ top: `${halfSize - ringCenterR * Math.cos(rad) - capSize / 2}px`
156
+ });
157
+ }
158
+ function step(ts) {
159
+ if (!startTs) startTs = Number(ts);
160
+ const elapsed = ts - startTs;
161
+ if (elapsed >= TRANSITION_DURATION) {
162
+ applyProgress(newProgress);
163
+ cancelRef.current = 0;
164
+ return;
165
+ }
166
+ const eased = cubicBezier(elapsed / TRANSITION_DURATION, 0, 0, .15, 1);
167
+ applyProgress(from + (newProgress - from) * eased);
168
+ cancelRef.current = requestAnimationFrame(step);
169
+ }
170
+ applyProgress(from);
171
+ cancelRef.current = requestAnimationFrame(step);
172
+ }
173
+ function cancelAnimation() {
174
+ "main thread";
175
+ if (cancelRef.current) {
176
+ cancelAnimationFrame(cancelRef.current);
177
+ cancelRef.current = 0;
178
+ }
179
+ }
180
+ useEffect(() => {
181
+ runOnMainThread(startAnimation)(progress);
182
+ return () => {
183
+ runOnMainThread(cancelAnimation)();
184
+ };
185
+ }, [progress, numSize]);
186
+ return <>
187
187
  <view main-thread:ref={rangeRef} className={classes.range} style={{
188
- position: "absolute",
189
- width: `${numSize}px`,
190
- height: `${numSize}px`,
191
- borderRadius: "50%",
192
- clipPath: initialClipPath,
193
- }}/>
188
+ position: "absolute",
189
+ width: `${numSize}px`,
190
+ height: `${numSize}px`,
191
+ borderRadius: "50%",
192
+ clipPath: initialClipPath
193
+ }} />
194
194
  <view main-thread:ref={startCapRef} className={classes.cap} style={{
195
- width: `${capSize}px`,
196
- height: `${capSize}px`,
197
- left: `${halfSize - capSize / 2}px`,
198
- top: `${halfSize - ringCenterR - capSize / 2}px`,
199
- }}/>
195
+ width: `${capSize}px`,
196
+ height: `${capSize}px`,
197
+ left: `${halfSize - capSize / 2}px`,
198
+ top: `${halfSize - ringCenterR - capSize / 2}px`
199
+ }} />
200
200
  <view main-thread:ref={endCapRef} className={classes.cap} style={{
201
- width: `${capSize}px`,
202
- height: `${capSize}px`,
203
- left: `${halfSize + ringCenterR * Math.sin(initialEndRad) - capSize / 2}px`,
204
- top: `${halfSize - ringCenterR * Math.cos(initialEndRad) - capSize / 2}px`,
205
- }}/>
206
- </>);
201
+ width: `${capSize}px`,
202
+ height: `${capSize}px`,
203
+ left: `${halfSize + ringCenterR * Math.sin(initialEndRad) - capSize / 2}px`,
204
+ top: `${halfSize - ringCenterR * Math.cos(initialEndRad) - capSize / 2}px`
205
+ }} />
206
+ </>;
207
207
  }
208
208
  function IndeterminateRange({ numSize, classes }) {
209
- const containerRef = useMainThreadRef(null);
210
- const rangeRef = useMainThreadRef(null);
211
- const headCapRef = useMainThreadRef(null);
212
- const tailCapRef = useMainThreadRef(null);
213
- const rafIdRef = useMainThreadRef(0);
214
- const { halfSize, ringCenterR, capSize } = computeRingGeometry(numSize);
215
- function startLoop() {
216
- "main thread";
217
- const containerEl = containerRef.current;
218
- const rangeEl = rangeRef.current;
219
- const headCapEl = headCapRef.current;
220
- let startTs = 0;
221
- function tick(ts) {
222
- if (!startTs)
223
- startTs = Number(ts);
224
- const elapsed = ts - startTs;
225
- const t = (elapsed % INDETERMINATE_DURATION) / INDETERMINATE_DURATION;
226
- const state = sampleIndeterminate(t);
227
- containerEl?.setStyleProperty("transform", `rotate(${state.containerDeg}deg)`);
228
- const clipPath = pieClipPath(numSize, state.arcLength);
229
- if (clipPath) {
230
- rangeEl?.setStyleProperty("clip-path", clipPath);
231
- }
232
- else {
233
- rangeEl?.setStyleProperty("clip-path", "none");
234
- }
235
- const headRad = (state.arcLength * Math.PI) / 180;
236
- headCapEl?.setStyleProperties({
237
- left: `${halfSize + ringCenterR * Math.sin(headRad) - capSize / 2}px`,
238
- top: `${halfSize - ringCenterR * Math.cos(headRad) - capSize / 2}px`,
239
- });
240
- rafIdRef.current = requestAnimationFrame(tick);
241
- }
242
- rafIdRef.current = requestAnimationFrame(tick);
243
- }
244
- function stopLoop() {
245
- "main thread";
246
- if (rafIdRef.current) {
247
- cancelAnimationFrame(rafIdRef.current);
248
- rafIdRef.current = 0;
249
- }
250
- }
251
- useEffect(() => {
252
- runOnMainThread(startLoop)();
253
- return () => {
254
- runOnMainThread(stopLoop)();
255
- };
256
- }, [numSize]);
257
- const initialClipPath = 'path("M 0 0 Z")';
258
- return (<view main-thread:ref={containerRef} style={{
259
- position: "absolute",
260
- width: `${numSize}px`,
261
- height: `${numSize}px`,
262
- transform: "rotate(0deg)",
263
- }}>
209
+ const containerRef = useMainThreadRef(null);
210
+ const rangeRef = useMainThreadRef(null);
211
+ const headCapRef = useMainThreadRef(null);
212
+ const tailCapRef = useMainThreadRef(null);
213
+ const rafIdRef = useMainThreadRef(0);
214
+ const { halfSize, ringCenterR, capSize } = computeRingGeometry(numSize);
215
+ function startLoop() {
216
+ "main thread";
217
+ const containerEl = containerRef.current;
218
+ const rangeEl = rangeRef.current;
219
+ const headCapEl = headCapRef.current;
220
+ let startTs = 0;
221
+ function tick(ts) {
222
+ if (!startTs) startTs = Number(ts);
223
+ const state = sampleIndeterminate((ts - startTs) % INDETERMINATE_DURATION / INDETERMINATE_DURATION);
224
+ containerEl?.setStyleProperty("transform", `rotate(${state.containerDeg}deg)`);
225
+ const clipPath = pieClipPath(numSize, state.arcLength);
226
+ if (clipPath) rangeEl?.setStyleProperty("clip-path", clipPath);
227
+ else rangeEl?.setStyleProperty("clip-path", "none");
228
+ const headRad = state.arcLength * Math.PI / 180;
229
+ headCapEl?.setStyleProperties({
230
+ left: `${halfSize + ringCenterR * Math.sin(headRad) - capSize / 2}px`,
231
+ top: `${halfSize - ringCenterR * Math.cos(headRad) - capSize / 2}px`
232
+ });
233
+ rafIdRef.current = requestAnimationFrame(tick);
234
+ }
235
+ rafIdRef.current = requestAnimationFrame(tick);
236
+ }
237
+ function stopLoop() {
238
+ "main thread";
239
+ if (rafIdRef.current) {
240
+ cancelAnimationFrame(rafIdRef.current);
241
+ rafIdRef.current = 0;
242
+ }
243
+ }
244
+ useEffect(() => {
245
+ runOnMainThread(startLoop)();
246
+ return () => {
247
+ runOnMainThread(stopLoop)();
248
+ };
249
+ }, [numSize]);
250
+ const initialClipPath = "path(\"M 0 0 Z\")";
251
+ return <view main-thread:ref={containerRef} style={{
252
+ position: "absolute",
253
+ width: `${numSize}px`,
254
+ height: `${numSize}px`,
255
+ transform: "rotate(0deg)"
256
+ }}>
264
257
  <view main-thread:ref={rangeRef} className={classes.range} style={{
265
- position: "absolute",
266
- width: `${numSize}px`,
267
- height: `${numSize}px`,
268
- borderRadius: "50%",
269
- clipPath: initialClipPath,
270
- }}/>
258
+ position: "absolute",
259
+ width: `${numSize}px`,
260
+ height: `${numSize}px`,
261
+ borderRadius: "50%",
262
+ clipPath: initialClipPath
263
+ }} />
271
264
  <view main-thread:ref={tailCapRef} className={classes.cap} style={{
272
- width: `${capSize}px`,
273
- height: `${capSize}px`,
274
- left: `${halfSize - capSize / 2}px`,
275
- top: `${halfSize - ringCenterR - capSize / 2}px`,
276
- }}/>
265
+ width: `${capSize}px`,
266
+ height: `${capSize}px`,
267
+ left: `${halfSize - capSize / 2}px`,
268
+ top: `${halfSize - ringCenterR - capSize / 2}px`
269
+ }} />
277
270
  <view main-thread:ref={headCapRef} className={classes.cap} style={{
278
- width: `${capSize}px`,
279
- height: `${capSize}px`,
280
- left: `${halfSize - capSize / 2}px`,
281
- top: `${halfSize - ringCenterR - capSize / 2}px`,
282
- }}/>
283
- </view>);
271
+ width: `${capSize}px`,
272
+ height: `${capSize}px`,
273
+ left: `${halfSize - capSize / 2}px`,
274
+ top: `${halfSize - ringCenterR - capSize / 2}px`
275
+ }} />
276
+ </view>;
284
277
  }
285
278
  ProgressCircleRoot.displayName = "ProgressCircleRoot";
286
279
  ProgressCircleRange.displayName = "ProgressCircleRange";
280
+ //#endregion
281
+ export { ProgressCircleRange, ProgressCircleRoot };
@@ -1,2 +1,2 @@
1
- export { ProgressCircleRange as Range, ProgressCircleRoot as Root, type ProgressCircleRootProps as RootProps, } from "./ProgressCircle";
1
+ export { ProgressCircleRange as Range, ProgressCircleRoot as Root, type ProgressCircleRootProps as RootProps, } from './ProgressCircle';
2
2
  //# sourceMappingURL=ProgressCircle.namespace.d.ts.map
@@ -1 +1,9 @@
1
- export { ProgressCircleRange as Range, ProgressCircleRoot as Root, } from "./ProgressCircle";
1
+ import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
2
+ import { ProgressCircleRange, ProgressCircleRoot } from "./ProgressCircle.jsx";
3
+ //#region src/components/ProgressCircle/ProgressCircle.namespace.ts
4
+ var ProgressCircle_namespace_exports = /* @__PURE__ */ __exportAll({
5
+ Range: () => ProgressCircleRange,
6
+ Root: () => ProgressCircleRoot
7
+ });
8
+ //#endregion
9
+ export { ProgressCircle_namespace_exports };
@@ -1,3 +1,3 @@
1
- export { ProgressCircleRange, ProgressCircleRoot, type ProgressCircleRootProps, type ProgressCircleRootProps as ProgressCircleProps, type RootProps, } from "./ProgressCircle";
2
- export * as ProgressCircle from "./ProgressCircle.namespace";
1
+ export { ProgressCircleRange, ProgressCircleRoot, type ProgressCircleRootProps, type ProgressCircleRootProps as ProgressCircleProps, type RootProps, } from './ProgressCircle';
2
+ export * as ProgressCircle from './ProgressCircle.namespace';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,50 +1,34 @@
1
- import * as React from "react";
2
- import { type CSSProperties, type ReactElement } from "react";
3
- import type { MainThread } from "@lynx-js/types";
4
- import type { RadioVariantProps } from "@seed-design/lynx-css/recipes/radio";
5
- import type { RadiomarkVariantProps } from "@seed-design/lynx-css/recipes/radiomark";
6
- export interface RadioGroupRootProps extends RadioVariantProps, Omit<RadiomarkVariantProps, "size" | "checked" | "disabled"> {
7
- children?: React.ReactNode;
8
- className?: string;
1
+ import { ReactElement } from '@lynx-js/react';
2
+ import { RadioVariantProps } from '@seed-design/lynx-css/recipes/radio';
3
+ import { RadiomarkVariantProps } from '@seed-design/lynx-css/recipes/radiomark';
4
+ import { LynxIconElementProps, LynxStyledElementProps } from '../../types';
5
+ import * as React from "@lynx-js/react";
6
+ export interface RadioGroupRootProps extends RadioVariantProps, Omit<RadiomarkVariantProps, "size" | "checked" | "disabled">, LynxStyledElementProps {
9
7
  value?: string;
10
8
  defaultValue?: string;
11
9
  disabled?: boolean;
12
10
  onValueChange?: (value: string) => void;
13
11
  }
14
12
  export declare const RadioGroupRoot: React.ForwardRefExoticComponent<RadioGroupRootProps & React.RefAttributes<unknown>>;
15
- export interface RadioGroupItemProps {
13
+ export interface RadioGroupItemProps extends LynxStyledElementProps {
16
14
  value: string;
17
- children?: React.ReactNode;
18
- className?: string;
19
15
  disabled?: boolean;
20
16
  }
21
17
  export declare const RadioGroupItem: React.ForwardRefExoticComponent<RadioGroupItemProps & React.RefAttributes<unknown>>;
22
- export interface RadioGroupItemControlProps extends Pick<RadiomarkVariantProps, "tone"> {
23
- children?: React.ReactNode;
24
- className?: string;
18
+ export interface RadioGroupItemControlProps extends Pick<RadiomarkVariantProps, "tone">, LynxStyledElementProps {
25
19
  }
26
20
  export declare const RadioGroupItemControl: React.ForwardRefExoticComponent<RadioGroupItemControlProps & React.RefAttributes<unknown>>;
27
- type IconElementProps = {
28
- className?: string;
29
- style?: CSSProperties;
30
- ref?: React.Ref<MainThread.Element>;
31
- };
32
- export interface RadioGroupItemIndicatorProps {
21
+ export interface RadioGroupItemIndicatorProps extends Pick<LynxStyledElementProps, "className" | "style"> {
33
22
  /** Icon rendered when not checked. Optional — falls back to default `<view>` dot when omitted. */
34
- unchecked?: ReactElement<IconElementProps>;
23
+ unchecked?: ReactElement<LynxIconElementProps>;
35
24
  /** Icon rendered when the item is checked. Optional — falls back to default `<view>` dot when omitted. */
36
- checked?: ReactElement<IconElementProps>;
37
- className?: string;
38
- style?: CSSProperties;
25
+ checked?: ReactElement<LynxIconElementProps>;
39
26
  }
40
27
  export declare function RadioGroupItemIndicator(props: RadioGroupItemIndicatorProps): React.JSX.Element;
41
28
  export declare namespace RadioGroupItemIndicator {
42
29
  var displayName: string;
43
30
  }
44
- export interface RadioGroupItemLabelProps {
45
- children?: React.ReactNode;
46
- className?: string;
31
+ export interface RadioGroupItemLabelProps extends LynxStyledElementProps {
47
32
  }
48
33
  export declare const RadioGroupItemLabel: React.ForwardRefExoticComponent<RadioGroupItemLabelProps & React.RefAttributes<unknown>>;
49
- export {};
50
34
  //# sourceMappingURL=RadioGroup.d.ts.map