@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.
Files changed (163) hide show
  1. package/dist-lib/_virtual/_rolldown/runtime.js +11 -0
  2. package/dist-lib/components/ui/Accordion.js +42 -67
  3. package/dist-lib/components/ui/Accordion.js.map +1 -1
  4. package/dist-lib/components/ui/Alert.js +71 -77
  5. package/dist-lib/components/ui/Alert.js.map +1 -1
  6. package/dist-lib/components/ui/Avatar.js +67 -92
  7. package/dist-lib/components/ui/Avatar.js.map +1 -1
  8. package/dist-lib/components/ui/Badge.js +119 -74
  9. package/dist-lib/components/ui/Badge.js.map +1 -1
  10. package/dist-lib/components/ui/Breadcrumbs.js +62 -50
  11. package/dist-lib/components/ui/Breadcrumbs.js.map +1 -1
  12. package/dist-lib/components/ui/Button.js +129 -131
  13. package/dist-lib/components/ui/Button.js.map +1 -1
  14. package/dist-lib/components/ui/Calendar.d.ts +1 -1
  15. package/dist-lib/components/ui/Calendar.js +99 -136
  16. package/dist-lib/components/ui/Calendar.js.map +1 -1
  17. package/dist-lib/components/ui/Card.js +88 -94
  18. package/dist-lib/components/ui/Card.js.map +1 -1
  19. package/dist-lib/components/ui/Carousel.js +125 -170
  20. package/dist-lib/components/ui/Carousel.js.map +1 -1
  21. package/dist-lib/components/ui/Chart.d.ts +3 -3
  22. package/dist-lib/components/ui/Chart.js +435 -464
  23. package/dist-lib/components/ui/Chart.js.map +1 -1
  24. package/dist-lib/components/ui/Checkbox.js +60 -69
  25. package/dist-lib/components/ui/Checkbox.js.map +1 -1
  26. package/dist-lib/components/ui/Combobox.js +179 -192
  27. package/dist-lib/components/ui/Combobox.js.map +1 -1
  28. package/dist-lib/components/ui/CommandPalette.d.ts +2 -2
  29. package/dist-lib/components/ui/CommandPalette.js +106 -167
  30. package/dist-lib/components/ui/CommandPalette.js.map +1 -1
  31. package/dist-lib/components/ui/ContextMenu.d.ts +1 -1
  32. package/dist-lib/components/ui/ContextMenu.js +89 -154
  33. package/dist-lib/components/ui/ContextMenu.js.map +1 -1
  34. package/dist-lib/components/ui/DataGrid.d.ts +1 -1
  35. package/dist-lib/components/ui/DataGrid.js +99 -96
  36. package/dist-lib/components/ui/DataGrid.js.map +1 -1
  37. package/dist-lib/components/ui/DatePicker.js +151 -188
  38. package/dist-lib/components/ui/DatePicker.js.map +1 -1
  39. package/dist-lib/components/ui/DesignSystemProvider.d.ts +1 -1
  40. package/dist-lib/components/ui/DesignSystemProvider.js +120 -130
  41. package/dist-lib/components/ui/DesignSystemProvider.js.map +1 -1
  42. package/dist-lib/components/ui/Dialog.d.ts +3 -3
  43. package/dist-lib/components/ui/Dialog.js +108 -156
  44. package/dist-lib/components/ui/Dialog.js.map +1 -1
  45. package/dist-lib/components/ui/Drawer.d.ts +3 -3
  46. package/dist-lib/components/ui/Drawer.js +90 -124
  47. package/dist-lib/components/ui/Drawer.js.map +1 -1
  48. package/dist-lib/components/ui/DropdownMenu.d.ts +1 -1
  49. package/dist-lib/components/ui/DropdownMenu.js +92 -158
  50. package/dist-lib/components/ui/DropdownMenu.js.map +1 -1
  51. package/dist-lib/components/ui/EmptyState.js +31 -44
  52. package/dist-lib/components/ui/EmptyState.js.map +1 -1
  53. package/dist-lib/components/ui/ErrorState.js +57 -67
  54. package/dist-lib/components/ui/ErrorState.js.map +1 -1
  55. package/dist-lib/components/ui/FileUpload.js +113 -107
  56. package/dist-lib/components/ui/FileUpload.js.map +1 -1
  57. package/dist-lib/components/ui/Form.d.ts +6 -4
  58. package/dist-lib/components/ui/Form.js +117 -122
  59. package/dist-lib/components/ui/Form.js.map +1 -1
  60. package/dist-lib/components/ui/Icon.d.ts +1 -1
  61. package/dist-lib/components/ui/Icon.js +30 -29
  62. package/dist-lib/components/ui/Icon.js.map +1 -1
  63. package/dist-lib/components/ui/IconButton.js +61 -63
  64. package/dist-lib/components/ui/IconButton.js.map +1 -1
  65. package/dist-lib/components/ui/Input.js +133 -156
  66. package/dist-lib/components/ui/Input.js.map +1 -1
  67. package/dist-lib/components/ui/Kbd.js +14 -21
  68. package/dist-lib/components/ui/Kbd.js.map +1 -1
  69. package/dist-lib/components/ui/MultiSelect.js +176 -208
  70. package/dist-lib/components/ui/MultiSelect.js.map +1 -1
  71. package/dist-lib/components/ui/Pagination.js +152 -149
  72. package/dist-lib/components/ui/Pagination.js.map +1 -1
  73. package/dist-lib/components/ui/Popover.js +18 -33
  74. package/dist-lib/components/ui/Popover.js.map +1 -1
  75. package/dist-lib/components/ui/Progress.js +77 -99
  76. package/dist-lib/components/ui/Progress.js.map +1 -1
  77. package/dist-lib/components/ui/RadioGroup.js +51 -80
  78. package/dist-lib/components/ui/RadioGroup.js.map +1 -1
  79. package/dist-lib/components/ui/RelativeTime.js +22 -29
  80. package/dist-lib/components/ui/RelativeTime.js.map +1 -1
  81. package/dist-lib/components/ui/ScrollArea.js +39 -58
  82. package/dist-lib/components/ui/ScrollArea.js.map +1 -1
  83. package/dist-lib/components/ui/Select.js +108 -131
  84. package/dist-lib/components/ui/Select.js.map +1 -1
  85. package/dist-lib/components/ui/Separator.js +18 -24
  86. package/dist-lib/components/ui/Separator.js.map +1 -1
  87. package/dist-lib/components/ui/Sheet.d.ts +2 -2
  88. package/dist-lib/components/ui/Sheet.js +77 -129
  89. package/dist-lib/components/ui/Sheet.js.map +1 -1
  90. package/dist-lib/components/ui/Sidebar.d.ts +1 -1
  91. package/dist-lib/components/ui/Sidebar.js +168 -207
  92. package/dist-lib/components/ui/Sidebar.js.map +1 -1
  93. package/dist-lib/components/ui/Skeleton.js +17 -27
  94. package/dist-lib/components/ui/Skeleton.js.map +1 -1
  95. package/dist-lib/components/ui/Slider.js +45 -62
  96. package/dist-lib/components/ui/Slider.js.map +1 -1
  97. package/dist-lib/components/ui/Snackbar.js +75 -55
  98. package/dist-lib/components/ui/Snackbar.js.map +1 -1
  99. package/dist-lib/components/ui/Spinner.js +45 -52
  100. package/dist-lib/components/ui/Spinner.js.map +1 -1
  101. package/dist-lib/components/ui/Stepper.js +56 -108
  102. package/dist-lib/components/ui/Stepper.js.map +1 -1
  103. package/dist-lib/components/ui/Switch.js +46 -79
  104. package/dist-lib/components/ui/Switch.js.map +1 -1
  105. package/dist-lib/components/ui/Table.js +108 -169
  106. package/dist-lib/components/ui/Table.js.map +1 -1
  107. package/dist-lib/components/ui/Tabs.js +57 -88
  108. package/dist-lib/components/ui/Tabs.js.map +1 -1
  109. package/dist-lib/components/ui/TagInput.js +76 -109
  110. package/dist-lib/components/ui/TagInput.js.map +1 -1
  111. package/dist-lib/components/ui/Textarea.js +74 -86
  112. package/dist-lib/components/ui/Textarea.js.map +1 -1
  113. package/dist-lib/components/ui/Timeline.d.ts +3 -3
  114. package/dist-lib/components/ui/Timeline.js +61 -49
  115. package/dist-lib/components/ui/Timeline.js.map +1 -1
  116. package/dist-lib/components/ui/Toast.d.ts +1 -1
  117. package/dist-lib/components/ui/Toast.js +136 -150
  118. package/dist-lib/components/ui/Toast.js.map +1 -1
  119. package/dist-lib/components/ui/Tooltip.d.ts +2 -2
  120. package/dist-lib/components/ui/Tooltip.js +35 -56
  121. package/dist-lib/components/ui/Tooltip.js.map +1 -1
  122. package/dist-lib/components/ui/TopNav.js +46 -66
  123. package/dist-lib/components/ui/TopNav.js.map +1 -1
  124. package/dist-lib/components/ui/Tree.js +134 -168
  125. package/dist-lib/components/ui/Tree.js.map +1 -1
  126. package/dist-lib/hooks/use-debounce.js +27 -33
  127. package/dist-lib/hooks/use-debounce.js.map +1 -1
  128. package/dist-lib/hooks/use-delayed-loading.js +19 -18
  129. package/dist-lib/hooks/use-delayed-loading.js.map +1 -1
  130. package/dist-lib/hooks/use-field-ids.js +14 -16
  131. package/dist-lib/hooks/use-field-ids.js.map +1 -1
  132. package/dist-lib/hooks/use-media-query.js +15 -19
  133. package/dist-lib/hooks/use-media-query.js.map +1 -1
  134. package/dist-lib/hooks/use-modifier-key.js +20 -15
  135. package/dist-lib/hooks/use-modifier-key.js.map +1 -1
  136. package/dist-lib/hooks/use-strings.js +10 -10
  137. package/dist-lib/hooks/use-strings.js.map +1 -1
  138. package/dist-lib/hooks/use-toast.js +73 -62
  139. package/dist-lib/hooks/use-toast.js.map +1 -1
  140. package/dist-lib/icon.js +2 -6
  141. package/dist-lib/icons/index.js +166 -163
  142. package/dist-lib/icons/index.js.map +1 -1
  143. package/dist-lib/illustrations/index.d.ts +7 -7
  144. package/dist-lib/illustrations/index.js +255 -106
  145. package/dist-lib/illustrations/index.js.map +1 -1
  146. package/dist-lib/index.js +69 -291
  147. package/dist-lib/lib/cva.js +2 -0
  148. package/dist-lib/lib/format.js +71 -87
  149. package/dist-lib/lib/format.js.map +1 -1
  150. package/dist-lib/lib/return-focus.js +11 -11
  151. package/dist-lib/lib/return-focus.js.map +1 -1
  152. package/dist-lib/lib/strings.js +167 -135
  153. package/dist-lib/lib/strings.js.map +1 -1
  154. package/dist-lib/lib/strings.mn.js +150 -113
  155. package/dist-lib/lib/strings.mn.js.map +1 -1
  156. package/dist-lib/lib/utils.js +9 -9
  157. package/dist-lib/lib/utils.js.map +1 -1
  158. package/dist-lib/styles.css +3 -1
  159. package/package.json +50 -50
  160. package/dist-lib/__tests__/helpers/color.d.ts +0 -9
  161. package/dist-lib/__tests__/helpers/theme.d.ts +0 -18
  162. package/dist-lib/icon.js.map +0 -1
  163. package/dist-lib/index.js.map +0 -1
@@ -1,20 +1,21 @@
1
1
  "use client";
2
- import { useState as f, useRef as i, useEffect as l } from "react";
3
- function d(t, { minVisible: u = 500 } = {}) {
4
- const [a, n] = f(t <= 0), e = i(t <= 0 ? Date.now() : null);
5
- return l(() => {
6
- const c = () => {
7
- e.current = Date.now(), n(!0);
8
- };
9
- if (t <= 0) {
10
- e.current ?? (e.current = Date.now()), n(!0);
11
- return;
12
- }
13
- const r = e.current === null ? 0 : Math.max(0, u - (Date.now() - e.current)), o = [];
14
- return r > 0 ? o.push(window.setTimeout(() => n(!1), r)) : n(!1), o.push(window.setTimeout(c, r + t)), () => o.forEach((s) => window.clearTimeout(s));
15
- }, [t, u]), a;
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
- export {
18
- d as useDelayedLoading
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"],"names":["useDelayedLoading","ms","minVisible","ready","setReady","useState","shownAt","useRef","useEffect","show","hold","timers","t"],"mappings":";;AAyBO,SAASA,EACdC,GACA,EAAE,YAAAC,IAAa,IAAA,IAA+B,CAAA,GACrC;AACT,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAASJ,KAAM,CAAC,GACpCK,IAAUC,EAAsBN,KAAM,IAAI,KAAK,IAAA,IAAQ,IAAI;AAEjE,SAAAO,EAAU,MAAM;AACd,UAAMC,IAAO,MAAM;AACjB,MAAAH,EAAQ,UAAU,KAAK,IAAA,GACvBF,EAAS,EAAI;AAAA,IACf;AACA,QAAIH,KAAM,GAAG;AACX,MAAAK,EAAQ,YAARA,EAAQ,UAAY,KAAK,IAAA,IACzBF,EAAS,EAAI;AACb;AAAA,IACF;AAEA,UAAMM,IACJJ,EAAQ,YAAY,OAAO,IAAI,KAAK,IAAI,GAAGJ,KAAc,KAAK,IAAA,IAAQI,EAAQ,QAAQ,GAClFK,IAAmB,CAAA;AACzB,WAAID,IAAO,IACTC,EAAO,KAAK,OAAO,WAAW,MAAMP,EAAS,EAAK,GAAGM,CAAI,CAAC,IAE1DN,EAAS,EAAK,GAEhBO,EAAO,KAAK,OAAO,WAAWF,GAAMC,IAAOT,CAAE,CAAC,GACvC,MAAMU,EAAO,QAAQ,CAACC,MAAM,OAAO,aAAaA,CAAC,CAAC;AAAA,EAC3D,GAAG,CAACX,GAAIC,CAAU,CAAC,GAEZC;AACT;"}
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 n } from "react";
3
- function l(s, o = {}) {
4
- const i = n(), r = s ?? i, e = `${r}-desc`, d = `${r}-error`, t = [
5
- o.hasError ? d : o.hasHelper ? e : void 0,
6
- o.extra
7
- ].filter(Boolean);
8
- return {
9
- fieldId: r,
10
- helperId: e,
11
- errorId: d,
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
- export {
16
- l as useFieldIds
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"],"names":["useFieldIds","id","present","autoId","useId","fieldId","helperId","errorId","parts"],"mappings":";;AA6BO,SAASA,EACdC,GACAC,IAKI,IACM;AACV,QAAMC,IAASC,EAAA,GACTC,IAAUJ,KAAME,GAChBG,IAAW,GAAGD,CAAO,SACrBE,IAAU,GAAGF,CAAO,UACpBG,IAAQ;AAAA,IACZN,EAAQ,WAAWK,IAAUL,EAAQ,YAAYI,IAAW;AAAA,IAC5DJ,EAAQ;AAAA,EAAA,EACR,OAAO,OAAO;AAChB,SAAO;AAAA,IACL,SAAAG;AAAA,IACA,UAAAC;AAAA,IACA,SAAAC;AAAA,IACA,aAAaC,EAAM,SAASA,EAAM,KAAK,GAAG,IAAI;AAAA,EAAA;AAElD;"}
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 o, useSyncExternalStore as d } from "react";
3
- function r(e) {
4
- const i = o(
5
- (n) => {
6
- if (typeof window > "u" || !window.matchMedia) return () => {
7
- };
8
- const t = window.matchMedia(e);
9
- return t.addEventListener("change", n), () => t.removeEventListener("change", n);
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 c() {
16
- return r("(prefers-reduced-motion: reduce)");
12
+ function r() {
13
+ return n("(prefers-reduced-motion: reduce)");
17
14
  }
18
- export {
19
- r as useMediaQuery,
20
- c as usePrefersReducedMotion
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"],"names":["useMediaQuery","query","subscribe","useCallback","onChange","list","useSyncExternalStore","usePrefersReducedMotion"],"mappings":";;AAYO,SAASA,EAAcC,GAAwB;AACpD,QAAMC,IAAYC;AAAA,IAChB,CAACC,MAAyB;AACxB,UAAI,OAAO,SAAW,OAAe,CAAC,OAAO,mBAAmB,MAAM;AAAA,MAAC;AACvE,YAAMC,IAAO,OAAO,WAAWJ,CAAK;AACpC,aAAAI,EAAK,iBAAiB,UAAUD,CAAQ,GACjC,MAAMC,EAAK,oBAAoB,UAAUD,CAAQ;AAAA,IAC1D;AAAA,IACA,CAACH,CAAK;AAAA,EAAA;AAIR,SAAOK,EAAqBJ,GAFR,MAClB,OAAO,SAAW,OAAe,OAAO,aAAa,OAAO,WAAWD,CAAK,EAAE,UAAU,IACtC,MAAM,EAAK;AACjE;AAGO,SAASM,IAAmC;AACjD,SAAOP,EAAc,kCAAkC;AACzD;"}
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 { useState as o, useEffect as r } from "react";
2
+ import { useEffect as e, useState as t } from "react";
3
+ //#region src/hooks/use-modifier-key.ts
3
4
  function n() {
4
- var a;
5
- if (typeof navigator > "u") return !1;
6
- const e = navigator, t = ((a = e.userAgentData) == null ? void 0 : a.platform) ?? e.platform ?? "";
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 s() {
10
- const [e, t] = o(!1);
11
- return r(() => {
12
- t(n());
13
- }, []), e ? { symbol: "⌘", label: "Cmd" } : { symbol: "Ctrl", label: "Ctrl" };
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
- export {
16
- n as isApplePlatform,
17
- s as useModifierKey
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"],"names":["isApplePlatform","nav","platform","_a","useModifierKey","apple","setApple","useState","useEffect"],"mappings":";;AAKO,SAASA,IAA2B;;AACzC,MAAI,OAAO,YAAc,IAAa,QAAO;AAC7C,QAAMC,IAAM,WACNC,MAAWC,IAAAF,EAAI,kBAAJ,gBAAAE,EAAmB,aAAYF,EAAI,YAAY;AAChE,SAAO,wBAAwB,KAAKC,CAAQ,KAAK,YAAY,KAAKD,EAAI,aAAa,EAAE;AACvF;AAaO,SAASG,IAA8B;AAC5C,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAAS,EAAK;AACxC,SAAAC,EAAU,MAAM;AACd,IAAAF,EAASN,GAAiB;AAAA,EAC5B,GAAG,CAAA,CAAE,GACEK,IAAQ,EAAE,QAAQ,KAAK,OAAO,MAAA,IAAU,EAAE,QAAQ,QAAQ,OAAO,OAAA;AAC1E;"}
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 { useContext as t, createContext as e } from "react";
3
- import { defaultStrings as n } from "../lib/strings.js";
4
- const r = e(n);
5
- function s() {
6
- return t(r);
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
- export {
9
- r as StringsContext,
10
- s as useStrings
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"],"names":["StringsContext","createContext","defaultStrings","useStrings","useContext"],"mappings":";;;AAMO,MAAMA,IAAiBC,EAAyBC,CAAc;AAG9D,SAASC,IAAwB;AACtC,SAAOC,EAAWJ,CAAc;AAClC;"}
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 { useSyncExternalStore as f, useCallback as u } from "react";
3
- const m = 3, l = [], d = {
4
- default: 4e3,
5
- success: 4e3,
6
- info: 4e3,
7
- warning: 6e3,
8
- danger: 0
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 p() {
11
- return {
12
- toasts: l,
13
- listeners: /* @__PURE__ */ new Set(),
14
- emit() {
15
- for (const t of this.listeners) t();
16
- },
17
- push(t) {
18
- const s = t.id ?? `t_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`, r = this.toasts.find((e) => e.id === s);
19
- let o;
20
- if (r)
21
- o = this.toasts.map((e) => {
22
- if (e.id !== s) return e;
23
- const a = t.variant ?? e.variant ?? "default", h = t.duration ?? (t.variant ? d[a] : e.duration);
24
- return { ...e, ...t, id: s, variant: a, duration: h, open: !0 };
25
- });
26
- else {
27
- const e = t.variant ?? "default";
28
- o = [{
29
- ...t,
30
- id: s,
31
- open: !0,
32
- variant: e,
33
- duration: t.duration ?? d[e]
34
- }, ...this.toasts];
35
- }
36
- let n = 0;
37
- return this.toasts = o.filter((e) => e.duration === 0 || n++ < m), this.emit(), s;
38
- },
39
- dismiss(t) {
40
- this.toasts = this.toasts.map((s) => s.id === t ? { ...s, open: !1 } : s), this.emit();
41
- },
42
- remove(t) {
43
- this.toasts = this.toasts.filter((s) => s.id !== t), this.emit();
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
- let c = null;
48
- function i() {
49
- return c || (c = p()), c;
56
+ var o = null;
57
+ function s() {
58
+ return o ||= a(), o;
50
59
  }
51
- const S = (t) => {
52
- const s = i();
53
- return s.listeners.add(t), () => {
54
- s.listeners.delete(t);
55
- };
56
- }, v = () => i().toasts, g = () => l;
57
- function _() {
58
- const t = f(S, v, g), s = u((n) => i().push(n), []), r = u((n) => i().dismiss(n), []), o = u((n) => i().remove(n), []);
59
- return { toasts: t, push: s, dismiss: r, remove: o };
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
- const b = (t) => i().push(t);
62
- export {
63
- d as TOAST_DURATIONS,
64
- b as toast,
65
- _ as useToast
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"],"names":["MAX_VISIBLE","EMPTY","TOAST_DURATIONS","createStore","listener","id","existing","x","merged","variant","duration","kept","t","store","getStore","subscribe","getSnapshot","getServerSnapshot","useToast","toasts","useSyncExternalStore","push","useCallback","dismiss","remove","toast"],"mappings":";;AAyCA,MAAMA,IAAc,GAWdC,IAAyB,CAAA,GAGlBC,IAAgD;AAAA,EAC3D,SAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AACV;AAEA,SAASC,IAA0B;AACjC,SAAO;AAAA,IACL,QAAQF;AAAA,IACR,+BAAe,IAAA;AAAA,IACf,OAAO;AACL,iBAAWG,KAAY,KAAK,UAAW,CAAAA,EAAA;AAAA,IACzC;AAAA,IACA,KAAK,GAAG;AACN,YAAMC,IAAK,EAAE,MAAM,KAAK,KAAK,KAAK,IAAI,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC,IACtEC,IAAW,KAAK,OAAO,KAAK,CAACC,MAAMA,EAAE,OAAOF,CAAE;AACpD,UAAIG;AACJ,UAAIF;AAEF,QAAAE,IAAS,KAAK,OAAO,IAAI,CAACD,MAAM;AAC9B,cAAIA,EAAE,OAAOF,EAAI,QAAOE;AACxB,gBAAME,IAAU,EAAE,WAAWF,EAAE,WAAW,WACpCG,IAAW,EAAE,aAAa,EAAE,UAAUR,EAAgBO,CAAO,IAAIF,EAAE;AACzE,iBAAO,EAAE,GAAGA,GAAG,GAAG,GAAG,IAAAF,GAAI,SAAAI,GAAS,UAAAC,GAAU,MAAM,GAAA;AAAA,QACpD,CAAC;AAAA,WACI;AACL,cAAMD,IAAU,EAAE,WAAW;AAQ7B,QAAAD,IAAS,CAPmB;AAAA,UAC1B,GAAG;AAAA,UACH,IAAAH;AAAA,UACA,MAAM;AAAA,UACN,SAAAI;AAAA,UACA,UAAU,EAAE,YAAYP,EAAgBO,CAAO;AAAA,QAAA,GAEjC,GAAG,KAAK,MAAM;AAAA,MAChC;AACA,UAAIE,IAAO;AACX,kBAAK,SAASH,EAAO,OAAO,CAACD,MAAMA,EAAE,aAAa,KAAKI,MAASX,CAAW,GAC3E,KAAK,KAAA,GACEK;AAAA,IACT;AAAA,IACA,QAAQA,GAAI;AACV,WAAK,SAAS,KAAK,OAAO,IAAI,CAACO,MAAOA,EAAE,OAAOP,IAAK,EAAE,GAAGO,GAAG,MAAM,GAAA,IAAUA,CAAE,GAC9E,KAAK,KAAA;AAAA,IACP;AAAA,IACA,OAAOP,GAAI;AACT,WAAK,SAAS,KAAK,OAAO,OAAO,CAACO,MAAMA,EAAE,OAAOP,CAAE,GACnD,KAAK,KAAA;AAAA,IACP;AAAA,EAAA;AAEJ;AAIA,IAAIQ,IAA2B;AAC/B,SAASC,IAAuB;AAC9B,SAAKD,MAAOA,IAAQV,EAAA,IACbU;AACT;AAEA,MAAME,IAAY,CAACX,MAAuB;AACxC,QAAM,IAAIU,EAAA;AACV,WAAE,UAAU,IAAIV,CAAQ,GACjB,MAAM;AACX,MAAE,UAAU,OAAOA,CAAQ;AAAA,EAC7B;AACF,GACMY,IAAc,MAAMF,EAAA,EAAW,QAC/BG,IAAoB,MAAMhB;AAezB,SAASiB,IAAW;AACzB,QAAMC,IAASC,EAAqBL,GAAWC,GAAaC,CAAiB,GAEvEI,IAAOC,EAAY,CAACV,MAAuBE,EAAA,EAAW,KAAKF,CAAC,GAAG,EAAE,GACjEW,IAAUD,EAAY,CAACjB,MAAeS,EAAA,EAAW,QAAQT,CAAE,GAAG,EAAE,GAChEmB,IAASF,EAAY,CAACjB,MAAeS,EAAA,EAAW,OAAOT,CAAE,GAAG,EAAE;AAEpE,SAAO,EAAE,QAAAc,GAAQ,MAAAE,GAAM,SAAAE,GAAS,QAAAC,EAAA;AAClC;AAGO,MAAMC,IAAQ,CAAC,MAAuBX,EAAA,EAAW,KAAK,CAAC;"}
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 c, iconNames as n } from "./components/ui/Icon.js";
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 };