magic-pill 8.0.2 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/CHANGELOG.md +82 -31
  2. package/README.md +69 -51
  3. package/dist/MagicPill.d.mts +6 -0
  4. package/dist/MagicPill.d.ts +5 -6
  5. package/dist/MagicPill.js +2 -0
  6. package/dist/MagicPill.js.map +1 -0
  7. package/dist/MagicPill.mjs +2 -0
  8. package/dist/MagicPill.mjs.map +1 -0
  9. package/dist/Navbar/Navbar.js +2 -0
  10. package/dist/Navbar/Navbar.js.map +1 -0
  11. package/dist/Navbar/Navbar.mjs +2 -0
  12. package/dist/Navbar/Navbar.mjs.map +1 -0
  13. package/dist/Notification/Notification.js +2 -0
  14. package/dist/Notification/Notification.js.map +1 -0
  15. package/dist/Notification/Notification.mjs +2 -0
  16. package/dist/Notification/Notification.mjs.map +1 -0
  17. package/dist/defaultPillData.d.mts +2 -0
  18. package/dist/defaultPillData.d.ts +3 -2
  19. package/dist/defaultPillData.js +7 -0
  20. package/dist/defaultPillData.js.map +1 -0
  21. package/dist/defaultPillData.mjs +7 -0
  22. package/dist/defaultPillData.mjs.map +1 -0
  23. package/dist/icons/arrow_label.js +2 -0
  24. package/dist/icons/arrow_label.js.map +1 -0
  25. package/dist/icons/arrow_label.mjs +2 -0
  26. package/dist/icons/arrow_label.mjs.map +1 -0
  27. package/dist/icons/box_label.js +2 -0
  28. package/dist/icons/box_label.js.map +1 -0
  29. package/dist/icons/box_label.mjs +2 -0
  30. package/dist/icons/box_label.mjs.map +1 -0
  31. package/dist/icons/checkmark.js +2 -0
  32. package/dist/icons/checkmark.js.map +1 -0
  33. package/dist/icons/checkmark.mjs +2 -0
  34. package/dist/icons/checkmark.mjs.map +1 -0
  35. package/dist/icons/checkmark_label.js +2 -0
  36. package/dist/icons/checkmark_label.js.map +1 -0
  37. package/dist/icons/checkmark_label.mjs +2 -0
  38. package/dist/icons/checkmark_label.mjs.map +1 -0
  39. package/dist/icons/coupon.js +2 -0
  40. package/dist/icons/coupon.js.map +1 -0
  41. package/dist/icons/coupon.mjs +2 -0
  42. package/dist/icons/coupon.mjs.map +1 -0
  43. package/dist/icons/cross_label.js +2 -0
  44. package/dist/icons/cross_label.js.map +1 -0
  45. package/dist/icons/cross_label.mjs +2 -0
  46. package/dist/icons/cross_label.mjs.map +1 -0
  47. package/dist/icons/info.js +2 -0
  48. package/dist/icons/info.js.map +1 -0
  49. package/dist/icons/info.mjs +2 -0
  50. package/dist/icons/info.mjs.map +1 -0
  51. package/dist/icons/info_label.js +2 -0
  52. package/dist/icons/info_label.js.map +1 -0
  53. package/dist/icons/info_label.mjs +2 -0
  54. package/dist/icons/info_label.mjs.map +1 -0
  55. package/dist/icons/mail_label.js +2 -0
  56. package/dist/icons/mail_label.js.map +1 -0
  57. package/dist/icons/mail_label.mjs +2 -0
  58. package/dist/icons/mail_label.mjs.map +1 -0
  59. package/dist/icons/plus_label.js +2 -0
  60. package/dist/icons/plus_label.js.map +1 -0
  61. package/dist/icons/plus_label.mjs +2 -0
  62. package/dist/icons/plus_label.mjs.map +1 -0
  63. package/dist/icons/questionmark.js +2 -0
  64. package/dist/icons/questionmark.js.map +1 -0
  65. package/dist/icons/questionmark.mjs +2 -0
  66. package/dist/icons/questionmark.mjs.map +1 -0
  67. package/dist/icons/quotation_label.js +2 -0
  68. package/dist/icons/quotation_label.js.map +1 -0
  69. package/dist/icons/quotation_label.mjs +2 -0
  70. package/dist/icons/quotation_label.mjs.map +1 -0
  71. package/dist/icons/tel_label.js +2 -0
  72. package/dist/icons/tel_label.js.map +1 -0
  73. package/dist/icons/tel_label.mjs +2 -0
  74. package/dist/icons/tel_label.mjs.map +1 -0
  75. package/dist/icons/undo_label.js +2 -0
  76. package/dist/icons/undo_label.js.map +1 -0
  77. package/dist/icons/undo_label.mjs +2 -0
  78. package/dist/icons/undo_label.mjs.map +1 -0
  79. package/dist/index.d.mts +8 -0
  80. package/dist/index.d.ts +9 -5
  81. package/dist/index.js +1 -2
  82. package/dist/index.mjs +1 -0
  83. package/dist/magicpill.css +91 -43
  84. package/dist/types/index.d.ts +4 -3
  85. package/dist/types/magicPill.d.mts +50 -0
  86. package/dist/types/magicPill.d.ts +9 -9
  87. package/dist/types/navbar.d.mts +27 -0
  88. package/dist/types/navbar.d.ts +7 -6
  89. package/dist/types/notification.d.mts +140 -0
  90. package/dist/types/notification.d.ts +22 -21
  91. package/dist/utils/handlers.d.mts +20 -0
  92. package/dist/utils/handlers.d.ts +5 -3
  93. package/dist/utils/handlers.js +2 -0
  94. package/dist/utils/handlers.js.map +1 -0
  95. package/dist/utils/handlers.mjs +2 -0
  96. package/dist/utils/handlers.mjs.map +1 -0
  97. package/dist/utils/icons.d.mts +20 -0
  98. package/dist/utils/icons.d.ts +16 -14
  99. package/dist/utils/icons.js +2 -0
  100. package/dist/utils/icons.js.map +1 -0
  101. package/dist/utils/icons.mjs +2 -0
  102. package/dist/utils/icons.mjs.map +1 -0
  103. package/package.json +35 -24
  104. package/dist/Navbar/Navbar.d.ts +0 -9
  105. package/dist/Notification/Notification.d.ts +0 -9
  106. package/dist/icons/arrow_label.d.ts +0 -3
  107. package/dist/icons/box_label.d.ts +0 -3
  108. package/dist/icons/checkmark.d.ts +0 -3
  109. package/dist/icons/checkmark_label.d.ts +0 -3
  110. package/dist/icons/coupon.d.ts +0 -3
  111. package/dist/icons/cross_label.d.ts +0 -3
  112. package/dist/icons/info.d.ts +0 -3
  113. package/dist/icons/mail_label.d.ts +0 -3
  114. package/dist/icons/plus_label.d.ts +0 -3
  115. package/dist/icons/questionmark.d.ts +0 -3
  116. package/dist/icons/quotation_label.d.ts +0 -3
  117. package/dist/icons/tel_label.d.ts +0 -3
  118. package/dist/icons/undo_label.d.ts +0 -3
  119. package/dist/index.esm.js +0 -2
  120. package/dist/index.esm.js.map +0 -1
  121. package/dist/index.js.map +0 -1
@@ -1,26 +1,26 @@
1
1
  /* Font import */
2
2
  @import url('https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&family=Overlock:ital,wght@0,400;0,700;0,900;1,400;1,700;1,900&display=swap');
3
3
 
4
+ /* CSS variables */
5
+ :root {
6
+ --mp__themeDark: #141414;
7
+ --mp__themeLight: #F9F9F9;
8
+ --mp__font-text: "Overlock", sans-serif;
9
+ --mp__font-accent: "Lexend", sans-serif;
10
+ --mp__normal: normal;
11
+ --mp__italic: italic;
12
+ --mp__medium: 400;
13
+ --mp__bold: 700;
14
+ --mp__black: 900;
15
+ --mp__success: #3F7253;
16
+ --mp__danger: #FC5D6A;
17
+ --mp__textSize: 19.4px;
18
+ --mp__titleSize: 31.42px;
19
+ }
20
+
4
21
  html {
5
22
  >body {
6
23
 
7
- /* CSS variables */
8
- .magicPill {
9
- --themeDark: #141414;
10
- --themeLight: #F9F9F9;
11
- --font-text: "Overlock", sans-serif;
12
- --font-accent: "Lexend", sans-serif;
13
- --normal: normal;
14
- --italic: italic;
15
- --medium: 400;
16
- --bold: 700;
17
- --black: 900;
18
- --success: #3F7253;
19
- --danger: #FC5D6A;
20
- --textSize: 19.4px;
21
- --titleSize: 31.42px;
22
- }
23
-
24
24
  /* General */
25
25
  .magicPill,
26
26
  .magicPill::before,
@@ -28,21 +28,21 @@ html {
28
28
  box-sizing: border-box;
29
29
  margin: 0;
30
30
  padding: 0;
31
- font-family: var(--font-text);
31
+ font-family: var(--mp__font-text);
32
32
  }
33
33
 
34
34
  .magicPill {
35
35
  z-index: 1;
36
36
  scale: 0;
37
- position: absolute;
37
+ position: fixed;
38
38
  top: calc(95dvh - 110px);
39
39
  left: 50%;
40
40
  transform: translateX(-50%);
41
41
  padding: 25px;
42
42
  display: flex;
43
43
  gap: 25px;
44
- background-color: var(--themeDark);
45
- color: var(--themeLight);
44
+ background-color: var(--mp__themeDark);
45
+ color: var(--mp__themeLight);
46
46
  border-radius: 100px;
47
47
  align-items: center;
48
48
  justify-content: flex-start;
@@ -60,8 +60,8 @@ html {
60
60
 
61
61
  >.message,
62
62
  .info {
63
- font-style: var(--italic);
64
- font-size: var(--textSize);
63
+ font-style: var(--mp__italic);
64
+ font-size: var(--mp__textSize);
65
65
 
66
66
  >* {
67
67
  opacity: 0;
@@ -69,23 +69,23 @@ html {
69
69
  }
70
70
 
71
71
  >.title {
72
- font-weight: var(--black);
73
- font-size: var(--titleSize);
72
+ font-weight: var(--mp__black);
73
+ font-size: var(--mp__titleSize);
74
74
  }
75
75
  }
76
76
 
77
77
  >.message {
78
78
  padding-left: 25px;
79
- border-left: 1px solid var(--themeLight);
80
- font-style: var(--italic);
79
+ border-left: 1px solid var(--mp__themeLight);
80
+ font-style: var(--mp__italic);
81
81
  font-size: 19.4px;
82
82
  min-width: max-content;
83
83
  }
84
84
 
85
85
  .CTA {
86
- font-family: var(--font-accent);
87
- font-size: var(--textSize);
88
- font-weight: var(--bold);
86
+ font-family: var(--mp__font-accent);
87
+ font-size: var(--mp__textSize);
88
+ font-weight: var(--mp__bold);
89
89
  display: flex;
90
90
  justify-content: flex-start;
91
91
  align-items: center;
@@ -94,8 +94,8 @@ html {
94
94
  max-width: 54.5px;
95
95
  min-width: 54.5px;
96
96
  overflow: hidden;
97
- background-color: var(--themeLight);
98
- color: var(--themeDark);
97
+ background-color: var(--mp__themeLight);
98
+ color: var(--mp__themeDark);
99
99
  text-decoration: none;
100
100
  border: transparent;
101
101
  border-radius: 100px;
@@ -112,8 +112,8 @@ html {
112
112
  >span {
113
113
  z-index: 1;
114
114
  min-width: max-content;
115
- font-family: var(--font-accent);
116
- color: var(--themeDark);
115
+ font-family: var(--mp__font-accent);
116
+ color: var(--mp__themeDark);
117
117
  text-decoration: none;
118
118
  }
119
119
  }
@@ -131,7 +131,7 @@ html {
131
131
  left: 0;
132
132
  width: 100%;
133
133
  height: 100%;
134
- background-color: var(--themeDark);
134
+ background-color: var(--mp__themeDark);
135
135
  border-radius: 40px;
136
136
  bottom: 0px;
137
137
  transition: height 250ms 250ms ease-in-out, bottom 250ms 250ms ease-in-out, border-radius 250ms 250ms ease-in-out;
@@ -157,9 +157,9 @@ html {
157
157
 
158
158
  >li.navbarItem {
159
159
  >a.CTA {
160
- font-family: var(--font-accent);
161
- font-size: var(--textSize);
162
- font-weight: var(--bold);
160
+ font-family: var(--mp__font-accent);
161
+ font-size: var(--mp__textSize);
162
+ font-weight: var(--mp__bold);
163
163
  display: flex;
164
164
  justify-content: flex-start;
165
165
  align-items: center;
@@ -168,8 +168,8 @@ html {
168
168
  max-width: 54.5px;
169
169
  min-width: 54.5px;
170
170
  overflow: hidden;
171
- background-color: var(--themeLight);
172
- color: var(--themeDark);
171
+ background-color: var(--mp__themeLight);
172
+ color: var(--mp__themeDark);
173
173
  text-decoration: none;
174
174
  border: transparent;
175
175
  border-radius: 100px;
@@ -186,8 +186,8 @@ html {
186
186
  >span {
187
187
  z-index: 1;
188
188
  min-width: max-content;
189
- font-family: var(--font-accent);
190
- color: var(--themeDark);
189
+ font-family: var(--mp__font-accent);
190
+ color: var(--mp__themeDark);
191
191
  text-decoration: none;
192
192
  }
193
193
  }
@@ -264,4 +264,52 @@ html {
264
264
  100% {
265
265
  scale: 1;
266
266
  }
267
- }
267
+ }
268
+
269
+ /* Reduced motion (Y2): no overshoot and no size or position animations,
270
+ only short fades. The timings in MagicPill.tsx don't change. */
271
+ @media (prefers-reduced-motion: reduce) {
272
+ html > body .magicPill,
273
+ html > body .magicPill * {
274
+ transition-duration: 1ms !important;
275
+ transition-delay: 0ms !important;
276
+ }
277
+
278
+ html > body .magicPill.entry {
279
+ animation: magicPillFadeIn 200ms ease-out forwards;
280
+ }
281
+
282
+ html > body .magicPill.out {
283
+ animation: magicPillFadeOut 200ms ease-in forwards;
284
+ }
285
+ }
286
+
287
+ @keyframes magicPillFadeIn {
288
+ 0% {
289
+ scale: 1;
290
+ opacity: 0;
291
+ }
292
+
293
+ 100% {
294
+ scale: 1;
295
+ opacity: 1;
296
+ }
297
+ }
298
+
299
+ /* Ends at scale 0, like the default exit, so the hidden pill doesn't block clicks */
300
+ @keyframes magicPillFadeOut {
301
+ 0% {
302
+ scale: 1;
303
+ opacity: 1;
304
+ }
305
+
306
+ 99% {
307
+ scale: 1;
308
+ opacity: 0;
309
+ }
310
+
311
+ 100% {
312
+ scale: 0;
313
+ opacity: 0;
314
+ }
315
+ }
@@ -1,3 +1,4 @@
1
- export type { MagicPillNavbar, MagicPillNavbarItem } from './navbar';
2
- export type { MagicPillNotification, MagicPillNotificationCTA, MagicPillNotificationInfo } from './notification';
3
- export type { MagicPillType, Mode, NotificationIcon, CTAIcon } from './magicPill';
1
+ import { MagicPillNavbar, MagicPillNavbarItem } from "./navbar.js";
2
+ import { MagicPillNotification, MagicPillNotificationCTA, MagicPillNotificationInfo } from "./notification.js";
3
+ import { CTAIcon, MagicPillType, Mode, NotificationIcon } from "./magicPill.js";
4
+ export type { CTAIcon, MagicPillNavbar, MagicPillNavbarItem, MagicPillNotification, MagicPillNotificationCTA, MagicPillNotificationInfo, MagicPillType, Mode, NotificationIcon };
@@ -0,0 +1,50 @@
1
+ import { MagicPillNotification } from "./notification.mjs";
2
+ import { MagicPillNavbar } from "./navbar.mjs";
3
+ export type Mode = "navbar" | "notification";
4
+ export type NotificationIcon = "info" | "checkmark" | "questionmark" | "coupon" | "";
5
+ export type CTAIcon = "arrow" | "box" | "checkmark" | "cross" | "info" | "mail" | "plus" | "quotation" | "tel" | "undo" | "";
6
+ /**
7
+ * Defines the structure of the Magic Pill component.
8
+ * Magic Pill can be used in two modes:
9
+ * 1. Navbar mode: Displays a navigation bar with multiple items.
10
+ * 2. Notification mode: Displays a notification with an optional call to action (CTA).
11
+ * Each mode has its own specific properties.
12
+ * @see {@link MagicPillNotification} for the structure of the notification.
13
+ * @see {@link MagicPillNavbar} for the structure of the navbar.
14
+ *
15
+ * @example
16
+ * ```json
17
+ * {
18
+ * mode: "navbar",
19
+ * navbar: [
20
+ * { icon: "home", label: "Home", link: "/home" },
21
+ * { icon: "settings", label: "Settings", link: "/settings" }
22
+ * ]
23
+ * }
24
+ * ```
25
+ * @example
26
+ * ```json
27
+ * {
28
+ * mode: "notification",
29
+ * notification: {
30
+ * icon: "info",
31
+ * message: "This is a notification",
32
+ * cta: { icon: "action", label: "Take Action", link: "/action" },
33
+ * info: {
34
+ * title: "Notification Title",
35
+ * content: "This is the content of the notification.",
36
+ * closeLabel: "Close"
37
+ * }
38
+ * }
39
+ * }
40
+ * ```
41
+ */
42
+ export type MagicPillType = {
43
+ mode: "navbar";
44
+ navbar: MagicPillNavbar;
45
+ notification?: never;
46
+ } | {
47
+ mode: "notification";
48
+ notification: MagicPillNotification;
49
+ navbar?: never;
50
+ };
@@ -1,5 +1,5 @@
1
- import type { MagicPillNotification } from "./notification";
2
- import type { MagicPillNavbar } from "./navbar";
1
+ import { MagicPillNotification } from "./notification.js";
2
+ import { MagicPillNavbar } from "./navbar.js";
3
3
  export type Mode = "navbar" | "notification";
4
4
  export type NotificationIcon = "info" | "checkmark" | "questionmark" | "coupon" | "";
5
5
  export type CTAIcon = "arrow" | "box" | "checkmark" | "cross" | "info" | "mail" | "plus" | "quotation" | "tel" | "undo" | "";
@@ -40,11 +40,11 @@ export type CTAIcon = "arrow" | "box" | "checkmark" | "cross" | "info" | "mail"
40
40
  * ```
41
41
  */
42
42
  export type MagicPillType = {
43
- mode: "navbar";
44
- navbar: MagicPillNavbar;
45
- notification?: never;
43
+ mode: "navbar";
44
+ navbar: MagicPillNavbar;
45
+ notification?: never;
46
46
  } | {
47
- mode: "notification";
48
- notification: MagicPillNotification;
49
- navbar?: never;
50
- };
47
+ mode: "notification";
48
+ notification: MagicPillNotification;
49
+ navbar?: never;
50
+ };
@@ -0,0 +1,27 @@
1
+ import { CTAIcon } from "./magicPill.mjs";
2
+ /**
3
+ * Defines the structure of a navigation item in the Magic Pill navbar.
4
+ * Each item has an icon, an optional label, and a link.
5
+ * @example
6
+ * ```ts
7
+ * {
8
+ * icon: "home",
9
+ * label: "Home",
10
+ * link: "/home"
11
+ * }
12
+ * ```
13
+ * @see {@link MagicPillNavbar} for the structure of the navbar that contains these items.
14
+ */
15
+ export interface MagicPillNavbarItem {
16
+ icon: CTAIcon;
17
+ label?: string;
18
+ link: string;
19
+ }
20
+ /**
21
+ * Defines the structure of the navbar in the Magic Pill component.
22
+ * It contains an array of navigation items.
23
+ * @see {@link MagicPillNavbarItem} for the structure of each item in the navbar.
24
+ */
25
+ export interface MagicPillNavbar {
26
+ navItems: MagicPillNavbarItem[];
27
+ }
@@ -1,4 +1,5 @@
1
- import { CTAIcon } from "./index";
1
+ import { CTAIcon } from "./magicPill.js";
2
+ import "./index.js";
2
3
  /**
3
4
  * Defines the structure of a navigation item in the Magic Pill navbar.
4
5
  * Each item has an icon, an optional label, and a link.
@@ -13,9 +14,9 @@ import { CTAIcon } from "./index";
13
14
  * @see {@link MagicPillNavbar} for the structure of the navbar that contains these items.
14
15
  */
15
16
  export interface MagicPillNavbarItem {
16
- icon: CTAIcon;
17
- label?: string;
18
- link: string;
17
+ icon: CTAIcon;
18
+ label?: string;
19
+ link: string;
19
20
  }
20
21
  /**
21
22
  * Defines the structure of the navbar in the Magic Pill component.
@@ -23,5 +24,5 @@ export interface MagicPillNavbarItem {
23
24
  * @see {@link MagicPillNavbarItem} for the structure of each item in the navbar.
24
25
  */
25
26
  export interface MagicPillNavbar {
26
- navItems: MagicPillNavbarItem[];
27
- }
27
+ navItems: MagicPillNavbarItem[];
28
+ }
@@ -0,0 +1,140 @@
1
+ import { CTAIcon, NotificationIcon } from "./magicPill.mjs";
2
+ /**
3
+ * Defines the structure of a call to action (CTA) in the Magic Pill notification.
4
+ * Each CTA has an icon, an optional label, and an optional link.
5
+ * @example
6
+ * ```ts
7
+ * {
8
+ * icon: "action",
9
+ * label: "Take Action",
10
+ * link: "/action"
11
+ * }
12
+ * ```
13
+ * @see {@link MagicPillNotification} for the structure of the notification that contains this CTA.
14
+ */
15
+ export interface MagicPillNotificationCTA {
16
+ icon: CTAIcon;
17
+ label?: string;
18
+ link?: string;
19
+ }
20
+ /**
21
+ * Defines the structure of additional information in the Magic Pill notification.
22
+ * This can include a title, content (which can contain HTML), and a close label.
23
+ * @example
24
+ * ```ts
25
+ * {
26
+ * title: "Notification Title",
27
+ * content: "This is the content of the notification.",
28
+ * closeLabel: "Close"
29
+ * }
30
+ * ```
31
+ * @see {@link MagicPillNotification} for the structure of the notification that contains this information.
32
+ * @see {@link MagicPillNotificationCTA} for the structure of the call to action in the notification.
33
+ */
34
+ export interface MagicPillNotificationInfo {
35
+ title?: string;
36
+ content: string;
37
+ closeLabel: string;
38
+ }
39
+ /**
40
+ * Defines the structure of a Magic Pill notification CTA with a link.
41
+ * @example
42
+ * ```ts
43
+ * {
44
+ * icon: "info",
45
+ * label: "Learn More",
46
+ * link: "/learn-more"
47
+ * }
48
+ * ```
49
+ * @see {@link MagicPillNotificationWithLink} for the whole notification structure that incorporates this very type..
50
+ */
51
+ interface MagicPillNotificationCTAWithLink {
52
+ icon: CTAIcon;
53
+ label?: string;
54
+ link: string;
55
+ }
56
+ /**
57
+ * Defines the structure of a Magic Pill notification CTA without a link.
58
+ * @example
59
+ * ```ts
60
+ * {
61
+ * icon: "info",
62
+ * label: "No Link Available"
63
+ * }
64
+ * ```
65
+ * @see {@link MagicPillNotificationWithoutLink} for the whole notification structure that incorporates this very type.
66
+ */
67
+ interface MagicPillNotificationCTAWithoutLink {
68
+ icon: CTAIcon;
69
+ label?: string;
70
+ link?: undefined;
71
+ }
72
+ /**
73
+ * Defines the base structure of a Magic Pill notification.
74
+ * It includes an optional icon and a mandatory message.
75
+ * @example
76
+ * ```ts
77
+ * {
78
+ * icon: "info",
79
+ * message: "This is a notification message."
80
+ * }
81
+ * ```
82
+ * @see {@link MagicPillNotificationWithLink} for notifications that include a CTA with a link.
83
+ * @see {@link MagicPillNotificationWithoutLink} for notifications that include a CTA without a link.
84
+ * @see {@link MagicPillNotificationWithoutCTA} for notifications that do not include a CTA.
85
+ */
86
+ interface MagicPillNotificationBase {
87
+ icon?: NotificationIcon;
88
+ message: string;
89
+ cta?: MagicPillNotificationCTA;
90
+ info?: MagicPillNotificationInfo;
91
+ }
92
+ /**
93
+ * Defines the structure of a Magic Pill notification with a CTA that includes a link.
94
+ * This type extends the base notification structure and includes a CTA with a mandatory link.
95
+ * @example
96
+ * ```ts
97
+ * {
98
+ * icon: "info",
99
+ * message: "This is a notification with a link.",
100
+ * cta: {
101
+ * icon: "action",
102
+ * label: "Take Action",
103
+ * link: "/action"
104
+ * }
105
+ * }
106
+ * ````
107
+ * @see {@link MagicPillNotificationBase} for the base structure of the notification.
108
+ * @see {@link MagicPillNotificationCTAWithLink} for the structure of the CTA with a link.
109
+ */
110
+ type MagicPillNotificationWithLink = MagicPillNotificationBase & {
111
+ cta: MagicPillNotificationCTAWithLink;
112
+ };
113
+ /**
114
+ * Defines the structure of a Magic Pill notification without a link in the CTA.
115
+ * This type extends the base notification structure and includes a CTA without a mandatory link.
116
+ * @example
117
+ * ```ts
118
+ * {
119
+ * icon: "info",
120
+ * message: "This is a notification without a link.",
121
+ * cta: {
122
+ * icon: "action",
123
+ * label: "No Link Available"
124
+ * },
125
+ * info: {
126
+ * title: "Notification Title",
127
+ * content: "This is the content of the notification.",
128
+ * closeLabel: "Close"
129
+ * }
130
+ * }
131
+ * ```
132
+ * @see {@link MagicPillNotificationBase} for the base structure of the notification.
133
+ * @see {@link MagicPillNotificationCTAWithoutLink} for the structure of the CTA without a link.
134
+ */
135
+ type MagicPillNotificationWithoutLink = MagicPillNotificationBase & {
136
+ cta: MagicPillNotificationCTAWithoutLink;
137
+ info: MagicPillNotificationInfo;
138
+ };
139
+ export type MagicPillNotification = MagicPillNotificationWithLink | MagicPillNotificationWithoutLink | MagicPillNotificationBase;
140
+ export {};
@@ -1,4 +1,5 @@
1
- import { NotificationIcon, CTAIcon } from "./index";
1
+ import { CTAIcon, NotificationIcon } from "./magicPill.js";
2
+ import "./index.js";
2
3
  /**
3
4
  * Defines the structure of a call to action (CTA) in the Magic Pill notification.
4
5
  * Each CTA has an icon, an optional label, and an optional link.
@@ -13,9 +14,9 @@ import { NotificationIcon, CTAIcon } from "./index";
13
14
  * @see {@link MagicPillNotification} for the structure of the notification that contains this CTA.
14
15
  */
15
16
  export interface MagicPillNotificationCTA {
16
- icon: CTAIcon;
17
- label?: string;
18
- link?: string;
17
+ icon: CTAIcon;
18
+ label?: string;
19
+ link?: string;
19
20
  }
20
21
  /**
21
22
  * Defines the structure of additional information in the Magic Pill notification.
@@ -32,9 +33,9 @@ export interface MagicPillNotificationCTA {
32
33
  * @see {@link MagicPillNotificationCTA} for the structure of the call to action in the notification.
33
34
  */
34
35
  export interface MagicPillNotificationInfo {
35
- title?: string;
36
- content: string;
37
- closeLabel: string;
36
+ title?: string;
37
+ content: string;
38
+ closeLabel: string;
38
39
  }
39
40
  /**
40
41
  * Defines the structure of a Magic Pill notification CTA with a link.
@@ -49,9 +50,9 @@ export interface MagicPillNotificationInfo {
49
50
  * @see {@link MagicPillNotificationWithLink} for the whole notification structure that incorporates this very type..
50
51
  */
51
52
  interface MagicPillNotificationCTAWithLink {
52
- icon: CTAIcon;
53
- label?: string;
54
- link: string;
53
+ icon: CTAIcon;
54
+ label?: string;
55
+ link: string;
55
56
  }
56
57
  /**
57
58
  * Defines the structure of a Magic Pill notification CTA without a link.
@@ -65,9 +66,9 @@ interface MagicPillNotificationCTAWithLink {
65
66
  * @see {@link MagicPillNotificationWithoutLink} for the whole notification structure that incorporates this very type.
66
67
  */
67
68
  interface MagicPillNotificationCTAWithoutLink {
68
- icon: CTAIcon;
69
- label?: string;
70
- link?: undefined;
69
+ icon: CTAIcon;
70
+ label?: string;
71
+ link?: undefined;
71
72
  }
72
73
  /**
73
74
  * Defines the base structure of a Magic Pill notification.
@@ -84,10 +85,10 @@ interface MagicPillNotificationCTAWithoutLink {
84
85
  * @see {@link MagicPillNotificationWithoutCTA} for notifications that do not include a CTA.
85
86
  */
86
87
  interface MagicPillNotificationBase {
87
- icon?: NotificationIcon;
88
- message: string;
89
- cta?: MagicPillNotificationCTA;
90
- info?: MagicPillNotificationInfo;
88
+ icon?: NotificationIcon;
89
+ message: string;
90
+ cta?: MagicPillNotificationCTA;
91
+ info?: MagicPillNotificationInfo;
91
92
  }
92
93
  /**
93
94
  * Defines the structure of a Magic Pill notification with a CTA that includes a link.
@@ -108,7 +109,7 @@ interface MagicPillNotificationBase {
108
109
  * @see {@link MagicPillNotificationCTAWithLink} for the structure of the CTA with a link.
109
110
  */
110
111
  type MagicPillNotificationWithLink = MagicPillNotificationBase & {
111
- cta: MagicPillNotificationCTAWithLink;
112
+ cta: MagicPillNotificationCTAWithLink;
112
113
  };
113
114
  /**
114
115
  * Defines the structure of a Magic Pill notification without a link in the CTA.
@@ -133,8 +134,8 @@ type MagicPillNotificationWithLink = MagicPillNotificationBase & {
133
134
  * @see {@link MagicPillNotificationCTAWithoutLink} for the structure of the CTA without a link.
134
135
  */
135
136
  type MagicPillNotificationWithoutLink = MagicPillNotificationBase & {
136
- cta: MagicPillNotificationCTAWithoutLink;
137
- info: MagicPillNotificationInfo;
137
+ cta: MagicPillNotificationCTAWithoutLink;
138
+ info: MagicPillNotificationInfo;
138
139
  };
139
140
  export type MagicPillNotification = MagicPillNotificationWithLink | MagicPillNotificationWithoutLink | MagicPillNotificationBase;
140
- export {};
141
+ export {};
@@ -0,0 +1,20 @@
1
+ import { CTAIcon, MagicPillType, Mode, NotificationIcon } from "../types/magicPill.mjs";
2
+ import { MagicPillNavbarItem } from "../types/navbar.mjs";
3
+ import { Dispatch, SetStateAction } from "react";
4
+ type SetPillData = Dispatch<SetStateAction<MagicPillType>>;
5
+ export declare const updateMode: (mode: Mode, setPillData: SetPillData) => void;
6
+ export declare const updateNotificationIcon: (icon: NotificationIcon, setPillData: SetPillData) => void;
7
+ export declare const updateNotificationMessage: (message: string, setPillData: SetPillData) => void;
8
+ export declare const updateCTAIcon: (icon: CTAIcon, setPillData: SetPillData) => void;
9
+ export declare const updateCTALabel: (label: string, setPillData: SetPillData) => void;
10
+ export declare const updateCTALink: (link: string, setPillData: SetPillData) => void;
11
+ export declare const updateInfoTitle: (title: string, setPillData: SetPillData) => void;
12
+ export declare const updateInfoContent: (content: string, setPillData: SetPillData) => void;
13
+ export declare const updateInfoCloseLabel: (closeLabel: string, setPillData: SetPillData) => void;
14
+ export declare const updateNavItemLabel: (label: string, index: number, setPillData: SetPillData) => void;
15
+ export declare const updateNavItemLink: (link: string, index: number, setPillData: SetPillData) => void;
16
+ export declare const updateNavItemIcon: (icon: CTAIcon, index: number, setPillData: SetPillData) => void;
17
+ export declare const handleActiveNavItem: (path: string, navItems: MagicPillNavbarItem[]) => string;
18
+ export declare const addNavItem: (navItem: MagicPillNavbarItem, setPillData: SetPillData) => void;
19
+ export declare const deleteNavItem: (index: number, setPillData: SetPillData) => void;
20
+ export {};
@@ -1,5 +1,7 @@
1
- import { CTAIcon, MagicPillNavbarItem, MagicPillType, Mode, NotificationIcon } from '../types';
2
- import { SetStateAction, Dispatch } from 'react';
1
+ import { MagicPillNavbarItem } from "../types/navbar.js";
2
+ import { CTAIcon, MagicPillType, Mode, NotificationIcon } from "../types/magicPill.js";
3
+ import "../types/index.js";
4
+ import { Dispatch, SetStateAction } from "react";
3
5
  type SetPillData = Dispatch<SetStateAction<MagicPillType>>;
4
6
  export declare const updateMode: (mode: Mode, setPillData: SetPillData) => void;
5
7
  export declare const updateNotificationIcon: (icon: NotificationIcon, setPillData: SetPillData) => void;
@@ -16,4 +18,4 @@ export declare const updateNavItemIcon: (icon: CTAIcon, index: number, setPillDa
16
18
  export declare const handleActiveNavItem: (path: string, navItems: MagicPillNavbarItem[]) => string;
17
19
  export declare const addNavItem: (navItem: MagicPillNavbarItem, setPillData: SetPillData) => void;
18
20
  export declare const deleteNavItem: (index: number, setPillData: SetPillData) => void;
19
- export {};
21
+ export {};
@@ -0,0 +1,2 @@
1
+ const e=require("../defaultPillData.js"),t=(e,t)=>{t(()=>e===`navbar`?{mode:`navbar`,navbar:{navItems:[]}}:{mode:`notification`,notification:{icon:``,message:``}})},n=(e,t)=>{t(t=>t.mode===`notification`?{...t,notification:{...t.notification,icon:e}}:t)},r=(e,t)=>{t(t=>t.mode===`notification`?{...t,notification:{...t.notification,message:e}}:t)},i=(t,n)=>{n(n=>n.mode===`notification`?{...n,notification:{...n.notification,cta:{...n.notification?.cta,icon:t||e.defaultPillData.notification?.cta?.icon||`arrow`}}}:n)},a=(t,n)=>{n(n=>n.mode===`notification`?{...n,notification:{...n.notification,cta:{...n.notification?.cta,icon:n.notification?.cta?.icon||e.defaultPillData.notification?.cta?.icon||`arrow`,label:t}}}:n)},o=(t,n)=>{n(n=>n.mode===`notification`?{...n,notification:{...n.notification,cta:{...n.notification?.cta,icon:n.notification?.cta?.icon||e.defaultPillData.notification?.cta?.icon||`arrow`,link:t},info:void 0}}:n)},s=(t,n)=>{n(n=>n.mode===`notification`?{...n,notification:{...n.notification,cta:{...n.notification?.cta,icon:n.notification?.cta?.icon||e.defaultPillData.notification?.cta?.icon||`arrow`,link:void 0},info:{...n.notification?.info,title:t,content:n.notification?.info?.content||``,closeLabel:n.notification?.info?.closeLabel||``}}}:n)},c=(t,n)=>{n(n=>n.mode===`notification`?{...n,notification:{...n.notification,cta:{...n.notification?.cta,icon:n.notification?.cta?.icon||e.defaultPillData.notification?.cta?.icon||`arrow`,link:void 0},info:{...n.notification?.info,title:n.notification?.info?.title||``,content:t,closeLabel:n.notification?.info?.closeLabel||``}}}:n)},l=(t,n)=>{n(n=>n.mode===`notification`?{...n,notification:{...n.notification,cta:{...n.notification?.cta,icon:n.notification?.cta?.icon||e.defaultPillData.notification?.cta?.icon||`arrow`,link:void 0},info:{...n.notification?.info,title:n.notification?.info?.title||``,content:n.notification?.info?.content||``,closeLabel:t}}}:n)},u=(e,t,n)=>{n(n=>{if(n.mode!==`navbar`)return n;let r=[...n.navbar.navItems];return r[t]={...r[t],label:e},{...n,navbar:{...n.navbar,navItems:r}}})},d=(e,t,n)=>{n(n=>{if(n.mode!==`navbar`)return n;let r=[...n.navbar.navItems];return r[t]={...r[t],link:e},{...n,navbar:{...n.navbar,navItems:r}}})},f=(e,t,n)=>{n(n=>{if(n.mode!==`navbar`)return n;let r=[...n.navbar.navItems];return r[t]={...r[t],icon:e},{...n,navbar:{...n.navbar,navItems:r}}})},p=(e,t)=>t&&[...t].sort((e,t)=>(t.link?.length||0)-(e.link?.length||0)).find(t=>t.link&&e.includes(t.link))?.label||``,m=(e,t)=>{t(t=>t.mode===`navbar`?{...t,navbar:{...t.navbar,navItems:[...t.navbar.navItems,e]}}:t)},h=(e,t)=>{t(t=>{if(t.mode!==`navbar`)return t;let n=[...t.navbar.navItems];return n.splice(e,1),{...t,navbar:{...t.navbar,navItems:n}}})};exports.addNavItem=m,exports.deleteNavItem=h,exports.handleActiveNavItem=p,exports.updateCTAIcon=i,exports.updateCTALabel=a,exports.updateCTALink=o,exports.updateInfoCloseLabel=l,exports.updateInfoContent=c,exports.updateInfoTitle=s,exports.updateMode=t,exports.updateNavItemIcon=f,exports.updateNavItemLabel=u,exports.updateNavItemLink=d,exports.updateNotificationIcon=n,exports.updateNotificationMessage=r;
2
+ //# sourceMappingURL=handlers.js.map