@konstructio/ui 0.1.2-alpha.50 → 0.1.2-alpha.52

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,55 +1,60 @@
1
1
  import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { R as j, A as T, P as w, O as K, C as P, T as z, D as B, a as E, b as S } from "../../index-D6KzX_ef.js";
3
- import { useRef as q, useState as F, useEffect as G } from "react";
4
- import { Button as s } from "../Button/Button.js";
2
+ import { R as K, A as P, P as z, O as B, C as E, T as S, D as q, a as F, b as G } from "../../index-BqhYevy7.js";
3
+ import { useRef as H, useState as I, useEffect as J } from "react";
4
+ import { Button as i } from "../Button/Button.js";
5
5
  import { cn as n } from "../../utils/index.js";
6
- import { useAlertDialog as H } from "./hooks/useAlertDialog.js";
7
- const I = ({
6
+ import { useAlertDialog as L } from "./hooks/useAlertDialog.js";
7
+ const M = ({
8
8
  buttonCancel: {
9
- className: i,
10
- text: o = "Cancel",
11
- ...c
9
+ className: o,
10
+ text: c = "Cancel",
11
+ ...d
12
12
  } = {},
13
13
  buttonConfirm: {
14
- className: d,
15
- text: m = "OK",
16
- ...f
14
+ className: m,
15
+ text: f = "OK",
16
+ ...p
17
17
  } = {},
18
- buttonTriggerClassName: p,
19
- buttonTriggerVariant: u,
18
+ buttonTriggerClassName: u,
20
19
  buttonTriggerText: h,
21
- description: x,
22
- showCancelButton: b = !0,
20
+ buttonTriggerVariant: x,
21
+ description: b,
22
+ isDescriptionChild: C,
23
+ isTitleChild: g,
24
+ showCancelButton: N = !0,
23
25
  theme: a,
24
- title: g,
25
- wrapperClassName: C,
26
- onConfirm: N,
27
- ...y
26
+ title: y,
27
+ wrapperClassName: k,
28
+ onClick: A,
29
+ onConfirm: D,
30
+ ...l
28
31
  }) => {
29
- const r = q(null), [k, A] = F(null), { isOpen: D, handleCancel: O, handleConfirm: v, handleOpen: R } = H({
30
- onConfirm: N
32
+ const r = H(null), [O, v] = I(null), { isOpen: R, handleCancel: j, handleConfirm: T, handleOpen: w } = L({
33
+ onConfirm: D
31
34
  });
32
- return G(() => {
35
+ return J(() => {
33
36
  if (!r.current || a)
34
37
  return;
35
- const l = r.current.closest("[data-theme]");
36
- l && A(l);
37
- }, []), /* @__PURE__ */ t(j, { open: D, ...y, children: [
38
+ const s = r.current.closest("[data-theme]");
39
+ s && v(s);
40
+ }, []), /* @__PURE__ */ t(K, { open: R, ...l, children: [
38
41
  /* @__PURE__ */ e(
39
- T,
42
+ P,
40
43
  {
41
44
  ref: r,
42
- className: p,
43
- variant: u,
45
+ className: u,
46
+ variant: x,
44
47
  text: h,
45
48
  "data-theme": a,
46
- onOpen: R
49
+ onOpen: w,
50
+ onClick: A,
51
+ ...l
47
52
  }
48
53
  ),
49
- /* @__PURE__ */ t(w, { container: k, children: [
50
- /* @__PURE__ */ e(K, { className: "bg-black opacity-70 dark:opacity-85 inset-0 fixed animate-in fade-in-0" }),
54
+ /* @__PURE__ */ t(z, { container: O, children: [
55
+ /* @__PURE__ */ e(B, { className: "bg-black opacity-70 dark:opacity-85 inset-0 fixed animate-in fade-in-0" }),
51
56
  /* @__PURE__ */ t(
52
- P,
57
+ E,
53
58
  {
54
59
  "data-theme": a,
55
60
  className: n(
@@ -72,32 +77,46 @@ const I = ({
72
77
  "dark:bg-metal-800",
73
78
  "dark:border-metal-700",
74
79
  "dark:border-slate-700",
75
- C
80
+ k
76
81
  ),
77
82
  children: [
78
- /* @__PURE__ */ e(z, { className: "text-base text-slate-700 font-semibold", children: g }),
79
- /* @__PURE__ */ e(B, { className: "text-sm text-slate-800", children: x }),
83
+ /* @__PURE__ */ e(
84
+ S,
85
+ {
86
+ asChild: g,
87
+ className: "text-base text-slate-700 font-semibold",
88
+ children: y
89
+ }
90
+ ),
91
+ /* @__PURE__ */ e(
92
+ q,
93
+ {
94
+ asChild: C,
95
+ className: "text-sm text-slate-800",
96
+ children: b
97
+ }
98
+ ),
80
99
  /* @__PURE__ */ t("div", { className: "flex flex-row gap-2 justify-end", children: [
81
- b && /* @__PURE__ */ e(E, { asChild: !0, children: /* @__PURE__ */ e(
82
- s,
100
+ N && /* @__PURE__ */ e(F, { asChild: !0, children: /* @__PURE__ */ e(
101
+ i,
83
102
  {
84
103
  type: "button",
85
104
  variant: "secondary",
86
- className: n(i),
87
- onClick: O,
88
- ...c,
89
- children: o
105
+ className: n(o),
106
+ onClick: j,
107
+ ...d,
108
+ children: c
90
109
  }
91
110
  ) }),
92
- /* @__PURE__ */ e(S, { asChild: !0, children: /* @__PURE__ */ e(
93
- s,
111
+ /* @__PURE__ */ e(G, { asChild: !0, children: /* @__PURE__ */ e(
112
+ i,
94
113
  {
95
114
  type: "button",
96
115
  variant: "primary",
97
- className: n(d),
98
- onClick: v,
99
- ...f,
100
- children: m
116
+ className: n(m),
117
+ onClick: T,
118
+ ...p,
119
+ children: f
101
120
  }
102
121
  ) })
103
122
  ] })
@@ -107,7 +126,7 @@ const I = ({
107
126
  ] })
108
127
  ] });
109
128
  };
110
- I.displayName = "KonstructAlertDialog";
129
+ M.displayName = "KonstructAlertDialog";
111
130
  export {
112
- I as AlertDialog
131
+ M as AlertDialog
113
132
  };
@@ -1,5 +1,5 @@
1
1
  import "react/jsx-runtime";
2
- import { A as e } from "../../../index-D6KzX_ef.js";
2
+ import { A as e } from "../../../index-BqhYevy7.js";
3
3
  import "react";
4
4
  import "../../Button/Button.js";
5
5
  import "../../../utils/index.js";
@@ -1,4 +1,4 @@
1
- import { A as g } from "../../../index-D6KzX_ef.js";
1
+ import { A as g } from "../../../index-BqhYevy7.js";
2
2
  export {
3
3
  g as AlertDialogTrigger
4
4
  };
@@ -185,13 +185,13 @@ const a = r(
185
185
  {
186
186
  variant: "danger",
187
187
  disabled: !0,
188
- class: [
189
- "text-red-700",
190
- "border-red-700",
191
- "bg-white",
192
- "hover:bg-red-50",
193
- "opacity-45"
194
- ]
188
+ class: ["text-white", "border-red-700", "bg-red-700", "opacity-45"]
189
+ },
190
+ {
191
+ variant: "danger",
192
+ version: "alternate",
193
+ disabled: !0,
194
+ class: ["text-red-700", "border-red-700", "bg-white", "opacity-45"]
195
195
  },
196
196
  {
197
197
  variant: "link",
@@ -1,48 +1,48 @@
1
- import { jsxs as l, jsx as r } from "react/jsx-runtime";
2
- import { Button as a } from "../../../Button/Button.js";
3
- import { cn as e } from "../../../../utils/index.js";
4
- import { E as u } from "../../../../ellipsis-vertical-BVPtjl5f.js";
5
- const b = ({
6
- actions: o,
1
+ import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
+ import { Button as n } from "../../../Button/Button.js";
3
+ import { cn as r } from "../../../../utils/index.js";
4
+ import { E as x } from "../../../../ellipsis-vertical-BVPtjl5f.js";
5
+ const y = ({
6
+ actions: a,
7
7
  wrapperClassName: i,
8
- triggerButtonClassName: n,
8
+ triggerButtonClassName: l,
9
9
  iconTriggerButtonClassName: s,
10
10
  wrapperActionsClassName: d,
11
- wrapperContentActionsClassName: h,
12
- ...c
13
- }) => o ? /* @__PURE__ */ l("div", { className: e("relative group", i), children: [
14
- /* @__PURE__ */ l(
15
- a,
11
+ wrapperContentActionsClassName: c,
12
+ ...m
13
+ }) => a ? /* @__PURE__ */ t("div", { className: r("relative group", i), children: [
14
+ /* @__PURE__ */ t(
15
+ n,
16
16
  {
17
17
  variant: "link",
18
18
  shape: "circle",
19
19
  size: "large",
20
- className: e(
20
+ className: r(
21
21
  "text-slate-400",
22
22
  "group-hover:text-slate-800",
23
23
  "group-hover:bg-aurora-50",
24
24
  "dark:text-metal-400",
25
25
  "dark:group-hover:text-aurora-500",
26
26
  "dark:group-hover:bg-aurora-900",
27
- n
27
+ l
28
28
  ),
29
29
  role: "presentation",
30
30
  children: [
31
- /* @__PURE__ */ r(
32
- u,
31
+ /* @__PURE__ */ e(
32
+ x,
33
33
  {
34
34
  "aria-hidden": "true",
35
- className: e("w-7 h-7", s)
35
+ className: r("w-7 h-7", s)
36
36
  }
37
37
  ),
38
- /* @__PURE__ */ r("span", { className: "sr-only", children: "Show Actions" })
38
+ /* @__PURE__ */ e("span", { className: "sr-only", children: "Show Actions" })
39
39
  ]
40
40
  }
41
41
  ),
42
- /* @__PURE__ */ r(
42
+ /* @__PURE__ */ e(
43
43
  "div",
44
44
  {
45
- className: e(
45
+ className: r(
46
46
  "absolute",
47
47
  "top-full",
48
48
  "right-0",
@@ -52,10 +52,10 @@ const b = ({
52
52
  "z-10",
53
53
  d
54
54
  ),
55
- children: /* @__PURE__ */ r(
55
+ children: /* @__PURE__ */ e(
56
56
  "div",
57
57
  {
58
- className: e(
58
+ className: r(
59
59
  "bg-white",
60
60
  "mt-0.5",
61
61
  "py-2",
@@ -67,42 +67,52 @@ const b = ({
67
67
  "fade-in-0",
68
68
  "dark:bg-metal-800",
69
69
  "dark:border-metal-700",
70
- h
70
+ c
71
71
  ),
72
- children: o.map(({ label: t, className: m, onClick: p }) => /* @__PURE__ */ r(
73
- a,
74
- {
75
- className: e(
76
- "w-full",
77
- "text-slate-800",
78
- "cursor-pointer",
79
- "p-0",
80
- "h-9",
81
- "flex",
82
- "gap-2",
83
- "text-sm",
84
- "font-normal",
85
- "justify-start",
86
- "rounded-none",
87
- "px-6",
88
- "hover:bg-gray-50",
89
- "hover:text-slate-800",
90
- "hover:no-underline",
91
- "dark:hover:bg-metal-700",
92
- m
93
- ),
94
- variant: "link",
95
- asChild: !0,
96
- role: "presentation",
97
- children: /* @__PURE__ */ r(a, { onClick: () => p(c.row.original), children: t })
98
- },
99
- t
100
- ))
72
+ children: a.map(
73
+ ({
74
+ id: p,
75
+ label: o,
76
+ className: h,
77
+ component: u = n,
78
+ componentProps: g,
79
+ onClick: v
80
+ }, f) => /* @__PURE__ */ e(
81
+ u,
82
+ {
83
+ className: r(
84
+ "w-full",
85
+ "text-slate-800",
86
+ "cursor-pointer",
87
+ "p-0",
88
+ "h-9",
89
+ "flex",
90
+ "gap-2",
91
+ "text-sm",
92
+ "font-normal",
93
+ "justify-start",
94
+ "rounded-none",
95
+ "px-6",
96
+ "hover:bg-gray-50",
97
+ "hover:text-slate-800",
98
+ "hover:no-underline",
99
+ "dark:hover:bg-metal-700",
100
+ h
101
+ ),
102
+ variant: "link",
103
+ role: "presentation",
104
+ onClick: () => v(m.row.original),
105
+ ...g,
106
+ children: o
107
+ },
108
+ p ?? (typeof o == "string" ? o : `action-${f}`)
109
+ )
110
+ )
101
111
  }
102
112
  )
103
113
  }
104
114
  )
105
115
  ] }) : null;
106
116
  export {
107
- b as Actions
117
+ y as Actions
108
118
  };
@@ -38,30 +38,30 @@ var Q = "AlertDialogOverlay", y = l.forwardRef(
38
38
  }
39
39
  );
40
40
  y.displayName = Q;
41
- var n = "AlertDialogContent", [U, X] = z(n), Z = /* @__PURE__ */ V("AlertDialogContent"), N = l.forwardRef(
41
+ var c = "AlertDialogContent", [U, X] = z(c), Z = /* @__PURE__ */ V("AlertDialogContent"), N = l.forwardRef(
42
42
  (r, e) => {
43
- const { __scopeAlertDialog: o, children: t, ...a } = r, c = s(o), d = l.useRef(null), P = u(e, d), g = l.useRef(null);
43
+ const { __scopeAlertDialog: o, children: t, ...a } = r, p = s(o), n = l.useRef(null), P = u(e, n), g = l.useRef(null);
44
44
  return /* @__PURE__ */ i(
45
45
  G,
46
46
  {
47
- contentName: n,
47
+ contentName: c,
48
48
  titleName: R,
49
49
  docsSlug: "alert-dialog",
50
50
  children: /* @__PURE__ */ i(U, { scope: o, cancelRef: g, children: /* @__PURE__ */ w(
51
51
  W,
52
52
  {
53
53
  role: "alertdialog",
54
- ...c,
54
+ ...p,
55
55
  ...a,
56
56
  ref: P,
57
- onOpenAutoFocus: M(a.onOpenAutoFocus, (p) => {
58
- p.preventDefault(), g.current?.focus({ preventScroll: !0 });
57
+ onOpenAutoFocus: M(a.onOpenAutoFocus, (d) => {
58
+ d.preventDefault(), g.current?.focus({ preventScroll: !0 });
59
59
  }),
60
- onPointerDownOutside: (p) => p.preventDefault(),
61
- onInteractOutside: (p) => p.preventDefault(),
60
+ onPointerDownOutside: (d) => d.preventDefault(),
61
+ onInteractOutside: (d) => d.preventDefault(),
62
62
  children: [
63
63
  /* @__PURE__ */ i(Z, { children: t }),
64
- /* @__PURE__ */ i(re, { contentRef: d })
64
+ /* @__PURE__ */ i(re, { contentRef: n })
65
65
  ]
66
66
  }
67
67
  ) })
@@ -69,7 +69,7 @@ var n = "AlertDialogContent", [U, X] = z(n), Z = /* @__PURE__ */ V("AlertDialogC
69
69
  );
70
70
  }
71
71
  );
72
- N.displayName = n;
72
+ N.displayName = c;
73
73
  var R = "AlertDialogTitle", h = l.forwardRef(
74
74
  (r, e) => {
75
75
  const { __scopeAlertDialog: o, ...t } = r, a = s(o);
@@ -91,17 +91,17 @@ var ee = "AlertDialogAction", E = l.forwardRef(
91
91
  E.displayName = ee;
92
92
  var T = "AlertDialogCancel", b = l.forwardRef(
93
93
  (r, e) => {
94
- const { __scopeAlertDialog: o, ...t } = r, { cancelRef: a } = X(T, o), c = s(o), d = u(e, a);
95
- return /* @__PURE__ */ i(f, { ...c, ...t, ref: d });
94
+ const { __scopeAlertDialog: o, ...t } = r, { cancelRef: a } = X(T, o), p = s(o), n = u(e, a);
95
+ return /* @__PURE__ */ i(f, { ...p, ...t, ref: n });
96
96
  }
97
97
  );
98
98
  b.displayName = T;
99
99
  var re = ({ contentRef: r }) => {
100
- const e = `\`${n}\` requires a description for the component to be accessible for screen reader users.
100
+ const e = `\`${c}\` requires a description for the component to be accessible for screen reader users.
101
101
 
102
- You can add a description to the \`${n}\` by passing a \`${C}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
102
+ You can add a description to the \`${c}\` by passing a \`${C}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
103
103
 
104
- Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${n}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
104
+ Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${c}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
105
105
 
106
106
  For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;
107
107
  return l.useEffect(() => {
@@ -110,18 +110,22 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
110
110
  ) || console.warn(e);
111
111
  }, [e, r]), null;
112
112
  }, de = m, oe = D, ge = _, ue = y, Ae = N, fe = E, ve = b, me = h, De = S;
113
- const _e = I(({ "data-theme": r, className: e, text: o, variant: t, onOpen: a }, c) => /* @__PURE__ */ i(oe, { asChild: !0, children: /* @__PURE__ */ i(
114
- k,
115
- {
116
- ref: c,
117
- type: "button",
118
- variant: t,
119
- "data-theme": r,
120
- className: q(e),
121
- onClick: a,
122
- children: o
123
- }
124
- ) }));
113
+ const _e = I(
114
+ ({ "data-theme": r, className: e, text: o, variant: t, onOpen: a, onClick: p }, n) => /* @__PURE__ */ i(oe, { asChild: !0, children: /* @__PURE__ */ i(
115
+ k,
116
+ {
117
+ ref: n,
118
+ type: "button",
119
+ variant: t,
120
+ "data-theme": r,
121
+ className: q(e),
122
+ onClick: () => {
123
+ a(), p?.();
124
+ },
125
+ children: o
126
+ }
127
+ ) })
128
+ );
125
129
  export {
126
130
  _e as A,
127
131
  Ae as C,
package/dist/index.d.ts CHANGED
@@ -30,10 +30,18 @@ import { UseQueryOptions } from '@tanstack/react-query';
30
30
  import { VariantProps } from 'class-variance-authority';
31
31
 
32
32
  declare type Action<TData> = {
33
- label: string | React.ReactNode;
34
- onClick: (rowData: TData) => void;
35
33
  className?: string;
36
- };
34
+ id?: string;
35
+ onClick: (rowData: TData) => void;
36
+ } & ({
37
+ component: FC;
38
+ label?: string | ReactNode;
39
+ componentProps?: Record<string, unknown>;
40
+ } | {
41
+ component?: undefined;
42
+ label: string | ReactNode;
43
+ componentProps?: never;
44
+ });
37
45
 
38
46
  /**
39
47
  * An alert component for displaying feedback messages.
@@ -125,16 +133,20 @@ declare interface AlertDialogProps extends PropsWithChildren, AlertDialogProps_2
125
133
  className?: string;
126
134
  /** Description text shown in the dialog */
127
135
  description?: string | ReactNode;
136
+ isDescriptionChild?: boolean;
128
137
  /** Whether to show the cancel button (default: true) */
129
138
  showCancelButton?: boolean;
130
139
  /** Theme override for this component */
131
140
  theme?: Theme;
132
141
  /** Title text shown in the dialog */
133
142
  title?: string | ReactNode;
143
+ isTitleChild?: boolean;
134
144
  /** CSS classes for the dialog wrapper */
135
145
  wrapperClassName?: string;
136
146
  /** Callback when confirm button is clicked */
137
- onConfirm?: () => void;
147
+ onConfirm?: VoidFunction;
148
+ /** Callback when the button is clicked */
149
+ onClick?: VoidFunction;
138
150
  }
139
151
 
140
152
  /**
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.49",
5
+ "version": "0.1.2-alpha.51",
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.50",
5
+ "version": "0.1.2-alpha.52",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",