@raydenui/ui 0.9.6 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Table-DCNSxua1.d.cts +31 -0
- package/dist/Table-DCNSxua1.d.ts +31 -0
- package/dist/blocks/ApplicationShellBlock.cjs +157 -0
- package/dist/blocks/ApplicationShellBlock.js +154 -0
- package/dist/blocks/CheckoutReviewBlock.cjs +16 -0
- package/dist/blocks/CheckoutReviewBlock.js +13 -0
- package/dist/blocks/CommandPaletteBlock.cjs +334 -0
- package/dist/blocks/CommandPaletteBlock.js +331 -0
- package/dist/blocks/CreateAccountBlock.cjs +147 -0
- package/dist/blocks/CreateAccountBlock.js +143 -0
- package/dist/blocks/EmptyStateBlock.cjs +19 -0
- package/dist/blocks/EmptyStateBlock.js +16 -0
- package/dist/blocks/FeatureOverviewBlock.cjs +54 -0
- package/dist/blocks/FeatureOverviewBlock.js +51 -0
- package/dist/blocks/HeaderBlock.cjs +230 -0
- package/dist/blocks/HeaderBlock.js +227 -0
- package/dist/blocks/KpiOverviewBlock.cjs +63 -0
- package/dist/blocks/KpiOverviewBlock.js +60 -0
- package/dist/blocks/LoginBlock.cjs +66 -0
- package/dist/blocks/LoginBlock.js +63 -0
- package/dist/blocks/NotificationsBlock.cjs +17 -0
- package/dist/blocks/NotificationsBlock.js +14 -0
- package/dist/blocks/PageHeaderBlock.cjs +121 -0
- package/dist/blocks/PageHeaderBlock.js +118 -0
- package/dist/blocks/PricingPlansBlock.cjs +146 -0
- package/dist/blocks/PricingPlansBlock.js +143 -0
- package/dist/blocks/ProductCollectionBlock.cjs +37 -0
- package/dist/blocks/ProductCollectionBlock.js +34 -0
- package/dist/blocks/ProductDetailBlock.cjs +30 -0
- package/dist/blocks/ProductDetailBlock.js +27 -0
- package/dist/blocks/ProductHeroBlock.cjs +83 -0
- package/dist/blocks/ProductHeroBlock.js +80 -0
- package/dist/blocks/ProfileSettingsBlock.cjs +130 -0
- package/dist/blocks/ProfileSettingsBlock.js +126 -0
- package/dist/blocks/QuickSendBlock.cjs +11 -0
- package/dist/blocks/QuickSendBlock.js +8 -0
- package/dist/blocks/RecentTransactionsBlock.cjs +13 -0
- package/dist/blocks/RecentTransactionsBlock.js +10 -0
- package/dist/blocks/SearchableTableBlock.cjs +91 -0
- package/dist/blocks/SearchableTableBlock.js +88 -0
- package/dist/blocks/ShoppingCartBlock.cjs +16 -0
- package/dist/blocks/ShoppingCartBlock.js +13 -0
- package/dist/blocks/SiteFooterBlock.cjs +69 -0
- package/dist/blocks/SiteFooterBlock.js +66 -0
- package/dist/blocks/TableBlock.cjs +20 -0
- package/dist/blocks/TableBlock.js +17 -0
- package/dist/blocks/TaskListBlock.cjs +198 -0
- package/dist/blocks/TaskListBlock.js +195 -0
- package/dist/blocks/WorkspaceSwitcherBlock.cjs +291 -0
- package/dist/blocks/WorkspaceSwitcherBlock.js +288 -0
- package/dist/blocks/commerce.cjs +44 -0
- package/dist/blocks/commerce.js +35 -0
- package/dist/blocks/index.cjs +53 -0
- package/dist/blocks/index.js +24 -0
- package/dist/blocks.d.cts +1820 -0
- package/dist/blocks.d.ts +1820 -0
- package/dist/chart.cjs +13 -0
- package/dist/chart.d.cts +59 -0
- package/dist/chart.d.ts +59 -0
- package/dist/chart.js +5 -0
- package/dist/components/Accordion/Accordion.cjs +94 -0
- package/dist/components/Accordion/Accordion.js +91 -0
- package/dist/components/Accordion/index.cjs +8 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/ActivityFeed/ActivityContent.cjs +40 -0
- package/dist/components/ActivityFeed/ActivityContent.js +37 -0
- package/dist/components/ActivityFeed/ActivityItem.cjs +19 -0
- package/dist/components/ActivityFeed/ActivityItem.js +16 -0
- package/dist/components/ActivityFeed/index.cjs +7 -0
- package/dist/components/ActivityFeed/index.js +2 -0
- package/dist/components/Alert/Alert.cjs +42 -0
- package/dist/components/Alert/Alert.js +39 -0
- package/dist/components/Alert/index.cjs +5 -0
- package/dist/components/Alert/index.js +1 -0
- package/dist/components/Avatar/Avatar.cjs +101 -0
- package/dist/components/Avatar/Avatar.js +98 -0
- package/dist/components/Avatar/index.cjs +6 -0
- package/dist/components/Avatar/index.js +1 -0
- package/dist/components/Badge/Badge.cjs +53 -0
- package/dist/components/Badge/Badge.js +50 -0
- package/dist/components/Badge/index.cjs +5 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Banner/Banner.cjs +83 -0
- package/dist/components/Banner/Banner.js +80 -0
- package/dist/components/Banner/index.cjs +5 -0
- package/dist/components/Banner/index.js +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.cjs +31 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +28 -0
- package/dist/components/Breadcrumb/index.cjs +5 -0
- package/dist/components/Breadcrumb/index.js +1 -0
- package/dist/components/Button/Button.cjs +88 -0
- package/dist/components/Button/Button.js +85 -0
- package/dist/components/Button/index.cjs +5 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.cjs +8 -0
- package/dist/components/ButtonGroup/ButtonGroup.js +5 -0
- package/dist/components/ButtonGroup/ButtonGroupItem.cjs +15 -0
- package/dist/components/ButtonGroup/ButtonGroupItem.js +12 -0
- package/dist/components/ButtonGroup/index.cjs +7 -0
- package/dist/components/ButtonGroup/index.js +2 -0
- package/dist/components/Card/Card.cjs +94 -0
- package/dist/components/Card/Card.js +91 -0
- package/dist/components/Card/index.cjs +9 -0
- package/dist/components/Card/index.js +1 -0
- package/dist/components/Chart/Chart.cjs +160 -0
- package/dist/components/Chart/Chart.js +153 -0
- package/dist/components/Chart/index.cjs +10 -0
- package/dist/components/Chart/index.js +2 -0
- package/dist/components/Chart/theme.cjs +67 -0
- package/dist/components/Chart/theme.js +62 -0
- package/dist/components/Chip/Chip.cjs +18 -0
- package/dist/components/Chip/Chip.js +15 -0
- package/dist/components/Chip/index.cjs +5 -0
- package/dist/components/Chip/index.js +1 -0
- package/dist/components/Counter/Counter.cjs +74 -0
- package/dist/components/Counter/Counter.js +71 -0
- package/dist/components/Counter/index.cjs +6 -0
- package/dist/components/Counter/index.js +1 -0
- package/dist/components/DatePicker/DatePicker.cjs +343 -0
- package/dist/components/DatePicker/DatePicker.js +340 -0
- package/dist/components/DatePicker/index.cjs +5 -0
- package/dist/components/DatePicker/index.js +1 -0
- package/dist/components/Divider/Divider.cjs +31 -0
- package/dist/components/Divider/Divider.js +28 -0
- package/dist/components/Divider/index.cjs +5 -0
- package/dist/components/Divider/index.js +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.cjs +108 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +105 -0
- package/dist/components/DropdownMenu/index.cjs +11 -0
- package/dist/components/DropdownMenu/index.js +1 -0
- package/dist/components/EmptyStateIllustration/EmptyStateIllustration.cjs +42 -0
- package/dist/components/EmptyStateIllustration/EmptyStateIllustration.js +39 -0
- package/dist/components/EmptyStateIllustration/illustrations.cjs +3322 -0
- package/dist/components/EmptyStateIllustration/illustrations.js +3319 -0
- package/dist/components/EmptyStateIllustration/index.cjs +7 -0
- package/dist/components/EmptyStateIllustration/index.js +2 -0
- package/dist/components/FileUpload/FileUpload.cjs +116 -0
- package/dist/components/FileUpload/FileUpload.js +113 -0
- package/dist/components/FileUpload/FileUploadDropZone.cjs +58 -0
- package/dist/components/FileUpload/FileUploadDropZone.js +55 -0
- package/dist/components/FileUpload/FileUploadIcons.cjs +55 -0
- package/dist/components/FileUpload/FileUploadIcons.js +50 -0
- package/dist/components/FileUpload/FileUploadItem.cjs +34 -0
- package/dist/components/FileUpload/FileUploadItem.js +31 -0
- package/dist/components/FileUpload/index.cjs +9 -0
- package/dist/components/FileUpload/index.js +3 -0
- package/dist/components/FormControl/Checkbox.cjs +27 -0
- package/dist/components/FormControl/Checkbox.js +24 -0
- package/dist/components/FormControl/Radio.cjs +15 -0
- package/dist/components/FormControl/Radio.js +12 -0
- package/dist/components/FormControl/Toggle.cjs +15 -0
- package/dist/components/FormControl/Toggle.js +12 -0
- package/dist/components/FormControl/index.cjs +9 -0
- package/dist/components/FormControl/index.js +3 -0
- package/dist/components/Icon/Icon.cjs +70 -0
- package/dist/components/Icon/Icon.js +34 -0
- package/dist/components/Icon/catalog.cjs +1672 -0
- package/dist/components/Icon/catalog.js +1669 -0
- package/dist/components/Icon/icons.cjs +5621 -0
- package/dist/components/Icon/icons.js +5610 -0
- package/dist/components/Icon/index.cjs +8 -0
- package/dist/components/Icon/index.js +2 -0
- package/dist/components/Input/Input.cjs +64 -0
- package/dist/components/Input/Input.js +61 -0
- package/dist/components/Input/index.cjs +5 -0
- package/dist/components/Input/index.js +1 -0
- package/dist/components/MetricsCard/MetricsCard.cjs +107 -0
- package/dist/components/MetricsCard/MetricsCard.js +104 -0
- package/dist/components/MetricsCard/index.cjs +5 -0
- package/dist/components/MetricsCard/index.js +1 -0
- package/dist/components/Modal/Modal.cjs +126 -0
- package/dist/components/Modal/Modal.js +123 -0
- package/dist/components/Modal/index.cjs +5 -0
- package/dist/components/Modal/index.js +1 -0
- package/dist/components/Pagination/Pagination.cjs +42 -0
- package/dist/components/Pagination/Pagination.js +39 -0
- package/dist/components/Pagination/index.cjs +5 -0
- package/dist/components/Pagination/index.js +1 -0
- package/dist/components/ProgressBar/ProgressBar.cjs +34 -0
- package/dist/components/ProgressBar/ProgressBar.js +31 -0
- package/dist/components/ProgressBar/index.cjs +5 -0
- package/dist/components/ProgressBar/index.js +1 -0
- package/dist/components/ProgressCircle/ProgressCircle.cjs +34 -0
- package/dist/components/ProgressCircle/ProgressCircle.js +31 -0
- package/dist/components/ProgressCircle/index.cjs +5 -0
- package/dist/components/ProgressCircle/index.js +1 -0
- package/dist/components/Select/Select.cjs +84 -0
- package/dist/components/Select/Select.js +80 -0
- package/dist/components/Select/SelectOption.cjs +26 -0
- package/dist/components/Select/SelectOption.js +23 -0
- package/dist/components/Select/index.cjs +7 -0
- package/dist/components/Select/index.js +2 -0
- package/dist/components/SidebarMenu/SidebarMenu.cjs +85 -0
- package/dist/components/SidebarMenu/SidebarMenu.js +81 -0
- package/dist/components/SidebarMenu/SidebarMenuItem.cjs +126 -0
- package/dist/components/SidebarMenu/SidebarMenuItem.js +122 -0
- package/dist/components/SidebarMenu/SidebarMenuSection.cjs +14 -0
- package/dist/components/SidebarMenu/SidebarMenuSection.js +11 -0
- package/dist/components/SidebarMenu/index.cjs +12 -0
- package/dist/components/SidebarMenu/index.js +4 -0
- package/dist/components/Slider/Slider.cjs +161 -0
- package/dist/components/Slider/Slider.js +158 -0
- package/dist/components/Slider/index.cjs +6 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Spinner/Spinner.cjs +93 -0
- package/dist/components/Spinner/Spinner.js +90 -0
- package/dist/components/Spinner/index.cjs +5 -0
- package/dist/components/Spinner/index.js +1 -0
- package/dist/components/Stepper/Stepper.cjs +82 -0
- package/dist/components/Stepper/Stepper.js +79 -0
- package/dist/components/Stepper/index.cjs +7 -0
- package/dist/components/Stepper/index.js +1 -0
- package/dist/components/Table/Table.cjs +25 -0
- package/dist/components/Table/Table.js +22 -0
- package/dist/components/Table/index.cjs +10 -0
- package/dist/components/Table/index.js +1 -0
- package/dist/components/Table/useTableSelection.cjs +60 -0
- package/dist/components/Table/useTableSelection.js +57 -0
- package/dist/components/Tabs/Tab.cjs +70 -0
- package/dist/components/Tabs/Tab.js +67 -0
- package/dist/components/Tabs/Tabs.cjs +133 -0
- package/dist/components/Tabs/Tabs.js +129 -0
- package/dist/components/Tabs/index.cjs +7 -0
- package/dist/components/Tabs/index.js +2 -0
- package/dist/components/Tooltip/Tooltip.cjs +101 -0
- package/dist/components/Tooltip/Tooltip.js +98 -0
- package/dist/components/Tooltip/index.cjs +5 -0
- package/dist/components/Tooltip/index.js +1 -0
- package/dist/context/ThemeContext.cjs +97 -0
- package/dist/context/ThemeContext.js +92 -0
- package/dist/fonts/README.md +13 -0
- package/dist/fonts/hanken-grotesk-cyrillic-ext-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-cyrillic-ext-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-ext-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-ext-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-latin-normal.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-vietnamese-italic.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-vietnamese-normal.woff2 +0 -0
- package/dist/fonts/hankengrotesk-LICENSE.txt +94 -0
- package/dist/fonts/manrope-LICENSE.txt +93 -0
- package/dist/fonts/manrope-cyrillic-ext-normal.woff2 +0 -0
- package/dist/fonts/manrope-cyrillic-normal.woff2 +0 -0
- package/dist/fonts/manrope-greek-normal.woff2 +0 -0
- package/dist/fonts/manrope-latin-ext-normal.woff2 +0 -0
- package/dist/fonts/manrope-latin-normal.woff2 +0 -0
- package/dist/fonts/manrope-vietnamese-normal.woff2 +0 -0
- package/dist/fonts.css +148 -0
- package/dist/hooks/form/index.cjs +11 -0
- package/dist/hooks/form/index.js +3 -0
- package/dist/hooks/form/useRaydenFormControl.cjs +81 -0
- package/dist/hooks/form/useRaydenFormControl.js +76 -0
- package/dist/hooks/form/useRaydenInput.cjs +38 -0
- package/dist/hooks/form/useRaydenInput.js +35 -0
- package/dist/hooks/form/useRaydenSelect.cjs +45 -0
- package/dist/hooks/form/useRaydenSelect.js +42 -0
- package/dist/hooks/index.cjs +17 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useBodyScrollLock.cjs +24 -0
- package/dist/hooks/useBodyScrollLock.js +21 -0
- package/dist/hooks/useCollisionAwareSide.cjs +72 -0
- package/dist/hooks/useCollisionAwareSide.js +69 -0
- package/dist/hooks/useControllableValue.cjs +16 -0
- package/dist/hooks/useControllableValue.js +13 -0
- package/dist/hooks/useDismissableLayer.cjs +100 -0
- package/dist/hooks/useDismissableLayer.js +97 -0
- package/dist/hooks/usePopupList.cjs +101 -0
- package/dist/hooks/usePopupList.js +98 -0
- package/dist/icons-8yD7I5jO.d.cts +430 -0
- package/dist/icons-8yD7I5jO.d.ts +430 -0
- package/dist/icons.cjs +2111 -418
- package/dist/icons.d.cts +1256 -429
- package/dist/icons.d.ts +1256 -429
- package/dist/icons.js +2089 -1
- package/dist/index.cjs +128 -15034
- package/dist/index.d.cts +698 -661
- package/dist/index.d.ts +698 -661
- package/dist/index.js +43 -14950
- package/dist/motion/Collapse.cjs +28 -0
- package/dist/motion/Collapse.js +25 -0
- package/dist/motion/MotionProvider.cjs +43 -0
- package/dist/motion/MotionProvider.js +38 -0
- package/dist/motion/Pressable.cjs +46 -0
- package/dist/motion/Pressable.js +43 -0
- package/dist/motion/Reveal.cjs +19 -0
- package/dist/motion/Reveal.js +16 -0
- package/dist/motion/SharedLayout.cjs +46 -0
- package/dist/motion/SharedLayout.js +43 -0
- package/dist/motion/index.cjs +19 -0
- package/dist/motion/index.js +6 -0
- package/dist/motion/presence.cjs +58 -0
- package/dist/motion/presence.js +55 -0
- package/dist/motion/presets.cjs +88 -0
- package/dist/motion/presets.js +84 -0
- package/dist/motion.d.cts +51 -0
- package/dist/motion.d.ts +51 -0
- package/dist/preset.cjs +356 -195
- package/dist/preset.d.cts +111 -32
- package/dist/preset.d.ts +111 -32
- package/dist/preset.js +353 -187
- package/dist/presets-Ba5QndHg.d.cts +144 -0
- package/dist/presets-Ba5QndHg.d.ts +144 -0
- package/dist/styles.css +1 -1
- package/dist/utils/cn.cjs +38 -0
- package/dist/utils/cn.js +35 -0
- package/dist/utils/resolveIcon.cjs +18 -0
- package/dist/utils/resolveIcon.js +15 -0
- package/package.json +79 -21
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RangeSlider = exports.Slider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
7
|
+
const sizeConfig = {
|
|
8
|
+
sm: { track: "h-1", handle: "size-3.5", handleSize: 14, border: "border-[2.333px]" },
|
|
9
|
+
md: { track: "h-2", handle: "size-4", handleSize: 16, border: "border-[2.667px]" },
|
|
10
|
+
lg: { track: "h-3", handle: "size-5", handleSize: 20, border: "border-[3.333px]" },
|
|
11
|
+
};
|
|
12
|
+
/* ─── Utilities ────────────────────────────────────────────────────────── */
|
|
13
|
+
function clamp(val, min, max) {
|
|
14
|
+
return Math.min(max, Math.max(min, val));
|
|
15
|
+
}
|
|
16
|
+
function getPercent(val, min, max) {
|
|
17
|
+
return max > min ? ((val - min) / (max - min)) * 100 : 0;
|
|
18
|
+
}
|
|
19
|
+
function snapValue(value, min, max, step) {
|
|
20
|
+
const increment = step > 0 ? step : 1;
|
|
21
|
+
return clamp(Number((min + Math.round((value - min) / increment) * increment).toFixed(10)), min, max);
|
|
22
|
+
}
|
|
23
|
+
function getValueFromPosition(clientX, rect, min, max, step) {
|
|
24
|
+
const pct = clamp((clientX - rect.left) / rect.width, 0, 1);
|
|
25
|
+
const raw = min + pct * (max - min);
|
|
26
|
+
return snapValue(raw, min, max, step);
|
|
27
|
+
}
|
|
28
|
+
function keyboardValue(key, value, min, max, step) {
|
|
29
|
+
const delta = step > 0 ? step : 1;
|
|
30
|
+
switch (key) {
|
|
31
|
+
case "ArrowRight":
|
|
32
|
+
case "ArrowUp":
|
|
33
|
+
return clamp(value + delta, min, max);
|
|
34
|
+
case "ArrowLeft":
|
|
35
|
+
case "ArrowDown":
|
|
36
|
+
return clamp(value - delta, min, max);
|
|
37
|
+
case "PageUp":
|
|
38
|
+
return clamp(value + delta * 10, min, max);
|
|
39
|
+
case "PageDown":
|
|
40
|
+
return clamp(value - delta * 10, min, max);
|
|
41
|
+
case "Home":
|
|
42
|
+
return min;
|
|
43
|
+
case "End":
|
|
44
|
+
return max;
|
|
45
|
+
default:
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/* ─── Slider ───────────────────────────────────────────────────────────── */
|
|
50
|
+
exports.Slider = (0, react_1.forwardRef)(({ value: controlledValue, onChange, size = "lg", label, metadata, showPercentage = true, min = 0, max = 100, step = 1, disabled = false, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...rest }, ref) => {
|
|
51
|
+
const [uncontrolled, setUncontrolled] = (0, react_1.useState)(min);
|
|
52
|
+
const val = clamp(controlledValue ?? uncontrolled, min, max);
|
|
53
|
+
const labelId = (0, react_1.useId)();
|
|
54
|
+
const trackRef = (0, react_1.useRef)(null);
|
|
55
|
+
const config = sizeConfig[size];
|
|
56
|
+
const pct = getPercent(val, min, max);
|
|
57
|
+
const metaItems = Array.isArray(metadata) ? metadata : metadata ? [metadata] : [];
|
|
58
|
+
const updateValue = (0, react_1.useCallback)((clientX) => {
|
|
59
|
+
if (disabled || !trackRef.current)
|
|
60
|
+
return;
|
|
61
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
62
|
+
const v = getValueFromPosition(clientX, rect, min, max, step);
|
|
63
|
+
if (controlledValue === undefined)
|
|
64
|
+
setUncontrolled(v);
|
|
65
|
+
onChange?.(v);
|
|
66
|
+
}, [disabled, min, max, step, controlledValue, onChange]);
|
|
67
|
+
const handlePointerDown = (0, react_1.useCallback)((e) => {
|
|
68
|
+
if (disabled)
|
|
69
|
+
return;
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
72
|
+
e.currentTarget.focus();
|
|
73
|
+
updateValue(e.clientX);
|
|
74
|
+
}, [disabled, updateValue]);
|
|
75
|
+
const handlePointerMove = (0, react_1.useCallback)((e) => {
|
|
76
|
+
if (disabled || !e.buttons)
|
|
77
|
+
return;
|
|
78
|
+
updateValue(e.clientX);
|
|
79
|
+
}, [disabled, updateValue]);
|
|
80
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: (0, cn_1.cn)("flex flex-col gap-2 w-full", disabled && "opacity-50", className), ...rest, children: [label && ((0, jsx_runtime_1.jsx)("span", { id: labelId, className: "text-sm font-medium text-grey-900 leading-[1.45]", children: label })), (0, jsx_runtime_1.jsxs)("div", { ref: trackRef, className: (0, cn_1.cn)("relative w-full h-11 touch-none cursor-pointer rounded-lg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-action-primary-text", disabled && "cursor-not-allowed"), onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onKeyDown: (event) => {
|
|
81
|
+
if (disabled)
|
|
82
|
+
return;
|
|
83
|
+
const next = keyboardValue(event.key, val, min, max, step);
|
|
84
|
+
if (next === null)
|
|
85
|
+
return;
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
if (controlledValue === undefined)
|
|
88
|
+
setUncontrolled(next);
|
|
89
|
+
onChange?.(next);
|
|
90
|
+
}, "aria-label": ariaLabel ?? (!label && !ariaLabelledBy ? "Value" : undefined), "aria-labelledby": ariaLabelledBy ?? (label ? labelId : undefined), "aria-disabled": disabled || undefined, role: "slider", "aria-valuenow": val, "aria-valuemin": min, "aria-valuemax": max, tabIndex: disabled ? -1 : 0, children: [(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("absolute inset-x-0 top-1/2 -translate-y-1/2 rounded-full bg-grey-200", config.track) }), (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("absolute left-0 top-1/2 -translate-y-1/2 rounded-full bg-action-primary", config.track), style: { width: `${pct}%` } }), (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("absolute top-1/2 rounded-full bg-action-primary border-white border-solid shadow-sm", config.handle, config.border), style: { left: `${pct}%`, transform: `translate(-50%, -50%)` } })] }), (metaItems.length > 0 || showPercentage) && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [metaItems.length > 0 && ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-1 items-center gap-1", children: metaItems.map((item, i) => ((0, jsx_runtime_1.jsxs)("span", { className: "contents", children: [i > 0 && (0, jsx_runtime_1.jsx)("span", { className: "text-xs text-grey-500", children: "\u2022" }), (0, jsx_runtime_1.jsx)("span", { className: "text-sm font-medium text-grey-500 leading-[1.45]", children: item })] }, i))) })), showPercentage && ((0, jsx_runtime_1.jsxs)("span", { className: "flex-1 text-sm font-semibold text-grey-500 text-right leading-[1.45]", children: [Math.round(pct), "%"] }))] }))] }));
|
|
91
|
+
});
|
|
92
|
+
exports.Slider.displayName = "Slider";
|
|
93
|
+
/* ─── RangeSlider ──────────────────────────────────────────────────────── */
|
|
94
|
+
exports.RangeSlider = (0, react_1.forwardRef)(({ value: controlledValue, onChange, size = "lg", label, showLabels = true, min = 0, max = 100, step = 1, disabled = false, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...rest }, ref) => {
|
|
95
|
+
const [uncontrolled, setUncontrolled] = (0, react_1.useState)(() => [
|
|
96
|
+
snapValue(min + (max - min) * 0.25, min, max, step),
|
|
97
|
+
snapValue(min + (max - min) * 0.75, min, max, step),
|
|
98
|
+
]);
|
|
99
|
+
const rawValue = controlledValue ?? uncontrolled;
|
|
100
|
+
const val = (0, react_1.useMemo)(() => {
|
|
101
|
+
const low = clamp(rawValue[0], min, max);
|
|
102
|
+
return [low, clamp(rawValue[1], low, max)];
|
|
103
|
+
}, [rawValue, min, max]);
|
|
104
|
+
const labelId = (0, react_1.useId)();
|
|
105
|
+
const lowRef = (0, react_1.useRef)(null);
|
|
106
|
+
const highRef = (0, react_1.useRef)(null);
|
|
107
|
+
const trackRef = (0, react_1.useRef)(null);
|
|
108
|
+
const dragging = (0, react_1.useRef)(null);
|
|
109
|
+
const config = sizeConfig[size];
|
|
110
|
+
const lowPct = getPercent(val[0], min, max);
|
|
111
|
+
const highPct = getPercent(val[1], min, max);
|
|
112
|
+
const update = (0, react_1.useCallback)((newVal) => {
|
|
113
|
+
if (controlledValue === undefined)
|
|
114
|
+
setUncontrolled(newVal);
|
|
115
|
+
onChange?.(newVal);
|
|
116
|
+
}, [controlledValue, onChange]);
|
|
117
|
+
const handlePointerDown = (0, react_1.useCallback)((e) => {
|
|
118
|
+
if (disabled || !trackRef.current)
|
|
119
|
+
return;
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
122
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
123
|
+
const v = getValueFromPosition(e.clientX, rect, min, max, step);
|
|
124
|
+
const distLow = Math.abs(v - val[0]);
|
|
125
|
+
const distHigh = Math.abs(v - val[1]);
|
|
126
|
+
dragging.current =
|
|
127
|
+
e.target.closest("[data-thumb]")?.dataset.thumb || (distLow <= distHigh ? "low" : "high");
|
|
128
|
+
(dragging.current === "low" ? lowRef : highRef).current?.focus();
|
|
129
|
+
if (dragging.current === "low") {
|
|
130
|
+
update([clamp(v, min, val[1]), val[1]]);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
update([val[0], clamp(v, val[0], max)]);
|
|
134
|
+
}
|
|
135
|
+
}, [disabled, min, max, step, val, update]);
|
|
136
|
+
const handlePointerMove = (0, react_1.useCallback)((e) => {
|
|
137
|
+
if (disabled || !e.buttons || !trackRef.current || !dragging.current)
|
|
138
|
+
return;
|
|
139
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
140
|
+
const v = getValueFromPosition(e.clientX, rect, min, max, step);
|
|
141
|
+
if (dragging.current === "low") {
|
|
142
|
+
update([clamp(v, min, val[1]), val[1]]);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
update([val[0], clamp(v, val[0], max)]);
|
|
146
|
+
}
|
|
147
|
+
}, [disabled, min, max, step, val, update]);
|
|
148
|
+
const handlePointerUp = (0, react_1.useCallback)(() => {
|
|
149
|
+
dragging.current = null;
|
|
150
|
+
}, []);
|
|
151
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: (0, cn_1.cn)("flex flex-col gap-2 w-full", disabled && "opacity-50", className), ...rest, children: [label && ((0, jsx_runtime_1.jsx)("span", { id: labelId, className: "text-sm font-medium text-grey-900 leading-[1.45]", children: label })), (0, jsx_runtime_1.jsxs)("div", { ref: trackRef, className: (0, cn_1.cn)("relative w-full h-11 touch-none cursor-pointer rounded-lg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-action-primary-text", disabled && "cursor-not-allowed"), onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp, onPointerCancel: handlePointerUp, children: [(0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("absolute inset-x-0 top-1/2 -translate-y-1/2 rounded-full bg-grey-200", config.track) }), (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("absolute top-1/2 -translate-y-1/2 rounded-full bg-action-primary", config.track), style: { left: `${lowPct}%`, width: `${highPct - lowPct}%` } }), ["low", "high"].map((thumb, index) => ((0, jsx_runtime_1.jsx)("div", { ref: thumb === "low" ? lowRef : highRef, "data-thumb": thumb, role: "slider", tabIndex: disabled ? -1 : 0, "aria-disabled": disabled || undefined, "aria-label": `${ariaLabel ?? label ?? "Range"} ${index === 0 ? "minimum" : "maximum"}`, "aria-describedby": ariaLabelledBy, "aria-valuenow": val[index], "aria-valuemin": index === 0 ? min : val[0], "aria-valuemax": index === 0 ? val[1] : max, onKeyDown: (event) => {
|
|
152
|
+
if (disabled)
|
|
153
|
+
return;
|
|
154
|
+
const next = keyboardValue(event.key, val[index], index === 0 ? min : val[0], index === 0 ? val[1] : max, step);
|
|
155
|
+
if (next === null)
|
|
156
|
+
return;
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
update(index === 0 ? [next, val[1]] : [val[0], next]);
|
|
159
|
+
}, className: "absolute top-1/2 size-11 -translate-x-1/2 -translate-y-1/2 flex items-center justify-center rounded-full focus-visible:outline-2 focus-visible:outline-action-primary-text", style: { left: `${index === 0 ? lowPct : highPct}%` }, children: (0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("rounded-full bg-action-primary border-white border-solid shadow-sm", config.handle, config.border) }) }, thumb)))] }), showLabels && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("span", { className: "text-sm font-medium text-grey-500 leading-[1.45]", children: [Math.round(getPercent(val[0], min, max)), "%"] }), (0, jsx_runtime_1.jsxs)("span", { className: "text-sm font-semibold text-grey-500 text-right leading-[1.45]", children: [Math.round(getPercent(val[1], min, max)), "%"] })] }))] }));
|
|
160
|
+
});
|
|
161
|
+
exports.RangeSlider.displayName = "RangeSlider";
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useId, useMemo, useRef, useState, } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
const sizeConfig = {
|
|
5
|
+
sm: { track: "h-1", handle: "size-3.5", handleSize: 14, border: "border-[2.333px]" },
|
|
6
|
+
md: { track: "h-2", handle: "size-4", handleSize: 16, border: "border-[2.667px]" },
|
|
7
|
+
lg: { track: "h-3", handle: "size-5", handleSize: 20, border: "border-[3.333px]" },
|
|
8
|
+
};
|
|
9
|
+
/* ─── Utilities ────────────────────────────────────────────────────────── */
|
|
10
|
+
function clamp(val, min, max) {
|
|
11
|
+
return Math.min(max, Math.max(min, val));
|
|
12
|
+
}
|
|
13
|
+
function getPercent(val, min, max) {
|
|
14
|
+
return max > min ? ((val - min) / (max - min)) * 100 : 0;
|
|
15
|
+
}
|
|
16
|
+
function snapValue(value, min, max, step) {
|
|
17
|
+
const increment = step > 0 ? step : 1;
|
|
18
|
+
return clamp(Number((min + Math.round((value - min) / increment) * increment).toFixed(10)), min, max);
|
|
19
|
+
}
|
|
20
|
+
function getValueFromPosition(clientX, rect, min, max, step) {
|
|
21
|
+
const pct = clamp((clientX - rect.left) / rect.width, 0, 1);
|
|
22
|
+
const raw = min + pct * (max - min);
|
|
23
|
+
return snapValue(raw, min, max, step);
|
|
24
|
+
}
|
|
25
|
+
function keyboardValue(key, value, min, max, step) {
|
|
26
|
+
const delta = step > 0 ? step : 1;
|
|
27
|
+
switch (key) {
|
|
28
|
+
case "ArrowRight":
|
|
29
|
+
case "ArrowUp":
|
|
30
|
+
return clamp(value + delta, min, max);
|
|
31
|
+
case "ArrowLeft":
|
|
32
|
+
case "ArrowDown":
|
|
33
|
+
return clamp(value - delta, min, max);
|
|
34
|
+
case "PageUp":
|
|
35
|
+
return clamp(value + delta * 10, min, max);
|
|
36
|
+
case "PageDown":
|
|
37
|
+
return clamp(value - delta * 10, min, max);
|
|
38
|
+
case "Home":
|
|
39
|
+
return min;
|
|
40
|
+
case "End":
|
|
41
|
+
return max;
|
|
42
|
+
default:
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/* ─── Slider ───────────────────────────────────────────────────────────── */
|
|
47
|
+
export const Slider = forwardRef(({ value: controlledValue, onChange, size = "lg", label, metadata, showPercentage = true, min = 0, max = 100, step = 1, disabled = false, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...rest }, ref) => {
|
|
48
|
+
const [uncontrolled, setUncontrolled] = useState(min);
|
|
49
|
+
const val = clamp(controlledValue ?? uncontrolled, min, max);
|
|
50
|
+
const labelId = useId();
|
|
51
|
+
const trackRef = useRef(null);
|
|
52
|
+
const config = sizeConfig[size];
|
|
53
|
+
const pct = getPercent(val, min, max);
|
|
54
|
+
const metaItems = Array.isArray(metadata) ? metadata : metadata ? [metadata] : [];
|
|
55
|
+
const updateValue = useCallback((clientX) => {
|
|
56
|
+
if (disabled || !trackRef.current)
|
|
57
|
+
return;
|
|
58
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
59
|
+
const v = getValueFromPosition(clientX, rect, min, max, step);
|
|
60
|
+
if (controlledValue === undefined)
|
|
61
|
+
setUncontrolled(v);
|
|
62
|
+
onChange?.(v);
|
|
63
|
+
}, [disabled, min, max, step, controlledValue, onChange]);
|
|
64
|
+
const handlePointerDown = useCallback((e) => {
|
|
65
|
+
if (disabled)
|
|
66
|
+
return;
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
69
|
+
e.currentTarget.focus();
|
|
70
|
+
updateValue(e.clientX);
|
|
71
|
+
}, [disabled, updateValue]);
|
|
72
|
+
const handlePointerMove = useCallback((e) => {
|
|
73
|
+
if (disabled || !e.buttons)
|
|
74
|
+
return;
|
|
75
|
+
updateValue(e.clientX);
|
|
76
|
+
}, [disabled, updateValue]);
|
|
77
|
+
return (_jsxs("div", { ref: ref, className: cn("flex flex-col gap-2 w-full", disabled && "opacity-50", className), ...rest, children: [label && (_jsx("span", { id: labelId, className: "text-sm font-medium text-grey-900 leading-[1.45]", children: label })), _jsxs("div", { ref: trackRef, className: cn("relative w-full h-11 touch-none cursor-pointer rounded-lg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-action-primary-text", disabled && "cursor-not-allowed"), onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onKeyDown: (event) => {
|
|
78
|
+
if (disabled)
|
|
79
|
+
return;
|
|
80
|
+
const next = keyboardValue(event.key, val, min, max, step);
|
|
81
|
+
if (next === null)
|
|
82
|
+
return;
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
if (controlledValue === undefined)
|
|
85
|
+
setUncontrolled(next);
|
|
86
|
+
onChange?.(next);
|
|
87
|
+
}, "aria-label": ariaLabel ?? (!label && !ariaLabelledBy ? "Value" : undefined), "aria-labelledby": ariaLabelledBy ?? (label ? labelId : undefined), "aria-disabled": disabled || undefined, role: "slider", "aria-valuenow": val, "aria-valuemin": min, "aria-valuemax": max, tabIndex: disabled ? -1 : 0, children: [_jsx("div", { className: cn("absolute inset-x-0 top-1/2 -translate-y-1/2 rounded-full bg-grey-200", config.track) }), _jsx("div", { className: cn("absolute left-0 top-1/2 -translate-y-1/2 rounded-full bg-action-primary", config.track), style: { width: `${pct}%` } }), _jsx("div", { className: cn("absolute top-1/2 rounded-full bg-action-primary border-white border-solid shadow-sm", config.handle, config.border), style: { left: `${pct}%`, transform: `translate(-50%, -50%)` } })] }), (metaItems.length > 0 || showPercentage) && (_jsxs("div", { className: "flex items-center justify-between", children: [metaItems.length > 0 && (_jsx("div", { className: "flex flex-1 items-center gap-1", children: metaItems.map((item, i) => (_jsxs("span", { className: "contents", children: [i > 0 && _jsx("span", { className: "text-xs text-grey-500", children: "\u2022" }), _jsx("span", { className: "text-sm font-medium text-grey-500 leading-[1.45]", children: item })] }, i))) })), showPercentage && (_jsxs("span", { className: "flex-1 text-sm font-semibold text-grey-500 text-right leading-[1.45]", children: [Math.round(pct), "%"] }))] }))] }));
|
|
88
|
+
});
|
|
89
|
+
Slider.displayName = "Slider";
|
|
90
|
+
/* ─── RangeSlider ──────────────────────────────────────────────────────── */
|
|
91
|
+
export const RangeSlider = forwardRef(({ value: controlledValue, onChange, size = "lg", label, showLabels = true, min = 0, max = 100, step = 1, disabled = false, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...rest }, ref) => {
|
|
92
|
+
const [uncontrolled, setUncontrolled] = useState(() => [
|
|
93
|
+
snapValue(min + (max - min) * 0.25, min, max, step),
|
|
94
|
+
snapValue(min + (max - min) * 0.75, min, max, step),
|
|
95
|
+
]);
|
|
96
|
+
const rawValue = controlledValue ?? uncontrolled;
|
|
97
|
+
const val = useMemo(() => {
|
|
98
|
+
const low = clamp(rawValue[0], min, max);
|
|
99
|
+
return [low, clamp(rawValue[1], low, max)];
|
|
100
|
+
}, [rawValue, min, max]);
|
|
101
|
+
const labelId = useId();
|
|
102
|
+
const lowRef = useRef(null);
|
|
103
|
+
const highRef = useRef(null);
|
|
104
|
+
const trackRef = useRef(null);
|
|
105
|
+
const dragging = useRef(null);
|
|
106
|
+
const config = sizeConfig[size];
|
|
107
|
+
const lowPct = getPercent(val[0], min, max);
|
|
108
|
+
const highPct = getPercent(val[1], min, max);
|
|
109
|
+
const update = useCallback((newVal) => {
|
|
110
|
+
if (controlledValue === undefined)
|
|
111
|
+
setUncontrolled(newVal);
|
|
112
|
+
onChange?.(newVal);
|
|
113
|
+
}, [controlledValue, onChange]);
|
|
114
|
+
const handlePointerDown = useCallback((e) => {
|
|
115
|
+
if (disabled || !trackRef.current)
|
|
116
|
+
return;
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
119
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
120
|
+
const v = getValueFromPosition(e.clientX, rect, min, max, step);
|
|
121
|
+
const distLow = Math.abs(v - val[0]);
|
|
122
|
+
const distHigh = Math.abs(v - val[1]);
|
|
123
|
+
dragging.current =
|
|
124
|
+
e.target.closest("[data-thumb]")?.dataset.thumb || (distLow <= distHigh ? "low" : "high");
|
|
125
|
+
(dragging.current === "low" ? lowRef : highRef).current?.focus();
|
|
126
|
+
if (dragging.current === "low") {
|
|
127
|
+
update([clamp(v, min, val[1]), val[1]]);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
update([val[0], clamp(v, val[0], max)]);
|
|
131
|
+
}
|
|
132
|
+
}, [disabled, min, max, step, val, update]);
|
|
133
|
+
const handlePointerMove = useCallback((e) => {
|
|
134
|
+
if (disabled || !e.buttons || !trackRef.current || !dragging.current)
|
|
135
|
+
return;
|
|
136
|
+
const rect = trackRef.current.getBoundingClientRect();
|
|
137
|
+
const v = getValueFromPosition(e.clientX, rect, min, max, step);
|
|
138
|
+
if (dragging.current === "low") {
|
|
139
|
+
update([clamp(v, min, val[1]), val[1]]);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
update([val[0], clamp(v, val[0], max)]);
|
|
143
|
+
}
|
|
144
|
+
}, [disabled, min, max, step, val, update]);
|
|
145
|
+
const handlePointerUp = useCallback(() => {
|
|
146
|
+
dragging.current = null;
|
|
147
|
+
}, []);
|
|
148
|
+
return (_jsxs("div", { ref: ref, className: cn("flex flex-col gap-2 w-full", disabled && "opacity-50", className), ...rest, children: [label && (_jsx("span", { id: labelId, className: "text-sm font-medium text-grey-900 leading-[1.45]", children: label })), _jsxs("div", { ref: trackRef, className: cn("relative w-full h-11 touch-none cursor-pointer rounded-lg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-action-primary-text", disabled && "cursor-not-allowed"), onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp, onPointerCancel: handlePointerUp, children: [_jsx("div", { className: cn("absolute inset-x-0 top-1/2 -translate-y-1/2 rounded-full bg-grey-200", config.track) }), _jsx("div", { className: cn("absolute top-1/2 -translate-y-1/2 rounded-full bg-action-primary", config.track), style: { left: `${lowPct}%`, width: `${highPct - lowPct}%` } }), ["low", "high"].map((thumb, index) => (_jsx("div", { ref: thumb === "low" ? lowRef : highRef, "data-thumb": thumb, role: "slider", tabIndex: disabled ? -1 : 0, "aria-disabled": disabled || undefined, "aria-label": `${ariaLabel ?? label ?? "Range"} ${index === 0 ? "minimum" : "maximum"}`, "aria-describedby": ariaLabelledBy, "aria-valuenow": val[index], "aria-valuemin": index === 0 ? min : val[0], "aria-valuemax": index === 0 ? val[1] : max, onKeyDown: (event) => {
|
|
149
|
+
if (disabled)
|
|
150
|
+
return;
|
|
151
|
+
const next = keyboardValue(event.key, val[index], index === 0 ? min : val[0], index === 0 ? val[1] : max, step);
|
|
152
|
+
if (next === null)
|
|
153
|
+
return;
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
update(index === 0 ? [next, val[1]] : [val[0], next]);
|
|
156
|
+
}, className: "absolute top-1/2 size-11 -translate-x-1/2 -translate-y-1/2 flex items-center justify-center rounded-full focus-visible:outline-2 focus-visible:outline-action-primary-text", style: { left: `${index === 0 ? lowPct : highPct}%` }, children: _jsx("div", { className: cn("rounded-full bg-action-primary border-white border-solid shadow-sm", config.handle, config.border) }) }, thumb)))] }), showLabels && (_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("span", { className: "text-sm font-medium text-grey-500 leading-[1.45]", children: [Math.round(getPercent(val[0], min, max)), "%"] }), _jsxs("span", { className: "text-sm font-semibold text-grey-500 text-right leading-[1.45]", children: [Math.round(getPercent(val[1], min, max)), "%"] })] }))] }));
|
|
157
|
+
});
|
|
158
|
+
RangeSlider.displayName = "RangeSlider";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RangeSlider = exports.Slider = void 0;
|
|
4
|
+
var Slider_1 = require("./Slider.cjs");
|
|
5
|
+
Object.defineProperty(exports, "Slider", { enumerable: true, get: function () { return Slider_1.Slider; } });
|
|
6
|
+
Object.defineProperty(exports, "RangeSlider", { enumerable: true, get: function () { return Slider_1.RangeSlider; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Slider, RangeSlider } from "./Slider.js";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Spinner = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
7
|
+
/* ─── Size Config ──────────────────────────────────────────────────────── */
|
|
8
|
+
const sizeMap = {
|
|
9
|
+
xs: 20,
|
|
10
|
+
sm: 24,
|
|
11
|
+
md: 32,
|
|
12
|
+
lg: 40,
|
|
13
|
+
xl: 48,
|
|
14
|
+
"2xl": 56,
|
|
15
|
+
"3xl": 64,
|
|
16
|
+
};
|
|
17
|
+
/* ─── Spinner SVGs ─────────────────────────────────────────────────────── */
|
|
18
|
+
function ThinSpinner({ size, color }) {
|
|
19
|
+
const r = size / 2 - 2;
|
|
20
|
+
const c = size / 2;
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, className: "animate-spin", children: [(0, jsx_runtime_1.jsx)("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: 1.5, opacity: 0.2, className: color }), (0, jsx_runtime_1.jsx)("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeDasharray: `${r * Math.PI * 0.75} ${r * Math.PI * 1.25}`, strokeLinecap: "round", className: color })] }));
|
|
22
|
+
}
|
|
23
|
+
function BoldSpinner({ size, color }) {
|
|
24
|
+
const sw = Math.max(2.5, size * 0.1);
|
|
25
|
+
const r = size / 2 - sw;
|
|
26
|
+
const c = size / 2;
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, className: "animate-spin", children: [(0, jsx_runtime_1.jsx)("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, opacity: 0.2, className: color }), (0, jsx_runtime_1.jsx)("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, strokeDasharray: `${r * Math.PI * 0.75} ${r * Math.PI * 1.25}`, strokeLinecap: "round", className: color })] }));
|
|
28
|
+
}
|
|
29
|
+
function DuoToneSpinner({ size, color }) {
|
|
30
|
+
const sw = Math.max(2, size * 0.08);
|
|
31
|
+
const r = size / 2 - sw;
|
|
32
|
+
const c = size / 2;
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, className: "animate-spin", children: [(0, jsx_runtime_1.jsx)("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, opacity: 0.15, className: color }), (0, jsx_runtime_1.jsx)("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, strokeDasharray: `${r * Math.PI} ${r * Math.PI}`, strokeLinecap: "round", className: color })] }));
|
|
34
|
+
}
|
|
35
|
+
function BufferingThinSpinner({ size, color }) {
|
|
36
|
+
const r = size / 2 - 2;
|
|
37
|
+
const c = size / 2;
|
|
38
|
+
const circumference = 2 * Math.PI * r;
|
|
39
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, children: [(0, jsx_runtime_1.jsx)("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: 1.5, opacity: 0.2, className: color }), (0, jsx_runtime_1.jsx)("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", className: (0, cn_1.cn)(color, "animate-[spinner-dash_1.5s_ease-in-out_infinite]"), style: { strokeDasharray: circumference, transformOrigin: "center" } })] }));
|
|
40
|
+
}
|
|
41
|
+
function BufferingBoldSpinner({ size, color }) {
|
|
42
|
+
const sw = Math.max(2.5, size * 0.1);
|
|
43
|
+
const r = size / 2 - sw;
|
|
44
|
+
const c = size / 2;
|
|
45
|
+
const circumference = 2 * Math.PI * r;
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, children: [(0, jsx_runtime_1.jsx)("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, opacity: 0.2, className: color }), (0, jsx_runtime_1.jsx)("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, strokeLinecap: "round", className: (0, cn_1.cn)(color, "animate-[spinner-dash_1.5s_ease-in-out_infinite]"), style: { strokeDasharray: circumference, transformOrigin: "center" } })] }));
|
|
47
|
+
}
|
|
48
|
+
function DotSpinner({ size, color }) {
|
|
49
|
+
const dotSize = Math.max(3, size * 0.15);
|
|
50
|
+
const c = size / 2;
|
|
51
|
+
const r = size / 2 - dotSize;
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, className: "animate-spin", children: [0, 1, 2, 3, 4, 5, 6, 7].map((i) => {
|
|
53
|
+
const angle = (i * 45 * Math.PI) / 180;
|
|
54
|
+
const x = c + r * Math.cos(angle);
|
|
55
|
+
const y = c + r * Math.sin(angle);
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)("circle", { cx: x, cy: y, r: dotSize / 2, fill: "currentColor", opacity: 0.15 + (i / 8) * 0.85, className: color }, i));
|
|
57
|
+
}) }));
|
|
58
|
+
}
|
|
59
|
+
function JugglingSpinner({ size, color }) {
|
|
60
|
+
const dotSize = Math.max(3, size * 0.18);
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, children: [0, 1, 2].map((i) => {
|
|
62
|
+
const cx = size / 2 + (i - 1) * (size * 0.35);
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)("circle", { cx: cx, cy: size / 2, r: dotSize / 2, fill: "currentColor", className: (0, cn_1.cn)(color, "animate-[juggle_1.4s_ease-in-out_infinite]"), style: { animationDelay: `${i * 0.16}s` } }, i));
|
|
64
|
+
}) }));
|
|
65
|
+
}
|
|
66
|
+
/* ─── Spinner Component ────────────────────────────────────────────────── */
|
|
67
|
+
exports.Spinner = (0, react_1.forwardRef)(({ type = "thin", size = "md", colorStyle = "brand", label, labelPosition = "after", className, ...rest }, ref) => {
|
|
68
|
+
const px = sizeMap[size];
|
|
69
|
+
const color = colorStyle === "brand" ? "text-primary-400" : "text-white";
|
|
70
|
+
const labelColor = colorStyle === "brand" ? "text-grey-900" : "text-white";
|
|
71
|
+
const spinnerEl = (() => {
|
|
72
|
+
switch (type) {
|
|
73
|
+
case "thin":
|
|
74
|
+
return (0, jsx_runtime_1.jsx)(ThinSpinner, { size: px, color: color });
|
|
75
|
+
case "bold":
|
|
76
|
+
return (0, jsx_runtime_1.jsx)(BoldSpinner, { size: px, color: color });
|
|
77
|
+
case "duo-tone":
|
|
78
|
+
return (0, jsx_runtime_1.jsx)(DuoToneSpinner, { size: px, color: color });
|
|
79
|
+
case "buffering-thin":
|
|
80
|
+
return (0, jsx_runtime_1.jsx)(BufferingThinSpinner, { size: px, color: color });
|
|
81
|
+
case "buffering-bold":
|
|
82
|
+
return (0, jsx_runtime_1.jsx)(BufferingBoldSpinner, { size: px, color: color });
|
|
83
|
+
case "dot":
|
|
84
|
+
return (0, jsx_runtime_1.jsx)(DotSpinner, { size: px, color: color });
|
|
85
|
+
case "juggling":
|
|
86
|
+
return (0, jsx_runtime_1.jsx)(JugglingSpinner, { size: px, color: color });
|
|
87
|
+
}
|
|
88
|
+
})();
|
|
89
|
+
const isVertical = labelPosition === "above" || labelPosition === "below";
|
|
90
|
+
const isReversed = labelPosition === "before" || labelPosition === "above";
|
|
91
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, role: "status", "aria-label": label || "Loading", "data-rayden-spinner": "", className: (0, cn_1.cn)("inline-flex items-center gap-2", isVertical && "flex-col", isReversed && (isVertical ? "flex-col-reverse" : "flex-row-reverse"), className), ...rest, children: [(0, jsx_runtime_1.jsx)("div", { className: "shrink-0", style: { width: px, height: px }, children: spinnerEl }), label && ((0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("text-sm leading-[1.45] whitespace-nowrap", labelColor), children: label }))] }));
|
|
92
|
+
});
|
|
93
|
+
exports.Spinner.displayName = "Spinner";
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
/* ─── Size Config ──────────────────────────────────────────────────────── */
|
|
5
|
+
const sizeMap = {
|
|
6
|
+
xs: 20,
|
|
7
|
+
sm: 24,
|
|
8
|
+
md: 32,
|
|
9
|
+
lg: 40,
|
|
10
|
+
xl: 48,
|
|
11
|
+
"2xl": 56,
|
|
12
|
+
"3xl": 64,
|
|
13
|
+
};
|
|
14
|
+
/* ─── Spinner SVGs ─────────────────────────────────────────────────────── */
|
|
15
|
+
function ThinSpinner({ size, color }) {
|
|
16
|
+
const r = size / 2 - 2;
|
|
17
|
+
const c = size / 2;
|
|
18
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, className: "animate-spin", children: [_jsx("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: 1.5, opacity: 0.2, className: color }), _jsx("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeDasharray: `${r * Math.PI * 0.75} ${r * Math.PI * 1.25}`, strokeLinecap: "round", className: color })] }));
|
|
19
|
+
}
|
|
20
|
+
function BoldSpinner({ size, color }) {
|
|
21
|
+
const sw = Math.max(2.5, size * 0.1);
|
|
22
|
+
const r = size / 2 - sw;
|
|
23
|
+
const c = size / 2;
|
|
24
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, className: "animate-spin", children: [_jsx("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, opacity: 0.2, className: color }), _jsx("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, strokeDasharray: `${r * Math.PI * 0.75} ${r * Math.PI * 1.25}`, strokeLinecap: "round", className: color })] }));
|
|
25
|
+
}
|
|
26
|
+
function DuoToneSpinner({ size, color }) {
|
|
27
|
+
const sw = Math.max(2, size * 0.08);
|
|
28
|
+
const r = size / 2 - sw;
|
|
29
|
+
const c = size / 2;
|
|
30
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, className: "animate-spin", children: [_jsx("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, opacity: 0.15, className: color }), _jsx("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, strokeDasharray: `${r * Math.PI} ${r * Math.PI}`, strokeLinecap: "round", className: color })] }));
|
|
31
|
+
}
|
|
32
|
+
function BufferingThinSpinner({ size, color }) {
|
|
33
|
+
const r = size / 2 - 2;
|
|
34
|
+
const c = size / 2;
|
|
35
|
+
const circumference = 2 * Math.PI * r;
|
|
36
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, children: [_jsx("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: 1.5, opacity: 0.2, className: color }), _jsx("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", className: cn(color, "animate-[spinner-dash_1.5s_ease-in-out_infinite]"), style: { strokeDasharray: circumference, transformOrigin: "center" } })] }));
|
|
37
|
+
}
|
|
38
|
+
function BufferingBoldSpinner({ size, color }) {
|
|
39
|
+
const sw = Math.max(2.5, size * 0.1);
|
|
40
|
+
const r = size / 2 - sw;
|
|
41
|
+
const c = size / 2;
|
|
42
|
+
const circumference = 2 * Math.PI * r;
|
|
43
|
+
return (_jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, children: [_jsx("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, opacity: 0.2, className: color }), _jsx("circle", { cx: c, cy: c, r: r, fill: "none", stroke: "currentColor", strokeWidth: sw, strokeLinecap: "round", className: cn(color, "animate-[spinner-dash_1.5s_ease-in-out_infinite]"), style: { strokeDasharray: circumference, transformOrigin: "center" } })] }));
|
|
44
|
+
}
|
|
45
|
+
function DotSpinner({ size, color }) {
|
|
46
|
+
const dotSize = Math.max(3, size * 0.15);
|
|
47
|
+
const c = size / 2;
|
|
48
|
+
const r = size / 2 - dotSize;
|
|
49
|
+
return (_jsx("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, className: "animate-spin", children: [0, 1, 2, 3, 4, 5, 6, 7].map((i) => {
|
|
50
|
+
const angle = (i * 45 * Math.PI) / 180;
|
|
51
|
+
const x = c + r * Math.cos(angle);
|
|
52
|
+
const y = c + r * Math.sin(angle);
|
|
53
|
+
return (_jsx("circle", { cx: x, cy: y, r: dotSize / 2, fill: "currentColor", opacity: 0.15 + (i / 8) * 0.85, className: color }, i));
|
|
54
|
+
}) }));
|
|
55
|
+
}
|
|
56
|
+
function JugglingSpinner({ size, color }) {
|
|
57
|
+
const dotSize = Math.max(3, size * 0.18);
|
|
58
|
+
return (_jsx("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, children: [0, 1, 2].map((i) => {
|
|
59
|
+
const cx = size / 2 + (i - 1) * (size * 0.35);
|
|
60
|
+
return (_jsx("circle", { cx: cx, cy: size / 2, r: dotSize / 2, fill: "currentColor", className: cn(color, "animate-[juggle_1.4s_ease-in-out_infinite]"), style: { animationDelay: `${i * 0.16}s` } }, i));
|
|
61
|
+
}) }));
|
|
62
|
+
}
|
|
63
|
+
/* ─── Spinner Component ────────────────────────────────────────────────── */
|
|
64
|
+
export const Spinner = forwardRef(({ type = "thin", size = "md", colorStyle = "brand", label, labelPosition = "after", className, ...rest }, ref) => {
|
|
65
|
+
const px = sizeMap[size];
|
|
66
|
+
const color = colorStyle === "brand" ? "text-primary-400" : "text-white";
|
|
67
|
+
const labelColor = colorStyle === "brand" ? "text-grey-900" : "text-white";
|
|
68
|
+
const spinnerEl = (() => {
|
|
69
|
+
switch (type) {
|
|
70
|
+
case "thin":
|
|
71
|
+
return _jsx(ThinSpinner, { size: px, color: color });
|
|
72
|
+
case "bold":
|
|
73
|
+
return _jsx(BoldSpinner, { size: px, color: color });
|
|
74
|
+
case "duo-tone":
|
|
75
|
+
return _jsx(DuoToneSpinner, { size: px, color: color });
|
|
76
|
+
case "buffering-thin":
|
|
77
|
+
return _jsx(BufferingThinSpinner, { size: px, color: color });
|
|
78
|
+
case "buffering-bold":
|
|
79
|
+
return _jsx(BufferingBoldSpinner, { size: px, color: color });
|
|
80
|
+
case "dot":
|
|
81
|
+
return _jsx(DotSpinner, { size: px, color: color });
|
|
82
|
+
case "juggling":
|
|
83
|
+
return _jsx(JugglingSpinner, { size: px, color: color });
|
|
84
|
+
}
|
|
85
|
+
})();
|
|
86
|
+
const isVertical = labelPosition === "above" || labelPosition === "below";
|
|
87
|
+
const isReversed = labelPosition === "before" || labelPosition === "above";
|
|
88
|
+
return (_jsxs("div", { ref: ref, role: "status", "aria-label": label || "Loading", "data-rayden-spinner": "", className: cn("inline-flex items-center gap-2", isVertical && "flex-col", isReversed && (isVertical ? "flex-col-reverse" : "flex-row-reverse"), className), ...rest, children: [_jsx("div", { className: "shrink-0", style: { width: px, height: px }, children: spinnerEl }), label && (_jsx("span", { className: cn("text-sm leading-[1.45] whitespace-nowrap", labelColor), children: label }))] }));
|
|
89
|
+
});
|
|
90
|
+
Spinner.displayName = "Spinner";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Spinner } from "./Spinner.js";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SegmentedStepper = exports.LinearStepper = exports.Stepper = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const cn_1 = require("../../utils/cn.cjs");
|
|
7
|
+
/* ─── Icons ────────────────────────────────────────────────────────────── */
|
|
8
|
+
function CheckIcon({ className }) {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)("svg", { className: className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 3, strokeLinecap: "round", strokeLinejoin: "round", children: (0, jsx_runtime_1.jsx)("path", { d: "M5 12l5 5L20 7" }) }));
|
|
10
|
+
}
|
|
11
|
+
/* ─── Step Indicator Circle ────────────────────────────────────────────── */
|
|
12
|
+
const statusText = {
|
|
13
|
+
completed: "Completed",
|
|
14
|
+
active: "Current step",
|
|
15
|
+
incomplete: "Not started",
|
|
16
|
+
disabled: "Unavailable",
|
|
17
|
+
};
|
|
18
|
+
function StepCircle({ status, indicator, stepNumber, icon, }) {
|
|
19
|
+
const isCompleted = status === "completed";
|
|
20
|
+
const isActive = status === "active";
|
|
21
|
+
const isDisabled = status === "disabled";
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)("shrink-0 flex items-center justify-center rounded-full size-6 border transition-colors", isCompleted && "bg-action-primary border-action-primary text-white", isActive && "bg-primary-50 border-primary-400 text-action-primary-text", !isCompleted && !isActive && !isDisabled && "bg-surface border-grey-300", isDisabled && "bg-grey-100 border-grey-200 text-grey-300"), children: [(0, jsx_runtime_1.jsx)("span", { className: "sr-only", children: statusText[status] }), isCompleted ? ((icon ?? (0, jsx_runtime_1.jsx)(CheckIcon, { className: "size-3.5" }))) : indicator === "dot" ? ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("size-2 rounded-full border", isActive
|
|
23
|
+
? "bg-primary-400 border-primary-400"
|
|
24
|
+
: isDisabled
|
|
25
|
+
? "bg-grey-300 border-grey-300"
|
|
26
|
+
: "bg-grey-400 border-grey-300") })) : indicator === "number" ? ((0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("text-xs font-medium", isActive ? "text-primary-400" : isDisabled ? "text-grey-300" : "text-on-surface-muted"), children: stepNumber })) : ((icon ?? ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("size-2 rounded-full", isActive ? "bg-primary-400" : isDisabled ? "bg-grey-300" : "bg-grey-400") }))))] }));
|
|
27
|
+
}
|
|
28
|
+
/* ─── Connector Line ───────────────────────────────────────────────────── */
|
|
29
|
+
function Connector({ orientation, completed, }) {
|
|
30
|
+
return orientation === "horizontal" ? ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("flex-1 h-0.5 rounded-full", completed ? "bg-primary-400" : "bg-grey-300") })) : ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("w-0.5 flex-1 min-h-[20px] ml-[11px] rounded-full", completed ? "bg-primary-400" : "bg-grey-300") }));
|
|
31
|
+
}
|
|
32
|
+
/* ─── Stepper ──────────────────────────────────────────────────────────── */
|
|
33
|
+
function resolveStatuses(steps, activeStep) {
|
|
34
|
+
if (activeStep !== undefined) {
|
|
35
|
+
return steps.map((s, i) => {
|
|
36
|
+
if (s.status === "disabled")
|
|
37
|
+
return "disabled";
|
|
38
|
+
if (i < activeStep)
|
|
39
|
+
return "completed";
|
|
40
|
+
if (i === activeStep)
|
|
41
|
+
return "active";
|
|
42
|
+
return "incomplete";
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return steps.map((s) => s.status ?? "incomplete");
|
|
46
|
+
}
|
|
47
|
+
exports.Stepper = (0, react_1.forwardRef)(({ steps, activeStep, orientation = "horizontal", indicator = "dot", className, ...rest }, ref) => {
|
|
48
|
+
const statuses = resolveStatuses(steps, activeStep);
|
|
49
|
+
if (orientation === "vertical") {
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: (0, cn_1.cn)("flex flex-col", className), ...rest, children: steps.map((step, i) => {
|
|
51
|
+
const status = statuses[i];
|
|
52
|
+
const isLast = i === steps.length - 1;
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex gap-3", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-center", children: [(0, jsx_runtime_1.jsx)(StepCircle, { status: status, indicator: indicator, stepNumber: i + 1, icon: step.icon }), !isLast && ((0, jsx_runtime_1.jsx)(Connector, { orientation: "vertical", completed: status === "completed" }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col pb-6", children: [(0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("text-sm font-medium leading-[1.45]", status === "active"
|
|
54
|
+
? "text-on-surface"
|
|
55
|
+
: status === "disabled"
|
|
56
|
+
? "text-grey-300"
|
|
57
|
+
: "text-on-surface-secondary"), children: step.title }), step.description && ((0, jsx_runtime_1.jsx)("span", { className: "text-xs text-on-surface-muted leading-[1.45]", children: step.description }))] })] }, i));
|
|
58
|
+
}) }));
|
|
59
|
+
}
|
|
60
|
+
// Horizontal
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: (0, cn_1.cn)("flex items-start w-full", className), ...rest, children: steps.map((step, i) => {
|
|
62
|
+
const status = statuses[i];
|
|
63
|
+
const isLast = i === steps.length - 1;
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col flex-1 items-center gap-2.5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1 w-full", children: [(0, jsx_runtime_1.jsx)(Connector, { orientation: "horizontal", completed: i > 0 && statuses[i - 1] === "completed" }), (0, jsx_runtime_1.jsx)(StepCircle, { status: status, indicator: indicator, stepNumber: i + 1, icon: step.icon }), (0, jsx_runtime_1.jsx)(Connector, { orientation: "horizontal", completed: !isLast && status === "completed" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-0.5 text-center w-full", children: [(0, jsx_runtime_1.jsx)("span", { className: (0, cn_1.cn)("text-xs font-medium leading-[1.45] tracking-tight", status === "active"
|
|
65
|
+
? "text-on-surface-body"
|
|
66
|
+
: status === "disabled"
|
|
67
|
+
? "text-grey-300"
|
|
68
|
+
: "text-on-surface-secondary"), children: step.title }), step.description && ((0, jsx_runtime_1.jsx)("span", { className: "text-xs text-on-surface-muted leading-[1.45] truncate", children: step.description }))] })] }, i));
|
|
69
|
+
}) }));
|
|
70
|
+
});
|
|
71
|
+
exports.Stepper.displayName = "Stepper";
|
|
72
|
+
/* ─── LinearStepper ────────────────────────────────────────────────────── */
|
|
73
|
+
exports.LinearStepper = (0, react_1.forwardRef)(({ currentStep, totalSteps, showLabel = true, className, ...rest }, ref) => {
|
|
74
|
+
const pct = Math.min(100, Math.max(0, (currentStep / totalSteps) * 100));
|
|
75
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: (0, cn_1.cn)("flex flex-col gap-2 w-full", className), ...rest, children: [showLabel && ((0, jsx_runtime_1.jsxs)("p", { className: "text-sm font-semibold leading-[1.45]", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-on-surface", children: currentStep }), (0, jsx_runtime_1.jsxs)("span", { className: "text-on-surface-muted", children: [" / ", totalSteps, " complete"] })] })), (0, jsx_runtime_1.jsx)("div", { className: "bg-grey-200 rounded-full p-1 w-full overflow-hidden", role: "progressbar", "aria-valuenow": currentStep, "aria-valuemin": 0, "aria-valuemax": totalSteps, "aria-valuetext": `Step ${currentStep} of ${totalSteps}`, "aria-label": "Progress", children: (0, jsx_runtime_1.jsx)("div", { className: "h-2 bg-primary-400 rounded-[10px] transition-all duration-300", style: { width: `${pct}%` } }) })] }));
|
|
76
|
+
});
|
|
77
|
+
exports.LinearStepper.displayName = "LinearStepper";
|
|
78
|
+
/* ─── SegmentedStepper ─────────────────────────────────────────────────── */
|
|
79
|
+
exports.SegmentedStepper = (0, react_1.forwardRef)(({ currentStep, totalSteps, showLabel = true, className, ...rest }, ref) => {
|
|
80
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: (0, cn_1.cn)("flex flex-col gap-2 w-full", className), ...rest, children: [showLabel && ((0, jsx_runtime_1.jsxs)("p", { className: "text-sm font-semibold leading-[1.45]", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-on-surface", children: currentStep }), (0, jsx_runtime_1.jsxs)("span", { className: "text-on-surface-muted", children: [" / ", totalSteps, " complete"] })] })), (0, jsx_runtime_1.jsx)("div", { className: "bg-grey-200 rounded-full p-1 w-full overflow-hidden", role: "progressbar", "aria-valuenow": currentStep, "aria-valuemin": 0, "aria-valuemax": totalSteps, "aria-valuetext": `Step ${currentStep} of ${totalSteps}`, "aria-label": "Progress", children: (0, jsx_runtime_1.jsx)("div", { className: "flex gap-1 h-2 w-full", children: Array.from({ length: totalSteps }, (_, i) => ((0, jsx_runtime_1.jsx)("div", { className: (0, cn_1.cn)("flex-1 rounded-[14px] border border-grey-50 transition-colors", i < currentStep ? "bg-primary-400" : "bg-grey-50") }, i))) }) })] }));
|
|
81
|
+
});
|
|
82
|
+
exports.SegmentedStepper.displayName = "SegmentedStepper";
|