@craftzbay/ui 0.11.3 → 0.11.4
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-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 +27 -33
- package/dist-lib/hooks/use-debounce.js.map +1 -1
- package/dist-lib/hooks/use-delayed-loading.js +19 -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.js +20 -15
- 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.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 +50 -50
- 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,20 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import { useEffect as e, useRef as t, useState as n } from "react";
|
|
3
|
+
//#region src/hooks/use-delayed-loading.ts
|
|
4
|
+
function r(r, { minVisible: i = 500 } = {}) {
|
|
5
|
+
let [a, o] = n(r <= 0), s = t(r <= 0 ? Date.now() : null);
|
|
6
|
+
return e(() => {
|
|
7
|
+
let e = () => {
|
|
8
|
+
s.current = Date.now(), o(!0);
|
|
9
|
+
};
|
|
10
|
+
if (r <= 0) {
|
|
11
|
+
s.current ??= Date.now(), o(!0);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
let t = s.current === null ? 0 : Math.max(0, i - (Date.now() - s.current)), n = [];
|
|
15
|
+
return t > 0 ? n.push(window.setTimeout(() => o(!1), t)) : o(!1), n.push(window.setTimeout(e, t + r)), () => n.forEach((e) => window.clearTimeout(e));
|
|
16
|
+
}, [r, i]), a;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=use-delayed-loading.js.map
|
|
18
|
+
//#endregion
|
|
19
|
+
export { r as useDelayedLoading };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=use-delayed-loading.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-delayed-loading.js","sources":["../../src/hooks/use-delayed-loading.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nexport interface DelayedLoadingOptions {\n /**\n * Once `true`, the value holds for at least this many ms even if `ms`\n * changes, so a placeholder that did appear never flickers away. Default 500.\n */\n minVisible?: number;\n}\n\n/**\n * Returns `false` until `ms` has elapsed, then `true`. Gate skeletons and\n * spinners behind it so sub-300ms loads never flash a placeholder.\n * `ms <= 0` returns `true` immediately (and synchronously on first render).\n *\n * Once shown, the value stays `true` for `minVisible` ms (default 500). Keep\n * the gated component mounted for that window on the consumer side too —\n * unmounting it early defeats the hold.\n *\n * @example\n * const showSkeleton = useDelayedLoading(300);\n * if (isLoading) return showSkeleton ? <Skeleton /> : null;\n */\nexport function useDelayedLoading(\n ms: number,\n { minVisible = 500 }: DelayedLoadingOptions = {},\n): boolean {\n const [ready, setReady] = useState(ms <= 0);\n const shownAt = useRef<number | null>(ms <= 0 ? Date.now() : null);\n\n useEffect(() => {\n const show = () => {\n shownAt.current = Date.now();\n setReady(true);\n };\n if (ms <= 0) {\n shownAt.current ??= Date.now();\n setReady(true);\n return;\n }\n // Respect the minimum-visible window before hiding again.\n const hold =\n shownAt.current === null ? 0 : Math.max(0, minVisible - (Date.now() - shownAt.current));\n const timers: number[] = [];\n if (hold > 0) {\n timers.push(window.setTimeout(() => setReady(false), hold));\n } else {\n setReady(false);\n }\n timers.push(window.setTimeout(show, hold + ms));\n return () => timers.forEach((t) => window.clearTimeout(t));\n }, [ms, minVisible]);\n\n return ready;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"use-delayed-loading.js","names":[],"sources":["../../src/hooks/use-delayed-loading.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nexport interface DelayedLoadingOptions {\n /**\n * Once `true`, the value holds for at least this many ms even if `ms`\n * changes, so a placeholder that did appear never flickers away. Default 500.\n */\n minVisible?: number;\n}\n\n/**\n * Returns `false` until `ms` has elapsed, then `true`. Gate skeletons and\n * spinners behind it so sub-300ms loads never flash a placeholder.\n * `ms <= 0` returns `true` immediately (and synchronously on first render).\n *\n * Once shown, the value stays `true` for `minVisible` ms (default 500). Keep\n * the gated component mounted for that window on the consumer side too —\n * unmounting it early defeats the hold.\n *\n * @example\n * const showSkeleton = useDelayedLoading(300);\n * if (isLoading) return showSkeleton ? <Skeleton /> : null;\n */\nexport function useDelayedLoading(\n ms: number,\n { minVisible = 500 }: DelayedLoadingOptions = {},\n): boolean {\n const [ready, setReady] = useState(ms <= 0);\n const shownAt = useRef<number | null>(ms <= 0 ? Date.now() : null);\n\n useEffect(() => {\n const show = () => {\n shownAt.current = Date.now();\n setReady(true);\n };\n if (ms <= 0) {\n shownAt.current ??= Date.now();\n setReady(true);\n return;\n }\n // Respect the minimum-visible window before hiding again.\n const hold =\n shownAt.current === null ? 0 : Math.max(0, minVisible - (Date.now() - shownAt.current));\n const timers: number[] = [];\n if (hold > 0) {\n timers.push(window.setTimeout(() => setReady(false), hold));\n } else {\n setReady(false);\n }\n timers.push(window.setTimeout(show, hold + ms));\n return () => timers.forEach((t) => window.clearTimeout(t));\n }, [ms, minVisible]);\n\n return ready;\n}\n"],"mappings":";;;AAyBA,SAAgB,EACd,GACA,EAAE,gBAAa,QAA+B,CAAC,GACtC;CACT,IAAM,CAAC,GAAO,KAAY,EAAS,KAAM,CAAC,GACpC,IAAU,EAAsB,KAAM,IAAI,KAAK,IAAI,IAAI,IAAI;CAyBjE,OAvBA,QAAgB;EACd,IAAM,UAAa;GAEjB,AADA,EAAQ,UAAU,KAAK,IAAI,GAC3B,EAAS,EAAI;EACf;EACA,IAAI,KAAM,GAAG;GAEX,AADA,EAAQ,YAAY,KAAK,IAAI,GAC7B,EAAS,EAAI;GACb;EACF;EAEA,IAAM,IACJ,EAAQ,YAAY,OAAO,IAAI,KAAK,IAAI,GAAG,KAAc,KAAK,IAAI,IAAI,EAAQ,QAAQ,GAClF,IAAmB,CAAC;EAO1B,OANI,IAAO,IACT,EAAO,KAAK,OAAO,iBAAiB,EAAS,EAAK,GAAG,CAAI,CAAC,IAE1D,EAAS,EAAK,GAEhB,EAAO,KAAK,OAAO,WAAW,GAAM,IAAO,CAAE,CAAC,SACjC,EAAO,SAAS,MAAM,OAAO,aAAa,CAAC,CAAC;CAC3D,GAAG,CAAC,GAAI,CAAU,CAAC,GAEZ;AACT"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useId as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
describedBy: t.length ? t.join(" ") : void 0
|
|
13
|
-
};
|
|
2
|
+
import { useId as e } from "react";
|
|
3
|
+
//#region src/hooks/use-field-ids.ts
|
|
4
|
+
function t(t, n = {}) {
|
|
5
|
+
let r = e(), i = t ?? r, a = `${i}-desc`, o = `${i}-error`, s = [n.hasError ? o : n.hasHelper ? a : void 0, n.extra].filter(Boolean);
|
|
6
|
+
return {
|
|
7
|
+
fieldId: i,
|
|
8
|
+
helperId: a,
|
|
9
|
+
errorId: o,
|
|
10
|
+
describedBy: s.length ? s.join(" ") : void 0
|
|
11
|
+
};
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=use-field-ids.js.map
|
|
13
|
+
//#endregion
|
|
14
|
+
export { t as useFieldIds };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=use-field-ids.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-field-ids.js","sources":["../../src/hooks/use-field-ids.ts"],"sourcesContent":["'use client';\n\nimport { useId } from 'react';\n\nexport interface FieldIds {\n /** Id for the control itself (`<input id>` / `<label htmlFor>`). */\n fieldId: string;\n /** Id for the description / helper text element (`<fieldId>-desc`). */\n helperId: string;\n /** Id for the validation message element. */\n errorId: string;\n /**\n * `aria-describedby` value computed from what actually renders — the error\n * wins over the helper; `undefined` when neither is present.\n */\n describedBy: string | undefined;\n}\n\n/**\n * Shared id wiring for form fields: one stable id for the control plus\n * derived helper / error ids, and an `aria-describedby` that only references\n * elements that exist. Pass a consumer `id` to keep `<label htmlFor>` in sync.\n *\n * @example\n * const { fieldId, helperId, errorId, describedBy } = useFieldIds(id, {\n * hasHelper: Boolean(helperText),\n * hasError: Boolean(error),\n * });\n */\nexport function useFieldIds(\n id?: string,\n present: {\n hasHelper?: boolean;\n hasError?: boolean;\n /** Consumer-supplied `aria-describedby` ids, appended after the helper / error id. */\n extra?: string;\n } = {},\n): FieldIds {\n const autoId = useId();\n const fieldId = id ?? autoId;\n const helperId = `${fieldId}-desc`;\n const errorId = `${fieldId}-error`;\n const parts = [\n present.hasError ? errorId : present.hasHelper ? helperId : undefined,\n present.extra,\n ].filter(Boolean);\n return {\n fieldId,\n helperId,\n errorId,\n describedBy: parts.length ? parts.join(' ') : undefined,\n };\n}\n"],"
|
|
1
|
+
{"version":3,"file":"use-field-ids.js","names":[],"sources":["../../src/hooks/use-field-ids.ts"],"sourcesContent":["'use client';\n\nimport { useId } from 'react';\n\nexport interface FieldIds {\n /** Id for the control itself (`<input id>` / `<label htmlFor>`). */\n fieldId: string;\n /** Id for the description / helper text element (`<fieldId>-desc`). */\n helperId: string;\n /** Id for the validation message element. */\n errorId: string;\n /**\n * `aria-describedby` value computed from what actually renders — the error\n * wins over the helper; `undefined` when neither is present.\n */\n describedBy: string | undefined;\n}\n\n/**\n * Shared id wiring for form fields: one stable id for the control plus\n * derived helper / error ids, and an `aria-describedby` that only references\n * elements that exist. Pass a consumer `id` to keep `<label htmlFor>` in sync.\n *\n * @example\n * const { fieldId, helperId, errorId, describedBy } = useFieldIds(id, {\n * hasHelper: Boolean(helperText),\n * hasError: Boolean(error),\n * });\n */\nexport function useFieldIds(\n id?: string,\n present: {\n hasHelper?: boolean;\n hasError?: boolean;\n /** Consumer-supplied `aria-describedby` ids, appended after the helper / error id. */\n extra?: string;\n } = {},\n): FieldIds {\n const autoId = useId();\n const fieldId = id ?? autoId;\n const helperId = `${fieldId}-desc`;\n const errorId = `${fieldId}-error`;\n const parts = [\n present.hasError ? errorId : present.hasHelper ? helperId : undefined,\n present.extra,\n ].filter(Boolean);\n return {\n fieldId,\n helperId,\n errorId,\n describedBy: parts.length ? parts.join(' ') : undefined,\n };\n}\n"],"mappings":";;;AA6BA,SAAgB,EACd,GACA,IAKI,CAAC,GACK;CACV,IAAM,IAAS,EAAM,GACf,IAAU,KAAM,GAChB,IAAW,GAAG,EAAQ,QACtB,IAAU,GAAG,EAAQ,SACrB,IAAQ,CACZ,EAAQ,WAAW,IAAU,EAAQ,YAAY,IAAW,KAAA,GAC5D,EAAQ,KACV,CAAC,CAAC,OAAO,OAAO;CAChB,OAAO;EACL;EACA;EACA;EACA,aAAa,EAAM,SAAS,EAAM,KAAK,GAAG,IAAI,KAAA;CAChD;AACF"}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useCallback as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[e]
|
|
12
|
-
);
|
|
13
|
-
return d(i, () => typeof window < "u" && window.matchMedia ? window.matchMedia(e).matches : !1, () => !1);
|
|
2
|
+
import { useCallback as e, useSyncExternalStore as t } from "react";
|
|
3
|
+
//#region src/hooks/use-media-query.ts
|
|
4
|
+
function n(n) {
|
|
5
|
+
let r = e((e) => {
|
|
6
|
+
if (typeof window > "u" || !window.matchMedia) return () => {};
|
|
7
|
+
let t = window.matchMedia(n);
|
|
8
|
+
return t.addEventListener("change", e), () => t.removeEventListener("change", e);
|
|
9
|
+
}, [n]);
|
|
10
|
+
return t(r, () => typeof window < "u" && window.matchMedia ? window.matchMedia(n).matches : !1, () => !1);
|
|
14
11
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
12
|
+
function r() {
|
|
13
|
+
return n("(prefers-reduced-motion: reduce)");
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=use-media-query.js.map
|
|
15
|
+
//#endregion
|
|
16
|
+
export { n as useMediaQuery, r as usePrefersReducedMotion };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=use-media-query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-media-query.js","sources":["../../src/hooks/use-media-query.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useSyncExternalStore } from 'react';\n\n/**\n * Subscribe to a CSS media query. SSR- and hydration-safe: the server snapshot\n * is always `false`, and the client re-renders with the real value after\n * hydration instead of producing a markup mismatch.\n *\n * @example\n * const isDesktop = useMediaQuery('(min-width: 1024px)');\n */\nexport function useMediaQuery(query: string): boolean {\n const subscribe = useCallback(\n (onChange: () => void) => {\n if (typeof window === 'undefined' || !window.matchMedia) return () => {};\n const list = window.matchMedia(query);\n list.addEventListener('change', onChange);\n return () => list.removeEventListener('change', onChange);\n },\n [query],\n );\n const getSnapshot = () =>\n typeof window !== 'undefined' && window.matchMedia ? window.matchMedia(query).matches : false;\n return useSyncExternalStore(subscribe, getSnapshot, () => false);\n}\n\n/** Convenience: respect `prefers-reduced-motion`. */\nexport function usePrefersReducedMotion(): boolean {\n return useMediaQuery('(prefers-reduced-motion: reduce)');\n}\n"],"
|
|
1
|
+
{"version":3,"file":"use-media-query.js","names":[],"sources":["../../src/hooks/use-media-query.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useSyncExternalStore } from 'react';\n\n/**\n * Subscribe to a CSS media query. SSR- and hydration-safe: the server snapshot\n * is always `false`, and the client re-renders with the real value after\n * hydration instead of producing a markup mismatch.\n *\n * @example\n * const isDesktop = useMediaQuery('(min-width: 1024px)');\n */\nexport function useMediaQuery(query: string): boolean {\n const subscribe = useCallback(\n (onChange: () => void) => {\n if (typeof window === 'undefined' || !window.matchMedia) return () => {};\n const list = window.matchMedia(query);\n list.addEventListener('change', onChange);\n return () => list.removeEventListener('change', onChange);\n },\n [query],\n );\n const getSnapshot = () =>\n typeof window !== 'undefined' && window.matchMedia ? window.matchMedia(query).matches : false;\n return useSyncExternalStore(subscribe, getSnapshot, () => false);\n}\n\n/** Convenience: respect `prefers-reduced-motion`. */\nexport function usePrefersReducedMotion(): boolean {\n return useMediaQuery('(prefers-reduced-motion: reduce)');\n}\n"],"mappings":";;;AAYA,SAAgB,EAAc,GAAwB;CACpD,IAAM,IAAY,GACf,MAAyB;EACxB,IAAI,OAAO,SAAW,OAAe,CAAC,OAAO,YAAY,aAAa,CAAC;EACvE,IAAM,IAAO,OAAO,WAAW,CAAK;EAEpC,OADA,EAAK,iBAAiB,UAAU,CAAQ,SAC3B,EAAK,oBAAoB,UAAU,CAAQ;CAC1D,GACA,CAAC,CAAK,CACR;CAGA,OAAO,EAAqB,SAD1B,OAAO,SAAW,OAAe,OAAO,aAAa,OAAO,WAAW,CAAK,CAAC,CAAC,UAAU,UAChC,EAAK;AACjE;AAGA,SAAgB,IAAmC;CACjD,OAAO,EAAc,kCAAkC;AACzD"}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect as e, useState as t } from "react";
|
|
3
|
+
//#region src/hooks/use-modifier-key.ts
|
|
3
4
|
function n() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return /mac|iphone|ipad|ipod/i.test(t) || /Mac OS X/i.test(e.userAgent ?? "");
|
|
5
|
+
if (typeof navigator > "u") return !1;
|
|
6
|
+
let e = navigator, t = e.userAgentData?.platform ?? e.platform ?? "";
|
|
7
|
+
return /mac|iphone|ipad|ipod/i.test(t) || /Mac OS X/i.test(e.userAgent ?? "");
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
function r() {
|
|
10
|
+
let [r, i] = t(!1);
|
|
11
|
+
return e(() => {
|
|
12
|
+
i(n());
|
|
13
|
+
}, []), r ? {
|
|
14
|
+
symbol: "⌘",
|
|
15
|
+
label: "Cmd"
|
|
16
|
+
} : {
|
|
17
|
+
symbol: "Ctrl",
|
|
18
|
+
label: "Ctrl"
|
|
19
|
+
};
|
|
14
20
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=use-modifier-key.js.map
|
|
21
|
+
//#endregion
|
|
22
|
+
export { n as isApplePlatform, r as useModifierKey };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=use-modifier-key.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-modifier-key.js","sources":["../../src/hooks/use-modifier-key.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\n/** True on macOS / iOS / iPadOS, where the command modifier is ⌘. */\nexport function isApplePlatform(): boolean {\n if (typeof navigator === 'undefined') return false;\n const nav = navigator as Navigator & { userAgentData?: { platform?: string } };\n const platform = nav.userAgentData?.platform ?? nav.platform ?? '';\n return /mac|iphone|ipad|ipod/i.test(platform) || /Mac OS X/i.test(nav.userAgent ?? '');\n}\n\nexport interface ModifierKey {\n /** Glyph for `<Kbd>`: `⌘` on Apple platforms, `Ctrl` elsewhere. */\n symbol: '⌘' | 'Ctrl';\n /** Spoken/long form for aria-labels and tooltips: `Cmd` / `Ctrl`. */\n label: 'Cmd' | 'Ctrl';\n}\n\n/**\n * Platform-correct command modifier for shortcut hints (⌘K vs Ctrl K).\n * Defaults to Ctrl until mounted so server output is deterministic.\n */\nexport function useModifierKey(): ModifierKey {\n const [apple, setApple] = useState(false);\n useEffect(() => {\n setApple(isApplePlatform());\n }, []);\n return apple ? { symbol: '⌘', label: 'Cmd' } : { symbol: 'Ctrl', label: 'Ctrl' };\n}\n"],"
|
|
1
|
+
{"version":3,"file":"use-modifier-key.js","names":[],"sources":["../../src/hooks/use-modifier-key.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\n/** True on macOS / iOS / iPadOS, where the command modifier is ⌘. */\nexport function isApplePlatform(): boolean {\n if (typeof navigator === 'undefined') return false;\n const nav = navigator as Navigator & { userAgentData?: { platform?: string } };\n const platform = nav.userAgentData?.platform ?? nav.platform ?? '';\n return /mac|iphone|ipad|ipod/i.test(platform) || /Mac OS X/i.test(nav.userAgent ?? '');\n}\n\nexport interface ModifierKey {\n /** Glyph for `<Kbd>`: `⌘` on Apple platforms, `Ctrl` elsewhere. */\n symbol: '⌘' | 'Ctrl';\n /** Spoken/long form for aria-labels and tooltips: `Cmd` / `Ctrl`. */\n label: 'Cmd' | 'Ctrl';\n}\n\n/**\n * Platform-correct command modifier for shortcut hints (⌘K vs Ctrl K).\n * Defaults to Ctrl until mounted so server output is deterministic.\n */\nexport function useModifierKey(): ModifierKey {\n const [apple, setApple] = useState(false);\n useEffect(() => {\n setApple(isApplePlatform());\n }, []);\n return apple ? { symbol: '⌘', label: 'Cmd' } : { symbol: 'Ctrl', label: 'Ctrl' };\n}\n"],"mappings":";;;AAKA,SAAgB,IAA2B;CACzC,IAAI,OAAO,YAAc,KAAa,OAAO;CAC7C,IAAM,IAAM,WACN,IAAW,EAAI,eAAe,YAAY,EAAI,YAAY;CAChE,OAAO,wBAAwB,KAAK,CAAQ,KAAK,YAAY,KAAK,EAAI,aAAa,EAAE;AACvF;AAaA,SAAgB,IAA8B;CAC5C,IAAM,CAAC,GAAO,KAAY,EAAS,EAAK;CAIxC,OAHA,QAAgB;EACd,EAAS,EAAgB,CAAC;CAC5B,GAAG,CAAC,CAAC,GACE,IAAQ;EAAE,QAAQ;EAAK,OAAO;CAAM,IAAI;EAAE,QAAQ;EAAQ,OAAO;CAAO;AACjF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { defaultStrings as e } from "../lib/strings.js";
|
|
3
|
+
import { createContext as t, useContext as n } from "react";
|
|
4
|
+
//#region src/hooks/use-strings.ts
|
|
5
|
+
var r = t(e);
|
|
6
|
+
function i() {
|
|
7
|
+
return n(r);
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=use-strings.js.map
|
|
9
|
+
//#endregion
|
|
10
|
+
export { r as StringsContext, i as useStrings };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=use-strings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-strings.js","sources":["../../src/hooks/use-strings.ts"],"sourcesContent":["'use client';\n\nimport { createContext, useContext } from 'react';\nimport { defaultStrings, type UiStrings } from '@/lib/strings';\n\n/** Resolved (complete) strings for the current subtree. */\nexport const StringsContext = createContext<UiStrings>(defaultStrings);\n\n/** Read the library strings — falls back to the English defaults without a provider. */\nexport function useStrings(): UiStrings {\n return useContext(StringsContext);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"use-strings.js","names":[],"sources":["../../src/hooks/use-strings.ts"],"sourcesContent":["'use client';\n\nimport { createContext, useContext } from 'react';\nimport { defaultStrings, type UiStrings } from '@/lib/strings';\n\n/** Resolved (complete) strings for the current subtree. */\nexport const StringsContext = createContext<UiStrings>(defaultStrings);\n\n/** Read the library strings — falls back to the English defaults without a provider. */\nexport function useStrings(): UiStrings {\n return useContext(StringsContext);\n}\n"],"mappings":";;;;AAMA,IAAa,IAAiB,EAAyB,CAAc;AAGrE,SAAgB,IAAwB;CACtC,OAAO,EAAW,CAAc;AAClC"}
|
|
@@ -1,67 +1,78 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { useCallback as e, useSyncExternalStore as t } from "react";
|
|
3
|
+
//#region src/hooks/use-toast.ts
|
|
4
|
+
var n = 3, r = [], i = {
|
|
5
|
+
default: 4e3,
|
|
6
|
+
success: 4e3,
|
|
7
|
+
info: 4e3,
|
|
8
|
+
warning: 6e3,
|
|
9
|
+
danger: 0
|
|
9
10
|
};
|
|
10
|
-
function
|
|
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
|
-
|
|
11
|
+
function a() {
|
|
12
|
+
return {
|
|
13
|
+
toasts: r,
|
|
14
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
15
|
+
emit() {
|
|
16
|
+
for (let e of this.listeners) e();
|
|
17
|
+
},
|
|
18
|
+
push(e) {
|
|
19
|
+
let t = e.id ?? `t_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`, r = this.toasts.find((e) => e.id === t), a;
|
|
20
|
+
if (r) a = this.toasts.map((n) => {
|
|
21
|
+
if (n.id !== t) return n;
|
|
22
|
+
let r = e.variant ?? n.variant ?? "default", a = e.duration ?? (e.variant ? i[r] : n.duration);
|
|
23
|
+
return {
|
|
24
|
+
...n,
|
|
25
|
+
...e,
|
|
26
|
+
id: t,
|
|
27
|
+
variant: r,
|
|
28
|
+
duration: a,
|
|
29
|
+
open: !0
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
else {
|
|
33
|
+
let n = e.variant ?? "default";
|
|
34
|
+
a = [{
|
|
35
|
+
...e,
|
|
36
|
+
id: t,
|
|
37
|
+
open: !0,
|
|
38
|
+
variant: n,
|
|
39
|
+
duration: e.duration ?? i[n]
|
|
40
|
+
}, ...this.toasts];
|
|
41
|
+
}
|
|
42
|
+
let o = 0;
|
|
43
|
+
return this.toasts = a.filter((e) => e.duration === 0 || o++ < n), this.emit(), t;
|
|
44
|
+
},
|
|
45
|
+
dismiss(e) {
|
|
46
|
+
this.toasts = this.toasts.map((t) => t.id === e ? {
|
|
47
|
+
...t,
|
|
48
|
+
open: !1
|
|
49
|
+
} : t), this.emit();
|
|
50
|
+
},
|
|
51
|
+
remove(e) {
|
|
52
|
+
this.toasts = this.toasts.filter((t) => t.id !== e), this.emit();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
46
55
|
}
|
|
47
|
-
|
|
48
|
-
function
|
|
49
|
-
|
|
56
|
+
var o = null;
|
|
57
|
+
function s() {
|
|
58
|
+
return o ||= a(), o;
|
|
50
59
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
var c = (e) => {
|
|
61
|
+
let t = s();
|
|
62
|
+
return t.listeners.add(e), () => {
|
|
63
|
+
t.listeners.delete(e);
|
|
64
|
+
};
|
|
65
|
+
}, l = () => s().toasts, u = () => r;
|
|
66
|
+
function d() {
|
|
67
|
+
return {
|
|
68
|
+
toasts: t(c, l, u),
|
|
69
|
+
push: e((e) => s().push(e), []),
|
|
70
|
+
dismiss: e((e) => s().dismiss(e), []),
|
|
71
|
+
remove: e((e) => s().remove(e), [])
|
|
72
|
+
};
|
|
60
73
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=use-toast.js.map
|
|
74
|
+
var f = (e) => s().push(e);
|
|
75
|
+
//#endregion
|
|
76
|
+
export { i as TOAST_DURATIONS, f as toast, d as useToast };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=use-toast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-toast.js","sources":["../../src/hooks/use-toast.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useSyncExternalStore, type ReactNode } from 'react';\n\n/* -----------------------------------------------------------------------------\n * Minimal toast queue + hook. The host app mounts a single <Toaster> near\n * the root which subscribes to this store; any component can call\n * `useToast().push({...})` from anywhere.\n *\n * Kept dependency-free intentionally — no external state library.\n * --------------------------------------------------------------------------- */\n\nexport type ToastVariant = 'default' | 'success' | 'warning' | 'danger' | 'info';\n\nexport interface ToastDescriptor {\n /** Auto-generated; pass an explicit id to update an in-flight toast in place. */\n id?: string;\n title?: ReactNode;\n description?: ReactNode;\n variant?: ToastVariant;\n /**\n * Milliseconds before auto-dismiss. Defaults per variant: success/info/default\n * 4000, warning 6000, danger 0 (stays until closed). Set to 0 to keep open.\n */\n duration?: number;\n /** Action button. The alt text is used for screen reader announcements. */\n action?: {\n label: ReactNode;\n altText: string;\n onClick: () => void;\n };\n}\n\ninterface InternalToast extends ToastDescriptor {\n id: string;\n open: boolean;\n}\n\ntype Listener = () => void;\n\n/** Max auto-dismissing toasts kept in the queue. Persistent (`duration: 0`) toasts never count. */\nconst MAX_VISIBLE = 3;\n\ninterface ToastStore {\n toasts: InternalToast[];\n listeners: Set<Listener>;\n emit(): void;\n push(t: ToastDescriptor): string;\n dismiss(id: string): void;\n remove(id: string): void;\n}\n\nconst EMPTY: InternalToast[] = [];\n\n/** Per-variant auto-dismiss defaults (ms). Errors persist until the user closes them. */\nexport const TOAST_DURATIONS: Record<ToastVariant, number> = {\n default: 4000,\n success: 4000,\n info: 4000,\n warning: 6000,\n danger: 0,\n};\n\nfunction createStore(): ToastStore {\n return {\n toasts: EMPTY,\n listeners: new Set<Listener>(),\n emit() {\n for (const listener of this.listeners) listener();\n },\n push(t) {\n const id = t.id ?? `t_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`;\n const existing = this.toasts.find((x) => x.id === id);\n let merged: InternalToast[];\n if (existing) {\n // Same id → update in place, keep queue position, re-open if it was closing.\n merged = this.toasts.map((x) => {\n if (x.id !== id) return x;\n const variant = t.variant ?? x.variant ?? 'default';\n const duration = t.duration ?? (t.variant ? TOAST_DURATIONS[variant] : x.duration);\n return { ...x, ...t, id, variant, duration, open: true };\n });\n } else {\n const variant = t.variant ?? 'default';\n const next: InternalToast = {\n ...t,\n id,\n open: true,\n variant,\n duration: t.duration ?? TOAST_DURATIONS[variant],\n };\n merged = [next, ...this.toasts];\n }\n let kept = 0;\n this.toasts = merged.filter((x) => x.duration === 0 || kept++ < MAX_VISIBLE);\n this.emit();\n return id;\n },\n dismiss(id) {\n this.toasts = this.toasts.map((t) => (t.id === id ? { ...t, open: false } : t));\n this.emit();\n },\n remove(id) {\n this.toasts = this.toasts.filter((t) => t.id !== id);\n this.emit();\n },\n };\n}\n\n// Created lazily on first use so a server process never holds toasts that\n// leak across requests; on the client there is exactly one queue.\nlet store: ToastStore | null = null;\nfunction getStore(): ToastStore {\n if (!store) store = createStore();\n return store;\n}\n\nconst subscribe = (listener: Listener) => {\n const s = getStore();\n s.listeners.add(listener);\n return () => {\n s.listeners.delete(listener);\n };\n};\nconst getSnapshot = () => getStore().toasts;\nconst getServerSnapshot = () => EMPTY;\n\n/**\n * Subscribe to the toast queue and dispatch new toasts.\n *\n * @example\n * const toast = useToast();\n * toast.push({ variant: 'success', title: 'Saved' });\n *\n * // With an action\n * toast.push({\n * title: 'Project archived',\n * action: { label: 'Undo', altText: 'Undo archive', onClick: undo },\n * });\n */\nexport function useToast() {\n const toasts = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n\n const push = useCallback((t: ToastDescriptor) => getStore().push(t), []);\n const dismiss = useCallback((id: string) => getStore().dismiss(id), []);\n const remove = useCallback((id: string) => getStore().remove(id), []);\n\n return { toasts, push, dismiss, remove };\n}\n\n/** Convenience export — dispatch a toast outside React (e.g. from an API client). */\nexport const toast = (t: ToastDescriptor) => getStore().push(t);\n"],"
|
|
1
|
+
{"version":3,"file":"use-toast.js","names":[],"sources":["../../src/hooks/use-toast.ts"],"sourcesContent":["'use client';\n\nimport { useCallback, useSyncExternalStore, type ReactNode } from 'react';\n\n/* -----------------------------------------------------------------------------\n * Minimal toast queue + hook. The host app mounts a single <Toaster> near\n * the root which subscribes to this store; any component can call\n * `useToast().push({...})` from anywhere.\n *\n * Kept dependency-free intentionally — no external state library.\n * --------------------------------------------------------------------------- */\n\nexport type ToastVariant = 'default' | 'success' | 'warning' | 'danger' | 'info';\n\nexport interface ToastDescriptor {\n /** Auto-generated; pass an explicit id to update an in-flight toast in place. */\n id?: string;\n title?: ReactNode;\n description?: ReactNode;\n variant?: ToastVariant;\n /**\n * Milliseconds before auto-dismiss. Defaults per variant: success/info/default\n * 4000, warning 6000, danger 0 (stays until closed). Set to 0 to keep open.\n */\n duration?: number;\n /** Action button. The alt text is used for screen reader announcements. */\n action?: {\n label: ReactNode;\n altText: string;\n onClick: () => void;\n };\n}\n\ninterface InternalToast extends ToastDescriptor {\n id: string;\n open: boolean;\n}\n\ntype Listener = () => void;\n\n/** Max auto-dismissing toasts kept in the queue. Persistent (`duration: 0`) toasts never count. */\nconst MAX_VISIBLE = 3;\n\ninterface ToastStore {\n toasts: InternalToast[];\n listeners: Set<Listener>;\n emit(): void;\n push(t: ToastDescriptor): string;\n dismiss(id: string): void;\n remove(id: string): void;\n}\n\nconst EMPTY: InternalToast[] = [];\n\n/** Per-variant auto-dismiss defaults (ms). Errors persist until the user closes them. */\nexport const TOAST_DURATIONS: Record<ToastVariant, number> = {\n default: 4000,\n success: 4000,\n info: 4000,\n warning: 6000,\n danger: 0,\n};\n\nfunction createStore(): ToastStore {\n return {\n toasts: EMPTY,\n listeners: new Set<Listener>(),\n emit() {\n for (const listener of this.listeners) listener();\n },\n push(t) {\n const id = t.id ?? `t_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`;\n const existing = this.toasts.find((x) => x.id === id);\n let merged: InternalToast[];\n if (existing) {\n // Same id → update in place, keep queue position, re-open if it was closing.\n merged = this.toasts.map((x) => {\n if (x.id !== id) return x;\n const variant = t.variant ?? x.variant ?? 'default';\n const duration = t.duration ?? (t.variant ? TOAST_DURATIONS[variant] : x.duration);\n return { ...x, ...t, id, variant, duration, open: true };\n });\n } else {\n const variant = t.variant ?? 'default';\n const next: InternalToast = {\n ...t,\n id,\n open: true,\n variant,\n duration: t.duration ?? TOAST_DURATIONS[variant],\n };\n merged = [next, ...this.toasts];\n }\n let kept = 0;\n this.toasts = merged.filter((x) => x.duration === 0 || kept++ < MAX_VISIBLE);\n this.emit();\n return id;\n },\n dismiss(id) {\n this.toasts = this.toasts.map((t) => (t.id === id ? { ...t, open: false } : t));\n this.emit();\n },\n remove(id) {\n this.toasts = this.toasts.filter((t) => t.id !== id);\n this.emit();\n },\n };\n}\n\n// Created lazily on first use so a server process never holds toasts that\n// leak across requests; on the client there is exactly one queue.\nlet store: ToastStore | null = null;\nfunction getStore(): ToastStore {\n if (!store) store = createStore();\n return store;\n}\n\nconst subscribe = (listener: Listener) => {\n const s = getStore();\n s.listeners.add(listener);\n return () => {\n s.listeners.delete(listener);\n };\n};\nconst getSnapshot = () => getStore().toasts;\nconst getServerSnapshot = () => EMPTY;\n\n/**\n * Subscribe to the toast queue and dispatch new toasts.\n *\n * @example\n * const toast = useToast();\n * toast.push({ variant: 'success', title: 'Saved' });\n *\n * // With an action\n * toast.push({\n * title: 'Project archived',\n * action: { label: 'Undo', altText: 'Undo archive', onClick: undo },\n * });\n */\nexport function useToast() {\n const toasts = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n\n const push = useCallback((t: ToastDescriptor) => getStore().push(t), []);\n const dismiss = useCallback((id: string) => getStore().dismiss(id), []);\n const remove = useCallback((id: string) => getStore().remove(id), []);\n\n return { toasts, push, dismiss, remove };\n}\n\n/** Convenience export — dispatch a toast outside React (e.g. from an API client). */\nexport const toast = (t: ToastDescriptor) => getStore().push(t);\n"],"mappings":";;;AAyCA,IAAM,IAAc,GAWd,IAAyB,CAAC,GAGnB,IAAgD;CAC3D,SAAS;CACT,SAAS;CACT,MAAM;CACN,SAAS;CACT,QAAQ;AACV;AAEA,SAAS,IAA0B;CACjC,OAAO;EACL,QAAQ;EACR,2BAAW,IAAI,IAAc;EAC7B,OAAO;GACL,KAAK,IAAM,KAAY,KAAK,WAAW,EAAS;EAClD;EACA,KAAK,GAAG;GACN,IAAM,IAAK,EAAE,MAAM,KAAK,KAAK,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,KACrE,IAAW,KAAK,OAAO,MAAM,MAAM,EAAE,OAAO,CAAE,GAChD;GACJ,IAAI,GAEF,IAAS,KAAK,OAAO,KAAK,MAAM;IAC9B,IAAI,EAAE,OAAO,GAAI,OAAO;IACxB,IAAM,IAAU,EAAE,WAAW,EAAE,WAAW,WACpC,IAAW,EAAE,aAAa,EAAE,UAAU,EAAgB,KAAW,EAAE;IACzE,OAAO;KAAE,GAAG;KAAG,GAAG;KAAG;KAAI;KAAS;KAAU,MAAM;IAAK;GACzD,CAAC;QACI;IACL,IAAM,IAAU,EAAE,WAAW;IAQ7B,IAAS,CAAC;KANR,GAAG;KACH;KACA,MAAM;KACN;KACA,UAAU,EAAE,YAAY,EAAgB;IAEhC,GAAM,GAAG,KAAK,MAAM;GAChC;GACA,IAAI,IAAO;GAGX,OAFA,KAAK,SAAS,EAAO,QAAQ,MAAM,EAAE,aAAa,KAAK,MAAS,CAAW,GAC3E,KAAK,KAAK,GACH;EACT;EACA,QAAQ,GAAI;GAEV,AADA,KAAK,SAAS,KAAK,OAAO,KAAK,MAAO,EAAE,OAAO,IAAK;IAAE,GAAG;IAAG,MAAM;GAAM,IAAI,CAAE,GAC9E,KAAK,KAAK;EACZ;EACA,OAAO,GAAI;GAET,AADA,KAAK,SAAS,KAAK,OAAO,QAAQ,MAAM,EAAE,OAAO,CAAE,GACnD,KAAK,KAAK;EACZ;CACF;AACF;AAIA,IAAI,IAA2B;AAC/B,SAAS,IAAuB;CAE9B,OADA,AAAY,MAAQ,EAAY,GACzB;AACT;AAEA,IAAM,KAAa,MAAuB;CACxC,IAAM,IAAI,EAAS;CAEnB,OADA,EAAE,UAAU,IAAI,CAAQ,SACX;EACX,EAAE,UAAU,OAAO,CAAQ;CAC7B;AACF,GACM,UAAoB,EAAS,CAAC,CAAC,QAC/B,UAA0B;AAehC,SAAgB,IAAW;CAOzB,OAAO;EAAE,QANM,EAAqB,GAAW,GAAa,CAMnD;EAAQ,MAJJ,GAAa,MAAuB,EAAS,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAIrD;EAAM,SAHP,GAAa,MAAe,EAAS,CAAC,CAAC,QAAQ,CAAE,GAAG,CAAC,CAG9C;EAAS,QAFjB,GAAa,MAAe,EAAS,CAAC,CAAC,OAAO,CAAE,GAAG,CAAC,CAEnC;CAAO;AACzC;AAGA,IAAa,KAAS,MAAuB,EAAS,CAAC,CAAC,KAAK,CAAC"}
|
package/dist-lib/icon.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Icon as
|
|
3
|
-
export {
|
|
4
|
-
c as Icon,
|
|
5
|
-
n as iconNames
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=icon.js.map
|
|
2
|
+
import { Icon as e, iconNames as t } from "./components/ui/Icon.js";
|
|
3
|
+
export { e as Icon, t as iconNames };
|