@craftzbay/ui 0.11.3 → 1.0.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/README.md +1 -1
- package/dist-lib/_virtual/_rolldown/runtime.js +11 -0
- package/dist-lib/components/ui/Accordion.js +42 -67
- package/dist-lib/components/ui/Accordion.js.map +1 -1
- package/dist-lib/components/ui/Alert.js +71 -77
- package/dist-lib/components/ui/Alert.js.map +1 -1
- package/dist-lib/components/ui/Avatar.js +67 -92
- package/dist-lib/components/ui/Avatar.js.map +1 -1
- package/dist-lib/components/ui/Badge.js +119 -74
- package/dist-lib/components/ui/Badge.js.map +1 -1
- package/dist-lib/components/ui/Breadcrumbs.js +62 -50
- package/dist-lib/components/ui/Breadcrumbs.js.map +1 -1
- package/dist-lib/components/ui/Button.js +129 -131
- package/dist-lib/components/ui/Button.js.map +1 -1
- package/dist-lib/components/ui/Calendar.d.ts +1 -1
- package/dist-lib/components/ui/Calendar.js +99 -136
- package/dist-lib/components/ui/Calendar.js.map +1 -1
- package/dist-lib/components/ui/Card.js +88 -94
- package/dist-lib/components/ui/Card.js.map +1 -1
- package/dist-lib/components/ui/Carousel.js +125 -170
- package/dist-lib/components/ui/Carousel.js.map +1 -1
- package/dist-lib/components/ui/Chart.d.ts +3 -3
- package/dist-lib/components/ui/Chart.js +435 -464
- package/dist-lib/components/ui/Chart.js.map +1 -1
- package/dist-lib/components/ui/Checkbox.js +60 -69
- package/dist-lib/components/ui/Checkbox.js.map +1 -1
- package/dist-lib/components/ui/Combobox.js +179 -192
- package/dist-lib/components/ui/Combobox.js.map +1 -1
- package/dist-lib/components/ui/CommandPalette.d.ts +2 -2
- package/dist-lib/components/ui/CommandPalette.js +106 -167
- package/dist-lib/components/ui/CommandPalette.js.map +1 -1
- package/dist-lib/components/ui/ContextMenu.d.ts +1 -1
- package/dist-lib/components/ui/ContextMenu.js +89 -154
- package/dist-lib/components/ui/ContextMenu.js.map +1 -1
- package/dist-lib/components/ui/DataGrid.d.ts +1 -1
- package/dist-lib/components/ui/DataGrid.js +99 -96
- package/dist-lib/components/ui/DataGrid.js.map +1 -1
- package/dist-lib/components/ui/DatePicker.js +151 -188
- package/dist-lib/components/ui/DatePicker.js.map +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.d.ts +1 -1
- package/dist-lib/components/ui/DesignSystemProvider.js +120 -130
- package/dist-lib/components/ui/DesignSystemProvider.js.map +1 -1
- package/dist-lib/components/ui/Dialog.d.ts +3 -3
- package/dist-lib/components/ui/Dialog.js +108 -156
- package/dist-lib/components/ui/Dialog.js.map +1 -1
- package/dist-lib/components/ui/Drawer.d.ts +3 -3
- package/dist-lib/components/ui/Drawer.js +90 -124
- package/dist-lib/components/ui/Drawer.js.map +1 -1
- package/dist-lib/components/ui/DropdownMenu.d.ts +1 -1
- package/dist-lib/components/ui/DropdownMenu.js +92 -158
- package/dist-lib/components/ui/DropdownMenu.js.map +1 -1
- package/dist-lib/components/ui/EmptyState.js +31 -44
- package/dist-lib/components/ui/EmptyState.js.map +1 -1
- package/dist-lib/components/ui/ErrorState.js +57 -67
- package/dist-lib/components/ui/ErrorState.js.map +1 -1
- package/dist-lib/components/ui/FileUpload.js +113 -107
- package/dist-lib/components/ui/FileUpload.js.map +1 -1
- package/dist-lib/components/ui/Form.d.ts +6 -4
- package/dist-lib/components/ui/Form.js +117 -122
- package/dist-lib/components/ui/Form.js.map +1 -1
- package/dist-lib/components/ui/Icon.d.ts +1 -1
- package/dist-lib/components/ui/Icon.js +30 -29
- package/dist-lib/components/ui/Icon.js.map +1 -1
- package/dist-lib/components/ui/IconButton.js +61 -63
- package/dist-lib/components/ui/IconButton.js.map +1 -1
- package/dist-lib/components/ui/Input.js +133 -156
- package/dist-lib/components/ui/Input.js.map +1 -1
- package/dist-lib/components/ui/Kbd.js +14 -21
- package/dist-lib/components/ui/Kbd.js.map +1 -1
- package/dist-lib/components/ui/MultiSelect.js +176 -208
- package/dist-lib/components/ui/MultiSelect.js.map +1 -1
- package/dist-lib/components/ui/Pagination.js +152 -149
- package/dist-lib/components/ui/Pagination.js.map +1 -1
- package/dist-lib/components/ui/Popover.js +18 -33
- package/dist-lib/components/ui/Popover.js.map +1 -1
- package/dist-lib/components/ui/Progress.js +77 -99
- package/dist-lib/components/ui/Progress.js.map +1 -1
- package/dist-lib/components/ui/RadioGroup.js +51 -80
- package/dist-lib/components/ui/RadioGroup.js.map +1 -1
- package/dist-lib/components/ui/RelativeTime.js +22 -29
- package/dist-lib/components/ui/RelativeTime.js.map +1 -1
- package/dist-lib/components/ui/ScrollArea.js +39 -58
- package/dist-lib/components/ui/ScrollArea.js.map +1 -1
- package/dist-lib/components/ui/Select.js +108 -131
- package/dist-lib/components/ui/Select.js.map +1 -1
- package/dist-lib/components/ui/Separator.js +18 -24
- package/dist-lib/components/ui/Separator.js.map +1 -1
- package/dist-lib/components/ui/Sheet.d.ts +2 -2
- package/dist-lib/components/ui/Sheet.js +77 -129
- package/dist-lib/components/ui/Sheet.js.map +1 -1
- package/dist-lib/components/ui/Sidebar.d.ts +1 -1
- package/dist-lib/components/ui/Sidebar.js +168 -207
- package/dist-lib/components/ui/Sidebar.js.map +1 -1
- package/dist-lib/components/ui/Skeleton.js +17 -27
- package/dist-lib/components/ui/Skeleton.js.map +1 -1
- package/dist-lib/components/ui/Slider.js +45 -62
- package/dist-lib/components/ui/Slider.js.map +1 -1
- package/dist-lib/components/ui/Snackbar.js +75 -55
- package/dist-lib/components/ui/Snackbar.js.map +1 -1
- package/dist-lib/components/ui/Spinner.js +45 -52
- package/dist-lib/components/ui/Spinner.js.map +1 -1
- package/dist-lib/components/ui/Stepper.js +56 -108
- package/dist-lib/components/ui/Stepper.js.map +1 -1
- package/dist-lib/components/ui/Switch.js +46 -79
- package/dist-lib/components/ui/Switch.js.map +1 -1
- package/dist-lib/components/ui/Table.js +108 -169
- package/dist-lib/components/ui/Table.js.map +1 -1
- package/dist-lib/components/ui/Tabs.js +57 -88
- package/dist-lib/components/ui/Tabs.js.map +1 -1
- package/dist-lib/components/ui/TagInput.js +76 -109
- package/dist-lib/components/ui/TagInput.js.map +1 -1
- package/dist-lib/components/ui/Textarea.js +74 -86
- package/dist-lib/components/ui/Textarea.js.map +1 -1
- package/dist-lib/components/ui/Timeline.d.ts +3 -3
- package/dist-lib/components/ui/Timeline.js +61 -49
- package/dist-lib/components/ui/Timeline.js.map +1 -1
- package/dist-lib/components/ui/Toast.d.ts +1 -1
- package/dist-lib/components/ui/Toast.js +136 -150
- package/dist-lib/components/ui/Toast.js.map +1 -1
- package/dist-lib/components/ui/Tooltip.d.ts +2 -2
- package/dist-lib/components/ui/Tooltip.js +35 -56
- package/dist-lib/components/ui/Tooltip.js.map +1 -1
- package/dist-lib/components/ui/TopNav.js +46 -66
- package/dist-lib/components/ui/TopNav.js.map +1 -1
- package/dist-lib/components/ui/Tree.js +134 -168
- package/dist-lib/components/ui/Tree.js.map +1 -1
- package/dist-lib/hooks/use-debounce.js +24 -33
- package/dist-lib/hooks/use-debounce.js.map +1 -1
- package/dist-lib/hooks/use-delayed-loading.js +20 -18
- package/dist-lib/hooks/use-delayed-loading.js.map +1 -1
- package/dist-lib/hooks/use-field-ids.js +14 -16
- package/dist-lib/hooks/use-field-ids.js.map +1 -1
- package/dist-lib/hooks/use-media-query.js +15 -19
- package/dist-lib/hooks/use-media-query.js.map +1 -1
- package/dist-lib/hooks/use-modifier-key.d.ts +0 -4
- package/dist-lib/hooks/use-modifier-key.js +19 -16
- package/dist-lib/hooks/use-modifier-key.js.map +1 -1
- package/dist-lib/hooks/use-strings.js +10 -10
- package/dist-lib/hooks/use-strings.js.map +1 -1
- package/dist-lib/hooks/use-toast.js +73 -62
- package/dist-lib/hooks/use-toast.js.map +1 -1
- package/dist-lib/icon.js +2 -6
- package/dist-lib/icons/index.d.ts +1 -1
- package/dist-lib/icons/index.js +166 -163
- package/dist-lib/icons/index.js.map +1 -1
- package/dist-lib/illustrations/index.d.ts +7 -7
- package/dist-lib/illustrations/index.js +255 -106
- package/dist-lib/illustrations/index.js.map +1 -1
- package/dist-lib/index.js +69 -291
- package/dist-lib/lib/cva.js +2 -0
- package/dist-lib/lib/format.js +71 -87
- package/dist-lib/lib/format.js.map +1 -1
- package/dist-lib/lib/return-focus.js +11 -11
- package/dist-lib/lib/return-focus.js.map +1 -1
- package/dist-lib/lib/strings.js +167 -135
- package/dist-lib/lib/strings.js.map +1 -1
- package/dist-lib/lib/strings.mn.js +150 -113
- package/dist-lib/lib/strings.mn.js.map +1 -1
- package/dist-lib/lib/utils.js +9 -9
- package/dist-lib/lib/utils.js.map +1 -1
- package/dist-lib/styles.css +3 -1
- package/package.json +53 -53
- package/dist-lib/__tests__/helpers/color.d.ts +0 -9
- package/dist-lib/__tests__/helpers/theme.d.ts +0 -18
- package/dist-lib/icon.js.map +0 -1
- package/dist-lib/index.js.map +0 -1
|
@@ -1,64 +1,47 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { useStrings as t } from "../../hooks/use-strings.js";
|
|
4
|
+
import { forwardRef as n, useId as r, useState as i } from "react";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
4
6
|
import * as s from "@radix-ui/react-slider";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"transition-transform duration-[var(--duration-fast)] ease-[var(--ease-out)]",
|
|
47
|
-
"hover:scale-110 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
|
48
|
-
),
|
|
49
|
-
"aria-label": w(x),
|
|
50
|
-
"aria-labelledby": !d && e && !m ? c : void 0
|
|
51
|
-
},
|
|
52
|
-
x
|
|
53
|
-
))
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
] });
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
z.displayName = "Slider";
|
|
61
|
-
export {
|
|
62
|
-
z as Slider
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=Slider.js.map
|
|
7
|
+
//#region src/components/ui/Slider.tsx
|
|
8
|
+
var c = n(function({ className: n, label: c, showValue: l, formatValue: u = (e) => String(e), value: d, defaultValue: f, onValueChange: p, ...m }, h) {
|
|
9
|
+
let [g, _] = i(f ?? [0]), v = d !== void 0, y = v ? d : g, b = y.length > 1, x = r(), S = t(), C = typeof c == "string" ? c : void 0, w = (e) => b ? e === 0 ? S.slider.minimum : S.slider.maximum : C ?? m["aria-label"] ?? S.slider.value;
|
|
10
|
+
return /* @__PURE__ */ o("div", {
|
|
11
|
+
className: e("flex flex-col gap-2", n),
|
|
12
|
+
children: [(c || l) && /* @__PURE__ */ o("div", {
|
|
13
|
+
className: "flex items-center justify-between",
|
|
14
|
+
children: [c && /* @__PURE__ */ a("span", {
|
|
15
|
+
id: x,
|
|
16
|
+
className: "text-foreground text-sm font-medium",
|
|
17
|
+
children: c
|
|
18
|
+
}), l && /* @__PURE__ */ a("span", {
|
|
19
|
+
className: "tabular text-foreground-muted font-mono text-xs",
|
|
20
|
+
children: b ? `${u(y[0])} – ${u(y[1])}` : u(y[0])
|
|
21
|
+
})]
|
|
22
|
+
}), /* @__PURE__ */ o(s.Root, {
|
|
23
|
+
ref: h,
|
|
24
|
+
value: d,
|
|
25
|
+
defaultValue: f,
|
|
26
|
+
onValueChange: (e) => {
|
|
27
|
+
v || _(e), p?.(e);
|
|
28
|
+
},
|
|
29
|
+
className: "relative flex w-full touch-none items-center py-3.5 select-none",
|
|
30
|
+
"aria-labelledby": c && !C ? x : void 0,
|
|
31
|
+
...m,
|
|
32
|
+
children: [/* @__PURE__ */ a(s.Track, {
|
|
33
|
+
className: "bg-background-muted relative h-1 w-full grow overflow-hidden rounded-full",
|
|
34
|
+
children: /* @__PURE__ */ a(s.Range, { className: "bg-accent absolute h-full" })
|
|
35
|
+
}), y.map((t, n) => /* @__PURE__ */ a(s.Thumb, {
|
|
36
|
+
className: e("border-accent bg-card relative block size-4 rounded-full border-2 shadow-sm", "before:absolute before:top-1/2 before:left-1/2 before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:content-[\"\"]", "focus-visible:ring-ring focus-visible:ring-offset-background outline-none focus-visible:ring-2 focus-visible:ring-offset-2", "transition-transform duration-[var(--duration-fast)] ease-[var(--ease-out)]", "hover:scale-110 data-[disabled]:pointer-events-none data-[disabled]:opacity-50"),
|
|
37
|
+
"aria-label": w(n),
|
|
38
|
+
"aria-labelledby": !b && c && !C ? x : void 0
|
|
39
|
+
}, n))]
|
|
40
|
+
})]
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
c.displayName = "Slider";
|
|
44
|
+
//#endregion
|
|
45
|
+
export { c as Slider };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=Slider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.js","sources":["../../../src/components/ui/Slider.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useId,\n useState,\n type ComponentPropsWithoutRef,\n type ElementRef,\n type ReactNode,\n} from 'react';\nimport * as SliderPrimitive from '@radix-ui/react-slider';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\nexport interface SliderProps extends Omit<\n ComponentPropsWithoutRef<typeof SliderPrimitive.Root>,\n 'value' | 'defaultValue'\n> {\n /**\n * Controlled value. Pass `[n]` for a single-thumb slider, `[a, b]` for a range slider.\n */\n value?: number[];\n defaultValue?: number[];\n /** Inline label rendered above the slider. */\n label?: ReactNode;\n /** Show the numeric value next to the label. */\n showValue?: boolean;\n /** Format the displayed value (e.g. `(v) => \\`${v}%\\``). */\n formatValue?: (value: number) => string;\n}\n\n/**\n * Single- or range-thumb slider. Pass one item in `value` for a single\n * thumb, two for a range.\n *\n * @example Single value\n * <Slider label=\"Volume\" showValue defaultValue={[60]} max={100} step={1} />\n *\n * @example Price range\n * <Slider label=\"Price\"\n * defaultValue={[50, 250]}\n * min={0} max={500} step={10}\n * formatValue={(v) => \\`$\\${v}\\`}\n * showValue />\n *\n * @do Use `showValue` when the absolute number matters (price, volume, weight).\n * @dont Hide the value when users will need to reason about exact thresholds.\n */\nexport const Slider = forwardRef<ElementRef<typeof SliderPrimitive.Root>, SliderProps>(\n function Slider(\n {\n className,\n label,\n showValue,\n formatValue = (v) => String(v),\n value,\n defaultValue,\n onValueChange,\n ...props\n },\n ref,\n ) {\n // Uncontrolled sliders track their own value so `showValue` stays live.\n const [internal, setInternal] = useState<number[]>(defaultValue ?? [0]);\n const isControlled = value !== undefined;\n const currentValue = isControlled ? value : internal;\n const isRange = currentValue.length > 1;\n const labelId = useId();\n const strings = useStrings();\n // Only a string label can double as aria-label; ReactNode labels are\n // referenced by id instead.\n const stringLabel = typeof label === 'string' ? label : undefined;\n const thumbLabel = (i: number) =>\n isRange\n ? i === 0\n ? strings.slider.minimum\n : strings.slider.maximum\n : (stringLabel ?? props['aria-label'] ?? strings.slider.value);\n\n return (\n <div className={cn('flex flex-col gap-2', className)}>\n {(label || showValue) && (\n <div className=\"flex items-center justify-between\">\n {label && (\n <span id={labelId} className=\"text-foreground text-sm font-medium\">\n {label}\n </span>\n )}\n {showValue && (\n <span className=\"tabular text-foreground-muted font-mono text-xs\">\n {isRange\n ? `${formatValue(currentValue[0])} – ${formatValue(currentValue[1])}`\n : formatValue(currentValue[0])}\n </span>\n )}\n </div>\n )}\n\n <SliderPrimitive.Root\n ref={ref}\n value={value}\n defaultValue={defaultValue}\n onValueChange={(v) => {\n if (!isControlled) setInternal(v);\n onValueChange?.(v);\n }}\n className=\"relative flex w-full touch-none items-center py-3.5 select-none\"\n aria-labelledby={label && !stringLabel ? labelId : undefined}\n {...props}\n >\n <SliderPrimitive.Track className=\"bg-background-muted relative h-1 w-full grow overflow-hidden rounded-full\">\n <SliderPrimitive.Range className=\"bg-accent absolute h-full\" />\n </SliderPrimitive.Track>\n {currentValue.map((_, i) => (\n <SliderPrimitive.Thumb\n key={i}\n className={cn(\n 'border-accent bg-card relative block size-4 rounded-full border-2 shadow-sm',\n // 44px touch target without growing the visible thumb.\n 'before:absolute before:top-1/2 before:left-1/2 before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:content-[\"\"]',\n 'focus-visible:ring-ring focus-visible:ring-offset-background outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-transform duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'hover:scale-110 data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n )}\n aria-label={thumbLabel(i)}\n aria-labelledby={!isRange && label && !stringLabel ? labelId : undefined}\n />\n ))}\n </SliderPrimitive.Root>\n </div>\n );\n },\n);\n\nSlider.displayName = 'Slider';\n"],"
|
|
1
|
+
{"version":3,"file":"Slider.js","names":[],"sources":["../../../src/components/ui/Slider.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useId,\n useState,\n type ComponentPropsWithoutRef,\n type ElementRef,\n type ReactNode,\n} from 'react';\nimport * as SliderPrimitive from '@radix-ui/react-slider';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\nexport interface SliderProps extends Omit<\n ComponentPropsWithoutRef<typeof SliderPrimitive.Root>,\n 'value' | 'defaultValue'\n> {\n /**\n * Controlled value. Pass `[n]` for a single-thumb slider, `[a, b]` for a range slider.\n */\n value?: number[];\n defaultValue?: number[];\n /** Inline label rendered above the slider. */\n label?: ReactNode;\n /** Show the numeric value next to the label. */\n showValue?: boolean;\n /** Format the displayed value (e.g. `(v) => \\`${v}%\\``). */\n formatValue?: (value: number) => string;\n}\n\n/**\n * Single- or range-thumb slider. Pass one item in `value` for a single\n * thumb, two for a range.\n *\n * @example Single value\n * <Slider label=\"Volume\" showValue defaultValue={[60]} max={100} step={1} />\n *\n * @example Price range\n * <Slider label=\"Price\"\n * defaultValue={[50, 250]}\n * min={0} max={500} step={10}\n * formatValue={(v) => \\`$\\${v}\\`}\n * showValue />\n *\n * @do Use `showValue` when the absolute number matters (price, volume, weight).\n * @dont Hide the value when users will need to reason about exact thresholds.\n */\nexport const Slider = forwardRef<ElementRef<typeof SliderPrimitive.Root>, SliderProps>(\n function Slider(\n {\n className,\n label,\n showValue,\n formatValue = (v) => String(v),\n value,\n defaultValue,\n onValueChange,\n ...props\n },\n ref,\n ) {\n // Uncontrolled sliders track their own value so `showValue` stays live.\n const [internal, setInternal] = useState<number[]>(defaultValue ?? [0]);\n const isControlled = value !== undefined;\n const currentValue = isControlled ? value : internal;\n const isRange = currentValue.length > 1;\n const labelId = useId();\n const strings = useStrings();\n // Only a string label can double as aria-label; ReactNode labels are\n // referenced by id instead.\n const stringLabel = typeof label === 'string' ? label : undefined;\n const thumbLabel = (i: number) =>\n isRange\n ? i === 0\n ? strings.slider.minimum\n : strings.slider.maximum\n : (stringLabel ?? props['aria-label'] ?? strings.slider.value);\n\n return (\n <div className={cn('flex flex-col gap-2', className)}>\n {(label || showValue) && (\n <div className=\"flex items-center justify-between\">\n {label && (\n <span id={labelId} className=\"text-foreground text-sm font-medium\">\n {label}\n </span>\n )}\n {showValue && (\n <span className=\"tabular text-foreground-muted font-mono text-xs\">\n {isRange\n ? `${formatValue(currentValue[0])} – ${formatValue(currentValue[1])}`\n : formatValue(currentValue[0])}\n </span>\n )}\n </div>\n )}\n\n <SliderPrimitive.Root\n ref={ref}\n value={value}\n defaultValue={defaultValue}\n onValueChange={(v) => {\n if (!isControlled) setInternal(v);\n onValueChange?.(v);\n }}\n className=\"relative flex w-full touch-none items-center py-3.5 select-none\"\n aria-labelledby={label && !stringLabel ? labelId : undefined}\n {...props}\n >\n <SliderPrimitive.Track className=\"bg-background-muted relative h-1 w-full grow overflow-hidden rounded-full\">\n <SliderPrimitive.Range className=\"bg-accent absolute h-full\" />\n </SliderPrimitive.Track>\n {currentValue.map((_, i) => (\n <SliderPrimitive.Thumb\n key={i}\n className={cn(\n 'border-accent bg-card relative block size-4 rounded-full border-2 shadow-sm',\n // 44px touch target without growing the visible thumb.\n 'before:absolute before:top-1/2 before:left-1/2 before:size-11 before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:content-[\"\"]',\n 'focus-visible:ring-ring focus-visible:ring-offset-background outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-transform duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'hover:scale-110 data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n )}\n aria-label={thumbLabel(i)}\n aria-labelledby={!isRange && label && !stringLabel ? labelId : undefined}\n />\n ))}\n </SliderPrimitive.Root>\n </div>\n );\n },\n);\n\nSlider.displayName = 'Slider';\n"],"mappings":";;;;;;;AAgDA,IAAa,IAAS,EACpB,SACE,EACE,cACA,UACA,cACA,kBAAe,MAAM,OAAO,CAAC,GAC7B,UACA,iBACA,kBACA,GAAG,KAEL,GACA;CAEA,IAAM,CAAC,GAAU,KAAe,EAAmB,KAAgB,CAAC,CAAC,CAAC,GAChE,IAAe,MAAU,KAAA,GACzB,IAAe,IAAe,IAAQ,GACtC,IAAU,EAAa,SAAS,GAChC,IAAU,EAAM,GAChB,IAAU,EAAW,GAGrB,IAAc,OAAO,KAAU,WAAW,IAAQ,KAAA,GAClD,KAAc,MAClB,IACI,MAAM,IACJ,EAAQ,OAAO,UACf,EAAQ,OAAO,UAChB,KAAe,EAAM,iBAAiB,EAAQ,OAAO;CAE5D,OACE,kBAAC,OAAD;EAAK,WAAW,EAAG,uBAAuB,CAAS;EAAnD,UAAA,EACI,KAAS,MACT,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACG,KACC,kBAAC,QAAD;IAAM,IAAI;IAAS,WAAU;IAC1B,UAAA;GACG,CAAA,GAEP,KACC,kBAAC,QAAD;IAAM,WAAU;IACb,UAAA,IACG,GAAG,EAAY,EAAa,EAAE,EAAE,KAAK,EAAY,EAAa,EAAE,MAChE,EAAY,EAAa,EAAE;GAC3B,CAAA,CAEL;EAGP,CAAA,GAAA,kBAAC,EAAgB,MAAjB;GACO;GACE;GACO;GACd,gBAAgB,MAAM;IAEpB,AADK,KAAc,EAAY,CAAC,GAChC,IAAgB,CAAC;GACnB;GACA,WAAU;GACV,mBAAiB,KAAS,CAAC,IAAc,IAAU,KAAA;GACnD,GAAI;GAVN,UAAA,CAYE,kBAAC,EAAgB,OAAjB;IAAuB,WAAU;IAC/B,UAAA,kBAAC,EAAgB,OAAjB,EAAuB,WAAU,4BAA6B,CAAA;GACzC,CAAA,GACtB,EAAa,KAAK,GAAG,MACpB,kBAAC,EAAgB,OAAjB;IAEE,WAAW,EACT,+EAEA,2JACA,8HACA,+EACA,gFACF;IACA,cAAY,EAAW,CAAC;IACxB,mBAAiB,CAAC,KAAW,KAAS,CAAC,IAAc,IAAU,KAAA;GAChE,GAXM,CAWN,CACF,CACmB;EACnB,CAAA,CAAA;;AAET,CACF;AAEA,EAAO,cAAc"}
|
|
@@ -1,57 +1,77 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { cva as t } from "../../lib/cva.js";
|
|
4
|
+
import { useStrings as n } from "../../hooks/use-strings.js";
|
|
5
|
+
import { AlertTriangle as r, CheckCircle2 as i, Info as a, X as o, XCircle as s } from "../../icons/index.js";
|
|
6
|
+
import { forwardRef as c } from "react";
|
|
7
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/ui/Snackbar.tsx
|
|
9
|
+
var d = t([
|
|
10
|
+
"relative pointer-events-auto w-full max-w-md",
|
|
11
|
+
"flex items-start gap-3 rounded-md border bg-card p-3 shadow-md",
|
|
12
|
+
"text-sm text-foreground"
|
|
13
|
+
], {
|
|
14
|
+
variants: { variant: {
|
|
15
|
+
default: "border-border",
|
|
16
|
+
info: "border-info-border-soft",
|
|
17
|
+
success: "border-success-border-soft",
|
|
18
|
+
warning: "border-warning-border-soft",
|
|
19
|
+
danger: "border-danger-border-soft"
|
|
20
|
+
} },
|
|
21
|
+
defaultVariants: { variant: "default" }
|
|
22
|
+
}), f = {
|
|
23
|
+
default: null,
|
|
24
|
+
info: /* @__PURE__ */ l(a, {
|
|
25
|
+
className: "text-info-text mt-0.5 size-4 shrink-0",
|
|
26
|
+
"aria-hidden": !0
|
|
27
|
+
}),
|
|
28
|
+
success: /* @__PURE__ */ l(i, {
|
|
29
|
+
className: "text-success-text mt-0.5 size-4 shrink-0",
|
|
30
|
+
"aria-hidden": !0
|
|
31
|
+
}),
|
|
32
|
+
warning: /* @__PURE__ */ l(r, {
|
|
33
|
+
className: "text-warning-text mt-0.5 size-4 shrink-0",
|
|
34
|
+
"aria-hidden": !0
|
|
35
|
+
}),
|
|
36
|
+
danger: /* @__PURE__ */ l(s, {
|
|
37
|
+
className: "text-danger-text mt-0.5 size-4 shrink-0",
|
|
38
|
+
"aria-hidden": !0
|
|
39
|
+
})
|
|
40
|
+
}, p = c(function({ className: t, variant: r = "default", title: i, action: a, onClose: s, icon: c, children: p, ...m }, h) {
|
|
41
|
+
let g = n(), _ = c === !1 ? null : c ?? f[r ?? "default"];
|
|
42
|
+
return /* @__PURE__ */ u("div", {
|
|
43
|
+
ref: h,
|
|
44
|
+
role: "status",
|
|
45
|
+
className: e(d({ variant: r }), t),
|
|
46
|
+
...m,
|
|
47
|
+
children: [
|
|
48
|
+
_,
|
|
49
|
+
/* @__PURE__ */ u("div", {
|
|
50
|
+
className: "min-w-0 flex-1",
|
|
51
|
+
children: [i && /* @__PURE__ */ l("p", {
|
|
52
|
+
className: "font-medium",
|
|
53
|
+
children: i
|
|
54
|
+
}), p && /* @__PURE__ */ l("p", {
|
|
55
|
+
className: "text-foreground-muted",
|
|
56
|
+
children: p
|
|
57
|
+
})]
|
|
58
|
+
}),
|
|
59
|
+
a,
|
|
60
|
+
s && /* @__PURE__ */ l("button", {
|
|
61
|
+
type: "button",
|
|
62
|
+
onClick: s,
|
|
63
|
+
"aria-label": g.snackbar.dismiss,
|
|
64
|
+
className: "text-foreground-muted hover:bg-background-muted hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-card rounded p-1 outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
65
|
+
children: /* @__PURE__ */ l(o, {
|
|
66
|
+
className: "size-4",
|
|
67
|
+
"aria-hidden": !0
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
});
|
|
52
72
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=Snackbar.js.map
|
|
73
|
+
p.displayName = "Snackbar";
|
|
74
|
+
//#endregion
|
|
75
|
+
export { p as Snackbar };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=Snackbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snackbar.js","sources":["../../../src/components/ui/Snackbar.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type HTMLAttributes, type ReactNode } from 'react';\nimport { CheckCircle2, Info, AlertTriangle, XCircle, X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { cva, type VariantProps } from '@/lib/cva';\n\nconst snackbar = cva(\n [\n 'relative pointer-events-auto w-full max-w-md',\n 'flex items-start gap-3 rounded-md border bg-card p-3 shadow-md',\n 'text-sm text-foreground',\n ],\n {\n variants: {\n variant: {\n default: 'border-border',\n info: 'border-info-border-soft',\n success: 'border-success-border-soft',\n warning: 'border-warning-border-soft',\n danger: 'border-danger-border-soft',\n },\n },\n defaultVariants: { variant: 'default' },\n },\n);\n\nconst iconForVariant: Record<NonNullable<VariantProps<typeof snackbar>['variant']>, ReactNode> = {\n default: null,\n info: <Info className=\"text-info-text mt-0.5 size-4 shrink-0\" aria-hidden />,\n success: <CheckCircle2 className=\"text-success-text mt-0.5 size-4 shrink-0\" aria-hidden />,\n warning: <AlertTriangle className=\"text-warning-text mt-0.5 size-4 shrink-0\" aria-hidden />,\n danger: <XCircle className=\"text-danger-text mt-0.5 size-4 shrink-0\" aria-hidden />,\n};\n\nexport interface SnackbarProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>, VariantProps<typeof snackbar> {\n /** Headline. */\n title?: ReactNode;\n /** Action button rendered on the right. */\n action?: ReactNode;\n /** Show a close (×) button on the right. */\n onClose?: () => void;\n /** Override the variant's default icon. Pass `false` to hide. */\n icon?: ReactNode | false;\n}\n\n/**\n * Persistent inline notification. Unlike Toast, Snackbar does **not** auto-\n * dismiss. Pair with an `action` button or an `onClose` handler.\n */\nexport const Snackbar = forwardRef<HTMLDivElement, SnackbarProps>(function Snackbar(\n { className, variant = 'default', title, action, onClose, icon, children, ...props },\n ref,\n) {\n const strings = useStrings();\n const renderedIcon = icon === false ? null : (icon ?? iconForVariant[variant ?? 'default']);\n\n return (\n <div ref={ref} role=\"status\" className={cn(snackbar({ variant }), className)} {...props}>\n {renderedIcon}\n <div className=\"min-w-0 flex-1\">\n {title && <p className=\"font-medium\">{title}</p>}\n {children && <p className=\"text-foreground-muted\">{children}</p>}\n </div>\n {action}\n {onClose && (\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={strings.snackbar.dismiss}\n className=\"text-foreground-muted hover:bg-background-muted hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-card rounded p-1 outline-none focus-visible:ring-2 focus-visible:ring-offset-2\"\n >\n <X className=\"size-4\" aria-hidden />\n </button>\n )}\n </div>\n );\n});\nSnackbar.displayName = 'Snackbar';\n"],"
|
|
1
|
+
{"version":3,"file":"Snackbar.js","names":[],"sources":["../../../src/components/ui/Snackbar.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type HTMLAttributes, type ReactNode } from 'react';\nimport { CheckCircle2, Info, AlertTriangle, XCircle, X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { cva, type VariantProps } from '@/lib/cva';\n\nconst snackbar = cva(\n [\n 'relative pointer-events-auto w-full max-w-md',\n 'flex items-start gap-3 rounded-md border bg-card p-3 shadow-md',\n 'text-sm text-foreground',\n ],\n {\n variants: {\n variant: {\n default: 'border-border',\n info: 'border-info-border-soft',\n success: 'border-success-border-soft',\n warning: 'border-warning-border-soft',\n danger: 'border-danger-border-soft',\n },\n },\n defaultVariants: { variant: 'default' },\n },\n);\n\nconst iconForVariant: Record<NonNullable<VariantProps<typeof snackbar>['variant']>, ReactNode> = {\n default: null,\n info: <Info className=\"text-info-text mt-0.5 size-4 shrink-0\" aria-hidden />,\n success: <CheckCircle2 className=\"text-success-text mt-0.5 size-4 shrink-0\" aria-hidden />,\n warning: <AlertTriangle className=\"text-warning-text mt-0.5 size-4 shrink-0\" aria-hidden />,\n danger: <XCircle className=\"text-danger-text mt-0.5 size-4 shrink-0\" aria-hidden />,\n};\n\nexport interface SnackbarProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>, VariantProps<typeof snackbar> {\n /** Headline. */\n title?: ReactNode;\n /** Action button rendered on the right. */\n action?: ReactNode;\n /** Show a close (×) button on the right. */\n onClose?: () => void;\n /** Override the variant's default icon. Pass `false` to hide. */\n icon?: ReactNode | false;\n}\n\n/**\n * Persistent inline notification. Unlike Toast, Snackbar does **not** auto-\n * dismiss. Pair with an `action` button or an `onClose` handler.\n */\nexport const Snackbar = forwardRef<HTMLDivElement, SnackbarProps>(function Snackbar(\n { className, variant = 'default', title, action, onClose, icon, children, ...props },\n ref,\n) {\n const strings = useStrings();\n const renderedIcon = icon === false ? null : (icon ?? iconForVariant[variant ?? 'default']);\n\n return (\n <div ref={ref} role=\"status\" className={cn(snackbar({ variant }), className)} {...props}>\n {renderedIcon}\n <div className=\"min-w-0 flex-1\">\n {title && <p className=\"font-medium\">{title}</p>}\n {children && <p className=\"text-foreground-muted\">{children}</p>}\n </div>\n {action}\n {onClose && (\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={strings.snackbar.dismiss}\n className=\"text-foreground-muted hover:bg-background-muted hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-card rounded p-1 outline-none focus-visible:ring-2 focus-visible:ring-offset-2\"\n >\n <X className=\"size-4\" aria-hidden />\n </button>\n )}\n </div>\n );\n});\nSnackbar.displayName = 'Snackbar';\n"],"mappings":";;;;;;;;AAQA,IAAM,IAAW,EACf;CACE;CACA;CACA;AACF,GACA;CACE,UAAU,EACR,SAAS;EACP,SAAS;EACT,MAAM;EACN,SAAS;EACT,SAAS;EACT,QAAQ;CACV,EACF;CACA,iBAAiB,EAAE,SAAS,UAAU;AACxC,CACF,GAEM,IAA2F;CAC/F,SAAS;CACT,MAAM,kBAAC,GAAD;EAAM,WAAU;EAAwC,eAAA;CAAa,CAAA;CAC3E,SAAS,kBAAC,GAAD;EAAc,WAAU;EAA2C,eAAA;CAAa,CAAA;CACzF,SAAS,kBAAC,GAAD;EAAe,WAAU;EAA2C,eAAA;CAAa,CAAA;CAC1F,QAAQ,kBAAC,GAAD;EAAS,WAAU;EAA0C,eAAA;CAAa,CAAA;AACpF,GAkBa,IAAW,EAA0C,SAChE,EAAE,cAAW,aAAU,WAAW,UAAO,WAAQ,YAAS,SAAM,aAAU,GAAG,KAC7E,GACA;CACA,IAAM,IAAU,EAAW,GACrB,IAAe,MAAS,KAAQ,OAAQ,KAAQ,EAAe,KAAW;CAEhF,OACE,kBAAC,OAAD;EAAU;EAAK,MAAK;EAAS,WAAW,EAAG,EAAS,EAAE,WAAQ,CAAC,GAAG,CAAS;EAAG,GAAI;EAAlF,UAAA;GACG;GACD,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,KAAS,kBAAC,KAAD;KAAG,WAAU;KAAe,UAAA;IAAS,CAAA,GAC9C,KAAY,kBAAC,KAAD;KAAG,WAAU;KAAyB;IAAY,CAAA,CAC5D;;GACJ;GACA,KACC,kBAAC,UAAD;IACE,MAAK;IACL,SAAS;IACT,cAAY,EAAQ,SAAS;IAC7B,WAAU;IAEV,UAAA,kBAAC,GAAD;KAAG,WAAU;KAAS,eAAA;IAAa,CAAA;GAC7B,CAAA;EAEP;;AAET,CAAC;AACD,EAAS,cAAc"}
|
|
@@ -1,54 +1,47 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
strokeLinecap: "round",
|
|
43
|
-
fill: "none"
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
);
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { useStrings as t } from "../../hooks/use-strings.js";
|
|
4
|
+
import { forwardRef as n } from "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/ui/Spinner.tsx
|
|
7
|
+
var a = {
|
|
8
|
+
sm: "size-3.5",
|
|
9
|
+
md: "size-4",
|
|
10
|
+
lg: "size-6"
|
|
11
|
+
}, o = {
|
|
12
|
+
accent: "text-accent",
|
|
13
|
+
neutral: "text-foreground-subtle",
|
|
14
|
+
"on-accent": "text-on-accent"
|
|
15
|
+
}, s = n(function({ className: n, tone: s = "accent", size: c = "md", label: l, decorative: u, ...d }, f) {
|
|
16
|
+
let p = t();
|
|
17
|
+
return /* @__PURE__ */ i("svg", {
|
|
18
|
+
ref: f,
|
|
19
|
+
viewBox: "0 0 24 24",
|
|
20
|
+
role: u ? void 0 : "status",
|
|
21
|
+
"aria-label": u ? void 0 : l ?? p.spinner.loading,
|
|
22
|
+
"aria-hidden": u || void 0,
|
|
23
|
+
"data-motion-keep": "",
|
|
24
|
+
className: e("animate-spin", a[c], o[s], n),
|
|
25
|
+
...d,
|
|
26
|
+
children: [/* @__PURE__ */ r("circle", {
|
|
27
|
+
cx: "12",
|
|
28
|
+
cy: "12",
|
|
29
|
+
r: "10",
|
|
30
|
+
stroke: "currentColor",
|
|
31
|
+
strokeWidth: "2.5",
|
|
32
|
+
strokeOpacity: .2,
|
|
33
|
+
fill: "none"
|
|
34
|
+
}), /* @__PURE__ */ r("path", {
|
|
35
|
+
d: "M12 2a10 10 0 0 1 10 10",
|
|
36
|
+
stroke: "currentColor",
|
|
37
|
+
strokeWidth: "2.5",
|
|
38
|
+
strokeLinecap: "round",
|
|
39
|
+
fill: "none"
|
|
40
|
+
})]
|
|
41
|
+
});
|
|
49
42
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
//# sourceMappingURL=Spinner.js.map
|
|
43
|
+
s.displayName = "Spinner";
|
|
44
|
+
//#endregion
|
|
45
|
+
export { s as Spinner };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=Spinner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spinner.js","sources":["../../../src/components/ui/Spinner.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type SVGProps } from 'react';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\nexport interface SpinnerProps extends SVGProps<SVGSVGElement> {\n /** Visual weight. */\n tone?: 'accent' | 'neutral' | 'on-accent';\n /** Pixel size. */\n size?: 'sm' | 'md' | 'lg';\n /** Accessible label. Required unless `decorative` is true. */\n label?: string;\n /** Hide from assistive tech (set when a parent already announces busy state). */\n decorative?: boolean;\n}\n\nconst sizeMap = { sm: 'size-3.5', md: 'size-4', lg: 'size-6' };\nconst toneMap = {\n accent: 'text-accent',\n neutral: 'text-foreground-subtle',\n 'on-accent': 'text-on-accent',\n};\n\n/**\n * Small indeterminate progress indicator. Use when the operation duration is\n * unknown and Progress isn't appropriate.\n *\n * @example\n * <Spinner label=\"Loading users\" />\n * <Button loading>Saving…</Button> // uses Spinner internally\n *\n * @do Provide a `label` so the busy state is announced.\n * @dont Use a Spinner for tasks that take 300ms+; use Skeleton instead.\n */\nexport const Spinner = forwardRef<SVGSVGElement, SpinnerProps>(function Spinner(\n { className, tone = 'accent', size = 'md', label, decorative, ...props },\n ref,\n) {\n const strings = useStrings();\n return (\n <svg\n ref={ref}\n viewBox=\"0 0 24 24\"\n role={decorative ? undefined : 'status'}\n aria-label={decorative ? undefined : (label ?? strings.spinner.loading)}\n aria-hidden={decorative || undefined}\n // Under prefers-reduced-motion theme.css swaps the spin for a slow\n // (1.6s) opacity pulse via this attribute — busy state stays perceivable.\n data-motion-keep=\"\"\n className={cn('animate-spin', sizeMap[size], toneMap[tone], className)}\n {...props}\n >\n <circle\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeOpacity={0.2}\n fill=\"none\"\n />\n <path\n d=\"M12 2a10 10 0 0 1 10 10\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n fill=\"none\"\n />\n </svg>\n );\n});\nSpinner.displayName = 'Spinner';\n"],"
|
|
1
|
+
{"version":3,"file":"Spinner.js","names":[],"sources":["../../../src/components/ui/Spinner.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, type SVGProps } from 'react';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\nexport interface SpinnerProps extends SVGProps<SVGSVGElement> {\n /** Visual weight. */\n tone?: 'accent' | 'neutral' | 'on-accent';\n /** Pixel size. */\n size?: 'sm' | 'md' | 'lg';\n /** Accessible label. Required unless `decorative` is true. */\n label?: string;\n /** Hide from assistive tech (set when a parent already announces busy state). */\n decorative?: boolean;\n}\n\nconst sizeMap = { sm: 'size-3.5', md: 'size-4', lg: 'size-6' };\nconst toneMap = {\n accent: 'text-accent',\n neutral: 'text-foreground-subtle',\n 'on-accent': 'text-on-accent',\n};\n\n/**\n * Small indeterminate progress indicator. Use when the operation duration is\n * unknown and Progress isn't appropriate.\n *\n * @example\n * <Spinner label=\"Loading users\" />\n * <Button loading>Saving…</Button> // uses Spinner internally\n *\n * @do Provide a `label` so the busy state is announced.\n * @dont Use a Spinner for tasks that take 300ms+; use Skeleton instead.\n */\nexport const Spinner = forwardRef<SVGSVGElement, SpinnerProps>(function Spinner(\n { className, tone = 'accent', size = 'md', label, decorative, ...props },\n ref,\n) {\n const strings = useStrings();\n return (\n <svg\n ref={ref}\n viewBox=\"0 0 24 24\"\n role={decorative ? undefined : 'status'}\n aria-label={decorative ? undefined : (label ?? strings.spinner.loading)}\n aria-hidden={decorative || undefined}\n // Under prefers-reduced-motion theme.css swaps the spin for a slow\n // (1.6s) opacity pulse via this attribute — busy state stays perceivable.\n data-motion-keep=\"\"\n className={cn('animate-spin', sizeMap[size], toneMap[tone], className)}\n {...props}\n >\n <circle\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeOpacity={0.2}\n fill=\"none\"\n />\n <path\n d=\"M12 2a10 10 0 0 1 10 10\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n fill=\"none\"\n />\n </svg>\n );\n});\nSpinner.displayName = 'Spinner';\n"],"mappings":";;;;;;AAiBA,IAAM,IAAU;CAAE,IAAI;CAAY,IAAI;CAAU,IAAI;AAAS,GACvD,IAAU;CACd,QAAQ;CACR,SAAS;CACT,aAAa;AACf,GAaa,IAAU,EAAwC,SAC7D,EAAE,cAAW,UAAO,UAAU,UAAO,MAAM,UAAO,eAAY,GAAG,KACjE,GACA;CACA,IAAM,IAAU,EAAW;CAC3B,OACE,kBAAC,OAAD;EACO;EACL,SAAQ;EACR,MAAM,IAAa,KAAA,IAAY;EAC/B,cAAY,IAAa,KAAA,IAAa,KAAS,EAAQ,QAAQ;EAC/D,eAAa,KAAc,KAAA;EAG3B,oBAAiB;EACjB,WAAW,EAAG,gBAAgB,EAAQ,IAAO,EAAQ,IAAO,CAAS;EACrE,GAAI;EAVN,UAAA,CAYE,kBAAC,UAAD;GACE,IAAG;GACH,IAAG;GACH,GAAE;GACF,QAAO;GACP,aAAY;GACZ,eAAe;GACf,MAAK;EACN,CAAA,GACD,kBAAC,QAAD;GACE,GAAE;GACF,QAAO;GACP,aAAY;GACZ,eAAc;GACd,MAAK;EACN,CAAA,CACE;;AAET,CAAC;AACD,EAAQ,cAAc"}
|