carbon-react 123.1.0 → 123.2.0
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,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { DialogProps } from "../dialog";
|
|
3
3
|
import { IconType } from "../icon";
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
5
|
export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFocusTrap" | "bespokeFocusTrap" | "focusableSelectors" | "help" | "role" | "contentPadding" | "focusableContainers" | "ariaRole" | "timeout" | "enableBackgroundUI" | "disableClose"> {
|
|
5
6
|
/** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground" */
|
|
6
7
|
cancelButtonType?: "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground";
|
|
@@ -22,6 +23,10 @@ export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFo
|
|
|
22
23
|
confirmButtonIconPosition?: "before" | "after";
|
|
23
24
|
/** Defines an Icon type within the confirm button (see Icon for options) */
|
|
24
25
|
confirmButtonIconType?: IconType;
|
|
26
|
+
/** Data tag prop bag for cancelButton */
|
|
27
|
+
cancelButtonDataProps?: TagProps;
|
|
28
|
+
/** Data tag prop bag for confirmButton */
|
|
29
|
+
confirmButtonDataProps?: TagProps;
|
|
25
30
|
/** Makes cancel button disabled */
|
|
26
31
|
disableCancel?: boolean;
|
|
27
32
|
/** Makes confirm button disabled */
|
|
@@ -33,5 +38,5 @@ export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFo
|
|
|
33
38
|
/** A custom event handler when a confirmation takes place */
|
|
34
39
|
onConfirm: (ev: React.MouseEvent<HTMLButtonElement>) => void;
|
|
35
40
|
}
|
|
36
|
-
export declare const Confirm: ({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, size, showCloseIcon, ...rest }: ConfirmProps) => React.JSX.Element;
|
|
41
|
+
export declare const Confirm: ({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelButtonDataProps, confirmButtonDataProps, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, size, showCloseIcon, ...rest }: ConfirmProps) => React.JSX.Element;
|
|
37
42
|
export default Confirm;
|
|
@@ -9,6 +9,7 @@ import Button from "../button/button.component";
|
|
|
9
9
|
import Icon from "../icon";
|
|
10
10
|
import Loader from "../loader";
|
|
11
11
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
12
|
+
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
12
13
|
export const Confirm = ({
|
|
13
14
|
"aria-labelledby": ariaLabelledBy,
|
|
14
15
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -23,6 +24,8 @@ export const Confirm = ({
|
|
|
23
24
|
cancelButtonIconPosition,
|
|
24
25
|
confirmButtonIconType,
|
|
25
26
|
confirmButtonIconPosition,
|
|
27
|
+
cancelButtonDataProps,
|
|
28
|
+
confirmButtonDataProps,
|
|
26
29
|
cancelLabel,
|
|
27
30
|
onCancel,
|
|
28
31
|
disableCancel,
|
|
@@ -57,26 +60,30 @@ export const Confirm = ({
|
|
|
57
60
|
}
|
|
58
61
|
const renderCancelButton = () => {
|
|
59
62
|
if (!onCancel) return null;
|
|
60
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
63
|
+
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
61
64
|
onClick: onCancel,
|
|
62
|
-
"data-element": "cancel",
|
|
63
65
|
buttonType: cancelButtonType,
|
|
64
66
|
destructive: cancelButtonDestructive,
|
|
65
67
|
disabled: disableCancel,
|
|
66
68
|
iconType: cancelButtonIconType,
|
|
67
69
|
iconPosition: cancelButtonIconPosition
|
|
68
|
-
},
|
|
70
|
+
}, tagComponent("cancel", {
|
|
71
|
+
"data-element": "cancel",
|
|
72
|
+
...cancelButtonDataProps
|
|
73
|
+
})), cancelLabel || l.confirm.no());
|
|
69
74
|
};
|
|
70
|
-
const renderConfirmButton = () => /*#__PURE__*/React.createElement(Button, {
|
|
75
|
+
const renderConfirmButton = () => /*#__PURE__*/React.createElement(Button, _extends({
|
|
71
76
|
onClick: onConfirm,
|
|
72
|
-
"data-element": "confirm",
|
|
73
77
|
buttonType: confirmButtonType,
|
|
74
78
|
destructive: confirmButtonDestructive,
|
|
75
79
|
disabled: isLoadingConfirm || disableConfirm,
|
|
76
80
|
ml: 2,
|
|
77
81
|
iconType: confirmButtonIconType,
|
|
78
82
|
iconPosition: confirmButtonIconPosition
|
|
79
|
-
},
|
|
83
|
+
}, tagComponent("confirm", {
|
|
84
|
+
"data-element": "confirm",
|
|
85
|
+
...confirmButtonDataProps
|
|
86
|
+
})), isLoadingConfirm ? /*#__PURE__*/React.createElement(Loader, {
|
|
80
87
|
isInsideButton: true,
|
|
81
88
|
isActive: true
|
|
82
89
|
}) : confirmLabel || l.confirm.yes());
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { DialogProps } from "../dialog";
|
|
3
3
|
import { IconType } from "../icon";
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
5
|
export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFocusTrap" | "bespokeFocusTrap" | "focusableSelectors" | "help" | "role" | "contentPadding" | "focusableContainers" | "ariaRole" | "timeout" | "enableBackgroundUI" | "disableClose"> {
|
|
5
6
|
/** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground" */
|
|
6
7
|
cancelButtonType?: "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground";
|
|
@@ -22,6 +23,10 @@ export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFo
|
|
|
22
23
|
confirmButtonIconPosition?: "before" | "after";
|
|
23
24
|
/** Defines an Icon type within the confirm button (see Icon for options) */
|
|
24
25
|
confirmButtonIconType?: IconType;
|
|
26
|
+
/** Data tag prop bag for cancelButton */
|
|
27
|
+
cancelButtonDataProps?: TagProps;
|
|
28
|
+
/** Data tag prop bag for confirmButton */
|
|
29
|
+
confirmButtonDataProps?: TagProps;
|
|
25
30
|
/** Makes cancel button disabled */
|
|
26
31
|
disableCancel?: boolean;
|
|
27
32
|
/** Makes confirm button disabled */
|
|
@@ -33,5 +38,5 @@ export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFo
|
|
|
33
38
|
/** A custom event handler when a confirmation takes place */
|
|
34
39
|
onConfirm: (ev: React.MouseEvent<HTMLButtonElement>) => void;
|
|
35
40
|
}
|
|
36
|
-
export declare const Confirm: ({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, size, showCloseIcon, ...rest }: ConfirmProps) => React.JSX.Element;
|
|
41
|
+
export declare const Confirm: ({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelButtonDataProps, confirmButtonDataProps, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, size, showCloseIcon, ...rest }: ConfirmProps) => React.JSX.Element;
|
|
37
42
|
export default Confirm;
|
|
@@ -14,6 +14,7 @@ var _button = _interopRequireDefault(require("../button/button.component"));
|
|
|
14
14
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
15
15
|
var _loader = _interopRequireDefault(require("../loader"));
|
|
16
16
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
17
|
+
var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags"));
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -32,6 +33,8 @@ const Confirm = ({
|
|
|
32
33
|
cancelButtonIconPosition,
|
|
33
34
|
confirmButtonIconType,
|
|
34
35
|
confirmButtonIconPosition,
|
|
36
|
+
cancelButtonDataProps,
|
|
37
|
+
confirmButtonDataProps,
|
|
35
38
|
cancelLabel,
|
|
36
39
|
onCancel,
|
|
37
40
|
disableCancel,
|
|
@@ -66,26 +69,30 @@ const Confirm = ({
|
|
|
66
69
|
}
|
|
67
70
|
const renderCancelButton = () => {
|
|
68
71
|
if (!onCancel) return null;
|
|
69
|
-
return /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_button.default, _extends({
|
|
70
73
|
onClick: onCancel,
|
|
71
|
-
"data-element": "cancel",
|
|
72
74
|
buttonType: cancelButtonType,
|
|
73
75
|
destructive: cancelButtonDestructive,
|
|
74
76
|
disabled: disableCancel,
|
|
75
77
|
iconType: cancelButtonIconType,
|
|
76
78
|
iconPosition: cancelButtonIconPosition
|
|
77
|
-
},
|
|
79
|
+
}, (0, _tags.default)("cancel", {
|
|
80
|
+
"data-element": "cancel",
|
|
81
|
+
...cancelButtonDataProps
|
|
82
|
+
})), cancelLabel || l.confirm.no());
|
|
78
83
|
};
|
|
79
|
-
const renderConfirmButton = () => /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
84
|
+
const renderConfirmButton = () => /*#__PURE__*/_react.default.createElement(_button.default, _extends({
|
|
80
85
|
onClick: onConfirm,
|
|
81
|
-
"data-element": "confirm",
|
|
82
86
|
buttonType: confirmButtonType,
|
|
83
87
|
destructive: confirmButtonDestructive,
|
|
84
88
|
disabled: isLoadingConfirm || disableConfirm,
|
|
85
89
|
ml: 2,
|
|
86
90
|
iconType: confirmButtonIconType,
|
|
87
91
|
iconPosition: confirmButtonIconPosition
|
|
88
|
-
},
|
|
92
|
+
}, (0, _tags.default)("confirm", {
|
|
93
|
+
"data-element": "confirm",
|
|
94
|
+
...confirmButtonDataProps
|
|
95
|
+
})), isLoadingConfirm ? /*#__PURE__*/_react.default.createElement(_loader.default, {
|
|
89
96
|
isInsideButton: true,
|
|
90
97
|
isActive: true
|
|
91
98
|
}) : confirmLabel || l.confirm.yes());
|