@ngrok/mantle 0.66.0 → 0.66.2
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/dist/accordion.d.ts +158 -154
- package/dist/accordion.js +1 -1
- package/dist/accordion.js.map +1 -1
- package/dist/alert-dialog.d.ts +282 -277
- package/dist/alert-dialog.js +1 -1
- package/dist/alert-dialog.js.map +1 -1
- package/dist/alert.d.ts +145 -138
- package/dist/alert.js +1 -1
- package/dist/alert.js.map +1 -1
- package/dist/anchor.d.ts +25 -22
- package/dist/anchor.js +1 -1
- package/dist/anchor.js.map +1 -1
- package/dist/as-child-XMVTepJu.d.ts +31 -0
- package/dist/badge.d.ts +29 -19
- package/dist/badge.js +1 -1
- package/dist/badge.js.map +1 -1
- package/dist/booleanish-CBGdPL3Q.js +2 -0
- package/dist/booleanish-CBGdPL3Q.js.map +1 -0
- package/dist/browser-only-QPyyfLaB.js +2 -0
- package/dist/browser-only-QPyyfLaB.js.map +1 -0
- package/dist/browser-only.d.ts +20 -15
- package/dist/browser-only.js +1 -2
- package/dist/button-B6StZJsz.d.ts +175 -0
- package/dist/button-CRRPesae.js +2 -0
- package/dist/button-CRRPesae.js.map +1 -0
- package/dist/button-DA2p0_5F.js +2 -0
- package/dist/button-DA2p0_5F.js.map +1 -0
- package/dist/button.d.ts +4 -9
- package/dist/button.js +1 -2
- package/dist/calendar.d.ts +14 -8
- package/dist/calendar.js +1 -1
- package/dist/calendar.js.map +1 -1
- package/dist/card.d.ts +99 -97
- package/dist/card.js +1 -1
- package/dist/card.js.map +1 -1
- package/dist/checkbox.d.ts +14 -12
- package/dist/checkbox.js +1 -1
- package/dist/checkbox.js.map +1 -1
- package/dist/code-block.d.ts +254 -237
- package/dist/code-block.js +3 -3
- package/dist/code-block.js.map +1 -1
- package/dist/code.d.ts +5 -3
- package/dist/code.js +1 -1
- package/dist/code.js.map +1 -1
- package/dist/color.d.ts +2 -38
- package/dist/color.js +1 -1
- package/dist/color.js.map +1 -1
- package/dist/combobox.d.ts +172 -167
- package/dist/combobox.js +1 -1
- package/dist/combobox.js.map +1 -1
- package/dist/command.d.ts +234 -227
- package/dist/command.js +1 -1
- package/dist/command.js.map +1 -1
- package/dist/compose-refs-DeIsFv68.js +2 -0
- package/dist/compose-refs-DeIsFv68.js.map +1 -0
- package/dist/cx-bKromGBh.js +2 -0
- package/dist/cx-bKromGBh.js.map +1 -0
- package/dist/cx.d.ts +4 -2
- package/dist/cx.js +1 -2
- package/dist/data-table.d.ts +211 -184
- package/dist/data-table.js +1 -1
- package/dist/data-table.js.map +1 -1
- package/dist/deep-non-nullable-BLM3Gz0I.d.ts +8 -0
- package/dist/description-list.d.ts +61 -59
- package/dist/description-list.js +1 -1
- package/dist/description-list.js.map +1 -1
- package/dist/dialog-BuD_JQf_.d.ts +422 -0
- package/dist/dialog-Cr5u0Eai.js +2 -0
- package/dist/dialog-Cr5u0Eai.js.map +1 -0
- package/dist/dialog.d.ts +3 -410
- package/dist/dialog.js +1 -2
- package/dist/direction-DfrtFTny.js +2 -0
- package/dist/direction-DfrtFTny.js.map +1 -0
- package/dist/{direction-DHheuUag.d.ts → direction-deXpJFDZ.d.ts} +9 -7
- package/dist/dropdown-menu-CjOaj-Ap.js +2 -0
- package/dist/dropdown-menu-CjOaj-Ap.js.map +1 -0
- package/dist/dropdown-menu-D_ZoY1AH.d.ts +330 -0
- package/dist/dropdown-menu.d.ts +2 -325
- package/dist/dropdown-menu.js +1 -2
- package/dist/flag.d.ts +31 -22
- package/dist/flag.js +1 -1
- package/dist/flag.js.map +1 -1
- package/dist/hooks.d.ts +72 -59
- package/dist/hooks.js +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/hover-card.d.ts +97 -91
- package/dist/hover-card.js +1 -1
- package/dist/hover-card.js.map +1 -1
- package/dist/{icon-DXTMiV1L.d.ts → icon-B1XLv02t.d.ts} +11 -9
- package/dist/icon-B5oNYYrJ.js +2 -0
- package/dist/icon-B5oNYYrJ.js.map +1 -0
- package/dist/icon-button-2r6S3HVA.d.ts +98 -0
- package/dist/icon-button-D4e9-dq-.js +2 -0
- package/dist/icon-button-D4e9-dq-.js.map +1 -0
- package/dist/icon.d.ts +4 -4
- package/dist/icon.js +1 -2
- package/dist/icons.d.ts +54 -41
- package/dist/icons.js +1 -1
- package/dist/icons.js.map +1 -1
- package/dist/{in-view-aHeQHaUj.d.ts → in-view-CTQRT44m.d.ts} +29 -22
- package/dist/in-view-bPnaWEL4.js +2 -0
- package/dist/in-view-bPnaWEL4.js.map +1 -0
- package/dist/index-BLCvtjLi.d.ts +40 -0
- package/dist/index-DWqhfw9n.d.ts +103 -0
- package/dist/{button-group-BFnqgdtl.d.ts → index-ViSCOUrU.d.ts} +10 -8
- package/dist/index-s8rMcilU.d.ts +47 -0
- package/dist/input.d.ts +3 -100
- package/dist/input.js +1 -1
- package/dist/input.js.map +1 -1
- package/dist/is-input-BFR8yMM7.js +2 -0
- package/dist/is-input-BFR8yMM7.js.map +1 -0
- package/dist/kbd-pyj32aN4.js +2 -0
- package/dist/kbd-pyj32aN4.js.map +1 -0
- package/dist/kbd.d.ts +10 -4
- package/dist/kbd.js +1 -2
- package/dist/label.d.ts +8 -6
- package/dist/label.js +1 -1
- package/dist/label.js.map +1 -1
- package/dist/media-object.d.ts +70 -68
- package/dist/media-object.js +1 -1
- package/dist/media-object.js.map +1 -1
- package/dist/multi-select.d.ts +226 -218
- package/dist/multi-select.js +1 -1
- package/dist/multi-select.js.map +1 -1
- package/dist/pagination.d.ts +168 -164
- package/dist/pagination.js +1 -1
- package/dist/pagination.js.map +1 -1
- package/dist/popover.d.ts +119 -117
- package/dist/popover.js +1 -1
- package/dist/popover.js.map +1 -1
- package/dist/primitive-Cath9ASB.js +2 -0
- package/dist/primitive-Cath9ASB.js.map +1 -0
- package/dist/primitive-tuHqhoRE.d.ts +16 -0
- package/dist/progress.d.ts +175 -150
- package/dist/progress.js +1 -1
- package/dist/progress.js.map +1 -1
- package/dist/radio-group.d.ts +246 -230
- package/dist/radio-group.js +1 -1
- package/dist/radio-group.js.map +1 -1
- package/dist/sandboxed-on-click.d.ts +36 -31
- package/dist/sandboxed-on-click.js +1 -1
- package/dist/sandboxed-on-click.js.map +1 -1
- package/dist/select-39Jfc1Cb.d.ts +265 -0
- package/dist/select-DZ2ztBkI.js +2 -0
- package/dist/select-DZ2ztBkI.js.map +1 -0
- package/dist/select.d.ts +2 -263
- package/dist/select.js +1 -2
- package/dist/separator-BcCNbHBg.js +2 -0
- package/dist/separator-BcCNbHBg.js.map +1 -0
- package/dist/separator.d.ts +28 -21
- package/dist/separator.js +1 -2
- package/dist/sheet.d.ts +319 -305
- package/dist/sheet.js +1 -1
- package/dist/sheet.js.map +1 -1
- package/dist/skeleton.d.ts +8 -6
- package/dist/skeleton.js +1 -1
- package/dist/skeleton.js.map +1 -1
- package/dist/slider.d.ts +48 -35
- package/dist/slider.js +1 -1
- package/dist/slider.js.map +1 -1
- package/dist/slot-DdnjeV2n.js +2 -0
- package/dist/slot-DdnjeV2n.js.map +1 -0
- package/dist/slot.d.ts +6 -4
- package/dist/slot.js +1 -2
- package/dist/sort-CfPsu1Gs.js +2 -0
- package/dist/sort-CfPsu1Gs.js.map +1 -0
- package/dist/split-button.d.ts +158 -162
- package/dist/split-button.js +1 -1
- package/dist/split-button.js.map +1 -1
- package/dist/svg-only-BVLlbQ4e.js +2 -0
- package/dist/svg-only-BVLlbQ4e.js.map +1 -0
- package/dist/{svg-only-Cp8Mu_sh.d.ts → svg-only-Dti1FvNV.d.ts} +11 -9
- package/dist/switch.d.ts +10 -8
- package/dist/switch.js +1 -1
- package/dist/switch.js.map +1 -1
- package/dist/table-BWMp12sl.js +2 -0
- package/dist/table-BWMp12sl.js.map +1 -0
- package/dist/table-Dpt192qt.d.ts +398 -0
- package/dist/table.d.ts +2 -396
- package/dist/table.js +1 -2
- package/dist/tabs.d.ts +110 -104
- package/dist/tabs.js +1 -1
- package/dist/tabs.js.map +1 -1
- package/dist/text-area.d.ts +10 -8
- package/dist/text-area.js +1 -1
- package/dist/text-area.js.map +1 -1
- package/dist/theme-provider-C8F5nFrJ.js +2 -0
- package/dist/theme-provider-C8F5nFrJ.js.map +1 -0
- package/dist/theme.d.ts +66 -39
- package/dist/theme.js +1 -2
- package/dist/{themes-Bi46K9ZW.d.ts → themes-ClppRAGt.d.ts} +4 -2
- package/dist/toast-1AuBbrBS.js +2 -0
- package/dist/toast-1AuBbrBS.js.map +1 -0
- package/dist/toast.d.ts +95 -87
- package/dist/toast.js +1 -2
- package/dist/tooltip.d.ts +78 -73
- package/dist/tooltip.js +1 -1
- package/dist/tooltip.js.map +1 -1
- package/dist/{chunk-W2YQRWR5.js → traffic-policy-file-QnF-2YkY.js} +2 -2
- package/dist/traffic-policy-file-QnF-2YkY.js.map +1 -0
- package/dist/types-884RJJqm.js +2 -0
- package/dist/types-884RJJqm.js.map +1 -0
- package/dist/{types-DehRoXC5.d.ts → types-DgXUgkpc.d.ts} +38 -36
- package/dist/types-Dh4BVhXC.d.ts +9 -0
- package/dist/types.d.ts +6 -49
- package/dist/types.js +1 -2
- package/dist/use-copy-to-clipboard-BEbQOKHc.js +2 -0
- package/dist/use-copy-to-clipboard-BEbQOKHc.js.map +1 -0
- package/dist/use-matches-media-query-CojcYxlA.js +2 -0
- package/dist/use-matches-media-query-CojcYxlA.js.map +1 -0
- package/dist/use-prefers-reduced-motion-BiG6QGkf.js +2 -0
- package/dist/use-prefers-reduced-motion-BiG6QGkf.js.map +1 -0
- package/dist/utils.d.ts +6 -5
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/dist/variant-props-UE-phTwh.d.ts +13 -0
- package/dist/with-style-props-D1QFTzj6.d.ts +29 -0
- package/package.json +6 -6
- package/dist/as-child-DJ7x3JFV.d.ts +0 -21
- package/dist/browser-only.js.map +0 -1
- package/dist/button-DLUUf_c-.d.ts +0 -173
- package/dist/button.js.map +0 -1
- package/dist/chunk-2FYR6IJV.js +0 -2
- package/dist/chunk-2FYR6IJV.js.map +0 -1
- package/dist/chunk-5VDCC3YW.js +0 -2
- package/dist/chunk-5VDCC3YW.js.map +0 -1
- package/dist/chunk-63ZAW25Z.js +0 -2
- package/dist/chunk-63ZAW25Z.js.map +0 -1
- package/dist/chunk-6J7D73WA.js +0 -2
- package/dist/chunk-6J7D73WA.js.map +0 -1
- package/dist/chunk-72TJUKMV.js +0 -1
- package/dist/chunk-72TJUKMV.js.map +0 -1
- package/dist/chunk-7MJQGBE4.js +0 -2
- package/dist/chunk-7MJQGBE4.js.map +0 -1
- package/dist/chunk-7YLII2US.js +0 -2
- package/dist/chunk-7YLII2US.js.map +0 -1
- package/dist/chunk-ADF5DAYG.js +0 -2
- package/dist/chunk-ADF5DAYG.js.map +0 -1
- package/dist/chunk-CBRSMQ26.js +0 -2
- package/dist/chunk-CBRSMQ26.js.map +0 -1
- package/dist/chunk-COQIVAQH.js +0 -2
- package/dist/chunk-COQIVAQH.js.map +0 -1
- package/dist/chunk-ELZLLG6G.js +0 -2
- package/dist/chunk-ELZLLG6G.js.map +0 -1
- package/dist/chunk-EVU5XGB4.js +0 -2
- package/dist/chunk-EVU5XGB4.js.map +0 -1
- package/dist/chunk-EYZYDUS2.js +0 -2
- package/dist/chunk-EYZYDUS2.js.map +0 -1
- package/dist/chunk-HKSO72E5.js +0 -2
- package/dist/chunk-HKSO72E5.js.map +0 -1
- package/dist/chunk-HL2HWYKP.js +0 -2
- package/dist/chunk-HL2HWYKP.js.map +0 -1
- package/dist/chunk-IVQ626TU.js +0 -2
- package/dist/chunk-IVQ626TU.js.map +0 -1
- package/dist/chunk-JQ5D5YZR.js +0 -2
- package/dist/chunk-JQ5D5YZR.js.map +0 -1
- package/dist/chunk-LBO5LEYM.js +0 -2
- package/dist/chunk-LBO5LEYM.js.map +0 -1
- package/dist/chunk-MLXONRJD.js +0 -2
- package/dist/chunk-MLXONRJD.js.map +0 -1
- package/dist/chunk-OHPGAB7U.js +0 -2
- package/dist/chunk-OHPGAB7U.js.map +0 -1
- package/dist/chunk-OP6JMBKJ.js +0 -2
- package/dist/chunk-OP6JMBKJ.js.map +0 -1
- package/dist/chunk-PFXFESEN.js +0 -2
- package/dist/chunk-PFXFESEN.js.map +0 -1
- package/dist/chunk-PNL7JOXI.js +0 -2
- package/dist/chunk-PNL7JOXI.js.map +0 -1
- package/dist/chunk-RED6SFAV.js +0 -2
- package/dist/chunk-RED6SFAV.js.map +0 -1
- package/dist/chunk-SBQHQ2SJ.js +0 -2
- package/dist/chunk-SBQHQ2SJ.js.map +0 -1
- package/dist/chunk-SGGOH2WW.js +0 -2
- package/dist/chunk-SGGOH2WW.js.map +0 -1
- package/dist/chunk-W2YQRWR5.js.map +0 -1
- package/dist/chunk-W5A5HSFE.js +0 -2
- package/dist/chunk-W5A5HSFE.js.map +0 -1
- package/dist/chunk-YPAUKPCE.js +0 -2
- package/dist/chunk-YPAUKPCE.js.map +0 -1
- package/dist/cx.js.map +0 -1
- package/dist/deep-non-nullable-SmpSvoSd.d.ts +0 -8
- package/dist/dialog.js.map +0 -1
- package/dist/dropdown-menu.js.map +0 -1
- package/dist/icon-button-CT71Ti9V.d.ts +0 -96
- package/dist/icon.js.map +0 -1
- package/dist/kbd.js.map +0 -1
- package/dist/primitive-CBR_XmVa.d.ts +0 -14
- package/dist/select.js.map +0 -1
- package/dist/separator.js.map +0 -1
- package/dist/slot.js.map +0 -1
- package/dist/table.js.map +0 -1
- package/dist/theme.js.map +0 -1
- package/dist/toast.js.map +0 -1
- package/dist/types-BuKAGhC-.d.ts +0 -7
- package/dist/types.js.map +0 -1
- package/dist/variant-props-oDo2u-We.d.ts +0 -11
- package/dist/with-style-props-VnLWm0Yd.d.ts +0 -27
package/dist/progress.d.ts
CHANGED
|
@@ -1,47 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import * as ProgressPrimitive from
|
|
1
|
+
import { ComponentProps, HTMLAttributes } from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import * as ProgressPrimitive from "@radix-ui/react-progress";
|
|
4
4
|
|
|
5
|
+
//#region src/components/progress/types.d.ts
|
|
5
6
|
type ValueType = number | "indeterminate";
|
|
6
|
-
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/components/progress/progress-donut.d.ts
|
|
7
9
|
type RemValue = `${number}rem`;
|
|
8
10
|
type StrokeWidth = number | RemValue;
|
|
9
11
|
type SvgAttributes = Omit<HTMLAttributes<SVGElement>, "viewBox" | "role" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "width" | "height">;
|
|
10
12
|
type Props = SvgAttributes & {
|
|
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
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The maximum value of the progress bar.
|
|
15
|
+
* This attribute describes how much work the task indicated by the progress element requires.
|
|
16
|
+
* The max attribute, if present, must have a value greater than 0. The default value is 100.
|
|
17
|
+
*
|
|
18
|
+
* @default 100
|
|
19
|
+
*/
|
|
20
|
+
max?: number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The width of the progress bar stroke.
|
|
23
|
+
* Note, we clamp the stroke width to a minimum of 1px and max of 12px since
|
|
24
|
+
* it is proportional to the viewbox size (0 0 32 32).
|
|
25
|
+
*
|
|
26
|
+
* @default 0.25rem (4px)
|
|
27
|
+
*/
|
|
28
|
+
strokeWidth?: StrokeWidth;
|
|
29
|
+
/**
|
|
30
|
+
* The current value of the progress bar.
|
|
31
|
+
* This attribute specifies how much of the task that has been completed.
|
|
32
|
+
* It must be a valid floating point number between 0 and max, or between 0 and 100 if max is omitted.
|
|
33
|
+
* If set to `"indeterminate"`, the progress bar is considered indeterminate.
|
|
34
|
+
*
|
|
35
|
+
* @default 0
|
|
36
|
+
*/
|
|
37
|
+
value?: ValueType | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Controls the rotation speed of the indeterminate spinner state.
|
|
40
|
+
*
|
|
41
|
+
* Accepts a Tailwind `animation-duration-*` utility (e.g. `animation-duration-[2s]`).
|
|
42
|
+
*
|
|
43
|
+
* This prop is applied in addition to `animate-spin` to control the speed of the indeterminate spinner.
|
|
44
|
+
* @default `animation-duration-[15s]`
|
|
45
|
+
*/
|
|
46
|
+
indeterminateRotationSpeed?: `animation-duration-${string}`;
|
|
45
47
|
};
|
|
46
48
|
type ProgressDonutIndicatorProps = Omit<ComponentProps<"g">, "children">;
|
|
47
49
|
/**
|
|
@@ -64,69 +66,81 @@ type ProgressDonutIndicatorProps = Omit<ComponentProps<"g">, "children">;
|
|
|
64
66
|
* ```
|
|
65
67
|
*/
|
|
66
68
|
declare const ProgressDonut: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
69
|
+
/**
|
|
70
|
+
* A simple circular progress bar which shows the completion progress of a task.
|
|
71
|
+
*
|
|
72
|
+
* The indicator color is inherited via `currentColor`. Override the default
|
|
73
|
+
* (`accent-600`) by setting the `ProgressDonut.Indicator`'s text color.
|
|
74
|
+
*
|
|
75
|
+
* @see https://mantle.ngrok.com/components/progress#api-progress-donut-root
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* <ProgressDonut.Root value={60}>
|
|
80
|
+
* <ProgressDonut.Indicator />
|
|
81
|
+
* </ProgressDonut.Root>
|
|
82
|
+
*
|
|
83
|
+
* <ProgressDonut.Root value={60}>
|
|
84
|
+
* <ProgressDonut.Indicator color="text-danger-600" />
|
|
85
|
+
* </ProgressDonut.Root>
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
readonly Root: {
|
|
89
|
+
({
|
|
90
|
+
children,
|
|
91
|
+
className,
|
|
92
|
+
max: _max,
|
|
93
|
+
strokeWidth: _strokeWidth,
|
|
94
|
+
value: _value,
|
|
95
|
+
indeterminateRotationSpeed,
|
|
96
|
+
...props
|
|
97
|
+
}: Props): react_jsx_runtime0.JSX.Element;
|
|
98
|
+
displayName: string;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* The indicator for the circular progress bar.
|
|
102
|
+
*
|
|
103
|
+
* @see https://mantle.ngrok.com/components/progress#api-progress-donut-indicator
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* <ProgressDonut.Root value={60}>
|
|
108
|
+
* <ProgressDonut.Indicator />
|
|
109
|
+
* </ProgressDonut.Root>
|
|
110
|
+
*
|
|
111
|
+
* <ProgressDonut.Root value={60}>
|
|
112
|
+
* <ProgressDonut.Indicator color="text-danger-600" />
|
|
113
|
+
* </ProgressDonut.Root>
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
readonly Indicator: {
|
|
117
|
+
({
|
|
118
|
+
className,
|
|
119
|
+
...props
|
|
120
|
+
}: ProgressDonutIndicatorProps): react_jsx_runtime0.JSX.Element;
|
|
121
|
+
displayName: string;
|
|
122
|
+
};
|
|
110
123
|
};
|
|
111
|
-
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/components/progress/progress-bar.d.ts
|
|
112
126
|
type RootProps = ComponentProps<"div"> & {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
/**
|
|
128
|
+
* The maximum value of the progress bar.
|
|
129
|
+
* This attribute describes how much work the task indicated by the progress element requires.
|
|
130
|
+
* The max attribute, if present, must have a value greater than 0. The default value is 100.
|
|
131
|
+
*
|
|
132
|
+
* @default 100
|
|
133
|
+
*/
|
|
134
|
+
max?: number | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* The current value of the progress bar.
|
|
137
|
+
* This attribute specifies how much of the task that has been completed.
|
|
138
|
+
* It must be a valid floating point number between 0 and max, or between 0 and 100 if max is omitted.
|
|
139
|
+
* If set to `"indeterminate"`, the progress bar is considered indeterminate. (for now there is no visual difference than 0)
|
|
140
|
+
*
|
|
141
|
+
* @default 0
|
|
142
|
+
*/
|
|
143
|
+
value?: ValueType | undefined;
|
|
130
144
|
};
|
|
131
145
|
/**
|
|
132
146
|
* Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
|
|
@@ -152,9 +166,15 @@ type RootProps = ComponentProps<"div"> & {
|
|
|
152
166
|
* </ProgressBar.Root>
|
|
153
167
|
* ```
|
|
154
168
|
*/
|
|
155
|
-
declare function Root({
|
|
169
|
+
declare function Root({
|
|
170
|
+
className,
|
|
171
|
+
children,
|
|
172
|
+
max: _max,
|
|
173
|
+
value: _value,
|
|
174
|
+
...props
|
|
175
|
+
}: RootProps): react_jsx_runtime0.JSX.Element;
|
|
156
176
|
declare namespace Root {
|
|
157
|
-
|
|
177
|
+
var displayName: string;
|
|
158
178
|
}
|
|
159
179
|
type IndicatorProps = ComponentProps<typeof ProgressPrimitive.Indicator>;
|
|
160
180
|
/**
|
|
@@ -177,9 +197,13 @@ type IndicatorProps = ComponentProps<typeof ProgressPrimitive.Indicator>;
|
|
|
177
197
|
* </ProgressBar.Root>
|
|
178
198
|
* ```
|
|
179
199
|
*/
|
|
180
|
-
declare function Indicator({
|
|
200
|
+
declare function Indicator({
|
|
201
|
+
className,
|
|
202
|
+
style,
|
|
203
|
+
...props
|
|
204
|
+
}: IndicatorProps): react_jsx_runtime0.JSX.Element;
|
|
181
205
|
declare namespace Indicator {
|
|
182
|
-
|
|
206
|
+
var displayName: string;
|
|
183
207
|
}
|
|
184
208
|
/**
|
|
185
209
|
* Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
|
|
@@ -206,52 +230,53 @@ declare namespace Indicator {
|
|
|
206
230
|
* ```
|
|
207
231
|
*/
|
|
208
232
|
declare const ProgressBar: {
|
|
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
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.
|
|
235
|
+
*
|
|
236
|
+
* A horizontal progress bar that shows the completion progress of a task.
|
|
237
|
+
* Use this component for linear progress indication.
|
|
238
|
+
*
|
|
239
|
+
* @see https://mantle.ngrok.com/components/progress#api-progress-bar
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```tsx
|
|
243
|
+
* <ProgressBar.Root value={60}>
|
|
244
|
+
* <ProgressBar.Indicator />
|
|
245
|
+
* </ProgressBar.Root>
|
|
246
|
+
*
|
|
247
|
+
* <ProgressBar.Root value={75} max={100}>
|
|
248
|
+
* <ProgressBar.Indicator />
|
|
249
|
+
* </ProgressBar.Root>
|
|
250
|
+
*
|
|
251
|
+
* // Indeterminate progress
|
|
252
|
+
* <ProgressBar.Root value="indeterminate">
|
|
253
|
+
* <ProgressBar.Indicator />
|
|
254
|
+
* </ProgressBar.Root>
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
readonly Root: typeof Root;
|
|
258
|
+
/**
|
|
259
|
+
* Displays the progress indicator, which visually represents the completion progress of a task.
|
|
260
|
+
*
|
|
261
|
+
* The visual indicator that shows the actual progress within the progress bar.
|
|
262
|
+
* This component should be used inside a ProgressBar.Root component.
|
|
263
|
+
*
|
|
264
|
+
* @see https://mantle.ngrok.com/components/progress#api-progress-bar-indicator
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```tsx
|
|
268
|
+
* <ProgressBar.Root value={60}>
|
|
269
|
+
* <ProgressBar.Indicator />
|
|
270
|
+
* </ProgressBar.Root>
|
|
271
|
+
*
|
|
272
|
+
* // Custom styled indicator
|
|
273
|
+
* <ProgressBar.Root value={60}>
|
|
274
|
+
* <ProgressBar.Indicator className="bg-success-600" />
|
|
275
|
+
* </ProgressBar.Root>
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
readonly Indicator: typeof Indicator;
|
|
255
279
|
};
|
|
256
|
-
|
|
280
|
+
//#endregion
|
|
257
281
|
export { ProgressBar, ProgressDonut };
|
|
282
|
+
//# sourceMappingURL=progress.d.ts.map
|
package/dist/progress.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"./cx-bKromGBh.js";import{createContext as t,useContext as n,useId as r,useMemo as i}from"react";import a from"clsx";import{jsx as o,jsxs as s}from"react/jsx-runtime";import*as c from"@radix-ui/react-progress";function l(e,{min:t,max:n}){return Math.min(n,Math.max(t,e))}function u(e){return typeof e==`number`}function d(e,t){return u(e)&&!Number.isNaN(e)&&e<=t&&e>=0}function f(e){return u(e)&&!Number.isNaN(e)&&e>0}const p={max:100,strokeWidth:`0.25rem`,value:0},m=t(p),h=({children:t,className:n,max:r=100,strokeWidth:a=4,value:c,indeterminateRotationSpeed:l,...h})=>{let g=f(r)?r:100,_=d(c,g)?c:c==null?0:`indeterminate`,b=v(a??p.strokeWidth),x=u(_)?_:void 0,S=y(b),C=i(()=>({max:g,strokeWidth:b,value:_}),[g,b,_]);return o(m.Provider,{value:C,children:s(`svg`,{"aria-valuemax":g,"aria-valuemin":0,"aria-valuenow":x,className:e(`size-6 text-gray-200 dark:text-gray-300`,_===`indeterminate`&&[`animate-spin`,l??`animation-duration-[15s]`],n),"data-max":g,"data-min":0,"data-value":x,height:`100%`,role:`progressbar`,width:`100%`,...h,children:[o(`circle`,{className:`[r:var(--radius)]`,cx:`50%`,cy:`50%`,fill:`transparent`,stroke:`currentColor`,strokeWidth:b,style:{"--radius":S}}),t]})})};h.displayName=`ProgressDonut`;const g=({className:t,...i})=>{let c=r(),l=n(m)??p,u=(l.value===`indeterminate`?.6:l.value/l.max)*100,d=v(l.strokeWidth),f=y(d);return s(`g`,{className:e(`text-accent-600`,t),...i,children:[l.value===`indeterminate`&&o(`defs`,{children:s(`linearGradient`,{id:c,children:[o(`stop`,{className:`stop-opacity-100 stop-color-current`,offset:`0%`}),o(`stop`,{className:`stop-opacity-0 stop-color-current`,offset:`95%`})]})}),o(`circle`,{className:a(`[r:var(--radius)]`,`origin-center`),cx:`50%`,cy:`50%`,fill:`transparent`,pathLength:100,stroke:l.value===`indeterminate`?`url(#${c})`:`currentColor`,strokeDasharray:100,strokeDashoffset:100-u,strokeLinecap:`round`,strokeWidth:d,style:{"--radius":f},transform:`rotate(-90)`})]})};g.displayName=`ProgressDonutIndicator`;const _={Root:h,Indicator:g};function v(e){let t=4;return e==null?t:(t=typeof e==`number`?e:e.endsWith(`rem`)?Number(e.replace(`rem`,``))*16:Number(e),l(Number.isNaN(t)?4:t,{min:1,max:12}))}function y(e){return`calc(50% - ${e/2}px)`}const b=t({max:100,value:0});function x({className:t,children:n,max:r=100,value:a,...s}){let l=f(r)?r:100,p=d(a,l)?a:a==null?0:`indeterminate`,m=u(p)?p:void 0,h=i(()=>({max:l,value:p}),[l,p]);return o(b.Provider,{value:h,children:o(c.Root,{"data-slot":`progress`,className:e(`bg-base-hover dark:bg-base shadow-inner relative h-3 w-full overflow-hidden rounded-md`,t),value:m,max:l,...s,children:n})})}x.displayName=`Root`;function S({className:t,style:r,...i}){let a=n(b),{max:s}=a,l=(s-(a.value===`indeterminate`?0:a.value))/s*100;return o(c.Indicator,{"data-slot":`progress-indicator`,className:e(`bg-accent-600 h-full w-full flex-1 transition-all`,t),style:{...r,transform:`translateX(-${l}%)`},...i})}S.displayName=`Indicator`;const C={Root:x,Indicator:S};export{C as ProgressBar,_ as ProgressDonut};
|
|
2
2
|
//# sourceMappingURL=progress.js.map
|
package/dist/progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/progress/progress-donut.tsx","../src/components/progress/math.ts","../src/components/progress/progress-bar.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { createContext, useContext, useId, useMemo } from \"react\";\nimport type { CSSProperties, ComponentProps, HTMLAttributes } from \"react\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { clamp, isNumber, isValidMaxNumber, isValidValueNumber } from \"./math.js\";\nimport type { ValueType } from \"./types.js\";\n\ntype RemValue = `${number}rem`;\ntype StrokeWidth = number | RemValue;\n\n/**\n * The default maximum value of the progress bar.\n */\nconst defaultMax = 100;\n\ntype ProgressContextValue = {\n\tmax: number;\n\tstrokeWidth: StrokeWidth;\n\tvalue: ValueType;\n};\n\nconst defaultContextValue = {\n\tmax: defaultMax,\n\tstrokeWidth: \"0.25rem\",\n\tvalue: 0,\n} as const satisfies ProgressContextValue;\n\nconst ProgressContext = createContext<ProgressContextValue>(defaultContextValue);\n\ntype SvgAttributes = Omit<\n\tHTMLAttributes<SVGElement>,\n\t\"viewBox\" | \"role\" | \"aria-valuemax\" | \"aria-valuemin\" | \"aria-valuenow\" | \"width\" | \"height\"\n>;\n\ntype Props = SvgAttributes & {\n\t/**\n\t * The maximum value of the progress bar.\n\t * This attribute describes how much work the task indicated by the progress element requires.\n\t * The max attribute, if present, must have a value greater than 0. The default value is 100.\n\t *\n\t * @default 100\n\t */\n\tmax?: number | undefined;\n\t/**\n\t * The width of the progress bar stroke.\n\t * Note, we clamp the stroke width to a minimum of 1px and max of 12px since\n\t * it is proportional to the viewbox size (0 0 32 32).\n\t *\n\t * @default 0.25rem (4px)\n\t */\n\tstrokeWidth?: StrokeWidth;\n\t/**\n\t * The current value of the progress bar.\n\t * This attribute specifies how much of the task that has been completed.\n\t * It must be a valid floating point number between 0 and max, or between 0 and 100 if max is omitted.\n\t * If set to `\"indeterminate\"`, the progress bar is considered indeterminate.\n\t *\n\t * @default 0\n\t */\n\tvalue?: ValueType | undefined;\n\t/**\n\t * Controls the rotation speed of the indeterminate spinner state.\n\t *\n\t * Accepts a Tailwind `animation-duration-*` utility (e.g. `animation-duration-[2s]`).\n\t *\n\t * This prop is applied in addition to `animate-spin` to control the speed of the indeterminate spinner.\n\t * @default `animation-duration-[15s]`\n\t */\n\tindeterminateRotationSpeed?: `animation-duration-${string}`;\n};\n\n/**\n * A simple circular progress bar which shows the completion progress of a task.\n *\n * The indicator color is inherited via `currentColor`. Override the default\n * (`accent-600`) by setting the `ProgressDonut.Indicator`'s text color.\n *\n * @see https://mantle.ngrok.com/components/progress#api-progress-donut\n *\n * @example\n * ```tsx\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator />\n * </ProgressDonut.Root>\n *\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator color=\"text-danger-600\" />\n * </ProgressDonut.Root>\n * ```\n */\nconst Root = ({\n\tchildren,\n\tclassName,\n\tmax: _max = defaultMax,\n\tstrokeWidth: _strokeWidth = 4,\n\tvalue: _value,\n\tindeterminateRotationSpeed,\n\t...props\n}: Props) => {\n\tconst max = isValidMaxNumber(_max) ? _max : defaultMax;\n\tconst value = (\n\t\tisValidValueNumber(_value, max) ? _value : _value == null ? 0 : \"indeterminate\"\n\t) satisfies ValueType;\n\tconst strokeWidthPx = deriveStrokeWidthPx(_strokeWidth ?? defaultContextValue.strokeWidth);\n\tconst valueNow = isNumber(value) ? value : undefined;\n\tconst radius = calcRadius(strokeWidthPx);\n\n\tconst ctx: ProgressContextValue = useMemo(\n\t\t() => ({\n\t\t\tmax,\n\t\t\tstrokeWidth: strokeWidthPx,\n\t\t\tvalue,\n\t\t}),\n\t\t[max, strokeWidthPx, value],\n\t);\n\n\treturn (\n\t\t<ProgressContext.Provider value={ctx}>\n\t\t\t{/* biome-ignore lint/a11y/useFocusableInteractive: progress bars don't need to be focusable */}\n\t\t\t<svg\n\t\t\t\taria-valuemax={max}\n\t\t\t\taria-valuemin={0}\n\t\t\t\taria-valuenow={valueNow}\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"size-6 text-gray-200 dark:text-gray-300\",\n\t\t\t\t\tvalue === \"indeterminate\" && [\n\t\t\t\t\t\t\"animate-spin\",\n\t\t\t\t\t\t// Default duration only if consumer hasn't set one.\n\t\t\t\t\t\t// Without this guard, both our `[15s]` and consumer overrides (e.g. `[2s]`)\n\t\t\t\t\t\t// end up in the DOM. Since tw-animate-css utilities aren't currently deduped by\n\t\t\t\t\t\t// tailwind-merge, whichever class Tailwind happened to emit last wins,\n\t\t\t\t\t\t// which isn't reliable.\n\t\t\t\t\t\tindeterminateRotationSpeed ?? \"animation-duration-[15s]\",\n\t\t\t\t\t],\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tdata-max={max}\n\t\t\t\tdata-min={0}\n\t\t\t\tdata-value={valueNow}\n\t\t\t\theight=\"100%\"\n\t\t\t\t// biome-ignore lint/a11y/noNoninteractiveElementToInteractiveRole: this is a radial progress bar, which is possible by SVG\n\t\t\t\trole=\"progressbar\"\n\t\t\t\twidth=\"100%\"\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<circle\n\t\t\t\t\tclassName=\"[r:var(--radius)]\"\n\t\t\t\t\tcx=\"50%\"\n\t\t\t\t\tcy=\"50%\"\n\t\t\t\t\tfill=\"transparent\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstrokeWidth={strokeWidthPx}\n\t\t\t\t\tstyle={{ \"--radius\": radius } as CSSProperties}\n\t\t\t\t/>\n\t\t\t\t{children}\n\t\t\t</svg>\n\t\t</ProgressContext.Provider>\n\t);\n};\nRoot.displayName = \"ProgressDonut\";\n\n/**\n * Length (value) of the progress indicator tail when the progress bar is indeterminate.\n */\nconst indeterminateTailPercent = 0.6;\n\ntype ProgressDonutIndicatorProps = Omit<ComponentProps<\"g\">, \"children\">;\n\n/**\n * The indicator for the circular progress bar.\n *\n * @see https://mantle.ngrok.com/components/progress#api-progress-donut-indicator\n *\n * @example\n * ```tsx\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator />\n * </ProgressDonut.Root>\n *\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator color=\"text-danger-600\" />\n * </ProgressDonut.Root>\n * ```\n */\nconst Indicator = ({ className, ...props }: ProgressDonutIndicatorProps) => {\n\tconst gradientId = useId();\n\tconst ctx = useContext(ProgressContext) ?? defaultContextValue;\n\tconst percentage =\n\t\t(ctx.value === \"indeterminate\" ? indeterminateTailPercent : ctx.value / ctx.max) * 100;\n\tconst strokeWidthPx = deriveStrokeWidthPx(ctx.strokeWidth);\n\tconst radius = calcRadius(strokeWidthPx);\n\n\treturn (\n\t\t<g className={cx(\"text-accent-600\", className)} {...props}>\n\t\t\t{ctx.value === \"indeterminate\" && (\n\t\t\t\t<defs>\n\t\t\t\t\t<linearGradient id={gradientId}>\n\t\t\t\t\t\t<stop className=\"stop-opacity-100 stop-color-current\" offset=\"0%\" />\n\t\t\t\t\t\t<stop className=\"stop-opacity-0 stop-color-current\" offset=\"95%\" />\n\t\t\t\t\t</linearGradient>\n\t\t\t\t</defs>\n\t\t\t)}\n\t\t\t<circle\n\t\t\t\tclassName={clsx(\n\t\t\t\t\t\"[r:var(--radius)]\", // set the circle radius to be the value of the calc'd CSS variable set on the style\n\t\t\t\t\t\"origin-center\",\n\t\t\t\t)}\n\t\t\t\tcx=\"50%\"\n\t\t\t\tcy=\"50%\"\n\t\t\t\tfill=\"transparent\"\n\t\t\t\tpathLength={100}\n\t\t\t\tstroke={ctx.value === \"indeterminate\" ? `url(#${gradientId})` : \"currentColor\"}\n\t\t\t\tstrokeDasharray={100}\n\t\t\t\tstrokeDashoffset={100 - percentage}\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeWidth={strokeWidthPx}\n\t\t\t\tstyle={{ \"--radius\": radius } as CSSProperties}\n\t\t\t\ttransform=\"rotate(-90)\" // rotate -90 degrees so it starts from the top\n\t\t\t/>\n\t\t</g>\n\t);\n};\nIndicator.displayName = \"ProgressDonutIndicator\";\n\n/**\n * A simple circular progress bar which shows the completion progress of a task.\n *\n * The indicator color is inherited via `currentColor`. Override the default\n * (`accent-600`) by setting the `ProgressDonut.Indicator`'s text color.\n *\n * @see https://mantle.ngrok.com/components/progress\n *\n * @example\n * ```tsx\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator />\n * </ProgressDonut.Root>\n *\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator color=\"text-danger-600\" />\n * </ProgressDonut.Root>\n * ```\n */\nconst ProgressDonut = {\n\t/**\n\t * A simple circular progress bar which shows the completion progress of a task.\n\t *\n\t * The indicator color is inherited via `currentColor`. Override the default\n\t * (`accent-600`) by setting the `ProgressDonut.Indicator`'s text color.\n\t *\n\t * @see https://mantle.ngrok.com/components/progress#api-progress-donut-root\n\t *\n\t * @example\n\t * ```tsx\n\t * <ProgressDonut.Root value={60}>\n\t * <ProgressDonut.Indicator />\n\t * </ProgressDonut.Root>\n\t *\n\t * <ProgressDonut.Root value={60}>\n\t * <ProgressDonut.Indicator color=\"text-danger-600\" />\n\t * </ProgressDonut.Root>\n\t * ```\n\t */\n\tRoot,\n\t/**\n\t * The indicator for the circular progress bar.\n\t *\n\t * @see https://mantle.ngrok.com/components/progress#api-progress-donut-indicator\n\t *\n\t * @example\n\t * ```tsx\n\t * <ProgressDonut.Root value={60}>\n\t * <ProgressDonut.Indicator />\n\t * </ProgressDonut.Root>\n\t *\n\t * <ProgressDonut.Root value={60}>\n\t * <ProgressDonut.Indicator color=\"text-danger-600\" />\n\t * </ProgressDonut.Root>\n\t * ```\n\t */\n\tIndicator,\n} as const;\n\nexport {\n\t//,\n\tProgressDonut,\n};\n\n/**\n * Derive the stroke width in pixels as a number value or pixels/rem from a string value.\n * Note, this function clamps the stroke width to a minimum of 1 and max of 12 since\n * it is proportional to the viewbox size (0 0 32 32).\n *\n * @example\n * ```tsx\n * const strokeWidth1 = deriveStrokeWidthPx(8);\n * // Returns: 8\n *\n * const strokeWidth2 = deriveStrokeWidthPx(\"0.5rem\");\n * // Returns: 8 (0.5 * 16)\n *\n * const strokeWidth3 = deriveStrokeWidthPx(20);\n * // Returns: 12 (clamped to maximum)\n * ```\n */\nexport function deriveStrokeWidthPx(strokeWidth: number | string | undefined | null): number {\n\tlet value = 4;\n\tif (strokeWidth == null) {\n\t\treturn value;\n\t}\n\n\tif (typeof strokeWidth === \"number\") {\n\t\tvalue = strokeWidth;\n\t} else if (strokeWidth.endsWith(\"rem\")) {\n\t\tvalue = Number(strokeWidth.replace(\"rem\", \"\")) * 16;\n\t} else {\n\t\tvalue = Number(strokeWidth);\n\t}\n\n\tconst stroke = Number.isNaN(value) ? 4 : value;\n\treturn clamp(stroke, { min: 1, max: 12 });\n}\n\n/**\n * Calculate the radius of the progress donut and indicator based on the stroke\n * width in pixels.\n */\nfunction calcRadius(strokeWidthPx: number) {\n\treturn `calc(50% - ${strokeWidthPx / 2}px)` as const;\n}\n","/**\n * Clamp a value between a minimum and maximum value.\n */\nfunction clamp(value: number, { min, max }: { min: number; max: number }): number {\n\treturn Math.min(max, Math.max(min, value));\n}\n\n/**\n * Check if a value is a number.\n */\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === \"number\";\n}\n\n/**\n * Check if a value is a valid number within the range of 0 to `max`.\n */\nfunction isValidValueNumber(value: unknown, max: number): value is number {\n\treturn isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;\n}\n\n/**\n * Check if a value is a valid number greater than 0.\n */\nfunction isValidMaxNumber(value: unknown): value is number {\n\treturn isNumber(value) && !Number.isNaN(value) && value > 0;\n}\n\nexport {\n\t//,\n\tclamp,\n\tisNumber,\n\tisValidValueNumber,\n\tisValidMaxNumber,\n};\n","\"use client\";\n\nimport * as ProgressPrimitive from \"@radix-ui/react-progress\";\n\nimport { type ComponentProps, createContext, useContext, useMemo } from \"react\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { isNumber, isValidMaxNumber, isValidValueNumber } from \"./math.js\";\nimport type { ValueType } from \"./types.js\";\n\n/**\n * The default maximum value of the progress bar.\n */\nconst defaultMax = 100;\n\ntype ProgressContextValue = {\n\tmax: number;\n\tvalue: ValueType;\n};\n\nconst defaultContextValue = {\n\tmax: defaultMax,\n\tvalue: 0,\n} as const satisfies ProgressContextValue;\n\nconst ProgressContext = createContext<ProgressContextValue>(defaultContextValue);\n\ntype RootProps = ComponentProps<\"div\"> & {\n\t/**\n\t * The maximum value of the progress bar.\n\t * This attribute describes how much work the task indicated by the progress element requires.\n\t * The max attribute, if present, must have a value greater than 0. The default value is 100.\n\t *\n\t * @default 100\n\t */\n\tmax?: number | undefined;\n\t/**\n\t * The current value of the progress bar.\n\t * This attribute specifies how much of the task that has been completed.\n\t * It must be a valid floating point number between 0 and max, or between 0 and 100 if max is omitted.\n\t * If set to `\"indeterminate\"`, the progress bar is considered indeterminate. (for now there is no visual difference than 0)\n\t *\n\t * @default 0\n\t */\n\tvalue?: ValueType | undefined;\n};\n\n/**\n * Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.\n *\n * A horizontal progress bar that shows the completion progress of a task.\n * Use this component for linear progress indication.\n *\n * @see https://mantle.ngrok.com/components/progress#api-progress-bar\n *\n * @example\n * ```tsx\n * <ProgressBar.Root value={60}>\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n *\n * <ProgressBar.Root value={75} max={100}>\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n *\n * // Indeterminate progress\n * <ProgressBar.Root value=\"indeterminate\">\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n * ```\n */\nfunction Root({ className, children, max: _max = defaultMax, value: _value, ...props }: RootProps) {\n\tconst max = isValidMaxNumber(_max) ? _max : defaultMax;\n\tconst value = (\n\t\tisValidValueNumber(_value, max) ? _value : _value == null ? 0 : \"indeterminate\"\n\t) satisfies ValueType;\n\n\tconst valueNow = isNumber(value) ? value : undefined;\n\n\tconst ctx: ProgressContextValue = useMemo(\n\t\t() => ({\n\t\t\tmax,\n\t\t\tvalue,\n\t\t}),\n\t\t[max, value],\n\t);\n\n\treturn (\n\t\t<ProgressContext.Provider value={ctx}>\n\t\t\t<ProgressPrimitive.Root\n\t\t\t\tdata-slot=\"progress\"\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"bg-base-hover dark:bg-base shadow-inner relative h-3 w-full overflow-hidden rounded-md\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tvalue={valueNow}\n\t\t\t\tmax={max}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</ProgressPrimitive.Root>\n\t\t</ProgressContext.Provider>\n\t);\n}\nRoot.displayName = \"Root\";\n\ntype IndicatorProps = ComponentProps<typeof ProgressPrimitive.Indicator>;\n\n/**\n * Displays the progress indicator, which visually represents the completion progress of a task.\n *\n * The visual indicator that shows the actual progress within the progress bar.\n * This component should be used inside a ProgressBar.Root component.\n *\n * @see https://mantle.ngrok.com/components/progress#api-progress-bar-indicator\n *\n * @example\n * ```tsx\n * <ProgressBar.Root value={60}>\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n *\n * // Custom styled indicator\n * <ProgressBar.Root value={60}>\n * <ProgressBar.Indicator className=\"bg-success-600\" />\n * </ProgressBar.Root>\n * ```\n */\nfunction Indicator({ className, style, ...props }: IndicatorProps) {\n\tconst ctx = useContext(ProgressContext);\n\tconst { max } = ctx;\n\tconst value = ctx.value === \"indeterminate\" ? 0 : ctx.value;\n\tconst translatePercent = ((max - value) / max) * 100;\n\n\treturn (\n\t\t<ProgressPrimitive.Indicator\n\t\t\tdata-slot=\"progress-indicator\"\n\t\t\tclassName={cx(\"bg-accent-600 h-full w-full flex-1 transition-all\", className)}\n\t\t\tstyle={{ ...style, transform: `translateX(-${translatePercent}%)` }}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\nIndicator.displayName = \"Indicator\";\n\n/**\n * Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.\n *\n * A horizontal progress bar that shows the completion progress of a task.\n * Use this component for linear progress indication.\n *\n * @see https://mantle.ngrok.com/components/progress\n *\n * @example\n * ```tsx\n * <ProgressBar.Root value={60}>\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n *\n * <ProgressBar.Root value={75} max={100}>\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n *\n * // Indeterminate progress\n * <ProgressBar.Root value=\"indeterminate\">\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n * ```\n */\nconst ProgressBar = {\n\t/**\n\t * Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.\n\t *\n\t * A horizontal progress bar that shows the completion progress of a task.\n\t * Use this component for linear progress indication.\n\t *\n\t * @see https://mantle.ngrok.com/components/progress#api-progress-bar\n\t *\n\t * @example\n\t * ```tsx\n\t * <ProgressBar.Root value={60}>\n\t * <ProgressBar.Indicator />\n\t * </ProgressBar.Root>\n\t *\n\t * <ProgressBar.Root value={75} max={100}>\n\t * <ProgressBar.Indicator />\n\t * </ProgressBar.Root>\n\t *\n\t * // Indeterminate progress\n\t * <ProgressBar.Root value=\"indeterminate\">\n\t * <ProgressBar.Indicator />\n\t * </ProgressBar.Root>\n\t * ```\n\t */\n\tRoot,\n\t/**\n\t * Displays the progress indicator, which visually represents the completion progress of a task.\n\t *\n\t * The visual indicator that shows the actual progress within the progress bar.\n\t * This component should be used inside a ProgressBar.Root component.\n\t *\n\t * @see https://mantle.ngrok.com/components/progress#api-progress-bar-indicator\n\t *\n\t * @example\n\t * ```tsx\n\t * <ProgressBar.Root value={60}>\n\t * <ProgressBar.Indicator />\n\t * </ProgressBar.Root>\n\t *\n\t * // Custom styled indicator\n\t * <ProgressBar.Root value={60}>\n\t * <ProgressBar.Indicator className=\"bg-success-600\" />\n\t * </ProgressBar.Root>\n\t * ```\n\t */\n\tIndicator,\n} as const;\n\nexport {\n\t//,\n\tProgressBar,\n};\n"],"mappings":"wCAAA,OAAOA,MAAU,OACjB,OAAS,iBAAAC,EAAe,cAAAC,EAAY,SAAAC,EAAO,WAAAC,MAAe,QCE1D,SAASC,EAAMC,EAAe,CAAE,IAAAC,EAAK,IAAAC,CAAI,EAAyC,CACjF,OAAO,KAAK,IAAIA,EAAK,KAAK,IAAID,EAAKD,CAAK,CAAC,CAC1C,CAKA,SAASG,EAASH,EAA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AAGe,EAAO,UAAW,eAAeE,CAAgB,IAAK,EACjE,GAAGb,EACL,CAEF,CACAU,EAAU,YAAc,YA0BxB,IAAMI,EAAc,CAyBnB,KAAAnB,EAqBA,UAAAe,CACD","names":["clsx","createContext","useContext","useId","useMemo","clamp","value","min","max","isNumber","isValidValueNumber","isValidMaxNumber","jsx","jsxs","defaultMax","defaultContextValue","ProgressContext","createContext","Root","children","className","_max","_strokeWidth","_value","indeterminateRotationSpeed","props","max","isValidMaxNumber","value","isValidValueNumber","strokeWidthPx","deriveStrokeWidthPx","valueNow","isNumber","radius","calcRadius","ctx","useMemo","cx","indeterminateTailPercent","Indicator","gradientId","useId","useContext","percentage","clsx","ProgressDonut","deriveStrokeWidthPx","strokeWidth","value","stroke","clamp","calcRadius","strokeWidthPx","ProgressPrimitive","createContext","useContext","useMemo","jsx","defaultMax","defaultContextValue","ProgressContext","createContext","Root","className","children","_max","_value","props","max","isValidMaxNumber","value","isValidValueNumber","valueNow","isNumber","ctx","useMemo","cx","Indicator","style","useContext","translatePercent","ProgressBar"]}
|
|
1
|
+
{"version":3,"file":"progress.js","names":["defaultMax","ProgressContext","Root","Indicator","clsx"],"sources":["../src/components/progress/math.ts","../src/components/progress/progress-donut.tsx","../src/components/progress/progress-bar.tsx"],"sourcesContent":["/**\n * Clamp a value between a minimum and maximum value.\n */\nfunction clamp(value: number, { min, max }: { min: number; max: number }): number {\n\treturn Math.min(max, Math.max(min, value));\n}\n\n/**\n * Check if a value is a number.\n */\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === \"number\";\n}\n\n/**\n * Check if a value is a valid number within the range of 0 to `max`.\n */\nfunction isValidValueNumber(value: unknown, max: number): value is number {\n\treturn isNumber(value) && !Number.isNaN(value) && value <= max && value >= 0;\n}\n\n/**\n * Check if a value is a valid number greater than 0.\n */\nfunction isValidMaxNumber(value: unknown): value is number {\n\treturn isNumber(value) && !Number.isNaN(value) && value > 0;\n}\n\nexport {\n\t//,\n\tclamp,\n\tisNumber,\n\tisValidValueNumber,\n\tisValidMaxNumber,\n};\n","import clsx from \"clsx\";\nimport { createContext, useContext, useId, useMemo } from \"react\";\nimport type { CSSProperties, ComponentProps, HTMLAttributes } from \"react\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { clamp, isNumber, isValidMaxNumber, isValidValueNumber } from \"./math.js\";\nimport type { ValueType } from \"./types.js\";\n\ntype RemValue = `${number}rem`;\ntype StrokeWidth = number | RemValue;\n\n/**\n * The default maximum value of the progress bar.\n */\nconst defaultMax = 100;\n\ntype ProgressContextValue = {\n\tmax: number;\n\tstrokeWidth: StrokeWidth;\n\tvalue: ValueType;\n};\n\nconst defaultContextValue = {\n\tmax: defaultMax,\n\tstrokeWidth: \"0.25rem\",\n\tvalue: 0,\n} as const satisfies ProgressContextValue;\n\nconst ProgressContext = createContext<ProgressContextValue>(defaultContextValue);\n\ntype SvgAttributes = Omit<\n\tHTMLAttributes<SVGElement>,\n\t\"viewBox\" | \"role\" | \"aria-valuemax\" | \"aria-valuemin\" | \"aria-valuenow\" | \"width\" | \"height\"\n>;\n\ntype Props = SvgAttributes & {\n\t/**\n\t * The maximum value of the progress bar.\n\t * This attribute describes how much work the task indicated by the progress element requires.\n\t * The max attribute, if present, must have a value greater than 0. The default value is 100.\n\t *\n\t * @default 100\n\t */\n\tmax?: number | undefined;\n\t/**\n\t * The width of the progress bar stroke.\n\t * Note, we clamp the stroke width to a minimum of 1px and max of 12px since\n\t * it is proportional to the viewbox size (0 0 32 32).\n\t *\n\t * @default 0.25rem (4px)\n\t */\n\tstrokeWidth?: StrokeWidth;\n\t/**\n\t * The current value of the progress bar.\n\t * This attribute specifies how much of the task that has been completed.\n\t * It must be a valid floating point number between 0 and max, or between 0 and 100 if max is omitted.\n\t * If set to `\"indeterminate\"`, the progress bar is considered indeterminate.\n\t *\n\t * @default 0\n\t */\n\tvalue?: ValueType | undefined;\n\t/**\n\t * Controls the rotation speed of the indeterminate spinner state.\n\t *\n\t * Accepts a Tailwind `animation-duration-*` utility (e.g. `animation-duration-[2s]`).\n\t *\n\t * This prop is applied in addition to `animate-spin` to control the speed of the indeterminate spinner.\n\t * @default `animation-duration-[15s]`\n\t */\n\tindeterminateRotationSpeed?: `animation-duration-${string}`;\n};\n\n/**\n * A simple circular progress bar which shows the completion progress of a task.\n *\n * The indicator color is inherited via `currentColor`. Override the default\n * (`accent-600`) by setting the `ProgressDonut.Indicator`'s text color.\n *\n * @see https://mantle.ngrok.com/components/progress#api-progress-donut\n *\n * @example\n * ```tsx\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator />\n * </ProgressDonut.Root>\n *\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator color=\"text-danger-600\" />\n * </ProgressDonut.Root>\n * ```\n */\nconst Root = ({\n\tchildren,\n\tclassName,\n\tmax: _max = defaultMax,\n\tstrokeWidth: _strokeWidth = 4,\n\tvalue: _value,\n\tindeterminateRotationSpeed,\n\t...props\n}: Props) => {\n\tconst max = isValidMaxNumber(_max) ? _max : defaultMax;\n\tconst value = (\n\t\tisValidValueNumber(_value, max) ? _value : _value == null ? 0 : \"indeterminate\"\n\t) satisfies ValueType;\n\tconst strokeWidthPx = deriveStrokeWidthPx(_strokeWidth ?? defaultContextValue.strokeWidth);\n\tconst valueNow = isNumber(value) ? value : undefined;\n\tconst radius = calcRadius(strokeWidthPx);\n\n\tconst ctx: ProgressContextValue = useMemo(\n\t\t() => ({\n\t\t\tmax,\n\t\t\tstrokeWidth: strokeWidthPx,\n\t\t\tvalue,\n\t\t}),\n\t\t[max, strokeWidthPx, value],\n\t);\n\n\treturn (\n\t\t<ProgressContext.Provider value={ctx}>\n\t\t\t{/* biome-ignore lint/a11y/useFocusableInteractive: progress bars don't need to be focusable */}\n\t\t\t<svg\n\t\t\t\taria-valuemax={max}\n\t\t\t\taria-valuemin={0}\n\t\t\t\taria-valuenow={valueNow}\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"size-6 text-gray-200 dark:text-gray-300\",\n\t\t\t\t\tvalue === \"indeterminate\" && [\n\t\t\t\t\t\t\"animate-spin\",\n\t\t\t\t\t\t// Default duration only if consumer hasn't set one.\n\t\t\t\t\t\t// Without this guard, both our `[15s]` and consumer overrides (e.g. `[2s]`)\n\t\t\t\t\t\t// end up in the DOM. Since tw-animate-css utilities aren't currently deduped by\n\t\t\t\t\t\t// tailwind-merge, whichever class Tailwind happened to emit last wins,\n\t\t\t\t\t\t// which isn't reliable.\n\t\t\t\t\t\tindeterminateRotationSpeed ?? \"animation-duration-[15s]\",\n\t\t\t\t\t],\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tdata-max={max}\n\t\t\t\tdata-min={0}\n\t\t\t\tdata-value={valueNow}\n\t\t\t\theight=\"100%\"\n\t\t\t\t// biome-ignore lint/a11y/noNoninteractiveElementToInteractiveRole: this is a radial progress bar, which is possible by SVG\n\t\t\t\trole=\"progressbar\"\n\t\t\t\twidth=\"100%\"\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<circle\n\t\t\t\t\tclassName=\"[r:var(--radius)]\"\n\t\t\t\t\tcx=\"50%\"\n\t\t\t\t\tcy=\"50%\"\n\t\t\t\t\tfill=\"transparent\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstrokeWidth={strokeWidthPx}\n\t\t\t\t\tstyle={{ \"--radius\": radius } as CSSProperties}\n\t\t\t\t/>\n\t\t\t\t{children}\n\t\t\t</svg>\n\t\t</ProgressContext.Provider>\n\t);\n};\nRoot.displayName = \"ProgressDonut\";\n\n/**\n * Length (value) of the progress indicator tail when the progress bar is indeterminate.\n */\nconst indeterminateTailPercent = 0.6;\n\ntype ProgressDonutIndicatorProps = Omit<ComponentProps<\"g\">, \"children\">;\n\n/**\n * The indicator for the circular progress bar.\n *\n * @see https://mantle.ngrok.com/components/progress#api-progress-donut-indicator\n *\n * @example\n * ```tsx\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator />\n * </ProgressDonut.Root>\n *\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator color=\"text-danger-600\" />\n * </ProgressDonut.Root>\n * ```\n */\nconst Indicator = ({ className, ...props }: ProgressDonutIndicatorProps) => {\n\tconst gradientId = useId();\n\tconst ctx = useContext(ProgressContext) ?? defaultContextValue;\n\tconst percentage =\n\t\t(ctx.value === \"indeterminate\" ? indeterminateTailPercent : ctx.value / ctx.max) * 100;\n\tconst strokeWidthPx = deriveStrokeWidthPx(ctx.strokeWidth);\n\tconst radius = calcRadius(strokeWidthPx);\n\n\treturn (\n\t\t<g className={cx(\"text-accent-600\", className)} {...props}>\n\t\t\t{ctx.value === \"indeterminate\" && (\n\t\t\t\t<defs>\n\t\t\t\t\t<linearGradient id={gradientId}>\n\t\t\t\t\t\t<stop className=\"stop-opacity-100 stop-color-current\" offset=\"0%\" />\n\t\t\t\t\t\t<stop className=\"stop-opacity-0 stop-color-current\" offset=\"95%\" />\n\t\t\t\t\t</linearGradient>\n\t\t\t\t</defs>\n\t\t\t)}\n\t\t\t<circle\n\t\t\t\tclassName={clsx(\n\t\t\t\t\t\"[r:var(--radius)]\", // set the circle radius to be the value of the calc'd CSS variable set on the style\n\t\t\t\t\t\"origin-center\",\n\t\t\t\t)}\n\t\t\t\tcx=\"50%\"\n\t\t\t\tcy=\"50%\"\n\t\t\t\tfill=\"transparent\"\n\t\t\t\tpathLength={100}\n\t\t\t\tstroke={ctx.value === \"indeterminate\" ? `url(#${gradientId})` : \"currentColor\"}\n\t\t\t\tstrokeDasharray={100}\n\t\t\t\tstrokeDashoffset={100 - percentage}\n\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\tstrokeWidth={strokeWidthPx}\n\t\t\t\tstyle={{ \"--radius\": radius } as CSSProperties}\n\t\t\t\ttransform=\"rotate(-90)\" // rotate -90 degrees so it starts from the top\n\t\t\t/>\n\t\t</g>\n\t);\n};\nIndicator.displayName = \"ProgressDonutIndicator\";\n\n/**\n * A simple circular progress bar which shows the completion progress of a task.\n *\n * The indicator color is inherited via `currentColor`. Override the default\n * (`accent-600`) by setting the `ProgressDonut.Indicator`'s text color.\n *\n * @see https://mantle.ngrok.com/components/progress\n *\n * @example\n * ```tsx\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator />\n * </ProgressDonut.Root>\n *\n * <ProgressDonut.Root value={60}>\n * <ProgressDonut.Indicator color=\"text-danger-600\" />\n * </ProgressDonut.Root>\n * ```\n */\nconst ProgressDonut = {\n\t/**\n\t * A simple circular progress bar which shows the completion progress of a task.\n\t *\n\t * The indicator color is inherited via `currentColor`. Override the default\n\t * (`accent-600`) by setting the `ProgressDonut.Indicator`'s text color.\n\t *\n\t * @see https://mantle.ngrok.com/components/progress#api-progress-donut-root\n\t *\n\t * @example\n\t * ```tsx\n\t * <ProgressDonut.Root value={60}>\n\t * <ProgressDonut.Indicator />\n\t * </ProgressDonut.Root>\n\t *\n\t * <ProgressDonut.Root value={60}>\n\t * <ProgressDonut.Indicator color=\"text-danger-600\" />\n\t * </ProgressDonut.Root>\n\t * ```\n\t */\n\tRoot,\n\t/**\n\t * The indicator for the circular progress bar.\n\t *\n\t * @see https://mantle.ngrok.com/components/progress#api-progress-donut-indicator\n\t *\n\t * @example\n\t * ```tsx\n\t * <ProgressDonut.Root value={60}>\n\t * <ProgressDonut.Indicator />\n\t * </ProgressDonut.Root>\n\t *\n\t * <ProgressDonut.Root value={60}>\n\t * <ProgressDonut.Indicator color=\"text-danger-600\" />\n\t * </ProgressDonut.Root>\n\t * ```\n\t */\n\tIndicator,\n} as const;\n\nexport {\n\t//,\n\tProgressDonut,\n};\n\n/**\n * Derive the stroke width in pixels as a number value or pixels/rem from a string value.\n * Note, this function clamps the stroke width to a minimum of 1 and max of 12 since\n * it is proportional to the viewbox size (0 0 32 32).\n *\n * @example\n * ```tsx\n * const strokeWidth1 = deriveStrokeWidthPx(8);\n * // Returns: 8\n *\n * const strokeWidth2 = deriveStrokeWidthPx(\"0.5rem\");\n * // Returns: 8 (0.5 * 16)\n *\n * const strokeWidth3 = deriveStrokeWidthPx(20);\n * // Returns: 12 (clamped to maximum)\n * ```\n */\nexport function deriveStrokeWidthPx(strokeWidth: number | string | undefined | null): number {\n\tlet value = 4;\n\tif (strokeWidth == null) {\n\t\treturn value;\n\t}\n\n\tif (typeof strokeWidth === \"number\") {\n\t\tvalue = strokeWidth;\n\t} else if (strokeWidth.endsWith(\"rem\")) {\n\t\tvalue = Number(strokeWidth.replace(\"rem\", \"\")) * 16;\n\t} else {\n\t\tvalue = Number(strokeWidth);\n\t}\n\n\tconst stroke = Number.isNaN(value) ? 4 : value;\n\treturn clamp(stroke, { min: 1, max: 12 });\n}\n\n/**\n * Calculate the radius of the progress donut and indicator based on the stroke\n * width in pixels.\n */\nfunction calcRadius(strokeWidthPx: number) {\n\treturn `calc(50% - ${strokeWidthPx / 2}px)` as const;\n}\n","\"use client\";\n\nimport * as ProgressPrimitive from \"@radix-ui/react-progress\";\n\nimport { type ComponentProps, createContext, useContext, useMemo } from \"react\";\nimport { cx } from \"../../utils/cx/cx.js\";\nimport { isNumber, isValidMaxNumber, isValidValueNumber } from \"./math.js\";\nimport type { ValueType } from \"./types.js\";\n\n/**\n * The default maximum value of the progress bar.\n */\nconst defaultMax = 100;\n\ntype ProgressContextValue = {\n\tmax: number;\n\tvalue: ValueType;\n};\n\nconst defaultContextValue = {\n\tmax: defaultMax,\n\tvalue: 0,\n} as const satisfies ProgressContextValue;\n\nconst ProgressContext = createContext<ProgressContextValue>(defaultContextValue);\n\ntype RootProps = ComponentProps<\"div\"> & {\n\t/**\n\t * The maximum value of the progress bar.\n\t * This attribute describes how much work the task indicated by the progress element requires.\n\t * The max attribute, if present, must have a value greater than 0. The default value is 100.\n\t *\n\t * @default 100\n\t */\n\tmax?: number | undefined;\n\t/**\n\t * The current value of the progress bar.\n\t * This attribute specifies how much of the task that has been completed.\n\t * It must be a valid floating point number between 0 and max, or between 0 and 100 if max is omitted.\n\t * If set to `\"indeterminate\"`, the progress bar is considered indeterminate. (for now there is no visual difference than 0)\n\t *\n\t * @default 0\n\t */\n\tvalue?: ValueType | undefined;\n};\n\n/**\n * Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.\n *\n * A horizontal progress bar that shows the completion progress of a task.\n * Use this component for linear progress indication.\n *\n * @see https://mantle.ngrok.com/components/progress#api-progress-bar\n *\n * @example\n * ```tsx\n * <ProgressBar.Root value={60}>\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n *\n * <ProgressBar.Root value={75} max={100}>\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n *\n * // Indeterminate progress\n * <ProgressBar.Root value=\"indeterminate\">\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n * ```\n */\nfunction Root({ className, children, max: _max = defaultMax, value: _value, ...props }: RootProps) {\n\tconst max = isValidMaxNumber(_max) ? _max : defaultMax;\n\tconst value = (\n\t\tisValidValueNumber(_value, max) ? _value : _value == null ? 0 : \"indeterminate\"\n\t) satisfies ValueType;\n\n\tconst valueNow = isNumber(value) ? value : undefined;\n\n\tconst ctx: ProgressContextValue = useMemo(\n\t\t() => ({\n\t\t\tmax,\n\t\t\tvalue,\n\t\t}),\n\t\t[max, value],\n\t);\n\n\treturn (\n\t\t<ProgressContext.Provider value={ctx}>\n\t\t\t<ProgressPrimitive.Root\n\t\t\t\tdata-slot=\"progress\"\n\t\t\t\tclassName={cx(\n\t\t\t\t\t\"bg-base-hover dark:bg-base shadow-inner relative h-3 w-full overflow-hidden rounded-md\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tvalue={valueNow}\n\t\t\t\tmax={max}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</ProgressPrimitive.Root>\n\t\t</ProgressContext.Provider>\n\t);\n}\nRoot.displayName = \"Root\";\n\ntype IndicatorProps = ComponentProps<typeof ProgressPrimitive.Indicator>;\n\n/**\n * Displays the progress indicator, which visually represents the completion progress of a task.\n *\n * The visual indicator that shows the actual progress within the progress bar.\n * This component should be used inside a ProgressBar.Root component.\n *\n * @see https://mantle.ngrok.com/components/progress#api-progress-bar-indicator\n *\n * @example\n * ```tsx\n * <ProgressBar.Root value={60}>\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n *\n * // Custom styled indicator\n * <ProgressBar.Root value={60}>\n * <ProgressBar.Indicator className=\"bg-success-600\" />\n * </ProgressBar.Root>\n * ```\n */\nfunction Indicator({ className, style, ...props }: IndicatorProps) {\n\tconst ctx = useContext(ProgressContext);\n\tconst { max } = ctx;\n\tconst value = ctx.value === \"indeterminate\" ? 0 : ctx.value;\n\tconst translatePercent = ((max - value) / max) * 100;\n\n\treturn (\n\t\t<ProgressPrimitive.Indicator\n\t\t\tdata-slot=\"progress-indicator\"\n\t\t\tclassName={cx(\"bg-accent-600 h-full w-full flex-1 transition-all\", className)}\n\t\t\tstyle={{ ...style, transform: `translateX(-${translatePercent}%)` }}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\nIndicator.displayName = \"Indicator\";\n\n/**\n * Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.\n *\n * A horizontal progress bar that shows the completion progress of a task.\n * Use this component for linear progress indication.\n *\n * @see https://mantle.ngrok.com/components/progress\n *\n * @example\n * ```tsx\n * <ProgressBar.Root value={60}>\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n *\n * <ProgressBar.Root value={75} max={100}>\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n *\n * // Indeterminate progress\n * <ProgressBar.Root value=\"indeterminate\">\n * <ProgressBar.Indicator />\n * </ProgressBar.Root>\n * ```\n */\nconst ProgressBar = {\n\t/**\n\t * Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.\n\t *\n\t * A horizontal progress bar that shows the completion progress of a task.\n\t * Use this component for linear progress indication.\n\t *\n\t * @see https://mantle.ngrok.com/components/progress#api-progress-bar\n\t *\n\t * @example\n\t * ```tsx\n\t * <ProgressBar.Root value={60}>\n\t * <ProgressBar.Indicator />\n\t * </ProgressBar.Root>\n\t *\n\t * <ProgressBar.Root value={75} max={100}>\n\t * <ProgressBar.Indicator />\n\t * </ProgressBar.Root>\n\t *\n\t * // Indeterminate progress\n\t * <ProgressBar.Root value=\"indeterminate\">\n\t * <ProgressBar.Indicator />\n\t * </ProgressBar.Root>\n\t * ```\n\t */\n\tRoot,\n\t/**\n\t * Displays the progress indicator, which visually represents the completion progress of a task.\n\t *\n\t * The visual indicator that shows the actual progress within the progress bar.\n\t * This component should be used inside a ProgressBar.Root component.\n\t *\n\t * @see https://mantle.ngrok.com/components/progress#api-progress-bar-indicator\n\t *\n\t * @example\n\t * ```tsx\n\t * <ProgressBar.Root value={60}>\n\t * <ProgressBar.Indicator />\n\t * </ProgressBar.Root>\n\t *\n\t * // Custom styled indicator\n\t * <ProgressBar.Root value={60}>\n\t * <ProgressBar.Indicator className=\"bg-success-600\" />\n\t * </ProgressBar.Root>\n\t * ```\n\t */\n\tIndicator,\n} as const;\n\nexport {\n\t//,\n\tProgressBar,\n};\n"],"mappings":"oOAGA,SAAS,EAAM,EAAe,CAAE,MAAK,OAA6C,CACjF,OAAO,KAAK,IAAI,EAAK,KAAK,IAAI,EAAK,EAAM,CAAC,CAM3C,SAAS,EAAS,EAAiC,CAClD,OAAO,OAAO,GAAU,SAMzB,SAAS,EAAmB,EAAgB,EAA8B,CACzE,OAAO,EAAS,EAAM,EAAI,CAAC,OAAO,MAAM,EAAM,EAAI,GAAS,GAAO,GAAS,EAM5E,SAAS,EAAiB,EAAiC,CAC1D,OAAO,EAAS,EAAM,EAAI,CAAC,OAAO,MAAM,EAAM,EAAI,EAAQ,ECZ3D,MAQM,EAAsB,CAC3B,IAAKA,IACL,YAAa,UACb,MAAO,EACP,CAEKC,EAAkB,EAAoC,EAAoB,CA+D1EC,GAAQ,CACb,WACA,YACA,IAAK,EAAOF,IACZ,YAAa,EAAe,EAC5B,MAAO,EACP,6BACA,GAAG,KACS,CACZ,IAAM,EAAM,EAAiB,EAAK,CAAG,EAAOA,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