carbon-react 106.6.10 → 107.1.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.
- package/esm/__internal__/click-away-wrapper/click-away-wrapper.component.d.ts +12 -0
- package/esm/__internal__/click-away-wrapper/click-away-wrapper.component.js +43 -0
- package/esm/__internal__/click-away-wrapper/index.d.ts +2 -0
- package/esm/__internal__/click-away-wrapper/index.js +1 -0
- package/esm/__internal__/focus-trap/focus-trap-utils.js +25 -1
- package/esm/__internal__/focus-trap/focus-trap.component.d.ts +3 -1
- package/esm/__internal__/focus-trap/focus-trap.component.js +44 -12
- package/esm/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.d.ts +0 -0
- package/esm/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.js +0 -0
- package/esm/components/advanced-color-picker/advanced-color-picker.component.js +5 -5
- package/esm/components/badge/badge.style.d.ts +1 -1
- package/esm/components/button/button.component.d.ts +1 -3
- package/esm/components/button/button.component.js +1 -12
- package/esm/components/button/button.style.d.ts +1 -1
- package/esm/components/button-toggle-group/button-toggle-group.component.js +1 -1
- package/esm/components/confirm/confirm.component.d.ts +1 -5
- package/esm/components/confirm/confirm.component.js +2 -14
- package/esm/components/confirm/confirm.d.ts +0 -2
- package/esm/components/date/date.component.js +19 -20
- package/esm/components/dialog/dialog.component.js +4 -3
- package/esm/components/dialog-full-screen/content.style.js +4 -10
- package/esm/components/dialog-full-screen/dialog-full-screen.component.js +4 -3
- package/esm/components/heading/heading.component.d.ts +27 -52
- package/esm/components/heading/heading.component.js +86 -170
- package/esm/components/heading/heading.d.ts +5 -3
- package/esm/components/i18n-provider/i18n-provider.component.d.ts +0 -9
- package/esm/components/i18n-provider/i18n-provider.component.js +0 -9
- package/esm/components/menu/__internal__/submenu/submenu.component.js +11 -17
- package/esm/components/menu/index.d.ts +0 -1
- package/esm/components/menu/index.js +0 -1
- package/esm/components/menu/menu-full-screen/menu-full-screen.component.js +4 -18
- package/esm/components/menu/menu-full-screen/menu-full-screen.style.js +1 -0
- package/esm/components/menu/menu-item/menu-item.component.js +0 -6
- package/esm/components/multi-action-button/multi-action-button.component.d.ts +1 -1
- package/esm/components/multi-action-button/multi-action-button.component.js +1 -11
- package/esm/components/navigation-bar/navigation-bar.component.d.ts +1 -6
- package/esm/components/navigation-bar/navigation-bar.component.js +1 -15
- package/esm/components/navigation-bar/navigation-bar.style.d.ts +0 -4
- package/esm/components/navigation-bar/navigation-bar.style.js +0 -8
- package/esm/components/popover-container/popover-container.component.js +16 -3
- package/esm/components/radio-button/radio-button-group.component.js +1 -1
- package/esm/components/select/select-list/select-list.component.js +2 -2
- package/esm/components/sidebar/__internal__/sidebar-header/sidebar-header.component.d.ts +3 -1
- package/esm/components/sidebar/__internal__/sidebar-header/sidebar-header.component.js +7 -2
- package/esm/components/sidebar/sidebar.component.js +10 -3
- package/esm/components/simple-color-picker/simple-color-picker.component.js +1 -1
- package/esm/components/split-button/split-button-toggle.style.d.ts +1 -1
- package/esm/components/split-button/split-button.component.d.ts +1 -4
- package/esm/components/split-button/split-button.component.js +3 -16
- package/esm/components/split-button/split-button.d.ts +0 -2
- package/esm/components/tile/tile.component.d.ts +1 -2
- package/esm/components/tile/tile.component.js +1 -13
- package/esm/components/tile/tile.d.ts +0 -2
- package/esm/components/tile-select/tile-select-group.component.js +1 -1
- package/esm/components/toast/toast.component.d.ts +1 -4
- package/esm/components/toast/toast.component.js +1 -13
- package/esm/components/toast/toast.d.ts +0 -2
- package/esm/locales/en-gb.js +0 -9
- package/esm/locales/locale.d.ts +0 -9
- package/esm/locales/pl-pl.js +0 -9
- package/lib/__internal__/click-away-wrapper/click-away-wrapper.component.d.ts +12 -0
- package/lib/__internal__/click-away-wrapper/click-away-wrapper.component.js +59 -0
- package/lib/__internal__/click-away-wrapper/index.d.ts +2 -0
- package/lib/{components/menu/submenu-block → __internal__/click-away-wrapper}/index.js +2 -2
- package/lib/{components/scrollable-list → __internal__/click-away-wrapper}/package.json +1 -1
- package/lib/__internal__/focus-trap/focus-trap-utils.js +25 -1
- package/lib/__internal__/focus-trap/focus-trap.component.d.ts +3 -1
- package/lib/__internal__/focus-trap/focus-trap.component.js +46 -12
- package/lib/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.d.ts +0 -0
- package/lib/{components/radio-button → __internal__/radio-button-mapper}/radio-button-mapper.component.js +0 -0
- package/lib/components/advanced-color-picker/advanced-color-picker.component.js +5 -5
- package/lib/components/badge/badge.style.d.ts +1 -1
- package/lib/components/button/button.component.d.ts +1 -3
- package/lib/components/button/button.component.js +1 -14
- package/lib/components/button/button.style.d.ts +1 -1
- package/lib/components/button-toggle-group/button-toggle-group.component.js +1 -1
- package/lib/components/confirm/confirm.component.d.ts +1 -5
- package/lib/components/confirm/confirm.component.js +2 -17
- package/lib/components/confirm/confirm.d.ts +0 -2
- package/lib/components/date/date.component.js +20 -20
- package/lib/components/dialog/dialog.component.js +4 -3
- package/lib/components/dialog-full-screen/content.style.js +4 -10
- package/lib/components/dialog-full-screen/dialog-full-screen.component.js +4 -3
- package/lib/components/heading/heading.component.d.ts +27 -52
- package/lib/components/heading/heading.component.js +86 -170
- package/lib/components/heading/heading.d.ts +5 -3
- package/lib/components/i18n-provider/i18n-provider.component.d.ts +0 -9
- package/lib/components/i18n-provider/i18n-provider.component.js +0 -9
- package/lib/components/menu/__internal__/submenu/submenu.component.js +12 -17
- package/lib/components/menu/index.d.ts +0 -1
- package/lib/components/menu/index.js +0 -8
- package/lib/components/menu/menu-full-screen/menu-full-screen.component.js +3 -17
- package/lib/components/menu/menu-full-screen/menu-full-screen.style.js +1 -0
- package/lib/components/menu/menu-item/menu-item.component.js +0 -7
- package/lib/components/multi-action-button/multi-action-button.component.d.ts +1 -1
- package/lib/components/multi-action-button/multi-action-button.component.js +1 -14
- package/lib/components/navigation-bar/navigation-bar.component.d.ts +1 -6
- package/lib/components/navigation-bar/navigation-bar.component.js +1 -18
- package/lib/components/navigation-bar/navigation-bar.style.d.ts +0 -4
- package/lib/components/navigation-bar/navigation-bar.style.js +0 -8
- package/lib/components/popover-container/popover-container.component.js +17 -3
- package/lib/components/radio-button/radio-button-group.component.js +1 -1
- package/lib/components/select/select-list/select-list.component.js +2 -2
- package/lib/components/sidebar/__internal__/sidebar-header/sidebar-header.component.d.ts +3 -1
- package/lib/components/sidebar/__internal__/sidebar-header/sidebar-header.component.js +7 -2
- package/lib/components/sidebar/sidebar.component.js +11 -3
- package/lib/components/simple-color-picker/simple-color-picker.component.js +1 -1
- package/lib/components/split-button/split-button-toggle.style.d.ts +1 -1
- package/lib/components/split-button/split-button.component.d.ts +1 -4
- package/lib/components/split-button/split-button.component.js +3 -18
- package/lib/components/split-button/split-button.d.ts +0 -2
- package/lib/components/tile/tile.component.d.ts +1 -2
- package/lib/components/tile/tile.component.js +1 -16
- package/lib/components/tile/tile.d.ts +0 -2
- package/lib/components/tile-select/tile-select-group.component.js +1 -1
- package/lib/components/toast/toast.component.d.ts +1 -4
- package/lib/components/toast/toast.component.js +1 -16
- package/lib/components/toast/toast.d.ts +0 -2
- package/lib/locales/en-gb.js +0 -9
- package/lib/locales/locale.d.ts +0 -9
- package/lib/locales/pl-pl.js +0 -9
- package/package.json +1 -1
- package/esm/components/app-wrapper/app-wrapper.component.d.ts +0 -25
- package/esm/components/app-wrapper/app-wrapper.component.js +0 -104
- package/esm/components/app-wrapper/app-wrapper.d.ts +0 -12
- package/esm/components/app-wrapper/app-wrapper.style.d.ts +0 -2
- package/esm/components/app-wrapper/app-wrapper.style.js +0 -17
- package/esm/components/app-wrapper/index.d.ts +0 -1
- package/esm/components/app-wrapper/index.js +0 -1
- package/esm/components/menu/submenu-block/index.d.ts +0 -2
- package/esm/components/menu/submenu-block/index.js +0 -1
- package/esm/components/menu/submenu-block/submenu-block.component.d.ts +0 -12
- package/esm/components/menu/submenu-block/submenu-block.component.js +0 -34
- package/esm/components/menu/submenu-block/submenu-block.d.ts +0 -12
- package/esm/components/menu/submenu-block/submenu-block.style.d.ts +0 -2
- package/esm/components/menu/submenu-block/submenu-block.style.js +0 -16
- package/esm/components/mount-in-app/__spec__.d.ts +0 -1
- package/esm/components/mount-in-app/__spec__.js +0 -47
- package/esm/components/mount-in-app/index.d.ts +0 -1
- package/esm/components/mount-in-app/mount-in-app.d.ts +0 -12
- package/esm/components/mount-in-app/mount-in-app.js +0 -90
- package/esm/components/mount-in-app/package.json +0 -3
- package/esm/components/multi-step-wizard/__spec__.d.ts +0 -1
- package/esm/components/multi-step-wizard/__spec__.js +0 -191
- package/esm/components/multi-step-wizard/multi-step-wizard.d.ts +0 -109
- package/esm/components/multi-step-wizard/multi-step-wizard.js +0 -383
- package/esm/components/multi-step-wizard/multi-step-wizard.style.d.ts +0 -2
- package/esm/components/multi-step-wizard/multi-step-wizard.style.js +0 -10
- package/esm/components/multi-step-wizard/package.json +0 -4
- package/esm/components/multi-step-wizard/step/__spec__.d.ts +0 -1
- package/esm/components/multi-step-wizard/step/__spec__.js +0 -399
- package/esm/components/multi-step-wizard/step/package.json +0 -4
- package/esm/components/multi-step-wizard/step/step.d.ts +0 -166
- package/esm/components/multi-step-wizard/step/step.js +0 -407
- package/esm/components/multi-step-wizard/step/step.style.d.ts +0 -13
- package/esm/components/multi-step-wizard/step/step.style.js +0 -138
- package/esm/components/scrollable-list/as-scrollable-list-item.wrapper.d.ts +0 -2
- package/esm/components/scrollable-list/as-scrollable-list-item.wrapper.js +0 -10
- package/esm/components/scrollable-list/index.d.ts +0 -4
- package/esm/components/scrollable-list/index.js +0 -4
- package/esm/components/scrollable-list/scrollable-list-item.component.d.ts +0 -2
- package/esm/components/scrollable-list/scrollable-list-item.component.js +0 -26
- package/esm/components/scrollable-list/scrollable-list.component.d.ts +0 -52
- package/esm/components/scrollable-list/scrollable-list.component.js +0 -306
- package/esm/components/scrollable-list/scrollable-list.context.d.ts +0 -3
- package/esm/components/scrollable-list/scrollable-list.context.js +0 -2
- package/esm/components/scrollable-list/scrollable-list.style.d.ts +0 -2
- package/esm/components/scrollable-list/scrollable-list.style.js +0 -30
- package/esm/components/scrollable-list/test-utils.d.ts +0 -2
- package/esm/components/scrollable-list/test-utils.js +0 -25
- package/lib/components/app-wrapper/app-wrapper.component.d.ts +0 -25
- package/lib/components/app-wrapper/app-wrapper.component.js +0 -120
- package/lib/components/app-wrapper/app-wrapper.d.ts +0 -12
- package/lib/components/app-wrapper/app-wrapper.style.d.ts +0 -2
- package/lib/components/app-wrapper/app-wrapper.style.js +0 -28
- package/lib/components/app-wrapper/index.d.ts +0 -1
- package/lib/components/app-wrapper/index.js +0 -15
- package/lib/components/app-wrapper/package.json +0 -6
- package/lib/components/menu/submenu-block/index.d.ts +0 -2
- package/lib/components/menu/submenu-block/package.json +0 -6
- package/lib/components/menu/submenu-block/submenu-block.component.d.ts +0 -12
- package/lib/components/menu/submenu-block/submenu-block.component.js +0 -53
- package/lib/components/menu/submenu-block/submenu-block.d.ts +0 -12
- package/lib/components/menu/submenu-block/submenu-block.style.d.ts +0 -2
- package/lib/components/menu/submenu-block/submenu-block.style.js +0 -33
- package/lib/components/mount-in-app/__spec__.d.ts +0 -1
- package/lib/components/mount-in-app/__spec__.js +0 -55
- package/lib/components/mount-in-app/index.d.ts +0 -1
- package/lib/components/mount-in-app/mount-in-app.d.ts +0 -12
- package/lib/components/mount-in-app/mount-in-app.js +0 -105
- package/lib/components/mount-in-app/package.json +0 -3
- package/lib/components/multi-step-wizard/__spec__.d.ts +0 -1
- package/lib/components/multi-step-wizard/__spec__.js +0 -202
- package/lib/components/multi-step-wizard/multi-step-wizard.d.ts +0 -109
- package/lib/components/multi-step-wizard/multi-step-wizard.js +0 -397
- package/lib/components/multi-step-wizard/multi-step-wizard.style.d.ts +0 -2
- package/lib/components/multi-step-wizard/multi-step-wizard.style.js +0 -21
- package/lib/components/multi-step-wizard/package.json +0 -4
- package/lib/components/multi-step-wizard/step/__spec__.d.ts +0 -1
- package/lib/components/multi-step-wizard/step/__spec__.js +0 -409
- package/lib/components/multi-step-wizard/step/package.json +0 -4
- package/lib/components/multi-step-wizard/step/step.d.ts +0 -166
- package/lib/components/multi-step-wizard/step/step.js +0 -421
- package/lib/components/multi-step-wizard/step/step.style.d.ts +0 -13
- package/lib/components/multi-step-wizard/step/step.style.js +0 -162
- package/lib/components/scrollable-list/as-scrollable-list-item.wrapper.d.ts +0 -2
- package/lib/components/scrollable-list/as-scrollable-list-item.wrapper.js +0 -21
- package/lib/components/scrollable-list/index.d.ts +0 -4
- package/lib/components/scrollable-list/index.js +0 -31
- package/lib/components/scrollable-list/scrollable-list-item.component.d.ts +0 -2
- package/lib/components/scrollable-list/scrollable-list-item.component.js +0 -42
- package/lib/components/scrollable-list/scrollable-list.component.d.ts +0 -52
- package/lib/components/scrollable-list/scrollable-list.component.js +0 -328
- package/lib/components/scrollable-list/scrollable-list.context.d.ts +0 -3
- package/lib/components/scrollable-list/scrollable-list.context.js +0 -14
- package/lib/components/scrollable-list/scrollable-list.style.d.ts +0 -2
- package/lib/components/scrollable-list/scrollable-list.style.js +0 -41
- package/lib/components/scrollable-list/test-utils.d.ts +0 -2
- package/lib/components/scrollable-list/test-utils.js +0 -37
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _events = _interopRequireDefault(require("../utils/helpers/events"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
19
|
+
|
|
20
|
+
const ClickAwayWrapper = ({
|
|
21
|
+
children,
|
|
22
|
+
handleClickAway,
|
|
23
|
+
eventTypeId = "click",
|
|
24
|
+
targets
|
|
25
|
+
}) => {
|
|
26
|
+
(0, _react.useEffect)(() => {
|
|
27
|
+
const fnClickAway = ev => {
|
|
28
|
+
const clickedElements = targets.filter(ref => (ref === null || ref === void 0 ? void 0 : ref.current) && _events.default.composedPath(ev).includes(ref.current));
|
|
29
|
+
|
|
30
|
+
if (!clickedElements || !clickedElements.length) {
|
|
31
|
+
handleClickAway(ev);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
document.addEventListener(eventTypeId, fnClickAway);
|
|
36
|
+
return function cleanup() {
|
|
37
|
+
document.removeEventListener(eventTypeId, fnClickAway);
|
|
38
|
+
};
|
|
39
|
+
}, [handleClickAway, targets, eventTypeId]);
|
|
40
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
ClickAwayWrapper.propTypes = {
|
|
44
|
+
"children": _propTypes.default.node,
|
|
45
|
+
"eventTypeId": _propTypes.default.oneOf(["click", "mousedown"]),
|
|
46
|
+
"handleClickAway": _propTypes.default.func.isRequired,
|
|
47
|
+
"targets": _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
48
|
+
"current": _propTypes.default.oneOfType([_propTypes.default.oneOf([null]), function (props, propName) {
|
|
49
|
+
if (props[propName] == null) {
|
|
50
|
+
return new Error("Prop '" + propName + "' is required but wasn't specified");
|
|
51
|
+
} else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
52
|
+
return new Error("Expected prop '" + propName + "' to be of type Element");
|
|
53
|
+
}
|
|
54
|
+
}]).isRequired
|
|
55
|
+
})).isRequired
|
|
56
|
+
};
|
|
57
|
+
ClickAwayWrapper.displayName = "ClickAwayWrapper";
|
|
58
|
+
var _default = ClickAwayWrapper;
|
|
59
|
+
exports.default = _default;
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "default", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _clickAwayWrapper.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _clickAwayWrapper = _interopRequireDefault(require("./click-away-wrapper.component"));
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -8,12 +8,36 @@ exports.isRadio = exports.nextNonRadioElementIndex = exports.defaultFocusableSel
|
|
|
8
8
|
const defaultFocusableSelectors = 'button:not([disabled]), [href], input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]';
|
|
9
9
|
exports.defaultFocusableSelectors = defaultFocusableSelectors;
|
|
10
10
|
|
|
11
|
+
const waitForVisibleAndFocus = element => {
|
|
12
|
+
const INTERVAL = 10;
|
|
13
|
+
const MAX_TIME = 100;
|
|
14
|
+
let timeSoFar = 0;
|
|
15
|
+
|
|
16
|
+
const stylesMatch = () => {
|
|
17
|
+
const actualStyles = window.getComputedStyle(element);
|
|
18
|
+
return actualStyles.visibility === "visible";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const check = () => {
|
|
22
|
+
/* istanbul ignore else */
|
|
23
|
+
if (stylesMatch()) {
|
|
24
|
+
element.focus();
|
|
25
|
+
} else if (timeSoFar < MAX_TIME) {
|
|
26
|
+
setTimeout(check, INTERVAL);
|
|
27
|
+
timeSoFar += INTERVAL;
|
|
28
|
+
} // just "fail" silently if maxTime exceeded - callback will never be called
|
|
29
|
+
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
check();
|
|
33
|
+
};
|
|
34
|
+
|
|
11
35
|
function setElementFocus(element) {
|
|
12
36
|
if (typeof element === "function") {
|
|
13
37
|
element();
|
|
14
38
|
} else {
|
|
15
39
|
const el = element.current || element;
|
|
16
|
-
el
|
|
40
|
+
waitForVisibleAndFocus(el);
|
|
17
41
|
}
|
|
18
42
|
}
|
|
19
43
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export default FocusTrap;
|
|
2
|
-
declare function FocusTrap({ children, autoFocus, focusFirstElement, bespokeTrap, wrapperRef, }: {
|
|
2
|
+
declare function FocusTrap({ children, autoFocus, focusFirstElement, bespokeTrap, wrapperRef, isOpen, }: {
|
|
3
3
|
children: any;
|
|
4
4
|
autoFocus?: boolean | undefined;
|
|
5
5
|
focusFirstElement: any;
|
|
6
6
|
bespokeTrap: any;
|
|
7
7
|
wrapperRef: any;
|
|
8
|
+
isOpen: any;
|
|
8
9
|
}): JSX.Element;
|
|
9
10
|
declare namespace FocusTrap {
|
|
10
11
|
namespace propTypes {
|
|
@@ -17,6 +18,7 @@ declare namespace FocusTrap {
|
|
|
17
18
|
const wrapperRef: PropTypes.Requireable<PropTypes.InferProps<{
|
|
18
19
|
current: PropTypes.Requireable<any>;
|
|
19
20
|
}>>;
|
|
21
|
+
const isOpen: PropTypes.Requireable<boolean>;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
import PropTypes from "prop-types";
|
|
@@ -13,6 +13,8 @@ var _focusTrapUtils = require("./focus-trap-utils");
|
|
|
13
13
|
|
|
14
14
|
var _modal = require("../../components/modal/modal.component");
|
|
15
15
|
|
|
16
|
+
var _usePrevious = _interopRequireDefault(require("../../hooks/__internal__/usePrevious"));
|
|
17
|
+
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
20
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -24,16 +26,16 @@ const FocusTrap = ({
|
|
|
24
26
|
autoFocus = true,
|
|
25
27
|
focusFirstElement,
|
|
26
28
|
bespokeTrap,
|
|
27
|
-
wrapperRef
|
|
29
|
+
wrapperRef,
|
|
30
|
+
isOpen
|
|
28
31
|
}) => {
|
|
29
32
|
const trapRef = (0, _react.useRef)(null);
|
|
30
|
-
const firstOpen = (0, _react.useRef)(true);
|
|
31
33
|
const [focusableElements, setFocusableElements] = (0, _react.useState)();
|
|
32
34
|
const [firstElement, setFirstElement] = (0, _react.useState)();
|
|
33
35
|
const [lastElement, setLastElement] = (0, _react.useState)();
|
|
34
36
|
const [currentFocusedElement, setCurrentFocusedElement] = (0, _react.useState)();
|
|
35
37
|
const {
|
|
36
|
-
isAnimationComplete,
|
|
38
|
+
isAnimationComplete = true,
|
|
37
39
|
triggerRefocusFlag
|
|
38
40
|
} = (0, _react.useContext)(_modal.ModalContext);
|
|
39
41
|
const hasNewInputs = (0, _react.useCallback)(candidate => {
|
|
@@ -69,12 +71,13 @@ const FocusTrap = ({
|
|
|
69
71
|
(0, _react.useLayoutEffect)(() => {
|
|
70
72
|
updateFocusableElements();
|
|
71
73
|
}, [children, updateFocusableElements]);
|
|
74
|
+
const shouldSetFocus = autoFocus && isOpen && isAnimationComplete && (focusFirstElement || (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current));
|
|
75
|
+
const prevShouldSetFocus = (0, _usePrevious.default)(shouldSetFocus);
|
|
72
76
|
(0, _react.useEffect)(() => {
|
|
73
|
-
if (
|
|
74
|
-
(0, _focusTrapUtils.setElementFocus)(focusFirstElement ||
|
|
75
|
-
firstOpen.current = false;
|
|
77
|
+
if (shouldSetFocus && !prevShouldSetFocus) {
|
|
78
|
+
(0, _focusTrapUtils.setElementFocus)(focusFirstElement || (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current));
|
|
76
79
|
}
|
|
77
|
-
}, [
|
|
80
|
+
}, [shouldSetFocus, prevShouldSetFocus, focusFirstElement, wrapperRef]);
|
|
78
81
|
(0, _react.useEffect)(() => {
|
|
79
82
|
const trapFn = ev => {
|
|
80
83
|
if (bespokeTrap) {
|
|
@@ -92,7 +95,7 @@ const FocusTrap = ({
|
|
|
92
95
|
ev.preventDefault();
|
|
93
96
|
} else if (ev.shiftKey) {
|
|
94
97
|
/* shift + tab */
|
|
95
|
-
if (activeElement === firstElement) {
|
|
98
|
+
if (activeElement === firstElement || activeElement === wrapperRef.current) {
|
|
96
99
|
lastElement.focus();
|
|
97
100
|
ev.preventDefault();
|
|
98
101
|
} // If current element is radio button -
|
|
@@ -115,7 +118,7 @@ const FocusTrap = ({
|
|
|
115
118
|
return function cleanup() {
|
|
116
119
|
document.removeEventListener("keydown", trapFn);
|
|
117
120
|
};
|
|
118
|
-
}, [firstElement, lastElement, focusableElements, bespokeTrap]);
|
|
121
|
+
}, [firstElement, lastElement, focusableElements, bespokeTrap, wrapperRef]);
|
|
119
122
|
const updateCurrentFocusedElement = (0, _react.useCallback)(() => {
|
|
120
123
|
const element = focusableElements === null || focusableElements === void 0 ? void 0 : focusableElements.find(el => el === document.activeElement);
|
|
121
124
|
|
|
@@ -130,22 +133,50 @@ const FocusTrap = ({
|
|
|
130
133
|
};
|
|
131
134
|
}, [updateCurrentFocusedElement]);
|
|
132
135
|
const refocusTrap = (0, _react.useCallback)(() => {
|
|
136
|
+
var _wrapperRef$current;
|
|
137
|
+
|
|
133
138
|
/* istanbul ignore else */
|
|
134
139
|
if (currentFocusedElement && !currentFocusedElement.hasAttribute("disabled")) {
|
|
135
140
|
// the trap breaks if it tries to refocus a disabled element
|
|
136
141
|
(0, _focusTrapUtils.setElementFocus)(currentFocusedElement);
|
|
142
|
+
} else if (wrapperRef !== null && wrapperRef !== void 0 && (_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.hasAttribute("tabindex")) {
|
|
143
|
+
(0, _focusTrapUtils.setElementFocus)(wrapperRef.current);
|
|
137
144
|
} else if (firstElement) {
|
|
138
145
|
(0, _focusTrapUtils.setElementFocus)(firstElement);
|
|
139
146
|
}
|
|
140
|
-
}, [currentFocusedElement, firstElement]);
|
|
147
|
+
}, [currentFocusedElement, firstElement, wrapperRef]);
|
|
141
148
|
(0, _react.useEffect)(() => {
|
|
142
149
|
if (triggerRefocusFlag) {
|
|
143
150
|
refocusTrap();
|
|
144
151
|
}
|
|
145
152
|
}, [triggerRefocusFlag, refocusTrap]);
|
|
153
|
+
const [tabIndex, setTabIndex] = (0, _react.useState)(0);
|
|
154
|
+
(0, _react.useEffect)(() => {
|
|
155
|
+
// issue in cypress prevents setting tabIndex to -1, instead tabIndex is set to 0 and removed on blur.
|
|
156
|
+
if (!isOpen) {
|
|
157
|
+
setTabIndex(0);
|
|
158
|
+
}
|
|
159
|
+
}, [isOpen]);
|
|
160
|
+
|
|
161
|
+
const onBlur = () => {
|
|
162
|
+
/* istanbul ignore else */
|
|
163
|
+
if (isOpen) {
|
|
164
|
+
setTabIndex(undefined);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const focusProps = {
|
|
169
|
+
tabIndex,
|
|
170
|
+
onBlur
|
|
171
|
+
}; // passes focusProps if no tabindex has been explicitly set on the wrapper
|
|
172
|
+
|
|
173
|
+
const clonedChildren = _react.default.Children.map(children, child => {
|
|
174
|
+
return child.props.tabIndex === undefined ? /*#__PURE__*/_react.default.cloneElement(child, focusProps) : child;
|
|
175
|
+
});
|
|
176
|
+
|
|
146
177
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
147
178
|
ref: trapRef
|
|
148
|
-
},
|
|
179
|
+
}, clonedChildren);
|
|
149
180
|
};
|
|
150
181
|
|
|
151
182
|
FocusTrap.propTypes = {
|
|
@@ -165,7 +196,10 @@ FocusTrap.propTypes = {
|
|
|
165
196
|
/** a ref to the container wrapping the focusable elements */
|
|
166
197
|
wrapperRef: _propTypes.default.shape({
|
|
167
198
|
current: _propTypes.default.any
|
|
168
|
-
})
|
|
199
|
+
}),
|
|
200
|
+
|
|
201
|
+
/* whether the modal (etc.) component that the focus trap is inside is open or not */
|
|
202
|
+
isOpen: _propTypes.default.bool
|
|
169
203
|
};
|
|
170
204
|
var _default = FocusTrap;
|
|
171
205
|
exports.default = _default;
|
|
File without changes
|
|
File without changes
|
|
@@ -68,17 +68,17 @@ const AdvancedColorPicker = ({
|
|
|
68
68
|
setSelectedColorRef(selected.ref.current);
|
|
69
69
|
}
|
|
70
70
|
}, [colors, currentColor, dialogOpen, isOpen]);
|
|
71
|
-
const handleFocus = (0, _react.useCallback)((e, firstFocusableElement
|
|
71
|
+
const handleFocus = (0, _react.useCallback)((e, firstFocusableElement) => {
|
|
72
72
|
if (e.key === "Tab") {
|
|
73
73
|
/* istanbul ignore else */
|
|
74
74
|
if (e.shiftKey) {
|
|
75
75
|
/* istanbul ignore else */
|
|
76
|
-
if (document.activeElement ===
|
|
77
|
-
|
|
76
|
+
if (document.activeElement === firstFocusableElement) {
|
|
77
|
+
selectedColorRef.focus();
|
|
78
78
|
e.preventDefault();
|
|
79
79
|
}
|
|
80
|
-
} else if (document.activeElement ===
|
|
81
|
-
|
|
80
|
+
} else if (document.activeElement === selectedColorRef) {
|
|
81
|
+
firstFocusableElement.focus();
|
|
82
82
|
e.preventDefault();
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -3,7 +3,7 @@ import Icon from "../icon";
|
|
|
3
3
|
declare const StyledBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
4
|
declare const StyledCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
5
|
declare const StyledButton: import("styled-components").StyledComponent<{
|
|
6
|
-
({ size, subtext,
|
|
6
|
+
({ size, subtext, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: import("../button").ButtonProps): JSX.Element;
|
|
7
7
|
displayName: string;
|
|
8
8
|
}, any, {}, never>;
|
|
9
9
|
declare const StyledCrossIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
|
|
@@ -10,8 +10,6 @@ export interface ButtonProps extends SpaceProps {
|
|
|
10
10
|
* This is required to comply with WCAG 4.1.2 - Buttons must have discernible text
|
|
11
11
|
*/
|
|
12
12
|
"aria-label"?: string;
|
|
13
|
-
/** [Legacy] Button types for legacy theme: "primary" | "secondary" */
|
|
14
|
-
as?: ButtonTypes;
|
|
15
13
|
/** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "darkBackground" */
|
|
16
14
|
buttonType?: ButtonTypes;
|
|
17
15
|
/** The text the button displays */
|
|
@@ -60,7 +58,7 @@ export interface ButtonProps extends SpaceProps {
|
|
|
60
58
|
rel?: string;
|
|
61
59
|
}
|
|
62
60
|
declare const Button: {
|
|
63
|
-
({ size, subtext,
|
|
61
|
+
({ size, subtext, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: ButtonProps): JSX.Element;
|
|
64
62
|
displayName: string;
|
|
65
63
|
};
|
|
66
64
|
declare const ButtonWithForwardRef: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -19,8 +19,6 @@ var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tag
|
|
|
19
19
|
|
|
20
20
|
var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
21
21
|
|
|
22
|
-
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
23
|
-
|
|
24
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
23
|
|
|
26
24
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -94,12 +92,10 @@ renderChildren.propTypes = {
|
|
|
94
92
|
}
|
|
95
93
|
}
|
|
96
94
|
};
|
|
97
|
-
let deprecatedWarnTriggered = false;
|
|
98
95
|
|
|
99
96
|
const Button = ({
|
|
100
97
|
size = "medium",
|
|
101
98
|
subtext = "",
|
|
102
|
-
as,
|
|
103
99
|
children,
|
|
104
100
|
forwardRef,
|
|
105
101
|
"aria-label": ariaLabel,
|
|
@@ -119,13 +115,6 @@ const Button = ({
|
|
|
119
115
|
fullWidth = false,
|
|
120
116
|
...rest
|
|
121
117
|
}) => {
|
|
122
|
-
if (!deprecatedWarnTriggered && as) {
|
|
123
|
-
deprecatedWarnTriggered = true;
|
|
124
|
-
|
|
125
|
-
_logger.default.deprecate( // eslint-disable-next-line max-len
|
|
126
|
-
"The `as` prop is deprecated and will soon be removed from the `Button` component interface. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
127
|
-
}
|
|
128
|
-
|
|
129
118
|
(0, _invariant.default)(!!(children || iconType), "Either prop `iconType` must be defined or this node must have children.");
|
|
130
119
|
|
|
131
120
|
if (subtext) {
|
|
@@ -133,7 +122,7 @@ const Button = ({
|
|
|
133
122
|
}
|
|
134
123
|
|
|
135
124
|
const [internalRef, setInternalRef] = (0, _react.useState)();
|
|
136
|
-
const buttonType =
|
|
125
|
+
const buttonType = buttonTypeProp;
|
|
137
126
|
let paddingX;
|
|
138
127
|
|
|
139
128
|
const handleLinkKeyDown = event => {
|
|
@@ -203,7 +192,6 @@ const Button = ({
|
|
|
203
192
|
|
|
204
193
|
Button.propTypes = {
|
|
205
194
|
"aria-label": _propTypes.default.string,
|
|
206
|
-
"as": _propTypes.default.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
|
|
207
195
|
"buttonType": _propTypes.default.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
|
|
208
196
|
"children": _propTypes.default.node,
|
|
209
197
|
"destructive": _propTypes.default.bool,
|
|
@@ -546,7 +534,6 @@ const ButtonWithForwardRef = /*#__PURE__*/_react.default.forwardRef((props, ref)
|
|
|
546
534
|
exports.ButtonWithForwardRef = ButtonWithForwardRef;
|
|
547
535
|
ButtonWithForwardRef.propTypes = {
|
|
548
536
|
"aria-label": _propTypes.default.string,
|
|
549
|
-
"as": _propTypes.default.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
|
|
550
537
|
"buttonType": _propTypes.default.oneOf(["darkBackground", "dashed", "primary", "secondary", "tertiary"]),
|
|
551
538
|
"children": _propTypes.default.node,
|
|
552
539
|
"destructive": _propTypes.default.bool,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SpaceProps } from "styled-system";
|
|
2
2
|
import { ButtonProps } from "./button.component";
|
|
3
|
-
declare const StyledButton: import("styled-components").StyledComponent<"button", any, SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> &
|
|
3
|
+
declare const StyledButton: import("styled-components").StyledComponent<"button", any, SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & ButtonProps & {
|
|
4
4
|
iconOnly?: boolean | undefined;
|
|
5
5
|
}, never>;
|
|
6
6
|
export declare const StyledButtonSubtext: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -17,7 +17,7 @@ var _buttonToggleGroup = _interopRequireDefault(require("./button-toggle-group.s
|
|
|
17
17
|
|
|
18
18
|
var _buttonToggle = _interopRequireDefault(require("../button-toggle"));
|
|
19
19
|
|
|
20
|
-
var _radioButtonMapper = _interopRequireDefault(require("
|
|
20
|
+
var _radioButtonMapper = _interopRequireDefault(require("../../__internal__/radio-button-mapper/radio-button-mapper.component"));
|
|
21
21
|
|
|
22
22
|
var _validationIcon = _interopRequireDefault(require("../../__internal__/validations/validation-icon.component"));
|
|
23
23
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export default Confirm;
|
|
2
|
-
declare function Confirm({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children,
|
|
2
|
+
declare function 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, ...rest }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
"aria-labelledby": any;
|
|
5
5
|
"aria-describedby": any;
|
|
6
6
|
"aria-label": any;
|
|
7
7
|
open: any;
|
|
8
8
|
children: any;
|
|
9
|
-
destructive: any;
|
|
10
9
|
cancelButtonDestructive: any;
|
|
11
10
|
confirmButtonDestructive: any;
|
|
12
11
|
cancelButtonType: any;
|
|
@@ -30,7 +29,6 @@ declare namespace Confirm {
|
|
|
30
29
|
namespace defaultProps {
|
|
31
30
|
const size: string;
|
|
32
31
|
const showCloseIcon: boolean;
|
|
33
|
-
const destructive: boolean;
|
|
34
32
|
const cancelButtonDestructive: boolean;
|
|
35
33
|
const confirmButtonDestructive: boolean;
|
|
36
34
|
const iconType: null;
|
|
@@ -81,8 +79,6 @@ declare namespace Confirm {
|
|
|
81
79
|
confirmLabel: PropTypes.Requireable<string>;
|
|
82
80
|
/** Customise the cancel button label */
|
|
83
81
|
cancelLabel: PropTypes.Requireable<string>;
|
|
84
|
-
/** Apply destructive style to the buttons */
|
|
85
|
-
destructive: PropTypes.Requireable<boolean>;
|
|
86
82
|
/** Apply destructive style to the cancel button */
|
|
87
83
|
cancelButtonDestructive: PropTypes.Requireable<boolean>;
|
|
88
84
|
/** Apply destructive style to the confirm button */
|
|
@@ -11,8 +11,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
|
|
13
13
|
|
|
14
|
-
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
15
|
-
|
|
16
14
|
var _heading = _interopRequireDefault(require("../heading"));
|
|
17
15
|
|
|
18
16
|
var _dialog = _interopRequireDefault(require("../dialog"));
|
|
@@ -35,15 +33,12 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
35
33
|
|
|
36
34
|
function _extends() { _extends = Object.assign || 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); }
|
|
37
35
|
|
|
38
|
-
let deprecatedWarnTriggered = false;
|
|
39
|
-
|
|
40
36
|
const Confirm = ({
|
|
41
37
|
"aria-labelledby": ariaLabelledBy,
|
|
42
38
|
"aria-describedby": ariaDescribedBy,
|
|
43
39
|
"aria-label": ariaLabel,
|
|
44
40
|
open,
|
|
45
41
|
children,
|
|
46
|
-
destructive,
|
|
47
42
|
cancelButtonDestructive,
|
|
48
43
|
confirmButtonDestructive,
|
|
49
44
|
cancelButtonType,
|
|
@@ -64,12 +59,6 @@ const Confirm = ({
|
|
|
64
59
|
title,
|
|
65
60
|
...rest
|
|
66
61
|
}) => {
|
|
67
|
-
if (!deprecatedWarnTriggered && destructive) {
|
|
68
|
-
deprecatedWarnTriggered = true;
|
|
69
|
-
|
|
70
|
-
_logger.default.deprecate("`destructive` prop is deprecated and will soon be removed. Please use `cancelButtonDestructive` and `confirmButtonDestructive` props.");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
62
|
const l = (0, _useLocale.default)();
|
|
74
63
|
const {
|
|
75
64
|
current: titleId
|
|
@@ -97,7 +86,7 @@ const Confirm = ({
|
|
|
97
86
|
onClick: onCancel,
|
|
98
87
|
"data-element": "cancel",
|
|
99
88
|
buttonType: cancelButtonType,
|
|
100
|
-
destructive:
|
|
89
|
+
destructive: cancelButtonDestructive,
|
|
101
90
|
disabled: disableCancel,
|
|
102
91
|
iconType: cancelButtonIconType,
|
|
103
92
|
iconPosition: cancelButtonIconPosition
|
|
@@ -108,7 +97,7 @@ const Confirm = ({
|
|
|
108
97
|
onClick: onConfirm,
|
|
109
98
|
"data-element": "confirm",
|
|
110
99
|
buttonType: confirmButtonType,
|
|
111
|
-
destructive:
|
|
100
|
+
destructive: confirmButtonDestructive,
|
|
112
101
|
disabled: isLoadingConfirm || disableConfirm,
|
|
113
102
|
ml: 2,
|
|
114
103
|
iconType: confirmButtonIconType,
|
|
@@ -152,7 +141,6 @@ const Confirm = ({
|
|
|
152
141
|
Confirm.defaultProps = {
|
|
153
142
|
size: "extra-small",
|
|
154
143
|
showCloseIcon: false,
|
|
155
|
-
destructive: false,
|
|
156
144
|
cancelButtonDestructive: false,
|
|
157
145
|
confirmButtonDestructive: false,
|
|
158
146
|
iconType: null,
|
|
@@ -220,9 +208,6 @@ Confirm.propTypes = {
|
|
|
220
208
|
/** Customise the cancel button label */
|
|
221
209
|
cancelLabel: _propTypes.default.string,
|
|
222
210
|
|
|
223
|
-
/** Apply destructive style to the buttons */
|
|
224
|
-
destructive: _propTypes.default.bool,
|
|
225
|
-
|
|
226
211
|
/** Apply destructive style to the cancel button */
|
|
227
212
|
cancelButtonDestructive: _propTypes.default.bool,
|
|
228
213
|
|
|
@@ -21,8 +21,6 @@ export interface ConfirmProps extends DialogProps {
|
|
|
21
21
|
cancelLabel?: string;
|
|
22
22
|
/** Customise the confirm button label */
|
|
23
23
|
confirmLabel?: string;
|
|
24
|
-
/** Apply destructive style to the buttons */
|
|
25
|
-
destructive?: boolean;
|
|
26
24
|
/** Apply destructive style to the cancel button */
|
|
27
25
|
cancelButtonDestructive?: boolean;
|
|
28
26
|
/** Apply destructive style to the confirm button */
|
|
@@ -29,6 +29,8 @@ var _datePicker = _interopRequireDefault(require("./__internal__/date-picker"));
|
|
|
29
29
|
|
|
30
30
|
var _dateRange = _interopRequireDefault(require("../date-range/date-range.context"));
|
|
31
31
|
|
|
32
|
+
var _clickAwayWrapper = _interopRequireDefault(require("../../__internal__/click-away-wrapper"));
|
|
33
|
+
|
|
32
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
35
|
|
|
34
36
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -259,23 +261,6 @@ const DateInput = ({
|
|
|
259
261
|
}
|
|
260
262
|
};
|
|
261
263
|
|
|
262
|
-
(0, _react.useEffect)(() => {
|
|
263
|
-
const fnClosePicker = ev => {
|
|
264
|
-
if (open && !_events.default.composedPath(ev).includes(parentRef.current) && !_events.default.composedPath(ev).includes(pickerRef.current)) {
|
|
265
|
-
alreadyFocused.current = true;
|
|
266
|
-
inputRef.current.focus();
|
|
267
|
-
isBlurBlocked.current = false;
|
|
268
|
-
inputRef.current.blur();
|
|
269
|
-
setOpen(false);
|
|
270
|
-
alreadyFocused.current = false;
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
document.addEventListener("mousedown", fnClosePicker);
|
|
275
|
-
return function cleanup() {
|
|
276
|
-
document.removeEventListener("mousedown", fnClosePicker);
|
|
277
|
-
};
|
|
278
|
-
}, [open]);
|
|
279
264
|
(0, _react.useEffect)(() => {
|
|
280
265
|
const [matchedFormat, matchedValue] = (0, _utils.findMatchedFormatAndValue)(value, formats);
|
|
281
266
|
|
|
@@ -307,7 +292,22 @@ const DateInput = ({
|
|
|
307
292
|
return value;
|
|
308
293
|
};
|
|
309
294
|
|
|
310
|
-
|
|
295
|
+
const handleClickAway = () => {
|
|
296
|
+
if (open) {
|
|
297
|
+
alreadyFocused.current = true;
|
|
298
|
+
inputRef.current.focus();
|
|
299
|
+
isBlurBlocked.current = false;
|
|
300
|
+
inputRef.current.blur();
|
|
301
|
+
setOpen(false);
|
|
302
|
+
alreadyFocused.current = false;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
return /*#__PURE__*/_react.default.createElement(_clickAwayWrapper.default, {
|
|
307
|
+
handleClickAway: handleClickAway,
|
|
308
|
+
eventTypeId: "mousedown",
|
|
309
|
+
targets: [parentRef, pickerRef]
|
|
310
|
+
}, /*#__PURE__*/_react.default.createElement(_date.default, _extends({
|
|
311
311
|
ref: wrapperRef,
|
|
312
312
|
role: "presentation",
|
|
313
313
|
size: size,
|
|
@@ -347,13 +347,13 @@ const DateInput = ({
|
|
|
347
347
|
ref: pickerRef,
|
|
348
348
|
pickerMouseDown: handlePickerMouseDown,
|
|
349
349
|
open: open
|
|
350
|
-
}));
|
|
350
|
+
})));
|
|
351
351
|
};
|
|
352
352
|
|
|
353
353
|
DateInput.propTypes = { ..._textbox.default.propTypes,
|
|
354
354
|
...marginPropTypes,
|
|
355
355
|
|
|
356
|
-
/** Pass any props that match the [DayPickerProps](https://react-day-picker.
|
|
356
|
+
/** Pass any props that match the [DayPickerProps](https://react-day-picker-v7.netlify.app/docs/getting-started/)
|
|
357
357
|
* interface to override default behaviors
|
|
358
358
|
* */
|
|
359
359
|
pickerProps: _propTypes.default.object,
|
|
@@ -179,7 +179,8 @@ const Dialog = ({
|
|
|
179
179
|
autoFocus: !disableAutoFocus,
|
|
180
180
|
focusFirstElement: focusFirstElement,
|
|
181
181
|
bespokeTrap: bespokeFocusTrap,
|
|
182
|
-
wrapperRef: dialogRef
|
|
182
|
+
wrapperRef: dialogRef,
|
|
183
|
+
isOpen: open
|
|
183
184
|
}, /*#__PURE__*/_react.default.createElement(_dialog.DialogStyle, _extends({
|
|
184
185
|
"aria-modal": true,
|
|
185
186
|
ref: dialogRef,
|
|
@@ -189,9 +190,9 @@ const Dialog = ({
|
|
|
189
190
|
"data-element": "dialog",
|
|
190
191
|
"data-role": rest["data-role"],
|
|
191
192
|
role: role
|
|
192
|
-
}, contentPadding), dialogTitle(), /*#__PURE__*/_react.default.createElement(_dialog.DialogContentStyle, contentPadding, /*#__PURE__*/_react.default.createElement(_dialog.DialogInnerContentStyle, _extends({
|
|
193
|
+
}, contentPadding), dialogTitle(), closeIcon(), /*#__PURE__*/_react.default.createElement(_dialog.DialogContentStyle, contentPadding, /*#__PURE__*/_react.default.createElement(_dialog.DialogInnerContentStyle, _extends({
|
|
193
194
|
ref: innerContentRef
|
|
194
|
-
}, contentPadding), children))
|
|
195
|
+
}, contentPadding), children)))));
|
|
195
196
|
};
|
|
196
197
|
|
|
197
198
|
Dialog.propTypes = {
|
|
@@ -93,16 +93,10 @@ const StyledContent = _styledComponents.default.div`
|
|
|
93
93
|
|
|
94
94
|
${({
|
|
95
95
|
hasHeader
|
|
96
|
-
}) => !hasHeader && `
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
.carbon-app-wrapper {
|
|
101
|
-
max-width: 100%;
|
|
102
|
-
padding: 0;
|
|
103
|
-
height: 70px;
|
|
104
|
-
}
|
|
105
|
-
`}
|
|
96
|
+
}) => !hasHeader && (0, _styledComponents.css)`
|
|
97
|
+
padding-top: 0;
|
|
98
|
+
margin-top: -25px;
|
|
99
|
+
`}
|
|
106
100
|
`;
|
|
107
101
|
var _default = StyledContent;
|
|
108
102
|
exports.default = _default;
|