@pibit.ai/cure-design-system 0.6.9 → 0.6.11

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.
@@ -1,85 +1,89 @@
1
- import { jsx as e, jsxs as t, Fragment as k } from "react/jsx-runtime";
2
- import { ChevronDown as z } from "@untitledui/icons";
3
- import { useState as D, useRef as j } from "react";
4
- import { Disclosure as E, DisclosurePanel as F } from "react-aria-components";
5
- import { cx as a } from "../../utils/cn.js";
6
- import { IsolateFromAccordionGroup as I } from "./accordion.js";
7
- import { Toggle as P } from "../../primitives/toggle/toggle.js";
8
- import { ButtonUtility as R } from "../../primitives/button/button-utility.js";
9
- const K = ({
10
- showToggle: f = !0,
11
- title: o,
12
- description: x,
13
- icon: n,
14
- iconBgColor: g = "var(--color-bg-warning-secondary)",
15
- defaultExpanded: p = !1,
16
- isExpanded: u,
1
+ import { jsx as e, jsxs as o, Fragment as T } from "react/jsx-runtime";
2
+ import { ChevronDown as j } from "@untitledui/icons";
3
+ import { useControlledState as E } from "@react-stately/utils";
4
+ import { useRef as A, Children as D } from "react";
5
+ import { Disclosure as F, DisclosurePanel as I } from "react-aria-components";
6
+ import { cx as t } from "../../utils/cn.js";
7
+ import { IsolateFromAccordionGroup as P } from "./accordion.js";
8
+ import { Toggle as R } from "../../primitives/toggle/toggle.js";
9
+ import { ButtonUtility as S } from "../../primitives/button/button-utility.js";
10
+ const q = (s) => D.toArray(s).some((r) => r !== ""), O = ({
11
+ showToggle: s = !0,
12
+ title: r,
13
+ description: f,
14
+ icon: i,
15
+ iconBgColor: p = "var(--color-bg-warning-secondary)",
16
+ defaultExpanded: u = !1,
17
+ isExpanded: x,
17
18
  onExpandedChange: h,
18
- defaultToggled: v = !0,
19
- onToggle: i,
19
+ defaultToggled: b = !0,
20
+ isToggled: N,
21
+ onToggle: y,
22
+ toggleLabel: v,
23
+ isDisabled: a = !1,
20
24
  children: l,
21
- className: b,
22
- isToggleDisabled: N = !1
25
+ className: C,
26
+ isToggleDisabled: k = !1
23
27
  }) => {
24
- const [d, y] = D(v), c = j(null), C = (r) => {
25
- y(r), i == null || i(r);
26
- };
27
- return /* @__PURE__ */ e(I, { children: /* @__PURE__ */ e(
28
- E,
28
+ const [d, w] = E(N, b, y), c = A(null);
29
+ return /* @__PURE__ */ e(P, { children: /* @__PURE__ */ e(
30
+ F,
29
31
  {
30
- isExpanded: u,
31
- defaultExpanded: p,
32
+ isExpanded: x,
33
+ defaultExpanded: u,
32
34
  onExpandedChange: h,
33
- className: a("bg-white rounded-lg border border-[var(--color-border-secondary)]", b),
34
- children: ({ isExpanded: r, state: w }) => /* @__PURE__ */ t(k, { children: [
35
- /* @__PURE__ */ t(
35
+ isDisabled: a,
36
+ className: t("bg-primary rounded-lg border border-secondary", C),
37
+ children: ({ isExpanded: m, state: z }) => /* @__PURE__ */ o(T, { children: [
38
+ /* @__PURE__ */ o(
36
39
  "div",
37
40
  {
38
- className: "flex items-center gap-4 p-3 cursor-pointer",
39
- onClick: (s) => {
40
- var m;
41
- (m = c.current) != null && m.contains(s.target) || w.toggle();
41
+ className: t("flex items-center gap-4 p-3", a ? "cursor-not-allowed" : "cursor-pointer"),
42
+ onClick: (n) => {
43
+ var g;
44
+ a || (g = c.current) != null && g.contains(n.target) || z.toggle();
42
45
  },
43
46
  children: [
44
- /* @__PURE__ */ t("div", { className: "flex items-center gap-3 flex-1 min-w-0", children: [
45
- n && /* @__PURE__ */ e(
47
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-3 flex-1 min-w-0", children: [
48
+ i && /* @__PURE__ */ e(
46
49
  "div",
47
50
  {
48
51
  className: "flex items-center justify-center size-8 rounded-lg shrink-0",
49
- style: { backgroundColor: g },
50
- children: n
52
+ style: { backgroundColor: p },
53
+ children: i
51
54
  }
52
55
  ),
53
- /* @__PURE__ */ t("div", { className: "flex flex-col flex-1 min-w-0", children: [
54
- /* @__PURE__ */ e("p", { className: "text-[var(--color-text-secondary)] text-md font-medium leading-6", children: o }),
55
- /* @__PURE__ */ e("p", { className: "text-[var(--color-text-tertiary)] text-sm font-normal leading-5", children: x })
56
+ /* @__PURE__ */ o("div", { className: "flex flex-col flex-1 min-w-0", children: [
57
+ /* @__PURE__ */ e("p", { className: "text-secondary text-md font-medium leading-6", children: r }),
58
+ /* @__PURE__ */ e("p", { className: "text-tertiary text-sm font-normal leading-5", children: f })
56
59
  ] })
57
60
  ] }),
58
- /* @__PURE__ */ t("div", { className: "flex items-center gap-2 shrink-0", children: [
59
- f && /* @__PURE__ */ e("div", { onClick: (s) => s.stopPropagation(), children: /* @__PURE__ */ e(
60
- P,
61
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-2 shrink-0", children: [
62
+ s && /* @__PURE__ */ e("div", { onClick: (n) => n.stopPropagation(), children: /* @__PURE__ */ e(
63
+ R,
61
64
  {
62
65
  size: "sm",
66
+ "aria-label": v ?? `Enable ${r}`,
63
67
  isSelected: d,
64
- onChange: C,
65
- isDisabled: N,
68
+ onChange: w,
69
+ isDisabled: k,
66
70
  disabledClasses: d ? "bg-brand-solid" : ""
67
71
  }
68
72
  ) }),
69
73
  /* @__PURE__ */ e("div", { ref: c, className: "contents", children: /* @__PURE__ */ e(
70
- R,
74
+ S,
71
75
  {
72
76
  slot: "trigger",
73
77
  size: "xs",
74
78
  color: "tertiary",
75
- "aria-label": o,
79
+ "aria-label": r,
76
80
  icon: /* @__PURE__ */ e(
77
- z,
81
+ j,
78
82
  {
79
83
  size: 20,
80
- className: a(
81
- "text-[var(--color-text-quaternary)] transition-transform duration-200",
82
- r && "rotate-180"
84
+ className: t(
85
+ "text-quaternary transition-transform duration-200",
86
+ m && "rotate-180"
83
87
  )
84
88
  }
85
89
  )
@@ -89,11 +93,11 @@ const K = ({
89
93
  ]
90
94
  }
91
95
  ),
92
- l && /* @__PURE__ */ e(F, { className: "[&[hidden]]:hidden", children: /* @__PURE__ */ e("div", { className: a("px-3 pb-3 pt-3", r && "animate-in fade-in duration-200"), children: l }) })
96
+ q(l) && /* @__PURE__ */ e(I, { className: "[&[hidden]]:hidden", children: /* @__PURE__ */ e("div", { className: t("px-3 pb-3 pt-3", m && "animate-in fade-in duration-200"), children: l }) })
93
97
  ] })
94
98
  }
95
99
  ) });
96
100
  };
97
101
  export {
98
- K as ExpandableCard
102
+ O as ExpandableCard
99
103
  };
@@ -0,0 +1,3 @@
1
+ export { DialogTrigger, ModalOverlay, Modal, Dialog, type ModalOverlayProps, type ModalProps, type DialogProps, } from './modal';
2
+ export { ModalWrapper, type ModalWrapperProps } from './modal-wrapper';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/modal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,KAAK,EACL,MAAM,EACN,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { ReactNode } from 'react';
2
+ export interface ModalWrapperProps {
3
+ isOpen: boolean;
4
+ onClose: (isOpen: boolean) => void;
5
+ children: ReactNode;
6
+ /** When false, the backdrop/overlay (dim + blur) is hidden. Default true. */
7
+ showOverlay?: boolean;
8
+ /** When false, neither overlay clicks nor Escape close the modal. Default true. */
9
+ isDismissable?: boolean;
10
+ /** When true, allows clicking through the overlay to interact with background elements. Default false. */
11
+ allowBackgroundInteraction?: boolean;
12
+ /** When true, clicks on this modal won't trigger parent ClickAwayListener handlers. */
13
+ ignoreClickAway?: boolean;
14
+ /** Extra classes on the overlay (for example, canvas-centered workflow modals). */
15
+ overlayClassName?: string;
16
+ /** Child draws its own frame (e.g. Modal-md), so skip the default gradient frame. */
17
+ bare?: boolean;
18
+ /**
19
+ * Test id. Lands on the `role="dialog"` element in the standard modal, but on a plain `div` (no dialog role)
20
+ * when `allowBackgroundInteraction` is true.
21
+ */
22
+ "data-testid"?: string;
23
+ }
24
+ /**
25
+ * A modal shell: overlay, gradient frame and dismiss rules around content the caller lays out.
26
+ *
27
+ * @example
28
+ * <ModalWrapper isOpen={open} onClose={() => setOpen(false)}>
29
+ * <div className="w-[480px] rounded-xl bg-primary p-6">…</div>
30
+ * </ModalWrapper>
31
+ */
32
+ export declare const ModalWrapper: ({ isOpen, onClose, children, showOverlay, isDismissable, allowBackgroundInteraction, ignoreClickAway, overlayClassName, bare, "data-testid": dataTestId, }: ModalWrapperProps) => import("react/jsx-runtime").JSX.Element;
33
+ //# sourceMappingURL=modal-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-wrapper.d.ts","sourceRoot":"","sources":["../../../src/patterns/modal/modal-wrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA6BvC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,SAAS,CAAC;IACpB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mFAAmF;IACnF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0GAA0G;IAC1G,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,uFAAuF;IACvF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qFAAqF;IACrF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,4JAW1B,iBAAiB,4CA6DnB,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { useEffect as g } from "react";
3
+ import { DialogTrigger as h } from "react-aria-components";
4
+ import { cx as i } from "../../utils/cn.js";
5
+ import { ModalOverlay as y, Modal as v, Dialog as w } from "./modal.js";
6
+ const n = [];
7
+ let f = !1;
8
+ const E = () => {
9
+ f || typeof document > "u" || (document.addEventListener("keydown", (e) => {
10
+ if (e.key !== "Escape" || n.length === 0 || e.defaultPrevented) return;
11
+ const r = n[n.length - 1];
12
+ r();
13
+ }), f = !0);
14
+ }, M = ({
15
+ isOpen: e,
16
+ onClose: r,
17
+ children: c,
18
+ showOverlay: l = !0,
19
+ isDismissable: a = !0,
20
+ allowBackgroundInteraction: m = !1,
21
+ ignoreClickAway: u = !1,
22
+ overlayClassName: p,
23
+ bare: x = !1,
24
+ "data-testid": o
25
+ }) => (g(() => {
26
+ if (!e || !a) return;
27
+ E();
28
+ const s = () => r(!1);
29
+ return n.push(s), () => {
30
+ const d = n.lastIndexOf(s);
31
+ d >= 0 && n.splice(d, 1);
32
+ };
33
+ }, [e, a, r]), m && e ? /* @__PURE__ */ t(
34
+ "div",
35
+ {
36
+ className: "fixed inset-0 z-50 flex items-center justify-center",
37
+ style: {
38
+ pointerEvents: "none",
39
+ paddingLeft: "calc(var(--floating-modal-inset-left, 0px) + 16px)",
40
+ paddingRight: "16px"
41
+ },
42
+ children: /* @__PURE__ */ t("div", { className: "w-[max-content] max-w-full", style: { pointerEvents: "auto" }, "data-testid": o, children: c })
43
+ }
44
+ ) : /* @__PURE__ */ t(h, { isOpen: e, onOpenChange: r, children: /* @__PURE__ */ t(
45
+ y,
46
+ {
47
+ isDismissable: a,
48
+ isKeyboardDismissDisabled: !a,
49
+ ...u ? { "data-ignore-click-away": !0 } : {},
50
+ className: i(
51
+ "max-h-screen max-w-screen overflow-hidden z-100000 flex justify-center items-center",
52
+ !l && "bg-transparent! backdrop-blur-none!",
53
+ l && p
54
+ ),
55
+ children: /* @__PURE__ */ t(v, { className: i(!x && "modal-bg-gradient", "!w-[max-content]"), children: /* @__PURE__ */ t(w, { className: "!w-[max-content]", "data-testid": o, children: c }) })
56
+ }
57
+ ) }));
58
+ export {
59
+ M as ModalWrapper
60
+ };
@@ -0,0 +1,13 @@
1
+ import { DialogProps as AriaDialogProps, ModalOverlayProps as AriaModalOverlayProps, DialogTrigger as AriaDialogTrigger } from 'react-aria-components';
2
+ export type ModalOverlayProps = AriaModalOverlayProps;
3
+ export type ModalProps = AriaModalOverlayProps;
4
+ export type DialogProps = AriaDialogProps;
5
+ /** Opens a `ModalOverlay` from a trigger, or holds it open through `isOpen` / `onOpenChange`. */
6
+ export declare const DialogTrigger: typeof AriaDialogTrigger;
7
+ /** The full-screen backdrop: dims and blurs the page and centres its `Modal`. */
8
+ export declare const ModalOverlay: (props: ModalOverlayProps) => import("react/jsx-runtime").JSX.Element;
9
+ /** The modal surface inside a `ModalOverlay`. */
10
+ export declare const Modal: (props: ModalProps) => import("react/jsx-runtime").JSX.Element;
11
+ /** The `role="dialog"` element inside a `Modal`. Give it an `aria-label` or a heading with `slot="title"`. */
12
+ export declare const Dialog: (props: DialogProps) => import("react/jsx-runtime").JSX.Element;
13
+ //# sourceMappingURL=modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/patterns/modal/modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,IAAI,eAAe,EAC9B,iBAAiB,IAAI,qBAAqB,EAC3C,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,aAAa,IAAI,iBAAiB,EAGnC,MAAM,uBAAuB,CAAC;AAU/B,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AACtD,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAC/C,MAAM,MAAM,WAAW,GAAG,eAAe,CAAC;AAE1C,iGAAiG;AACjG,eAAO,MAAM,aAAa,0BAAoB,CAAC;AAE/C,iFAAiF;AACjF,eAAO,MAAM,YAAY,GAAI,OAAO,iBAAiB,4CAcpD,CAAC;AAEF,iDAAiD;AACjD,eAAO,MAAM,KAAK,GAAI,OAAO,UAAU,4CAYtC,CAAC;AAEF,8GAA8G;AAC9G,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,4CAExC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { DialogTrigger as o, ModalOverlay as n, Modal as t, Dialog as s } from "react-aria-components";
3
+ import { cx as l } from "../../utils/cn.js";
4
+ const d = o, c = (a) => /* @__PURE__ */ i(
5
+ n,
6
+ {
7
+ ...a,
8
+ className: (e) => l(
9
+ "fixed inset-0 z-50 flex min-h-dvh w-full items-end justify-center overflow-y-auto bg-overlay/70 px-4 pt-4 pb-[clamp(16px,8vh,64px)] outline-hidden backdrop-blur-[8px] sm:items-center sm:justify-center sm:p-8",
10
+ e.isEntering && "duration-300 ease-out animate-in fade-in",
11
+ e.isExiting && "duration-200 ease-in animate-out fade-out",
12
+ typeof a.className == "function" ? a.className(e) : a.className
13
+ )
14
+ }
15
+ ), f = (a) => /* @__PURE__ */ i(
16
+ t,
17
+ {
18
+ ...a,
19
+ className: (e) => l(
20
+ "max-h-full w-full align-middle outline-hidden max-sm:overflow-y-auto max-sm:rounded-xl",
21
+ e.isEntering && "duration-300 ease-out animate-in zoom-in-95",
22
+ e.isExiting && "duration-200 ease-in animate-out zoom-out-95",
23
+ typeof a.className == "function" ? a.className(e) : a.className
24
+ )
25
+ }
26
+ ), g = (a) => /* @__PURE__ */ i(s, { ...a, className: l("flex w-full items-center justify-center outline-hidden", a.className) });
27
+ export {
28
+ g as Dialog,
29
+ d as DialogTrigger,
30
+ f as Modal,
31
+ c as ModalOverlay
32
+ };