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