@codefast/ui 0.3.11-canary.1 → 0.3.11
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/CHANGELOG.md +36 -0
- package/README.md +34 -14
- package/dist/components/accordion.d.ts +29 -10
- package/dist/components/accordion.js +38 -37
- package/dist/components/alert-dialog.d.ts +60 -24
- package/dist/components/alert-dialog.js +69 -72
- package/dist/components/alert.d.ts +27 -15
- package/dist/components/alert.js +29 -31
- package/dist/components/aspect-ratio.d.ts +8 -4
- package/dist/components/aspect-ratio.js +7 -5
- package/dist/components/avatar.d.ts +17 -6
- package/dist/components/avatar.js +19 -17
- package/dist/components/badge.d.ts +21 -14
- package/dist/components/badge.js +19 -22
- package/dist/components/breadcrumb.d.ts +35 -12
- package/dist/components/breadcrumb.js +48 -54
- package/dist/components/button-group.d.ts +29 -14
- package/dist/components/button-group.js +27 -32
- package/dist/components/button.d.ts +35 -25
- package/dist/components/button.js +50 -48
- package/dist/components/calendar.d.ts +24 -9
- package/dist/components/calendar.js +92 -98
- package/dist/components/card.d.ts +34 -10
- package/dist/components/card.js +39 -37
- package/dist/components/carousel.d.ts +55 -24
- package/dist/components/carousel.js +113 -130
- package/dist/components/chart.d.ts +72 -36
- package/dist/components/chart.js +154 -166
- package/dist/components/checkbox-cards.d.ts +15 -8
- package/dist/components/checkbox-cards.js +22 -25
- package/dist/components/checkbox-group.d.ts +16 -8
- package/dist/components/checkbox-group.js +19 -19
- package/dist/components/checkbox.d.ts +9 -4
- package/dist/components/checkbox.js +14 -14
- package/dist/components/collapsible.d.ts +14 -6
- package/dist/components/collapsible.js +18 -16
- package/dist/components/command.d.ts +55 -23
- package/dist/components/command.js +70 -85
- package/dist/components/context-menu.d.ts +72 -22
- package/dist/components/context-menu.js +88 -109
- package/dist/components/dialog.d.ts +53 -22
- package/dist/components/dialog.js +71 -85
- package/dist/components/drawer.d.ts +60 -28
- package/dist/components/drawer.js +59 -67
- package/dist/components/dropdown-menu.d.ts +73 -22
- package/dist/components/dropdown-menu.js +95 -112
- package/dist/components/empty.d.ts +37 -15
- package/dist/components/empty.js +43 -45
- package/dist/components/field.d.ts +63 -25
- package/dist/components/field.js +88 -104
- package/dist/components/form.d.ts +37 -15
- package/dist/components/form.js +65 -70
- package/dist/components/hover-card.d.ts +21 -7
- package/dist/components/hover-card.js +24 -24
- package/dist/components/input-group.d.ts +53 -28
- package/dist/components/input-group.js +63 -77
- package/dist/components/input-number.d.ts +28 -7
- package/dist/components/input-number.js +55 -59
- package/dist/components/input-otp.d.ts +24 -10
- package/dist/components/input-otp.js +33 -37
- package/dist/components/input-password.d.ts +12 -5
- package/dist/components/input-password.js +31 -32
- package/dist/components/input-search.d.ts +18 -8
- package/dist/components/input-search.js +43 -41
- package/dist/components/input.d.ts +10 -4
- package/dist/components/input.js +9 -7
- package/dist/components/item.d.ts +69 -32
- package/dist/components/item.js +89 -92
- package/dist/components/kbd.d.ts +13 -5
- package/dist/components/kbd.js +13 -11
- package/dist/components/label.d.ts +9 -4
- package/dist/components/label.js +9 -7
- package/dist/components/menubar.d.ts +80 -23
- package/dist/components/menubar.js +97 -118
- package/dist/components/native-select.d.ts +16 -6
- package/dist/components/native-select.js +25 -26
- package/dist/components/navigation-menu.d.ts +36 -12
- package/dist/components/navigation-menu.js +60 -75
- package/dist/components/pagination.d.ts +35 -14
- package/dist/components/pagination.js +54 -69
- package/dist/components/popover.d.ts +24 -8
- package/dist/components/popover.js +28 -28
- package/dist/components/progress-circle.d.ts +106 -88
- package/dist/components/progress-circle.js +106 -138
- package/dist/components/progress.d.ts +10 -4
- package/dist/components/progress.js +14 -14
- package/dist/components/radio-cards.d.ts +10 -4
- package/dist/components/radio-cards.js +22 -23
- package/dist/components/radio-group.d.ts +13 -5
- package/dist/components/radio-group.js +18 -16
- package/dist/components/radio.d.ts +12 -5
- package/dist/components/radio.js +10 -8
- package/dist/components/resizable.d.ts +18 -7
- package/dist/components/resizable.js +22 -22
- package/dist/components/scroll-area.d.ts +33 -20
- package/dist/components/scroll-area.js +84 -88
- package/dist/components/select.d.ts +50 -16
- package/dist/components/select.js +77 -96
- package/dist/components/separator.d.ts +29 -19
- package/dist/components/separator.js +36 -34
- package/dist/components/sheet.d.ts +62 -29
- package/dist/components/sheet.js +79 -100
- package/dist/components/sidebar.d.ts +160 -66
- package/dist/components/sidebar.js +294 -336
- package/dist/components/skeleton.d.ts +9 -4
- package/dist/components/skeleton.js +8 -6
- package/dist/components/slider.d.ts +13 -4
- package/dist/components/slider.js +34 -40
- package/dist/components/sonner.d.ts +10 -7
- package/dist/components/sonner.js +16 -14
- package/dist/components/spinner.d.ts +12 -5
- package/dist/components/spinner.js +33 -35
- package/dist/components/switch.d.ts +9 -4
- package/dist/components/switch.js +13 -11
- package/dist/components/table.d.ts +37 -11
- package/dist/components/table.js +47 -45
- package/dist/components/tabs.d.ts +21 -7
- package/dist/components/tabs.js +24 -22
- package/dist/components/textarea.d.ts +9 -4
- package/dist/components/textarea.js +8 -6
- package/dist/components/toggle-group.d.ts +24 -9
- package/dist/components/toggle-group.js +41 -42
- package/dist/components/toggle.d.ts +25 -17
- package/dist/components/toggle.js +30 -28
- package/dist/components/tooltip.d.ts +24 -8
- package/dist/components/tooltip.js +29 -32
- package/dist/hooks/use-animated-value.d.ts +4 -1
- package/dist/hooks/use-animated-value.js +57 -36
- package/dist/hooks/use-copy-to-clipboard.d.ts +11 -5
- package/dist/hooks/use-copy-to-clipboard.js +39 -20
- package/dist/hooks/use-is-mobile.d.ts +4 -1
- package/dist/hooks/use-is-mobile.js +21 -1
- package/dist/hooks/use-media-query.d.ts +4 -1
- package/dist/hooks/use-media-query.js +45 -18
- package/dist/hooks/use-mutation-observer.d.ts +6 -2
- package/dist/hooks/use-mutation-observer.js +34 -16
- package/dist/hooks/use-pagination.d.ts +22 -14
- package/dist/hooks/use-pagination.js +100 -49
- package/dist/index.d.ts +69 -130
- package/dist/index.js +11 -11
- package/dist/primitives/checkbox-group.d.ts +105 -83
- package/dist/primitives/checkbox-group.js +111 -84
- package/dist/primitives/input-number.d.ts +51 -40
- package/dist/primitives/input-number.js +483 -350
- package/dist/primitives/input.d.ts +48 -42
- package/dist/primitives/input.js +65 -43
- package/dist/primitives/progress-circle.d.ts +79 -48
- package/dist/primitives/progress-circle.js +154 -105
- package/package.json +6 -7
|
@@ -1,129 +1,178 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContextScope } from "@radix-ui/react-context";
|
|
4
3
|
import { useId, useMemo } from "react";
|
|
4
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
5
|
+
//#region src/primitives/progress-circle.tsx
|
|
5
6
|
const PROGRESS_CIRCLE_PROVIDER_NAME = "ProgressCircleProvider";
|
|
6
7
|
const [createProgressCircleContext, createProgressCircleScope] = createContextScope(PROGRESS_CIRCLE_PROVIDER_NAME);
|
|
7
8
|
const [ProgressCircleContextProvider, useProgressCircleContext] = createProgressCircleContext(PROGRESS_CIRCLE_PROVIDER_NAME);
|
|
9
|
+
/**
|
|
10
|
+
* Provides context for the ProgressCircle component
|
|
11
|
+
*
|
|
12
|
+
* Manages calculations for rendering the circular progress indicator,
|
|
13
|
+
* including value clamping, sizing, thresholds, and indeterminate state.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <ProgressCircleProvider
|
|
18
|
+
* value={75}
|
|
19
|
+
* min={0}
|
|
20
|
+
* max={100}
|
|
21
|
+
* size={64}
|
|
22
|
+
* thresholds={[
|
|
23
|
+
* { value: 30, color: 'red', background: 'pink' },
|
|
24
|
+
* { value: 70, color: 'yellow', background: 'lightyellow' },
|
|
25
|
+
* { value: 100, color: 'green', background: 'lightgreen' }
|
|
26
|
+
* ]}
|
|
27
|
+
* >
|
|
28
|
+
* <ProgressCircleSVG>
|
|
29
|
+
* <ProgressCircleIndicator />
|
|
30
|
+
* <ProgressCircleTrack />
|
|
31
|
+
* </ProgressCircleSVG>
|
|
32
|
+
* <ProgressCircleValue />
|
|
33
|
+
* </ProgressCircleProvider>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
8
36
|
function ProgressCircleProvider({ __scopeProgressCircle, children, formatValue, id: propertyId, max = 100, min = 0, size = 48, startAngle = -90, strokeWidth = 4, thresholds, value }) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
radius: radius,
|
|
51
|
-
rotationTransform: rotationTransform,
|
|
52
|
-
scope: __scopeProgressCircle,
|
|
53
|
-
size: validSize,
|
|
54
|
-
strokeDashoffset: strokeDashoffset,
|
|
55
|
-
strokeWidth: validStrokeWidth,
|
|
56
|
-
threshold: threshold,
|
|
57
|
-
value: value ?? 0,
|
|
58
|
-
valueText: valueText,
|
|
59
|
-
children: children
|
|
60
|
-
});
|
|
37
|
+
const uniqueId = useId();
|
|
38
|
+
const id = propertyId ?? uniqueId;
|
|
39
|
+
const validSize = Math.max(0, size);
|
|
40
|
+
const validStrokeWidth = Math.max(0, strokeWidth);
|
|
41
|
+
const validStartAngle = startAngle % 360;
|
|
42
|
+
let validMin = min;
|
|
43
|
+
let validMax = max;
|
|
44
|
+
if (validMin > validMax) [validMin, validMax] = [validMax, validMin];
|
|
45
|
+
const clampedValue = value === null || value === void 0 ? void 0 : clamp(validMin, validMax, value);
|
|
46
|
+
const range = validMax - validMin;
|
|
47
|
+
const percentage = clampedValue !== void 0 && range > 0 ? (clampedValue - validMin) / range * 100 : 0;
|
|
48
|
+
const valueText = clampedValue !== void 0 && formatValue ? formatValue(clampedValue) : `${Math.round(percentage).toString()}%`;
|
|
49
|
+
const sortedThresholds = useMemo(() => thresholds && thresholds.length > 0 ? [...thresholds].toSorted((a, b) => a.value - b.value) : [], [thresholds]);
|
|
50
|
+
const threshold = useMemo(() => {
|
|
51
|
+
if (clampedValue === void 0) return;
|
|
52
|
+
for (const sortedThreshold of sortedThresholds) if (clampedValue <= sortedThreshold.value) return sortedThreshold;
|
|
53
|
+
return sortedThresholds.at(-1);
|
|
54
|
+
}, [sortedThresholds, clampedValue]);
|
|
55
|
+
const center = validSize / 2;
|
|
56
|
+
const radius = Math.max(0, center - validStrokeWidth / 2);
|
|
57
|
+
const circumference = 2 * Math.PI * radius;
|
|
58
|
+
const strokeDashoffset = circumference - percentage / 100 * circumference;
|
|
59
|
+
const rotationTransform = `rotate(${validStartAngle.toString()}, 0, 0)`;
|
|
60
|
+
return /* @__PURE__ */ jsx(ProgressCircleContextProvider, {
|
|
61
|
+
center,
|
|
62
|
+
circumference,
|
|
63
|
+
clampedValue,
|
|
64
|
+
id,
|
|
65
|
+
max: validMax,
|
|
66
|
+
min: validMin,
|
|
67
|
+
radius,
|
|
68
|
+
rotationTransform,
|
|
69
|
+
scope: __scopeProgressCircle,
|
|
70
|
+
size: validSize,
|
|
71
|
+
strokeDashoffset,
|
|
72
|
+
strokeWidth: validStrokeWidth,
|
|
73
|
+
threshold,
|
|
74
|
+
value: value ?? 0,
|
|
75
|
+
valueText,
|
|
76
|
+
children
|
|
77
|
+
});
|
|
61
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Root component for the progress circle
|
|
81
|
+
*
|
|
82
|
+
* Serves as a wrapper for other progress circle components.
|
|
83
|
+
*/
|
|
62
84
|
function ProgressCircle({ __scopeProgressCircle, ...props }) {
|
|
63
|
-
|
|
64
|
-
...props
|
|
65
|
-
});
|
|
85
|
+
return /* @__PURE__ */ jsx("div", { ...props });
|
|
66
86
|
}
|
|
67
87
|
const PROGRESS_CIRCLE_SVG_NAME = "ProgressCircleSVG";
|
|
88
|
+
/**
|
|
89
|
+
* SVG container for the progress circle
|
|
90
|
+
*
|
|
91
|
+
* Renders the SVG with accessibility attributes and supports indeterminate state.
|
|
92
|
+
*/
|
|
68
93
|
function ProgressCircleSVG({ __scopeProgressCircle, ...props }) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
const { clampedValue, id, max, min, size, valueText } = useProgressCircleContext(PROGRESS_CIRCLE_SVG_NAME, __scopeProgressCircle);
|
|
95
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
96
|
+
"aria-label": "Progress",
|
|
97
|
+
"aria-valuemax": max,
|
|
98
|
+
"aria-valuemin": min,
|
|
99
|
+
"aria-valuenow": clampedValue,
|
|
100
|
+
"aria-valuetext": clampedValue === void 0 ? void 0 : valueText,
|
|
101
|
+
height: size,
|
|
102
|
+
id,
|
|
103
|
+
role: "progressbar",
|
|
104
|
+
viewBox: `0 0 ${size.toString()} ${size.toString()}`,
|
|
105
|
+
width: size,
|
|
106
|
+
...props
|
|
107
|
+
});
|
|
83
108
|
}
|
|
84
109
|
const PROGRESS_CIRCLE_TRACK_NAME = "ProgressCircleTrack";
|
|
110
|
+
/**
|
|
111
|
+
* Background circle for the progress indicator
|
|
112
|
+
*
|
|
113
|
+
* Renders the static track of the progress circle.
|
|
114
|
+
*/
|
|
85
115
|
function ProgressCircleTrack({ __scopeProgressCircle, ...props }) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
116
|
+
const { center, radius, strokeWidth, threshold } = useProgressCircleContext(PROGRESS_CIRCLE_TRACK_NAME, __scopeProgressCircle);
|
|
117
|
+
return /* @__PURE__ */ jsx("circle", {
|
|
118
|
+
cx: center,
|
|
119
|
+
cy: center,
|
|
120
|
+
fill: "transparent",
|
|
121
|
+
r: radius,
|
|
122
|
+
stroke: threshold?.background ?? "currentColor",
|
|
123
|
+
strokeWidth,
|
|
124
|
+
...props
|
|
125
|
+
});
|
|
96
126
|
}
|
|
97
127
|
const PROGRESS_CIRCLE_INDICATOR_NAME = "ProgressCircleIndicator";
|
|
128
|
+
/**
|
|
129
|
+
* Foreground circle showing progress
|
|
130
|
+
*
|
|
131
|
+
* Renders the dynamic progress indicator with stroke dash properties.
|
|
132
|
+
*/
|
|
98
133
|
function ProgressCircleIndicator({ __scopeProgressCircle, ...props }) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
134
|
+
const { center, circumference, radius, rotationTransform, strokeDashoffset, strokeWidth, threshold } = useProgressCircleContext(PROGRESS_CIRCLE_INDICATOR_NAME, __scopeProgressCircle);
|
|
135
|
+
return /* @__PURE__ */ jsx("circle", {
|
|
136
|
+
cx: center,
|
|
137
|
+
cy: center,
|
|
138
|
+
fill: "transparent",
|
|
139
|
+
r: radius,
|
|
140
|
+
stroke: threshold?.color ?? "currentColor",
|
|
141
|
+
strokeDasharray: circumference,
|
|
142
|
+
strokeDashoffset,
|
|
143
|
+
strokeLinecap: "round",
|
|
144
|
+
strokeWidth,
|
|
145
|
+
transform: rotationTransform,
|
|
146
|
+
...props
|
|
147
|
+
});
|
|
113
148
|
}
|
|
114
149
|
const PROGRESS_CIRCLE_VALUE_NAME = "ProgressCircleValue";
|
|
150
|
+
/**
|
|
151
|
+
* Displays the current progress value
|
|
152
|
+
*
|
|
153
|
+
* Supports custom content or default value text rendering.
|
|
154
|
+
*/
|
|
115
155
|
function ProgressCircleValue({ __scopeProgressCircle, children, ...props }) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
156
|
+
const { clampedValue, valueText } = useProgressCircleContext(PROGRESS_CIRCLE_VALUE_NAME, __scopeProgressCircle);
|
|
157
|
+
if (typeof children === "function") return children({
|
|
158
|
+
value: clampedValue,
|
|
159
|
+
valueText
|
|
160
|
+
});
|
|
161
|
+
return /* @__PURE__ */ jsx("div", {
|
|
162
|
+
...props,
|
|
163
|
+
children: children ?? valueText
|
|
164
|
+
});
|
|
125
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Clamps a value within a specified min/max range
|
|
168
|
+
*
|
|
169
|
+
* @param min - Minimum value
|
|
170
|
+
* @param max - Maximum value
|
|
171
|
+
* @param value - Value to clamp
|
|
172
|
+
* @returns Clamped value
|
|
173
|
+
*/
|
|
126
174
|
function clamp(min, max, value) {
|
|
127
|
-
|
|
175
|
+
return Math.min(max, Math.max(min, value));
|
|
128
176
|
}
|
|
129
|
-
|
|
177
|
+
//#endregion
|
|
178
|
+
export { ProgressCircleIndicator as Indicator, ProgressCircleIndicator, ProgressCircle, ProgressCircle as Root, ProgressCircleProvider, ProgressCircleProvider as Provider, ProgressCircleSVG, ProgressCircleSVG as SVG, ProgressCircleTrack, ProgressCircleTrack as Track, ProgressCircleValue, ProgressCircleValue as Value, createProgressCircleScope };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/ui",
|
|
3
|
-
"version": "0.3.11
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "Core UI components library built with React and Tailwind CSS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -382,11 +382,9 @@
|
|
|
382
382
|
"sonner": "^2.0.7",
|
|
383
383
|
"tw-animate-css": "^1.4.0",
|
|
384
384
|
"vaul": "^1.1.2",
|
|
385
|
-
"@codefast/tailwind-variants": "0.3.11
|
|
385
|
+
"@codefast/tailwind-variants": "0.3.11"
|
|
386
386
|
},
|
|
387
387
|
"devDependencies": {
|
|
388
|
-
"@rsbuild/plugin-react": "^1.4.6",
|
|
389
|
-
"@rslib/core": "0.19.1",
|
|
390
388
|
"@swc/core": "^1.15.21",
|
|
391
389
|
"@swc/jest": "^0.2.39",
|
|
392
390
|
"@tailwindcss/postcss": "^4.2.2",
|
|
@@ -403,8 +401,9 @@
|
|
|
403
401
|
"postcss": "^8.5.8",
|
|
404
402
|
"tailwindcss": "^4.2.2",
|
|
405
403
|
"ts-node": "^10.9.2",
|
|
404
|
+
"tsdown": "^0.21.7",
|
|
406
405
|
"typescript": "^6.0.2",
|
|
407
|
-
"@codefast/typescript-config": "0.3.11
|
|
406
|
+
"@codefast/typescript-config": "0.3.11"
|
|
408
407
|
},
|
|
409
408
|
"peerDependencies": {
|
|
410
409
|
"@types/react": "^19.0",
|
|
@@ -421,9 +420,9 @@
|
|
|
421
420
|
}
|
|
422
421
|
},
|
|
423
422
|
"scripts": {
|
|
424
|
-
"build": "
|
|
423
|
+
"build": "tsdown",
|
|
425
424
|
"clean": "rm -rf dist",
|
|
426
|
-
"dev": "
|
|
425
|
+
"dev": "tsdown --watch --no-clean",
|
|
427
426
|
"test": "jest",
|
|
428
427
|
"test:coverage": "jest --coverage",
|
|
429
428
|
"test:coverage:ci": "jest --coverage --ci",
|