@fuf-stack/pixels 1.10.2 → 1.11.1

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 (131) hide show
  1. package/dist/Accordion/Accordion.d.cts +512 -74
  2. package/dist/Accordion/Accordion.d.cts.map +1 -1
  3. package/dist/Accordion/Accordion.d.ts +512 -74
  4. package/dist/Accordion/Accordion.d.ts.map +1 -1
  5. package/dist/Alert/Alert.cjs +18 -6
  6. package/dist/Alert/Alert.cjs.map +1 -1
  7. package/dist/Alert/Alert.d.cts +396 -98
  8. package/dist/Alert/Alert.d.cts.map +1 -1
  9. package/dist/Alert/Alert.d.ts +396 -98
  10. package/dist/Alert/Alert.d.ts.map +1 -1
  11. package/dist/Alert/Alert.js +18 -6
  12. package/dist/Alert/Alert.js.map +1 -1
  13. package/dist/Avatar/Avatar.d.cts +734 -45
  14. package/dist/Avatar/Avatar.d.cts.map +1 -1
  15. package/dist/Avatar/Avatar.d.ts +734 -45
  16. package/dist/Avatar/Avatar.d.ts.map +1 -1
  17. package/dist/Badge/Badge.d.cts +377 -27
  18. package/dist/Badge/Badge.d.cts.map +1 -1
  19. package/dist/Badge/Badge.d.ts +377 -27
  20. package/dist/Badge/Badge.d.ts.map +1 -1
  21. package/dist/Breadcrumb/Breadcrumb.d.cts +853 -51
  22. package/dist/Breadcrumb/Breadcrumb.d.cts.map +1 -1
  23. package/dist/Breadcrumb/Breadcrumb.d.ts +853 -51
  24. package/dist/Breadcrumb/Breadcrumb.d.ts.map +1 -1
  25. package/dist/Button/Button.cjs.map +1 -1
  26. package/dist/Button/Button.d.cts +3 -215
  27. package/dist/Button/Button.d.cts.map +1 -1
  28. package/dist/Button/Button.d.ts +3 -215
  29. package/dist/Button/Button.d.ts.map +1 -1
  30. package/dist/Button/Button.js.map +1 -1
  31. package/dist/Card/Card.d.cts +734 -45
  32. package/dist/Card/Card.d.cts.map +1 -1
  33. package/dist/Card/Card.d.ts +734 -45
  34. package/dist/Card/Card.d.ts.map +1 -1
  35. package/dist/Drawer/Drawer.d.cts +972 -57
  36. package/dist/Drawer/Drawer.d.cts.map +1 -1
  37. package/dist/Drawer/Drawer.d.ts +972 -57
  38. package/dist/Drawer/Drawer.d.ts.map +1 -1
  39. package/dist/Label/Label.d.cts +418 -173
  40. package/dist/Label/Label.d.cts.map +1 -1
  41. package/dist/Label/Label.d.ts +418 -173
  42. package/dist/Label/Label.d.ts.map +1 -1
  43. package/dist/Menu/Menu.d.cts +377 -27
  44. package/dist/Menu/Menu.d.cts.map +1 -1
  45. package/dist/Menu/Menu.d.ts +377 -27
  46. package/dist/Menu/Menu.d.ts.map +1 -1
  47. package/dist/Modal/Modal.cjs +1 -1
  48. package/dist/Modal/Modal.cjs.map +1 -1
  49. package/dist/Modal/Modal.d.cts +347 -71
  50. package/dist/Modal/Modal.d.cts.map +1 -1
  51. package/dist/Modal/Modal.d.ts +347 -71
  52. package/dist/Modal/Modal.d.ts.map +1 -1
  53. package/dist/Modal/Modal.js +2 -2
  54. package/dist/Modal/Modal.js.map +1 -1
  55. package/dist/Modal/ModalHost.cjs +40 -0
  56. package/dist/Modal/ModalHost.cjs.map +1 -0
  57. package/dist/Modal/ModalHost.d.cts +16 -0
  58. package/dist/Modal/ModalHost.d.cts.map +1 -0
  59. package/dist/Modal/ModalHost.d.ts +16 -0
  60. package/dist/Modal/ModalHost.d.ts.map +1 -0
  61. package/dist/Modal/ModalHost.js +39 -0
  62. package/dist/Modal/ModalHost.js.map +1 -0
  63. package/dist/Modal/index.cjs +4 -0
  64. package/dist/Modal/index.cjs.map +1 -1
  65. package/dist/Modal/index.d.cts +3 -1
  66. package/dist/Modal/index.d.ts +3 -1
  67. package/dist/Modal/index.js +3 -1
  68. package/dist/Modal/index.js.map +1 -1
  69. package/dist/Modal/modalStore.cjs +80 -0
  70. package/dist/Modal/modalStore.cjs.map +1 -0
  71. package/dist/Modal/modalStore.d.cts +31 -0
  72. package/dist/Modal/modalStore.d.cts.map +1 -0
  73. package/dist/Modal/modalStore.d.ts +31 -0
  74. package/dist/Modal/modalStore.d.ts.map +1 -0
  75. package/dist/Modal/modalStore.js +78 -0
  76. package/dist/Modal/modalStore.js.map +1 -0
  77. package/dist/Popover/Popover.d.cts +1091 -63
  78. package/dist/Popover/Popover.d.cts.map +1 -1
  79. package/dist/Popover/Popover.d.ts +1091 -63
  80. package/dist/Popover/Popover.d.ts.map +1 -1
  81. package/dist/Progress/Progress.d.cts +321 -85
  82. package/dist/Progress/Progress.d.cts.map +1 -1
  83. package/dist/Progress/Progress.d.ts +321 -85
  84. package/dist/Progress/Progress.d.ts.map +1 -1
  85. package/dist/ProgressCircular/ProgressCircular.d.cts +507 -186
  86. package/dist/ProgressCircular/ProgressCircular.d.cts.map +1 -1
  87. package/dist/ProgressCircular/ProgressCircular.d.ts +507 -186
  88. package/dist/ProgressCircular/ProgressCircular.d.ts.map +1 -1
  89. package/dist/SearchInput/SearchInput.d.cts +615 -39
  90. package/dist/SearchInput/SearchInput.d.cts.map +1 -1
  91. package/dist/SearchInput/SearchInput.d.ts +615 -39
  92. package/dist/SearchInput/SearchInput.d.ts.map +1 -1
  93. package/dist/Table/Table.d.cts +514 -96
  94. package/dist/Table/Table.d.cts.map +1 -1
  95. package/dist/Table/Table.d.ts +514 -96
  96. package/dist/Table/Table.d.ts.map +1 -1
  97. package/dist/Tabs/Tabs.d.cts +972 -57
  98. package/dist/Tabs/Tabs.d.cts.map +1 -1
  99. package/dist/Tabs/Tabs.d.ts +972 -57
  100. package/dist/Tabs/Tabs.d.ts.map +1 -1
  101. package/dist/Toast/Toaster.cjs +10 -2
  102. package/dist/Toast/Toaster.cjs.map +1 -1
  103. package/dist/Toast/Toaster.d.cts +5 -2
  104. package/dist/Toast/Toaster.d.cts.map +1 -1
  105. package/dist/Toast/Toaster.d.ts +5 -2
  106. package/dist/Toast/Toaster.d.ts.map +1 -1
  107. package/dist/Toast/Toaster.js +10 -2
  108. package/dist/Toast/Toaster.js.map +1 -1
  109. package/dist/Toast/index.cjs +3 -3
  110. package/dist/Toast/index.cjs.map +1 -1
  111. package/dist/Toast/index.d.cts +1 -1
  112. package/dist/Toast/index.d.ts +1 -1
  113. package/dist/Toast/index.js +1 -1
  114. package/dist/Toast/index.js.map +1 -1
  115. package/dist/Toast/{Toast.cjs → toast.cjs} +2 -2
  116. package/dist/Toast/{Toast.cjs.map → toast.cjs.map} +1 -1
  117. package/dist/Toast/{Toast.d.cts → toast.d.cts} +2 -2
  118. package/dist/Toast/{Toast.d.cts.map → toast.d.cts.map} +1 -1
  119. package/dist/Toast/{Toast.d.ts → toast.d.ts} +2 -2
  120. package/dist/Toast/{Toast.d.ts.map → toast.d.ts.map} +1 -1
  121. package/dist/Toast/{Toast.js → toast.js} +2 -2
  122. package/dist/Toast/{Toast.js.map → toast.js.map} +1 -1
  123. package/dist/Tooltip/Tooltip.d.cts +452 -143
  124. package/dist/Tooltip/Tooltip.d.cts.map +1 -1
  125. package/dist/Tooltip/Tooltip.d.ts +452 -143
  126. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  127. package/dist/index.cjs +6 -2
  128. package/dist/index.d.cts +4 -2
  129. package/dist/index.d.ts +4 -2
  130. package/dist/index.js +4 -2
  131. package/package.json +4 -4
@@ -0,0 +1,16 @@
1
+ //#region src/Modal/ModalHost.d.ts
2
+ /**
3
+ * Renders all modals opened via the imperative `modal.open()` API.
4
+ *
5
+ * Mount once at the top level of your app, similar to `<Toaster />`:
6
+ *
7
+ * ```tsx
8
+ * <ModalHost />
9
+ * ```
10
+ *
11
+ * Then open modals from anywhere with `modal.open({ ... })`.
12
+ */
13
+ declare const ModalHost: () => import("react/jsx-runtime").JSX.Element;
14
+ //#endregion
15
+ export { ModalHost };
16
+ //# sourceMappingURL=ModalHost.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalHost.d.cts","names":[],"sources":["../../src/Modal/ModalHost.tsx"],"mappings":";;;;;;AA6CC;;;;;;cA7BK,SAAA,oCAAS,GAAA,CAAA,OA6Bd"}
@@ -0,0 +1,16 @@
1
+ //#region src/Modal/ModalHost.d.ts
2
+ /**
3
+ * Renders all modals opened via the imperative `modal.open()` API.
4
+ *
5
+ * Mount once at the top level of your app, similar to `<Toaster />`:
6
+ *
7
+ * ```tsx
8
+ * <ModalHost />
9
+ * ```
10
+ *
11
+ * Then open modals from anywhere with `modal.open({ ... })`.
12
+ */
13
+ declare const ModalHost: () => import("react/jsx-runtime").JSX.Element;
14
+ //#endregion
15
+ export { ModalHost };
16
+ //# sourceMappingURL=ModalHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalHost.d.ts","names":[],"sources":["../../src/Modal/ModalHost.tsx"],"mappings":";;;;;;AA6CC;;;;;;cA7BK,SAAA,oCAAS,GAAA,CAAA,OA6Bd"}
@@ -0,0 +1,39 @@
1
+ import Modal from "./Modal.js";
2
+ import { modal, useModalEntries } from "./modalStore.js";
3
+ import { Fragment, jsx } from "react/jsx-runtime";
4
+ import { useEffect } from "react";
5
+ //#region src/Modal/ModalHost.tsx
6
+ /**
7
+ * Renders all modals opened via the imperative `modal.open()` API.
8
+ *
9
+ * Mount once at the top level of your app, similar to `<Toaster />`:
10
+ *
11
+ * ```tsx
12
+ * <ModalHost />
13
+ * ```
14
+ *
15
+ * Then open modals from anywhere with `modal.open({ ... })`.
16
+ */
17
+ const ModalHost = () => {
18
+ const entries = useModalEntries();
19
+ useEffect(() => {
20
+ return () => {
21
+ modal.reset();
22
+ };
23
+ }, []);
24
+ return /* @__PURE__ */ jsx(Fragment, { children: entries.map((entry) => {
25
+ const { id, isOpen, content, onClose: _onClose, ...modalProps } = entry;
26
+ return /* @__PURE__ */ jsx(Modal, {
27
+ ...modalProps,
28
+ isOpen,
29
+ onClose: () => {
30
+ modal.close(id);
31
+ },
32
+ children: content
33
+ }, id);
34
+ }) });
35
+ };
36
+ //#endregion
37
+ export { ModalHost as default };
38
+
39
+ //# sourceMappingURL=ModalHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalHost.js","names":[],"sources":["../../src/Modal/ModalHost.tsx"],"sourcesContent":["import { useEffect } from 'react';\n\nimport Modal from './Modal';\nimport { modal, useModalEntries } from './modalStore';\n\n/**\n * Renders all modals opened via the imperative `modal.open()` API.\n *\n * Mount once at the top level of your app, similar to `<Toaster />`:\n *\n * ```tsx\n * <ModalHost />\n * ```\n *\n * Then open modals from anywhere with `modal.open({ ... })`.\n */\nconst ModalHost = () => {\n const entries = useModalEntries();\n\n // Clear the store when the host unmounts so any still-open\n // modal does not re-appear when a new host mounts.\n useEffect(() => {\n return () => {\n modal.reset();\n };\n }, []);\n return (\n <>\n {entries.map((entry) => {\n const { id, isOpen, content, onClose: _onClose, ...modalProps } = entry;\n return (\n <Modal\n key={id}\n {...modalProps}\n isOpen={isOpen}\n onClose={() => {\n modal.close(id);\n }}\n >\n {content}\n </Modal>\n );\n })}\n </>\n );\n};\n\nexport default ModalHost;\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,kBAAkB;CACtB,MAAM,UAAU,gBAAgB;CAIhC,gBAAgB;EACd,aAAa;GACX,MAAM,MAAM;EACd;CACF,GAAG,CAAC,CAAC;CACL,OACE,oBAAA,UAAA,EAAA,UACG,QAAQ,KAAK,UAAU;EACtB,MAAM,EAAE,IAAI,QAAQ,SAAS,SAAS,UAAU,GAAG,eAAe;EAClE,OACE,oBAAC,OAAD;GAEE,GAAI;GACI;GACR,eAAe;IACb,MAAM,MAAM,EAAE;GAChB;aAEC;EACI,GARA,EAQA;CAEX,CAAC,EACD,CAAA;AAEN"}
@@ -3,11 +3,15 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_Modal = require("./Modal.cjs");
6
+ const require_modalStore = require("./modalStore.cjs");
7
+ const require_ModalHost = require("./ModalHost.cjs");
6
8
  //#region src/Modal/index.ts
7
9
  var Modal_default = require_Modal.default;
8
10
  //#endregion
9
11
  exports.Modal = require_Modal.default;
12
+ exports.ModalHost = require_ModalHost.default;
10
13
  exports.default = Modal_default;
14
+ exports.modal = require_modalStore.modal;
11
15
  exports.modalVariants = require_Modal.modalVariants;
12
16
 
13
17
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Modal"],"sources":["../../src/Modal/index.ts"],"sourcesContent":["import Modal, { modalVariants } from './Modal';\n\nexport type { ModalProps } from './Modal';\n\nexport { Modal, modalVariants };\n\nexport default Modal;\n"],"mappings":";;;;;;AAMA,IAAA,gBAAeA,cAAAA"}
1
+ {"version":3,"file":"index.cjs","names":["Modal"],"sources":["../../src/Modal/index.ts"],"sourcesContent":["import Modal from './Modal';\n\nexport type { ModalProps } from './Modal';\nexport type { ModalEntry, ModalOpenOptions, ModalStoreApi } from './modalStore';\n\nexport { default as ModalHost } from './ModalHost';\nexport { modal } from './modalStore';\nexport { modalVariants } from './Modal';\nexport { Modal };\n\nexport default Modal;\n"],"mappings":";;;;;;;;AAUA,IAAA,gBAAeA,cAAAA"}
@@ -1,2 +1,4 @@
1
1
  import { Modal, ModalProps, modalVariants } from "./Modal.cjs";
2
- export { Modal, Modal as default, type ModalProps, modalVariants };
2
+ import { ModalEntry, ModalOpenOptions, ModalStoreApi, modal } from "./modalStore.cjs";
3
+ import { ModalHost } from "./ModalHost.cjs";
4
+ export { Modal, Modal as default, type ModalEntry, ModalHost, type ModalOpenOptions, type ModalProps, type ModalStoreApi, modal, modalVariants };
@@ -1,2 +1,4 @@
1
1
  import { Modal, ModalProps, modalVariants } from "./Modal.js";
2
- export { Modal, Modal as default, type ModalProps, modalVariants };
2
+ import { ModalEntry, ModalOpenOptions, ModalStoreApi, modal } from "./modalStore.js";
3
+ import { ModalHost } from "./ModalHost.js";
4
+ export { Modal, Modal as default, type ModalEntry, ModalHost, type ModalOpenOptions, type ModalProps, type ModalStoreApi, modal, modalVariants };
@@ -1,7 +1,9 @@
1
1
  import Modal, { modalVariants } from "./Modal.js";
2
+ import { modal } from "./modalStore.js";
3
+ import ModalHost from "./ModalHost.js";
2
4
  //#region src/Modal/index.ts
3
5
  var Modal_default = Modal;
4
6
  //#endregion
5
- export { Modal, Modal_default as default, modalVariants };
7
+ export { Modal, ModalHost, Modal_default as default, modal, modalVariants };
6
8
 
7
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/Modal/index.ts"],"sourcesContent":["import Modal, { modalVariants } from './Modal';\n\nexport type { ModalProps } from './Modal';\n\nexport { Modal, modalVariants };\n\nexport default Modal;\n"],"mappings":";;AAMA,IAAA,gBAAe"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/Modal/index.ts"],"sourcesContent":["import Modal from './Modal';\n\nexport type { ModalProps } from './Modal';\nexport type { ModalEntry, ModalOpenOptions, ModalStoreApi } from './modalStore';\n\nexport { default as ModalHost } from './ModalHost';\nexport { modal } from './modalStore';\nexport { modalVariants } from './Modal';\nexport { Modal };\n\nexport default Modal;\n"],"mappings":";;;;AAUA,IAAA,gBAAe"}
@@ -0,0 +1,80 @@
1
+ require("../_virtual/_rolldown/runtime.cjs");
2
+ let react = require("react");
3
+ //#region src/Modal/modalStore.ts
4
+ const MODAL_CLOSE_ANIMATION_MS = 300;
5
+ let nextId = 0;
6
+ let entries = [];
7
+ const listeners = /* @__PURE__ */ new Set();
8
+ const emit = () => {
9
+ listeners.forEach((listener) => {
10
+ listener();
11
+ });
12
+ };
13
+ const subscribe = (listener) => {
14
+ listeners.add(listener);
15
+ return () => {
16
+ listeners.delete(listener);
17
+ };
18
+ };
19
+ const getSnapshot = () => {
20
+ return entries;
21
+ };
22
+ /** React hook used by `ModalHost` to subscribe to the modal stack */
23
+ const useModalEntries = () => {
24
+ return (0, react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
25
+ };
26
+ const open = (options) => {
27
+ nextId += 1;
28
+ const id = `modal-${nextId}`;
29
+ entries = [...entries, {
30
+ ...options,
31
+ id,
32
+ isOpen: true
33
+ }];
34
+ emit();
35
+ return id;
36
+ };
37
+ const close = (id) => {
38
+ const entry = entries.find((e) => {
39
+ return e.id === id;
40
+ });
41
+ if (!entry?.isOpen) return;
42
+ entries = entries.map((e) => {
43
+ return e.id === id ? {
44
+ ...e,
45
+ isOpen: false
46
+ } : e;
47
+ });
48
+ emit();
49
+ entry.onClose?.();
50
+ setTimeout(() => {
51
+ entries = entries.filter((e) => {
52
+ return e.id !== id;
53
+ });
54
+ emit();
55
+ }, MODAL_CLOSE_ANIMATION_MS);
56
+ };
57
+ const closeAll = () => {
58
+ entries.forEach((entry) => {
59
+ if (entry.isOpen) close(entry.id);
60
+ });
61
+ };
62
+ const reset = () => {
63
+ entries = [];
64
+ emit();
65
+ };
66
+ /**
67
+ * Imperative API for opening modals from anywhere (e.g. from inside a toast).
68
+ * Requires a `<ModalHost />` to be mounted somewhere in the React tree.
69
+ */
70
+ const modal = {
71
+ open,
72
+ close,
73
+ closeAll,
74
+ reset
75
+ };
76
+ //#endregion
77
+ exports.modal = modal;
78
+ exports.useModalEntries = useModalEntries;
79
+
80
+ //# sourceMappingURL=modalStore.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modalStore.cjs","names":[],"sources":["../../src/Modal/modalStore.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ModalProps } from './Modal';\n\nimport { useSyncExternalStore } from 'react';\n\n/** Options accepted by `modal.open()` */\nexport interface ModalOpenOptions extends Omit<\n ModalProps,\n 'isOpen' | 'onClose' | 'children'\n> {\n /** Modal body content */\n content?: ReactNode;\n /** Callback fired when the modal is closed (by user or programmatically) */\n onClose?: () => void;\n}\n\n/** Internal entry tracked by the store */\nexport interface ModalEntry extends ModalOpenOptions {\n id: string;\n isOpen: boolean;\n}\n\n// Duration of the HeroUI modal close animation. Entries stay in the list this\n// long after `close()` so the exit animation can play before unmounting.\nconst MODAL_CLOSE_ANIMATION_MS = 300;\n\nlet nextId = 0;\nlet entries: ModalEntry[] = [];\nconst listeners = new Set<() => void>();\n\nconst emit = () => {\n listeners.forEach((listener) => {\n listener();\n });\n};\n\nconst subscribe = (listener: () => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n};\n\nconst getSnapshot = () => {\n return entries;\n};\n\n/** React hook used by `ModalHost` to subscribe to the modal stack */\nexport const useModalEntries = (): ModalEntry[] => {\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n\nconst open = (options: ModalOpenOptions): string => {\n nextId += 1;\n const id = `modal-${nextId}`;\n entries = [...entries, { ...options, id, isOpen: true }];\n emit();\n return id;\n};\n\nconst close = (id: string): void => {\n const entry = entries.find((e) => {\n return e.id === id;\n });\n if (!entry?.isOpen) {\n return;\n }\n entries = entries.map((e) => {\n return e.id === id ? { ...e, isOpen: false } : e;\n });\n emit();\n entry.onClose?.();\n setTimeout(() => {\n entries = entries.filter((e) => {\n return e.id !== id;\n });\n emit();\n }, MODAL_CLOSE_ANIMATION_MS);\n};\n\nconst closeAll = (): void => {\n entries.forEach((entry) => {\n if (entry.isOpen) {\n close(entry.id);\n }\n });\n};\n\n// Hard-resets the store without firing onClose callbacks or close animations.\n// Used by `ModalHost` on unmount so the store does not retain entries that\n// would re-appear when a host mounts again (e.g. switching Storybook stories).\nconst reset = (): void => {\n entries = [];\n emit();\n};\n\n/**\n * Imperative API for opening modals from anywhere (e.g. from inside a toast).\n * Requires a `<ModalHost />` to be mounted somewhere in the React tree.\n */\nexport const modal = {\n open,\n close,\n closeAll,\n reset,\n};\n\n/** Imperative modal API as exposed by the `modal` store. */\nexport type ModalStoreApi = typeof modal;\n"],"mappings":";;;AAwBA,MAAM,2BAA2B;AAEjC,IAAI,SAAS;AACb,IAAI,UAAwB,CAAC;AAC7B,MAAM,4BAAY,IAAI,IAAgB;AAEtC,MAAM,aAAa;CACjB,UAAU,SAAS,aAAa;EAC9B,SAAS;CACX,CAAC;AACH;AAEA,MAAM,aAAa,aAAyB;CAC1C,UAAU,IAAI,QAAQ;CACtB,aAAa;EACX,UAAU,OAAO,QAAQ;CAC3B;AACF;AAEA,MAAM,oBAAoB;CACxB,OAAO;AACT;;AAGA,MAAa,wBAAsC;CACjD,QAAA,GAAA,MAAA,sBAA4B,WAAW,aAAa,WAAW;AACjE;AAEA,MAAM,QAAQ,YAAsC;CAClD,UAAU;CACV,MAAM,KAAK,SAAS;CACpB,UAAU,CAAC,GAAG,SAAS;EAAE,GAAG;EAAS;EAAI,QAAQ;CAAK,CAAC;CACvD,KAAK;CACL,OAAO;AACT;AAEA,MAAM,SAAS,OAAqB;CAClC,MAAM,QAAQ,QAAQ,MAAM,MAAM;EAChC,OAAO,EAAE,OAAO;CAClB,CAAC;CACD,IAAI,CAAC,OAAO,QACV;CAEF,UAAU,QAAQ,KAAK,MAAM;EAC3B,OAAO,EAAE,OAAO,KAAK;GAAE,GAAG;GAAG,QAAQ;EAAM,IAAI;CACjD,CAAC;CACD,KAAK;CACL,MAAM,UAAU;CAChB,iBAAiB;EACf,UAAU,QAAQ,QAAQ,MAAM;GAC9B,OAAO,EAAE,OAAO;EAClB,CAAC;EACD,KAAK;CACP,GAAG,wBAAwB;AAC7B;AAEA,MAAM,iBAAuB;CAC3B,QAAQ,SAAS,UAAU;EACzB,IAAI,MAAM,QACR,MAAM,MAAM,EAAE;CAElB,CAAC;AACH;AAKA,MAAM,cAAoB;CACxB,UAAU,CAAC;CACX,KAAK;AACP;;;;;AAMA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;AACF"}
@@ -0,0 +1,31 @@
1
+ import { ModalProps } from "./Modal.cjs";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/Modal/modalStore.d.ts
5
+ /** Options accepted by `modal.open()` */
6
+ interface ModalOpenOptions extends Omit<ModalProps, 'isOpen' | 'onClose' | 'children'> {
7
+ /** Modal body content */
8
+ content?: ReactNode;
9
+ /** Callback fired when the modal is closed (by user or programmatically) */
10
+ onClose?: () => void;
11
+ }
12
+ /** Internal entry tracked by the store */
13
+ interface ModalEntry extends ModalOpenOptions {
14
+ id: string;
15
+ isOpen: boolean;
16
+ }
17
+ /**
18
+ * Imperative API for opening modals from anywhere (e.g. from inside a toast).
19
+ * Requires a `<ModalHost />` to be mounted somewhere in the React tree.
20
+ */
21
+ declare const modal: {
22
+ open: (options: ModalOpenOptions) => string;
23
+ close: (id: string) => void;
24
+ closeAll: () => void;
25
+ reset: () => void;
26
+ };
27
+ /** Imperative modal API as exposed by the `modal` store. */
28
+ type ModalStoreApi = typeof modal;
29
+ //#endregion
30
+ export { ModalEntry, ModalOpenOptions, ModalStoreApi, modal };
31
+ //# sourceMappingURL=modalStore.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modalStore.d.cts","names":[],"sources":["../../src/Modal/modalStore.ts"],"mappings":";;;;;UAMiB,gBAAA,SAAyB,IAAA,CACxC,UAAA;EADe;EAKf,OAAA,GAAU,SAAA;;EAEV,OAAA;AAAA;;UAIe,UAAA,SAAmB,gBAAgB;EAClD,EAAA;EACA,MAAA;AAAA;;;AANO;AAIT;cAmFa,KAAA;kBAhDU,gBAAgB;;;;;;KAwD3B,aAAA,UAAuB,KAAK"}
@@ -0,0 +1,31 @@
1
+ import { ModalProps } from "./Modal.js";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/Modal/modalStore.d.ts
5
+ /** Options accepted by `modal.open()` */
6
+ interface ModalOpenOptions extends Omit<ModalProps, 'isOpen' | 'onClose' | 'children'> {
7
+ /** Modal body content */
8
+ content?: ReactNode;
9
+ /** Callback fired when the modal is closed (by user or programmatically) */
10
+ onClose?: () => void;
11
+ }
12
+ /** Internal entry tracked by the store */
13
+ interface ModalEntry extends ModalOpenOptions {
14
+ id: string;
15
+ isOpen: boolean;
16
+ }
17
+ /**
18
+ * Imperative API for opening modals from anywhere (e.g. from inside a toast).
19
+ * Requires a `<ModalHost />` to be mounted somewhere in the React tree.
20
+ */
21
+ declare const modal: {
22
+ open: (options: ModalOpenOptions) => string;
23
+ close: (id: string) => void;
24
+ closeAll: () => void;
25
+ reset: () => void;
26
+ };
27
+ /** Imperative modal API as exposed by the `modal` store. */
28
+ type ModalStoreApi = typeof modal;
29
+ //#endregion
30
+ export { ModalEntry, ModalOpenOptions, ModalStoreApi, modal };
31
+ //# sourceMappingURL=modalStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modalStore.d.ts","names":[],"sources":["../../src/Modal/modalStore.ts"],"mappings":";;;;;UAMiB,gBAAA,SAAyB,IAAA,CACxC,UAAA;EADe;EAKf,OAAA,GAAU,SAAA;;EAEV,OAAA;AAAA;;UAIe,UAAA,SAAmB,gBAAgB;EAClD,EAAA;EACA,MAAA;AAAA;;;AANO;AAIT;cAmFa,KAAA;kBAhDU,gBAAgB;;;;;;KAwD3B,aAAA,UAAuB,KAAK"}
@@ -0,0 +1,78 @@
1
+ import { useSyncExternalStore } from "react";
2
+ //#region src/Modal/modalStore.ts
3
+ const MODAL_CLOSE_ANIMATION_MS = 300;
4
+ let nextId = 0;
5
+ let entries = [];
6
+ const listeners = /* @__PURE__ */ new Set();
7
+ const emit = () => {
8
+ listeners.forEach((listener) => {
9
+ listener();
10
+ });
11
+ };
12
+ const subscribe = (listener) => {
13
+ listeners.add(listener);
14
+ return () => {
15
+ listeners.delete(listener);
16
+ };
17
+ };
18
+ const getSnapshot = () => {
19
+ return entries;
20
+ };
21
+ /** React hook used by `ModalHost` to subscribe to the modal stack */
22
+ const useModalEntries = () => {
23
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
24
+ };
25
+ const open = (options) => {
26
+ nextId += 1;
27
+ const id = `modal-${nextId}`;
28
+ entries = [...entries, {
29
+ ...options,
30
+ id,
31
+ isOpen: true
32
+ }];
33
+ emit();
34
+ return id;
35
+ };
36
+ const close = (id) => {
37
+ const entry = entries.find((e) => {
38
+ return e.id === id;
39
+ });
40
+ if (!entry?.isOpen) return;
41
+ entries = entries.map((e) => {
42
+ return e.id === id ? {
43
+ ...e,
44
+ isOpen: false
45
+ } : e;
46
+ });
47
+ emit();
48
+ entry.onClose?.();
49
+ setTimeout(() => {
50
+ entries = entries.filter((e) => {
51
+ return e.id !== id;
52
+ });
53
+ emit();
54
+ }, MODAL_CLOSE_ANIMATION_MS);
55
+ };
56
+ const closeAll = () => {
57
+ entries.forEach((entry) => {
58
+ if (entry.isOpen) close(entry.id);
59
+ });
60
+ };
61
+ const reset = () => {
62
+ entries = [];
63
+ emit();
64
+ };
65
+ /**
66
+ * Imperative API for opening modals from anywhere (e.g. from inside a toast).
67
+ * Requires a `<ModalHost />` to be mounted somewhere in the React tree.
68
+ */
69
+ const modal = {
70
+ open,
71
+ close,
72
+ closeAll,
73
+ reset
74
+ };
75
+ //#endregion
76
+ export { modal, useModalEntries };
77
+
78
+ //# sourceMappingURL=modalStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modalStore.js","names":[],"sources":["../../src/Modal/modalStore.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ModalProps } from './Modal';\n\nimport { useSyncExternalStore } from 'react';\n\n/** Options accepted by `modal.open()` */\nexport interface ModalOpenOptions extends Omit<\n ModalProps,\n 'isOpen' | 'onClose' | 'children'\n> {\n /** Modal body content */\n content?: ReactNode;\n /** Callback fired when the modal is closed (by user or programmatically) */\n onClose?: () => void;\n}\n\n/** Internal entry tracked by the store */\nexport interface ModalEntry extends ModalOpenOptions {\n id: string;\n isOpen: boolean;\n}\n\n// Duration of the HeroUI modal close animation. Entries stay in the list this\n// long after `close()` so the exit animation can play before unmounting.\nconst MODAL_CLOSE_ANIMATION_MS = 300;\n\nlet nextId = 0;\nlet entries: ModalEntry[] = [];\nconst listeners = new Set<() => void>();\n\nconst emit = () => {\n listeners.forEach((listener) => {\n listener();\n });\n};\n\nconst subscribe = (listener: () => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n};\n\nconst getSnapshot = () => {\n return entries;\n};\n\n/** React hook used by `ModalHost` to subscribe to the modal stack */\nexport const useModalEntries = (): ModalEntry[] => {\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n};\n\nconst open = (options: ModalOpenOptions): string => {\n nextId += 1;\n const id = `modal-${nextId}`;\n entries = [...entries, { ...options, id, isOpen: true }];\n emit();\n return id;\n};\n\nconst close = (id: string): void => {\n const entry = entries.find((e) => {\n return e.id === id;\n });\n if (!entry?.isOpen) {\n return;\n }\n entries = entries.map((e) => {\n return e.id === id ? { ...e, isOpen: false } : e;\n });\n emit();\n entry.onClose?.();\n setTimeout(() => {\n entries = entries.filter((e) => {\n return e.id !== id;\n });\n emit();\n }, MODAL_CLOSE_ANIMATION_MS);\n};\n\nconst closeAll = (): void => {\n entries.forEach((entry) => {\n if (entry.isOpen) {\n close(entry.id);\n }\n });\n};\n\n// Hard-resets the store without firing onClose callbacks or close animations.\n// Used by `ModalHost` on unmount so the store does not retain entries that\n// would re-appear when a host mounts again (e.g. switching Storybook stories).\nconst reset = (): void => {\n entries = [];\n emit();\n};\n\n/**\n * Imperative API for opening modals from anywhere (e.g. from inside a toast).\n * Requires a `<ModalHost />` to be mounted somewhere in the React tree.\n */\nexport const modal = {\n open,\n close,\n closeAll,\n reset,\n};\n\n/** Imperative modal API as exposed by the `modal` store. */\nexport type ModalStoreApi = typeof modal;\n"],"mappings":";;AAwBA,MAAM,2BAA2B;AAEjC,IAAI,SAAS;AACb,IAAI,UAAwB,CAAC;AAC7B,MAAM,4BAAY,IAAI,IAAgB;AAEtC,MAAM,aAAa;CACjB,UAAU,SAAS,aAAa;EAC9B,SAAS;CACX,CAAC;AACH;AAEA,MAAM,aAAa,aAAyB;CAC1C,UAAU,IAAI,QAAQ;CACtB,aAAa;EACX,UAAU,OAAO,QAAQ;CAC3B;AACF;AAEA,MAAM,oBAAoB;CACxB,OAAO;AACT;;AAGA,MAAa,wBAAsC;CACjD,OAAO,qBAAqB,WAAW,aAAa,WAAW;AACjE;AAEA,MAAM,QAAQ,YAAsC;CAClD,UAAU;CACV,MAAM,KAAK,SAAS;CACpB,UAAU,CAAC,GAAG,SAAS;EAAE,GAAG;EAAS;EAAI,QAAQ;CAAK,CAAC;CACvD,KAAK;CACL,OAAO;AACT;AAEA,MAAM,SAAS,OAAqB;CAClC,MAAM,QAAQ,QAAQ,MAAM,MAAM;EAChC,OAAO,EAAE,OAAO;CAClB,CAAC;CACD,IAAI,CAAC,OAAO,QACV;CAEF,UAAU,QAAQ,KAAK,MAAM;EAC3B,OAAO,EAAE,OAAO,KAAK;GAAE,GAAG;GAAG,QAAQ;EAAM,IAAI;CACjD,CAAC;CACD,KAAK;CACL,MAAM,UAAU;CAChB,iBAAiB;EACf,UAAU,QAAQ,QAAQ,MAAM;GAC9B,OAAO,EAAE,OAAO;EAClB,CAAC;EACD,KAAK;CACP,GAAG,wBAAwB;AAC7B;AAEA,MAAM,iBAAuB;CAC3B,QAAQ,SAAS,UAAU;EACzB,IAAI,MAAM,QACR,MAAM,MAAM,EAAE;CAElB,CAAC;AACH;AAKA,MAAM,cAAoB;CACxB,UAAU,CAAC;CACX,KAAK;AACP;;;;;AAMA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;AACF"}