carbon-react 104.12.2 → 104.16.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/lib/__internal__/popover/index.d.ts +1 -1
- package/lib/__internal__/popover/popover.component.d.ts +3 -1
- package/lib/__internal__/popover/popover.component.js +12 -3
- package/lib/__internal__/popover/popover.d.ts +46 -0
- package/lib/__internal__/popover/popover.style.d.ts +2 -0
- package/lib/__internal__/popover/popover.style.js +29 -0
- package/lib/components/button-bar/button-bar.style.d.ts +0 -1
- package/lib/components/button-bar/button-bar.style.js +6 -7
- package/lib/components/button-toggle/button-toggle.style.js +25 -41
- package/lib/components/button-toggle-group/button-toggle-group.style.js +5 -13
- package/lib/components/dialog/dialog.style.js +3 -0
- package/lib/components/modal/modal.component.js +23 -24
- package/lib/components/modal/modal.style.js +22 -15
- package/lib/components/note/note.style.js +14 -28
- package/lib/components/profile/profile-test.stories.js +75 -0
- package/lib/components/select/filterable-select/filterable-select.component.js +9 -4
- package/lib/components/select/multi-select/multi-select.component.js +9 -5
- package/lib/components/select/multi-select/multi-select.style.js +1 -0
- package/lib/components/select/option-group-header/option-group-header.style.js +3 -3
- package/lib/components/select/select-list/select-list.component.js +18 -5
- package/lib/components/select/select-list/select-list.style.js +2 -2
- package/lib/components/select/select-textbox/select-textbox.component.d.ts +2 -1
- package/lib/components/select/select-textbox/select-textbox.component.js +67 -2
- package/lib/components/select/select.style.js +9 -3
- package/lib/components/select/simple-select/simple-select.component.js +12 -9
- package/lib/hooks/__internal__/useScrollBlock/index.d.ts +4 -0
- package/lib/hooks/__internal__/useScrollBlock/index.js +15 -0
- package/lib/hooks/__internal__/useScrollBlock/scroll-block-manager.d.ts +10 -0
- package/lib/hooks/__internal__/useScrollBlock/scroll-block-manager.js +63 -0
- package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.d.ts +5 -0
- package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.js +95 -0
- package/lib/style/themes/base/base-theme.config.d.ts +2 -4
- package/lib/style/themes/base/base-theme.config.js +2 -5
- package/lib/style/themes/sage/index.d.ts +1 -0
- package/package.json +16 -16
- package/lib/components/portal/portal.style.d.ts +0 -3
- package/lib/components/portal/portal.style.js +0 -20
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DefaultStory = exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _specialCharacters = _interopRequireWildcard(require("../../../.storybook/utils/argTypes/specialCharacters"));
|
|
11
|
+
|
|
12
|
+
var _profile = _interopRequireDefault(require("./profile.component"));
|
|
13
|
+
|
|
14
|
+
var _profile2 = require("./profile.config");
|
|
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
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
var _default = {
|
|
25
|
+
title: "Profile/Test",
|
|
26
|
+
parameters: {
|
|
27
|
+
info: {
|
|
28
|
+
disable: true
|
|
29
|
+
},
|
|
30
|
+
chromatic: {
|
|
31
|
+
disable: true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
argTypes: {
|
|
35
|
+
size: {
|
|
36
|
+
control: {
|
|
37
|
+
type: "select",
|
|
38
|
+
options: _profile2.PROFILE_SIZES
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
emailSpecialCharacters: {
|
|
42
|
+
options: [..._specialCharacters.default.options, ..._specialCharacters.email.options],
|
|
43
|
+
mapping: { ..._specialCharacters.default.mapping,
|
|
44
|
+
..._specialCharacters.email.mapping
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
nameSpecialCharacters: _specialCharacters.default
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.default = _default;
|
|
51
|
+
|
|
52
|
+
const DefaultStory = ({
|
|
53
|
+
email,
|
|
54
|
+
emailSpecialCharacters,
|
|
55
|
+
name,
|
|
56
|
+
nameSpecialCharacters,
|
|
57
|
+
...args
|
|
58
|
+
}) => /*#__PURE__*/_react.default.createElement(_profile.default, _extends({
|
|
59
|
+
email: email || emailSpecialCharacters,
|
|
60
|
+
name: name || nameSpecialCharacters
|
|
61
|
+
}, args));
|
|
62
|
+
|
|
63
|
+
exports.DefaultStory = DefaultStory;
|
|
64
|
+
DefaultStory.story = {
|
|
65
|
+
name: "default",
|
|
66
|
+
args: {
|
|
67
|
+
email: "johnsmith@sage.com",
|
|
68
|
+
initials: "JS",
|
|
69
|
+
size: _profile2.PROFILE_SIZES[0],
|
|
70
|
+
name: "John Smith",
|
|
71
|
+
src: "",
|
|
72
|
+
emailSpecialCharacters: undefined,
|
|
73
|
+
nameSpecialCharacters: undefined
|
|
74
|
+
}
|
|
75
|
+
};
|
|
@@ -437,21 +437,26 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
437
437
|
}, children);
|
|
438
438
|
|
|
439
439
|
return /*#__PURE__*/_react.default.createElement(_select.default, _extends({
|
|
440
|
+
"aria-expanded": isOpen,
|
|
441
|
+
"aria-haspopup": "listbox",
|
|
440
442
|
ref: containerRef,
|
|
441
443
|
hasTextCursor: true,
|
|
442
444
|
readOnly: readOnly,
|
|
443
445
|
disabled: disabled,
|
|
444
446
|
"data-component": dataComponent,
|
|
445
447
|
"data-role": dataRole,
|
|
446
|
-
"data-element": dataElement
|
|
447
|
-
|
|
448
|
+
"data-element": dataElement,
|
|
449
|
+
isOpen: isOpen
|
|
450
|
+
}, (0, _utils.filterStyledSystemMarginProps)(textboxProps)), /*#__PURE__*/_react.default.createElement("div", {
|
|
451
|
+
ref: containerRef
|
|
452
|
+
}, /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
|
|
448
453
|
activeDescendantId: activeDescendantId,
|
|
449
454
|
"aria-controls": isOpen ? selectListId.current : undefined,
|
|
450
455
|
isOpen: isOpen,
|
|
451
456
|
hasTextCursor: true,
|
|
452
457
|
labelId: labelId.current,
|
|
453
|
-
|
|
454
|
-
}, getTextboxProps())),
|
|
458
|
+
textboxRef: textboxRef
|
|
459
|
+
}, getTextboxProps()))), isOpen && selectList);
|
|
455
460
|
});
|
|
456
461
|
|
|
457
462
|
FilterableSelect.propTypes = { ..._selectTextbox.formInputPropTypes,
|
|
@@ -456,15 +456,19 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
456
456
|
}, children);
|
|
457
457
|
|
|
458
458
|
return /*#__PURE__*/_react.default.createElement(_multiSelect.StyledSelectMultiSelect, _extends({
|
|
459
|
-
|
|
459
|
+
"aria-expanded": isOpen,
|
|
460
|
+
"aria-haspopup": "listbox",
|
|
460
461
|
disabled: disabled,
|
|
461
462
|
readOnly: readOnly,
|
|
462
463
|
hasTextCursor: true,
|
|
463
464
|
size: size,
|
|
464
465
|
"data-component": dataComponent,
|
|
465
466
|
"data-role": dataRole,
|
|
466
|
-
"data-element": dataElement
|
|
467
|
-
|
|
467
|
+
"data-element": dataElement,
|
|
468
|
+
isOpen: isOpen
|
|
469
|
+
}, (0, _utils.filterStyledSystemMarginProps)(textboxProps)), /*#__PURE__*/_react.default.createElement("div", {
|
|
470
|
+
ref: containerRef
|
|
471
|
+
}, /*#__PURE__*/_react.default.createElement(_multiSelect.StyledAccessibilityLabelContainer, {
|
|
468
472
|
"data-element": "accessibility-label",
|
|
469
473
|
id: accessibilityLabelId.current
|
|
470
474
|
}, accessibilityLabel), /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
|
|
@@ -474,8 +478,8 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
474
478
|
hasTextCursor: true,
|
|
475
479
|
isOpen: isOpen,
|
|
476
480
|
labelId: labelId.current,
|
|
477
|
-
|
|
478
|
-
}, getTextboxProps())),
|
|
481
|
+
textboxRef: textboxRef
|
|
482
|
+
}, getTextboxProps()))), isOpen && selectList);
|
|
479
483
|
});
|
|
480
484
|
|
|
481
485
|
MultiSelect.propTypes = { ..._selectTextbox.formInputPropTypes,
|
|
@@ -26,16 +26,16 @@ const StyledOptionGroupHeader = _styledComponents.default.div`
|
|
|
26
26
|
line-height: 18px;
|
|
27
27
|
text-align: left;
|
|
28
28
|
margin: 0;
|
|
29
|
-
color: var(--
|
|
29
|
+
color: var(--colorsUtilityYin055);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
${_icon.default} {
|
|
33
33
|
margin-right: 4px;
|
|
34
34
|
margin-left: -5px;
|
|
35
|
-
color: var(--
|
|
35
|
+
color: var(--colorsUtilityYin055);
|
|
36
36
|
|
|
37
37
|
&:hover {
|
|
38
|
-
color: var(--
|
|
38
|
+
color: var(--colorsUtilityYin055);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
`;
|
|
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _useScrollBlock = _interopRequireDefault(require("../../../hooks/__internal__/useScrollBlock"));
|
|
13
|
+
|
|
12
14
|
var _selectList = require("./select-list.style");
|
|
13
15
|
|
|
14
16
|
var _popover = _interopRequireDefault(require("../../../__internal__/popover"));
|
|
@@ -82,6 +84,16 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
82
84
|
const listRef = (0, _react.useRef)();
|
|
83
85
|
const tableRef = (0, _react.useRef)();
|
|
84
86
|
const listActionButtonRef = (0, _react.useRef)();
|
|
87
|
+
const {
|
|
88
|
+
blockScroll,
|
|
89
|
+
allowScroll
|
|
90
|
+
} = (0, _useScrollBlock.default)();
|
|
91
|
+
(0, _react.useEffect)(() => {
|
|
92
|
+
blockScroll();
|
|
93
|
+
return () => {
|
|
94
|
+
allowScroll();
|
|
95
|
+
};
|
|
96
|
+
}, [allowScroll, blockScroll]);
|
|
85
97
|
const setPlacementCallback = (0, _react.useCallback)(popper => {
|
|
86
98
|
placement.current = popper.placement;
|
|
87
99
|
}, [placement]);
|
|
@@ -222,12 +234,12 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
222
234
|
}
|
|
223
235
|
}, [onListScrollBottom]);
|
|
224
236
|
const assignListWidth = (0, _react.useCallback)(() => {
|
|
225
|
-
if (
|
|
237
|
+
if (anchorElement) {
|
|
226
238
|
const inputBoundingRect = anchorElement.getBoundingClientRect();
|
|
227
239
|
const width = `${inputBoundingRect.width}px`;
|
|
228
240
|
setListWidth(width);
|
|
229
241
|
}
|
|
230
|
-
}, [anchorElement
|
|
242
|
+
}, [anchorElement]);
|
|
231
243
|
(0, _react.useLayoutEffect)(() => {
|
|
232
244
|
assignListWidth();
|
|
233
245
|
window.addEventListener("resize", assignListWidth);
|
|
@@ -288,10 +300,10 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
288
300
|
listRef.current.scrollTop = listRef.current.scrollHeight;
|
|
289
301
|
}
|
|
290
302
|
}, [children, currentOptionsListIndex, isLoading, lastOptionIndex]);
|
|
291
|
-
const popoverModifiers = [...fixedPopoverModifiers, {
|
|
303
|
+
const popoverModifiers = (0, _react.useMemo)(() => [...fixedPopoverModifiers, {
|
|
292
304
|
name: "flip",
|
|
293
305
|
enabled: flipEnabled
|
|
294
|
-
}];
|
|
306
|
+
}], [flipEnabled]);
|
|
295
307
|
|
|
296
308
|
function isNavigationKey(keyEvent) {
|
|
297
309
|
return keyEvent === "ArrowDown" || keyEvent === "ArrowUp" || keyEvent === "Home" || keyEvent === "End";
|
|
@@ -317,7 +329,8 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
317
329
|
disablePortal: disablePortal,
|
|
318
330
|
reference: anchorRef,
|
|
319
331
|
onFirstUpdate: setPlacementCallback,
|
|
320
|
-
modifiers: popoverModifiers
|
|
332
|
+
modifiers: popoverModifiers,
|
|
333
|
+
disableBackgroundUI: true
|
|
321
334
|
}, /*#__PURE__*/_react.default.createElement(_selectList.StyledPopoverContainer, {
|
|
322
335
|
height: listHeight,
|
|
323
336
|
width: listWidth,
|
|
@@ -101,7 +101,7 @@ const StyledSelectListTableHeader = _styledComponents.default.thead`
|
|
|
101
101
|
font-weight: 900;
|
|
102
102
|
font-size: 12px;
|
|
103
103
|
text-transform: uppercase;
|
|
104
|
-
color: var(--
|
|
104
|
+
color: var(--colorsUtilityYin055);
|
|
105
105
|
:after {
|
|
106
106
|
content: "";
|
|
107
107
|
display: block;
|
|
@@ -110,7 +110,7 @@ const StyledSelectListTableHeader = _styledComponents.default.thead`
|
|
|
110
110
|
left: 0px;
|
|
111
111
|
background-image: linear-gradient(
|
|
112
112
|
var(--colorsComponentsNavigationYin100),
|
|
113
|
-
var(--
|
|
113
|
+
var(--colorsUtilityYang100)
|
|
114
114
|
);
|
|
115
115
|
opacity: 0.03;
|
|
116
116
|
height: 8px;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default SelectTextbox;
|
|
2
|
-
declare function SelectTextbox({ accessibilityLabelId, "aria-controls": ariaControls, value, disabled, isOpen, readOnly, placeholder, labelId, size, onClick, onFocus, onBlur, onChange, selectedValue, required, hasTextCursor, transparent, activeDescendantId, ...restProps }: {
|
|
2
|
+
declare function SelectTextbox({ accessibilityLabelId, "aria-controls": ariaControls, value, disabled, isOpen, readOnly, placeholder, labelId, size, onClick, onFocus, onBlur, onChange, selectedValue, required, textboxRef, hasTextCursor, transparent, activeDescendantId, ...restProps }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
accessibilityLabelId?: string | undefined;
|
|
5
5
|
"aria-controls": any;
|
|
@@ -16,6 +16,7 @@ declare function SelectTextbox({ accessibilityLabelId, "aria-controls": ariaCont
|
|
|
16
16
|
onChange: any;
|
|
17
17
|
selectedValue: any;
|
|
18
18
|
required: any;
|
|
19
|
+
textboxRef: any;
|
|
19
20
|
hasTextCursor: any;
|
|
20
21
|
transparent: any;
|
|
21
22
|
activeDescendantId: any;
|
|
@@ -9,14 +9,18 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _core = require("@popperjs/core");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _textbox = _interopRequireDefault(require("../../textbox"));
|
|
15
15
|
|
|
16
16
|
var _selectText = _interopRequireDefault(require("../__internal__/select-text/select-text.component"));
|
|
17
17
|
|
|
18
18
|
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid/guid"));
|
|
19
19
|
|
|
20
|
+
var _useLocale = _interopRequireDefault(require("../../../hooks/__internal__/useLocale"));
|
|
21
|
+
|
|
22
|
+
var _useResizeObserver = _interopRequireDefault(require("../../../hooks/__internal__/useResizeObserver"));
|
|
23
|
+
|
|
20
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
25
|
|
|
22
26
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -25,6 +29,42 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
25
29
|
|
|
26
30
|
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); }
|
|
27
31
|
|
|
32
|
+
const modifiers = [{
|
|
33
|
+
name: "flip",
|
|
34
|
+
enabled: false
|
|
35
|
+
}, {
|
|
36
|
+
name: "offset",
|
|
37
|
+
options: {
|
|
38
|
+
offset: ({
|
|
39
|
+
placement,
|
|
40
|
+
reference
|
|
41
|
+
}) => {
|
|
42
|
+
if (placement === "bottom") {
|
|
43
|
+
return [0, -reference.height];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
name: "sameDimensions",
|
|
51
|
+
enabled: true,
|
|
52
|
+
phase: "beforeWrite",
|
|
53
|
+
requires: ["computeStyles"],
|
|
54
|
+
fn: ({
|
|
55
|
+
state
|
|
56
|
+
}) => {
|
|
57
|
+
state.styles.popper.width = `${state.rects.reference.width}px`;
|
|
58
|
+
state.styles.reference.height = `${state.rects.popper.height}px`;
|
|
59
|
+
},
|
|
60
|
+
effect: ({
|
|
61
|
+
state
|
|
62
|
+
}) => {
|
|
63
|
+
state.elements.popper.style.width = `${state.elements.reference.offsetWidth}px`;
|
|
64
|
+
state.elements.reference.height = `${state.elements.popper.height}px`;
|
|
65
|
+
}
|
|
66
|
+
}];
|
|
67
|
+
|
|
28
68
|
const SelectTextbox = ({
|
|
29
69
|
accessibilityLabelId = "",
|
|
30
70
|
"aria-controls": ariaControls,
|
|
@@ -41,11 +81,36 @@ const SelectTextbox = ({
|
|
|
41
81
|
onChange,
|
|
42
82
|
selectedValue,
|
|
43
83
|
required,
|
|
84
|
+
textboxRef,
|
|
44
85
|
hasTextCursor,
|
|
45
86
|
transparent,
|
|
46
87
|
activeDescendantId,
|
|
47
88
|
...restProps
|
|
48
89
|
}) => {
|
|
90
|
+
const popperInstance = (0, _react.useRef)();
|
|
91
|
+
(0, _react.useLayoutEffect)(() => {
|
|
92
|
+
if (textboxRef && isOpen) {
|
|
93
|
+
popperInstance.current = (0, _core.createPopper)(textboxRef.parentElement.parentElement, textboxRef.parentElement, {
|
|
94
|
+
strategy: "fixed",
|
|
95
|
+
modifiers
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return () => {
|
|
100
|
+
if (popperInstance.current) {
|
|
101
|
+
popperInstance.current.destroy();
|
|
102
|
+
popperInstance.current = null;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}, [textboxRef, isOpen]);
|
|
106
|
+
const resizeObserverRef = (0, _react.useMemo)(() => ({
|
|
107
|
+
current: textboxRef === null || textboxRef === void 0 ? void 0 : textboxRef.parentElement
|
|
108
|
+
}), [textboxRef]);
|
|
109
|
+
(0, _useResizeObserver.default)(resizeObserverRef, () => {
|
|
110
|
+
var _popperInstance$curre;
|
|
111
|
+
|
|
112
|
+
popperInstance === null || popperInstance === void 0 ? void 0 : (_popperInstance$curre = popperInstance.current) === null || _popperInstance$curre === void 0 ? void 0 : _popperInstance$curre.update();
|
|
113
|
+
}, !isOpen);
|
|
49
114
|
const l = (0, _useLocale.default)();
|
|
50
115
|
const textId = (0, _react.useRef)((0, _guid.default)());
|
|
51
116
|
|
|
@@ -28,7 +28,9 @@ const StyledSelect = _styledComponents.default.div`
|
|
|
28
28
|
hasTextCursor,
|
|
29
29
|
disabled,
|
|
30
30
|
readOnly,
|
|
31
|
-
|
|
31
|
+
theme,
|
|
32
|
+
transparent,
|
|
33
|
+
isOpen
|
|
32
34
|
}) => (0, _styledComponents.css)`
|
|
33
35
|
${_styledSystem.margin}
|
|
34
36
|
|
|
@@ -44,8 +46,8 @@ const StyledSelect = _styledComponents.default.div`
|
|
|
44
46
|
`}
|
|
45
47
|
|
|
46
48
|
${readOnly && (0, _styledComponents.css)`
|
|
47
|
-
cursor: "text";
|
|
48
|
-
color: var(--
|
|
49
|
+
cursor: ${hasTextCursor ? "text" : "default"};
|
|
50
|
+
color: var(--colorsActionMinorYin090);
|
|
49
51
|
text-shadow: none;
|
|
50
52
|
`}
|
|
51
53
|
}
|
|
@@ -54,6 +56,10 @@ const StyledSelect = _styledComponents.default.div`
|
|
|
54
56
|
cursor: ${hasTextCursor ? "text" : "pointer"};
|
|
55
57
|
padding-right: 0;
|
|
56
58
|
|
|
59
|
+
${isOpen && (0, _styledComponents.css)`
|
|
60
|
+
z-index: ${theme.zIndex.aboveAll};
|
|
61
|
+
`}
|
|
62
|
+
|
|
57
63
|
${disabled && (0, _styledComponents.css)`
|
|
58
64
|
cursor: not-allowed;
|
|
59
65
|
`}
|
|
@@ -365,18 +365,21 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
365
365
|
transparent: transparent,
|
|
366
366
|
disabled: disabled,
|
|
367
367
|
readOnly: readOnly,
|
|
368
|
-
|
|
368
|
+
"aria-expanded": isOpen,
|
|
369
|
+
"aria-haspopup": "listbox",
|
|
369
370
|
"data-component": dataComponent,
|
|
370
371
|
"data-role": dataRole,
|
|
371
|
-
"data-element": dataElement
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
372
|
+
"data-element": dataElement,
|
|
373
|
+
isOpen: isOpen
|
|
374
|
+
}, (0, _utils.filterStyledSystemMarginProps)(props)), /*#__PURE__*/_react.default.createElement("div", {
|
|
375
|
+
ref: containerRef
|
|
376
|
+
}, /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
|
|
377
|
+
"aria-controls": isOpen ? selectListId.current : undefined,
|
|
375
378
|
activeDescendantId: activeDescendantId,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
})),
|
|
379
|
+
labelId: labelId.current,
|
|
380
|
+
isOpen: isOpen,
|
|
381
|
+
textboxRef: textboxRef
|
|
382
|
+
}, getTextboxProps()))), isOpen && selectList);
|
|
380
383
|
});
|
|
381
384
|
|
|
382
385
|
SimpleSelect.propTypes = {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useScrollBlock.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _useScrollBlock = _interopRequireDefault(require("./useScrollBlock"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default ScrollBlockManager;
|
|
2
|
+
declare class ScrollBlockManager {
|
|
3
|
+
components: any;
|
|
4
|
+
originalValues: any;
|
|
5
|
+
registerComponent(id: any): void;
|
|
6
|
+
unregisterComponent(id: any): void;
|
|
7
|
+
saveOriginalValues(values: any): void;
|
|
8
|
+
getOriginalValues(): any;
|
|
9
|
+
isBlocked(): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
|
|
10
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
+
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
13
|
+
|
|
14
|
+
let ScrollBlockManager = /*#__PURE__*/function () {
|
|
15
|
+
function ScrollBlockManager() {
|
|
16
|
+
_classCallCheck(this, ScrollBlockManager);
|
|
17
|
+
|
|
18
|
+
// Due to possibility of multiple carbon versions using it
|
|
19
|
+
// it is necessary to maintain same structure in this global variable
|
|
20
|
+
if (!window.__CARBON_INTERNALS_SCROLL_BLOCKERS) {
|
|
21
|
+
window.__CARBON_INTERNALS_SCROLL_BLOCKERS = {
|
|
22
|
+
components: {},
|
|
23
|
+
originalValues: []
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
this.components = window.__CARBON_INTERNALS_SCROLL_BLOCKERS.components;
|
|
28
|
+
this.originalValues = window.__CARBON_INTERNALS_SCROLL_BLOCKERS.originalValues;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_createClass(ScrollBlockManager, [{
|
|
32
|
+
key: "registerComponent",
|
|
33
|
+
value: function registerComponent(id) {
|
|
34
|
+
this.components[id] = true;
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "unregisterComponent",
|
|
38
|
+
value: function unregisterComponent(id) {
|
|
39
|
+
delete this.components[id];
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "saveOriginalValues",
|
|
43
|
+
value: function saveOriginalValues(values) {
|
|
44
|
+
this.originalValues.length = 0;
|
|
45
|
+
this.originalValues.push(...values);
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "getOriginalValues",
|
|
49
|
+
value: function getOriginalValues() {
|
|
50
|
+
return this.originalValues;
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "isBlocked",
|
|
54
|
+
value: function isBlocked() {
|
|
55
|
+
return Object.entries(this.components).length !== 0;
|
|
56
|
+
}
|
|
57
|
+
}]);
|
|
58
|
+
|
|
59
|
+
return ScrollBlockManager;
|
|
60
|
+
}();
|
|
61
|
+
|
|
62
|
+
var _default = ScrollBlockManager;
|
|
63
|
+
exports.default = _default;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
11
|
+
|
|
12
|
+
var _scrollBlockManager = _interopRequireDefault(require("./scroll-block-manager"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const scrollBlockManager = new _scrollBlockManager.default();
|
|
17
|
+
/* istanbul ignore next */
|
|
18
|
+
|
|
19
|
+
const safeDocument = typeof document !== "undefined" ? document : {};
|
|
20
|
+
|
|
21
|
+
const useScrollBlock = () => {
|
|
22
|
+
const {
|
|
23
|
+
current: containerGuid
|
|
24
|
+
} = (0, _react.useRef)((0, _guid.default)());
|
|
25
|
+
const rules = (0, _react.useMemo)(() => {
|
|
26
|
+
const {
|
|
27
|
+
documentElement,
|
|
28
|
+
body
|
|
29
|
+
} = safeDocument;
|
|
30
|
+
const scrollBarWidth = window.innerWidth - documentElement.clientWidth;
|
|
31
|
+
const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
|
|
32
|
+
return [{
|
|
33
|
+
element: documentElement,
|
|
34
|
+
property: "position",
|
|
35
|
+
blockingValue: "relative"
|
|
36
|
+
}, {
|
|
37
|
+
element: documentElement,
|
|
38
|
+
property: "overflow",
|
|
39
|
+
blockingValue: "hidden"
|
|
40
|
+
}, {
|
|
41
|
+
element: body,
|
|
42
|
+
property: "position",
|
|
43
|
+
blockingValue: "relative"
|
|
44
|
+
}, {
|
|
45
|
+
element: body,
|
|
46
|
+
property: "overflow",
|
|
47
|
+
blockingValue: "hidden"
|
|
48
|
+
}, {
|
|
49
|
+
element: body,
|
|
50
|
+
property: "paddingRight",
|
|
51
|
+
blockingValue: `${bodyPaddingRight + scrollBarWidth}px`
|
|
52
|
+
}];
|
|
53
|
+
}, []);
|
|
54
|
+
const blockScroll = (0, _react.useCallback)(() => {
|
|
55
|
+
const isBlocked = scrollBlockManager.isBlocked();
|
|
56
|
+
scrollBlockManager.registerComponent(containerGuid);
|
|
57
|
+
|
|
58
|
+
if (isBlocked) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const originalValues = rules.map(({
|
|
63
|
+
element,
|
|
64
|
+
property
|
|
65
|
+
}) => element.style[property]);
|
|
66
|
+
scrollBlockManager.saveOriginalValues(originalValues);
|
|
67
|
+
rules.forEach(({
|
|
68
|
+
element,
|
|
69
|
+
property,
|
|
70
|
+
blockingValue
|
|
71
|
+
}) => {
|
|
72
|
+
element.style[property] = blockingValue;
|
|
73
|
+
});
|
|
74
|
+
}, [containerGuid, rules]);
|
|
75
|
+
const allowScroll = (0, _react.useCallback)(() => {
|
|
76
|
+
scrollBlockManager.unregisterComponent(containerGuid);
|
|
77
|
+
const isBlocked = scrollBlockManager.isBlocked();
|
|
78
|
+
if (isBlocked) return;
|
|
79
|
+
const originalValues = scrollBlockManager.getOriginalValues();
|
|
80
|
+
rules.forEach(({
|
|
81
|
+
element,
|
|
82
|
+
property
|
|
83
|
+
}, index) => {
|
|
84
|
+
element.style[property] = originalValues[index];
|
|
85
|
+
});
|
|
86
|
+
scrollBlockManager.saveOriginalValues([]);
|
|
87
|
+
}, [containerGuid, rules]);
|
|
88
|
+
return {
|
|
89
|
+
blockScroll,
|
|
90
|
+
allowScroll
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
var _default = useScrollBlock;
|
|
95
|
+
exports.default = _default;
|
|
@@ -336,9 +336,6 @@ declare function _default(palette: any): {
|
|
|
336
336
|
background: any;
|
|
337
337
|
altHover: any;
|
|
338
338
|
};
|
|
339
|
-
note: {
|
|
340
|
-
timeStamp: string;
|
|
341
|
-
};
|
|
342
339
|
editorLinkPreview: {
|
|
343
340
|
background: any;
|
|
344
341
|
hoverBackground: any;
|
|
@@ -348,11 +345,11 @@ declare function _default(palette: any): {
|
|
|
348
345
|
zIndex: {
|
|
349
346
|
smallOverlay: number;
|
|
350
347
|
overlay: number;
|
|
351
|
-
popover: number;
|
|
352
348
|
nav: number;
|
|
353
349
|
modal: number;
|
|
354
350
|
header: number;
|
|
355
351
|
fullScreenModal: number;
|
|
352
|
+
popover: number;
|
|
356
353
|
notification: number;
|
|
357
354
|
aboveAll: number;
|
|
358
355
|
};
|
|
@@ -546,6 +543,7 @@ declare function _default(palette: any): {
|
|
|
546
543
|
colorsSemanticNegativeYang100: string;
|
|
547
544
|
colorsSemanticCaution400: string;
|
|
548
545
|
colorsSemanticCaution600: string;
|
|
546
|
+
colorsSemanticCaution650: string;
|
|
549
547
|
colorsSemanticCautionTransparent: string;
|
|
550
548
|
colorsSemanticCautionYin030: string;
|
|
551
549
|
colorsSemanticCautionYin055: string;
|