carbon-react 104.12.0 → 104.14.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-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/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/select-list/select-list.component.js +18 -5
- 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 +7 -1
- package/lib/components/select/simple-select/simple-select.component.js +12 -9
- package/lib/components/toast/toast.style.js +1 -1
- 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 +1 -1
- package/lib/style/themes/base/base-theme.config.js +2 -2
- package/package.json +15 -15
- package/lib/components/portal/portal.style.d.ts +0 -3
- package/lib/components/portal/portal.style.js +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from "./popover
|
|
1
|
+
export { default } from "./popover";
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
export default Popover;
|
|
2
|
-
declare function Popover({ children, placement, disablePortal, reference, onFirstUpdate, modifiers, }: {
|
|
2
|
+
declare function Popover({ children, placement, disablePortal, reference, onFirstUpdate, modifiers, disableBackgroundUI, }: {
|
|
3
3
|
children: any;
|
|
4
4
|
placement: any;
|
|
5
5
|
disablePortal: any;
|
|
6
6
|
reference: any;
|
|
7
7
|
onFirstUpdate: any;
|
|
8
8
|
modifiers: any;
|
|
9
|
+
disableBackgroundUI: any;
|
|
9
10
|
}): any;
|
|
10
11
|
declare namespace Popover {
|
|
11
12
|
namespace propTypes {
|
|
12
13
|
const children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
13
14
|
const placement: PropTypes.Requireable<string>;
|
|
15
|
+
const disableBackgroundUI: PropTypes.Requireable<boolean>;
|
|
14
16
|
const modifiers: PropTypes.Requireable<any[]>;
|
|
15
17
|
const onFirstUpdate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
18
|
const disablePortal: PropTypes.Requireable<boolean>;
|
|
@@ -15,6 +15,8 @@ var _core = require("@popperjs/core");
|
|
|
15
15
|
|
|
16
16
|
var _useResizeObserver = _interopRequireDefault(require("../../hooks/__internal__/useResizeObserver"));
|
|
17
17
|
|
|
18
|
+
var _popover = _interopRequireDefault(require("./popover.style"));
|
|
19
|
+
|
|
18
20
|
var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
|
|
19
21
|
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -29,7 +31,8 @@ const Popover = ({
|
|
|
29
31
|
disablePortal,
|
|
30
32
|
reference,
|
|
31
33
|
onFirstUpdate,
|
|
32
|
-
modifiers
|
|
34
|
+
modifiers,
|
|
35
|
+
disableBackgroundUI
|
|
33
36
|
}) => {
|
|
34
37
|
const elementDOM = (0, _react.useRef)();
|
|
35
38
|
|
|
@@ -90,6 +93,10 @@ const Popover = ({
|
|
|
90
93
|
};
|
|
91
94
|
}, [disablePortal]);
|
|
92
95
|
|
|
96
|
+
if (disableBackgroundUI) {
|
|
97
|
+
content = /*#__PURE__*/_react.default.createElement(_popover.default, null, content);
|
|
98
|
+
}
|
|
99
|
+
|
|
93
100
|
if (disablePortal) {
|
|
94
101
|
return content;
|
|
95
102
|
}
|
|
@@ -102,11 +109,13 @@ Popover.propTypes = {
|
|
|
102
109
|
children: _propTypes.default.node.isRequired,
|
|
103
110
|
// Placement of children in relation to the reference element
|
|
104
111
|
placement: _propTypes.default.oneOf(["auto", "auto-start", "auto-end", "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "right", "right-start", "right-end", "left", "left-start", "left-end"]),
|
|
112
|
+
// Disables interaction with background UI
|
|
113
|
+
disableBackgroundUI: _propTypes.default.bool,
|
|
105
114
|
// Optional modifiers array, for more information and object structure go to:
|
|
106
115
|
// https://popper.js.org/docs/v2/constructors/#modifiers
|
|
107
116
|
modifiers: _propTypes.default.array,
|
|
108
|
-
// Optional onFirstUpdate
|
|
109
|
-
// https://popper.js.org/docs/v2/
|
|
117
|
+
// Optional onFirstUpdate function, for more information go to:
|
|
118
|
+
// https://popper.js.org/docs/v2/lifecycle/#hook-into-the-lifecycle
|
|
110
119
|
onFirstUpdate: _propTypes.default.func,
|
|
111
120
|
// When true, children are not rendered in portal
|
|
112
121
|
disablePortal: _propTypes.default.bool,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { State } from "@popperjs/core";
|
|
3
|
+
|
|
4
|
+
type PopoverModifier = {
|
|
5
|
+
name: string;
|
|
6
|
+
options?: Record<string, unknown>;
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export interface PopoverPropTypes {
|
|
11
|
+
// Element to be positioned, has to be a single node and has to accept `ref` and `style` props
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
// Placement of children in relation to the reference element
|
|
14
|
+
placement?:
|
|
15
|
+
| "auto"
|
|
16
|
+
| "auto-start"
|
|
17
|
+
| "auto-end"
|
|
18
|
+
| "top"
|
|
19
|
+
| "top-start"
|
|
20
|
+
| "top-end"
|
|
21
|
+
| "bottom"
|
|
22
|
+
| "bottom-start"
|
|
23
|
+
| "bottom-end"
|
|
24
|
+
| "right"
|
|
25
|
+
| "right-start"
|
|
26
|
+
| "right-end"
|
|
27
|
+
| "left"
|
|
28
|
+
| "left-start"
|
|
29
|
+
| "left-end";
|
|
30
|
+
// Disables interaction with background UI
|
|
31
|
+
disableBackgroundUI?: boolean;
|
|
32
|
+
// Optional modifiers array, for more information and object structure go to:
|
|
33
|
+
// https://popper.js.org/docs/v2/constructors/#modifiers
|
|
34
|
+
modifiers?: PopoverModifier[];
|
|
35
|
+
// Optional onFirstUpdate function, for more information go to:
|
|
36
|
+
// hhttps://popper.js.org/docs/v2/lifecycle/#hook-into-the-lifecycle
|
|
37
|
+
onFirstUpdate?: (state: State) => void;
|
|
38
|
+
// When true, children are not rendered in portal
|
|
39
|
+
disablePortal?: boolean;
|
|
40
|
+
// Reference element, children will be positioned in relation to this element - should be a ref
|
|
41
|
+
reference?: React.RefObject<HTMLElement>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare function Popover(props: PopoverPropTypes): JSX.Element;
|
|
45
|
+
|
|
46
|
+
export default Popover;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
|
|
10
|
+
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
const StyledBackdrop = _styledComponents.default.div`
|
|
15
|
+
bottom: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
position: fixed;
|
|
18
|
+
right: 0;
|
|
19
|
+
top: 0;
|
|
20
|
+
z-index: ${({
|
|
21
|
+
theme
|
|
22
|
+
}) => theme.zIndex.popover};
|
|
23
|
+
background: transparent;
|
|
24
|
+
`;
|
|
25
|
+
StyledBackdrop.defaultProps = {
|
|
26
|
+
theme: _base.default
|
|
27
|
+
};
|
|
28
|
+
var _default = StyledBackdrop;
|
|
29
|
+
exports.default = _default;
|
|
@@ -9,8 +9,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
|
|
10
10
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
11
11
|
|
|
12
|
-
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
13
|
-
|
|
14
12
|
var _icon = _interopRequireDefault(require("../icon/icon.style"));
|
|
15
13
|
|
|
16
14
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -63,41 +61,35 @@ const StyledButtonToggleLabel = _styledComponents.default.label`
|
|
|
63
61
|
padding: 0 ${paddingConfig[size]}px;
|
|
64
62
|
font-size: ${fontSizeConfig[size]}px;
|
|
65
63
|
`}
|
|
66
|
-
font-weight:
|
|
64
|
+
font-weight: 700;
|
|
67
65
|
cursor: pointer;
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
theme
|
|
71
|
-
}) => (0, _styledComponents.css)`
|
|
72
|
-
border: 1px solid ${theme.colors.border};
|
|
73
|
-
background-color: ${theme.colors.white};
|
|
67
|
+
border: 1px solid var(--colorsActionMinor500);
|
|
74
68
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
${_icon.default} {
|
|
70
|
+
color: var(--colorsActionMinor500);
|
|
71
|
+
}
|
|
78
72
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
73
|
+
input:checked ~ && {
|
|
74
|
+
background-color: var(--colorsActionMinor300);
|
|
75
|
+
color: var(--colorsActionMinor600);
|
|
76
|
+
cursor: auto;
|
|
77
|
+
}
|
|
85
78
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
input:focus ~ & {
|
|
80
|
+
outline: 3px solid var(--colorsSemanticFocus500);
|
|
81
|
+
z-index: 100;
|
|
82
|
+
}
|
|
90
83
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
input:not(:checked):not(:disabled) ~ &:hover {
|
|
85
|
+
background-color: var(--colorsActionMinor200);
|
|
86
|
+
border-color: var(--colorsActionMinor500);
|
|
87
|
+
color: var(--colorsActionMinor500);
|
|
95
88
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
89
|
+
${_icon.default} {
|
|
90
|
+
color: var(--colorsActionMinor500);
|
|
99
91
|
}
|
|
100
|
-
|
|
92
|
+
}
|
|
101
93
|
|
|
102
94
|
${({
|
|
103
95
|
buttonIcon,
|
|
@@ -113,16 +105,14 @@ const StyledButtonToggleLabel = _styledComponents.default.label`
|
|
|
113
105
|
`}
|
|
114
106
|
|
|
115
107
|
${({
|
|
116
|
-
disabled
|
|
117
|
-
theme
|
|
108
|
+
disabled
|
|
118
109
|
}) => disabled && (0, _styledComponents.css)`
|
|
119
110
|
& {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
color: ${theme.disabled.buttonText};
|
|
111
|
+
border-color: var(--colorsActionDisabled500);
|
|
112
|
+
color: var(--colorsActionMinorYin030);
|
|
123
113
|
|
|
124
114
|
${_icon.default} {
|
|
125
|
-
color:
|
|
115
|
+
color: var(--colorsActionMinorYin030);
|
|
126
116
|
}
|
|
127
117
|
}
|
|
128
118
|
cursor: not-allowed;
|
|
@@ -188,10 +178,4 @@ const StyledButtonToggleInput = _styledComponents.default.input`
|
|
|
188
178
|
exports.StyledButtonToggleInput = StyledButtonToggleInput;
|
|
189
179
|
StyledButtonToggleIcon.propTypes = {
|
|
190
180
|
buttonIconSize: _propTypes.default.string
|
|
191
|
-
};
|
|
192
|
-
StyledButtonToggleLabel.defaultProps = {
|
|
193
|
-
theme: _base.default
|
|
194
|
-
};
|
|
195
|
-
StyledButtonToggleLabel.defaultProps = {
|
|
196
|
-
theme: _base.default
|
|
197
181
|
};
|
|
@@ -11,8 +11,6 @@ var _buttonToggle = require("../button-toggle/button-toggle.style");
|
|
|
11
11
|
|
|
12
12
|
var _validationIcon = _interopRequireDefault(require("../../__internal__/validations/validation-icon.style"));
|
|
13
13
|
|
|
14
|
-
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
15
|
-
|
|
16
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
15
|
|
|
18
16
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -30,24 +28,21 @@ const ButtonToggleGroupStyle = _styledComponents.default.div`
|
|
|
30
28
|
|
|
31
29
|
${_buttonToggle.StyledButtonToggleLabel} {
|
|
32
30
|
${({
|
|
33
|
-
theme,
|
|
34
31
|
info
|
|
35
32
|
}) => info && (0, _styledComponents.css)`
|
|
36
|
-
border-color:
|
|
33
|
+
border-color: var(--colorsActionMinor500);
|
|
37
34
|
`};
|
|
38
35
|
${({
|
|
39
|
-
theme,
|
|
40
36
|
warning
|
|
41
37
|
}) => warning && (0, _styledComponents.css)`
|
|
42
|
-
border-color:
|
|
38
|
+
border-color: var(--colorsSemanticCaution500);
|
|
43
39
|
`}
|
|
44
40
|
${({
|
|
45
|
-
theme,
|
|
46
41
|
error
|
|
47
42
|
}) => error && (0, _styledComponents.css)`
|
|
48
|
-
box-shadow: inset 1px 1px 0
|
|
49
|
-
inset -1px -1px 0
|
|
50
|
-
border-color:
|
|
43
|
+
box-shadow: inset 1px 1px 0 var(--colorsSemanticNegative500),
|
|
44
|
+
inset -1px -1px 0 var(--colorsSemanticNegative500);
|
|
45
|
+
border-color: var(--colorsSemanticNegative500);
|
|
51
46
|
`}
|
|
52
47
|
}
|
|
53
48
|
|
|
@@ -55,8 +50,5 @@ const ButtonToggleGroupStyle = _styledComponents.default.div`
|
|
|
55
50
|
margin-left: 4px;
|
|
56
51
|
}
|
|
57
52
|
`;
|
|
58
|
-
ButtonToggleGroupStyle.defaultProps = {
|
|
59
|
-
theme: _base.default
|
|
60
|
-
};
|
|
61
53
|
var _default = ButtonToggleGroupStyle;
|
|
62
54
|
exports.default = _default;
|
|
@@ -11,9 +11,11 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _reactTransitionGroup = require("react-transition-group");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _useScrollBlock = _interopRequireDefault(require("../../hooks/__internal__/useScrollBlock"));
|
|
15
|
+
|
|
16
|
+
var _portal = _interopRequireDefault(require("../portal"));
|
|
15
17
|
|
|
16
|
-
var
|
|
18
|
+
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
17
19
|
|
|
18
20
|
var _modalManager = _interopRequireDefault(require("./__internal__/modal-manager"));
|
|
19
21
|
|
|
@@ -44,35 +46,30 @@ const Modal = ({
|
|
|
44
46
|
const ref = (0, _react.useRef)();
|
|
45
47
|
const listenerAdded = (0, _react.useRef)(false);
|
|
46
48
|
const modalRegistered = (0, _react.useRef)(false);
|
|
47
|
-
const originalOverflow = (0, _react.useRef)(undefined);
|
|
48
49
|
const [isAnimationComplete, setAnimationComplete] = (0, _react.useState)(false);
|
|
49
50
|
const [triggerRefocusFlag, setTriggerRefocusFlag] = (0, _react.useState)(false);
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}, [enableBackgroundUI]);
|
|
56
|
-
const unsetOverflow = (0, _react.useCallback)(() => {
|
|
57
|
-
if (typeof originalOverflow.current !== "undefined" && !enableBackgroundUI) {
|
|
58
|
-
document.documentElement.style.overflow = originalOverflow.current;
|
|
59
|
-
originalOverflow.current = undefined;
|
|
60
|
-
}
|
|
61
|
-
}, [enableBackgroundUI]);
|
|
51
|
+
const {
|
|
52
|
+
blockScroll,
|
|
53
|
+
allowScroll
|
|
54
|
+
} = (0, _useScrollBlock.default)();
|
|
62
55
|
(0, _react.useEffect)(() => {
|
|
63
|
-
if (
|
|
64
|
-
|
|
56
|
+
if (enableBackgroundUI) {
|
|
57
|
+
return;
|
|
65
58
|
}
|
|
66
59
|
|
|
67
|
-
if (
|
|
68
|
-
|
|
60
|
+
if (open) {
|
|
61
|
+
blockScroll();
|
|
62
|
+
} else {
|
|
63
|
+
allowScroll();
|
|
69
64
|
}
|
|
70
|
-
}, [
|
|
65
|
+
}, [allowScroll, blockScroll, enableBackgroundUI, open]);
|
|
71
66
|
(0, _react.useEffect)(() => {
|
|
72
67
|
return () => {
|
|
73
|
-
|
|
68
|
+
if (!enableBackgroundUI) {
|
|
69
|
+
allowScroll();
|
|
70
|
+
}
|
|
74
71
|
};
|
|
75
|
-
}, [
|
|
72
|
+
}, [allowScroll, enableBackgroundUI]);
|
|
76
73
|
const closeModal = (0, _react.useCallback)(ev => {
|
|
77
74
|
const isTopmost = _modalManager.default.isTopmost(ref.current);
|
|
78
75
|
|
|
@@ -143,7 +140,8 @@ const Modal = ({
|
|
|
143
140
|
if (open) {
|
|
144
141
|
background = !enableBackgroundUI ? /*#__PURE__*/_react.default.createElement(_modal.StyledModalBackground, {
|
|
145
142
|
"data-element": "modal-background",
|
|
146
|
-
transitionName: "modal-background"
|
|
143
|
+
transitionName: "modal-background",
|
|
144
|
+
transitionTime: timeout
|
|
147
145
|
}) : null;
|
|
148
146
|
content = children;
|
|
149
147
|
}
|
|
@@ -151,6 +149,7 @@ const Modal = ({
|
|
|
151
149
|
return /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_modal.StyledModal, _extends({
|
|
152
150
|
"data-state": open ? "open" : "closed",
|
|
153
151
|
transitionName: "modal",
|
|
152
|
+
transitionTime: timeout,
|
|
154
153
|
ref: ref
|
|
155
154
|
}, rest), /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.TransitionGroup, null, background && /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
|
|
156
155
|
key: "modal",
|
|
@@ -197,7 +196,7 @@ Modal.defaultProps = {
|
|
|
197
196
|
onCancel: null,
|
|
198
197
|
enableBackgroundUI: false,
|
|
199
198
|
disableEscKey: false,
|
|
200
|
-
timeout:
|
|
199
|
+
timeout: 300
|
|
201
200
|
};
|
|
202
201
|
var _default = Modal;
|
|
203
202
|
exports.default = _default;
|
|
@@ -7,14 +7,15 @@ exports.StyledModalBackground = exports.StyledModal = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
9
|
|
|
10
|
+
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
10
14
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
11
15
|
|
|
12
16
|
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; }
|
|
13
17
|
|
|
14
18
|
const backgroundOpacity = "0.6";
|
|
15
|
-
const backgroundAnimationLength = "300ms";
|
|
16
|
-
const initialPosition = "50px";
|
|
17
|
-
const animationLength = "300ms";
|
|
18
19
|
const StyledModalBackground = _styledComponents.default.div`
|
|
19
20
|
background-color: rgba(0, 20, 29, 0.6);
|
|
20
21
|
bottom: 0;
|
|
@@ -25,7 +26,8 @@ const StyledModalBackground = _styledComponents.default.div`
|
|
|
25
26
|
top: 0;
|
|
26
27
|
|
|
27
28
|
${({
|
|
28
|
-
transitionName
|
|
29
|
+
transitionName,
|
|
30
|
+
transitionTime
|
|
29
31
|
}) => (0, _styledComponents.css)`
|
|
30
32
|
&.${transitionName}-enter, .${transitionName}-appear {
|
|
31
33
|
opacity: 0;
|
|
@@ -34,7 +36,7 @@ const StyledModalBackground = _styledComponents.default.div`
|
|
|
34
36
|
&.${transitionName}-enter.${transitionName}-enter-active,
|
|
35
37
|
&.${transitionName}-appear.${transitionName}-appear-active {
|
|
36
38
|
opacity: ${backgroundOpacity};
|
|
37
|
-
transition: opacity ${
|
|
39
|
+
transition: opacity ${transitionTime}ms ease-out;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
&.${transitionName}-exit {
|
|
@@ -43,37 +45,42 @@ const StyledModalBackground = _styledComponents.default.div`
|
|
|
43
45
|
|
|
44
46
|
&.${transitionName}-exit.${transitionName}-exit-active {
|
|
45
47
|
opacity: 0;
|
|
46
|
-
transition: opacity ${
|
|
48
|
+
transition: opacity ${transitionTime}ms 100ms ease-out;
|
|
47
49
|
}
|
|
48
|
-
`}
|
|
50
|
+
`};
|
|
49
51
|
`;
|
|
50
52
|
exports.StyledModalBackground = StyledModalBackground;
|
|
51
53
|
const StyledModal = _styledComponents.default.div`
|
|
54
|
+
position: absolute;
|
|
55
|
+
z-index: ${({
|
|
56
|
+
theme
|
|
57
|
+
}) => theme.zIndex.modal};
|
|
58
|
+
|
|
52
59
|
${({
|
|
53
|
-
transitionName
|
|
60
|
+
transitionName,
|
|
61
|
+
transitionTime
|
|
54
62
|
}) => (0, _styledComponents.css)`
|
|
55
63
|
.${transitionName}-enter, .${transitionName}-appear {
|
|
56
64
|
opacity: 0;
|
|
57
|
-
margin-top: ${initialPosition};
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
.${transitionName}-enter.${transitionName}-enter-active,
|
|
61
68
|
.${transitionName}-appear.${transitionName}-appear-active {
|
|
62
69
|
opacity: 1;
|
|
63
|
-
|
|
64
|
-
transition: all ${animationLength} 100ms ease-out;
|
|
70
|
+
transition: all ${transitionTime}ms 100ms ease-out;
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
.${transitionName}-exit {
|
|
68
74
|
opacity: 1;
|
|
69
|
-
margin-top: 0;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
.${transitionName}-exit.${transitionName}-exit-active {
|
|
73
78
|
opacity: 0;
|
|
74
|
-
|
|
75
|
-
transition: all ${animationLength} ease-out;
|
|
79
|
+
transition: all ${transitionTime}ms ease-out;
|
|
76
80
|
}
|
|
77
81
|
`}
|
|
78
82
|
`;
|
|
79
|
-
exports.StyledModal = StyledModal;
|
|
83
|
+
exports.StyledModal = StyledModal;
|
|
84
|
+
StyledModal.defaultProps = {
|
|
85
|
+
theme: _base.default
|
|
86
|
+
};
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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
|
|
|
@@ -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;
|
|
@@ -348,11 +348,11 @@ declare function _default(palette: any): {
|
|
|
348
348
|
zIndex: {
|
|
349
349
|
smallOverlay: number;
|
|
350
350
|
overlay: number;
|
|
351
|
-
popover: number;
|
|
352
351
|
nav: number;
|
|
353
352
|
modal: number;
|
|
354
353
|
header: number;
|
|
355
354
|
fullScreenModal: number;
|
|
355
|
+
popover: number;
|
|
356
356
|
notification: number;
|
|
357
357
|
aboveAll: number;
|
|
358
358
|
};
|
|
@@ -369,12 +369,12 @@ var _default = palette => {
|
|
|
369
369
|
zIndex: {
|
|
370
370
|
smallOverlay: 10,
|
|
371
371
|
overlay: 1000,
|
|
372
|
-
popover: 2000,
|
|
373
372
|
nav: 2999,
|
|
374
373
|
modal: 3000,
|
|
375
374
|
header: 4000,
|
|
376
375
|
fullScreenModal: 5000,
|
|
377
|
-
|
|
376
|
+
popover: 6000,
|
|
377
|
+
notification: 7000,
|
|
378
378
|
aboveAll: 9999
|
|
379
379
|
},
|
|
380
380
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "104.
|
|
3
|
+
"version": "104.14.0",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"engines": {
|
|
@@ -71,18 +71,18 @@
|
|
|
71
71
|
"@semantic-release/changelog": "^6.0.1",
|
|
72
72
|
"@semantic-release/exec": "^6.0.2",
|
|
73
73
|
"@semantic-release/git": "^10.0.1",
|
|
74
|
-
"@storybook/addon-a11y": "^6.
|
|
75
|
-
"@storybook/addon-actions": "^6.
|
|
76
|
-
"@storybook/addon-controls": "^6.
|
|
77
|
-
"@storybook/addon-docs": "^6.
|
|
74
|
+
"@storybook/addon-a11y": "^6.4.18",
|
|
75
|
+
"@storybook/addon-actions": "^6.4.18",
|
|
76
|
+
"@storybook/addon-controls": "^6.4.18",
|
|
77
|
+
"@storybook/addon-docs": "^6.4.18",
|
|
78
78
|
"@storybook/addon-google-analytics": "^6.2.9",
|
|
79
|
-
"@storybook/addon-links": "^6.
|
|
80
|
-
"@storybook/addon-toolbars": "^6.
|
|
81
|
-
"@storybook/addon-viewport": "^6.
|
|
82
|
-
"@storybook/addons": "^6.
|
|
83
|
-
"@storybook/components": "^6.
|
|
84
|
-
"@storybook/react": "^6.
|
|
85
|
-
"@storybook/theming": "^6.
|
|
79
|
+
"@storybook/addon-links": "^6.4.18",
|
|
80
|
+
"@storybook/addon-toolbars": "^6.4.18",
|
|
81
|
+
"@storybook/addon-viewport": "^6.4.18",
|
|
82
|
+
"@storybook/addons": "^6.4.18",
|
|
83
|
+
"@storybook/components": "^6.4.18",
|
|
84
|
+
"@storybook/react": "^6.4.18",
|
|
85
|
+
"@storybook/theming": "^6.4.18",
|
|
86
86
|
"@types/enzyme": "^3.10.3",
|
|
87
87
|
"@types/enzyme-adapter-react-16": "^1.0.5",
|
|
88
88
|
"@types/jest": "^26.0.19",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"react-dom": "^16.12.0",
|
|
144
144
|
"react-test-renderer": "^16.12.0",
|
|
145
145
|
"rimraf": "^3.0.2",
|
|
146
|
-
"semantic-release": "^
|
|
146
|
+
"semantic-release": "^19.0.2",
|
|
147
147
|
"semver": "^7.3.5",
|
|
148
148
|
"sprintf-js": "^1.1.2",
|
|
149
149
|
"styled-components": "^4.4.1",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"typescript": "^4.3.5",
|
|
152
152
|
"typescript-to-proptypes": "^2.2.1",
|
|
153
153
|
"uuid": "^8.3.2",
|
|
154
|
-
"webpack-dev-server": "^3.11.
|
|
154
|
+
"webpack-dev-server": "^3.11.3"
|
|
155
155
|
},
|
|
156
156
|
"dependencies": {
|
|
157
157
|
"@octokit/rest": "^18.12.0",
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"immutable": "~3.8.2",
|
|
168
168
|
"invariant": "^2.2.4",
|
|
169
169
|
"lodash": "^4.17.20",
|
|
170
|
-
"node-fetch": "^2.6.
|
|
170
|
+
"node-fetch": "^2.6.7",
|
|
171
171
|
"polished": "^4.0.5",
|
|
172
172
|
"prop-types": "^15.7.2",
|
|
173
173
|
"react-day-picker": "~7.4.10",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
|
|
10
|
-
var _portal = _interopRequireDefault(require("./portal"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
const StyledPortal = (0, _styledComponents.default)(_portal.default)`
|
|
15
|
-
position: absolute;
|
|
16
|
-
top: 0;
|
|
17
|
-
z-index: 1002;
|
|
18
|
-
`;
|
|
19
|
-
var _default = StyledPortal;
|
|
20
|
-
exports.default = _default;
|