carbon-react 104.10.1 → 104.12.1
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/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js +3 -0
- package/lib/components/navigation-bar/navigation-bar.style.js +10 -9
- package/lib/components/pager/pager.style.js +3 -1
- package/lib/components/search/search.style.js +31 -40
- package/lib/components/select/__internal__/select-list-context.d.ts +3 -0
- package/lib/components/select/__internal__/select-list-context.js +15 -0
- package/lib/components/select/__internal__/select-text/select-text.component.d.ts +30 -0
- package/lib/components/select/__internal__/select-text/select-text.component.js +111 -0
- package/lib/components/select/__internal__/select-text/select-text.d.ts +34 -0
- package/lib/components/select/__internal__/select-text/select-text.style.d.ts +2 -0
- package/lib/components/select/__internal__/select-text/select-text.style.js +65 -0
- package/lib/components/select/filterable-select/filterable-select.component.js +7 -4
- package/lib/components/select/multi-select/multi-select.component.js +23 -7
- package/lib/components/select/multi-select/multi-select.style.d.ts +1 -0
- package/lib/components/select/multi-select/multi-select.style.js +5 -1
- package/lib/components/select/option/option.component.js +32 -8
- package/lib/components/select/option-row/option-row.component.js +23 -6
- package/lib/components/select/select-list/select-list.component.js +36 -23
- package/lib/components/select/select-textbox/select-textbox.component.d.ts +113 -26
- package/lib/components/select/select-textbox/select-textbox.component.js +82 -3
- package/lib/components/select/select-textbox/select-textbox.d.ts +8 -2
- package/lib/components/select/select.style.js +10 -7
- package/lib/components/select/simple-select/simple-select.component.js +13 -20
- package/package.json +1 -1
package/lib/components/flat-table/flat-table-body-draggable/flat-table-body-draggable.component.js
CHANGED
|
@@ -109,7 +109,10 @@ const FlatTableBodyDraggable = ({
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
FlatTableBodyDraggable.propTypes = {
|
|
112
|
+
/** Callback fired when order is changed */
|
|
112
113
|
getOrder: _propTypes.default.func,
|
|
114
|
+
|
|
115
|
+
/** Array of FlatTableRow. */
|
|
113
116
|
children: _propTypes.default.node.isRequired
|
|
114
117
|
};
|
|
115
118
|
var _default = FlatTableBodyDraggable;
|
|
@@ -65,24 +65,25 @@ const StyledNavigationBar = _styledComponents.default.nav`
|
|
|
65
65
|
z-index: ${theme.zIndex.nav};
|
|
66
66
|
|
|
67
67
|
${navigationType === "light" && (0, _styledComponents.css)`
|
|
68
|
-
background-color:
|
|
69
|
-
border-bottom:
|
|
68
|
+
background-color: var(--colorsComponentsMenuSpringStandard500);
|
|
69
|
+
border-bottom: var(--borderWidth100) solid
|
|
70
|
+
var(--colorsComponentsMenuSpringChildAlt500);
|
|
70
71
|
`}
|
|
71
72
|
|
|
72
73
|
${navigationType === "dark" && (0, _styledComponents.css)`
|
|
73
|
-
background-color:
|
|
74
|
-
|
|
75
|
-
color: ${theme.colors.white};
|
|
74
|
+
background-color: var(--colorsComponentsMenuAutumnStandard500);
|
|
75
|
+
color: var(--colorsComponentsMenuYang100);
|
|
76
76
|
`}
|
|
77
77
|
|
|
78
78
|
${navigationType === "black" && (0, _styledComponents.css)`
|
|
79
|
-
background-color:
|
|
80
|
-
color:
|
|
79
|
+
background-color: var(--colorsComponentsMenuWinterStandard500);
|
|
80
|
+
color: var(--colorsComponentsMenuYang100);
|
|
81
81
|
`}
|
|
82
82
|
|
|
83
83
|
${navigationType === "white" && (0, _styledComponents.css)`
|
|
84
|
-
background-color:
|
|
85
|
-
border-bottom:
|
|
84
|
+
background-color: var(--colorsComponentsMenuSummerStandard500);
|
|
85
|
+
border-bottom: var(--borderWidth100) solid
|
|
86
|
+
var(--colorsComponentsMenuSummerChildAlt500);
|
|
86
87
|
`}
|
|
87
88
|
`}
|
|
88
89
|
`;
|
|
@@ -15,6 +15,8 @@ var _inputIconToggle = _interopRequireDefault(require("../../__internal__/input-
|
|
|
15
15
|
|
|
16
16
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
17
17
|
|
|
18
|
+
var _selectText = _interopRequireDefault(require("../select/__internal__/select-text/select-text.style"));
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
21
|
|
|
20
22
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -108,7 +110,7 @@ const StyledPagerSizeOptions = _styledComponents.default.div`
|
|
|
108
110
|
min-width: 10px;
|
|
109
111
|
margin: 0px 4px;
|
|
110
112
|
|
|
111
|
-
${
|
|
113
|
+
${_selectText.default} {
|
|
112
114
|
font-size: 14px;
|
|
113
115
|
padding-right: 0px;
|
|
114
116
|
padding-left: 8px;
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.StyledButtonIcon = exports.StyledSearchButton = exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
-
|
|
10
8
|
var _styledSystem = require("styled-system");
|
|
11
9
|
|
|
10
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
11
|
+
|
|
12
12
|
var _inputIconToggle = _interopRequireDefault(require("../../__internal__/input-icon-toggle/input-icon-toggle.style"));
|
|
13
13
|
|
|
14
14
|
var _inputPresentation = _interopRequireDefault(require("../../__internal__/input/input-presentation.style"));
|
|
@@ -40,7 +40,7 @@ const StyledSearch = _styledComponents.default.div`
|
|
|
40
40
|
variant
|
|
41
41
|
}) => {
|
|
42
42
|
const darkVariant = variant === "dark";
|
|
43
|
-
const variantColor = darkVariant ?
|
|
43
|
+
const variantColor = darkVariant ? "var(--colorsUtilityMajor200)" : "var(--colorsUtilityMajor300)";
|
|
44
44
|
const iconColor = darkVariant && (searchHasValue && isFocused || !searchHasValue && isFocused || !isFocused && searchHasValue && showSearchButton);
|
|
45
45
|
return (0, _styledComponents.css)`
|
|
46
46
|
${_styledSystem.margin}
|
|
@@ -52,52 +52,53 @@ const StyledSearch = _styledComponents.default.div`
|
|
|
52
52
|
font-size: 14px;
|
|
53
53
|
font-weight: 700;
|
|
54
54
|
:hover {
|
|
55
|
-
border-bottom-color: ${
|
|
55
|
+
border-bottom-color: ${darkVariant ? "var(--colorsUtilityMajor100)" : "var(--colorsUtilityMajor400)"};
|
|
56
56
|
cursor: pointer;
|
|
57
57
|
}
|
|
58
58
|
${(isFocused || searchHasValue) && (0, _styledComponents.css)`
|
|
59
59
|
border-color: transparent;
|
|
60
60
|
transition: background 0.2s ease;
|
|
61
|
-
color: ${theme.icon.defaultHover};
|
|
62
61
|
:hover {
|
|
63
62
|
border-color: transparent;
|
|
64
63
|
}
|
|
65
64
|
`}
|
|
66
65
|
${isFocused && !searchIsActive && (0, _styledComponents.css)`
|
|
67
66
|
border-color: transparent;
|
|
68
|
-
color: ${theme.icon.defaultHover};
|
|
69
67
|
`}
|
|
70
68
|
${!isFocused && searchHasValue && !showSearchButton && (0, _styledComponents.css)`
|
|
71
69
|
border-bottom: 2px solid ${variantColor};
|
|
72
70
|
:hover {
|
|
73
|
-
border-bottom-color:
|
|
71
|
+
border-bottom-color: var(--colorsUtilityMajor400);
|
|
74
72
|
cursor: pointer;
|
|
75
73
|
}
|
|
76
74
|
`}
|
|
77
75
|
|
|
78
76
|
${_input.default} {
|
|
77
|
+
::-moz-placeholder {
|
|
78
|
+
color: var(--colorsUtilityYin055);
|
|
79
|
+
opacity: 1;
|
|
80
|
+
}
|
|
81
|
+
::placeholder {
|
|
82
|
+
color: var(--colorsUtilityYin055);
|
|
83
|
+
}
|
|
84
|
+
|
|
79
85
|
${darkVariant && !isFocused && (0, _styledComponents.css)`
|
|
80
86
|
::-moz-placeholder {
|
|
81
|
-
color:
|
|
87
|
+
color: var(--colorsUtilityMajor200);
|
|
82
88
|
opacity: 1;
|
|
83
89
|
}
|
|
84
90
|
::placeholder {
|
|
85
|
-
color:
|
|
91
|
+
color: var(--colorsUtilityMajor200);
|
|
86
92
|
}
|
|
87
93
|
`}
|
|
88
94
|
|
|
89
|
-
${darkVariant && (0, _styledComponents.css)`
|
|
90
|
-
|
|
91
|
-
color: ${theme.search.darkVariantText};
|
|
92
|
-
`}
|
|
93
|
-
${!isFocused && !searchHasValue && (0, _styledComponents.css)`
|
|
94
|
-
color: ${theme.search.darkVariantPlaceholder};
|
|
95
|
-
`}
|
|
95
|
+
${darkVariant && !isFocused && searchHasValue && !showSearchButton && (0, _styledComponents.css)`
|
|
96
|
+
color: var(--colorsUtilityYang100);
|
|
96
97
|
`}
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
${_inputPresentation.default} {
|
|
100
|
-
background-color: ${searchHasValue || isFocused ?
|
|
101
|
+
background-color: ${searchHasValue || isFocused ? "var(--colorsUtilityYang100)" : "transparent"};
|
|
101
102
|
flex: 1;
|
|
102
103
|
font-size: 14px;
|
|
103
104
|
font-weight: 700;
|
|
@@ -106,11 +107,10 @@ const StyledSearch = _styledComponents.default.div`
|
|
|
106
107
|
cursor: pointer;
|
|
107
108
|
${!isFocused && !searchHasValue && (0, _styledComponents.css)`
|
|
108
109
|
border: 1px solid transparent;
|
|
109
|
-
color: ${theme.icon.default};
|
|
110
110
|
`}
|
|
111
111
|
${!isFocused && searchHasValue && !showSearchButton && (0, _styledComponents.css)`
|
|
112
112
|
border: 1px solid transparent;
|
|
113
|
-
background-color: ${darkVariant ? "transparent" :
|
|
113
|
+
background-color: ${darkVariant ? "transparent" : "var(--colorsUtilityYang100)"};
|
|
114
114
|
`}
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -118,24 +118,19 @@ const StyledSearch = _styledComponents.default.div`
|
|
|
118
118
|
flex: 1;
|
|
119
119
|
z-index: ${theme.zIndex.smallOverlay};
|
|
120
120
|
}
|
|
121
|
-
${_button.default} {
|
|
122
|
-
background-color: ${theme.search.button};
|
|
123
|
-
cursor: pointer;
|
|
124
|
-
color: ${theme.colors.white};
|
|
125
|
-
}
|
|
126
121
|
${_icon.default} {
|
|
127
|
-
color: ${iconColor ?
|
|
122
|
+
color: ${iconColor ? "var(--colorsUtilityMajor400)" : "var(--colorsUtilityMajor200)"};
|
|
128
123
|
${!darkVariant && (0, _styledComponents.css)`
|
|
129
|
-
color:
|
|
124
|
+
color: var(--colorsUtilityMajor400);
|
|
130
125
|
`}
|
|
131
126
|
|
|
132
127
|
width: 20px;
|
|
133
128
|
height: 20px;
|
|
134
129
|
cursor: pointer;
|
|
135
130
|
:hover {
|
|
136
|
-
color: ${iconColor ?
|
|
131
|
+
color: ${iconColor ? "var(--colorsUtilityMajor500)" : "var(--colorsUtilityMajor100)"};
|
|
137
132
|
${!darkVariant && (0, _styledComponents.css)`
|
|
138
|
-
color:
|
|
133
|
+
color: var(--colorsUtilityMajor500);
|
|
139
134
|
`}
|
|
140
135
|
}
|
|
141
136
|
}
|
|
@@ -156,17 +151,13 @@ exports.default = _default;
|
|
|
156
151
|
const StyledSearchButton = _styledComponents.default.div`
|
|
157
152
|
display: inline-flex;
|
|
158
153
|
border-bottom: none;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
background
|
|
164
|
-
border-color:
|
|
165
|
-
|
|
166
|
-
background: ${theme.colors.secondary};
|
|
167
|
-
border-color: ${theme.colors.secondary};
|
|
168
|
-
}
|
|
169
|
-
`}
|
|
154
|
+
& ${_button.default} {
|
|
155
|
+
background-color: var(--colorsActionMajor500);
|
|
156
|
+
border-color: var(--colorsActionMajorTransparent);
|
|
157
|
+
:hover {
|
|
158
|
+
background: var(--colorsActionMajor600);
|
|
159
|
+
border-color: var(--colorsActionMajorTransparent);
|
|
160
|
+
}
|
|
170
161
|
|
|
171
162
|
width: 40px;
|
|
172
163
|
margin: 0px 0px;
|
|
@@ -181,7 +172,7 @@ const StyledSearchButton = _styledComponents.default.div`
|
|
|
181
172
|
exports.StyledSearchButton = StyledSearchButton;
|
|
182
173
|
const StyledButtonIcon = _styledComponents.default.div`
|
|
183
174
|
&&& ${_icon.default} {
|
|
184
|
-
color:
|
|
175
|
+
color: var(--colorsActionMajorYang100);
|
|
185
176
|
margin-right: 0px;
|
|
186
177
|
}
|
|
187
178
|
`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const SelectListContext = /*#__PURE__*/_react.default.createContext({});
|
|
13
|
+
|
|
14
|
+
var _default = SelectListContext;
|
|
15
|
+
exports.default = _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default SelectText;
|
|
2
|
+
declare function SelectText({ disabled, formattedValue, onClick, onKeyDown, onFocus, onBlur, onMouseDown, placeholder, readOnly, textId, transparent, }: {
|
|
3
|
+
disabled: any;
|
|
4
|
+
formattedValue: any;
|
|
5
|
+
onClick: any;
|
|
6
|
+
onKeyDown: any;
|
|
7
|
+
onFocus: any;
|
|
8
|
+
onBlur: any;
|
|
9
|
+
onMouseDown: any;
|
|
10
|
+
placeholder: any;
|
|
11
|
+
readOnly: any;
|
|
12
|
+
textId: any;
|
|
13
|
+
transparent: any;
|
|
14
|
+
}): JSX.Element;
|
|
15
|
+
declare namespace SelectText {
|
|
16
|
+
namespace propTypes {
|
|
17
|
+
const disabled: PropTypes.Requireable<boolean>;
|
|
18
|
+
const formattedValue: PropTypes.Requireable<string>;
|
|
19
|
+
const onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
|
+
const onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
21
|
+
const onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
+
const onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
+
const onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
24
|
+
const placeholder: PropTypes.Requireable<string>;
|
|
25
|
+
const readOnly: PropTypes.Requireable<boolean>;
|
|
26
|
+
const transparent: PropTypes.Requireable<boolean>;
|
|
27
|
+
const textId: PropTypes.Requireable<string>;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,111 @@
|
|
|
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 _selectText = _interopRequireDefault(require("./select-text.style"));
|
|
13
|
+
|
|
14
|
+
var _useLocale = _interopRequireDefault(require("../../../../hooks/__internal__/useLocale"));
|
|
15
|
+
|
|
16
|
+
var _inputBehaviour = require("../../../../__internal__/input-behaviour");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
const SelectText = ({
|
|
25
|
+
disabled,
|
|
26
|
+
formattedValue,
|
|
27
|
+
onClick,
|
|
28
|
+
onKeyDown,
|
|
29
|
+
onFocus,
|
|
30
|
+
onBlur,
|
|
31
|
+
onMouseDown,
|
|
32
|
+
placeholder,
|
|
33
|
+
readOnly,
|
|
34
|
+
textId,
|
|
35
|
+
transparent
|
|
36
|
+
}) => {
|
|
37
|
+
const l = (0, _useLocale.default)();
|
|
38
|
+
const inputContext = (0, _react.useContext)(_inputBehaviour.InputContext);
|
|
39
|
+
const hasPlaceholder = !disabled && !readOnly && !formattedValue;
|
|
40
|
+
const placeholderText = hasPlaceholder ? placeholder || l.select.placeholder() : "";
|
|
41
|
+
|
|
42
|
+
function handleFocus(event) {
|
|
43
|
+
inputContext.onFocus(event);
|
|
44
|
+
|
|
45
|
+
if (onFocus) {
|
|
46
|
+
onFocus(event);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function handleBlur(event) {
|
|
51
|
+
inputContext.onBlur(event);
|
|
52
|
+
|
|
53
|
+
if (onBlur) {
|
|
54
|
+
onBlur(event);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return /*#__PURE__*/_react.default.createElement(_selectText.default, {
|
|
59
|
+
"aria-hidden": true,
|
|
60
|
+
"data-element": "select-text",
|
|
61
|
+
disabled: disabled,
|
|
62
|
+
hasPlaceholder: hasPlaceholder,
|
|
63
|
+
id: textId,
|
|
64
|
+
onBlur: handleBlur,
|
|
65
|
+
onClick: onClick,
|
|
66
|
+
onFocus: handleFocus,
|
|
67
|
+
onKeyDown: onKeyDown,
|
|
68
|
+
onMouseDown: onMouseDown,
|
|
69
|
+
readOnly: readOnly,
|
|
70
|
+
role: "button",
|
|
71
|
+
tabIndex: "-1",
|
|
72
|
+
transparent: transparent
|
|
73
|
+
}, formattedValue || placeholderText);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
SelectText.propTypes = {
|
|
77
|
+
/** If true the Component will be disabled */
|
|
78
|
+
disabled: _propTypes.default.bool,
|
|
79
|
+
|
|
80
|
+
/** Value to be displayed */
|
|
81
|
+
formattedValue: _propTypes.default.string,
|
|
82
|
+
|
|
83
|
+
/** Callback function for when the Select Textbox loses it's focus. */
|
|
84
|
+
onBlur: _propTypes.default.func,
|
|
85
|
+
|
|
86
|
+
/** Callback function for when the component is clicked. */
|
|
87
|
+
onClick: _propTypes.default.func,
|
|
88
|
+
|
|
89
|
+
/** Callback function for when the Select Textbox is focused. */
|
|
90
|
+
onFocus: _propTypes.default.func,
|
|
91
|
+
|
|
92
|
+
/** Callback function for when the key is pressed when focused on Select Text. */
|
|
93
|
+
onKeyDown: _propTypes.default.func,
|
|
94
|
+
|
|
95
|
+
/** Callback function for when the left mouse key is pressed when focused on Select Text. */
|
|
96
|
+
onMouseDown: _propTypes.default.func,
|
|
97
|
+
|
|
98
|
+
/** Placeholder string to be displayed when formattedValue is empty */
|
|
99
|
+
placeholder: _propTypes.default.string,
|
|
100
|
+
|
|
101
|
+
/** If true the Component will be read-only */
|
|
102
|
+
readOnly: _propTypes.default.bool,
|
|
103
|
+
|
|
104
|
+
/** If true the component has no border and a transparent background */
|
|
105
|
+
transparent: _propTypes.default.bool,
|
|
106
|
+
|
|
107
|
+
/** Id of the Select Text element */
|
|
108
|
+
textId: _propTypes.default.string
|
|
109
|
+
};
|
|
110
|
+
var _default = SelectText;
|
|
111
|
+
exports.default = _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
export interface SelectTextProps {
|
|
4
|
+
/** If true the Component will be disabled */
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
/** Value to be displayed */
|
|
7
|
+
formattedValue?: string;
|
|
8
|
+
/** Label id passed from Select component */
|
|
9
|
+
labelId?: string;
|
|
10
|
+
/** If true, the list is displayed */
|
|
11
|
+
isOpen?: boolean;
|
|
12
|
+
/** Callback function for when the Select Textbox loses it's focus. */
|
|
13
|
+
onBlur?: (ev: React.FocusEvent<HTMLElement>) => void;
|
|
14
|
+
/** Callback function for when the component is clicked. */
|
|
15
|
+
onClick?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
16
|
+
/** Callback function for when the Select Textbox is focused. */
|
|
17
|
+
onFocus?: (ev: React.FocusEvent<HTMLElement>) => void;
|
|
18
|
+
/** Callback function for when the key is pressed when focused on Select Text. */
|
|
19
|
+
onKeyDown?: (ev: React.KeyboardEvent<HTMLElement>) => void;
|
|
20
|
+
/** Callback function for when the left mouse key is pressed when focused on Select Text. */
|
|
21
|
+
onMouseDown?: (ev: React.MouseEvent<HTMLElement>) => void;
|
|
22
|
+
/** Placeholder string to be displayed when formattedValue is empty */
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
/** If true the Component will be read-only */
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
/** If true the component has no border and a transparent background */
|
|
27
|
+
transparent?: boolean;
|
|
28
|
+
/** Id of the Select Text element */
|
|
29
|
+
textId?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare function SelectText(props: SelectTextProps): JSX.Element;
|
|
33
|
+
|
|
34
|
+
export default SelectText;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
|
|
10
|
+
var _themes = require("../../../../style/themes");
|
|
11
|
+
|
|
12
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
const StyledSelectText = _styledComponents.default.span`
|
|
17
|
+
${({
|
|
18
|
+
disabled,
|
|
19
|
+
hasPlaceholder,
|
|
20
|
+
readOnly,
|
|
21
|
+
theme,
|
|
22
|
+
transparent
|
|
23
|
+
}) => (0, _styledComponents.css)`
|
|
24
|
+
align-items: center;
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
flex-grow: 1;
|
|
27
|
+
font-size: 14px;
|
|
28
|
+
height: auto;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
outline: none;
|
|
31
|
+
text-overflow: ellipsis;
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
width: 30px;
|
|
34
|
+
z-index: 1;
|
|
35
|
+
|
|
36
|
+
${transparent && (0, _styledComponents.css)`
|
|
37
|
+
font-weight: 900;
|
|
38
|
+
text-align: right;
|
|
39
|
+
flex-direction: row-reverse;
|
|
40
|
+
`}
|
|
41
|
+
|
|
42
|
+
${hasPlaceholder && (0, _styledComponents.css)`
|
|
43
|
+
color: ${theme.text.placeholder};
|
|
44
|
+
font-weight: normal;
|
|
45
|
+
user-select: none;
|
|
46
|
+
`}
|
|
47
|
+
|
|
48
|
+
${disabled && (0, _styledComponents.css)`
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
color: var(--colorsUtilityYin030);
|
|
51
|
+
text-shadow: none;
|
|
52
|
+
`}
|
|
53
|
+
|
|
54
|
+
${readOnly && (0, _styledComponents.css)`
|
|
55
|
+
cursor: default;
|
|
56
|
+
color: var(--colorsYin065);
|
|
57
|
+
text-shadow: none;
|
|
58
|
+
`}
|
|
59
|
+
`}
|
|
60
|
+
`;
|
|
61
|
+
StyledSelectText.defaultProps = {
|
|
62
|
+
theme: _themes.baseTheme
|
|
63
|
+
};
|
|
64
|
+
var _default = StyledSelectText;
|
|
65
|
+
exports.default = _default;
|
|
@@ -67,6 +67,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
67
67
|
flipEnabled = true,
|
|
68
68
|
...textboxProps
|
|
69
69
|
}, inputRef) => {
|
|
70
|
+
const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
|
|
70
71
|
const selectListId = (0, _react.useRef)((0, _guid.default)());
|
|
71
72
|
const labelId = (0, _react.useRef)((0, _guid.default)());
|
|
72
73
|
const containerRef = (0, _react.useRef)();
|
|
@@ -255,6 +256,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
255
256
|
}, [textValue, filterText, textboxRef, disabled, readOnly]);
|
|
256
257
|
const onSelectOption = (0, _react.useCallback)(optionData => {
|
|
257
258
|
const {
|
|
259
|
+
id: selectedOptionId,
|
|
258
260
|
text,
|
|
259
261
|
value: newValue,
|
|
260
262
|
selectionType
|
|
@@ -273,6 +275,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
273
275
|
|
|
274
276
|
setTextValue(text);
|
|
275
277
|
triggerChange(newValue);
|
|
278
|
+
setActiveDescendantId(selectedOptionId);
|
|
276
279
|
|
|
277
280
|
if (selectionType !== "navigationKey") {
|
|
278
281
|
setOpen(false);
|
|
@@ -434,8 +437,6 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
434
437
|
}, children);
|
|
435
438
|
|
|
436
439
|
return /*#__PURE__*/_react.default.createElement(_select.default, _extends({
|
|
437
|
-
"aria-expanded": isOpen,
|
|
438
|
-
"aria-haspopup": "listbox",
|
|
439
440
|
ref: containerRef,
|
|
440
441
|
hasTextCursor: true,
|
|
441
442
|
readOnly: readOnly,
|
|
@@ -444,8 +445,10 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
444
445
|
"data-role": dataRole,
|
|
445
446
|
"data-element": dataElement
|
|
446
447
|
}, (0, _utils.filterStyledSystemMarginProps)(textboxProps)), /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
|
|
447
|
-
|
|
448
|
-
|
|
448
|
+
activeDescendantId: activeDescendantId,
|
|
449
|
+
"aria-controls": isOpen ? selectListId.current : undefined,
|
|
450
|
+
isOpen: isOpen,
|
|
451
|
+
hasTextCursor: true,
|
|
449
452
|
labelId: labelId.current,
|
|
450
453
|
positionedChildren: disablePortal && isOpen && selectList
|
|
451
454
|
}, getTextboxProps())), !disablePortal && isOpen && selectList);
|
|
@@ -70,7 +70,9 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
70
70
|
flipEnabled = true,
|
|
71
71
|
...textboxProps
|
|
72
72
|
}, inputRef) => {
|
|
73
|
+
const [activeDescendantId, setActiveDescendantId] = (0, _react.useState)();
|
|
73
74
|
const selectListId = (0, _react.useRef)((0, _guid.default)());
|
|
75
|
+
const accessibilityLabelId = (0, _react.useRef)((0, _guid.default)());
|
|
74
76
|
const labelId = (0, _react.useRef)((0, _guid.default)());
|
|
75
77
|
const containerRef = (0, _react.useRef)();
|
|
76
78
|
const listboxRef = (0, _react.useRef)();
|
|
@@ -163,6 +165,13 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
163
165
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
164
166
|
|
|
165
167
|
}, [onKeyDown, readOnly, filterText, textValue, setOpen, removeSelectedValue]);
|
|
168
|
+
const accessibilityLabel = (0, _react.useMemo)(() => {
|
|
169
|
+
return selectedValue && selectedValue.length ? _react.default.Children.map(children, child => {
|
|
170
|
+
return selectedValue.includes(child.props.value) ? child.props.text : false;
|
|
171
|
+
}).filter(child => child).reduce((acc, item) => {
|
|
172
|
+
return acc ? `${acc}, ${item}` : item;
|
|
173
|
+
}, "") : null;
|
|
174
|
+
}, [children, selectedValue]);
|
|
166
175
|
const handleGlobalClick = (0, _react.useCallback)(event => {
|
|
167
176
|
isMouseDownReported.current = false;
|
|
168
177
|
|
|
@@ -340,11 +349,13 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
340
349
|
const onSelectOption = (0, _react.useCallback)(optionData => {
|
|
341
350
|
const {
|
|
342
351
|
value: newValue,
|
|
343
|
-
selectionType
|
|
352
|
+
selectionType,
|
|
353
|
+
id: selectedOptionId
|
|
344
354
|
} = optionData;
|
|
345
355
|
|
|
346
356
|
if (selectionType === "navigationKey") {
|
|
347
357
|
setHighlightedValue(newValue);
|
|
358
|
+
setActiveDescendantId(selectedOptionId);
|
|
348
359
|
return;
|
|
349
360
|
}
|
|
350
361
|
|
|
@@ -440,12 +451,11 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
440
451
|
multiColumn: multiColumn,
|
|
441
452
|
listPlacement: listPlacement,
|
|
442
453
|
flipEnabled: flipEnabled,
|
|
443
|
-
loaderDataRole: "multi-select-list-loader"
|
|
454
|
+
loaderDataRole: "multi-select-list-loader",
|
|
455
|
+
multiselectValues: selectedValue
|
|
444
456
|
}, children);
|
|
445
457
|
|
|
446
458
|
return /*#__PURE__*/_react.default.createElement(_multiSelect.StyledSelectMultiSelect, _extends({
|
|
447
|
-
"aria-expanded": isOpen,
|
|
448
|
-
"aria-haspopup": "listbox",
|
|
449
459
|
ref: containerRef,
|
|
450
460
|
disabled: disabled,
|
|
451
461
|
readOnly: readOnly,
|
|
@@ -454,9 +464,15 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
454
464
|
"data-component": dataComponent,
|
|
455
465
|
"data-role": dataRole,
|
|
456
466
|
"data-element": dataElement
|
|
457
|
-
}, (0, _utils.filterStyledSystemMarginProps)(textboxProps)), /*#__PURE__*/_react.default.createElement(
|
|
458
|
-
"
|
|
459
|
-
|
|
467
|
+
}, (0, _utils.filterStyledSystemMarginProps)(textboxProps)), /*#__PURE__*/_react.default.createElement(_multiSelect.StyledAccessibilityLabelContainer, {
|
|
468
|
+
"data-element": "accessibility-label",
|
|
469
|
+
id: accessibilityLabelId.current
|
|
470
|
+
}, accessibilityLabel), /*#__PURE__*/_react.default.createElement(_selectTextbox.default, _extends({
|
|
471
|
+
accessibilityLabelId: accessibilityLabelId.current,
|
|
472
|
+
activeDescendantId: activeDescendantId,
|
|
473
|
+
"aria-controls": isOpen ? selectListId.current : undefined,
|
|
474
|
+
hasTextCursor: true,
|
|
475
|
+
isOpen: isOpen,
|
|
460
476
|
labelId: labelId.current,
|
|
461
477
|
positionedChildren: disablePortal && isOpen && selectList
|
|
462
478
|
}, getTextboxProps())), !disablePortal && isOpen && selectList);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export const StyledSelectPillContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
2
|
export const StyledSelectMultiSelect: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export const StyledAccessibilityLabelContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.StyledSelectMultiSelect = exports.StyledSelectPillContainer = void 0;
|
|
6
|
+
exports.StyledAccessibilityLabelContainer = exports.StyledSelectMultiSelect = exports.StyledSelectPillContainer = void 0;
|
|
7
7
|
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
9
|
|
|
@@ -47,6 +47,10 @@ const StyledSelectMultiSelect = (0, _styledComponents.default)(_select.default)`
|
|
|
47
47
|
}
|
|
48
48
|
`;
|
|
49
49
|
exports.StyledSelectMultiSelect = StyledSelectMultiSelect;
|
|
50
|
+
const StyledAccessibilityLabelContainer = _styledComponents.default.div`
|
|
51
|
+
display: none;
|
|
52
|
+
`;
|
|
53
|
+
exports.StyledAccessibilityLabelContainer = StyledAccessibilityLabelContainer;
|
|
50
54
|
StyledSelectPillContainer.defaultProps = {
|
|
51
55
|
theme: _themes.baseTheme
|
|
52
56
|
};
|