magic-pill 8.1.0 → 9.0.0-next.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 (207) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/MIGRATING.md +224 -0
  3. package/README.md +312 -257
  4. package/dist/MagicPill/MagicPill.d.mts +27 -0
  5. package/dist/MagicPill/MagicPill.d.ts +27 -0
  6. package/dist/MagicPill/MagicPill.js +185 -0
  7. package/dist/MagicPill/MagicPill.mjs +185 -0
  8. package/dist/MagicPill/choreography.js +91 -0
  9. package/dist/MagicPill/choreography.mjs +85 -0
  10. package/dist/Pill/Pill.d.mts +7 -0
  11. package/dist/Pill/Pill.d.ts +7 -0
  12. package/dist/Pill/Pill.js +106 -0
  13. package/dist/Pill/Pill.mjs +106 -0
  14. package/dist/Pill/PillAction.d.mts +7 -0
  15. package/dist/Pill/PillAction.d.ts +7 -0
  16. package/dist/Pill/PillAction.js +67 -0
  17. package/dist/Pill/PillAction.mjs +67 -0
  18. package/dist/Pill/PillContext.d.mts +3 -0
  19. package/dist/Pill/PillContext.d.ts +3 -0
  20. package/dist/Pill/PillContext.js +26 -0
  21. package/dist/Pill/PillContext.mjs +24 -0
  22. package/dist/Pill/PillPanel.d.mts +9 -0
  23. package/dist/Pill/PillPanel.d.ts +9 -0
  24. package/dist/Pill/PillPanel.js +88 -0
  25. package/dist/Pill/PillPanel.mjs +87 -0
  26. package/dist/Pill/parts.d.mts +10 -0
  27. package/dist/Pill/parts.d.ts +10 -0
  28. package/dist/Pill/parts.js +46 -0
  29. package/dist/Pill/parts.mjs +43 -0
  30. package/dist/Pill/types.d.mts +88 -0
  31. package/dist/Pill/types.d.ts +88 -0
  32. package/dist/PillNavbar/PillNavbar.d.mts +31 -0
  33. package/dist/PillNavbar/PillNavbar.d.ts +31 -0
  34. package/dist/PillNavbar/PillNavbar.js +44 -0
  35. package/dist/PillNavbar/PillNavbar.mjs +44 -0
  36. package/dist/PillNavbar/matchPath.d.mts +2 -0
  37. package/dist/PillNavbar/matchPath.d.ts +2 -0
  38. package/dist/PillNavbar/matchPath.js +34 -0
  39. package/dist/PillNavbar/matchPath.mjs +34 -0
  40. package/dist/PillNotification/PillNotification.d.mts +51 -0
  41. package/dist/PillNotification/PillNotification.d.ts +51 -0
  42. package/dist/PillNotification/PillNotification.js +64 -0
  43. package/dist/PillNotification/PillNotification.mjs +63 -0
  44. package/dist/icons/ArrowIcon.d.mts +4 -0
  45. package/dist/icons/ArrowIcon.d.ts +4 -0
  46. package/dist/icons/ArrowIcon.js +21 -0
  47. package/dist/icons/ArrowIcon.mjs +21 -0
  48. package/dist/icons/BoxIcon.d.mts +4 -0
  49. package/dist/icons/BoxIcon.d.ts +4 -0
  50. package/dist/icons/BoxIcon.js +21 -0
  51. package/dist/icons/BoxIcon.mjs +21 -0
  52. package/dist/icons/CheckIcon.d.mts +4 -0
  53. package/dist/icons/CheckIcon.d.ts +4 -0
  54. package/dist/icons/CheckIcon.js +17 -0
  55. package/dist/icons/CheckIcon.mjs +17 -0
  56. package/dist/icons/CloseIcon.d.mts +4 -0
  57. package/dist/icons/CloseIcon.d.ts +4 -0
  58. package/dist/icons/CloseIcon.js +17 -0
  59. package/dist/icons/CloseIcon.mjs +17 -0
  60. package/dist/icons/CouponIcon.d.mts +4 -0
  61. package/dist/icons/CouponIcon.d.ts +4 -0
  62. package/dist/icons/CouponIcon.js +17 -0
  63. package/dist/icons/CouponIcon.mjs +17 -0
  64. package/dist/icons/DocumentIcon.d.mts +4 -0
  65. package/dist/icons/DocumentIcon.d.ts +4 -0
  66. package/dist/icons/DocumentIcon.js +17 -0
  67. package/dist/icons/DocumentIcon.mjs +17 -0
  68. package/dist/icons/HelpIcon.d.mts +4 -0
  69. package/dist/icons/HelpIcon.d.ts +4 -0
  70. package/dist/icons/HelpIcon.js +17 -0
  71. package/dist/icons/HelpIcon.mjs +17 -0
  72. package/dist/icons/InfoIcon.d.mts +4 -0
  73. package/dist/icons/InfoIcon.d.ts +4 -0
  74. package/dist/icons/InfoIcon.js +17 -0
  75. package/dist/icons/InfoIcon.mjs +17 -0
  76. package/dist/icons/MailIcon.d.mts +4 -0
  77. package/dist/icons/MailIcon.d.ts +4 -0
  78. package/dist/icons/MailIcon.js +17 -0
  79. package/dist/icons/MailIcon.mjs +17 -0
  80. package/dist/icons/PhoneIcon.d.mts +4 -0
  81. package/dist/icons/PhoneIcon.d.ts +4 -0
  82. package/dist/icons/PhoneIcon.js +21 -0
  83. package/dist/icons/PhoneIcon.mjs +21 -0
  84. package/dist/icons/PlusIcon.d.mts +4 -0
  85. package/dist/icons/PlusIcon.d.ts +4 -0
  86. package/dist/icons/PlusIcon.js +17 -0
  87. package/dist/icons/PlusIcon.mjs +17 -0
  88. package/dist/icons/UndoIcon.d.mts +4 -0
  89. package/dist/icons/UndoIcon.d.ts +4 -0
  90. package/dist/icons/UndoIcon.js +21 -0
  91. package/dist/icons/UndoIcon.mjs +21 -0
  92. package/dist/icons/types.d.mts +3 -0
  93. package/dist/icons/types.d.ts +3 -0
  94. package/dist/index.d.mts +25 -8
  95. package/dist/index.d.ts +25 -9
  96. package/dist/index.js +50 -1
  97. package/dist/index.mjs +24 -1
  98. package/dist/store/store.d.mts +63 -0
  99. package/dist/store/store.d.ts +63 -0
  100. package/dist/store/store.js +104 -0
  101. package/dist/store/store.mjs +102 -0
  102. package/dist/store/usePillQueue.d.mts +6 -0
  103. package/dist/store/usePillQueue.d.ts +6 -0
  104. package/dist/store/usePillQueue.js +17 -0
  105. package/dist/store/usePillQueue.mjs +17 -0
  106. package/dist/styles.css +456 -0
  107. package/dist/utils/react.js +23 -0
  108. package/dist/utils/react.mjs +21 -0
  109. package/dist/utils/url.js +22 -0
  110. package/dist/utils/url.mjs +22 -0
  111. package/package.json +7 -4
  112. package/dist/MagicPill.d.mts +0 -6
  113. package/dist/MagicPill.d.ts +0 -7
  114. package/dist/MagicPill.js +0 -2
  115. package/dist/MagicPill.js.map +0 -1
  116. package/dist/MagicPill.mjs +0 -2
  117. package/dist/MagicPill.mjs.map +0 -1
  118. package/dist/Navbar/Navbar.js +0 -2
  119. package/dist/Navbar/Navbar.js.map +0 -1
  120. package/dist/Navbar/Navbar.mjs +0 -2
  121. package/dist/Navbar/Navbar.mjs.map +0 -1
  122. package/dist/Notification/Notification.js +0 -2
  123. package/dist/Notification/Notification.js.map +0 -1
  124. package/dist/Notification/Notification.mjs +0 -2
  125. package/dist/Notification/Notification.mjs.map +0 -1
  126. package/dist/defaultPillData.d.mts +0 -2
  127. package/dist/defaultPillData.d.ts +0 -3
  128. package/dist/defaultPillData.js +0 -7
  129. package/dist/defaultPillData.js.map +0 -1
  130. package/dist/defaultPillData.mjs +0 -7
  131. package/dist/defaultPillData.mjs.map +0 -1
  132. package/dist/icons/arrow_label.js +0 -2
  133. package/dist/icons/arrow_label.js.map +0 -1
  134. package/dist/icons/arrow_label.mjs +0 -2
  135. package/dist/icons/arrow_label.mjs.map +0 -1
  136. package/dist/icons/box_label.js +0 -2
  137. package/dist/icons/box_label.js.map +0 -1
  138. package/dist/icons/box_label.mjs +0 -2
  139. package/dist/icons/box_label.mjs.map +0 -1
  140. package/dist/icons/checkmark.js +0 -2
  141. package/dist/icons/checkmark.js.map +0 -1
  142. package/dist/icons/checkmark.mjs +0 -2
  143. package/dist/icons/checkmark.mjs.map +0 -1
  144. package/dist/icons/checkmark_label.js +0 -2
  145. package/dist/icons/checkmark_label.js.map +0 -1
  146. package/dist/icons/checkmark_label.mjs +0 -2
  147. package/dist/icons/checkmark_label.mjs.map +0 -1
  148. package/dist/icons/coupon.js +0 -2
  149. package/dist/icons/coupon.js.map +0 -1
  150. package/dist/icons/coupon.mjs +0 -2
  151. package/dist/icons/coupon.mjs.map +0 -1
  152. package/dist/icons/cross_label.js +0 -2
  153. package/dist/icons/cross_label.js.map +0 -1
  154. package/dist/icons/cross_label.mjs +0 -2
  155. package/dist/icons/cross_label.mjs.map +0 -1
  156. package/dist/icons/info.js +0 -2
  157. package/dist/icons/info.js.map +0 -1
  158. package/dist/icons/info.mjs +0 -2
  159. package/dist/icons/info.mjs.map +0 -1
  160. package/dist/icons/info_label.js +0 -2
  161. package/dist/icons/info_label.js.map +0 -1
  162. package/dist/icons/info_label.mjs +0 -2
  163. package/dist/icons/info_label.mjs.map +0 -1
  164. package/dist/icons/mail_label.js +0 -2
  165. package/dist/icons/mail_label.js.map +0 -1
  166. package/dist/icons/mail_label.mjs +0 -2
  167. package/dist/icons/mail_label.mjs.map +0 -1
  168. package/dist/icons/plus_label.js +0 -2
  169. package/dist/icons/plus_label.js.map +0 -1
  170. package/dist/icons/plus_label.mjs +0 -2
  171. package/dist/icons/plus_label.mjs.map +0 -1
  172. package/dist/icons/questionmark.js +0 -2
  173. package/dist/icons/questionmark.js.map +0 -1
  174. package/dist/icons/questionmark.mjs +0 -2
  175. package/dist/icons/questionmark.mjs.map +0 -1
  176. package/dist/icons/quotation_label.js +0 -2
  177. package/dist/icons/quotation_label.js.map +0 -1
  178. package/dist/icons/quotation_label.mjs +0 -2
  179. package/dist/icons/quotation_label.mjs.map +0 -1
  180. package/dist/icons/tel_label.js +0 -2
  181. package/dist/icons/tel_label.js.map +0 -1
  182. package/dist/icons/tel_label.mjs +0 -2
  183. package/dist/icons/tel_label.mjs.map +0 -1
  184. package/dist/icons/undo_label.js +0 -2
  185. package/dist/icons/undo_label.js.map +0 -1
  186. package/dist/icons/undo_label.mjs +0 -2
  187. package/dist/icons/undo_label.mjs.map +0 -1
  188. package/dist/magicpill.css +0 -315
  189. package/dist/types/index.d.ts +0 -4
  190. package/dist/types/magicPill.d.mts +0 -50
  191. package/dist/types/magicPill.d.ts +0 -50
  192. package/dist/types/navbar.d.mts +0 -27
  193. package/dist/types/navbar.d.ts +0 -28
  194. package/dist/types/notification.d.mts +0 -140
  195. package/dist/types/notification.d.ts +0 -141
  196. package/dist/utils/handlers.d.mts +0 -20
  197. package/dist/utils/handlers.d.ts +0 -21
  198. package/dist/utils/handlers.js +0 -2
  199. package/dist/utils/handlers.js.map +0 -1
  200. package/dist/utils/handlers.mjs +0 -2
  201. package/dist/utils/handlers.mjs.map +0 -1
  202. package/dist/utils/icons.d.mts +0 -20
  203. package/dist/utils/icons.d.ts +0 -20
  204. package/dist/utils/icons.js +0 -2
  205. package/dist/utils/icons.js.map +0 -1
  206. package/dist/utils/icons.mjs +0 -2
  207. package/dist/utils/icons.mjs.map +0 -1
@@ -0,0 +1,17 @@
1
+ let react_jsx_runtime = require("react/jsx-runtime");
2
+
3
+ // src/icons/PlusIcon.tsx
4
+ /** v9 icon (from `plus_label`): drawn in `currentColor`, decorative by default. */
5
+ const PlusIcon = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
6
+ width: "1em",
7
+ height: "1em",
8
+ viewBox: "0 0 27 28",
9
+ fill: "currentColor",
10
+ "aria-hidden": "true",
11
+ focusable: "false",
12
+ xmlns: "http://www.w3.org/2000/svg",
13
+ ...props,
14
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M0.8045 14.7234C0.357701 14.7234 -0.00450093 14.3612 -0.00450059 13.9144C-0.00450082 13.4676 0.357702 13.1054 0.8045 13.1054L12.5806 13.1054L12.5806 1.32934C12.5806 0.882544 12.9428 0.520341 13.3896 0.52034C13.8364 0.520341 14.1986 0.882543 14.1986 1.32934L14.1986 13.1054L25.9747 13.1054C26.4215 13.1054 26.7837 13.4676 26.7837 13.9144C26.7837 14.3612 26.4215 14.7234 25.9747 14.7234H14.1986L14.1986 26.4995C14.1986 26.9463 13.8364 27.3085 13.3896 27.3085C12.9428 27.3085 12.5806 26.9463 12.5806 26.4995L12.5806 14.7234L0.8045 14.7234Z" })
15
+ });
16
+
17
+ module.exports = PlusIcon;
@@ -0,0 +1,17 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+
3
+ // src/icons/PlusIcon.tsx
4
+ /** v9 icon (from `plus_label`): drawn in `currentColor`, decorative by default. */
5
+ const PlusIcon = (props) => /* @__PURE__ */ jsx("svg", {
6
+ width: "1em",
7
+ height: "1em",
8
+ viewBox: "0 0 27 28",
9
+ fill: "currentColor",
10
+ "aria-hidden": "true",
11
+ focusable: "false",
12
+ xmlns: "http://www.w3.org/2000/svg",
13
+ ...props,
14
+ children: /* @__PURE__ */ jsx("path", { d: "M0.8045 14.7234C0.357701 14.7234 -0.00450093 14.3612 -0.00450059 13.9144C-0.00450082 13.4676 0.357702 13.1054 0.8045 13.1054L12.5806 13.1054L12.5806 1.32934C12.5806 0.882544 12.9428 0.520341 13.3896 0.52034C13.8364 0.520341 14.1986 0.882543 14.1986 1.32934L14.1986 13.1054L25.9747 13.1054C26.4215 13.1054 26.7837 13.4676 26.7837 13.9144C26.7837 14.3612 26.4215 14.7234 25.9747 14.7234H14.1986L14.1986 26.4995C14.1986 26.9463 13.8364 27.3085 13.3896 27.3085C12.9428 27.3085 12.5806 26.9463 12.5806 26.4995L12.5806 14.7234L0.8045 14.7234Z" })
15
+ });
16
+
17
+ export { PlusIcon as default };
@@ -0,0 +1,4 @@
1
+ import { IconProps } from "./types.mjs";
2
+ /** v9 icon (from `undo_label`): drawn in `currentColor`, decorative by default. */
3
+ declare const UndoIcon: (props: IconProps) => import("react").JSX.Element;
4
+ export { UndoIcon as default };
@@ -0,0 +1,4 @@
1
+ import { IconProps } from "./types.js";
2
+ /** v9 icon (from `undo_label`): drawn in `currentColor`, decorative by default. */
3
+ declare const UndoIcon: (props: IconProps) => import("react").JSX.Element;
4
+ export = UndoIcon;
@@ -0,0 +1,21 @@
1
+ let react_jsx_runtime = require("react/jsx-runtime");
2
+
3
+ // src/icons/UndoIcon.tsx
4
+ /** v9 icon (from `undo_label`): drawn in `currentColor`, decorative by default. */
5
+ const UndoIcon = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
6
+ width: "1em",
7
+ height: "1em",
8
+ viewBox: "0 0 24 25",
9
+ fill: "currentColor",
10
+ "aria-hidden": "true",
11
+ focusable: "false",
12
+ xmlns: "http://www.w3.org/2000/svg",
13
+ ...props,
14
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
15
+ fillRule: "evenodd",
16
+ clipRule: "evenodd",
17
+ d: "M0.85896 7.85305C0.543026 7.53712 0.543026 7.02489 0.85896 6.70895L7.33096 0.236954C7.64689 -0.0789795 8.15912 -0.0789795 8.47506 0.236954C8.79099 0.552889 8.79099 1.06512 8.47506 1.38105L3.38411 6.472H19.229C21.463 6.472 23.274 8.28301 23.274 10.517V23.461C23.274 23.9078 22.9118 24.27 22.465 24.27C22.0182 24.27 21.656 23.9078 21.656 23.461V10.517C21.656 9.17661 20.5694 8.09 19.229 8.09H3.38411L8.47506 13.181C8.79099 13.4969 8.79099 14.0091 8.47506 14.3251C8.15912 14.641 7.64689 14.641 7.33096 14.3251L0.85896 7.85305Z"
18
+ })
19
+ });
20
+
21
+ module.exports = UndoIcon;
@@ -0,0 +1,21 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+
3
+ // src/icons/UndoIcon.tsx
4
+ /** v9 icon (from `undo_label`): drawn in `currentColor`, decorative by default. */
5
+ const UndoIcon = (props) => /* @__PURE__ */ jsx("svg", {
6
+ width: "1em",
7
+ height: "1em",
8
+ viewBox: "0 0 24 25",
9
+ fill: "currentColor",
10
+ "aria-hidden": "true",
11
+ focusable: "false",
12
+ xmlns: "http://www.w3.org/2000/svg",
13
+ ...props,
14
+ children: /* @__PURE__ */ jsx("path", {
15
+ fillRule: "evenodd",
16
+ clipRule: "evenodd",
17
+ d: "M0.85896 7.85305C0.543026 7.53712 0.543026 7.02489 0.85896 6.70895L7.33096 0.236954C7.64689 -0.0789795 8.15912 -0.0789795 8.47506 0.236954C8.79099 0.552889 8.79099 1.06512 8.47506 1.38105L3.38411 6.472H19.229C21.463 6.472 23.274 8.28301 23.274 10.517V23.461C23.274 23.9078 22.9118 24.27 22.465 24.27C22.0182 24.27 21.656 23.9078 21.656 23.461V10.517C21.656 9.17661 20.5694 8.09 19.229 8.09H3.38411L8.47506 13.181C8.79099 13.4969 8.79099 14.0091 8.47506 14.3251C8.15912 14.641 7.64689 14.641 7.33096 14.3251L0.85896 7.85305Z"
18
+ })
19
+ });
20
+
21
+ export { UndoIcon as default };
@@ -0,0 +1,3 @@
1
+ import { ComponentPropsWithoutRef } from "react";
2
+ /** Props of the v9 icons: any <svg> attribute. */
3
+ export type IconProps = ComponentPropsWithoutRef<"svg">;
@@ -0,0 +1,3 @@
1
+ import { ComponentPropsWithoutRef } from "react";
2
+ /** Props of the v9 icons: any <svg> attribute. */
3
+ export type IconProps = ComponentPropsWithoutRef<"svg">;
package/dist/index.d.mts CHANGED
@@ -1,8 +1,25 @@
1
- import { MagicPillNavbar, MagicPillNavbarItem } from "./types/navbar.mjs";
2
- import { MagicPillNotification, MagicPillNotificationCTA, MagicPillNotificationInfo } from "./types/notification.mjs";
3
- import { CTAIcon, MagicPillType, Mode, NotificationIcon } from "./types/magicPill.mjs";
4
- import MagicPill from "./MagicPill.mjs";
5
- import { addNavItem, deleteNavItem, handleActiveNavItem, updateCTAIcon, updateCTALabel, updateCTALink, updateInfoCloseLabel, updateInfoContent, updateInfoTitle, updateMode, updateNavItemIcon, updateNavItemLabel, updateNavItemLink, updateNotificationIcon, updateNotificationMessage } from "./utils/handlers.mjs";
6
- import { CTAIcons, Icons, getIconComponent } from "./utils/icons.mjs";
7
- import { defaultPillData } from "./defaultPillData.mjs";
8
- export { type CTAIcon, CTAIcons, Icons, MagicPill, type MagicPillNavbar, type MagicPillNavbarItem, type MagicPillNotification, type MagicPillNotificationCTA, type MagicPillNotificationInfo, type MagicPillType, type Mode, type NotificationIcon, addNavItem, defaultPillData, deleteNavItem, getIconComponent, handleActiveNavItem, updateCTAIcon, updateCTALabel, updateCTALink, updateInfoCloseLabel, updateInfoContent, updateInfoTitle, updateMode, updateNavItemIcon, updateNavItemLabel, updateNavItemLink, updateNotificationIcon, updateNotificationMessage };
1
+ import Pill from "./Pill/Pill.mjs";
2
+ import { PillActions, PillDivider, PillIcon, PillMessage } from "./Pill/parts.mjs";
3
+ import PillAction from "./Pill/PillAction.mjs";
4
+ import { PillPanel, PillPanelTrigger } from "./Pill/PillPanel.mjs";
5
+ import { usePill } from "./Pill/PillContext.mjs";
6
+ import { LinkComponent, PillActionProps, PillButtonActionProps, PillContextValue, PillLinkActionProps, PillOrientation, PillPanelProps, PillPlacement, PillPresence, PillProps, PillVariant } from "./Pill/types.mjs";
7
+ import { NotificationAction, NotificationPanel, PillNotification, PillNotificationClassNames, PillNotificationProps } from "./PillNotification/PillNotification.mjs";
8
+ import { NavItem, PillNavbar, PillNavbarProps } from "./PillNavbar/PillNavbar.mjs";
9
+ import MagicPill, { MagicPillProps } from "./MagicPill/MagicPill.mjs";
10
+ import { DismissReason, NotifyInput, NotifyOptions, NotifyRenderOptions, PillController, PillQueueState, QueuedNotification, pill } from "./store/store.mjs";
11
+ import { usePillQueue } from "./store/usePillQueue.mjs";
12
+ import ArrowIcon from "./icons/ArrowIcon.mjs";
13
+ import BoxIcon from "./icons/BoxIcon.mjs";
14
+ import CheckIcon from "./icons/CheckIcon.mjs";
15
+ import CloseIcon from "./icons/CloseIcon.mjs";
16
+ import CouponIcon from "./icons/CouponIcon.mjs";
17
+ import DocumentIcon from "./icons/DocumentIcon.mjs";
18
+ import HelpIcon from "./icons/HelpIcon.mjs";
19
+ import InfoIcon from "./icons/InfoIcon.mjs";
20
+ import MailIcon from "./icons/MailIcon.mjs";
21
+ import PhoneIcon from "./icons/PhoneIcon.mjs";
22
+ import PlusIcon from "./icons/PlusIcon.mjs";
23
+ import UndoIcon from "./icons/UndoIcon.mjs";
24
+ import { IconProps } from "./icons/types.mjs";
25
+ export { ArrowIcon, BoxIcon, CheckIcon, CloseIcon, CouponIcon, type DismissReason, DocumentIcon, HelpIcon, type IconProps, InfoIcon, type LinkComponent, MagicPill, type MagicPillProps, MailIcon, type NavItem, type NotificationAction, type NotificationPanel, type NotifyInput, type NotifyOptions, type NotifyRenderOptions, PhoneIcon, Pill, PillAction, type PillActionProps, PillActions, type PillButtonActionProps, type PillContextValue, type PillController, PillDivider, PillIcon, type PillLinkActionProps, PillMessage, PillNavbar, type PillNavbarProps, PillNotification, type PillNotificationClassNames, type PillNotificationProps, type PillOrientation, PillPanel, type PillPanelProps, PillPanelTrigger, type PillPlacement, type PillPresence, type PillProps, type PillQueueState, type PillVariant, PlusIcon, type QueuedNotification, UndoIcon, pill, usePill, usePillQueue };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,25 @@
1
- import { MagicPillNavbar, MagicPillNavbarItem } from "./types/navbar.js";
2
- import { MagicPillNotification, MagicPillNotificationCTA, MagicPillNotificationInfo } from "./types/notification.js";
3
- import { CTAIcon, MagicPillType, Mode, NotificationIcon } from "./types/magicPill.js";
4
- import MagicPill from "./MagicPill.js";
5
- import "./types/index.js";
6
- import { addNavItem, deleteNavItem, handleActiveNavItem, updateCTAIcon, updateCTALabel, updateCTALink, updateInfoCloseLabel, updateInfoContent, updateInfoTitle, updateMode, updateNavItemIcon, updateNavItemLabel, updateNavItemLink, updateNotificationIcon, updateNotificationMessage } from "./utils/handlers.js";
7
- import { CTAIcons, Icons, getIconComponent } from "./utils/icons.js";
8
- import { defaultPillData } from "./defaultPillData.js";
9
- export { type CTAIcon, CTAIcons, Icons, MagicPill, type MagicPillNavbar, type MagicPillNavbarItem, type MagicPillNotification, type MagicPillNotificationCTA, type MagicPillNotificationInfo, type MagicPillType, type Mode, type NotificationIcon, addNavItem, defaultPillData, deleteNavItem, getIconComponent, handleActiveNavItem, updateCTAIcon, updateCTALabel, updateCTALink, updateInfoCloseLabel, updateInfoContent, updateInfoTitle, updateMode, updateNavItemIcon, updateNavItemLabel, updateNavItemLink, updateNotificationIcon, updateNotificationMessage };
1
+ import Pill from "./Pill/Pill.js";
2
+ import { PillActions, PillDivider, PillIcon, PillMessage } from "./Pill/parts.js";
3
+ import PillAction from "./Pill/PillAction.js";
4
+ import { PillPanel, PillPanelTrigger } from "./Pill/PillPanel.js";
5
+ import { usePill } from "./Pill/PillContext.js";
6
+ import { LinkComponent, PillActionProps, PillButtonActionProps, PillContextValue, PillLinkActionProps, PillOrientation, PillPanelProps, PillPlacement, PillPresence, PillProps, PillVariant } from "./Pill/types.js";
7
+ import { NotificationAction, NotificationPanel, PillNotification, PillNotificationClassNames, PillNotificationProps } from "./PillNotification/PillNotification.js";
8
+ import { NavItem, PillNavbar, PillNavbarProps } from "./PillNavbar/PillNavbar.js";
9
+ import MagicPill, { MagicPillProps } from "./MagicPill/MagicPill.js";
10
+ import { DismissReason, NotifyInput, NotifyOptions, NotifyRenderOptions, PillController, PillQueueState, QueuedNotification, pill } from "./store/store.js";
11
+ import { usePillQueue } from "./store/usePillQueue.js";
12
+ import ArrowIcon from "./icons/ArrowIcon.js";
13
+ import BoxIcon from "./icons/BoxIcon.js";
14
+ import CheckIcon from "./icons/CheckIcon.js";
15
+ import CloseIcon from "./icons/CloseIcon.js";
16
+ import CouponIcon from "./icons/CouponIcon.js";
17
+ import DocumentIcon from "./icons/DocumentIcon.js";
18
+ import HelpIcon from "./icons/HelpIcon.js";
19
+ import InfoIcon from "./icons/InfoIcon.js";
20
+ import MailIcon from "./icons/MailIcon.js";
21
+ import PhoneIcon from "./icons/PhoneIcon.js";
22
+ import PlusIcon from "./icons/PlusIcon.js";
23
+ import UndoIcon from "./icons/UndoIcon.js";
24
+ import { IconProps } from "./icons/types.js";
25
+ export { ArrowIcon, BoxIcon, CheckIcon, CloseIcon, CouponIcon, type DismissReason, DocumentIcon, HelpIcon, type IconProps, InfoIcon, type LinkComponent, MagicPill, type MagicPillProps, MailIcon, type NavItem, type NotificationAction, type NotificationPanel, type NotifyInput, type NotifyOptions, type NotifyRenderOptions, PhoneIcon, Pill, PillAction, type PillActionProps, PillActions, type PillButtonActionProps, type PillContextValue, type PillController, PillDivider, PillIcon, type PillLinkActionProps, PillMessage, PillNavbar, type PillNavbarProps, PillNotification, type PillNotificationClassNames, type PillNotificationProps, type PillOrientation, PillPanel, type PillPanelProps, PillPanelTrigger, type PillPlacement, type PillPresence, type PillProps, type PillQueueState, type PillVariant, PlusIcon, type QueuedNotification, UndoIcon, pill, usePill, usePillQueue };
package/dist/index.js CHANGED
@@ -1 +1,50 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./MagicPill.js"),t=require("./utils/handlers.js"),n=require("./utils/icons.js"),r=require("./defaultPillData.js");exports.CTAIcons=n.CTAIcons,exports.Icons=n.Icons,exports.MagicPill=e,exports.addNavItem=t.addNavItem,exports.defaultPillData=r.defaultPillData,exports.deleteNavItem=t.deleteNavItem,exports.getIconComponent=n.getIconComponent,exports.handleActiveNavItem=t.handleActiveNavItem,exports.updateCTAIcon=t.updateCTAIcon,exports.updateCTALabel=t.updateCTALabel,exports.updateCTALink=t.updateCTALink,exports.updateInfoCloseLabel=t.updateInfoCloseLabel,exports.updateInfoContent=t.updateInfoContent,exports.updateInfoTitle=t.updateInfoTitle,exports.updateMode=t.updateMode,exports.updateNavItemIcon=t.updateNavItemIcon,exports.updateNavItemLabel=t.updateNavItemLabel,exports.updateNavItemLink=t.updateNavItemLink,exports.updateNotificationIcon=t.updateNotificationIcon,exports.updateNotificationMessage=t.updateNotificationMessage;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_Pill = require("./Pill/Pill.js");
3
+ const require_parts = require("./Pill/parts.js");
4
+ const require_PillAction = require("./Pill/PillAction.js");
5
+ const require_PillPanel = require("./Pill/PillPanel.js");
6
+ const require_PillContext = require("./Pill/PillContext.js");
7
+ const require_PillNotification = require("./PillNotification/PillNotification.js");
8
+ const require_PillNavbar = require("./PillNavbar/PillNavbar.js");
9
+ const require_MagicPill = require("./MagicPill/MagicPill.js");
10
+ const require_store = require("./store/store.js");
11
+ const require_usePillQueue = require("./store/usePillQueue.js");
12
+ const require_ArrowIcon = require("./icons/ArrowIcon.js");
13
+ const require_BoxIcon = require("./icons/BoxIcon.js");
14
+ const require_CheckIcon = require("./icons/CheckIcon.js");
15
+ const require_CloseIcon = require("./icons/CloseIcon.js");
16
+ const require_CouponIcon = require("./icons/CouponIcon.js");
17
+ const require_DocumentIcon = require("./icons/DocumentIcon.js");
18
+ const require_HelpIcon = require("./icons/HelpIcon.js");
19
+ const require_InfoIcon = require("./icons/InfoIcon.js");
20
+ const require_MailIcon = require("./icons/MailIcon.js");
21
+ const require_PhoneIcon = require("./icons/PhoneIcon.js");
22
+ const require_PlusIcon = require("./icons/PlusIcon.js");
23
+ const require_UndoIcon = require("./icons/UndoIcon.js");
24
+
25
+ exports.ArrowIcon = require_ArrowIcon;
26
+ exports.BoxIcon = require_BoxIcon;
27
+ exports.CheckIcon = require_CheckIcon;
28
+ exports.CloseIcon = require_CloseIcon;
29
+ exports.CouponIcon = require_CouponIcon;
30
+ exports.DocumentIcon = require_DocumentIcon;
31
+ exports.HelpIcon = require_HelpIcon;
32
+ exports.InfoIcon = require_InfoIcon;
33
+ exports.MagicPill = require_MagicPill;
34
+ exports.MailIcon = require_MailIcon;
35
+ exports.PhoneIcon = require_PhoneIcon;
36
+ exports.Pill = require_Pill;
37
+ exports.PillAction = require_PillAction;
38
+ exports.PillActions = require_parts.PillActions;
39
+ exports.PillDivider = require_parts.PillDivider;
40
+ exports.PillIcon = require_parts.PillIcon;
41
+ exports.PillMessage = require_parts.PillMessage;
42
+ exports.PillNavbar = require_PillNavbar.PillNavbar;
43
+ exports.PillNotification = require_PillNotification.PillNotification;
44
+ exports.PillPanel = require_PillPanel.PillPanel;
45
+ exports.PillPanelTrigger = require_PillPanel.PillPanelTrigger;
46
+ exports.PlusIcon = require_PlusIcon;
47
+ exports.UndoIcon = require_UndoIcon;
48
+ exports.pill = require_store.pill;
49
+ exports.usePill = require_PillContext.usePill;
50
+ exports.usePillQueue = require_usePillQueue.usePillQueue;
package/dist/index.mjs CHANGED
@@ -1 +1,24 @@
1
- import e from"./MagicPill.mjs";import{addNavItem as t,deleteNavItem as n,handleActiveNavItem as r,updateCTAIcon as i,updateCTALabel as a,updateCTALink as o,updateInfoCloseLabel as s,updateInfoContent as c,updateInfoTitle as l,updateMode as u,updateNavItemIcon as d,updateNavItemLabel as f,updateNavItemLink as p,updateNotificationIcon as m,updateNotificationMessage as h}from"./utils/handlers.mjs";import{CTAIcons as g,Icons as _,getIconComponent as v}from"./utils/icons.mjs";import{defaultPillData as y}from"./defaultPillData.mjs";export{g as CTAIcons,_ as Icons,e as MagicPill,t as addNavItem,y as defaultPillData,n as deleteNavItem,v as getIconComponent,r as handleActiveNavItem,i as updateCTAIcon,a as updateCTALabel,o as updateCTALink,s as updateInfoCloseLabel,c as updateInfoContent,l as updateInfoTitle,u as updateMode,d as updateNavItemIcon,f as updateNavItemLabel,p as updateNavItemLink,m as updateNotificationIcon,h as updateNotificationMessage};
1
+ import Pill from "./Pill/Pill.mjs";
2
+ import { PillActions, PillDivider, PillIcon, PillMessage } from "./Pill/parts.mjs";
3
+ import PillAction from "./Pill/PillAction.mjs";
4
+ import { PillPanel, PillPanelTrigger } from "./Pill/PillPanel.mjs";
5
+ import { usePill } from "./Pill/PillContext.mjs";
6
+ import { PillNotification } from "./PillNotification/PillNotification.mjs";
7
+ import { PillNavbar } from "./PillNavbar/PillNavbar.mjs";
8
+ import MagicPill from "./MagicPill/MagicPill.mjs";
9
+ import { pill } from "./store/store.mjs";
10
+ import { usePillQueue } from "./store/usePillQueue.mjs";
11
+ import ArrowIcon from "./icons/ArrowIcon.mjs";
12
+ import BoxIcon from "./icons/BoxIcon.mjs";
13
+ import CheckIcon from "./icons/CheckIcon.mjs";
14
+ import CloseIcon from "./icons/CloseIcon.mjs";
15
+ import CouponIcon from "./icons/CouponIcon.mjs";
16
+ import DocumentIcon from "./icons/DocumentIcon.mjs";
17
+ import HelpIcon from "./icons/HelpIcon.mjs";
18
+ import InfoIcon from "./icons/InfoIcon.mjs";
19
+ import MailIcon from "./icons/MailIcon.mjs";
20
+ import PhoneIcon from "./icons/PhoneIcon.mjs";
21
+ import PlusIcon from "./icons/PlusIcon.mjs";
22
+ import UndoIcon from "./icons/UndoIcon.mjs";
23
+
24
+ export { ArrowIcon, BoxIcon, CheckIcon, CloseIcon, CouponIcon, DocumentIcon, HelpIcon, InfoIcon, MagicPill, MailIcon, PhoneIcon, Pill, PillAction, PillActions, PillDivider, PillIcon, PillMessage, PillNavbar, PillNotification, PillPanel, PillPanelTrigger, PlusIcon, UndoIcon, pill, usePill, usePillQueue };
@@ -0,0 +1,63 @@
1
+ import { ReactNode } from "react";
2
+ import { PillVariant } from "../Pill/types.mjs";
3
+ import { PillNotificationProps } from "../PillNotification/PillNotification.mjs";
4
+ export type DismissReason = "timeout" | "action" | "dismissed" | "cleared";
5
+ interface NotifyCommon {
6
+ /**
7
+ * Reusing the id of a queued or visible notification updates it in place
8
+ * (e.g. "Saving…" → "Saved") instead of queueing a new one.
9
+ */
10
+ id?: string;
11
+ variant?: PillVariant;
12
+ /**
13
+ * Milliseconds the notification stays once fully shown. Default: the host's
14
+ * `duration` (5000). `Infinity` keeps it until dismissed. The countdown
15
+ * pauses on hover, focus, an open panel and a hidden browser tab, and
16
+ * starts again from the full duration afterwards.
17
+ */
18
+ duration?: number;
19
+ /**
20
+ * What screen readers announce. Default: the text of the message (or of the
21
+ * whole pill for a `render` notification). `false` announces nothing.
22
+ */
23
+ announce?: string | false;
24
+ onDismiss?: (id: string, reason: DismissReason) => void;
25
+ }
26
+ /** The built-in notification template, as data. */
27
+ export interface NotifyOptions extends NotifyCommon, Omit<PillNotificationProps, "linkComponent" | "classNames"> {
28
+ render?: undefined;
29
+ }
30
+ /** Your own template, with the queue, timing and animation of the host. */
31
+ export interface NotifyRenderOptions extends NotifyCommon {
32
+ render: (notification: {
33
+ id: string;
34
+ dismiss: () => void;
35
+ }) => ReactNode;
36
+ }
37
+ export type NotifyInput = NotifyOptions | NotifyRenderOptions;
38
+ export interface QueuedNotification {
39
+ readonly id: string;
40
+ readonly input: NotifyInput;
41
+ }
42
+ export interface PillQueueState {
43
+ /** The notification the pill shows (or is about to show). */
44
+ readonly current: QueuedNotification | null;
45
+ /** The ones waiting behind it, first in, first out. */
46
+ readonly queued: readonly QueuedNotification[];
47
+ }
48
+ export interface PillController {
49
+ readonly name: string;
50
+ /**
51
+ * Queue a notification (first in, first out). Returns its id.
52
+ * Calls made before the host mounts are kept and shown once it mounts.
53
+ */
54
+ notify: (input: NotifyInput) => string;
55
+ update: (id: string, patch: Partial<NotifyOptions>) => void;
56
+ /** Dismiss one notification, or the visible one when called without an id. */
57
+ dismiss: (id?: string) => void;
58
+ /** Empty the queue and dismiss the visible notification. */
59
+ clear: () => void;
60
+ }
61
+ /** Control the <MagicPill> with this name (default "main") from anywhere. */
62
+ export declare function pill(name?: string): PillController;
63
+ export {};
@@ -0,0 +1,63 @@
1
+ import { ReactNode } from "react";
2
+ import { PillVariant } from "../Pill/types.js";
3
+ import { PillNotificationProps } from "../PillNotification/PillNotification.js";
4
+ export type DismissReason = "timeout" | "action" | "dismissed" | "cleared";
5
+ interface NotifyCommon {
6
+ /**
7
+ * Reusing the id of a queued or visible notification updates it in place
8
+ * (e.g. "Saving…" → "Saved") instead of queueing a new one.
9
+ */
10
+ id?: string;
11
+ variant?: PillVariant;
12
+ /**
13
+ * Milliseconds the notification stays once fully shown. Default: the host's
14
+ * `duration` (5000). `Infinity` keeps it until dismissed. The countdown
15
+ * pauses on hover, focus, an open panel and a hidden browser tab, and
16
+ * starts again from the full duration afterwards.
17
+ */
18
+ duration?: number;
19
+ /**
20
+ * What screen readers announce. Default: the text of the message (or of the
21
+ * whole pill for a `render` notification). `false` announces nothing.
22
+ */
23
+ announce?: string | false;
24
+ onDismiss?: (id: string, reason: DismissReason) => void;
25
+ }
26
+ /** The built-in notification template, as data. */
27
+ export interface NotifyOptions extends NotifyCommon, Omit<PillNotificationProps, "linkComponent" | "classNames"> {
28
+ render?: undefined;
29
+ }
30
+ /** Your own template, with the queue, timing and animation of the host. */
31
+ export interface NotifyRenderOptions extends NotifyCommon {
32
+ render: (notification: {
33
+ id: string;
34
+ dismiss: () => void;
35
+ }) => ReactNode;
36
+ }
37
+ export type NotifyInput = NotifyOptions | NotifyRenderOptions;
38
+ export interface QueuedNotification {
39
+ readonly id: string;
40
+ readonly input: NotifyInput;
41
+ }
42
+ export interface PillQueueState {
43
+ /** The notification the pill shows (or is about to show). */
44
+ readonly current: QueuedNotification | null;
45
+ /** The ones waiting behind it, first in, first out. */
46
+ readonly queued: readonly QueuedNotification[];
47
+ }
48
+ export interface PillController {
49
+ readonly name: string;
50
+ /**
51
+ * Queue a notification (first in, first out). Returns its id.
52
+ * Calls made before the host mounts are kept and shown once it mounts.
53
+ */
54
+ notify: (input: NotifyInput) => string;
55
+ update: (id: string, patch: Partial<NotifyOptions>) => void;
56
+ /** Dismiss one notification, or the visible one when called without an id. */
57
+ dismiss: (id?: string) => void;
58
+ /** Empty the queue and dismiss the visible notification. */
59
+ clear: () => void;
60
+ }
61
+ /** Control the <MagicPill> with this name (default "main") from anywhere. */
62
+ export declare function pill(name?: string): PillController;
63
+ export {};
@@ -0,0 +1,104 @@
1
+ const require_react = require("../utils/react.js");
2
+
3
+ // src/store/store.ts
4
+ const EMPTY_STATE = Object.freeze({
5
+ current: null,
6
+ queued: Object.freeze([])
7
+ });
8
+ let lastId = 0;
9
+ const isServer = () => typeof document === "undefined";
10
+ function createStore(name) {
11
+ let items = [];
12
+ let state = EMPTY_STATE;
13
+ let hosts = 0;
14
+ const listeners = /* @__PURE__ */ new Set();
15
+ const commit = (next) => {
16
+ items = next;
17
+ state = next.length === 0 ? EMPTY_STATE : {
18
+ current: next[0],
19
+ queued: next.slice(1)
20
+ };
21
+ listeners.forEach((listener) => listener());
22
+ };
23
+ const replace = (id, input) => commit(items.map((item) => item.id === id ? {
24
+ id,
25
+ input
26
+ } : item));
27
+ return {
28
+ getState: () => state,
29
+ subscribe(listener) {
30
+ listeners.add(listener);
31
+ return () => listeners.delete(listener);
32
+ },
33
+ notify(input) {
34
+ const id = input.id ?? `mp-${++lastId}`;
35
+ if (isServer()) {
36
+ require_react.devWarn(`pill("${name}").notify() was called on the server and does nothing: call it from client code.`);
37
+ return id;
38
+ }
39
+ if (items.some((item) => item.id === id)) replace(id, input);
40
+ else commit([...items, {
41
+ id,
42
+ input
43
+ }]);
44
+ return id;
45
+ },
46
+ update(id, patch) {
47
+ const item = items.find((queued) => queued.id === id);
48
+ if (item) replace(id, {
49
+ ...item.input,
50
+ ...patch
51
+ });
52
+ },
53
+ dismiss(id, reason) {
54
+ const item = id === void 0 ? items[0] : items.find((queued) => queued.id === id);
55
+ if (!item) return;
56
+ commit(items.filter((queued) => queued !== item));
57
+ item.input.onDismiss?.(item.id, reason);
58
+ },
59
+ clear() {
60
+ const dismissed = items;
61
+ if (dismissed.length === 0) return;
62
+ commit([]);
63
+ dismissed.forEach((item) => item.input.onDismiss?.(item.id, "cleared"));
64
+ },
65
+ registerHost() {
66
+ hosts += 1;
67
+ if (hosts > 1) require_react.devWarn(`Several <MagicPill name="${name}"> are mounted. Give each one its own name.`);
68
+ return () => {
69
+ hosts -= 1;
70
+ };
71
+ }
72
+ };
73
+ }
74
+ const stores = /* @__PURE__ */ new Map();
75
+ /** The store of the pill with this name, created on first use. */
76
+ function getStore(name) {
77
+ let store = stores.get(name);
78
+ if (!store) {
79
+ store = createStore(name);
80
+ stores.set(name, store);
81
+ }
82
+ return store;
83
+ }
84
+ const controllers = /* @__PURE__ */ new Map();
85
+ /** Control the <MagicPill> with this name (default "main") from anywhere. */
86
+ function pill(name = "main") {
87
+ let controller = controllers.get(name);
88
+ if (!controller) {
89
+ const store = getStore(name);
90
+ controller = Object.freeze({
91
+ name,
92
+ notify: (input) => store.notify(input),
93
+ update: (id, patch) => store.update(id, patch),
94
+ dismiss: (id) => store.dismiss(id, "dismissed"),
95
+ clear: () => store.clear()
96
+ });
97
+ controllers.set(name, controller);
98
+ }
99
+ return controller;
100
+ }
101
+
102
+ exports.EMPTY_STATE = EMPTY_STATE;
103
+ exports.getStore = getStore;
104
+ exports.pill = pill;
@@ -0,0 +1,102 @@
1
+ import { devWarn } from "../utils/react.mjs";
2
+
3
+ // src/store/store.ts
4
+ const EMPTY_STATE = Object.freeze({
5
+ current: null,
6
+ queued: Object.freeze([])
7
+ });
8
+ let lastId = 0;
9
+ const isServer = () => typeof document === "undefined";
10
+ function createStore(name) {
11
+ let items = [];
12
+ let state = EMPTY_STATE;
13
+ let hosts = 0;
14
+ const listeners = /* @__PURE__ */ new Set();
15
+ const commit = (next) => {
16
+ items = next;
17
+ state = next.length === 0 ? EMPTY_STATE : {
18
+ current: next[0],
19
+ queued: next.slice(1)
20
+ };
21
+ listeners.forEach((listener) => listener());
22
+ };
23
+ const replace = (id, input) => commit(items.map((item) => item.id === id ? {
24
+ id,
25
+ input
26
+ } : item));
27
+ return {
28
+ getState: () => state,
29
+ subscribe(listener) {
30
+ listeners.add(listener);
31
+ return () => listeners.delete(listener);
32
+ },
33
+ notify(input) {
34
+ const id = input.id ?? `mp-${++lastId}`;
35
+ if (isServer()) {
36
+ devWarn(`pill("${name}").notify() was called on the server and does nothing: call it from client code.`);
37
+ return id;
38
+ }
39
+ if (items.some((item) => item.id === id)) replace(id, input);
40
+ else commit([...items, {
41
+ id,
42
+ input
43
+ }]);
44
+ return id;
45
+ },
46
+ update(id, patch) {
47
+ const item = items.find((queued) => queued.id === id);
48
+ if (item) replace(id, {
49
+ ...item.input,
50
+ ...patch
51
+ });
52
+ },
53
+ dismiss(id, reason) {
54
+ const item = id === void 0 ? items[0] : items.find((queued) => queued.id === id);
55
+ if (!item) return;
56
+ commit(items.filter((queued) => queued !== item));
57
+ item.input.onDismiss?.(item.id, reason);
58
+ },
59
+ clear() {
60
+ const dismissed = items;
61
+ if (dismissed.length === 0) return;
62
+ commit([]);
63
+ dismissed.forEach((item) => item.input.onDismiss?.(item.id, "cleared"));
64
+ },
65
+ registerHost() {
66
+ hosts += 1;
67
+ if (hosts > 1) devWarn(`Several <MagicPill name="${name}"> are mounted. Give each one its own name.`);
68
+ return () => {
69
+ hosts -= 1;
70
+ };
71
+ }
72
+ };
73
+ }
74
+ const stores = /* @__PURE__ */ new Map();
75
+ /** The store of the pill with this name, created on first use. */
76
+ function getStore(name) {
77
+ let store = stores.get(name);
78
+ if (!store) {
79
+ store = createStore(name);
80
+ stores.set(name, store);
81
+ }
82
+ return store;
83
+ }
84
+ const controllers = /* @__PURE__ */ new Map();
85
+ /** Control the <MagicPill> with this name (default "main") from anywhere. */
86
+ function pill(name = "main") {
87
+ let controller = controllers.get(name);
88
+ if (!controller) {
89
+ const store = getStore(name);
90
+ controller = Object.freeze({
91
+ name,
92
+ notify: (input) => store.notify(input),
93
+ update: (id, patch) => store.update(id, patch),
94
+ dismiss: (id) => store.dismiss(id, "dismissed"),
95
+ clear: () => store.clear()
96
+ });
97
+ controllers.set(name, controller);
98
+ }
99
+ return controller;
100
+ }
101
+
102
+ export { EMPTY_STATE, getStore, pill };
@@ -0,0 +1,6 @@
1
+ import { PillQueueState } from "./store.mjs";
2
+ /**
3
+ * Headless access to a pill's queue, to build your own host or display
4
+ * (like react-hot-toast's useToaster). <MagicPill> is built on it.
5
+ */
6
+ export declare function usePillQueue(name?: string): PillQueueState;
@@ -0,0 +1,6 @@
1
+ import { PillQueueState } from "./store.js";
2
+ /**
3
+ * Headless access to a pill's queue, to build your own host or display
4
+ * (like react-hot-toast's useToaster). <MagicPill> is built on it.
5
+ */
6
+ export declare function usePillQueue(name?: string): PillQueueState;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+
3
+ let react = require("react");
4
+ const require_store = require("./store.js");
5
+
6
+ // src/store/usePillQueue.ts
7
+ const getServerSnapshot = () => require_store.EMPTY_STATE;
8
+ /**
9
+ * Headless access to a pill's queue, to build your own host or display
10
+ * (like react-hot-toast's useToaster). <MagicPill> is built on it.
11
+ */
12
+ function usePillQueue(name = "main") {
13
+ const store = require_store.getStore(name);
14
+ return (0, react.useSyncExternalStore)(store.subscribe, store.getState, getServerSnapshot);
15
+ }
16
+
17
+ exports.usePillQueue = usePillQueue;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+
3
+ import { useSyncExternalStore } from "react";
4
+ import { EMPTY_STATE, getStore } from "./store.mjs";
5
+
6
+ // src/store/usePillQueue.ts
7
+ const getServerSnapshot = () => EMPTY_STATE;
8
+ /**
9
+ * Headless access to a pill's queue, to build your own host or display
10
+ * (like react-hot-toast's useToaster). <MagicPill> is built on it.
11
+ */
12
+ function usePillQueue(name = "main") {
13
+ const store = getStore(name);
14
+ return useSyncExternalStore(store.subscribe, store.getState, getServerSnapshot);
15
+ }
16
+
17
+ export { usePillQueue };