@canonical/react-components 0.51.6 → 0.52.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.
|
@@ -28,6 +28,14 @@ export type Props = PropsWithSpread<{
|
|
|
28
28
|
* Function to perform the action prompted by the modal.
|
|
29
29
|
*/
|
|
30
30
|
onConfirm: (event: MouseEvent<HTMLElement>) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the confirm button should be in the loading state.
|
|
33
|
+
*/
|
|
34
|
+
confirmButtonLoading?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the confirm button should be disabled.
|
|
37
|
+
*/
|
|
38
|
+
confirmButtonDisabled?: boolean;
|
|
31
39
|
}, Omit<ModalProps, "buttonRow">>;
|
|
32
|
-
export declare const ConfirmationModal: ({ cancelButtonLabel, children, confirmButtonAppearance, confirmButtonLabel, confirmExtra, onConfirm, ...props }: Props) => ReactElement;
|
|
40
|
+
export declare const ConfirmationModal: ({ cancelButtonLabel, children, confirmButtonAppearance, confirmButtonLabel, confirmExtra, onConfirm, confirmButtonLoading, confirmButtonDisabled, ...props }: Props) => ReactElement;
|
|
33
41
|
export default ConfirmationModal;
|
|
@@ -7,6 +7,7 @@ exports.default = exports.ConfirmationModal = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _Button = _interopRequireDefault(require("../Button"));
|
|
9
9
|
var _Modal = _interopRequireDefault(require("../Modal"));
|
|
10
|
+
var _ActionButton = _interopRequireDefault(require("../ActionButton"));
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
13
|
const ConfirmationModal = _ref => {
|
|
@@ -17,6 +18,8 @@ const ConfirmationModal = _ref => {
|
|
|
17
18
|
confirmButtonLabel,
|
|
18
19
|
confirmExtra,
|
|
19
20
|
onConfirm,
|
|
21
|
+
confirmButtonLoading,
|
|
22
|
+
confirmButtonDisabled,
|
|
20
23
|
...props
|
|
21
24
|
} = _ref;
|
|
22
25
|
const handleClick = action => event => {
|
|
@@ -31,10 +34,12 @@ const ConfirmationModal = _ref => {
|
|
|
31
34
|
buttonRow: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, confirmExtra, /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
32
35
|
className: "u-no-margin--bottom",
|
|
33
36
|
onClick: handleClick(props.close)
|
|
34
|
-
}, cancelButtonLabel), /*#__PURE__*/_react.default.createElement(
|
|
37
|
+
}, cancelButtonLabel), /*#__PURE__*/_react.default.createElement(_ActionButton.default, {
|
|
35
38
|
appearance: confirmButtonAppearance,
|
|
36
39
|
className: "u-no-margin--bottom",
|
|
37
|
-
onClick: handleClick(onConfirm)
|
|
40
|
+
onClick: handleClick(onConfirm),
|
|
41
|
+
loading: confirmButtonLoading,
|
|
42
|
+
disabled: confirmButtonDisabled
|
|
38
43
|
}, confirmButtonLabel))
|
|
39
44
|
}, props), children);
|
|
40
45
|
};
|
|
@@ -73,6 +73,7 @@ export declare const adjustForWindow: (position: Position, fitsWindow: WindowFit
|
|
|
73
73
|
* @param positionElementClassName An optional class to apply to the element that wraps the children.
|
|
74
74
|
* @param tooltipClassName An optional class to apply to the tooltip message element.
|
|
75
75
|
* @param zIndex The z-index value of the tooltip message element.
|
|
76
|
+
* @param delay Delay in ms after which Tooltip will appear (defaults to 350ms).
|
|
76
77
|
*/
|
|
77
78
|
declare const Tooltip: ({ autoAdjust, children, className, followMouse, message, position, positionElementClassName, tooltipClassName, zIndex, delay, }: Props) => JSX.Element;
|
|
78
79
|
export default Tooltip;
|
|
@@ -115,6 +115,7 @@ const adjustForWindow = (position, fitsWindow) => {
|
|
|
115
115
|
* @param positionElementClassName An optional class to apply to the element that wraps the children.
|
|
116
116
|
* @param tooltipClassName An optional class to apply to the tooltip message element.
|
|
117
117
|
* @param zIndex The z-index value of the tooltip message element.
|
|
118
|
+
* @param delay Delay in ms after which Tooltip will appear (defaults to 350ms).
|
|
118
119
|
*/
|
|
119
120
|
exports.adjustForWindow = adjustForWindow;
|
|
120
121
|
const Tooltip = _ref => {
|
|
@@ -210,9 +211,15 @@ const Tooltip = _ref => {
|
|
|
210
211
|
openPortal(e);
|
|
211
212
|
};
|
|
212
213
|
const delayedOpenPortal = (0, _react.useCallback)(() => {
|
|
214
|
+
if (isOpen) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (timer) {
|
|
218
|
+
clearTimeout(timer);
|
|
219
|
+
}
|
|
213
220
|
const timeout = setTimeout(() => openPortal(), delay);
|
|
214
221
|
setTimer(timeout);
|
|
215
|
-
}, [delay, openPortal]);
|
|
222
|
+
}, [delay, openPortal, timer, isOpen]);
|
|
216
223
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, message ? /*#__PURE__*/_react.default.createElement("span", {
|
|
217
224
|
className: className,
|
|
218
225
|
onBlur: handleBlur,
|