@seed-design/lynx-react 0.2.0-alpha.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_virtual/_rolldown/runtime.js +13 -0
- package/lib/components/ActionButton/ActionButton.d.ts +26 -32
- package/lib/components/ActionButton/ActionButton.d.ts.map +1 -1
- package/lib/components/ActionButton/ActionButton.jsx +139 -120
- package/lib/components/ActionButton/index.d.ts +1 -1
- package/lib/components/AppBar/AppBar.d.ts +35 -0
- package/lib/components/AppBar/AppBar.d.ts.map +1 -0
- package/lib/components/AppBar/AppBar.jsx +132 -0
- package/lib/components/AppBar/AppBar.namespace.d.ts +2 -0
- package/lib/components/AppBar/AppBar.namespace.d.ts.map +1 -0
- package/lib/components/AppBar/AppBar.namespace.js +15 -0
- package/lib/components/AppBar/context.d.ts +13 -0
- package/lib/components/AppBar/context.d.ts.map +1 -0
- package/lib/components/AppBar/context.js +12 -0
- package/lib/components/AppBar/index.d.ts +3 -0
- package/lib/components/AppBar/index.d.ts.map +1 -0
- package/lib/components/AppBar/useAppBar.d.ts +15 -0
- package/lib/components/AppBar/useAppBar.d.ts.map +1 -0
- package/lib/components/AppBar/useAppBar.js +72 -0
- package/lib/components/Badge/Badge.d.ts +14 -0
- package/lib/components/Badge/Badge.d.ts.map +1 -0
- package/lib/components/Badge/Badge.jsx +15 -0
- package/lib/components/Badge/index.d.ts +2 -0
- package/lib/components/Badge/index.d.ts.map +1 -0
- package/lib/components/BottomSheet/BottomSheet.d.ts +22 -27
- package/lib/components/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/lib/components/BottomSheet/BottomSheet.jsx +127 -142
- package/lib/components/BottomSheet/BottomSheet.namespace.d.ts +1 -1
- package/lib/components/BottomSheet/BottomSheet.namespace.js +18 -1
- package/lib/components/BottomSheet/index.d.ts +2 -2
- package/lib/components/Box/Box.d.ts +20 -0
- package/lib/components/Box/Box.d.ts.map +1 -0
- package/lib/components/Box/Box.jsx +14 -0
- package/lib/components/Box/index.d.ts +2 -0
- package/lib/components/Box/index.d.ts.map +1 -0
- package/lib/components/Checkbox/Checkbox.d.ts +14 -30
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/components/Checkbox/Checkbox.jsx +107 -98
- package/lib/components/Checkbox/Checkbox.namespace.d.ts +1 -1
- package/lib/components/Checkbox/Checkbox.namespace.js +12 -1
- package/lib/components/Checkbox/index.d.ts +2 -2
- package/lib/components/Icon/Icon.d.ts +37 -0
- package/lib/components/Icon/Icon.d.ts.map +1 -0
- package/lib/components/Icon/Icon.jsx +143 -0
- package/lib/components/Icon/index.d.ts +2 -0
- package/lib/components/Icon/index.d.ts.map +1 -0
- package/lib/components/ProgressCircle/ProgressCircle.d.ts +4 -8
- package/lib/components/ProgressCircle/ProgressCircle.d.ts.map +1 -1
- package/lib/components/ProgressCircle/ProgressCircle.jsx +255 -260
- package/lib/components/ProgressCircle/ProgressCircle.namespace.d.ts +1 -1
- package/lib/components/ProgressCircle/ProgressCircle.namespace.js +9 -1
- package/lib/components/ProgressCircle/index.d.ts +2 -2
- package/lib/components/RadioGroup/RadioGroup.d.ts +12 -28
- package/lib/components/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/lib/components/RadioGroup/RadioGroup.jsx +134 -118
- package/lib/components/RadioGroup/RadioGroup.namespace.d.ts +1 -1
- package/lib/components/RadioGroup/RadioGroup.namespace.js +12 -1
- package/lib/components/RadioGroup/index.d.ts +2 -2
- package/lib/components/Stack/Stack.d.ts +33 -0
- package/lib/components/Stack/Stack.d.ts.map +1 -0
- package/lib/components/Stack/Stack.jsx +39 -0
- package/lib/components/Stack/index.d.ts +2 -0
- package/lib/components/Stack/index.d.ts.map +1 -0
- package/lib/components/Switch/Switch.d.ts +8 -14
- package/lib/components/Switch/Switch.d.ts.map +1 -1
- package/lib/components/Switch/Switch.jsx +82 -56
- package/lib/components/Switch/Switch.namespace.d.ts +1 -1
- package/lib/components/Switch/Switch.namespace.js +11 -1
- package/lib/components/Switch/index.d.ts +2 -2
- package/lib/components/TagGroup/TagGroup.d.ts +8 -14
- package/lib/components/TagGroup/TagGroup.d.ts.map +1 -1
- package/lib/components/TagGroup/TagGroup.jsx +42 -39
- package/lib/components/TagGroup/TagGroup.namespace.d.ts +1 -1
- package/lib/components/TagGroup/TagGroup.namespace.js +10 -1
- package/lib/components/TagGroup/index.d.ts +2 -2
- package/lib/components/Text/Text.d.ts +7 -0
- package/lib/components/Text/Text.d.ts.map +1 -0
- package/lib/components/Text/Text.jsx +28 -0
- package/lib/components/Text/index.d.ts +2 -0
- package/lib/components/Text/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +13 -7
- package/lib/components/index.d.ts.map +1 -1
- package/lib/hooks/index.d.ts +4 -3
- package/lib/hooks/index.d.ts.map +1 -1
- package/lib/hooks/{use-controllable-state.d.ts → useControllableState.d.ts} +1 -1
- package/lib/hooks/useControllableState.d.ts.map +1 -0
- package/lib/hooks/useControllableState.js +27 -0
- package/lib/hooks/useIconColor.d.ts +19 -0
- package/lib/hooks/useIconColor.d.ts.map +1 -0
- package/lib/hooks/useIconColor.js +38 -0
- package/lib/hooks/{use-press-tap.d.ts → usePressTap.d.ts} +12 -9
- package/lib/hooks/usePressTap.d.ts.map +1 -0
- package/lib/hooks/usePressTap.js +35 -0
- package/lib/hooks/useSafeArea.d.ts +19 -0
- package/lib/hooks/useSafeArea.d.ts.map +1 -0
- package/lib/hooks/useSafeArea.js +33 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +29 -3
- package/lib/types.d.ts +51 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/utils/children.d.ts +3 -0
- package/lib/utils/children.d.ts.map +1 -0
- package/lib/utils/children.js +8 -0
- package/lib/utils/create-slot-recipe-context.d.ts +13 -12
- package/lib/utils/create-slot-recipe-context.d.ts.map +1 -1
- package/lib/utils/create-slot-recipe-context.jsx +88 -70
- package/lib/utils/get-seed-class-name.d.ts +6 -7
- package/lib/utils/get-seed-class-name.d.ts.map +1 -1
- package/lib/utils/get-seed-class-name.js +26 -37
- package/lib/utils/index.d.ts +4 -4
- package/lib/utils/resolve-recipe-token.js +45 -43
- package/lib/utils/split-multiple-variants-props.js +32 -32
- package/lib/utils/styled.d.ts +83 -0
- package/lib/utils/styled.d.ts.map +1 -0
- package/lib/utils/styled.js +144 -0
- package/package.json +9 -9
- package/src/components/ActionButton/ActionButton.test.tsx +167 -0
- package/src/components/ActionButton/ActionButton.tsx +210 -168
- package/src/components/AppBar/AppBar.namespace.ts +18 -0
- package/src/components/AppBar/AppBar.test.tsx +270 -0
- package/src/components/AppBar/AppBar.tsx +288 -0
- package/src/components/AppBar/context.ts +27 -0
- package/src/components/AppBar/index.ts +21 -0
- package/src/components/AppBar/useAppBar.ts +100 -0
- package/src/components/Badge/Badge.test.tsx +54 -0
- package/src/components/Badge/Badge.tsx +32 -0
- package/src/components/Badge/index.ts +1 -0
- package/src/components/BottomSheet/BottomSheet.test.tsx +219 -0
- package/src/components/BottomSheet/BottomSheet.tsx +120 -83
- package/src/components/Box/Box.test.tsx +85 -0
- package/src/components/Box/Box.tsx +39 -0
- package/src/components/Box/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.tsx +108 -117
- package/src/components/Icon/Icon.tsx +265 -0
- package/src/components/Icon/index.ts +8 -0
- package/src/components/ProgressCircle/ProgressCircle.tsx +39 -25
- package/src/components/RadioGroup/RadioGroup.tsx +100 -118
- package/src/components/Stack/Stack.tsx +97 -0
- package/src/components/Stack/index.ts +1 -0
- package/src/components/Switch/Switch.tsx +61 -52
- package/src/components/TagGroup/TagGroup.tsx +27 -25
- package/src/components/Text/Text.tsx +64 -0
- package/src/components/Text/index.ts +1 -0
- package/src/components/index.ts +6 -0
- package/src/hooks/index.ts +4 -3
- package/src/hooks/{__tests__/use-controllable-state.test.ts → useControllableState.test.ts} +1 -1
- package/src/hooks/useIconColor.test.ts +13 -0
- package/src/hooks/useIconColor.ts +67 -0
- package/src/hooks/{__tests__/use-press-tap.test.ts → usePressTap.test.ts} +1 -1
- package/src/hooks/{use-press-tap.ts → usePressTap.ts} +14 -10
- package/src/hooks/useSafeArea.test.ts +83 -0
- package/src/hooks/useSafeArea.ts +56 -0
- package/src/index.ts +1 -0
- package/src/types.ts +76 -0
- package/src/utils/children.ts +13 -0
- package/src/utils/create-slot-recipe-context.test.tsx +96 -0
- package/src/utils/create-slot-recipe-context.tsx +55 -15
- package/src/utils/get-seed-class-name.ts +7 -12
- package/src/utils/{__tests__/split-multiple-variants-props.test.ts → split-multiple-variants-props.test.ts} +1 -1
- package/src/utils/styled.ts +442 -0
- package/lib/components/ActionButton/index.js +0 -1
- package/lib/components/BottomSheet/index.js +0 -2
- package/lib/components/Checkbox/index.js +0 -2
- package/lib/components/ProgressCircle/index.js +0 -2
- package/lib/components/RadioGroup/index.js +0 -2
- package/lib/components/Switch/index.js +0 -2
- package/lib/components/TagGroup/index.js +0 -2
- package/lib/components/index.js +0 -7
- package/lib/hooks/index.js +0 -3
- package/lib/hooks/use-controllable-state.d.ts.map +0 -1
- package/lib/hooks/use-controllable-state.js +0 -27
- package/lib/hooks/use-icon-color.d.ts +0 -15
- package/lib/hooks/use-icon-color.d.ts.map +0 -1
- package/lib/hooks/use-icon-color.js +0 -37
- package/lib/hooks/use-press-tap.d.ts.map +0 -1
- package/lib/hooks/use-press-tap.js +0 -35
- package/lib/utils/index.js +0 -4
- package/src/components/ActionButton/__tests__/ActionButton.test.tsx +0 -35
- package/src/components/BottomSheet/__tests__/BottomSheet.test.tsx +0 -119
- package/src/components/__tests__/ProgressCircle.test.ts +0 -33
- package/src/components/__tests__/exports.test.ts +0 -38
- package/src/components/__tests__/switch.test.ts +0 -34
- package/src/hooks/use-icon-color.ts +0 -51
- package/src/utils/__tests__/create-slot-recipe-context.test.tsx +0 -228
- /package/src/hooks/{use-controllable-state.ts → useControllableState.ts} +0 -0
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
const TRANSITION_DURATION = 300;
|
|
74
|
+
var INDETERMINATE_DURATION = 1200;
|
|
75
|
+
var TRANSITION_DURATION = 300;
|
|
82
76
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
2
|
-
export * as ProgressCircle from
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
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
|
-
|
|
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<
|
|
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<
|
|
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
|