@cerberus-design/react 0.14.2-next-2f75188 → 0.14.2-next-f58c1be
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.
- package/build/legacy/context/confirm-modal.cjs +103 -170
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +124 -171
- package/build/legacy/context/cta-modal.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +178 -231
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/index.cjs +861 -895
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/{chunk-MUTAYS3P.js → chunk-BHB56M7S.js} +24 -40
- package/build/modern/chunk-BHB56M7S.js.map +1 -0
- package/build/modern/{chunk-R4RFWDBM.js → chunk-FGCO27TC.js} +19 -47
- package/build/modern/chunk-FGCO27TC.js.map +1 -0
- package/build/modern/{chunk-VGEK2DQB.js → chunk-SD3OVTHT.js} +65 -94
- package/build/modern/chunk-SD3OVTHT.js.map +1 -0
- package/build/modern/context/confirm-modal.js +2 -7
- package/build/modern/context/cta-modal.js +3 -7
- package/build/modern/context/prompt-modal.js +3 -7
- package/build/modern/index.js +3 -3
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/context/confirm-modal.tsx +40 -40
- package/src/context/cta-modal.tsx +22 -36
- package/src/context/prompt-modal.tsx +97 -101
- package/src/index.ts +10 -7
- package/build/modern/chunk-MUTAYS3P.js.map +0 -1
- package/build/modern/chunk-R4RFWDBM.js.map +0 -1
- package/build/modern/chunk-VGEK2DQB.js.map +0 -1
|
@@ -25,11 +25,7 @@ __export(prompt_modal_exports, {
|
|
|
25
25
|
usePromptModal: () => usePromptModal
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(prompt_modal_exports);
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
// src/components/Portal.tsx
|
|
31
|
-
var import_react = require("@ark-ui/react");
|
|
32
|
-
var Portal = import_react.Portal;
|
|
28
|
+
var import_react6 = require("react");
|
|
33
29
|
|
|
34
30
|
// src/components/Button.tsx
|
|
35
31
|
var import_css = require("@cerberus/styled-system/css");
|
|
@@ -54,45 +50,19 @@ function Button(props) {
|
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
// src/context/prompt-modal.tsx
|
|
57
|
-
var
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
// src/aria-helpers/trap-focus.aria.ts
|
|
61
|
-
function trapFocus(modalRef) {
|
|
62
|
-
var _a;
|
|
63
|
-
const focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
64
|
-
const focusable = Array.from(
|
|
65
|
-
((_a = modalRef.current) == null ? void 0 : _a.querySelectorAll(focusableElements)) ?? []
|
|
66
|
-
);
|
|
67
|
-
const firstFocusable = focusable[0];
|
|
68
|
-
const lastFocusable = focusable[focusable.length - 1];
|
|
69
|
-
return function handleKeyDown(event) {
|
|
70
|
-
if (event.key === "Tab") {
|
|
71
|
-
if (event.shiftKey) {
|
|
72
|
-
if (document.activeElement === firstFocusable) {
|
|
73
|
-
lastFocusable.focus();
|
|
74
|
-
event.preventDefault();
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
if (document.activeElement === lastFocusable) {
|
|
78
|
-
firstFocusable.focus();
|
|
79
|
-
event.preventDefault();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
53
|
+
var import_css6 = require("@cerberus/styled-system/css");
|
|
54
|
+
var import_patterns3 = require("@cerberus/styled-system/patterns");
|
|
85
55
|
|
|
86
56
|
// src/components/Input.tsx
|
|
87
57
|
var import_recipes2 = require("@cerberus/styled-system/recipes");
|
|
88
58
|
var import_css2 = require("@cerberus/styled-system/css");
|
|
89
59
|
|
|
90
60
|
// src/context/field.tsx
|
|
91
|
-
var
|
|
61
|
+
var import_react = require("react");
|
|
92
62
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
93
|
-
var FieldContext = (0,
|
|
63
|
+
var FieldContext = (0, import_react.createContext)(null);
|
|
94
64
|
function Field(props) {
|
|
95
|
-
const value = (0,
|
|
65
|
+
const value = (0, import_react.useMemo)(
|
|
96
66
|
() => ({
|
|
97
67
|
disabled: props.disabled,
|
|
98
68
|
readOnly: props.readOnly,
|
|
@@ -104,7 +74,7 @@ function Field(props) {
|
|
|
104
74
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FieldContext.Provider, { value, children: props.children });
|
|
105
75
|
}
|
|
106
76
|
function useFieldContext() {
|
|
107
|
-
const context = (0,
|
|
77
|
+
const context = (0, import_react.useContext)(FieldContext);
|
|
108
78
|
if (!context) {
|
|
109
79
|
throw new Error("useFieldContext must be used within a Field Provider.");
|
|
110
80
|
}
|
|
@@ -112,11 +82,11 @@ function useFieldContext() {
|
|
|
112
82
|
}
|
|
113
83
|
|
|
114
84
|
// src/context/cerberus.tsx
|
|
115
|
-
var
|
|
85
|
+
var import_react2 = require("react");
|
|
116
86
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
117
|
-
var CerberusContext = (0,
|
|
87
|
+
var CerberusContext = (0, import_react2.createContext)(null);
|
|
118
88
|
function useCerberusContext() {
|
|
119
|
-
const context = (0,
|
|
89
|
+
const context = (0, import_react2.useContext)(CerberusContext);
|
|
120
90
|
if (!context) {
|
|
121
91
|
throw new Error("useCerberus must be used within a CerberusProvider");
|
|
122
92
|
}
|
|
@@ -124,11 +94,11 @@ function useCerberusContext() {
|
|
|
124
94
|
}
|
|
125
95
|
|
|
126
96
|
// src/components/Show.tsx
|
|
127
|
-
var
|
|
97
|
+
var import_react3 = require("react");
|
|
128
98
|
function Show(props) {
|
|
129
99
|
const { when, children, fallback } = props;
|
|
130
|
-
const condition = (0,
|
|
131
|
-
return (0,
|
|
100
|
+
const condition = (0, import_react3.useMemo)(() => when ?? false, [when]);
|
|
101
|
+
return (0, import_react3.useMemo)(() => {
|
|
132
102
|
if (condition) return children;
|
|
133
103
|
return fallback ?? null;
|
|
134
104
|
}, [condition, children, fallback]);
|
|
@@ -200,90 +170,11 @@ function Label(props) {
|
|
|
200
170
|
);
|
|
201
171
|
}
|
|
202
172
|
|
|
203
|
-
// src/
|
|
204
|
-
var import_react5 = require("react");
|
|
205
|
-
function useModal() {
|
|
206
|
-
const modalRef = (0, import_react5.useRef)(null);
|
|
207
|
-
const [isOpen, setIsOpen] = (0, import_react5.useState)(false);
|
|
208
|
-
const show = (0, import_react5.useCallback)(() => {
|
|
209
|
-
var _a;
|
|
210
|
-
(_a = modalRef.current) == null ? void 0 : _a.showModal();
|
|
211
|
-
setIsOpen(true);
|
|
212
|
-
}, []);
|
|
213
|
-
const close = (0, import_react5.useCallback)(() => {
|
|
214
|
-
var _a;
|
|
215
|
-
(_a = modalRef.current) == null ? void 0 : _a.close();
|
|
216
|
-
setIsOpen(false);
|
|
217
|
-
}, []);
|
|
218
|
-
return (0, import_react5.useMemo)(() => {
|
|
219
|
-
return {
|
|
220
|
-
modalRef,
|
|
221
|
-
show,
|
|
222
|
-
close,
|
|
223
|
-
isOpen
|
|
224
|
-
};
|
|
225
|
-
}, [modalRef, show, close, isOpen]);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// src/components/Modal.tsx
|
|
173
|
+
// src/components/Avatar.tsx
|
|
229
174
|
var import_css4 = require("@cerberus/styled-system/css");
|
|
175
|
+
var import_patterns2 = require("@cerberus/styled-system/patterns");
|
|
230
176
|
var import_recipes4 = require("@cerberus/styled-system/recipes");
|
|
231
|
-
var import_react6 = require("react");
|
|
232
177
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
233
|
-
function ModalEl(props, ref) {
|
|
234
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
235
|
-
"dialog",
|
|
236
|
-
{
|
|
237
|
-
...props,
|
|
238
|
-
className: (0, import_css4.cx)(props.className, (0, import_recipes4.modal)().dialog),
|
|
239
|
-
ref
|
|
240
|
-
}
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
var Modal = (0, import_react6.forwardRef)(ModalEl);
|
|
244
|
-
|
|
245
|
-
// src/components/ModalHeader.tsx
|
|
246
|
-
var import_css5 = require("@cerberus/styled-system/css");
|
|
247
|
-
var import_patterns2 = require("@cerberus/styled-system/patterns");
|
|
248
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
249
|
-
function ModalHeader(props) {
|
|
250
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
251
|
-
"div",
|
|
252
|
-
{
|
|
253
|
-
...props,
|
|
254
|
-
className: (0, import_css5.cx)(
|
|
255
|
-
props.className,
|
|
256
|
-
(0, import_patterns2.vstack)({
|
|
257
|
-
alignItems: "flex-start",
|
|
258
|
-
gap: "md",
|
|
259
|
-
position: "relative"
|
|
260
|
-
})
|
|
261
|
-
)
|
|
262
|
-
}
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// src/components/ModalHeading.tsx
|
|
267
|
-
var import_css6 = require("@cerberus/styled-system/css");
|
|
268
|
-
var import_recipes5 = require("@cerberus/styled-system/recipes");
|
|
269
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
270
|
-
function ModalHeading(props) {
|
|
271
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { ...props, className: (0, import_css6.cx)(props.className, (0, import_recipes5.modal)().heading) });
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
// src/components/ModalDescription.tsx
|
|
275
|
-
var import_css7 = require("@cerberus/styled-system/css");
|
|
276
|
-
var import_recipes6 = require("@cerberus/styled-system/recipes");
|
|
277
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
278
|
-
function ModalDescription(props) {
|
|
279
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { ...props, className: (0, import_css7.cx)(props.className, (0, import_recipes6.modal)().description) });
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// src/components/Avatar.tsx
|
|
283
|
-
var import_css8 = require("@cerberus/styled-system/css");
|
|
284
|
-
var import_patterns3 = require("@cerberus/styled-system/patterns");
|
|
285
|
-
var import_recipes7 = require("@cerberus/styled-system/recipes");
|
|
286
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
287
178
|
function Avatar(props) {
|
|
288
179
|
const {
|
|
289
180
|
ariaLabel,
|
|
@@ -299,28 +190,28 @@ function Avatar(props) {
|
|
|
299
190
|
const { icons } = useCerberusContext();
|
|
300
191
|
const { avatar: AvatarIcon } = icons;
|
|
301
192
|
const initials = (ariaLabel || "").split(" ").map((word) => word[0]).join("").slice(0, 2);
|
|
302
|
-
return /* @__PURE__ */ (0,
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
303
194
|
"div",
|
|
304
195
|
{
|
|
305
196
|
...nativeProps,
|
|
306
|
-
className: (0,
|
|
197
|
+
className: (0, import_css4.cx)(
|
|
307
198
|
nativeProps.className,
|
|
308
|
-
(0,
|
|
309
|
-
(0,
|
|
199
|
+
(0, import_recipes4.avatar)({ gradient, size }),
|
|
200
|
+
(0, import_patterns2.circle)()
|
|
310
201
|
),
|
|
311
|
-
children: /* @__PURE__ */ (0,
|
|
202
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
312
203
|
Show,
|
|
313
204
|
{
|
|
314
205
|
when: Boolean(src) || Boolean(as),
|
|
315
|
-
fallback: /* @__PURE__ */ (0,
|
|
206
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
316
207
|
Show,
|
|
317
208
|
{
|
|
318
209
|
when: Boolean(initials),
|
|
319
|
-
fallback: /* @__PURE__ */ (0,
|
|
210
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
320
211
|
Show,
|
|
321
212
|
{
|
|
322
213
|
when: Boolean(icon),
|
|
323
|
-
fallback: /* @__PURE__ */ (0,
|
|
214
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
324
215
|
AvatarIcon,
|
|
325
216
|
{
|
|
326
217
|
size: iconSizeMap[size]
|
|
@@ -332,15 +223,15 @@ function Avatar(props) {
|
|
|
332
223
|
children: initials
|
|
333
224
|
}
|
|
334
225
|
),
|
|
335
|
-
children: /* @__PURE__ */ (0,
|
|
226
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
336
227
|
Show,
|
|
337
228
|
{
|
|
338
229
|
when: Boolean(as),
|
|
339
|
-
fallback: /* @__PURE__ */ (0,
|
|
230
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
340
231
|
"img",
|
|
341
232
|
{
|
|
342
233
|
alt: props.ariaLabel,
|
|
343
|
-
className: (0,
|
|
234
|
+
className: (0, import_css4.css)({
|
|
344
235
|
h: "full",
|
|
345
236
|
objectFit: "cover",
|
|
346
237
|
w: "full"
|
|
@@ -371,88 +262,162 @@ var iconSizeMap = {
|
|
|
371
262
|
"4xl": 32
|
|
372
263
|
};
|
|
373
264
|
|
|
265
|
+
// src/components/Text.tsx
|
|
266
|
+
var import_jsx = require("@cerberus/styled-system/jsx");
|
|
267
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
268
|
+
function Text(props) {
|
|
269
|
+
const { as = "p", ...pandaJSXProps } = props;
|
|
270
|
+
switch (as) {
|
|
271
|
+
case "h1":
|
|
272
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.H1, { ...pandaJSXProps });
|
|
273
|
+
case "h2":
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.H2, { ...pandaJSXProps });
|
|
275
|
+
case "h3":
|
|
276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.H3, { ...pandaJSXProps });
|
|
277
|
+
case "h4":
|
|
278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.H4, { ...pandaJSXProps });
|
|
279
|
+
case "h5":
|
|
280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.H5, { ...pandaJSXProps });
|
|
281
|
+
case "h6":
|
|
282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.H6, { ...pandaJSXProps });
|
|
283
|
+
case "strong":
|
|
284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.Strong, { ...pandaJSXProps });
|
|
285
|
+
case "em":
|
|
286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.Em, { ...pandaJSXProps });
|
|
287
|
+
case "small":
|
|
288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.Small, { ...pandaJSXProps });
|
|
289
|
+
case "span":
|
|
290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.Span, { ...pandaJSXProps });
|
|
291
|
+
default:
|
|
292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx.P, { ...pandaJSXProps });
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// src/components/Dialog.tsx
|
|
297
|
+
var import_react5 = require("@ark-ui/react");
|
|
298
|
+
var import_recipes5 = require("@cerberus/styled-system/recipes");
|
|
299
|
+
|
|
300
|
+
// src/components/Portal.tsx
|
|
301
|
+
var import_react4 = require("@ark-ui/react");
|
|
302
|
+
var Portal = import_react4.Portal;
|
|
303
|
+
|
|
304
|
+
// src/components/Dialog.tsx
|
|
305
|
+
var import_css5 = require("@cerberus/styled-system/css");
|
|
306
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
307
|
+
function DialogProvider(props) {
|
|
308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.Dialog.Root, { ...props });
|
|
309
|
+
}
|
|
310
|
+
function Dialog(props) {
|
|
311
|
+
const { size, ...contentProps } = props;
|
|
312
|
+
const styles = (0, import_recipes5.dialog)({ size });
|
|
313
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Portal, { children: [
|
|
314
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogBackdrop, { className: styles.backdrop }),
|
|
315
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogPositioner, { className: styles.positioner, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogContent, { className: styles.content, ...contentProps }) })
|
|
316
|
+
] });
|
|
317
|
+
}
|
|
318
|
+
function DialogHeading(props) {
|
|
319
|
+
const styles = (0, import_recipes5.dialog)();
|
|
320
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.Dialog.Title, { ...props, className: (0, import_css5.cx)(props.className, styles.title) });
|
|
321
|
+
}
|
|
322
|
+
function DialogDescription(props) {
|
|
323
|
+
const styles = (0, import_recipes5.dialog)();
|
|
324
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
325
|
+
import_react5.Dialog.Description,
|
|
326
|
+
{
|
|
327
|
+
...props,
|
|
328
|
+
className: (0, import_css5.cx)(props.className, styles.description)
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
var DialogTrigger = import_react5.Dialog.Trigger;
|
|
333
|
+
var DialogCloseTrigger = import_react5.Dialog.CloseTrigger;
|
|
334
|
+
var DialogBackdrop = import_react5.Dialog.Backdrop;
|
|
335
|
+
var DialogPositioner = import_react5.Dialog.Positioner;
|
|
336
|
+
var DialogContent = import_react5.Dialog.Content;
|
|
337
|
+
|
|
374
338
|
// src/context/prompt-modal.tsx
|
|
375
|
-
var
|
|
376
|
-
var
|
|
339
|
+
var import_jsx2 = require("@cerberus/styled-system/jsx");
|
|
340
|
+
var import_react7 = require("@ark-ui/react");
|
|
341
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
342
|
+
var PromptModalContext = (0, import_react6.createContext)(null);
|
|
377
343
|
function PromptModal(props) {
|
|
378
|
-
const
|
|
379
|
-
const
|
|
380
|
-
const [content, setContent] = (0,
|
|
381
|
-
const [inputValue, setInputValue] = (0,
|
|
382
|
-
const focusTrap = trapFocus(modalRef);
|
|
344
|
+
const resolveRef = (0, import_react6.useRef)(null);
|
|
345
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
346
|
+
const [content, setContent] = (0, import_react6.useState)(null);
|
|
347
|
+
const [inputValue, setInputValue] = (0, import_react6.useState)("");
|
|
383
348
|
const { icons } = useCerberusContext();
|
|
384
349
|
const { promptModal: PromptIcon } = icons;
|
|
385
|
-
const isValid = (0,
|
|
350
|
+
const isValid = (0, import_react6.useMemo)(
|
|
386
351
|
() => inputValue === (content == null ? void 0 : content.key),
|
|
387
352
|
[inputValue, content]
|
|
388
353
|
);
|
|
389
|
-
const palette = (0,
|
|
354
|
+
const palette = (0, import_react6.useMemo)(
|
|
390
355
|
() => (content == null ? void 0 : content.kind) === "destructive" ? "danger" : "action",
|
|
391
356
|
[content]
|
|
392
357
|
);
|
|
393
|
-
const handleChange = (0,
|
|
358
|
+
const handleChange = (0, import_react6.useCallback)(
|
|
394
359
|
(e) => {
|
|
395
360
|
setInputValue(e.currentTarget.value);
|
|
396
361
|
},
|
|
397
362
|
[content]
|
|
398
363
|
);
|
|
399
|
-
const handleChoice = (0,
|
|
364
|
+
const handleChoice = (0, import_react6.useCallback)(
|
|
400
365
|
(e) => {
|
|
401
366
|
var _a;
|
|
402
367
|
const target = e.currentTarget;
|
|
403
368
|
if (target.value === "true") {
|
|
404
369
|
(_a = resolveRef.current) == null ? void 0 : _a.call(resolveRef, inputValue);
|
|
405
370
|
}
|
|
406
|
-
|
|
371
|
+
setOpen(false);
|
|
407
372
|
},
|
|
408
|
-
[inputValue,
|
|
373
|
+
[inputValue, setOpen]
|
|
409
374
|
);
|
|
410
|
-
const handleShow = (0,
|
|
375
|
+
const handleShow = (0, import_react6.useCallback)(
|
|
411
376
|
(options) => {
|
|
412
377
|
return new Promise((resolve) => {
|
|
413
378
|
setContent({ ...options, kind: options.kind || "non-destructive" });
|
|
414
|
-
|
|
379
|
+
setOpen(true);
|
|
415
380
|
resolveRef.current = resolve;
|
|
416
381
|
});
|
|
417
382
|
},
|
|
418
|
-
[
|
|
383
|
+
[setOpen]
|
|
419
384
|
);
|
|
420
|
-
const value = (0,
|
|
385
|
+
const value = (0, import_react6.useMemo)(
|
|
421
386
|
() => ({
|
|
422
387
|
show: handleShow
|
|
423
388
|
}),
|
|
424
389
|
[handleShow]
|
|
425
390
|
);
|
|
426
|
-
return /* @__PURE__ */ (0,
|
|
391
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(PromptModalContext.Provider, { value, children: [
|
|
427
392
|
props.children,
|
|
428
|
-
/* @__PURE__ */ (0,
|
|
429
|
-
/* @__PURE__ */ (0,
|
|
430
|
-
/* @__PURE__ */ (0,
|
|
431
|
-
|
|
393
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DialogProvider, { open, onOpenChange: (e) => setOpen(e.open), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Dialog, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx2.VStack, { gap: "xl", w: "full", children: [
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx2.VStack, { alignItems: "flex-start", gap: "md", w: "full", children: [
|
|
395
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
396
|
+
import_jsx2.HStack,
|
|
432
397
|
{
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
children: /* @__PURE__ */ (0,
|
|
398
|
+
alignSelf: "center",
|
|
399
|
+
justify: "center",
|
|
400
|
+
paddingBlockEnd: "md",
|
|
401
|
+
w: "full",
|
|
402
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
438
403
|
Show,
|
|
439
404
|
{
|
|
440
405
|
when: palette === "danger",
|
|
441
|
-
fallback: /* @__PURE__ */ (0,
|
|
406
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
442
407
|
Avatar,
|
|
443
408
|
{
|
|
444
409
|
ariaLabel: "",
|
|
445
410
|
gradient: "charon-light",
|
|
446
|
-
icon: /* @__PURE__ */ (0,
|
|
411
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PromptIcon, { size: 24 }),
|
|
447
412
|
src: ""
|
|
448
413
|
}
|
|
449
414
|
),
|
|
450
|
-
children: /* @__PURE__ */ (0,
|
|
415
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
451
416
|
Avatar,
|
|
452
417
|
{
|
|
453
418
|
ariaLabel: "",
|
|
454
419
|
gradient: "hades-dark",
|
|
455
|
-
icon: /* @__PURE__ */ (0,
|
|
420
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PromptIcon, { size: 24 }),
|
|
456
421
|
src: ""
|
|
457
422
|
}
|
|
458
423
|
)
|
|
@@ -460,43 +425,34 @@ function PromptModal(props) {
|
|
|
460
425
|
)
|
|
461
426
|
}
|
|
462
427
|
),
|
|
463
|
-
/* @__PURE__ */ (0,
|
|
464
|
-
/* @__PURE__ */ (0,
|
|
428
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DialogHeading, { children: content == null ? void 0 : content.heading }),
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DialogDescription, { children: content == null ? void 0 : content.description })
|
|
465
430
|
] }),
|
|
466
|
-
/* @__PURE__ */ (0,
|
|
467
|
-
|
|
431
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
432
|
+
import_jsx2.VStack,
|
|
468
433
|
{
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
434
|
+
alignItems: "flex-start",
|
|
435
|
+
marginBlockStart: "md",
|
|
436
|
+
marginBlockEnd: "lg",
|
|
437
|
+
w: "full",
|
|
438
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Field, { invalid: !isValid, children: [
|
|
439
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
476
440
|
Label,
|
|
477
441
|
{
|
|
478
|
-
className: (0,
|
|
479
|
-
gap:
|
|
480
|
-
|
|
442
|
+
className: (0, import_patterns3.hstack)({
|
|
443
|
+
gap: "xs",
|
|
444
|
+
justify: "flex-start !important"
|
|
481
445
|
}),
|
|
482
446
|
htmlFor: "confirm",
|
|
483
447
|
size: "md",
|
|
484
448
|
children: [
|
|
485
449
|
"Type",
|
|
486
|
-
/* @__PURE__ */ (0,
|
|
487
|
-
"strong",
|
|
488
|
-
{
|
|
489
|
-
className: (0, import_css9.css)({
|
|
490
|
-
textTransform: "uppercase"
|
|
491
|
-
}),
|
|
492
|
-
children: content == null ? void 0 : content.key
|
|
493
|
-
}
|
|
494
|
-
),
|
|
450
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { as: "strong", textTransform: "uppercase", children: content == null ? void 0 : content.key }),
|
|
495
451
|
"to confirm"
|
|
496
452
|
]
|
|
497
453
|
}
|
|
498
454
|
),
|
|
499
|
-
/* @__PURE__ */ (0,
|
|
455
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
500
456
|
Input,
|
|
501
457
|
{
|
|
502
458
|
id: "confirm",
|
|
@@ -508,50 +464,41 @@ function PromptModal(props) {
|
|
|
508
464
|
] })
|
|
509
465
|
}
|
|
510
466
|
),
|
|
511
|
-
/* @__PURE__ */ (0,
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
usage: "outlined",
|
|
543
|
-
value: "false",
|
|
544
|
-
children: content == null ? void 0 : content.cancelText
|
|
545
|
-
}
|
|
546
|
-
)
|
|
547
|
-
]
|
|
548
|
-
}
|
|
549
|
-
)
|
|
550
|
-
] }) })
|
|
467
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx2.HStack, { gap: "md", justify: "stretch", w: "full", children: [
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
469
|
+
Button,
|
|
470
|
+
{
|
|
471
|
+
autoFocus: true,
|
|
472
|
+
className: (0, import_css6.css)({
|
|
473
|
+
w: "1/2"
|
|
474
|
+
}),
|
|
475
|
+
disabled: !isValid,
|
|
476
|
+
name: "confirm",
|
|
477
|
+
onClick: handleChoice,
|
|
478
|
+
palette,
|
|
479
|
+
value: "true",
|
|
480
|
+
children: content == null ? void 0 : content.actionText
|
|
481
|
+
}
|
|
482
|
+
),
|
|
483
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react7.DialogCloseTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
484
|
+
Button,
|
|
485
|
+
{
|
|
486
|
+
className: (0, import_css6.css)({
|
|
487
|
+
w: "1/2"
|
|
488
|
+
}),
|
|
489
|
+
name: "cancel",
|
|
490
|
+
onClick: handleChoice,
|
|
491
|
+
usage: "outlined",
|
|
492
|
+
value: "false",
|
|
493
|
+
children: content == null ? void 0 : content.cancelText
|
|
494
|
+
}
|
|
495
|
+
) })
|
|
496
|
+
] })
|
|
497
|
+
] }) }) })
|
|
551
498
|
] });
|
|
552
499
|
}
|
|
553
500
|
function usePromptModal() {
|
|
554
|
-
const context = (0,
|
|
501
|
+
const context = (0, import_react6.useContext)(PromptModalContext);
|
|
555
502
|
if (context === null) {
|
|
556
503
|
throw new Error("usePromptModal must be used within a PromptModal Provider");
|
|
557
504
|
}
|