@agentero/design-system 0.23.4 → 0.23.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentero/design-system",
3
- "version": "0.23.4",
3
+ "version": "0.23.5",
4
4
  "description": "A React component library built with Tailwind CSS v4 and Radix UI primitives",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -3,6 +3,7 @@ import { VariantProps } from 'tailwind-variants';
3
3
  import * as DialogPrimitive from '@radix-ui/react-dialog';
4
4
  type RootProps = ComponentProps<typeof DialogPrimitive.Root>;
5
5
  type TriggerProps = ComponentProps<typeof DialogPrimitive.Trigger>;
6
+ type ModalVariant = 'dialog' | 'alert';
6
7
  export declare const modalRecipe: import('tailwind-variants').TVReturnType<{
7
8
  size: {
8
9
  md: {
@@ -56,6 +57,14 @@ type ContentProps = ComponentProps<typeof DialogPrimitive.Content> & {
56
57
  * Both shrink to the viewport on small screens.
57
58
  */
58
59
  size?: ModalVariants['size'];
60
+ /**
61
+ * `'dialog'` (default) is dismissable: `Escape`, an overlay click, and the
62
+ * X button in `Modal.Title` all close it. `'alert'` removes all three, so
63
+ * the only way out is one of the buttons in `Modal.Footer`, and exposes
64
+ * `role="alertdialog"` to assistive technology. Use it when dismissing
65
+ * without choosing would leave the user stuck or lose their work.
66
+ */
67
+ variant?: ModalVariant;
59
68
  };
60
69
  type TitleProps = ComponentProps<typeof DialogPrimitive.Title>;
61
70
  type BodyProps = ComponentProps<'div'>;
@@ -72,6 +81,10 @@ type CloseProps = ComponentProps<typeof DialogPrimitive.Close>;
72
81
  * (right-aligned actions). Open it controlled (`open`/`onOpenChange`) or via
73
82
  * `Trigger`; close from inside with `Close asChild` around your cancel button.
74
83
  *
84
+ * For a modal the user has to answer, pass `variant="alert"` to `Content`:
85
+ * `Escape`, the overlay click and the X button all stop closing it, and it is
86
+ * announced as an `alertdialog`.
87
+ *
75
88
  * @summary Compound modal dialog over a dimmed overlay
76
89
  *
77
90
  * @example
@@ -90,6 +103,20 @@ type CloseProps = ComponentProps<typeof DialogPrimitive.Close>;
90
103
  * </Modal.Root>
91
104
  * ```
92
105
  *
106
+ * @example
107
+ * ```tsx
108
+ * // Alert: no Escape, no overlay click, no X — the user must answer.
109
+ * <Modal.Root open={isOpen}>
110
+ * <Modal.Content variant="alert">
111
+ * <Modal.Title>Complete your Docusign integration</Modal.Title>
112
+ * <Modal.Body>Authorize access to finish connecting your account.</Modal.Body>
113
+ * <Modal.Footer>
114
+ * <Button onClick={handleAuthorize}>Authorize</Button>
115
+ * </Modal.Footer>
116
+ * </Modal.Content>
117
+ * </Modal.Root>
118
+ * ```
119
+ *
93
120
  * @component
94
121
  * @namespace Modal
95
122
  */
@@ -103,7 +130,7 @@ export declare const Modal: {
103
130
  displayName: string;
104
131
  };
105
132
  Content: {
106
- ({ className, size, children, ...props }: ContentProps): import("react/jsx-runtime").JSX.Element;
133
+ ({ className, size, variant, children, onEscapeKeyDown, onPointerDownOutside, ...props }: ContentProps): import("react/jsx-runtime").JSX.Element;
107
134
  displayName: string;
108
135
  };
109
136
  Title: {
@@ -4,19 +4,20 @@ import { Button as t } from "../button/button.js";
4
4
  import { IconClose as n } from "./icons.js";
5
5
  import { tv as r } from "tailwind-variants";
6
6
  import { jsx as i, jsxs as a } from "react/jsx-runtime";
7
- import * as o from "@radix-ui/react-dialog";
7
+ import { createContext as o, useContext as s } from "react";
8
+ import * as c from "@radix-ui/react-dialog";
8
9
  //#region src/modal/modal.tsx
9
- var s = (e) => /* @__PURE__ */ i(o.Root, {
10
+ var l = (e) => /* @__PURE__ */ i(c.Root, {
10
11
  "data-slot": "modal-root",
11
12
  ...e
12
13
  });
13
- s.displayName = "Modal.Root";
14
- var c = (e) => /* @__PURE__ */ i(o.Trigger, {
14
+ l.displayName = "Modal.Root";
15
+ var u = (e) => /* @__PURE__ */ i(c.Trigger, {
15
16
  "data-slot": "modal-trigger",
16
17
  ...e
17
18
  });
18
- c.displayName = "Modal.Trigger";
19
- var l = r({
19
+ u.displayName = "Modal.Trigger";
20
+ var d = o("dialog"), f = r({
20
21
  slots: {
21
22
  overlay: [
22
23
  "fixed inset-0 z-(--z-index-overlay) bg-overlay-dark-300",
@@ -39,64 +40,77 @@ var l = r({
39
40
  lg: { content: "max-w-[45rem]" }
40
41
  } },
41
42
  defaultVariants: { size: "md" }
42
- }), u = l(), d = ({ className: t, size: n, children: r, ...s }) => {
43
- let c = l({ size: n });
44
- return /* @__PURE__ */ a(o.Portal, { children: [/* @__PURE__ */ i(o.Overlay, {
45
- "data-slot": "modal-overlay",
46
- className: c.overlay()
47
- }), /* @__PURE__ */ i(o.Content, {
48
- "data-slot": "modal-content",
49
- "aria-describedby": void 0,
50
- className: e(c.content(), t),
51
- ...s,
52
- children: r
53
- })] });
43
+ }), p = f(), m = ({ className: t, size: n, variant: r = "dialog", children: o, onEscapeKeyDown: s, onPointerDownOutside: l, ...u }) => {
44
+ let p = f({ size: n }), m = r === "alert";
45
+ return /* @__PURE__ */ i(d.Provider, {
46
+ value: r,
47
+ children: /* @__PURE__ */ a(c.Portal, { children: [/* @__PURE__ */ i(c.Overlay, {
48
+ "data-slot": "modal-overlay",
49
+ className: p.overlay()
50
+ }), /* @__PURE__ */ i(c.Content, {
51
+ "data-slot": "modal-content",
52
+ role: m ? "alertdialog" : "dialog",
53
+ "aria-describedby": void 0,
54
+ className: e(p.content(), t),
55
+ onEscapeKeyDown: (e) => {
56
+ s?.(e), m && e.preventDefault();
57
+ },
58
+ onPointerDownOutside: (e) => {
59
+ l?.(e), m && e.preventDefault();
60
+ },
61
+ ...u,
62
+ children: o
63
+ })] })
64
+ });
54
65
  };
55
- d.displayName = "Modal.Content";
56
- var f = ({ className: e, children: r, ...s }) => /* @__PURE__ */ a("div", {
57
- "data-slot": "modal-title",
58
- className: u.title({ className: e }),
59
- children: [/* @__PURE__ */ i(o.Title, {
60
- ...s,
61
- children: r
62
- }), /* @__PURE__ */ i(o.Close, {
63
- asChild: !0,
64
- children: /* @__PURE__ */ i(t, {
65
- variant: "ghost",
66
- size: "sm",
67
- "aria-label": "Close",
68
- className: "-my-2 -mr-6 shrink-0",
69
- children: /* @__PURE__ */ i(n, {})
70
- })
71
- })]
72
- });
73
- f.displayName = "Modal.Title";
74
- var p = ({ className: e, ...t }) => /* @__PURE__ */ i("div", {
66
+ m.displayName = "Modal.Content";
67
+ var h = ({ className: e, children: r, ...o }) => {
68
+ let l = s(d);
69
+ return /* @__PURE__ */ a("div", {
70
+ "data-slot": "modal-title",
71
+ className: p.title({ className: e }),
72
+ children: [/* @__PURE__ */ i(c.Title, {
73
+ ...o,
74
+ children: r
75
+ }), l === "dialog" && /* @__PURE__ */ i(c.Close, {
76
+ asChild: !0,
77
+ children: /* @__PURE__ */ i(t, {
78
+ variant: "ghost",
79
+ size: "sm",
80
+ "aria-label": "Close",
81
+ className: "-my-2 -mr-6 shrink-0",
82
+ children: /* @__PURE__ */ i(n, {})
83
+ })
84
+ })]
85
+ });
86
+ };
87
+ h.displayName = "Modal.Title";
88
+ var g = ({ className: e, ...t }) => /* @__PURE__ */ i("div", {
75
89
  "data-slot": "modal-body",
76
90
  tabIndex: 0,
77
- className: u.body({ className: e }),
91
+ className: p.body({ className: e }),
78
92
  ...t
79
93
  });
80
- p.displayName = "Modal.Body";
81
- var m = ({ className: e, ...t }) => /* @__PURE__ */ i("div", {
94
+ g.displayName = "Modal.Body";
95
+ var _ = ({ className: e, ...t }) => /* @__PURE__ */ i("div", {
82
96
  "data-slot": "modal-footer",
83
- className: u.footer({ className: e }),
97
+ className: p.footer({ className: e }),
84
98
  ...t
85
99
  });
86
- m.displayName = "Modal.Footer";
87
- var h = (e) => /* @__PURE__ */ i(o.Close, {
100
+ _.displayName = "Modal.Footer";
101
+ var v = (e) => /* @__PURE__ */ i(c.Close, {
88
102
  "data-slot": "modal-close",
89
103
  ...e
90
104
  });
91
- h.displayName = "Modal.Close";
92
- var g = {
93
- Root: s,
94
- Trigger: c,
95
- Content: d,
96
- Title: f,
97
- Body: p,
98
- Footer: m,
99
- Close: h
105
+ v.displayName = "Modal.Close";
106
+ var y = {
107
+ Root: l,
108
+ Trigger: u,
109
+ Content: m,
110
+ Title: h,
111
+ Body: g,
112
+ Footer: _,
113
+ Close: v
100
114
  };
101
115
  //#endregion
102
- export { g as Modal, l as modalRecipe };
116
+ export { y as Modal, f as modalRecipe };