@nucleux/action-confirmation 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nucleux
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @nucleux/action-confirmation
2
+
3
+ ActionConfirmation — a guardrail before an agent takes a consequential action — Nucleux agentic UI for React.
4
+
5
+ Part of **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — agentic UI components for React. Install a single component, or the full kit via [`@nucleux/react`](https://www.npmjs.com/package/@nucleux/react).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @nucleux/action-confirmation @nucleux/tokens
11
+ ```
12
+
13
+ `react` / `react-dom` are peer dependencies.
14
+
15
+ ## Usage
16
+
17
+ ```tsx
18
+ import { ActionConfirmation } from "@nucleux/action-confirmation";
19
+ ```
20
+
21
+ Requires the theme once in your app: `import "@nucleux/tokens/styles.css";`
22
+ and the Tailwind preset from `@nucleux/tokens/preset`.
23
+
24
+ ## License
25
+
26
+ MIT © Nucleux
package/dist/index.cjs ADDED
@@ -0,0 +1,109 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var utils = require('@nucleux/utils');
6
+ var lucideReact = require('lucide-react');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
+
29
+ // src/index.tsx
30
+ var ActionConfirmation = React__namespace.forwardRef(
31
+ ({
32
+ title,
33
+ description,
34
+ variant = "destructive",
35
+ badge = "AI action",
36
+ icon,
37
+ confirmLabel = "Confirm",
38
+ cancelLabel = "Cancel",
39
+ onConfirm,
40
+ onCancel,
41
+ className,
42
+ children,
43
+ ...props
44
+ }, ref) => {
45
+ const destructive = variant === "destructive";
46
+ return /* @__PURE__ */ jsxRuntime.jsxs(
47
+ "div",
48
+ {
49
+ ref,
50
+ role: "alertdialog",
51
+ "aria-label": typeof title === "string" ? title : void 0,
52
+ className: utils.cn(
53
+ "flex flex-col gap-3 rounded-xl border bg-background p-5",
54
+ destructive ? "border-destructive/50" : "border-border",
55
+ className
56
+ ),
57
+ ...props,
58
+ children: [
59
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
60
+ /* @__PURE__ */ jsxRuntime.jsx(
61
+ "span",
62
+ {
63
+ className: utils.cn(
64
+ "mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg]:size-4",
65
+ destructive ? "bg-destructive/10 text-destructive" : "bg-warning/10 text-warning"
66
+ ),
67
+ children: icon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { "aria-hidden": "true" })
68
+ }
69
+ ),
70
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
71
+ badge && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex w-fit items-center rounded-full bg-muted px-2 py-0.5 text-[0.6875rem] font-medium uppercase tracking-wide text-muted-foreground", children: badge }),
72
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-base font-semibold text-foreground", children: title }),
73
+ description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: description }),
74
+ children
75
+ ] })
76
+ ] }),
77
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-2", children: [
78
+ /* @__PURE__ */ jsxRuntime.jsx(
79
+ "button",
80
+ {
81
+ type: "button",
82
+ onClick: onCancel,
83
+ className: "inline-flex items-center rounded-lg border border-border bg-background px-3 py-2 text-sm font-medium text-foreground transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
84
+ children: cancelLabel
85
+ }
86
+ ),
87
+ /* @__PURE__ */ jsxRuntime.jsx(
88
+ "button",
89
+ {
90
+ type: "button",
91
+ onClick: onConfirm,
92
+ className: utils.cn(
93
+ "inline-flex items-center rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
94
+ destructive ? "bg-destructive text-destructive-foreground hover:bg-destructive/90" : "bg-info text-info-foreground hover:bg-info/90"
95
+ ),
96
+ children: confirmLabel
97
+ }
98
+ )
99
+ ] })
100
+ ]
101
+ }
102
+ );
103
+ }
104
+ );
105
+ ActionConfirmation.displayName = "ActionConfirmation";
106
+
107
+ exports.ActionConfirmation = ActionConfirmation;
108
+ //# sourceMappingURL=index.cjs.map
109
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["React","jsxs","cn","jsx","AlertTriangle"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,IAAM,kBAAA,GAA2BA,gBAAA,CAAA,UAAA;AAAA,EACtC,CACE;AAAA,IACE,KAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA,GAAU,aAAA;AAAA,IACV,KAAA,GAAQ,WAAA;AAAA,IACR,IAAA;AAAA,IACA,YAAA,GAAe,SAAA;AAAA,IACf,WAAA,GAAc,QAAA;AAAA,IACd,SAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAG;AAAA,KAEL,GAAA,KACG;AACH,IAAA,MAAM,cAAc,OAAA,KAAY,aAAA;AAChC,IAAA,uBACEC,eAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,IAAA,EAAK,aAAA;AAAA,QACL,YAAA,EAAY,OAAO,KAAA,KAAU,QAAA,GAAW,KAAA,GAAQ,MAAA;AAAA,QAChD,SAAA,EAAWC,QAAA;AAAA,UACT,yDAAA;AAAA,UACA,cAAc,uBAAA,GAA0B,eAAA;AAAA,UACxC;AAAA,SACF;AAAA,QACC,GAAG,KAAA;AAAA,QAEJ,QAAA,EAAA;AAAA,0BAAAD,eAAA,CAAC,KAAA,EAAA,EAAI,WAAU,wBAAA,EACb,QAAA,EAAA;AAAA,4BAAAE,cAAA;AAAA,cAAC,MAAA;AAAA,cAAA;AAAA,gBACC,SAAA,EAAWD,QAAA;AAAA,kBACT,0FAAA;AAAA,kBACA,cAAc,oCAAA,GAAuC;AAAA,iBACvD;AAAA,gBAEC,QAAA,EAAA,IAAA,oBAAQC,cAAA,CAACC,yBAAA,EAAA,EAAc,aAAA,EAAY,MAAA,EAAO;AAAA;AAAA,aAC7C;AAAA,4BACAH,eAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,oCAAA,EACZ,QAAA,EAAA;AAAA,cAAA,KAAA,oBACCE,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,6IAAA,EACb,QAAA,EAAA,KAAA,EACH,CAAA;AAAA,8BAEFA,cAAA,CAAC,IAAA,EAAA,EAAG,SAAA,EAAU,yCAAA,EAA2C,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,cAC9D,WAAA,oBAAeA,cAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,iCAAiC,QAAA,EAAA,WAAA,EAAY,CAAA;AAAA,cACzE;AAAA,aAAA,EACH;AAAA,WAAA,EACF,CAAA;AAAA,0BACAF,eAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,qCAAA,EACb,QAAA,EAAA;AAAA,4BAAAE,cAAA;AAAA,cAAC,QAAA;AAAA,cAAA;AAAA,gBACC,IAAA,EAAK,QAAA;AAAA,gBACL,OAAA,EAAS,QAAA;AAAA,gBACT,SAAA,EAAU,gOAAA;AAAA,gBAET,QAAA,EAAA;AAAA;AAAA,aACH;AAAA,4BACAA,cAAA;AAAA,cAAC,QAAA;AAAA,cAAA;AAAA,gBACC,IAAA,EAAK,QAAA;AAAA,gBACL,OAAA,EAAS,SAAA;AAAA,gBACT,SAAA,EAAWD,QAAA;AAAA,kBACT,6JAAA;AAAA,kBACA,cACI,oEAAA,GACA;AAAA,iBACN;AAAA,gBAEC,QAAA,EAAA;AAAA;AAAA;AACH,WAAA,EACF;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AACA,kBAAA,CAAmB,WAAA,GAAc,oBAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\nimport { AlertTriangle } from \"lucide-react\";\n\nexport type ActionConfirmationVariant = \"default\" | \"destructive\";\n\nexport interface ActionConfirmationProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n /** The action in question, e.g. `\"Send 18 emails?\"`. */\n title: React.ReactNode;\n /** What will happen / why it matters. */\n description?: React.ReactNode;\n /** Risk styling. `destructive` for irreversible/high-impact actions. */\n variant?: ActionConfirmationVariant;\n /** Badge text marking this as an agent action. Defaults to `\"AI action\"`. */\n badge?: React.ReactNode;\n /** Leading icon. Defaults to a warning triangle. */\n icon?: React.ReactNode;\n confirmLabel?: React.ReactNode;\n cancelLabel?: React.ReactNode;\n onConfirm?: () => void;\n onCancel?: () => void;\n}\n\n/**\n * A guardrail shown before an agent performs a consequential or irreversible\n * action — states the action, its impact, and requires explicit confirmation.\n * Source: Figma \"Recovery / Verification\".\n */\nexport const ActionConfirmation = React.forwardRef<HTMLDivElement, ActionConfirmationProps>(\n (\n {\n title,\n description,\n variant = \"destructive\",\n badge = \"AI action\",\n icon,\n confirmLabel = \"Confirm\",\n cancelLabel = \"Cancel\",\n onConfirm,\n onCancel,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const destructive = variant === \"destructive\";\n return (\n <div\n ref={ref}\n role=\"alertdialog\"\n aria-label={typeof title === \"string\" ? title : undefined}\n className={cn(\n \"flex flex-col gap-3 rounded-xl border bg-background p-5\",\n destructive ? \"border-destructive/50\" : \"border-border\",\n className,\n )}\n {...props}\n >\n <div className=\"flex items-start gap-3\">\n <span\n className={cn(\n \"mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg]:size-4\",\n destructive ? \"bg-destructive/10 text-destructive\" : \"bg-warning/10 text-warning\",\n )}\n >\n {icon ?? <AlertTriangle aria-hidden=\"true\" />}\n </span>\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n {badge && (\n <span className=\"inline-flex w-fit items-center rounded-full bg-muted px-2 py-0.5 text-[0.6875rem] font-medium uppercase tracking-wide text-muted-foreground\">\n {badge}\n </span>\n )}\n <h3 className=\"text-base font-semibold text-foreground\">{title}</h3>\n {description && <p className=\"text-sm text-muted-foreground\">{description}</p>}\n {children}\n </div>\n </div>\n <div className=\"flex items-center justify-end gap-2\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"inline-flex items-center rounded-lg border border-border bg-background px-3 py-2 text-sm font-medium text-foreground transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {cancelLabel}\n </button>\n <button\n type=\"button\"\n onClick={onConfirm}\n className={cn(\n \"inline-flex items-center rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n destructive\n ? \"bg-destructive text-destructive-foreground hover:bg-destructive/90\"\n : \"bg-info text-info-foreground hover:bg-info/90\",\n )}\n >\n {confirmLabel}\n </button>\n </div>\n </div>\n );\n },\n);\nActionConfirmation.displayName = \"ActionConfirmation\";\n"]}
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+
3
+ type ActionConfirmationVariant = "default" | "destructive";
4
+ interface ActionConfirmationProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
5
+ /** The action in question, e.g. `"Send 18 emails?"`. */
6
+ title: React.ReactNode;
7
+ /** What will happen / why it matters. */
8
+ description?: React.ReactNode;
9
+ /** Risk styling. `destructive` for irreversible/high-impact actions. */
10
+ variant?: ActionConfirmationVariant;
11
+ /** Badge text marking this as an agent action. Defaults to `"AI action"`. */
12
+ badge?: React.ReactNode;
13
+ /** Leading icon. Defaults to a warning triangle. */
14
+ icon?: React.ReactNode;
15
+ confirmLabel?: React.ReactNode;
16
+ cancelLabel?: React.ReactNode;
17
+ onConfirm?: () => void;
18
+ onCancel?: () => void;
19
+ }
20
+ /**
21
+ * A guardrail shown before an agent performs a consequential or irreversible
22
+ * action — states the action, its impact, and requires explicit confirmation.
23
+ * Source: Figma "Recovery / Verification".
24
+ */
25
+ declare const ActionConfirmation: React.ForwardRefExoticComponent<ActionConfirmationProps & React.RefAttributes<HTMLDivElement>>;
26
+
27
+ export { ActionConfirmation, type ActionConfirmationProps, type ActionConfirmationVariant };
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+
3
+ type ActionConfirmationVariant = "default" | "destructive";
4
+ interface ActionConfirmationProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
5
+ /** The action in question, e.g. `"Send 18 emails?"`. */
6
+ title: React.ReactNode;
7
+ /** What will happen / why it matters. */
8
+ description?: React.ReactNode;
9
+ /** Risk styling. `destructive` for irreversible/high-impact actions. */
10
+ variant?: ActionConfirmationVariant;
11
+ /** Badge text marking this as an agent action. Defaults to `"AI action"`. */
12
+ badge?: React.ReactNode;
13
+ /** Leading icon. Defaults to a warning triangle. */
14
+ icon?: React.ReactNode;
15
+ confirmLabel?: React.ReactNode;
16
+ cancelLabel?: React.ReactNode;
17
+ onConfirm?: () => void;
18
+ onCancel?: () => void;
19
+ }
20
+ /**
21
+ * A guardrail shown before an agent performs a consequential or irreversible
22
+ * action — states the action, its impact, and requires explicit confirmation.
23
+ * Source: Figma "Recovery / Verification".
24
+ */
25
+ declare const ActionConfirmation: React.ForwardRefExoticComponent<ActionConfirmationProps & React.RefAttributes<HTMLDivElement>>;
26
+
27
+ export { ActionConfirmation, type ActionConfirmationProps, type ActionConfirmationVariant };
package/dist/index.js ADDED
@@ -0,0 +1,87 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { cn } from '@nucleux/utils';
4
+ import { AlertTriangle } from 'lucide-react';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+
7
+ // src/index.tsx
8
+ var ActionConfirmation = React.forwardRef(
9
+ ({
10
+ title,
11
+ description,
12
+ variant = "destructive",
13
+ badge = "AI action",
14
+ icon,
15
+ confirmLabel = "Confirm",
16
+ cancelLabel = "Cancel",
17
+ onConfirm,
18
+ onCancel,
19
+ className,
20
+ children,
21
+ ...props
22
+ }, ref) => {
23
+ const destructive = variant === "destructive";
24
+ return /* @__PURE__ */ jsxs(
25
+ "div",
26
+ {
27
+ ref,
28
+ role: "alertdialog",
29
+ "aria-label": typeof title === "string" ? title : void 0,
30
+ className: cn(
31
+ "flex flex-col gap-3 rounded-xl border bg-background p-5",
32
+ destructive ? "border-destructive/50" : "border-border",
33
+ className
34
+ ),
35
+ ...props,
36
+ children: [
37
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
38
+ /* @__PURE__ */ jsx(
39
+ "span",
40
+ {
41
+ className: cn(
42
+ "mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg]:size-4",
43
+ destructive ? "bg-destructive/10 text-destructive" : "bg-warning/10 text-warning"
44
+ ),
45
+ children: icon ?? /* @__PURE__ */ jsx(AlertTriangle, { "aria-hidden": "true" })
46
+ }
47
+ ),
48
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
49
+ badge && /* @__PURE__ */ jsx("span", { className: "inline-flex w-fit items-center rounded-full bg-muted px-2 py-0.5 text-[0.6875rem] font-medium uppercase tracking-wide text-muted-foreground", children: badge }),
50
+ /* @__PURE__ */ jsx("h3", { className: "text-base font-semibold text-foreground", children: title }),
51
+ description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description }),
52
+ children
53
+ ] })
54
+ ] }),
55
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-2", children: [
56
+ /* @__PURE__ */ jsx(
57
+ "button",
58
+ {
59
+ type: "button",
60
+ onClick: onCancel,
61
+ className: "inline-flex items-center rounded-lg border border-border bg-background px-3 py-2 text-sm font-medium text-foreground transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
62
+ children: cancelLabel
63
+ }
64
+ ),
65
+ /* @__PURE__ */ jsx(
66
+ "button",
67
+ {
68
+ type: "button",
69
+ onClick: onConfirm,
70
+ className: cn(
71
+ "inline-flex items-center rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
72
+ destructive ? "bg-destructive text-destructive-foreground hover:bg-destructive/90" : "bg-info text-info-foreground hover:bg-info/90"
73
+ ),
74
+ children: confirmLabel
75
+ }
76
+ )
77
+ ] })
78
+ ]
79
+ }
80
+ );
81
+ }
82
+ );
83
+ ActionConfirmation.displayName = "ActionConfirmation";
84
+
85
+ export { ActionConfirmation };
86
+ //# sourceMappingURL=index.js.map
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;AA6BO,IAAM,kBAAA,GAA2B,KAAA,CAAA,UAAA;AAAA,EACtC,CACE;AAAA,IACE,KAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA,GAAU,aAAA;AAAA,IACV,KAAA,GAAQ,WAAA;AAAA,IACR,IAAA;AAAA,IACA,YAAA,GAAe,SAAA;AAAA,IACf,WAAA,GAAc,QAAA;AAAA,IACd,SAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAG;AAAA,KAEL,GAAA,KACG;AACH,IAAA,MAAM,cAAc,OAAA,KAAY,aAAA;AAChC,IAAA,uBACE,IAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,IAAA,EAAK,aAAA;AAAA,QACL,YAAA,EAAY,OAAO,KAAA,KAAU,QAAA,GAAW,KAAA,GAAQ,MAAA;AAAA,QAChD,SAAA,EAAW,EAAA;AAAA,UACT,yDAAA;AAAA,UACA,cAAc,uBAAA,GAA0B,eAAA;AAAA,UACxC;AAAA,SACF;AAAA,QACC,GAAG,KAAA;AAAA,QAEJ,QAAA,EAAA;AAAA,0BAAA,IAAA,CAAC,KAAA,EAAA,EAAI,WAAU,wBAAA,EACb,QAAA,EAAA;AAAA,4BAAA,GAAA;AAAA,cAAC,MAAA;AAAA,cAAA;AAAA,gBACC,SAAA,EAAW,EAAA;AAAA,kBACT,0FAAA;AAAA,kBACA,cAAc,oCAAA,GAAuC;AAAA,iBACvD;AAAA,gBAEC,QAAA,EAAA,IAAA,oBAAQ,GAAA,CAAC,aAAA,EAAA,EAAc,aAAA,EAAY,MAAA,EAAO;AAAA;AAAA,aAC7C;AAAA,4BACA,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,oCAAA,EACZ,QAAA,EAAA;AAAA,cAAA,KAAA,oBACC,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,6IAAA,EACb,QAAA,EAAA,KAAA,EACH,CAAA;AAAA,8BAEF,GAAA,CAAC,IAAA,EAAA,EAAG,SAAA,EAAU,yCAAA,EAA2C,QAAA,EAAA,KAAA,EAAM,CAAA;AAAA,cAC9D,WAAA,oBAAe,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,iCAAiC,QAAA,EAAA,WAAA,EAAY,CAAA;AAAA,cACzE;AAAA,aAAA,EACH;AAAA,WAAA,EACF,CAAA;AAAA,0BACA,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,qCAAA,EACb,QAAA,EAAA;AAAA,4BAAA,GAAA;AAAA,cAAC,QAAA;AAAA,cAAA;AAAA,gBACC,IAAA,EAAK,QAAA;AAAA,gBACL,OAAA,EAAS,QAAA;AAAA,gBACT,SAAA,EAAU,gOAAA;AAAA,gBAET,QAAA,EAAA;AAAA;AAAA,aACH;AAAA,4BACA,GAAA;AAAA,cAAC,QAAA;AAAA,cAAA;AAAA,gBACC,IAAA,EAAK,QAAA;AAAA,gBACL,OAAA,EAAS,SAAA;AAAA,gBACT,SAAA,EAAW,EAAA;AAAA,kBACT,6JAAA;AAAA,kBACA,cACI,oEAAA,GACA;AAAA,iBACN;AAAA,gBAEC,QAAA,EAAA;AAAA;AAAA;AACH,WAAA,EACF;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AACA,kBAAA,CAAmB,WAAA,GAAc,oBAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\nimport { AlertTriangle } from \"lucide-react\";\n\nexport type ActionConfirmationVariant = \"default\" | \"destructive\";\n\nexport interface ActionConfirmationProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n /** The action in question, e.g. `\"Send 18 emails?\"`. */\n title: React.ReactNode;\n /** What will happen / why it matters. */\n description?: React.ReactNode;\n /** Risk styling. `destructive` for irreversible/high-impact actions. */\n variant?: ActionConfirmationVariant;\n /** Badge text marking this as an agent action. Defaults to `\"AI action\"`. */\n badge?: React.ReactNode;\n /** Leading icon. Defaults to a warning triangle. */\n icon?: React.ReactNode;\n confirmLabel?: React.ReactNode;\n cancelLabel?: React.ReactNode;\n onConfirm?: () => void;\n onCancel?: () => void;\n}\n\n/**\n * A guardrail shown before an agent performs a consequential or irreversible\n * action — states the action, its impact, and requires explicit confirmation.\n * Source: Figma \"Recovery / Verification\".\n */\nexport const ActionConfirmation = React.forwardRef<HTMLDivElement, ActionConfirmationProps>(\n (\n {\n title,\n description,\n variant = \"destructive\",\n badge = \"AI action\",\n icon,\n confirmLabel = \"Confirm\",\n cancelLabel = \"Cancel\",\n onConfirm,\n onCancel,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const destructive = variant === \"destructive\";\n return (\n <div\n ref={ref}\n role=\"alertdialog\"\n aria-label={typeof title === \"string\" ? title : undefined}\n className={cn(\n \"flex flex-col gap-3 rounded-xl border bg-background p-5\",\n destructive ? \"border-destructive/50\" : \"border-border\",\n className,\n )}\n {...props}\n >\n <div className=\"flex items-start gap-3\">\n <span\n className={cn(\n \"mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg]:size-4\",\n destructive ? \"bg-destructive/10 text-destructive\" : \"bg-warning/10 text-warning\",\n )}\n >\n {icon ?? <AlertTriangle aria-hidden=\"true\" />}\n </span>\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n {badge && (\n <span className=\"inline-flex w-fit items-center rounded-full bg-muted px-2 py-0.5 text-[0.6875rem] font-medium uppercase tracking-wide text-muted-foreground\">\n {badge}\n </span>\n )}\n <h3 className=\"text-base font-semibold text-foreground\">{title}</h3>\n {description && <p className=\"text-sm text-muted-foreground\">{description}</p>}\n {children}\n </div>\n </div>\n <div className=\"flex items-center justify-end gap-2\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"inline-flex items-center rounded-lg border border-border bg-background px-3 py-2 text-sm font-medium text-foreground transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {cancelLabel}\n </button>\n <button\n type=\"button\"\n onClick={onConfirm}\n className={cn(\n \"inline-flex items-center rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n destructive\n ? \"bg-destructive text-destructive-foreground hover:bg-destructive/90\"\n : \"bg-info text-info-foreground hover:bg-info/90\",\n )}\n >\n {confirmLabel}\n </button>\n </div>\n </div>\n );\n },\n);\nActionConfirmation.displayName = \"ActionConfirmation\";\n"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@nucleux/action-confirmation",
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "description": "ActionConfirmation — a guardrail before an agent takes a consequential action — Nucleux agentic UI for React.",
7
+ "keywords": [
8
+ "nucleux",
9
+ "react",
10
+ "ui",
11
+ "components",
12
+ "agentic",
13
+ "ai",
14
+ "tailwind",
15
+ "action-confirmation"
16
+ ],
17
+ "main": "./dist/index.cjs",
18
+ "module": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md"
30
+ ],
31
+ "peerDependencies": {
32
+ "react": ">=18",
33
+ "react-dom": ">=18"
34
+ },
35
+ "dependencies": {
36
+ "lucide-react": "^0.469.0",
37
+ "@nucleux/utils": "0.1.1"
38
+ },
39
+ "devDependencies": {
40
+ "tsup": "^8.3.5",
41
+ "typescript": "^5.7.2",
42
+ "@types/react": "^18.3.18",
43
+ "react": "^18.3.1"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "license": "MIT",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/intelligaia-open-labs/nucleux.git",
52
+ "directory": "packages/action-confirmation"
53
+ },
54
+ "homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
55
+ "scripts": {
56
+ "build": "tsup"
57
+ }
58
+ }