@cerberus-design/react 0.11.1 → 0.12.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 (162) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +244 -33
  2. package/build/legacy/components/Admonition.cjs +1 -1
  3. package/build/legacy/components/Admonition.cjs.map +1 -1
  4. package/build/legacy/components/Avatar.cjs +1 -1
  5. package/build/legacy/components/Avatar.cjs.map +1 -1
  6. package/build/legacy/components/Checkbox.cjs +1 -1
  7. package/build/legacy/components/Checkbox.cjs.map +1 -1
  8. package/build/legacy/components/FileStatus.cjs +1 -1
  9. package/build/legacy/components/FileStatus.cjs.map +1 -1
  10. package/build/legacy/components/FileUploader.cjs +1 -1
  11. package/build/legacy/components/FileUploader.cjs.map +1 -1
  12. package/build/legacy/components/Input.cjs +1 -1
  13. package/build/legacy/components/Input.cjs.map +1 -1
  14. package/build/legacy/components/Menu.cjs +82 -0
  15. package/build/legacy/components/Menu.cjs.map +1 -0
  16. package/build/legacy/components/ModalHeader.cjs +2 -1
  17. package/build/legacy/components/ModalHeader.cjs.map +1 -1
  18. package/build/legacy/components/NavMenuLink.cjs.map +1 -1
  19. package/build/legacy/components/NavMenuList.cjs.map +1 -1
  20. package/build/legacy/components/NavMenuTrigger.cjs.map +1 -1
  21. package/build/legacy/components/Notification.cjs +3 -3
  22. package/build/legacy/components/Notification.cjs.map +1 -1
  23. package/build/legacy/components/Select.cjs +1 -1
  24. package/build/legacy/components/Select.cjs.map +1 -1
  25. package/build/legacy/components/Tag.cjs +3 -3
  26. package/build/legacy/components/Tag.cjs.map +1 -1
  27. package/build/legacy/components/Tbody.cjs.map +1 -1
  28. package/build/legacy/components/Td.cjs.map +1 -1
  29. package/build/legacy/components/Th.cjs +1 -0
  30. package/build/legacy/components/Th.cjs.map +1 -1
  31. package/build/legacy/components/Thead.cjs.map +1 -1
  32. package/build/legacy/components/Toggle.cjs +1 -1
  33. package/build/legacy/components/Toggle.cjs.map +1 -1
  34. package/build/legacy/config/cerbIcons.cjs +1 -1
  35. package/build/legacy/config/cerbIcons.cjs.map +1 -1
  36. package/build/legacy/config/defineIcons.cjs +1 -1
  37. package/build/legacy/config/defineIcons.cjs.map +1 -1
  38. package/build/legacy/context/confirm-modal.cjs +3 -2
  39. package/build/legacy/context/confirm-modal.cjs.map +1 -1
  40. package/build/legacy/context/cta-modal.cjs +567 -0
  41. package/build/legacy/context/cta-modal.cjs.map +1 -0
  42. package/build/legacy/context/navMenu.cjs.map +1 -1
  43. package/build/legacy/context/notification-center.cjs +3 -3
  44. package/build/legacy/context/notification-center.cjs.map +1 -1
  45. package/build/legacy/context/prompt-modal.cjs +3 -2
  46. package/build/legacy/context/prompt-modal.cjs.map +1 -1
  47. package/build/legacy/index.cjs +501 -324
  48. package/build/legacy/index.cjs.map +1 -1
  49. package/build/legacy/utils/index.cjs +34 -0
  50. package/build/legacy/utils/index.cjs.map +1 -0
  51. package/build/modern/_tsup-dts-rollup.d.ts +244 -33
  52. package/build/modern/{chunk-HPM2XRWT.js → chunk-3R4TIF2X.js} +1 -1
  53. package/build/modern/{chunk-HPM2XRWT.js.map → chunk-3R4TIF2X.js.map} +1 -1
  54. package/build/modern/{chunk-RDQHHCFR.js → chunk-5OSUZUR4.js} +2 -2
  55. package/build/modern/{chunk-O75QAT4Z.js → chunk-6WS765J3.js} +1 -1
  56. package/build/modern/chunk-6WS765J3.js.map +1 -0
  57. package/build/modern/{chunk-KLUBAM4U.js → chunk-7SGPJM66.js} +4 -4
  58. package/build/modern/chunk-7SGPJM66.js.map +1 -0
  59. package/build/modern/{chunk-X4Y4WTRU.js → chunk-CSEHDNMJ.js} +7 -7
  60. package/build/modern/{chunk-TMR7JGMP.js → chunk-F27AAKQ3.js} +3 -3
  61. package/build/modern/chunk-F27AAKQ3.js.map +1 -0
  62. package/build/modern/{chunk-243VUIA6.js → chunk-F72ZABKX.js} +2 -2
  63. package/build/modern/chunk-F72ZABKX.js.map +1 -0
  64. package/build/modern/{chunk-KF6V5JLW.js → chunk-N4QTLDVM.js} +3 -3
  65. package/build/modern/{chunk-MDIUFBDX.js → chunk-NB6DV4VA.js} +2 -2
  66. package/build/modern/{chunk-UJKS4DDN.js → chunk-NKM6PISB.js} +2 -2
  67. package/build/modern/{chunk-YWCTMLLO.js → chunk-NMNONSHU.js} +2 -2
  68. package/build/modern/{chunk-OWKN5IV7.js → chunk-PM7CWT3N.js} +2 -2
  69. package/build/modern/chunk-PM7CWT3N.js.map +1 -0
  70. package/build/modern/chunk-RUR5MV54.js +52 -0
  71. package/build/modern/chunk-RUR5MV54.js.map +1 -0
  72. package/build/modern/{chunk-CO4BKT7K.js → chunk-SGKHA4EB.js} +1 -1
  73. package/build/modern/chunk-SGKHA4EB.js.map +1 -0
  74. package/build/modern/{chunk-ZX6DBC2Z.js → chunk-SPZYPRZ6.js} +2 -2
  75. package/build/modern/chunk-T6LS5P5W.js +155 -0
  76. package/build/modern/chunk-T6LS5P5W.js.map +1 -0
  77. package/build/modern/chunk-UTGEFJ3L.js +10 -0
  78. package/build/modern/chunk-UTGEFJ3L.js.map +1 -0
  79. package/build/modern/{chunk-5V5MBSM3.js → chunk-UZVQ4INR.js} +2 -2
  80. package/build/modern/chunk-UZVQ4INR.js.map +1 -0
  81. package/build/modern/{chunk-FT7DFRHQ.js → chunk-VERRHMW4.js} +2 -2
  82. package/build/modern/{chunk-3NE6C66J.js → chunk-VP5ERLAY.js} +8 -8
  83. package/build/modern/{chunk-HCB5NQ5J.js → chunk-W4DXACNV.js} +3 -3
  84. package/build/modern/{chunk-KBBASJIY.js → chunk-WPVDQRRF.js} +1 -1
  85. package/build/modern/chunk-WPVDQRRF.js.map +1 -0
  86. package/build/modern/{chunk-PA5EB7EO.js → chunk-XL4JREDT.js} +2 -2
  87. package/build/modern/{chunk-PKY46RRA.js → chunk-Y6QQCRQV.js} +1 -1
  88. package/build/modern/{chunk-PKY46RRA.js.map → chunk-Y6QQCRQV.js.map} +1 -1
  89. package/build/modern/{chunk-YMJMB6OP.js → chunk-ZBMA5G54.js} +6 -6
  90. package/build/modern/{chunk-ULYQLKWA.js → chunk-ZFAIE47A.js} +3 -2
  91. package/build/modern/{chunk-ULYQLKWA.js.map → chunk-ZFAIE47A.js.map} +1 -1
  92. package/build/modern/{chunk-PKQTTFWA.js → chunk-ZR37P4NZ.js} +1 -1
  93. package/build/modern/{chunk-PKQTTFWA.js.map → chunk-ZR37P4NZ.js.map} +1 -1
  94. package/build/modern/components/Admonition.js +4 -4
  95. package/build/modern/components/Avatar.js +3 -3
  96. package/build/modern/components/Checkbox.js +3 -3
  97. package/build/modern/components/FileStatus.js +5 -5
  98. package/build/modern/components/FileUploader.js +4 -4
  99. package/build/modern/components/Input.js +3 -3
  100. package/build/modern/components/Menu.js +19 -0
  101. package/build/modern/components/Menu.js.map +1 -0
  102. package/build/modern/components/ModalHeader.js +1 -1
  103. package/build/modern/components/NavMenuLink.js +1 -1
  104. package/build/modern/components/NavMenuList.js +2 -2
  105. package/build/modern/components/NavMenuTrigger.js +2 -2
  106. package/build/modern/components/Notification.js +3 -3
  107. package/build/modern/components/Select.js +3 -3
  108. package/build/modern/components/Tag.js +3 -3
  109. package/build/modern/components/Tbody.js +1 -1
  110. package/build/modern/components/Td.js +1 -1
  111. package/build/modern/components/Th.js +2 -1
  112. package/build/modern/components/Thead.js +1 -1
  113. package/build/modern/components/Toggle.js +3 -3
  114. package/build/modern/config/cerbIcons.js +1 -1
  115. package/build/modern/config/defineIcons.js +2 -2
  116. package/build/modern/context/confirm-modal.js +6 -6
  117. package/build/modern/context/cta-modal.js +25 -0
  118. package/build/modern/context/cta-modal.js.map +1 -0
  119. package/build/modern/context/navMenu.js +1 -1
  120. package/build/modern/context/notification-center.js +4 -4
  121. package/build/modern/context/prompt-modal.js +7 -7
  122. package/build/modern/index.js +72 -46
  123. package/build/modern/index.js.map +1 -1
  124. package/build/modern/utils/index.js +7 -0
  125. package/build/modern/utils/index.js.map +1 -0
  126. package/package.json +3 -2
  127. package/src/components/Menu.tsx +244 -0
  128. package/src/components/ModalHeader.tsx +1 -0
  129. package/src/components/NavMenuLink.tsx +1 -11
  130. package/src/components/NavMenuList.tsx +1 -3
  131. package/src/components/NavMenuTrigger.tsx +1 -10
  132. package/src/components/Notification.tsx +2 -2
  133. package/src/components/Tag.tsx +8 -4
  134. package/src/components/Tbody.tsx +1 -2
  135. package/src/components/Td.tsx +1 -2
  136. package/src/components/Th.tsx +4 -2
  137. package/src/components/Thead.tsx +1 -2
  138. package/src/config/cerbIcons.ts +2 -2
  139. package/src/context/cta-modal.tsx +210 -0
  140. package/src/context/navMenu.tsx +1 -2
  141. package/src/index.ts +3 -0
  142. package/src/utils/index.ts +19 -0
  143. package/build/modern/chunk-243VUIA6.js.map +0 -1
  144. package/build/modern/chunk-5V5MBSM3.js.map +0 -1
  145. package/build/modern/chunk-CO4BKT7K.js.map +0 -1
  146. package/build/modern/chunk-KBBASJIY.js.map +0 -1
  147. package/build/modern/chunk-KLUBAM4U.js.map +0 -1
  148. package/build/modern/chunk-O75QAT4Z.js.map +0 -1
  149. package/build/modern/chunk-OWKN5IV7.js.map +0 -1
  150. package/build/modern/chunk-TMR7JGMP.js.map +0 -1
  151. /package/build/modern/{chunk-RDQHHCFR.js.map → chunk-5OSUZUR4.js.map} +0 -0
  152. /package/build/modern/{chunk-X4Y4WTRU.js.map → chunk-CSEHDNMJ.js.map} +0 -0
  153. /package/build/modern/{chunk-KF6V5JLW.js.map → chunk-N4QTLDVM.js.map} +0 -0
  154. /package/build/modern/{chunk-MDIUFBDX.js.map → chunk-NB6DV4VA.js.map} +0 -0
  155. /package/build/modern/{chunk-UJKS4DDN.js.map → chunk-NKM6PISB.js.map} +0 -0
  156. /package/build/modern/{chunk-YWCTMLLO.js.map → chunk-NMNONSHU.js.map} +0 -0
  157. /package/build/modern/{chunk-ZX6DBC2Z.js.map → chunk-SPZYPRZ6.js.map} +0 -0
  158. /package/build/modern/{chunk-FT7DFRHQ.js.map → chunk-VERRHMW4.js.map} +0 -0
  159. /package/build/modern/{chunk-3NE6C66J.js.map → chunk-VP5ERLAY.js.map} +0 -0
  160. /package/build/modern/{chunk-HCB5NQ5J.js.map → chunk-W4DXACNV.js.map} +0 -0
  161. /package/build/modern/{chunk-PA5EB7EO.js.map → chunk-XL4JREDT.js.map} +0 -0
  162. /package/build/modern/{chunk-YMJMB6OP.js.map → chunk-ZBMA5G54.js.map} +0 -0
@@ -0,0 +1,567 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/context/cta-modal.tsx
22
+ var cta_modal_exports = {};
23
+ __export(cta_modal_exports, {
24
+ CTAModal: () => CTAModal,
25
+ useCTAModal: () => useCTAModal
26
+ });
27
+ module.exports = __toCommonJS(cta_modal_exports);
28
+ var import_react4 = require("react");
29
+
30
+ // src/components/Portal.tsx
31
+ var import_react_dom = require("react-dom");
32
+ function Portal(props) {
33
+ if (typeof window !== "undefined") {
34
+ const container = props.container || document.body;
35
+ return (0, import_react_dom.createPortal)(props.children, container, props.key);
36
+ }
37
+ return null;
38
+ }
39
+
40
+ // src/components/Button.tsx
41
+ var import_css = require("@cerberus/styled-system/css");
42
+ var import_recipes = require("@cerberus/styled-system/recipes");
43
+ var import_jsx_runtime = require("react/jsx-runtime");
44
+ function Button(props) {
45
+ const { palette, usage, shape, ...nativeProps } = props;
46
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
47
+ "button",
48
+ {
49
+ ...nativeProps,
50
+ className: (0, import_css.cx)(
51
+ nativeProps.className,
52
+ (0, import_recipes.button)({
53
+ palette,
54
+ usage,
55
+ shape
56
+ })
57
+ )
58
+ }
59
+ );
60
+ }
61
+
62
+ // src/config/cerbIcons.ts
63
+ var import_icons = require("@cerberus/icons");
64
+
65
+ // src/config/icons/checkbox.icons.tsx
66
+ var import_jsx_runtime2 = require("react/jsx-runtime");
67
+ function CheckmarkIcon(props) {
68
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
69
+ "svg",
70
+ {
71
+ "aria-hidden": "true",
72
+ xmlns: "http://www.w3.org/2000/svg",
73
+ fill: "none",
74
+ role: "img",
75
+ viewBox: "0 0 24 24",
76
+ ...props,
77
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
78
+ "path",
79
+ {
80
+ fill: "currentColor",
81
+ d: "M9.714 18 4 12.335l1.818-1.764 3.896 3.824L18.181 6 20 7.803 9.714 18Z"
82
+ }
83
+ )
84
+ }
85
+ );
86
+ }
87
+ function IndeterminateIcon(props) {
88
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
89
+ "svg",
90
+ {
91
+ "aria-hidden": "true",
92
+ xmlns: "http://www.w3.org/2000/svg",
93
+ role: "img",
94
+ fill: "none",
95
+ viewBox: "0 0 24 24",
96
+ ...props,
97
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { fill: "currentColor", d: "M4 11h16v2.667H4z" })
98
+ }
99
+ );
100
+ }
101
+
102
+ // src/components/AnimatingUploadIcon.tsx
103
+ var import_jsx_runtime3 = require("react/jsx-runtime");
104
+ function AnimatingUploadIcon(props) {
105
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
106
+ "svg",
107
+ {
108
+ "aria-hidden": "true",
109
+ xmlns: "http://www.w3.org/2000/svg",
110
+ width: props.size ?? "1em",
111
+ height: props.size ?? "1em",
112
+ viewBox: "0 0 24 24",
113
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
114
+ "g",
115
+ {
116
+ fill: "none",
117
+ stroke: "currentColor",
118
+ strokeLinecap: "square",
119
+ strokeLinejoin: "round",
120
+ strokeWidth: 1.5,
121
+ children: [
122
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
123
+ "path",
124
+ {
125
+ "data-name": "animating-trail",
126
+ strokeDasharray: "2 4",
127
+ strokeDashoffset: 6,
128
+ d: "M12 21c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9",
129
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
130
+ "animate",
131
+ {
132
+ attributeName: "stroke-dashoffset",
133
+ dur: "0.45s",
134
+ repeatCount: "indefinite",
135
+ values: "6;0"
136
+ }
137
+ )
138
+ }
139
+ ),
140
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
141
+ "path",
142
+ {
143
+ "data-name": "half-circle",
144
+ strokeDasharray: 32,
145
+ strokeDashoffset: 32,
146
+ d: "M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9",
147
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
148
+ "animate",
149
+ {
150
+ fill: "freeze",
151
+ attributeName: "stroke-dashoffset",
152
+ begin: "0.075s",
153
+ dur: "0.3s",
154
+ values: "32;0"
155
+ }
156
+ )
157
+ }
158
+ ),
159
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
160
+ "svg",
161
+ {
162
+ "aria-hidden": "true",
163
+ xmlns: "http://www.w3.org/2000/svg",
164
+ width: "0.8em",
165
+ height: "0.8em",
166
+ x: "27%",
167
+ y: "27%",
168
+ viewBox: "0 0 24 24",
169
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
170
+ "polygon",
171
+ {
172
+ fill: "currentColor",
173
+ stroke: "currentColor",
174
+ strokeWidth: 0.8,
175
+ opacity: "1",
176
+ points: "3.7,6.7 7.5,2.9 7.5,15 8.5,15 8.5,2.9 12.3,6.7 13,6 8,1 3,6 ",
177
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
178
+ "animate",
179
+ {
180
+ fill: "freeze",
181
+ attributeName: "opacity",
182
+ values: "1;0;1",
183
+ dur: "2s",
184
+ repeatCount: "indefinite"
185
+ }
186
+ )
187
+ }
188
+ )
189
+ }
190
+ )
191
+ ]
192
+ }
193
+ )
194
+ }
195
+ );
196
+ }
197
+
198
+ // src/config/cerbIcons.ts
199
+ var defaultIcons = {
200
+ avatar: import_icons.UserFilled,
201
+ checkbox: CheckmarkIcon,
202
+ close: import_icons.Close,
203
+ confirmModal: import_icons.Information,
204
+ delete: import_icons.TrashCan,
205
+ promptModal: import_icons.Information,
206
+ waitingFileUploader: import_icons.CloudUpload,
207
+ fileUploader: AnimatingUploadIcon,
208
+ indeterminate: IndeterminateIcon,
209
+ infoNotification: import_icons.Information,
210
+ successNotification: import_icons.CheckmarkOutline,
211
+ warningNotification: import_icons.WarningAlt,
212
+ dangerNotification: import_icons.WarningFilled,
213
+ invalid: import_icons.WarningFilled,
214
+ invalidAlt: import_icons.Warning,
215
+ redo: import_icons.Restart,
216
+ selectArrow: import_icons.ChevronDown,
217
+ toggleChecked: import_icons.Checkmark
218
+ };
219
+
220
+ // src/config/defineIcons.ts
221
+ var $cerberusIcons = defaultIcons;
222
+
223
+ // src/aria-helpers/trap-focus.aria.ts
224
+ function trapFocus(modalRef) {
225
+ var _a;
226
+ const focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
227
+ const focusable = Array.from(
228
+ ((_a = modalRef.current) == null ? void 0 : _a.querySelectorAll(focusableElements)) ?? []
229
+ );
230
+ const firstFocusable = focusable[0];
231
+ const lastFocusable = focusable[focusable.length - 1];
232
+ return function handleKeyDown(event) {
233
+ if (event.key === "Tab") {
234
+ if (event.shiftKey) {
235
+ if (document.activeElement === firstFocusable) {
236
+ lastFocusable.focus();
237
+ event.preventDefault();
238
+ }
239
+ } else {
240
+ if (document.activeElement === lastFocusable) {
241
+ firstFocusable.focus();
242
+ event.preventDefault();
243
+ }
244
+ }
245
+ }
246
+ };
247
+ }
248
+
249
+ // src/components/Show.tsx
250
+ var import_react = require("react");
251
+ function Show(props) {
252
+ const { when, children, fallback } = props;
253
+ const condition = (0, import_react.useMemo)(() => when ?? false, [when]);
254
+ return (0, import_react.useMemo)(() => {
255
+ if (condition) return children;
256
+ return fallback ?? null;
257
+ }, [condition, children, fallback]);
258
+ }
259
+
260
+ // src/components/Modal.tsx
261
+ var import_css2 = require("@cerberus/styled-system/css");
262
+ var import_recipes2 = require("@cerberus/styled-system/recipes");
263
+ var import_react2 = require("react");
264
+ var import_jsx_runtime4 = require("react/jsx-runtime");
265
+ function ModalEl(props, ref) {
266
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
267
+ "dialog",
268
+ {
269
+ ...props,
270
+ className: (0, import_css2.cx)(props.className, (0, import_recipes2.modal)().dialog),
271
+ ref
272
+ }
273
+ );
274
+ }
275
+ var Modal = (0, import_react2.forwardRef)(ModalEl);
276
+
277
+ // src/hooks/useModal.ts
278
+ var import_react3 = require("react");
279
+ function useModal() {
280
+ const modalRef = (0, import_react3.useRef)(null);
281
+ const [isOpen, setIsOpen] = (0, import_react3.useState)(false);
282
+ const show = (0, import_react3.useCallback)(() => {
283
+ var _a;
284
+ (_a = modalRef.current) == null ? void 0 : _a.showModal();
285
+ setIsOpen(true);
286
+ }, []);
287
+ const close = (0, import_react3.useCallback)(() => {
288
+ var _a;
289
+ (_a = modalRef.current) == null ? void 0 : _a.close();
290
+ setIsOpen(false);
291
+ }, []);
292
+ return (0, import_react3.useMemo)(() => {
293
+ return {
294
+ modalRef,
295
+ show,
296
+ close,
297
+ isOpen
298
+ };
299
+ }, [modalRef, show, close, isOpen]);
300
+ }
301
+
302
+ // src/components/ModalHeader.tsx
303
+ var import_css3 = require("@cerberus/styled-system/css");
304
+ var import_patterns = require("@cerberus/styled-system/patterns");
305
+ var import_jsx_runtime5 = require("react/jsx-runtime");
306
+ function ModalHeader(props) {
307
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
308
+ "div",
309
+ {
310
+ ...props,
311
+ className: (0, import_css3.cx)(
312
+ props.className,
313
+ (0, import_patterns.vstack)({
314
+ alignItems: "flex-start",
315
+ gap: "md",
316
+ mb: "md",
317
+ position: "relative"
318
+ })
319
+ )
320
+ }
321
+ );
322
+ }
323
+
324
+ // src/components/ModalHeading.tsx
325
+ var import_css4 = require("@cerberus/styled-system/css");
326
+ var import_recipes3 = require("@cerberus/styled-system/recipes");
327
+ var import_jsx_runtime6 = require("react/jsx-runtime");
328
+ function ModalHeading(props) {
329
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { ...props, className: (0, import_css4.cx)(props.className, (0, import_recipes3.modal)().heading) });
330
+ }
331
+
332
+ // src/components/ModalDescription.tsx
333
+ var import_css5 = require("@cerberus/styled-system/css");
334
+ var import_recipes4 = require("@cerberus/styled-system/recipes");
335
+ var import_jsx_runtime7 = require("react/jsx-runtime");
336
+ function ModalDescription(props) {
337
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { ...props, className: (0, import_css5.cx)(props.className, (0, import_recipes4.modal)().description) });
338
+ }
339
+
340
+ // src/components/Avatar.tsx
341
+ var import_css6 = require("@cerberus/styled-system/css");
342
+ var import_patterns2 = require("@cerberus/styled-system/patterns");
343
+ var import_recipes5 = require("@cerberus/styled-system/recipes");
344
+ var import_jsx_runtime8 = require("react/jsx-runtime");
345
+ function Avatar(props) {
346
+ const {
347
+ ariaLabel,
348
+ as,
349
+ gradient,
350
+ size,
351
+ src,
352
+ width,
353
+ height,
354
+ icon,
355
+ ...nativeProps
356
+ } = props;
357
+ const { avatar: AvatarIcon } = $cerberusIcons;
358
+ const initials = (ariaLabel || "").split(" ").map((word) => word[0]).join("").slice(0, 2);
359
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
360
+ "div",
361
+ {
362
+ ...nativeProps,
363
+ className: (0, import_css6.cx)(
364
+ nativeProps.className,
365
+ (0, import_recipes5.avatar)({ gradient, size }),
366
+ (0, import_patterns2.circle)()
367
+ ),
368
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
369
+ Show,
370
+ {
371
+ when: Boolean(src) || Boolean(as),
372
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
373
+ Show,
374
+ {
375
+ when: Boolean(initials),
376
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
377
+ Show,
378
+ {
379
+ when: Boolean(icon),
380
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
381
+ AvatarIcon,
382
+ {
383
+ size: iconSizeMap[size]
384
+ }
385
+ ),
386
+ children: icon
387
+ }
388
+ ),
389
+ children: initials
390
+ }
391
+ ),
392
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
393
+ Show,
394
+ {
395
+ when: Boolean(as),
396
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
397
+ "img",
398
+ {
399
+ alt: props.ariaLabel,
400
+ className: (0, import_css6.css)({
401
+ h: "full",
402
+ objectFit: "cover",
403
+ w: "full"
404
+ }),
405
+ decoding: "async",
406
+ loading: "lazy",
407
+ src,
408
+ height,
409
+ width
410
+ }
411
+ ),
412
+ children: as
413
+ }
414
+ )
415
+ }
416
+ )
417
+ }
418
+ );
419
+ }
420
+ var iconSizeMap = {
421
+ xs: 16,
422
+ sm: 16,
423
+ md: 20,
424
+ lg: 34,
425
+ xl: 32,
426
+ "2xl": 32,
427
+ "3xl": 32,
428
+ "4xl": 32
429
+ };
430
+
431
+ // src/context/cta-modal.tsx
432
+ var import_jsx = require("@cerberus/styled-system/jsx");
433
+
434
+ // src/components/IconButton.tsx
435
+ var import_css7 = require("@cerberus/styled-system/css");
436
+ var import_recipes6 = require("@cerberus/styled-system/recipes");
437
+ var import_jsx_runtime9 = require("react/jsx-runtime");
438
+ function IconButton(props) {
439
+ const { ariaLabel, palette, usage, size, ...nativeProps } = props;
440
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
441
+ "button",
442
+ {
443
+ ...nativeProps,
444
+ "aria-label": ariaLabel ?? "Icon Button",
445
+ className: (0, import_css7.cx)(
446
+ nativeProps.className,
447
+ (0, import_recipes6.iconButton)({
448
+ palette,
449
+ usage,
450
+ size
451
+ })
452
+ )
453
+ }
454
+ );
455
+ }
456
+
457
+ // src/context/cta-modal.tsx
458
+ var import_css8 = require("@cerberus/styled-system/css");
459
+ var import_jsx2 = require("@cerberus/styled-system/jsx");
460
+ var import_jsx_runtime10 = require("react/jsx-runtime");
461
+ var CTAModalContext = (0, import_react4.createContext)(null);
462
+ function CTAModal(props) {
463
+ var _a, _b;
464
+ const { modalRef, show, close } = useModal();
465
+ const [content, setContent] = (0, import_react4.useState)(null);
466
+ const focusTrap = trapFocus(modalRef);
467
+ const FallbackIcon = $cerberusIcons.confirmModal;
468
+ const confirmIcon = content == null ? void 0 : content.icon;
469
+ const { close: CloseIcon } = $cerberusIcons;
470
+ const handleShow = (0, import_react4.useCallback)(
471
+ (options) => {
472
+ const maxActions = 2;
473
+ if (options.actions.length > maxActions) {
474
+ throw new Error(
475
+ `CTA Modal only supports a maximum of ${maxActions} actions.`
476
+ );
477
+ }
478
+ setContent({ ...options });
479
+ show();
480
+ },
481
+ [show]
482
+ );
483
+ const handleActionClick = (0, import_react4.useCallback)(
484
+ (event) => {
485
+ const index = event.currentTarget.getAttribute("data-index");
486
+ const action = content == null ? void 0 : content.actions[Number(index)];
487
+ if (typeof (action == null ? void 0 : action.onClick) === "function") {
488
+ action.onClick(event);
489
+ }
490
+ close();
491
+ },
492
+ [content, close]
493
+ );
494
+ const value = (0, import_react4.useMemo)(
495
+ () => ({
496
+ show: handleShow
497
+ }),
498
+ [handleShow]
499
+ );
500
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(CTAModalContext.Provider, { value, children: [
501
+ props.children,
502
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Modal, { onKeyDown: focusTrap, ref: modalRef, children: [
503
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
504
+ "span",
505
+ {
506
+ className: (0, import_css8.css)({
507
+ padding: "md",
508
+ position: "absolute",
509
+ right: 0,
510
+ top: 0,
511
+ zIndex: "decorator"
512
+ }),
513
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(IconButton, { ariaLabel: "Close modal", onClick: close, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CloseIcon, {}) })
514
+ }
515
+ ),
516
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(ModalHeader, { children: [
517
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx.HStack, { justify: "center", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
518
+ Avatar,
519
+ {
520
+ ariaLabel: "",
521
+ gradient: "charon-light",
522
+ icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
523
+ Show,
524
+ {
525
+ when: Boolean(confirmIcon),
526
+ fallback: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FallbackIcon, { size: 24 }),
527
+ children: confirmIcon
528
+ }
529
+ ),
530
+ src: ""
531
+ }
532
+ ) }),
533
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx2.VStack, { gap: "lg", w: "full", children: [
534
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ModalHeading, { children: content == null ? void 0 : content.heading }),
535
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ModalDescription, { children: content == null ? void 0 : content.description })
536
+ ] })
537
+ ] }),
538
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx.HStack, { gap: "md", pt: "sm", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Show, { when: Boolean((_a = content == null ? void 0 : content.actions) == null ? void 0 : _a.length), children: (_b = content == null ? void 0 : content.actions) == null ? void 0 : _b.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
539
+ Button,
540
+ {
541
+ "data-index": index,
542
+ className: (0, import_css8.css)({
543
+ w: "1/2"
544
+ }),
545
+ onClick: handleActionClick,
546
+ shape: "rounded",
547
+ usage: "outlined",
548
+ children: action.text
549
+ },
550
+ index
551
+ )) }) })
552
+ ] }) })
553
+ ] });
554
+ }
555
+ function useCTAModal() {
556
+ const context = (0, import_react4.useContext)(CTAModalContext);
557
+ if (context === null) {
558
+ throw new Error("useCTAModal must be used within a CTAModal Provider");
559
+ }
560
+ return context;
561
+ }
562
+ // Annotate the CommonJS export names for ESM import in node:
563
+ 0 && (module.exports = {
564
+ CTAModal,
565
+ useCTAModal
566
+ });
567
+ //# sourceMappingURL=cta-modal.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/cta-modal.tsx","../../../src/components/Portal.tsx","../../../src/components/Button.tsx","../../../src/config/cerbIcons.ts","../../../src/config/icons/checkbox.icons.tsx","../../../src/components/AnimatingUploadIcon.tsx","../../../src/config/defineIcons.ts","../../../src/aria-helpers/trap-focus.aria.ts","../../../src/components/Show.tsx","../../../src/components/Modal.tsx","../../../src/hooks/useModal.ts","../../../src/components/ModalHeader.tsx","../../../src/components/ModalHeading.tsx","../../../src/components/ModalDescription.tsx","../../../src/components/Avatar.tsx","../../../src/components/IconButton.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type ButtonHTMLAttributes,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { Portal } from '../components/Portal'\nimport { Button } from '../components/Button'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport { trapFocus } from '../aria-helpers/trap-focus.aria'\nimport { Show } from '../components/Show'\nimport { Modal } from '../components/Modal'\nimport { useModal } from '../hooks/useModal'\nimport { ModalHeader } from '../components/ModalHeader'\nimport { ModalHeading } from '../components/ModalHeading'\nimport { ModalDescription } from '../components/ModalDescription'\nimport { Avatar } from '../components/Avatar'\nimport { HStack } from '@cerberus/styled-system/jsx'\nimport { IconButton } from '../components/IconButton'\nimport { css } from '@cerberus/styled-system/css'\nimport { VStack } from '@cerberus/styled-system/jsx'\n\n/**\n * This module provides a context and hook for the cta modal.\n * @module\n */\n\nexport interface ShowCTAModalOptions {\n /**\n * The heading of the cta modal.\n */\n heading: string\n /**\n * The description of the cta modal.\n */\n description?: string\n /**\n * The icon used for the modal Avatar.\n */\n icon?: ReactNode\n /**\n * The actions for the cta modal. Max of 2 actions.\n */\n actions: {\n text: string\n onClick: Required<ButtonHTMLAttributes<HTMLButtonElement>['onClick']>\n }[]\n}\n\nexport interface CTAModalValue {\n show: (options: ShowCTAModalOptions) => void\n}\n\nconst CTAModalContext = createContext<CTAModalValue | null>(null)\n\nexport interface CTAModalProviderProps {}\n\n/**\n * Provides a CTA modal to the app.\n * @see https://cerberus.digitalu.design/react/cta-modal\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <CTAModal>\n * <SomeFeatureSection />\n * </CTAModal>\n *\n * // Use the hook to show the cta modal.\n * const cta = useCTAModal()\n *\n * const handleClick = useCallback(async () => {\n * const userConsent = await cta.show({\n * heading: 'Create or copy a Cohort',\n * description:\n * 'Create a new cohort or copy and existing one.',\n * icon: <Copy size={24} />,\n * actions: [\n * {\n * text: 'Create Cohort',\n * onClick: () => {},\n * {\n * text: 'Copy Cohort',\n * onClick: () => {}\n * }\n * })\n * setConsent(userConsent)\n * }, [cta])\n * ```\n */\nexport function CTAModal(props: PropsWithChildren<CTAModalProviderProps>) {\n const { modalRef, show, close } = useModal()\n const [content, setContent] = useState<ShowCTAModalOptions | null>(null)\n const focusTrap = trapFocus(modalRef)\n const FallbackIcon = $cerberusIcons.confirmModal\n const confirmIcon = content?.icon as ReactNode\n const { close: CloseIcon } = $cerberusIcons\n\n const handleShow = useCallback(\n (options: ShowCTAModalOptions) => {\n const maxActions = 2\n if (options.actions.length > maxActions) {\n throw new Error(\n `CTA Modal only supports a maximum of ${maxActions} actions.`,\n )\n }\n setContent({ ...options })\n show()\n },\n [show],\n )\n\n const handleActionClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const index = event.currentTarget.getAttribute('data-index')\n const action = content?.actions[Number(index)]\n if (typeof action?.onClick === 'function') {\n action.onClick(event)\n }\n close()\n },\n [content, close],\n )\n\n const value = useMemo(\n () => ({\n show: handleShow,\n }),\n [handleShow],\n )\n\n return (\n <CTAModalContext.Provider value={value}>\n {props.children}\n\n <Portal>\n <Modal onKeyDown={focusTrap} ref={modalRef}>\n <span\n className={css({\n padding: 'md',\n position: 'absolute',\n right: 0,\n top: 0,\n zIndex: 'decorator',\n })}\n >\n <IconButton ariaLabel=\"Close modal\" onClick={close}>\n <CloseIcon />\n </IconButton>\n </span>\n\n <ModalHeader>\n <HStack justify=\"center\" w=\"full\">\n <Avatar\n ariaLabel=\"\"\n gradient=\"charon-light\"\n icon={\n <Show\n when={Boolean(confirmIcon)}\n fallback={<FallbackIcon size={24} />}\n >\n {confirmIcon}\n </Show>\n }\n src=\"\"\n />\n </HStack>\n <VStack gap=\"lg\" w=\"full\">\n <ModalHeading>{content?.heading}</ModalHeading>\n <ModalDescription>{content?.description}</ModalDescription>\n </VStack>\n </ModalHeader>\n\n <HStack gap=\"md\" pt=\"sm\" w=\"full\">\n <Show when={Boolean(content?.actions?.length)}>\n {content?.actions?.map((action, index) => (\n <Button\n data-index={index}\n className={css({\n w: '1/2',\n })}\n key={index}\n onClick={handleActionClick}\n shape=\"rounded\"\n usage=\"outlined\"\n >\n {action.text}\n </Button>\n ))}\n </Show>\n </HStack>\n </Modal>\n </Portal>\n </CTAModalContext.Provider>\n )\n}\n\nexport function useCTAModal(): CTAModalValue {\n const context = useContext(CTAModalContext)\n if (context === null) {\n throw new Error('useCTAModal must be used within a CTAModal Provider')\n }\n return context\n}\n","import type { PropsWithChildren } from 'react'\nimport { createPortal } from 'react-dom'\n\n/**\n * This module is the Portal component.\n * @module\n */\n\nexport interface PortalProps {\n /**\n * The root container to render the children into.\n * @default document.body\n */\n container?: Element | DocumentFragment\n /**\n * An optional key to use for the Portal component.\n */\n key?: null | string\n}\n\n/**\n * The Portal component is used to render children into a DOM node that exists outside the DOM hierarchy of the parent component.\n * @see https://cerberus.digitalu.design/react/portal\n * @definition [React Portal Docs](https://react.dev/reference/react-dom/createPortal)\n */\nexport function Portal(props: PropsWithChildren<PortalProps>) {\n if (typeof window !== 'undefined') {\n const container = props.container || document.body\n return createPortal(props.children, container, props.key)\n }\n\n return null\n}\n","import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n button,\n type ButtonVariantProps,\n} from '@cerberus/styled-system/recipes'\n\n/**\n * This module contains the Button component.\n * @module\n */\n\nexport type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &\n ButtonVariantProps\n\n/**\n * A component that allows the user to perform actions\n * @see https://cerberus.digitalu.design/react/button\n */\nexport function Button(props: ButtonProps): JSX.Element {\n const { palette, usage, shape, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n }),\n )}\n />\n )\n}\n","import {\n Checkmark,\n CheckmarkOutline,\n ChevronDown,\n Close,\n CloudUpload,\n Information,\n Restart,\n TrashCan,\n UserFilled,\n Warning,\n WarningAlt,\n WarningFilled,\n type CarbonIconType,\n} from '@cerberus/icons'\nimport type { ElementType } from 'react'\nimport { CheckmarkIcon, IndeterminateIcon } from './icons/checkbox.icons'\nimport { AnimatingUploadIcon } from '../components/AnimatingUploadIcon'\n\nexport type IconType = CarbonIconType | ElementType\n\nexport interface DefinedIcons {\n avatar?: IconType\n checkbox?: IconType\n close?: IconType\n confirmModal?: IconType\n delete?: IconType\n promptModal?: IconType\n waitingFileUploader?: IconType\n fileUploader?: IconType\n indeterminate?: IconType\n infoNotification?: IconType\n successNotification?: IconType\n warningNotification?: IconType\n dangerNotification?: IconType\n invalid: IconType\n invalidAlt?: IconType\n redo?: IconType\n selectArrow?: IconType\n toggleChecked?: IconType\n}\n\nexport const defaultIcons: DefinedIcons = {\n avatar: UserFilled,\n checkbox: CheckmarkIcon,\n close: Close,\n confirmModal: Information,\n delete: TrashCan,\n promptModal: Information,\n waitingFileUploader: CloudUpload,\n fileUploader: AnimatingUploadIcon,\n indeterminate: IndeterminateIcon,\n infoNotification: Information,\n successNotification: CheckmarkOutline,\n warningNotification: WarningAlt,\n dangerNotification: WarningFilled,\n invalid: WarningFilled,\n invalidAlt: Warning,\n redo: Restart,\n selectArrow: ChevronDown,\n toggleChecked: Checkmark,\n}\n","import type { SVGProps } from 'react'\n\n/**\n * This module contains substitute icons for the Checkbox component.\n * @module\n */\n\ninterface CheckboxIconProps extends SVGProps<SVGSVGElement> {}\n\n/**\n * Checkmark icon for Checkbox component\n */\nexport function CheckmarkIcon(props: CheckboxIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n role=\"img\"\n viewBox=\"0 0 24 24\"\n {...props}\n >\n <path\n fill=\"currentColor\"\n d=\"M9.714 18 4 12.335l1.818-1.764 3.896 3.824L18.181 6 20 7.803 9.714 18Z\"\n />\n </svg>\n )\n}\n\ninterface IndeterminateIconProps extends SVGProps<SVGSVGElement> {}\n\n/**\n * Indeterminate icon for Checkbox component\n */\nexport function IndeterminateIcon(props: IndeterminateIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n role=\"img\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n {...props}\n >\n <path fill=\"currentColor\" d=\"M4 11h16v2.667H4z\" />\n </svg>\n )\n}\n","import { type CarbonIconProps } from '@cerberus/icons'\n\n/**\n * This module contains an animating icon to use for the FileStatus component.\n * @module\n */\n\nexport type AnimatingUploadIconProps = CarbonIconProps\n\nexport function AnimatingUploadIcon(props: AnimatingUploadIconProps) {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width={props.size ?? '1em'}\n height={props.size ?? '1em'}\n viewBox=\"0 0 24 24\"\n >\n <g\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"square\"\n strokeLinejoin=\"round\"\n strokeWidth={1.5}\n >\n <path\n data-name=\"animating-trail\"\n strokeDasharray=\"2 4\"\n strokeDashoffset={6}\n d=\"M12 21c-4.97 0 -9 -4.03 -9 -9c0 -4.97 4.03 -9 9 -9\"\n >\n <animate\n attributeName=\"stroke-dashoffset\"\n dur=\"0.45s\"\n repeatCount=\"indefinite\"\n values=\"6;0\"\n ></animate>\n </path>\n\n <path\n data-name=\"half-circle\"\n strokeDasharray={32}\n strokeDashoffset={32}\n d=\"M12 3c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9\"\n >\n <animate\n fill=\"freeze\"\n attributeName=\"stroke-dashoffset\"\n begin=\"0.075s\"\n dur=\"0.3s\"\n values=\"32;0\"\n ></animate>\n </path>\n\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"0.8em\"\n height=\"0.8em\"\n x=\"27%\"\n y=\"27%\"\n viewBox=\"0 0 24 24\"\n >\n <polygon\n fill=\"currentColor\"\n stroke=\"currentColor\"\n strokeWidth={0.8}\n opacity=\"1\"\n points=\"3.7,6.7 7.5,2.9 7.5,15 8.5,15 8.5,2.9 12.3,6.7 13,6 8,1 3,6 \"\n >\n <animate\n fill=\"freeze\"\n attributeName=\"opacity\"\n values=\"1;0;1\"\n dur=\"2s\"\n repeatCount=\"indefinite\"\n ></animate>\n </polygon>\n </svg>\n </g>\n </svg>\n )\n}\n","import { defaultIcons, type DefinedIcons } from './cerbIcons'\n\nfunction _validateIconsProperties(icons: DefinedIcons) {\n if (!icons.invalid) {\n throw new Error(\n 'The an invalid property must be defined in your custom icons library.',\n )\n }\n}\n\nexport function defineIcons(icons: DefinedIcons): Required<DefinedIcons> {\n _validateIconsProperties(icons)\n $cerberusIcons = {\n ...defaultIcons,\n ...icons,\n } as Required<DefinedIcons>\n return $cerberusIcons\n}\n\n// Default icons\n\nexport let $cerberusIcons = defaultIcons as Required<DefinedIcons>\n","import type { KeyboardEvent, KeyboardEventHandler, RefObject } from 'react'\n\nexport function trapFocus(\n modalRef: RefObject<HTMLDialogElement>,\n): KeyboardEventHandler<HTMLDialogElement> {\n const focusableElements =\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])'\n const focusable = Array.from(\n modalRef.current?.querySelectorAll(focusableElements) ?? [],\n )\n const firstFocusable = focusable[0] as HTMLElement\n const lastFocusable = focusable[focusable.length - 1] as HTMLElement\n\n return function handleKeyDown(event: KeyboardEvent<HTMLDialogElement>) {\n if (event.key === 'Tab') {\n if (event.shiftKey) {\n if (document.activeElement === firstFocusable) {\n lastFocusable.focus()\n event.preventDefault()\n }\n } else {\n if (document.activeElement === lastFocusable) {\n firstFocusable.focus()\n event.preventDefault()\n }\n }\n }\n }\n}\n","'use client'\n\nimport { useMemo, type PropsWithChildren, type ReactNode } from 'react'\n\n/**\n * This module contains the Show component.\n * @module\n */\n\nexport interface ShowProps {\n /**\n * The condition to render memoized children or the fallback content.\n */\n when: boolean | null | undefined\n /**\n * The children to render when the condition is false.\n */\n fallback?: ReactNode\n}\n\n/**\n * Conditionally render a memoized version of the children or optional fallback\n * content.\n * @see https://cerberus.digitalu.design/react/show\n * @example\n * ```tsx\n * <Show when={isLoggedIn} fallback={<Navigate to=\"/login\" />}>\n * <Dashboard />\n * </Show>\n */\nexport function Show(props: PropsWithChildren<ShowProps>): ReactNode {\n const { when, children, fallback } = props\n const condition = useMemo(() => when ?? false, [when])\n\n return useMemo(() => {\n if (condition) return children\n return fallback ?? null\n }, [condition, children, fallback])\n}\n","import { cx } from '@cerberus/styled-system/css'\nimport { modal } from '@cerberus/styled-system/recipes'\nimport { forwardRef, type ForwardedRef, type HTMLAttributes } from 'react'\n\n/**\n * This module contains the Modal root component for a customizable modal.\n * @module\n */\n\n// Modal\n\nexport type ModalProps = HTMLAttributes<HTMLDialogElement>\n\nfunction ModalEl(props: ModalProps, ref: ForwardedRef<HTMLDialogElement>) {\n return (\n <dialog\n {...props}\n className={cx(props.className, modal().dialog)}\n ref={ref}\n />\n )\n}\n\n/**\n * The Modal component is the root element for a customizable modal.\n * @see https://cerberus.digitalu.design/react/modal\n * @example\n * ```tsx\n * const { modalRef } = useModal()\n *\n * <Modal ref={modalRef}>\n * <Avatar icon={SomeIcon} />\n * <ModalHeader>\n * <ModalHeading>Modal Heading</ModalHeading>\n * <ModalDescription>Modal description</ModalDescription>\n * </ModalHeader>\n *\n * {props.children}\n * </Modal>\n * ```\n */\nexport const Modal = forwardRef(ModalEl)\n","'use client'\n\nimport { useCallback, useMemo, useRef, useState, type RefObject } from 'react'\n\n/**\n * This module provides a hook for using a custom modal.\n * @module\n */\n\ninterface UseModalReturnValue {\n /**\n * The ref for the modal.\n */\n modalRef: RefObject<HTMLDialogElement>\n /**\n * Shows the modal.\n */\n show: () => void\n /**\n * Closes the modal.\n */\n close: () => void\n /**\n * Whether the modal is open based on the show and close methods.\n */\n isOpen: boolean\n}\n\n/**\n * Provides a hook for using a custom modal via the native dialog element\n * methods.\n *\n * Cerberus modals use the native dialog element. This hook\n * does not control the modal via React state but rather by calling the\n * native dialog element's `showModal` and `close` methods.\n *\n * @memberof module:Modal\n * @see https://cerberus.digitalu.design/react/modal\n * @description [Moz Dev Dialog Docs](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/showModal)\n */\nexport function useModal(): UseModalReturnValue {\n const modalRef = useRef<HTMLDialogElement | null>(null)\n const [isOpen, setIsOpen] = useState<boolean>(false)\n\n const show = useCallback(() => {\n modalRef.current?.showModal()\n setIsOpen(true)\n }, [])\n\n const close = useCallback(() => {\n modalRef.current?.close()\n setIsOpen(false)\n }, [])\n\n return useMemo(() => {\n return {\n modalRef,\n show,\n close,\n isOpen,\n }\n }, [modalRef, show, close, isOpen])\n}\n","import { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport type { HTMLAttributes } from 'react'\n\n/**\n * This module contains the ModalHeader component for a customizable modal.\n * @module\n */\n\nexport type ModalHeaderProps = HTMLAttributes<HTMLDivElement>\n\n/**\n * The ModalHeader component is a header element for a customizable modal.\n * @see https://cerberus.digitalu.design/react/modal\n * @example\n * ```tsx\n * <Modal>\n * <ModalHeader>\n * <h2>Modal Heading</h2>\n * </ModalHeader>\n * </Modal>\n * ```\n */\nexport function ModalHeader(props: ModalHeaderProps) {\n return (\n <div\n {...props}\n className={cx(\n props.className,\n vstack({\n alignItems: 'flex-start',\n gap: 'md',\n mb: 'md',\n position: 'relative',\n }),\n )}\n />\n )\n}\n","import { cx } from '@cerberus/styled-system/css'\nimport { modal } from '@cerberus/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\n/**\n * This module contains the ModalHeading component for a customizable modal.\n * @module\n */\n\nexport type ModalHeadingProps = HTMLAttributes<HTMLParagraphElement>\n\n/**\n * The ModalHeading component is a heading element for a customizable modal.\n * @see https://cerberus.digitalu.design/react/modal\n * @example\n * ```tsx\n * <Modal>\n * <ModalHeading>Modal Heading</ModalHeading>\n * </Modal>\n * ```\n */\nexport function ModalHeading(props: ModalHeadingProps) {\n return <p {...props} className={cx(props.className, modal().heading)} />\n}\n","import { cx } from '@cerberus/styled-system/css'\nimport { modal } from '@cerberus/styled-system/recipes'\nimport type { HTMLAttributes } from 'react'\n\n/**\n * This module contains the ModalDescription component for a customizable modal.\n * @module\n */\n\nexport type ModalDescriptionProps = HTMLAttributes<HTMLParagraphElement>\n\n/**\n * The ModalDescription component is a heading element for a customizable modal.\n * @see https://cerberus.digitalu.design/react/modal\n * @example\n * ```tsx\n * <Modal>\n * <ModalDescription>Modal Heading</ModalDescription>\n * </Modal>\n * ```\n */\nexport function ModalDescription(props: ModalDescriptionProps) {\n return <p {...props} className={cx(props.className, modal().description)} />\n}\n","import { css, cx } from '@cerberus/styled-system/css'\nimport { circle } from '@cerberus/styled-system/patterns'\nimport {\n avatar,\n type AvatarVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { $cerberusIcons } from '../config/defineIcons'\nimport type { HtmlHTMLAttributes, ReactNode } from 'react'\nimport { Show } from './Show'\n\n/**\n * This module contains the Avatar component.\n * @module\n */\n\nexport type SharedAvatarProps = {\n /**\n * An optional icon to show when no src or ariaLabel is provided.\n */\n icon?: ReactNode\n /**\n * The size of the avatar.\n */\n width?: number\n /**\n * The size of the avatar.\n */\n height?: number\n}\nexport type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> &\n SharedAvatarProps & {\n /**\n * The aria-label for the avatar needed for accessibility.\n */\n ariaLabel: string\n /**\n * An optional element to replace the image. Recommended for Next.js Image component.\n */\n as?: never\n /**\n * The source of the image.\n */\n src: string\n }\nexport type AvatarAsProps = SharedAvatarProps & {\n /**\n * An optional element to replace the image. Recommended for Next.js Image component.\n */\n as: ReactNode\n /**\n * The aria-label for the avatar needed for accessibility.\n */\n ariaLabel?: never\n /**\n * The source of the image.\n */\n src?: never\n}\n\nexport type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &\n AvatarVariantProps) &\n (AvatarImageProps | AvatarAsProps)\n\n/**\n * The Avatar component is used to represent a user or entity. It will show an image if src provided, otherwise it will show the ariaLabel of the ariaLabel. If the ariaLabel is empty, it will show a `defineIcons().avatar` icon.\n * @see https://cerberus.digitalu.design/react/avatar\n * @example\n * ```tsx\n * <Avatar\n * ariaLabel=\"Protector Cerberus\"\n * src=\"https://cerberus.digitalu.design/logo.svg\"\n * />\n * ```\n */\nexport function Avatar(props: AvatarProps) {\n const {\n ariaLabel,\n as,\n gradient,\n size,\n src,\n width,\n height,\n icon,\n ...nativeProps\n } = props\n const { avatar: AvatarIcon } = $cerberusIcons\n const initials = (ariaLabel || '')\n .split(' ')\n .map((word) => word[0])\n .join('')\n .slice(0, 2)\n\n return (\n <div\n {...nativeProps}\n className={cx(\n nativeProps.className,\n avatar({ gradient, size }),\n circle(),\n )}\n >\n <Show\n when={Boolean(src) || Boolean(as)}\n fallback={\n <Show\n when={Boolean(initials)}\n fallback={\n <Show\n when={Boolean(icon)}\n fallback={\n <AvatarIcon\n size={iconSizeMap[size as keyof typeof iconSizeMap]}\n />\n }\n >\n {icon}\n </Show>\n }\n >\n {initials}\n </Show>\n }\n >\n <Show\n when={Boolean(as)}\n fallback={\n <img\n alt={props.ariaLabel}\n className={css({\n h: 'full',\n objectFit: 'cover',\n w: 'full',\n })}\n decoding=\"async\"\n loading=\"lazy\"\n src={src}\n height={height}\n width={width}\n />\n }\n >\n {as}\n </Show>\n </Show>\n </div>\n )\n}\n\nconst iconSizeMap = {\n xs: 16,\n sm: 16,\n md: 20,\n lg: 34,\n xl: 32,\n '2xl': 32,\n '3xl': 32,\n '4xl': 32,\n}\n","import type { ButtonHTMLAttributes } from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n iconButton,\n type IconButtonVariantProps,\n} from '@cerberus/styled-system/recipes'\n\n/**\n * This module contains the Icon Button component.\n * @module\n */\n\nexport interface IconButtonRawProps\n extends ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * The aria-label attribute for the icon button.\n */\n ariaLabel: string\n}\nexport type IconButtonProps = IconButtonRawProps & IconButtonVariantProps\n\n/**\n * A component that allows the user to perform actions using an icon\n * @see https://cerberus.digitalu.design/react/icon-button\n */\nexport function IconButton(props: IconButtonProps): JSX.Element {\n const { ariaLabel, palette, usage, size, ...nativeProps } = props\n return (\n <button\n {...nativeProps}\n aria-label={ariaLabel ?? 'Icon Button'}\n className={cx(\n nativeProps.className,\n iconButton({\n palette,\n usage,\n size,\n }),\n )}\n />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H;AAAA,YAEF,KAAI;AAAA;AAAA,QACN,GACF;AAAA,QACA,+CAAC,sBAAO,KAAI,MAAK,GAAE,QACjB;AAAA,wDAAC,gBAAc,6CAAS,SAAQ;AAAA,UAChC,8CAAC,oBAAkB,6CAAS,aAAY;AAAA,WAC1C;AAAA,SACF;AAAA,MAEA,8CAAC,qBAAO,KAAI,MAAK,IAAG,MAAK,GAAE,QACzB,wDAAC,QAAK,MAAM,SAAQ,wCAAS,YAAT,mBAAkB,MAAM,GACzC,mDAAS,YAAT,mBAAkB,IAAI,CAAC,QAAQ,UAC9B;AAAA,QAAC;AAAA;AAAA,UACC,cAAY;AAAA,UACZ,eAAW,iBAAI;AAAA,YACb,GAAG;AAAA,UACL,CAAC;AAAA,UAED,SAAS;AAAA,UACT,OAAM;AAAA,UACN,OAAM;AAAA,UAEL,iBAAO;AAAA;AAAA,QALH;AAAA,MAMP,IAEJ,GACF;AAAA,OACF,GACF;AAAA,KACF;AAEJ;AAEO,SAAS,cAA6B;AAC3C,QAAM,cAAU,0BAAW,eAAe;AAC1C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":["import_react","import_jsx_runtime","import_jsx_runtime","import_css","import_recipes","import_react","import_jsx_runtime","import_react","import_css","import_jsx_runtime","import_css","import_recipes","import_jsx_runtime","import_css","import_recipes","import_jsx_runtime","import_css","import_patterns","import_recipes","import_jsx_runtime","import_css","import_recipes","import_jsx_runtime","import_css","import_jsx","import_jsx_runtime"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/navMenu.tsx"],"sourcesContent":["'use client'\n\nimport { css } from '@cerberus/styled-system/css'\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type PropsWithChildren,\n type RefObject,\n} from 'react'\n\n/**\n * This module provides a context and hook for the nav menu.\n * @module NavMenu\n */\n\nexport type NavTriggerRef = RefObject<HTMLButtonElement>\nexport type NavMenuRef = RefObject<HTMLUListElement>\n\nexport interface NavMenuContextValue {\n /**\n * The ref for the trigger button.\n */\n triggerRef: NavTriggerRef | null\n /**\n * The ref for the menu.\n */\n menuRef: NavMenuRef | null\n /**\n * Whether the menu is expanded.\n */\n expanded: boolean\n /**\n * Called when the menu button is clicked.\n */\n onToggle: () => void\n}\n\nconst NavMenuContext = createContext<NavMenuContextValue | null>(null)\n\n/**\n * Provides the nav menu state for all the NavMenu family components.\n * @see https://cerberus.digitalu.design/react/nav-menu\n */\nexport function NavMenu(props: PropsWithChildren): JSX.Element {\n const triggerRef = useRef<HTMLButtonElement>(null)\n const menuRef = useRef<HTMLUListElement>(null)\n const [expanded, setExpanded] = useState<boolean>(false)\n\n const handleToggle = useCallback(() => {\n setExpanded((prev) => !prev)\n }, [])\n\n const value = useMemo(\n () => ({\n triggerRef,\n menuRef,\n expanded,\n onToggle: handleToggle,\n }),\n [expanded, handleToggle],\n )\n\n return (\n <NavMenuContext.Provider value={value}>\n <nav\n className={css({\n position: 'relative',\n })}\n >\n {props.children}\n </nav>\n </NavMenuContext.Provider>\n )\n}\n\n/**\n * Used to access the nav menu context.\n * @returns The nav menu context.\n */\nexport function useNavMenuContext(): NavMenuContextValue {\n const context = useContext(NavMenuContext)\n if (!context) {\n throw new Error('useNavMenuContext must be used within a NavMenu.')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAoB;AACpB,mBASO;AAwDD;AA3BN,IAAM,qBAAiB,4BAA0C,IAAI;AAM9D,SAAS,QAAQ,OAAuC;AAC7D,QAAM,iBAAa,qBAA0B,IAAI;AACjD,QAAM,cAAU,qBAAyB,IAAI;AAC7C,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAkB,KAAK;AAEvD,QAAM,mBAAe,0BAAY,MAAM;AACrC,gBAAY,CAAC,SAAS,CAAC,IAAI;AAAA,EAC7B,GAAG,CAAC,CAAC;AAEL,QAAM,YAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU;AAAA,IACZ;AAAA,IACA,CAAC,UAAU,YAAY;AAAA,EACzB;AAEA,SACE,4CAAC,eAAe,UAAf,EAAwB,OACvB;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,gBAAI;AAAA,QACb,UAAU;AAAA,MACZ,CAAC;AAAA,MAEA,gBAAM;AAAA;AAAA,EACT,GACF;AAEJ;AAMO,SAAS,oBAAyC;AACvD,QAAM,cAAU,yBAAW,cAAc;AACzC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/context/navMenu.tsx"],"sourcesContent":["'use client'\n\nimport { css } from '@cerberus/styled-system/css'\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type PropsWithChildren,\n type RefObject,\n} from 'react'\n\n/**\n * This module provides a context and hook for the nav menu.\n * @module NavMenu\n */\n\nexport type NavTriggerRef = RefObject<HTMLButtonElement>\nexport type NavMenuRef = RefObject<HTMLUListElement>\n\nexport interface NavMenuContextValue {\n /**\n * The ref for the trigger button.\n */\n triggerRef: NavTriggerRef | null\n /**\n * The ref for the menu.\n */\n menuRef: NavMenuRef | null\n /**\n * Whether the menu is expanded.\n */\n expanded: boolean\n /**\n * Called when the menu button is clicked.\n */\n onToggle: () => void\n}\n\nconst NavMenuContext = createContext<NavMenuContextValue | null>(null)\n\n/**\n * @deprecated use the {@link Menu} family instead\n */\nexport function NavMenu(props: PropsWithChildren): JSX.Element {\n const triggerRef = useRef<HTMLButtonElement>(null)\n const menuRef = useRef<HTMLUListElement>(null)\n const [expanded, setExpanded] = useState<boolean>(false)\n\n const handleToggle = useCallback(() => {\n setExpanded((prev) => !prev)\n }, [])\n\n const value = useMemo(\n () => ({\n triggerRef,\n menuRef,\n expanded,\n onToggle: handleToggle,\n }),\n [expanded, handleToggle],\n )\n\n return (\n <NavMenuContext.Provider value={value}>\n <nav\n className={css({\n position: 'relative',\n })}\n >\n {props.children}\n </nav>\n </NavMenuContext.Provider>\n )\n}\n\n/**\n * Used to access the nav menu context.\n * @returns The nav menu context.\n */\nexport function useNavMenuContext(): NavMenuContextValue {\n const context = useContext(NavMenuContext)\n if (!context) {\n throw new Error('useNavMenuContext must be used within a NavMenu.')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAoB;AACpB,mBASO;AAuDD;AA1BN,IAAM,qBAAiB,4BAA0C,IAAI;AAK9D,SAAS,QAAQ,OAAuC;AAC7D,QAAM,iBAAa,qBAA0B,IAAI;AACjD,QAAM,cAAU,qBAAyB,IAAI;AAC7C,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAkB,KAAK;AAEvD,QAAM,mBAAe,0BAAY,MAAM;AACrC,gBAAY,CAAC,SAAS,CAAC,IAAI;AAAA,EAC7B,GAAG,CAAC,CAAC;AAEL,QAAM,YAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU;AAAA,IACZ;AAAA,IACA,CAAC,UAAU,YAAY;AAAA,EACzB;AAEA,SACE,4CAAC,eAAe,UAAf,EAAwB,OACvB;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,gBAAI;AAAA,QACb,UAAU;AAAA,MACZ,CAAC;AAAA,MAEA,gBAAM;AAAA;AAAA,EACT,GACF;AAEJ;AAMO,SAAS,oBAAyC;AACvD,QAAM,cAAU,yBAAW,cAAc;AACzC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAO;AACT;","names":[]}