@a-type/ui 0.6.13 → 0.6.14
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/dist/cjs/components/button/ConfirmedButton.d.ts +2 -1
- package/dist/cjs/components/button/ConfirmedButton.js +2 -2
- package/dist/cjs/components/button/ConfirmedButton.js.map +1 -1
- package/dist/esm/components/button/ConfirmedButton.d.ts +2 -1
- package/dist/esm/components/button/ConfirmedButton.js +2 -2
- package/dist/esm/components/button/ConfirmedButton.js.map +1 -1
- package/package.json +1 -1
- package/src/components/button/ConfirmedButton.tsx +3 -1
|
@@ -7,5 +7,6 @@ export interface ConfirmedButtonProps extends Omit<ButtonProps, 'onClick'> {
|
|
|
7
7
|
cancelAction?: string;
|
|
8
8
|
onConfirm: () => void | Promise<any>;
|
|
9
9
|
skip?: boolean;
|
|
10
|
+
confirmColor?: ButtonProps['color'];
|
|
10
11
|
}
|
|
11
|
-
export declare function ConfirmedButton({ confirmText, confirmTitle, confirmAction, cancelAction, onConfirm, skip, ...rest }: ConfirmedButtonProps): JSX.Element;
|
|
12
|
+
export declare function ConfirmedButton({ confirmText, confirmTitle, confirmAction, cancelAction, confirmColor, onConfirm, skip, ...rest }: ConfirmedButtonProps): JSX.Element;
|
|
@@ -20,7 +20,7 @@ const dialog_js_1 = require("../dialog.js");
|
|
|
20
20
|
const typography_js_1 = require("../typography.js");
|
|
21
21
|
const Button_js_1 = require("./Button.js");
|
|
22
22
|
function ConfirmedButton(_a) {
|
|
23
|
-
var { confirmText, confirmTitle = 'Are you sure?', confirmAction = 'OK', cancelAction = 'Nevermind', onConfirm, skip } = _a, rest = __rest(_a, ["confirmText", "confirmTitle", "confirmAction", "cancelAction", "onConfirm", "skip"]);
|
|
23
|
+
var { confirmText, confirmTitle = 'Are you sure?', confirmAction = 'OK', cancelAction = 'Nevermind', confirmColor = 'primary', onConfirm, skip } = _a, rest = __rest(_a, ["confirmText", "confirmTitle", "confirmAction", "cancelAction", "confirmColor", "onConfirm", "skip"]);
|
|
24
24
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
25
25
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
26
26
|
const confirm = (0, react_1.useCallback)(async () => {
|
|
@@ -36,7 +36,7 @@ function ConfirmedButton(_a) {
|
|
|
36
36
|
if (skip) {
|
|
37
37
|
return (0, jsx_runtime_1.jsx)(Button_js_1.Button, Object.assign({}, rest));
|
|
38
38
|
}
|
|
39
|
-
return ((0, jsx_runtime_1.jsxs)(dialog_js_1.Dialog, Object.assign({ open: open, onOpenChange: setOpen }, { children: [(0, jsx_runtime_1.jsx)(dialog_js_1.DialogTrigger, Object.assign({ asChild: true }, { children: (0, jsx_runtime_1.jsx)(Button_js_1.Button, Object.assign({}, rest)) })), (0, jsx_runtime_1.jsxs)(dialog_js_1.DialogContent, { children: [(0, jsx_runtime_1.jsx)(dialog_js_1.DialogTitle, { children: confirmTitle }), (0, jsx_runtime_1.jsx)(typography_js_1.P, { children: confirmText }), (0, jsx_runtime_1.jsxs)(dialog_js_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(dialog_js_1.DialogClose, Object.assign({ asChild: true }, { children: (0, jsx_runtime_1.jsx)(Button_js_1.Button, { children: cancelAction }) })), (0, jsx_runtime_1.jsx)(Button_js_1.Button, Object.assign({ loading: loading, onClick: confirm, color:
|
|
39
|
+
return ((0, jsx_runtime_1.jsxs)(dialog_js_1.Dialog, Object.assign({ open: open, onOpenChange: setOpen }, { children: [(0, jsx_runtime_1.jsx)(dialog_js_1.DialogTrigger, Object.assign({ asChild: true }, { children: (0, jsx_runtime_1.jsx)(Button_js_1.Button, Object.assign({}, rest)) })), (0, jsx_runtime_1.jsxs)(dialog_js_1.DialogContent, { children: [(0, jsx_runtime_1.jsx)(dialog_js_1.DialogTitle, { children: confirmTitle }), (0, jsx_runtime_1.jsx)(typography_js_1.P, { children: confirmText }), (0, jsx_runtime_1.jsxs)(dialog_js_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(dialog_js_1.DialogClose, Object.assign({ asChild: true }, { children: (0, jsx_runtime_1.jsx)(Button_js_1.Button, { children: cancelAction }) })), (0, jsx_runtime_1.jsx)(Button_js_1.Button, Object.assign({ loading: loading, onClick: confirm, color: confirmColor }, { children: confirmAction }))] })] })] })));
|
|
40
40
|
}
|
|
41
41
|
exports.ConfirmedButton = ConfirmedButton;
|
|
42
42
|
//# sourceMappingURL=ConfirmedButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmedButton.js","sourceRoot":"","sources":["../../../../src/components/button/ConfirmedButton.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;AAEb,iCAA8C;AAC9C,4CAOsB;AACtB,oDAAqC;AACrC,2CAAkD;
|
|
1
|
+
{"version":3,"file":"ConfirmedButton.js","sourceRoot":"","sources":["../../../../src/components/button/ConfirmedButton.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;AAEb,iCAA8C;AAC9C,4CAOsB;AACtB,oDAAqC;AACrC,2CAAkD;AAYlD,SAAgB,eAAe,CAAC,EAST;QATS,EAC/B,WAAW,EACX,YAAY,GAAG,eAAe,EAC9B,aAAa,GAAG,IAAI,EACpB,YAAY,GAAG,WAAW,EAC1B,YAAY,GAAG,SAAS,EACxB,SAAS,EACT,IAAI,OAEkB,EADnB,IAAI,cARwB,qGAS/B,CADO;IAEP,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QACtC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI;YACH,MAAM,SAAS,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,CAAC;SACf;gBAAS;YACT,UAAU,CAAC,KAAK,CAAC,CAAC;SAClB;IACF,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,IAAI,IAAI,EAAE;QACT,OAAO,uBAAC,kBAAM,oBAAK,IAAI,EAAI,CAAC;KAC5B;IAED,OAAO,CACN,wBAAC,kBAAM,kBAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,iBACxC,uBAAC,yBAAa,kBAAC,OAAO,sBACrB,uBAAC,kBAAM,oBAAK,IAAI,EAAI,IACL,EAChB,wBAAC,yBAAa,eACb,uBAAC,uBAAW,cAAE,YAAY,GAAe,EACzC,uBAAC,iBAAC,cAAE,WAAW,GAAK,EACpB,wBAAC,yBAAa,eACb,uBAAC,uBAAW,kBAAC,OAAO,sBACnB,uBAAC,kBAAM,cAAE,YAAY,GAAU,IAClB,EACd,uBAAC,kBAAM,kBAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,gBAC7D,aAAa,IACN,IACM,IACD,KACR,CACT,CAAC;AACH,CAAC;AA7CD,0CA6CC"}
|
|
@@ -7,5 +7,6 @@ export interface ConfirmedButtonProps extends Omit<ButtonProps, 'onClick'> {
|
|
|
7
7
|
cancelAction?: string;
|
|
8
8
|
onConfirm: () => void | Promise<any>;
|
|
9
9
|
skip?: boolean;
|
|
10
|
+
confirmColor?: ButtonProps['color'];
|
|
10
11
|
}
|
|
11
|
-
export declare function ConfirmedButton({ confirmText, confirmTitle, confirmAction, cancelAction, onConfirm, skip, ...rest }: ConfirmedButtonProps): JSX.Element;
|
|
12
|
+
export declare function ConfirmedButton({ confirmText, confirmTitle, confirmAction, cancelAction, confirmColor, onConfirm, skip, ...rest }: ConfirmedButtonProps): JSX.Element;
|
|
@@ -17,7 +17,7 @@ import { Dialog, DialogActions, DialogClose, DialogContent, DialogTitle, DialogT
|
|
|
17
17
|
import { P } from '../typography.js';
|
|
18
18
|
import { Button } from './Button.js';
|
|
19
19
|
export function ConfirmedButton(_a) {
|
|
20
|
-
var { confirmText, confirmTitle = 'Are you sure?', confirmAction = 'OK', cancelAction = 'Nevermind', onConfirm, skip } = _a, rest = __rest(_a, ["confirmText", "confirmTitle", "confirmAction", "cancelAction", "onConfirm", "skip"]);
|
|
20
|
+
var { confirmText, confirmTitle = 'Are you sure?', confirmAction = 'OK', cancelAction = 'Nevermind', confirmColor = 'primary', onConfirm, skip } = _a, rest = __rest(_a, ["confirmText", "confirmTitle", "confirmAction", "cancelAction", "confirmColor", "onConfirm", "skip"]);
|
|
21
21
|
const [open, setOpen] = useState(false);
|
|
22
22
|
const [loading, setLoading] = useState(false);
|
|
23
23
|
const confirm = useCallback(async () => {
|
|
@@ -33,6 +33,6 @@ export function ConfirmedButton(_a) {
|
|
|
33
33
|
if (skip) {
|
|
34
34
|
return _jsx(Button, Object.assign({}, rest));
|
|
35
35
|
}
|
|
36
|
-
return (_jsxs(Dialog, Object.assign({ open: open, onOpenChange: setOpen }, { children: [_jsx(DialogTrigger, Object.assign({ asChild: true }, { children: _jsx(Button, Object.assign({}, rest)) })), _jsxs(DialogContent, { children: [_jsx(DialogTitle, { children: confirmTitle }), _jsx(P, { children: confirmText }), _jsxs(DialogActions, { children: [_jsx(DialogClose, Object.assign({ asChild: true }, { children: _jsx(Button, { children: cancelAction }) })), _jsx(Button, Object.assign({ loading: loading, onClick: confirm, color:
|
|
36
|
+
return (_jsxs(Dialog, Object.assign({ open: open, onOpenChange: setOpen }, { children: [_jsx(DialogTrigger, Object.assign({ asChild: true }, { children: _jsx(Button, Object.assign({}, rest)) })), _jsxs(DialogContent, { children: [_jsx(DialogTitle, { children: confirmTitle }), _jsx(P, { children: confirmText }), _jsxs(DialogActions, { children: [_jsx(DialogClose, Object.assign({ asChild: true }, { children: _jsx(Button, { children: cancelAction }) })), _jsx(Button, Object.assign({ loading: loading, onClick: confirm, color: confirmColor }, { children: confirmAction }))] })] })] })));
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=ConfirmedButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmedButton.js","sourceRoot":"","sources":["../../../../src/components/button/ConfirmedButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;AAEb,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EACN,MAAM,EACN,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAAE,MAAM,EAAe,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmedButton.js","sourceRoot":"","sources":["../../../../src/components/button/ConfirmedButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;AAEb,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EACN,MAAM,EACN,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAAE,MAAM,EAAe,MAAM,aAAa,CAAC;AAYlD,MAAM,UAAU,eAAe,CAAC,EAST;QATS,EAC/B,WAAW,EACX,YAAY,GAAG,eAAe,EAC9B,aAAa,GAAG,IAAI,EACpB,YAAY,GAAG,WAAW,EAC1B,YAAY,GAAG,SAAS,EACxB,SAAS,EACT,IAAI,OAEkB,EADnB,IAAI,cARwB,qGAS/B,CADO;IAEP,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACtC,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,IAAI;YACH,MAAM,SAAS,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,CAAC;SACf;gBAAS;YACT,UAAU,CAAC,KAAK,CAAC,CAAC;SAClB;IACF,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,IAAI,IAAI,EAAE;QACT,OAAO,KAAC,MAAM,oBAAK,IAAI,EAAI,CAAC;KAC5B;IAED,OAAO,CACN,MAAC,MAAM,kBAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,iBACxC,KAAC,aAAa,kBAAC,OAAO,sBACrB,KAAC,MAAM,oBAAK,IAAI,EAAI,IACL,EAChB,MAAC,aAAa,eACb,KAAC,WAAW,cAAE,YAAY,GAAe,EACzC,KAAC,CAAC,cAAE,WAAW,GAAK,EACpB,MAAC,aAAa,eACb,KAAC,WAAW,kBAAC,OAAO,sBACnB,KAAC,MAAM,cAAE,YAAY,GAAU,IAClB,EACd,KAAC,MAAM,kBAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,gBAC7D,aAAa,IACN,IACM,IACD,KACR,CACT,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ export interface ConfirmedButtonProps extends Omit<ButtonProps, 'onClick'> {
|
|
|
19
19
|
cancelAction?: string;
|
|
20
20
|
onConfirm: () => void | Promise<any>;
|
|
21
21
|
skip?: boolean;
|
|
22
|
+
confirmColor?: ButtonProps['color'];
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export function ConfirmedButton({
|
|
@@ -26,6 +27,7 @@ export function ConfirmedButton({
|
|
|
26
27
|
confirmTitle = 'Are you sure?',
|
|
27
28
|
confirmAction = 'OK',
|
|
28
29
|
cancelAction = 'Nevermind',
|
|
30
|
+
confirmColor = 'primary',
|
|
29
31
|
onConfirm,
|
|
30
32
|
skip,
|
|
31
33
|
...rest
|
|
@@ -58,7 +60,7 @@ export function ConfirmedButton({
|
|
|
58
60
|
<DialogClose asChild>
|
|
59
61
|
<Button>{cancelAction}</Button>
|
|
60
62
|
</DialogClose>
|
|
61
|
-
<Button loading={loading} onClick={confirm} color=
|
|
63
|
+
<Button loading={loading} onClick={confirm} color={confirmColor}>
|
|
62
64
|
{confirmAction}
|
|
63
65
|
</Button>
|
|
64
66
|
</DialogActions>
|