@codefast/ui 0.3.13-canary.3 → 0.3.13
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 +44 -0
- package/dist/components/accordion.d.mts +37 -0
- package/dist/components/accordion.mjs +53 -0
- package/dist/components/alert-dialog.d.mts +74 -0
- package/dist/components/alert-dialog.mjs +92 -0
- package/dist/components/alert.d.mts +30 -0
- package/dist/components/alert.mjs +49 -0
- package/dist/components/aspect-ratio.d.mts +10 -0
- package/dist/components/aspect-ratio.mjs +12 -0
- package/dist/components/avatar.d.mts +21 -0
- package/dist/components/avatar.mjs +28 -0
- package/dist/components/badge.d.mts +24 -0
- package/dist/components/badge.mjs +56 -0
- package/dist/components/breadcrumb.d.mts +44 -0
- package/dist/components/breadcrumb.mjs +67 -0
- package/dist/components/button-group.d.mts +34 -0
- package/dist/components/button-group.mjs +53 -0
- package/dist/components/button.d.mts +38 -0
- package/dist/components/button.mjs +99 -0
- package/dist/components/calendar.d.mts +27 -0
- package/dist/components/calendar.mjs +114 -0
- package/dist/components/card.d.mts +41 -0
- package/dist/components/card.mjs +55 -0
- package/dist/components/carousel.d.mts +68 -0
- package/dist/components/carousel.mjs +135 -0
- package/dist/components/chart.d.mts +93 -0
- package/dist/components/chart.mjs +189 -0
- package/dist/components/checkbox-cards.d.mts +17 -0
- package/dist/components/checkbox-cards.mjs +30 -0
- package/dist/components/checkbox-group.d.mts +16 -0
- package/dist/components/checkbox-group.mjs +27 -0
- package/dist/components/checkbox.d.mts +11 -0
- package/dist/components/checkbox.mjs +20 -0
- package/dist/components/collapsible.d.mts +18 -0
- package/dist/components/collapsible.mjs +24 -0
- package/dist/components/command.d.mts +57 -0
- package/dist/components/command.mjs +92 -0
- package/dist/components/context-menu.d.mts +91 -0
- package/dist/components/context-menu.mjs +122 -0
- package/dist/components/dialog.d.mts +65 -0
- package/dist/components/dialog.mjs +93 -0
- package/dist/components/drawer.d.mts +65 -0
- package/dist/components/drawer.mjs +78 -0
- package/dist/components/dropdown-menu.d.mts +92 -0
- package/dist/components/dropdown-menu.mjs +129 -0
- package/dist/components/empty.d.mts +44 -0
- package/dist/components/empty.mjs +64 -0
- package/dist/components/field.d.mts +79 -0
- package/dist/components/field.mjs +132 -0
- package/dist/components/form.d.mts +48 -0
- package/dist/components/form.mjs +92 -0
- package/dist/components/hover-card.d.mts +26 -0
- package/dist/components/hover-card.mjs +35 -0
- package/dist/components/input-group.d.mts +61 -0
- package/dist/components/input-group.mjs +142 -0
- package/dist/components/input-number.d.mts +28 -0
- package/dist/components/input-number.mjs +61 -0
- package/dist/components/input-otp.d.mts +29 -0
- package/dist/components/input-otp.mjs +48 -0
- package/dist/components/input-password.d.mts +13 -0
- package/dist/components/input-password.mjs +38 -0
- package/dist/components/input-search.d.mts +20 -0
- package/dist/components/input-search.mjs +50 -0
- package/dist/components/input.d.mts +11 -0
- package/dist/components/input.mjs +14 -0
- package/dist/components/item.d.mts +82 -0
- package/dist/components/item.mjs +137 -0
- package/dist/components/kbd.d.mts +15 -0
- package/dist/components/kbd.mjs +19 -0
- package/dist/components/label.d.mts +11 -0
- package/dist/components/label.mjs +14 -0
- package/dist/components/menubar.d.mts +100 -0
- package/dist/components/menubar.mjs +133 -0
- package/dist/components/native-select.d.mts +19 -0
- package/dist/components/native-select.mjs +34 -0
- package/dist/components/navigation-menu.d.mts +44 -0
- package/dist/components/navigation-menu.mjs +79 -0
- package/dist/components/pagination.d.mts +46 -0
- package/dist/components/pagination.mjs +71 -0
- package/dist/components/popover.d.mts +30 -0
- package/dist/components/popover.mjs +41 -0
- package/dist/components/progress-circle.d.mts +124 -0
- package/dist/components/progress-circle.mjs +120 -0
- package/dist/components/progress.d.mts +12 -0
- package/dist/components/progress.mjs +19 -0
- package/dist/components/{radio-cards.d.ts → radio-cards.d.mts} +10 -5
- package/dist/components/radio-cards.mjs +29 -0
- package/dist/components/radio-group.d.mts +16 -0
- package/dist/components/radio-group.mjs +25 -0
- package/dist/components/radio.d.mts +14 -0
- package/dist/components/radio.mjs +16 -0
- package/dist/components/resizable.d.mts +23 -0
- package/dist/components/resizable.mjs +32 -0
- package/dist/components/scroll-area.d.mts +40 -0
- package/dist/components/scroll-area.mjs +101 -0
- package/dist/components/select.d.mts +62 -0
- package/dist/components/select.mjs +101 -0
- package/dist/components/separator.d.mts +32 -0
- package/dist/components/separator.mjs +45 -0
- package/dist/components/sheet.d.mts +75 -0
- package/dist/components/sheet.mjs +134 -0
- package/dist/components/sidebar.d.mts +195 -0
- package/dist/components/sidebar.mjs +375 -0
- package/dist/components/skeleton.d.mts +10 -0
- package/dist/components/skeleton.mjs +12 -0
- package/dist/components/slider.d.mts +15 -0
- package/dist/components/slider.mjs +40 -0
- package/dist/components/sonner.d.mts +10 -0
- package/dist/components/sonner.mjs +21 -0
- package/dist/components/spinner.d.mts +14 -0
- package/dist/components/spinner.mjs +40 -0
- package/dist/components/switch.d.mts +11 -0
- package/dist/components/switch.mjs +18 -0
- package/dist/components/table.d.mts +45 -0
- package/dist/components/table.mjs +65 -0
- package/dist/components/tabs.d.mts +26 -0
- package/dist/components/tabs.mjs +35 -0
- package/dist/components/textarea.d.mts +10 -0
- package/dist/components/textarea.mjs +12 -0
- package/dist/components/toggle-group.d.mts +30 -0
- package/dist/components/toggle-group.mjs +53 -0
- package/dist/components/toggle.d.mts +28 -0
- package/dist/components/toggle.mjs +53 -0
- package/dist/components/tooltip.d.mts +30 -0
- package/dist/components/tooltip.mjs +42 -0
- package/dist/hooks/{use-animated-value.d.ts → use-animated-value.d.mts} +4 -2
- package/dist/hooks/use-animated-value.mjs +62 -0
- package/dist/hooks/{use-copy-to-clipboard.d.ts → use-copy-to-clipboard.d.mts} +11 -6
- package/dist/hooks/use-copy-to-clipboard.mjs +43 -0
- package/dist/hooks/{use-is-mobile.d.ts → use-is-mobile.d.mts} +4 -2
- package/dist/hooks/use-is-mobile.mjs +26 -0
- package/dist/hooks/{use-media-query.d.ts → use-media-query.d.mts} +4 -2
- package/dist/hooks/use-media-query.mjs +50 -0
- package/dist/hooks/{use-mutation-observer.d.ts → use-mutation-observer.d.mts} +6 -3
- package/dist/hooks/use-mutation-observer.mjs +41 -0
- package/dist/hooks/use-pagination.d.mts +44 -0
- package/dist/hooks/use-pagination.mjs +107 -0
- package/dist/index.d.mts +69 -0
- package/dist/index.mjs +69 -0
- package/dist/lib/utils.d.mts +13 -0
- package/dist/lib/utils.mjs +10 -0
- package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/clsx.d.mts +6 -0
- package/dist/primitives/checkbox-group.d.mts +144 -0
- package/dist/primitives/checkbox-group.mjs +126 -0
- package/dist/primitives/input-number.d.mts +73 -0
- package/dist/primitives/input-number.mjs +514 -0
- package/dist/primitives/input.d.mts +72 -0
- package/dist/primitives/input.mjs +75 -0
- package/dist/primitives/progress-circle.d.mts +146 -0
- package/dist/primitives/progress-circle.mjs +178 -0
- package/package.json +164 -170
- package/dist/components/accordion.d.ts +0 -19
- package/dist/components/accordion.d.ts.map +0 -1
- package/dist/components/accordion.js +0 -26
- package/dist/components/alert-dialog.d.ts +0 -39
- package/dist/components/alert-dialog.d.ts.map +0 -1
- package/dist/components/alert-dialog.js +0 -39
- package/dist/components/alert.d.ts +0 -19
- package/dist/components/alert.d.ts.map +0 -1
- package/dist/components/alert.js +0 -41
- package/dist/components/aspect-ratio.d.ts +0 -7
- package/dist/components/aspect-ratio.d.ts.map +0 -1
- package/dist/components/aspect-ratio.js +0 -10
- package/dist/components/avatar.d.ts +0 -11
- package/dist/components/avatar.d.ts.map +0 -1
- package/dist/components/avatar.js +0 -17
- package/dist/components/badge.d.ts +0 -18
- package/dist/components/badge.d.ts.map +0 -1
- package/dist/components/badge.js +0 -59
- package/dist/components/breadcrumb.d.ts +0 -22
- package/dist/components/breadcrumb.d.ts.map +0 -1
- package/dist/components/breadcrumb.js +0 -31
- package/dist/components/button-group.d.ts +0 -20
- package/dist/components/button-group.d.ts.map +0 -1
- package/dist/components/button-group.js +0 -48
- package/dist/components/button.d.ts +0 -29
- package/dist/components/button.d.ts.map +0 -1
- package/dist/components/button.js +0 -92
- package/dist/components/calendar.d.ts +0 -13
- package/dist/components/calendar.d.ts.map +0 -1
- package/dist/components/calendar.js +0 -104
- package/dist/components/card.d.ts +0 -18
- package/dist/components/card.d.ts.map +0 -1
- package/dist/components/card.js +0 -27
- package/dist/components/carousel.d.ts +0 -38
- package/dist/components/carousel.d.ts.map +0 -1
- package/dist/components/carousel.js +0 -103
- package/dist/components/chart.d.ts +0 -58
- package/dist/components/chart.d.ts.map +0 -1
- package/dist/components/chart.js +0 -198
- package/dist/components/checkbox-cards.d.ts +0 -11
- package/dist/components/checkbox-cards.d.ts.map +0 -1
- package/dist/components/checkbox-cards.js +0 -16
- package/dist/components/checkbox-group.d.ts +0 -9
- package/dist/components/checkbox-group.d.ts.map +0 -1
- package/dist/components/checkbox-group.js +0 -15
- package/dist/components/checkbox.d.ts +0 -7
- package/dist/components/checkbox.d.ts.map +0 -1
- package/dist/components/checkbox.js +0 -12
- package/dist/components/collapsible.d.ts +0 -11
- package/dist/components/collapsible.d.ts.map +0 -1
- package/dist/components/collapsible.js +0 -16
- package/dist/components/command.d.ts +0 -26
- package/dist/components/command.d.ts.map +0 -1
- package/dist/components/command.js +0 -41
- package/dist/components/context-menu.d.ts +0 -42
- package/dist/components/context-menu.d.ts.map +0 -1
- package/dist/components/context-menu.js +0 -54
- package/dist/components/dialog.d.ts +0 -35
- package/dist/components/dialog.d.ts.map +0 -1
- package/dist/components/dialog.js +0 -41
- package/dist/components/drawer.d.ts +0 -34
- package/dist/components/drawer.d.ts.map +0 -1
- package/dist/components/drawer.js +0 -36
- package/dist/components/dropdown-menu.d.ts +0 -42
- package/dist/components/dropdown-menu.d.ts.map +0 -1
- package/dist/components/dropdown-menu.js +0 -54
- package/dist/components/empty.d.ts +0 -23
- package/dist/components/empty.d.ts.map +0 -1
- package/dist/components/empty.js +0 -47
- package/dist/components/field.d.ts +0 -42
- package/dist/components/field.d.ts.map +0 -1
- package/dist/components/field.js +0 -85
- package/dist/components/form.d.ts +0 -27
- package/dist/components/form.d.ts.map +0 -1
- package/dist/components/form.js +0 -76
- package/dist/components/hover-card.d.ts +0 -13
- package/dist/components/hover-card.d.ts.map +0 -1
- package/dist/components/hover-card.js +0 -20
- package/dist/components/input-group.d.ts +0 -37
- package/dist/components/input-group.d.ts.map +0 -1
- package/dist/components/input-group.js +0 -127
- package/dist/components/input-number.d.ts +0 -8
- package/dist/components/input-number.d.ts.map +0 -1
- package/dist/components/input-number.js +0 -20
- package/dist/components/input-otp.d.ts +0 -16
- package/dist/components/input-otp.d.ts.map +0 -1
- package/dist/components/input-otp.js +0 -25
- package/dist/components/input-password.d.ts +0 -7
- package/dist/components/input-password.d.ts.map +0 -1
- package/dist/components/input-password.js +0 -17
- package/dist/components/input-search.d.ts +0 -11
- package/dist/components/input-search.d.ts.map +0 -1
- package/dist/components/input-search.js +0 -22
- package/dist/components/input.d.ts +0 -6
- package/dist/components/input.d.ts.map +0 -1
- package/dist/components/input.js +0 -10
- package/dist/components/item.d.ts +0 -46
- package/dist/components/item.d.ts.map +0 -1
- package/dist/components/item.js +0 -94
- package/dist/components/kbd.d.ts +0 -8
- package/dist/components/kbd.d.ts.map +0 -1
- package/dist/components/kbd.js +0 -12
- package/dist/components/label.d.ts +0 -7
- package/dist/components/label.d.ts.map +0 -1
- package/dist/components/label.js +0 -11
- package/dist/components/menubar.d.ts +0 -44
- package/dist/components/menubar.d.ts.map +0 -1
- package/dist/components/menubar.js +0 -57
- package/dist/components/native-select.d.ts +0 -10
- package/dist/components/native-select.d.ts.map +0 -1
- package/dist/components/native-select.js +0 -16
- package/dist/components/navigation-menu.d.ts +0 -21
- package/dist/components/navigation-menu.d.ts.map +0 -1
- package/dist/components/navigation-menu.js +0 -43
- package/dist/components/pagination.d.ts +0 -26
- package/dist/components/pagination.d.ts.map +0 -1
- package/dist/components/pagination.js +0 -29
- package/dist/components/popover.d.ts +0 -15
- package/dist/components/popover.d.ts.map +0 -1
- package/dist/components/popover.js +0 -23
- package/dist/components/progress-circle.d.ts +0 -107
- package/dist/components/progress-circle.d.ts.map +0 -1
- package/dist/components/progress-circle.js +0 -83
- package/dist/components/progress.d.ts +0 -7
- package/dist/components/progress.d.ts.map +0 -1
- package/dist/components/progress.js +0 -13
- package/dist/components/radio-cards.d.ts.map +0 -1
- package/dist/components/radio-cards.js +0 -15
- package/dist/components/radio-group.d.ts +0 -9
- package/dist/components/radio-group.d.ts.map +0 -1
- package/dist/components/radio-group.js +0 -14
- package/dist/components/radio.d.ts +0 -8
- package/dist/components/radio.d.ts.map +0 -1
- package/dist/components/radio.js +0 -11
- package/dist/components/resizable.d.ts +0 -13
- package/dist/components/resizable.d.ts.map +0 -1
- package/dist/components/resizable.js +0 -18
- package/dist/components/scroll-area.d.ts +0 -28
- package/dist/components/scroll-area.d.ts.map +0 -1
- package/dist/components/scroll-area.js +0 -77
- package/dist/components/select.d.ts +0 -29
- package/dist/components/select.d.ts.map +0 -1
- package/dist/components/select.js +0 -49
- package/dist/components/separator.d.ts +0 -23
- package/dist/components/separator.d.ts.map +0 -1
- package/dist/components/separator.js +0 -36
- package/dist/components/sheet.d.ts +0 -43
- package/dist/components/sheet.d.ts.map +0 -1
- package/dist/components/sheet.js +0 -90
- package/dist/components/sidebar.d.ts +0 -102
- package/dist/components/sidebar.d.ts.map +0 -1
- package/dist/components/sidebar.js +0 -241
- package/dist/components/skeleton.d.ts +0 -6
- package/dist/components/skeleton.d.ts.map +0 -1
- package/dist/components/skeleton.js +0 -9
- package/dist/components/slider.d.ts +0 -7
- package/dist/components/slider.d.ts.map +0 -1
- package/dist/components/slider.js +0 -18
- package/dist/components/sonner.d.ts +0 -8
- package/dist/components/sonner.d.ts.map +0 -1
- package/dist/components/sonner.js +0 -18
- package/dist/components/spinner.d.ts +0 -8
- package/dist/components/spinner.d.ts.map +0 -1
- package/dist/components/spinner.js +0 -27
- package/dist/components/switch.d.ts +0 -7
- package/dist/components/switch.d.ts.map +0 -1
- package/dist/components/switch.js +0 -11
- package/dist/components/table.d.ts +0 -20
- package/dist/components/table.d.ts.map +0 -1
- package/dist/components/table.js +0 -30
- package/dist/components/tabs.d.ts +0 -13
- package/dist/components/tabs.d.ts.map +0 -1
- package/dist/components/tabs.js +0 -20
- package/dist/components/textarea.d.ts +0 -6
- package/dist/components/textarea.d.ts.map +0 -1
- package/dist/components/textarea.js +0 -9
- package/dist/components/toggle-group.d.ts +0 -16
- package/dist/components/toggle-group.d.ts.map +0 -1
- package/dist/components/toggle-group.js +0 -35
- package/dist/components/toggle.d.ts +0 -21
- package/dist/components/toggle.d.ts.map +0 -1
- package/dist/components/toggle.js +0 -49
- package/dist/components/tooltip.d.ts +0 -15
- package/dist/components/tooltip.d.ts.map +0 -1
- package/dist/components/tooltip.js +0 -23
- package/dist/hooks/use-animated-value.d.ts.map +0 -1
- package/dist/hooks/use-animated-value.js +0 -71
- package/dist/hooks/use-copy-to-clipboard.d.ts.map +0 -1
- package/dist/hooks/use-copy-to-clipboard.js +0 -46
- package/dist/hooks/use-is-mobile.d.ts.map +0 -1
- package/dist/hooks/use-is-mobile.js +0 -23
- package/dist/hooks/use-media-query.d.ts.map +0 -1
- package/dist/hooks/use-media-query.js +0 -53
- package/dist/hooks/use-mutation-observer.d.ts.map +0 -1
- package/dist/hooks/use-mutation-observer.js +0 -40
- package/dist/hooks/use-pagination.d.ts +0 -37
- package/dist/hooks/use-pagination.d.ts.map +0 -1
- package/dist/hooks/use-pagination.js +0 -107
- package/dist/index.d.ts +0 -131
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -68
- package/dist/lib/utils.d.ts +0 -10
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js +0 -10
- package/dist/primitives/checkbox-group.d.ts +0 -123
- package/dist/primitives/checkbox-group.d.ts.map +0 -1
- package/dist/primitives/checkbox-group.js +0 -112
- package/dist/primitives/input-number.d.ts +0 -63
- package/dist/primitives/input-number.d.ts.map +0 -1
- package/dist/primitives/input-number.js +0 -458
- package/dist/primitives/input.d.ts +0 -67
- package/dist/primitives/input.d.ts.map +0 -1
- package/dist/primitives/input.js +0 -76
- package/dist/primitives/progress-circle.d.ts +0 -116
- package/dist/primitives/progress-circle.d.ts.map +0 -1
- package/dist/primitives/progress-circle.js +0 -163
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import * as _$_radix_ui_react_context0 from "@radix-ui/react-context";
|
|
3
|
+
import { Scope } from "@radix-ui/react-context";
|
|
4
|
+
|
|
5
|
+
//#region src/primitives/progress-circle.d.ts
|
|
6
|
+
type ScopedProps<P> = P & {
|
|
7
|
+
__scopeProgressCircle?: Scope;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Defines color thresholds based on progress values
|
|
11
|
+
*/
|
|
12
|
+
interface Threshold {
|
|
13
|
+
/**
|
|
14
|
+
* Background color to be applied
|
|
15
|
+
*/
|
|
16
|
+
background: string;
|
|
17
|
+
/**
|
|
18
|
+
* Foreground color to be applied
|
|
19
|
+
*/
|
|
20
|
+
color: string;
|
|
21
|
+
/**
|
|
22
|
+
* The value at which this threshold becomes active
|
|
23
|
+
*/
|
|
24
|
+
value: number;
|
|
25
|
+
}
|
|
26
|
+
declare const createProgressCircleScope: _$_radix_ui_react_context0.CreateScope;
|
|
27
|
+
interface ProgressCircleProviderProps {
|
|
28
|
+
/** React children to be rendered inside the progress circle */
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
/** Custom function to format the numeric value for display */
|
|
31
|
+
formatValue?: (value: number) => string;
|
|
32
|
+
/** Unique identifier for the progress circle component */
|
|
33
|
+
id?: string;
|
|
34
|
+
/** Maximum value of the progress (defaults to 100) */
|
|
35
|
+
max?: number;
|
|
36
|
+
/** Minimum value of the progress (defaults to 0) */
|
|
37
|
+
min?: number;
|
|
38
|
+
/** Size of the progress circle in pixels */
|
|
39
|
+
size?: number;
|
|
40
|
+
/** Starting angle of the progress circle in degrees (0 = top) */
|
|
41
|
+
startAngle?: number;
|
|
42
|
+
/** Width of the progress circle's stroke in pixels */
|
|
43
|
+
strokeWidth?: number;
|
|
44
|
+
/** Array of threshold configurations for different value ranges */
|
|
45
|
+
thresholds?: Threshold[];
|
|
46
|
+
/** Current progress value (null for indeterminate state) */
|
|
47
|
+
value?: null | number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Provides context for the ProgressCircle component
|
|
51
|
+
*
|
|
52
|
+
* Manages calculations for rendering the circular progress indicator,
|
|
53
|
+
* including value clamping, sizing, thresholds, and indeterminate state.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <ProgressCircleProvider
|
|
58
|
+
* value={75}
|
|
59
|
+
* min={0}
|
|
60
|
+
* max={100}
|
|
61
|
+
* size={64}
|
|
62
|
+
* thresholds={[
|
|
63
|
+
* { value: 30, color: 'red', background: 'pink' },
|
|
64
|
+
* { value: 70, color: 'yellow', background: 'lightyellow' },
|
|
65
|
+
* { value: 100, color: 'green', background: 'lightgreen' }
|
|
66
|
+
* ]}
|
|
67
|
+
* >
|
|
68
|
+
* <ProgressCircleSVG>
|
|
69
|
+
* <ProgressCircleIndicator />
|
|
70
|
+
* <ProgressCircleTrack />
|
|
71
|
+
* </ProgressCircleSVG>
|
|
72
|
+
* <ProgressCircleValue />
|
|
73
|
+
* </ProgressCircleProvider>
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function ProgressCircleProvider({
|
|
77
|
+
__scopeProgressCircle,
|
|
78
|
+
children,
|
|
79
|
+
formatValue,
|
|
80
|
+
id: propertyId,
|
|
81
|
+
max,
|
|
82
|
+
min,
|
|
83
|
+
size,
|
|
84
|
+
startAngle,
|
|
85
|
+
strokeWidth,
|
|
86
|
+
thresholds,
|
|
87
|
+
value
|
|
88
|
+
}: ScopedProps<ProgressCircleProviderProps>): ReactNode;
|
|
89
|
+
type ProgressCircleProps = ComponentProps<"div">;
|
|
90
|
+
/**
|
|
91
|
+
* Root component for the progress circle
|
|
92
|
+
*
|
|
93
|
+
* Serves as a wrapper for other progress circle components.
|
|
94
|
+
*/
|
|
95
|
+
declare function ProgressCircle({
|
|
96
|
+
__scopeProgressCircle,
|
|
97
|
+
...props
|
|
98
|
+
}: ScopedProps<ProgressCircleProps>): ReactNode;
|
|
99
|
+
type ProgressCircleSVGProps = ComponentProps<"svg">;
|
|
100
|
+
/**
|
|
101
|
+
* SVG container for the progress circle
|
|
102
|
+
*
|
|
103
|
+
* Renders the SVG with accessibility attributes and supports indeterminate state.
|
|
104
|
+
*/
|
|
105
|
+
declare function ProgressCircleSVG({
|
|
106
|
+
__scopeProgressCircle,
|
|
107
|
+
...props
|
|
108
|
+
}: ScopedProps<ProgressCircleSVGProps>): ReactNode;
|
|
109
|
+
type ProgressCircleTrackProps = ComponentProps<"circle">;
|
|
110
|
+
/**
|
|
111
|
+
* Background circle for the progress indicator
|
|
112
|
+
*
|
|
113
|
+
* Renders the static track of the progress circle.
|
|
114
|
+
*/
|
|
115
|
+
declare function ProgressCircleTrack({
|
|
116
|
+
__scopeProgressCircle,
|
|
117
|
+
...props
|
|
118
|
+
}: ScopedProps<ProgressCircleTrackProps>): ReactNode;
|
|
119
|
+
type ProgressCircleIndicatorProps = ComponentProps<"circle">;
|
|
120
|
+
/**
|
|
121
|
+
* Foreground circle showing progress
|
|
122
|
+
*
|
|
123
|
+
* Renders the dynamic progress indicator with stroke dash properties.
|
|
124
|
+
*/
|
|
125
|
+
declare function ProgressCircleIndicator({
|
|
126
|
+
__scopeProgressCircle,
|
|
127
|
+
...props
|
|
128
|
+
}: ScopedProps<ProgressCircleIndicatorProps>): ReactNode;
|
|
129
|
+
interface ProgressCircleValueProps extends Omit<ComponentProps<"div">, "children"> {
|
|
130
|
+
children?: ((context: {
|
|
131
|
+
value: number | undefined;
|
|
132
|
+
valueText: string;
|
|
133
|
+
}) => ReactNode) | ReactNode;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Displays the current progress value
|
|
137
|
+
*
|
|
138
|
+
* Supports custom content or default value text rendering.
|
|
139
|
+
*/
|
|
140
|
+
declare function ProgressCircleValue({
|
|
141
|
+
__scopeProgressCircle,
|
|
142
|
+
children,
|
|
143
|
+
...props
|
|
144
|
+
}: ScopedProps<ProgressCircleValueProps>): ReactNode;
|
|
145
|
+
//#endregion
|
|
146
|
+
export { ProgressCircleIndicator as Indicator, ProgressCircleIndicator, ProgressCircle, ProgressCircle as Root, type ProgressCircleIndicatorProps, type ProgressCircleProps, ProgressCircleProvider, ProgressCircleProvider as Provider, type ProgressCircleProviderProps, ProgressCircleSVG, ProgressCircleSVG as SVG, type ProgressCircleSVGProps, ProgressCircleTrack, ProgressCircleTrack as Track, type ProgressCircleTrackProps, ProgressCircleValue, ProgressCircleValue as Value, type ProgressCircleValueProps, createProgressCircleScope };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useMemo } from "react";
|
|
4
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
5
|
+
//#region src/primitives/progress-circle.tsx
|
|
6
|
+
const PROGRESS_CIRCLE_PROVIDER_NAME = "ProgressCircleProvider";
|
|
7
|
+
const [createProgressCircleContext, createProgressCircleScope] = createContextScope(PROGRESS_CIRCLE_PROVIDER_NAME);
|
|
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
|
+
*/
|
|
36
|
+
function ProgressCircleProvider({ __scopeProgressCircle, children, formatValue, id: propertyId, max = 100, min = 0, size = 48, startAngle = -90, strokeWidth = 4, thresholds, value }) {
|
|
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
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Root component for the progress circle
|
|
81
|
+
*
|
|
82
|
+
* Serves as a wrapper for other progress circle components.
|
|
83
|
+
*/
|
|
84
|
+
function ProgressCircle({ __scopeProgressCircle, ...props }) {
|
|
85
|
+
return /* @__PURE__ */ jsx("div", { ...props });
|
|
86
|
+
}
|
|
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
|
+
*/
|
|
93
|
+
function ProgressCircleSVG({ __scopeProgressCircle, ...props }) {
|
|
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
|
+
});
|
|
108
|
+
}
|
|
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
|
+
*/
|
|
115
|
+
function ProgressCircleTrack({ __scopeProgressCircle, ...props }) {
|
|
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
|
+
});
|
|
126
|
+
}
|
|
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
|
+
*/
|
|
133
|
+
function ProgressCircleIndicator({ __scopeProgressCircle, ...props }) {
|
|
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
|
+
});
|
|
148
|
+
}
|
|
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
|
+
*/
|
|
155
|
+
function ProgressCircleValue({ __scopeProgressCircle, children, ...props }) {
|
|
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
|
+
});
|
|
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
|
+
*/
|
|
174
|
+
function clamp(min, max, value) {
|
|
175
|
+
return Math.min(max, Math.max(min, value));
|
|
176
|
+
}
|
|
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 };
|