@konstructio/ui 0.1.2-alpha.116 → 0.1.2-alpha.118

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.
@@ -0,0 +1,84 @@
1
+ import { t as A } from "./x-Vur_9PXW.js";
2
+ import { t as H } from "./dist-C_jtUTU9.js";
3
+ import { t as h } from "./utils-DnIJruo0.js";
4
+ import { t as x } from "./Combination-CnMM05mt.js";
5
+ import { Body as B } from "./components/Modal/components/Body/Body.js";
6
+ import { Footer as C } from "./components/Modal/components/Footer/Footer.js";
7
+ import { Header as E } from "./components/Modal/components/Header/Header.js";
8
+ import { t as R } from "./es2015-B_07N-UL.js";
9
+ import { buttonCloseVariants as V, modalVariants as j } from "./components/Modal/components/Wrapper/Wrapper.variants.js";
10
+ import { Children as d, isValidElement as l, useEffect as g, useRef as D, useState as S } from "react";
11
+ import { createPortal as z } from "react-dom";
12
+ import { Fragment as I, jsx as a, jsxs as m } from "react/jsx-runtime";
13
+ import { motion as K } from "motion/react";
14
+ var L = ({ animateResize: c = !1, ariaLabel: n, ariaLabelledBy: s, autoFocus: i = !0, buttonCloseClassName: f, children: r, className: u, containerClassName: p, showCloseButton: o = !0, theme: y, transition: b, onClose: v }) => {
15
+ const F = d.toArray(r).find((e) => l(e) && e.type === t.Header), N = d.toArray(r).find((e) => l(e) && e.type === t.Body), k = d.toArray(r).find((e) => l(e) && e.type === t.Footer), w = d.toArray(r).filter((e) => !l(e) || ![
16
+ t.Header,
17
+ t.Body,
18
+ t.Footer
19
+ ].includes(e.type));
20
+ return /* @__PURE__ */ a(x, { children: /* @__PURE__ */ m("div", {
21
+ className: h("fixed inset-0 grid place-content-center", p),
22
+ "data-theme": y,
23
+ children: [/* @__PURE__ */ a("div", {
24
+ className: "absolute inset-0 bg-black opacity-70 dark:opacity-85 animate-in fade-in-0",
25
+ onClick: v,
26
+ role: "presentation"
27
+ }), /* @__PURE__ */ a(R, {
28
+ returnFocus: !0,
29
+ autoFocus: i,
30
+ className: "contents",
31
+ children: /* @__PURE__ */ m(K.div, {
32
+ className: h(j({ className: u })),
33
+ role: "dialog",
34
+ "aria-modal": "true",
35
+ "aria-label": n,
36
+ "aria-labelledby": s,
37
+ layout: c ? "size" : void 0,
38
+ transition: b ?? {
39
+ duration: 0.25,
40
+ ease: "easeInOut"
41
+ },
42
+ children: [
43
+ F,
44
+ o && /* @__PURE__ */ m("button", {
45
+ className: h(V({ className: f })),
46
+ onClick: v,
47
+ children: [/* @__PURE__ */ a(A, {}), /* @__PURE__ */ a(H, { children: "Dismiss modal" })]
48
+ }),
49
+ N ?? w,
50
+ k
51
+ ]
52
+ })
53
+ })]
54
+ }) });
55
+ }, t = ({ isOpen: c, onClose: n, container: s, theme: i, ...f }) => {
56
+ const r = D(null), [u, p] = S(null);
57
+ return g(() => {
58
+ if (!r.current || i || s) return;
59
+ const o = r.current.closest("[data-theme]");
60
+ o && p(o);
61
+ }, [i, s]), g(() => {
62
+ const o = new AbortController(), y = (b) => {
63
+ b.code === "Escape" && n?.();
64
+ };
65
+ return window.addEventListener("keydown", y, { signal: o.signal }), () => {
66
+ o.abort();
67
+ };
68
+ }, [n]), /* @__PURE__ */ m(I, { children: [/* @__PURE__ */ a("span", {
69
+ ref: r,
70
+ "data-testid": "modal-anchor",
71
+ hidden: !0
72
+ }), c && z(/* @__PURE__ */ a(L, {
73
+ ...f,
74
+ theme: i,
75
+ onClose: n
76
+ }), s || u || document.body)] });
77
+ };
78
+ t.Header = E;
79
+ t.Body = B;
80
+ t.Footer = C;
81
+ export {
82
+ L as n,
83
+ t
84
+ };
@@ -1,43 +1,44 @@
1
- import { t as H } from "../../Input-2M2I_H60.js";
1
+ import { t as K } from "../../Input-2M2I_H60.js";
2
2
  import { t as g } from "../../utils-DnIJruo0.js";
3
- import { WarningIcon as K } from "../../assets/icons/components/Warning.js";
3
+ import { WarningIcon as T } from "../../assets/icons/components/Warning.js";
4
4
  import { Button as C } from "../Button/Button.js";
5
5
  import { Typography as d } from "../Typography/Typography.js";
6
- import { CopyButton as T } from "../CopyButton/CopyButton.js";
7
- import { t as l } from "../../Modal-CysTe3zL.js";
8
- import { useEffect as V, useId as W, useState as A } from "react";
9
- import { Fragment as G, jsx as e, jsxs as r } from "react/jsx-runtime";
10
- var J = ({ cancelLabel: N = "Cancel", children: v, className: k, confirmationInputClassName: I, confirmationInputLabel: w, confirmationPrompt: B, confirmationText: a, confirmLabel: n = "Confirm", containerClassName: j, copyLabel: D = "Copy", description: i, icon: c, isOpen: o, isPending: t = !1, pendingLabel: F, theme: S, title: $, variant: f = "danger", onClose: M, onConfirm: q }) => {
11
- const s = W(), p = `${s}-title`, [u, h] = A(""), x = !!a, y = !x || u === a;
12
- V(() => {
6
+ import { CopyButton as V } from "../CopyButton/CopyButton.js";
7
+ import { t as l } from "../../Modal-0Wp5szX4.js";
8
+ import { useEffect as W, useId as A, useState as G } from "react";
9
+ import { Fragment as J, jsx as e, jsxs as r } from "react/jsx-runtime";
10
+ var L = ({ autoFocus: N, cancelLabel: v = "Cancel", children: k, className: I, confirmationInputClassName: w, confirmationInputLabel: B, confirmationPrompt: j, confirmationText: a, confirmLabel: n = "Confirm", containerClassName: D, copyLabel: F = "Copy", description: i, icon: c, isOpen: o, isPending: t = !1, pendingLabel: S, theme: $, title: M, variant: f = "danger", onClose: q, onConfirm: z }) => {
11
+ const s = A(), p = `${s}-title`, [u, h] = G(""), x = !!a, y = !x || u === a;
12
+ W(() => {
13
13
  o && h("");
14
14
  }, [o]);
15
15
  const b = () => {
16
- t || M();
17
- }, z = (m) => {
18
- m.preventDefault(), !(t || !y) && q();
19
- }, E = c === void 0 ? /* @__PURE__ */ e(K, {
16
+ t || q();
17
+ }, E = (m) => {
18
+ m.preventDefault(), !(t || !y) && z();
19
+ }, H = c === void 0 ? /* @__PURE__ */ e(T, {
20
20
  size: 24,
21
21
  "aria-hidden": "true",
22
22
  className: g("shrink-0", f === "danger" ? "text-red-600 dark:text-red-500" : "text-aurora-500")
23
23
  }) : c;
24
24
  return /* @__PURE__ */ e(l, {
25
25
  isOpen: o,
26
- theme: S,
26
+ theme: $,
27
+ autoFocus: N,
27
28
  showCloseButton: !1,
28
29
  ariaLabelledBy: p,
29
- containerClassName: j,
30
- className: g("max-w-125 min-h-0 min-w-0 gap-0 p-6", k),
30
+ containerClassName: D,
31
+ className: g("max-w-125 min-h-0 min-w-0 gap-0 p-6", I),
31
32
  onClose: b,
32
33
  children: /* @__PURE__ */ r("form", {
33
34
  id: s,
34
35
  noValidate: !0,
35
36
  className: "flex flex-col gap-6",
36
- onSubmit: z,
37
+ onSubmit: E,
37
38
  children: [
38
39
  /* @__PURE__ */ r(l.Header, {
39
40
  className: "flex items-start gap-4",
40
- children: [E, /* @__PURE__ */ r("div", {
41
+ children: [H, /* @__PURE__ */ r("div", {
41
42
  className: "flex min-w-0 flex-1 flex-col gap-4",
42
43
  children: [
43
44
  /* @__PURE__ */ e(d, {
@@ -45,14 +46,14 @@ var J = ({ cancelLabel: N = "Cancel", children: v, className: k, confirmationInp
45
46
  variant: "subtitle3",
46
47
  component: "h2",
47
48
  className: "text-slate-800 dark:text-slate-200",
48
- children: $
49
+ children: M
49
50
  }),
50
51
  i ? /* @__PURE__ */ e(d, {
51
52
  variant: "body2",
52
53
  className: "text-slate-700 dark:text-slate-50",
53
54
  children: i
54
55
  }) : null,
55
- v
56
+ k
56
57
  ]
57
58
  })]
58
59
  }),
@@ -62,23 +63,23 @@ var J = ({ cancelLabel: N = "Cancel", children: v, className: k, confirmationInp
62
63
  variant: "body2",
63
64
  component: "p",
64
65
  className: "flex flex-wrap items-center gap-1 font-medium text-slate-800 dark:text-metal-50",
65
- children: B ?? /* @__PURE__ */ r(G, { children: [
66
+ children: j ?? /* @__PURE__ */ r(J, { children: [
66
67
  "Type",
67
- /* @__PURE__ */ e(T, {
68
+ /* @__PURE__ */ e(V, {
68
69
  text: a,
69
70
  label: a,
70
- copyLabel: D,
71
+ copyLabel: F,
71
72
  className: "rounded-xs border border-gray-200 bg-gray-50 px-1 py-0.5 font-medium hover:bg-gray-100 dark:border-metal-700 dark:bg-metal-700 dark:hover:bg-metal-600",
72
73
  children: a
73
74
  }),
74
75
  "to confirm"
75
76
  ] })
76
- }), /* @__PURE__ */ e(H, {
77
+ }), /* @__PURE__ */ e(K, {
77
78
  value: u,
78
79
  autoComplete: "off",
79
80
  disabled: t,
80
- className: I,
81
- "aria-label": w ?? `Type ${a} to confirm`,
81
+ className: w,
82
+ "aria-label": B ?? `Type ${a} to confirm`,
82
83
  onChange: (m) => {
83
84
  h(m.target.value);
84
85
  }
@@ -91,20 +92,20 @@ var J = ({ cancelLabel: N = "Cancel", children: v, className: k, confirmationInp
91
92
  variant: "secondary",
92
93
  disabled: t,
93
94
  onClick: b,
94
- children: N
95
+ children: v
95
96
  }), /* @__PURE__ */ e(C, {
96
97
  type: "submit",
97
98
  form: s,
98
99
  variant: f,
99
100
  disabled: t || !y,
100
- children: t ? F ?? n : n
101
+ children: t ? S ?? n : n
101
102
  })]
102
103
  })
103
104
  ]
104
105
  })
105
106
  });
106
107
  };
107
- J.displayName = "KonstructConfirmDialog";
108
+ L.displayName = "KonstructConfirmDialog";
108
109
  export {
109
- J as ConfirmDialog
110
+ L as ConfirmDialog
110
111
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { t } from "../../Modal-CysTe3zL.js";
2
+ import { t } from "../../Modal-0Wp5szX4.js";
3
3
  export {
4
4
  t as Modal
5
5
  };
@@ -1,4 +1,4 @@
1
- import { n as p } from "../../../../Modal-CysTe3zL.js";
1
+ import { n as p } from "../../../../Modal-0Wp5szX4.js";
2
2
  export {
3
3
  p as Wrapper
4
4
  };
@@ -1,7 +1,7 @@
1
1
  import { Body as o } from "./Body/Body.js";
2
2
  import { Footer as p } from "./Footer/Footer.js";
3
3
  import { Header as e } from "./Header/Header.js";
4
- import { n as i } from "../../../Modal-CysTe3zL.js";
4
+ import { n as i } from "../../../Modal-0Wp5szX4.js";
5
5
  export {
6
6
  o as Body,
7
7
  p as Footer,
@@ -19,7 +19,7 @@ import { Card as _ } from "./Card/Card.js";
19
19
  import { CheckboxCard as y } from "./CheckboxCard/CheckboxCard.js";
20
20
  import { Collapse as M } from "./Collapse/Collapse.js";
21
21
  import { CopyButton as z } from "./CopyButton/CopyButton.js";
22
- import { t as W } from "../Modal-CysTe3zL.js";
22
+ import { t as W } from "../Modal-0Wp5szX4.js";
23
23
  import { ConfirmDialog as j } from "./ConfirmDialog/ConfirmDialog.js";
24
24
  import { DatePicker as H } from "./Datepicker/DatePicker.js";
25
25
  import { Radio as K } from "./Radio/Radio.js";
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import { Card as X } from "./components/Card/Card.js";
24
24
  import { CheckboxCard as q } from "./components/CheckboxCard/CheckboxCard.js";
25
25
  import { Collapse as K } from "./components/Collapse/Collapse.js";
26
26
  import { CopyButton as Z } from "./components/CopyButton/CopyButton.js";
27
- import { t as rr } from "./Modal-CysTe3zL.js";
27
+ import { t as rr } from "./Modal-0Wp5szX4.js";
28
28
  import { ConfirmDialog as tr } from "./components/ConfirmDialog/ConfirmDialog.js";
29
29
  import { DatePicker as ir } from "./components/Datepicker/DatePicker.js";
30
30
  import { Radio as er } from "./components/Radio/Radio.js";
@@ -2,6 +2,8 @@ import { ReactNode } from 'react';
2
2
  import { Theme } from '../../domain/theme';
3
3
  import { Props as ButtonProps } from '../Button/Button.types';
4
4
  export type Props = {
5
+ /** Move focus to the first focusable element when the dialog opens. Defaults to true */
6
+ autoFocus?: boolean;
5
7
  /** Label of the cancel button */
6
8
  cancelLabel?: ReactNode;
7
9
  /** Extra content rendered below the description, e.g. an Alert */
@@ -19,8 +19,12 @@ import { modalVariants } from './components/Wrapper/Wrapper.variants';
19
19
  */
20
20
  export type Props = PropsWithChildren & VariantProps<typeof modalVariants> & {
21
21
  /** CSS classes for the close button */
22
+ /** Animate height changes of the content, e.g. when a step is swapped. Defaults to false */
23
+ animateResize?: boolean;
22
24
  ariaLabel?: string;
23
25
  ariaLabelledBy?: string;
26
+ /** Move focus to the first focusable element when the modal opens. Defaults to true */
27
+ autoFocus?: boolean;
24
28
  buttonCloseClassName?: string;
25
29
  /** Additional CSS classes for the modal */
26
30
  className?: string;
@@ -34,7 +38,7 @@ export type Props = PropsWithChildren & VariantProps<typeof modalVariants> & {
34
38
  showCloseButton?: boolean;
35
39
  /** Theme override for this component */
36
40
  theme?: Theme;
37
- /** Motion transition config for the modal animation */
41
+ /** Motion transition used when `animateResize` is enabled */
38
42
  transition?: Transition;
39
43
  /** Callback when modal is closed (Escape key or close button) */
40
44
  onClose?: () => void;
@@ -4,8 +4,10 @@ import { PropsWithChildren } from 'react';
4
4
  import { Theme } from '../../../../domain/theme';
5
5
  import { modalVariants } from './Wrapper.variants';
6
6
  export type Props = PropsWithChildren & VariantProps<typeof modalVariants> & {
7
+ animateResize?: boolean;
7
8
  ariaLabel?: string;
8
9
  ariaLabelledBy?: string;
10
+ autoFocus?: boolean;
9
11
  buttonCloseClassName?: string;
10
12
  className?: string;
11
13
  containerClassName?: string;
package/dist/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@konstructio/ui",
3
3
  "description": "A set of reusable and customizable React components built for konstruct.io",
4
4
  "private": false,
5
- "version": "0.1.2-alpha.115",
5
+ "version": "0.1.2-alpha.117",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@konstructio/ui",
3
3
  "description": "A set of reusable and customizable React components built for konstruct.io",
4
4
  "private": false,
5
- "version": "0.1.2-alpha.116",
5
+ "version": "0.1.2-alpha.118",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",
@@ -1,83 +0,0 @@
1
- import { t as k } from "./x-Vur_9PXW.js";
2
- import { t as w } from "./dist-C_jtUTU9.js";
3
- import { t as h } from "./utils-DnIJruo0.js";
4
- import { t as A } from "./Combination-CnMM05mt.js";
5
- import { Body as H } from "./components/Modal/components/Body/Body.js";
6
- import { Footer as x } from "./components/Modal/components/Footer/Footer.js";
7
- import { Header as B } from "./components/Modal/components/Header/Header.js";
8
- import { t as C } from "./es2015-B_07N-UL.js";
9
- import { buttonCloseVariants as E, modalVariants as R } from "./components/Modal/components/Wrapper/Wrapper.variants.js";
10
- import { Children as l, isValidElement as m, useEffect as g, useRef as V, useState as j } from "react";
11
- import { createPortal as D } from "react-dom";
12
- import { Fragment as S, jsx as a, jsxs as c } from "react/jsx-runtime";
13
- import { motion as z } from "motion/react";
14
- var I = ({ ariaLabel: f, ariaLabelledBy: n, buttonCloseClassName: s, children: r, className: p, containerClassName: i, showCloseButton: u = !0, theme: y, transition: o, onClose: d }) => {
15
- const b = l.toArray(r).find((e) => m(e) && e.type === t.Header), v = l.toArray(r).find((e) => m(e) && e.type === t.Body), F = l.toArray(r).find((e) => m(e) && e.type === t.Footer), N = l.toArray(r).filter((e) => !m(e) || ![
16
- t.Header,
17
- t.Body,
18
- t.Footer
19
- ].includes(e.type));
20
- return /* @__PURE__ */ a(A, { children: /* @__PURE__ */ c("div", {
21
- className: h("fixed inset-0 grid place-content-center", i),
22
- "data-theme": y,
23
- children: [/* @__PURE__ */ a("div", {
24
- className: "absolute inset-0 bg-black opacity-70 dark:opacity-85 animate-in fade-in-0",
25
- onClick: d,
26
- role: "presentation"
27
- }), /* @__PURE__ */ a(C, {
28
- returnFocus: !0,
29
- className: "contents",
30
- children: /* @__PURE__ */ c(z.div, {
31
- className: h(R({ className: p })),
32
- role: "dialog",
33
- "aria-modal": "true",
34
- "aria-label": f,
35
- "aria-labelledby": n,
36
- layout: "size",
37
- transition: o ?? {
38
- duration: 0.25,
39
- ease: "easeInOut"
40
- },
41
- children: [
42
- b,
43
- u && /* @__PURE__ */ c("button", {
44
- className: h(E({ className: s })),
45
- onClick: d,
46
- children: [/* @__PURE__ */ a(k, {}), /* @__PURE__ */ a(w, { children: "Dismiss modal" })]
47
- }),
48
- v ?? N,
49
- F
50
- ]
51
- })
52
- })]
53
- }) });
54
- }, t = ({ isOpen: f, onClose: n, container: s, theme: r, ...p }) => {
55
- const i = V(null), [u, y] = j(null);
56
- return g(() => {
57
- if (!i.current || r || s) return;
58
- const o = i.current.closest("[data-theme]");
59
- o && y(o);
60
- }, [r, s]), g(() => {
61
- const o = new AbortController(), d = (b) => {
62
- b.code === "Escape" && n?.();
63
- };
64
- return window.addEventListener("keydown", d, { signal: o.signal }), () => {
65
- o.abort();
66
- };
67
- }, [n]), /* @__PURE__ */ c(S, { children: [/* @__PURE__ */ a("span", {
68
- ref: i,
69
- "data-testid": "modal-anchor",
70
- hidden: !0
71
- }), f && D(/* @__PURE__ */ a(I, {
72
- ...p,
73
- theme: r,
74
- onClose: n
75
- }), s || u || document.body)] });
76
- };
77
- t.Header = B;
78
- t.Body = H;
79
- t.Footer = x;
80
- export {
81
- I as n,
82
- t
83
- };