@carbon/react 1.18.0 → 1.19.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/es/components/ComboBox/ComboBox.js +20 -5
- package/es/components/Dropdown/Dropdown.js +26 -4
- package/es/components/ListBox/next/ListBoxSelection.js +1 -0
- package/es/components/Notification/Notification.js +2 -1
- package/es/components/NumberInput/NumberInput.js +4 -2
- package/es/components/TextArea/TextArea.js +7 -1
- package/es/components/Toggle/Toggle.js +1 -1
- package/es/{components → es/components}/Checkbox/Checkbox.Skeleton.d.ts +0 -0
- package/es/{components → es/components}/Checkbox/Checkbox.d.ts +0 -0
- package/es/{components → es/components}/Checkbox/index.d.ts +0 -0
- package/es/{components → es/components}/Text/Text.d.ts +0 -0
- package/es/{components → es/components}/Text/TextDirection.d.ts +0 -0
- package/es/{components → es/components}/Text/createTextComponent.d.ts +0 -0
- package/es/{components → es/components}/Text/index.d.ts +0 -0
- package/es/{internal → es/internal}/usePrefix.d.ts +0 -0
- package/es/feature-flags.js +2 -1
- package/es/internal/useNoInteractiveChildren.js +4 -0
- package/lib/components/ComboBox/ComboBox.js +20 -5
- package/lib/components/Dropdown/Dropdown.js +26 -4
- package/lib/components/ListBox/next/ListBoxSelection.js +1 -0
- package/lib/components/Notification/Notification.js +2 -1
- package/lib/components/NumberInput/NumberInput.js +4 -2
- package/lib/components/TextArea/TextArea.js +7 -1
- package/lib/components/Toggle/Toggle.js +1 -1
- package/lib/feature-flags.js +2 -1
- package/lib/internal/useNoInteractiveChildren.js +4 -0
- package/lib/{components → lib/components}/Checkbox/Checkbox.Skeleton.d.ts +0 -0
- package/lib/{components → lib/components}/Checkbox/Checkbox.d.ts +0 -0
- package/lib/{components → lib/components}/Checkbox/index.d.ts +0 -0
- package/lib/{components → lib/components}/Text/Text.d.ts +0 -0
- package/lib/{components → lib/components}/Text/TextDirection.d.ts +0 -0
- package/lib/{components → lib/components}/Text/createTextComponent.d.ts +0 -0
- package/lib/{components → lib/components}/Text/index.d.ts +0 -0
- package/lib/{internal → lib/internal}/usePrefix.d.ts +0 -0
- package/package.json +10 -10
|
@@ -28,7 +28,7 @@ import { Text } from '../Text/Text.js';
|
|
|
28
28
|
import ListBox from '../ListBox/ListBox.js';
|
|
29
29
|
import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
|
|
30
30
|
|
|
31
|
-
var _excluded = ["ariaLabel", "className", "direction", "disabled", "downshiftProps", "helperText", "id", "initialSelectedItem", "invalid", "invalidText", "items", "itemToElement", "itemToString", "light", "onChange", "onInputChange", "onToggleClick", "placeholder", "selectedItem", "shouldFilterItem", "size", "titleText", "translateWithId", "type", "warn", "warnText", "onStateChange"];
|
|
31
|
+
var _excluded = ["ariaLabel", "className", "direction", "disabled", "downshiftProps", "helperText", "id", "initialSelectedItem", "invalid", "invalidText", "items", "itemToElement", "itemToString", "light", "onChange", "onInputChange", "onToggleClick", "placeholder", "readOnly", "selectedItem", "shouldFilterItem", "size", "titleText", "translateWithId", "type", "warn", "warnText", "onStateChange"];
|
|
32
32
|
|
|
33
33
|
var defaultItemToString = function defaultItemToString(item) {
|
|
34
34
|
if (typeof item === 'string') {
|
|
@@ -102,6 +102,7 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
102
102
|
onInputChange = props.onInputChange,
|
|
103
103
|
onToggleClick = props.onToggleClick,
|
|
104
104
|
placeholder = props.placeholder,
|
|
105
|
+
readOnly = props.readOnly,
|
|
105
106
|
selectedItem = props.selectedItem,
|
|
106
107
|
shouldFilterItem = props.shouldFilterItem,
|
|
107
108
|
size = props.size,
|
|
@@ -223,7 +224,7 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
223
224
|
|
|
224
225
|
var enabled = useFeatureFlag('enable-v11-release');
|
|
225
226
|
var showWarning = !invalid && warn;
|
|
226
|
-
var className = cx("".concat(prefix, "--combo-box"), [enabled ? null : containerClassName], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _defineProperty(_cx, "".concat(prefix, "--combo-box--warning"), showWarning), _cx));
|
|
227
|
+
var className = cx("".concat(prefix, "--combo-box"), [enabled ? null : containerClassName], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _defineProperty(_cx, "".concat(prefix, "--combo-box--warning"), showWarning), _defineProperty(_cx, "".concat(prefix, "--combo-box--readonly"), readOnly), _cx));
|
|
227
228
|
var titleClasses = cx("".concat(prefix, "--label"), _defineProperty({}, "".concat(prefix, "--label--disabled"), disabled));
|
|
228
229
|
var comboBoxHelperId = !helperText ? undefined : "combobox-helper-text-".concat(comboBoxInstanceId);
|
|
229
230
|
var helperClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
@@ -269,7 +270,7 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
269
270
|
});
|
|
270
271
|
var labelProps = getLabelProps();
|
|
271
272
|
var buttonProps = getToggleButtonProps({
|
|
272
|
-
disabled: disabled,
|
|
273
|
+
disabled: disabled || readOnly,
|
|
273
274
|
onClick: handleToggleClick(isOpen),
|
|
274
275
|
// When we moved the "root node" of Downshift to the <input> for
|
|
275
276
|
// ARIA 1.2 compliance, we unfortunately hit this branch for the
|
|
@@ -313,6 +314,14 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
313
314
|
}
|
|
314
315
|
};
|
|
315
316
|
|
|
317
|
+
var readOnlyEventHandlers = readOnly ? {
|
|
318
|
+
onKeyDown: function onKeyDown(evt) {
|
|
319
|
+
// This prevents the select from opening for the above keys
|
|
320
|
+
if (evt.key !== 'Tab') {
|
|
321
|
+
evt.preventDefault();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
} : {};
|
|
316
325
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
317
326
|
className: wrapperClasses
|
|
318
327
|
}, titleText && /*#__PURE__*/React__default.createElement(Text, _extends({
|
|
@@ -343,7 +352,8 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
343
352
|
"aria-haspopup": "listbox",
|
|
344
353
|
"aria-controls": inputProps['aria-controls'],
|
|
345
354
|
title: textInput === null || textInput === void 0 ? void 0 : (_textInput$current = textInput.current) === null || _textInput$current === void 0 ? void 0 : _textInput$current.value
|
|
346
|
-
}, inputProps, rest, {
|
|
355
|
+
}, inputProps, rest, readOnlyEventHandlers, {
|
|
356
|
+
readOnly: readOnly,
|
|
347
357
|
ref: mergeRefs(textInput, ref)
|
|
348
358
|
})), invalid && /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
349
359
|
className: "".concat(prefix, "--list-box__invalid-icon")
|
|
@@ -352,7 +362,7 @@ var ComboBox = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
352
362
|
}), inputValue && /*#__PURE__*/React__default.createElement(ListBoxSelection, {
|
|
353
363
|
clearSelection: clearSelection,
|
|
354
364
|
translateWithId: translateWithId,
|
|
355
|
-
disabled: disabled,
|
|
365
|
+
disabled: disabled || readOnly,
|
|
356
366
|
onClearSelection: handleSelectionClear
|
|
357
367
|
}), /*#__PURE__*/React__default.createElement(ListBoxTrigger, _extends({}, buttonProps, {
|
|
358
368
|
isOpen: isOpen,
|
|
@@ -493,6 +503,11 @@ ComboBox.propTypes = {
|
|
|
493
503
|
*/
|
|
494
504
|
placeholder: PropTypes.string,
|
|
495
505
|
|
|
506
|
+
/**
|
|
507
|
+
* Is the ComboBox readonly?
|
|
508
|
+
*/
|
|
509
|
+
readOnly: PropTypes.bool,
|
|
510
|
+
|
|
496
511
|
/**
|
|
497
512
|
* For full control of the selection
|
|
498
513
|
*/
|
|
@@ -21,7 +21,7 @@ import { FormContext } from '../FluidForm/FormContext.js';
|
|
|
21
21
|
import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
|
|
22
22
|
import ListBox from '../ListBox/ListBox.js';
|
|
23
23
|
|
|
24
|
-
var _excluded = ["className", "disabled", "direction", "items", "label", "ariaLabel", "itemToString", "itemToElement", "renderSelectedItem", "type", "size", "onChange", "id", "titleText", "hideLabel", "helperText", "translateWithId", "light", "invalid", "invalidText", "warn", "warnText", "initialSelectedItem", "selectedItem", "downshiftProps"];
|
|
24
|
+
var _excluded = ["className", "disabled", "direction", "items", "label", "ariaLabel", "itemToString", "itemToElement", "renderSelectedItem", "type", "size", "onChange", "id", "titleText", "hideLabel", "helperText", "translateWithId", "light", "invalid", "invalidText", "warn", "warnText", "initialSelectedItem", "selectedItem", "downshiftProps", "readOnly"];
|
|
25
25
|
|
|
26
26
|
var defaultItemToString = function defaultItemToString(item) {
|
|
27
27
|
if (typeof item === 'string') {
|
|
@@ -59,6 +59,7 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
|
|
|
59
59
|
initialSelectedItem = _ref.initialSelectedItem,
|
|
60
60
|
controlledSelectedItem = _ref.selectedItem,
|
|
61
61
|
downshiftProps = _ref.downshiftProps,
|
|
62
|
+
readOnly = _ref.readOnly,
|
|
62
63
|
other = _objectWithoutProperties(_ref, _excluded);
|
|
63
64
|
|
|
64
65
|
var prefix = usePrefix();
|
|
@@ -97,7 +98,7 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
|
|
|
97
98
|
isFocused = _useState2[0],
|
|
98
99
|
setIsFocused = _useState2[1];
|
|
99
100
|
|
|
100
|
-
var className = cx("".concat(prefix, "--dropdown"), [enabled ? null : containerClassName], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--dropdown--invalid"), invalid), _defineProperty(_cx, "".concat(prefix, "--dropdown--warning"), showWarning), _defineProperty(_cx, "".concat(prefix, "--dropdown--open"), isOpen), _defineProperty(_cx, "".concat(prefix, "--dropdown--inline"), inline), _defineProperty(_cx, "".concat(prefix, "--dropdown--disabled"), disabled), _defineProperty(_cx, "".concat(prefix, "--dropdown--light"), light), _defineProperty(_cx, "".concat(prefix, "--dropdown--").concat(size), size), _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx));
|
|
101
|
+
var className = cx("".concat(prefix, "--dropdown"), [enabled ? null : containerClassName], (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--dropdown--invalid"), invalid), _defineProperty(_cx, "".concat(prefix, "--dropdown--warning"), showWarning), _defineProperty(_cx, "".concat(prefix, "--dropdown--open"), isOpen), _defineProperty(_cx, "".concat(prefix, "--dropdown--inline"), inline), _defineProperty(_cx, "".concat(prefix, "--dropdown--disabled"), disabled), _defineProperty(_cx, "".concat(prefix, "--dropdown--light"), light), _defineProperty(_cx, "".concat(prefix, "--dropdown--readonly"), readOnly), _defineProperty(_cx, "".concat(prefix, "--dropdown--").concat(size), size), _defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx));
|
|
101
102
|
var titleClasses = cx("".concat(prefix, "--label"), (_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--label--disabled"), disabled), _defineProperty(_cx2, "".concat(prefix, "--visually-hidden"), hideLabel), _cx2));
|
|
102
103
|
var helperClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
103
104
|
var wrapperClasses = cx("".concat(prefix, "--dropdown__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline"), inline), _defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused && !isOpen), _cx4)); // needs to be Capitalized for react to render it correctly
|
|
@@ -127,6 +128,21 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
|
|
|
127
128
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
128
129
|
};
|
|
129
130
|
|
|
131
|
+
var readOnlyEventHandlers = readOnly ? {
|
|
132
|
+
onClick: function onClick(evt) {
|
|
133
|
+
// NOTE: does not prevent click
|
|
134
|
+
evt.preventDefault(); // focus on the element as per readonly input behavior
|
|
135
|
+
|
|
136
|
+
evt.target.focus();
|
|
137
|
+
},
|
|
138
|
+
onKeyDown: function onKeyDown(evt) {
|
|
139
|
+
var selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter']; // This prevents the select from opening for the above keys
|
|
140
|
+
|
|
141
|
+
if (selectAccessKeys.includes(evt.key)) {
|
|
142
|
+
evt.preventDefault();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} : {};
|
|
130
146
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
131
147
|
className: wrapperClasses
|
|
132
148
|
}, other), titleText && /*#__PURE__*/React__default.createElement("label", _extends({
|
|
@@ -152,9 +168,10 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function Dropdown(_ref, re
|
|
|
152
168
|
type: "button",
|
|
153
169
|
className: "".concat(prefix, "--list-box__field"),
|
|
154
170
|
disabled: disabled,
|
|
155
|
-
"aria-disabled": disabled
|
|
171
|
+
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
172
|
+
,
|
|
156
173
|
title: selectedItem ? itemToString(selectedItem) : label
|
|
157
|
-
}, toggleButtonProps, {
|
|
174
|
+
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
158
175
|
ref: mergeRefs(toggleButtonProps.ref, ref)
|
|
159
176
|
}), /*#__PURE__*/React__default.createElement("span", {
|
|
160
177
|
className: "".concat(prefix, "--list-box__label")
|
|
@@ -278,6 +295,11 @@ Dropdown.propTypes = {
|
|
|
278
295
|
*/
|
|
279
296
|
onChange: PropTypes.func,
|
|
280
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Whether or not the Dropdown is readonly
|
|
300
|
+
*/
|
|
301
|
+
readOnly: PropTypes.bool,
|
|
302
|
+
|
|
281
303
|
/**
|
|
282
304
|
* An optional callback to render the currently selected item as a react element instead of only
|
|
283
305
|
* as a string.
|
|
@@ -90,6 +90,7 @@ function ListBoxSelection(_ref) {
|
|
|
90
90
|
return /*#__PURE__*/React__default.createElement("button", _extends({}, rest, {
|
|
91
91
|
"aria-label": description,
|
|
92
92
|
className: className,
|
|
93
|
+
disabled: disabled,
|
|
93
94
|
onClick: onClick,
|
|
94
95
|
onKeyDown: onKeyDown,
|
|
95
96
|
tabIndex: disabled ? -1 : 0,
|
|
@@ -170,7 +170,8 @@ function NotificationIcon(_ref3) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
return /*#__PURE__*/React__default.createElement(IconForKind, {
|
|
173
|
-
className: "".concat(prefix, "--").concat(notificationType, "-notification__icon")
|
|
173
|
+
className: "".concat(prefix, "--").concat(notificationType, "-notification__icon"),
|
|
174
|
+
size: 20
|
|
174
175
|
}, /*#__PURE__*/React__default.createElement("title", null, iconDescription));
|
|
175
176
|
}
|
|
176
177
|
|
|
@@ -51,8 +51,10 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
51
51
|
_props$invalidText = props.invalidText,
|
|
52
52
|
invalidText = _props$invalidText === void 0 ? enabled ? undefined : 'Provide invalidText' : _props$invalidText,
|
|
53
53
|
light = props.light,
|
|
54
|
-
max = props.max,
|
|
55
|
-
|
|
54
|
+
_props$max = props.max,
|
|
55
|
+
max = _props$max === void 0 ? 100 : _props$max,
|
|
56
|
+
_props$min = props.min,
|
|
57
|
+
min = _props$min === void 0 ? 0 : _props$min,
|
|
56
58
|
onChange = props.onChange,
|
|
57
59
|
_onClick = props.onClick,
|
|
58
60
|
onKeyUp = props.onKeyUp,
|
|
@@ -103,6 +103,7 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, re
|
|
|
103
103
|
"aria-invalid": invalid || null,
|
|
104
104
|
"aria-describedby": invalid ? errorId : null,
|
|
105
105
|
disabled: other.disabled,
|
|
106
|
+
readOnly: other.readOnly,
|
|
106
107
|
style: other.cols ? {} : {
|
|
107
108
|
width: "100%"
|
|
108
109
|
}
|
|
@@ -112,7 +113,7 @@ var TextArea = /*#__PURE__*/React__default.forwardRef(function TextArea(_ref, re
|
|
|
112
113
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
113
114
|
className: "".concat(prefix, "--text-area__label-wrapper")
|
|
114
115
|
}, label, counter), /*#__PURE__*/React__default.createElement("div", {
|
|
115
|
-
className: "".concat(prefix, "--text-area__wrapper"),
|
|
116
|
+
className: cx("".concat(prefix, "--text-area__wrapper"), _defineProperty({}, "".concat(prefix, "--text-area__wrapper--readonly"), other.readOnly)),
|
|
116
117
|
"data-invalid": invalid || null
|
|
117
118
|
}, invalid && !isFluid && /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
118
119
|
className: "".concat(prefix, "--text-area__invalid-icon")
|
|
@@ -210,6 +211,11 @@ TextArea.propTypes = {
|
|
|
210
211
|
*/
|
|
211
212
|
placeholder: PropTypes.string,
|
|
212
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Whether the textarea should be read-only
|
|
216
|
+
*/
|
|
217
|
+
readOnly: PropTypes.bool,
|
|
218
|
+
|
|
213
219
|
/**
|
|
214
220
|
* Specify the rows attribute for the `<textarea>`
|
|
215
221
|
*/
|
|
@@ -61,7 +61,7 @@ function Toggle(_ref) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
var isSm = size === 'sm';
|
|
64
|
-
var sideLabel = checked ? labelB : labelA;
|
|
64
|
+
var sideLabel = hideLabel ? labelText : checked ? labelB : labelA;
|
|
65
65
|
var wrapperClasses = cx("".concat(prefix, "--toggle"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--toggle--disabled"), disabled), _defineProperty(_classNames, "".concat(prefix, "--toggle--readonly"), readOnly), _classNames), className);
|
|
66
66
|
var labelTextClasses = cx("".concat(prefix, "--toggle__label-text"), _defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
|
|
67
67
|
var appearanceClasses = cx("".concat(prefix, "--toggle__appearance"), _defineProperty({}, "".concat(prefix, "--toggle__appearance--sm"), isSm));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/es/feature-flags.js
CHANGED
|
@@ -39,7 +39,7 @@ var Downshift__default = /*#__PURE__*/_interopDefaultLegacy(Downshift);
|
|
|
39
39
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
40
40
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
41
41
|
|
|
42
|
-
var _excluded = ["ariaLabel", "className", "direction", "disabled", "downshiftProps", "helperText", "id", "initialSelectedItem", "invalid", "invalidText", "items", "itemToElement", "itemToString", "light", "onChange", "onInputChange", "onToggleClick", "placeholder", "selectedItem", "shouldFilterItem", "size", "titleText", "translateWithId", "type", "warn", "warnText", "onStateChange"];
|
|
42
|
+
var _excluded = ["ariaLabel", "className", "direction", "disabled", "downshiftProps", "helperText", "id", "initialSelectedItem", "invalid", "invalidText", "items", "itemToElement", "itemToString", "light", "onChange", "onInputChange", "onToggleClick", "placeholder", "readOnly", "selectedItem", "shouldFilterItem", "size", "titleText", "translateWithId", "type", "warn", "warnText", "onStateChange"];
|
|
43
43
|
|
|
44
44
|
var defaultItemToString = function defaultItemToString(item) {
|
|
45
45
|
if (typeof item === 'string') {
|
|
@@ -113,6 +113,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
113
113
|
onInputChange = props.onInputChange,
|
|
114
114
|
onToggleClick = props.onToggleClick,
|
|
115
115
|
placeholder = props.placeholder,
|
|
116
|
+
readOnly = props.readOnly,
|
|
116
117
|
selectedItem = props.selectedItem,
|
|
117
118
|
shouldFilterItem = props.shouldFilterItem,
|
|
118
119
|
size = props.size,
|
|
@@ -234,7 +235,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
234
235
|
|
|
235
236
|
var enabled = index.useFeatureFlag('enable-v11-release');
|
|
236
237
|
var showWarning = !invalid && warn;
|
|
237
|
-
var className = cx__default["default"]("".concat(prefix, "--combo-box"), [enabled ? null : containerClassName], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--combo-box--warning"), showWarning), _cx));
|
|
238
|
+
var className = cx__default["default"]("".concat(prefix, "--combo-box"), [enabled ? null : containerClassName], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--combo-box--warning"), showWarning), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--combo-box--readonly"), readOnly), _cx));
|
|
238
239
|
var titleClasses = cx__default["default"]("".concat(prefix, "--label"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--label--disabled"), disabled));
|
|
239
240
|
var comboBoxHelperId = !helperText ? undefined : "combobox-helper-text-".concat(comboBoxInstanceId);
|
|
240
241
|
var helperClasses = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
@@ -280,7 +281,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
280
281
|
});
|
|
281
282
|
var labelProps = getLabelProps();
|
|
282
283
|
var buttonProps = getToggleButtonProps({
|
|
283
|
-
disabled: disabled,
|
|
284
|
+
disabled: disabled || readOnly,
|
|
284
285
|
onClick: handleToggleClick(isOpen),
|
|
285
286
|
// When we moved the "root node" of Downshift to the <input> for
|
|
286
287
|
// ARIA 1.2 compliance, we unfortunately hit this branch for the
|
|
@@ -324,6 +325,14 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
324
325
|
}
|
|
325
326
|
};
|
|
326
327
|
|
|
328
|
+
var readOnlyEventHandlers = readOnly ? {
|
|
329
|
+
onKeyDown: function onKeyDown(evt) {
|
|
330
|
+
// This prevents the select from opening for the above keys
|
|
331
|
+
if (evt.key !== 'Tab') {
|
|
332
|
+
evt.preventDefault();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
} : {};
|
|
327
336
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
328
337
|
className: wrapperClasses
|
|
329
338
|
}, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -354,7 +363,8 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
354
363
|
"aria-haspopup": "listbox",
|
|
355
364
|
"aria-controls": inputProps['aria-controls'],
|
|
356
365
|
title: textInput === null || textInput === void 0 ? void 0 : (_textInput$current = textInput.current) === null || _textInput$current === void 0 ? void 0 : _textInput$current.value
|
|
357
|
-
}, inputProps, rest, {
|
|
366
|
+
}, inputProps, rest, readOnlyEventHandlers, {
|
|
367
|
+
readOnly: readOnly,
|
|
358
368
|
ref: mergeRefs["default"](textInput, ref)
|
|
359
369
|
})), invalid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
360
370
|
className: "".concat(prefix, "--list-box__invalid-icon")
|
|
@@ -363,7 +373,7 @@ var ComboBox = /*#__PURE__*/React__default["default"].forwardRef(function (props
|
|
|
363
373
|
}), inputValue && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
|
|
364
374
|
clearSelection: clearSelection,
|
|
365
375
|
translateWithId: translateWithId,
|
|
366
|
-
disabled: disabled,
|
|
376
|
+
disabled: disabled || readOnly,
|
|
367
377
|
onClearSelection: handleSelectionClear
|
|
368
378
|
}), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
|
|
369
379
|
isOpen: isOpen,
|
|
@@ -504,6 +514,11 @@ ComboBox.propTypes = {
|
|
|
504
514
|
*/
|
|
505
515
|
placeholder: PropTypes__default["default"].string,
|
|
506
516
|
|
|
517
|
+
/**
|
|
518
|
+
* Is the ComboBox readonly?
|
|
519
|
+
*/
|
|
520
|
+
readOnly: PropTypes__default["default"].bool,
|
|
521
|
+
|
|
507
522
|
/**
|
|
508
523
|
* For full control of the selection
|
|
509
524
|
*/
|
|
@@ -31,7 +31,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
31
31
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
32
32
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
33
33
|
|
|
34
|
-
var _excluded = ["className", "disabled", "direction", "items", "label", "ariaLabel", "itemToString", "itemToElement", "renderSelectedItem", "type", "size", "onChange", "id", "titleText", "hideLabel", "helperText", "translateWithId", "light", "invalid", "invalidText", "warn", "warnText", "initialSelectedItem", "selectedItem", "downshiftProps"];
|
|
34
|
+
var _excluded = ["className", "disabled", "direction", "items", "label", "ariaLabel", "itemToString", "itemToElement", "renderSelectedItem", "type", "size", "onChange", "id", "titleText", "hideLabel", "helperText", "translateWithId", "light", "invalid", "invalidText", "warn", "warnText", "initialSelectedItem", "selectedItem", "downshiftProps", "readOnly"];
|
|
35
35
|
|
|
36
36
|
var defaultItemToString = function defaultItemToString(item) {
|
|
37
37
|
if (typeof item === 'string') {
|
|
@@ -69,6 +69,7 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
|
|
|
69
69
|
initialSelectedItem = _ref.initialSelectedItem,
|
|
70
70
|
controlledSelectedItem = _ref.selectedItem,
|
|
71
71
|
downshiftProps = _ref.downshiftProps,
|
|
72
|
+
readOnly = _ref.readOnly,
|
|
72
73
|
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
73
74
|
|
|
74
75
|
var prefix = usePrefix.usePrefix();
|
|
@@ -107,7 +108,7 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
|
|
|
107
108
|
isFocused = _useState2[0],
|
|
108
109
|
setIsFocused = _useState2[1];
|
|
109
110
|
|
|
110
|
-
var className = cx__default["default"]("".concat(prefix, "--dropdown"), [enabled ? null : containerClassName], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--warning"), showWarning), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--open"), isOpen), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--light"), light), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--").concat(size), size), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx));
|
|
111
|
+
var className = cx__default["default"]("".concat(prefix, "--dropdown"), [enabled ? null : containerClassName], (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--warning"), showWarning), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--open"), isOpen), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--light"), light), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--readonly"), readOnly), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--dropdown--").concat(size), size), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--list-box--up"), direction === 'top'), _cx));
|
|
111
112
|
var titleClasses = cx__default["default"]("".concat(prefix, "--label"), (_cx2 = {}, _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--label--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_cx2, "".concat(prefix, "--visually-hidden"), hideLabel), _cx2));
|
|
112
113
|
var helperClasses = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
113
114
|
var wrapperClasses = cx__default["default"]("".concat(prefix, "--dropdown__wrapper"), "".concat(prefix, "--list-box__wrapper"), [enabled ? containerClassName : null], (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--dropdown__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--inline--invalid"), inline && invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--invalid"), isFluid && invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--list-box__wrapper--fluid--focus"), isFluid && isFocused && !isOpen), _cx4)); // needs to be Capitalized for react to render it correctly
|
|
@@ -137,6 +138,21 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
|
|
|
137
138
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
138
139
|
};
|
|
139
140
|
|
|
141
|
+
var readOnlyEventHandlers = readOnly ? {
|
|
142
|
+
onClick: function onClick(evt) {
|
|
143
|
+
// NOTE: does not prevent click
|
|
144
|
+
evt.preventDefault(); // focus on the element as per readonly input behavior
|
|
145
|
+
|
|
146
|
+
evt.target.focus();
|
|
147
|
+
},
|
|
148
|
+
onKeyDown: function onKeyDown(evt) {
|
|
149
|
+
var selectAccessKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter']; // This prevents the select from opening for the above keys
|
|
150
|
+
|
|
151
|
+
if (selectAccessKeys.includes(evt.key)) {
|
|
152
|
+
evt.preventDefault();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} : {};
|
|
140
156
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
141
157
|
className: wrapperClasses
|
|
142
158
|
}, other), titleText && /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
@@ -162,9 +178,10 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Dropdo
|
|
|
162
178
|
type: "button",
|
|
163
179
|
className: "".concat(prefix, "--list-box__field"),
|
|
164
180
|
disabled: disabled,
|
|
165
|
-
"aria-disabled": disabled
|
|
181
|
+
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
182
|
+
,
|
|
166
183
|
title: selectedItem ? itemToString(selectedItem) : label
|
|
167
|
-
}, toggleButtonProps, {
|
|
184
|
+
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
168
185
|
ref: mergeRefs["default"](toggleButtonProps.ref, ref)
|
|
169
186
|
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
170
187
|
className: "".concat(prefix, "--list-box__label")
|
|
@@ -288,6 +305,11 @@ Dropdown.propTypes = {
|
|
|
288
305
|
*/
|
|
289
306
|
onChange: PropTypes__default["default"].func,
|
|
290
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Whether or not the Dropdown is readonly
|
|
310
|
+
*/
|
|
311
|
+
readOnly: PropTypes__default["default"].bool,
|
|
312
|
+
|
|
291
313
|
/**
|
|
292
314
|
* An optional callback to render the currently selected item as a react element instead of only
|
|
293
315
|
* as a string.
|
|
@@ -100,6 +100,7 @@ function ListBoxSelection(_ref) {
|
|
|
100
100
|
return /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
101
101
|
"aria-label": description,
|
|
102
102
|
className: className,
|
|
103
|
+
disabled: disabled,
|
|
103
104
|
onClick: onClick,
|
|
104
105
|
onKeyDown: onKeyDown,
|
|
105
106
|
tabIndex: disabled ? -1 : 0,
|
|
@@ -180,7 +180,8 @@ function NotificationIcon(_ref3) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
return /*#__PURE__*/React__default["default"].createElement(IconForKind, {
|
|
183
|
-
className: "".concat(prefix, "--").concat(notificationType, "-notification__icon")
|
|
183
|
+
className: "".concat(prefix, "--").concat(notificationType, "-notification__icon"),
|
|
184
|
+
size: 20
|
|
184
185
|
}, /*#__PURE__*/React__default["default"].createElement("title", null, iconDescription));
|
|
185
186
|
}
|
|
186
187
|
|
|
@@ -61,8 +61,10 @@ var NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function Num
|
|
|
61
61
|
_props$invalidText = props.invalidText,
|
|
62
62
|
invalidText = _props$invalidText === void 0 ? enabled ? undefined : 'Provide invalidText' : _props$invalidText,
|
|
63
63
|
light = props.light,
|
|
64
|
-
max = props.max,
|
|
65
|
-
|
|
64
|
+
_props$max = props.max,
|
|
65
|
+
max = _props$max === void 0 ? 100 : _props$max,
|
|
66
|
+
_props$min = props.min,
|
|
67
|
+
min = _props$min === void 0 ? 0 : _props$min,
|
|
66
68
|
onChange = props.onChange,
|
|
67
69
|
_onClick = props.onClick,
|
|
68
70
|
onKeyUp = props.onKeyUp,
|
|
@@ -113,6 +113,7 @@ var TextArea = /*#__PURE__*/React__default["default"].forwardRef(function TextAr
|
|
|
113
113
|
"aria-invalid": invalid || null,
|
|
114
114
|
"aria-describedby": invalid ? errorId : null,
|
|
115
115
|
disabled: other.disabled,
|
|
116
|
+
readOnly: other.readOnly,
|
|
116
117
|
style: other.cols ? {} : {
|
|
117
118
|
width: "100%"
|
|
118
119
|
}
|
|
@@ -122,7 +123,7 @@ var TextArea = /*#__PURE__*/React__default["default"].forwardRef(function TextAr
|
|
|
122
123
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
123
124
|
className: "".concat(prefix, "--text-area__label-wrapper")
|
|
124
125
|
}, label, counter), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
125
|
-
className: "".concat(prefix, "--text-area__wrapper"),
|
|
126
|
+
className: cx__default["default"]("".concat(prefix, "--text-area__wrapper"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--text-area__wrapper--readonly"), other.readOnly)),
|
|
126
127
|
"data-invalid": invalid || null
|
|
127
128
|
}, invalid && !isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
128
129
|
className: "".concat(prefix, "--text-area__invalid-icon")
|
|
@@ -220,6 +221,11 @@ TextArea.propTypes = {
|
|
|
220
221
|
*/
|
|
221
222
|
placeholder: PropTypes__default["default"].string,
|
|
222
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Whether the textarea should be read-only
|
|
226
|
+
*/
|
|
227
|
+
readOnly: PropTypes__default["default"].bool,
|
|
228
|
+
|
|
223
229
|
/**
|
|
224
230
|
* Specify the rows attribute for the `<textarea>`
|
|
225
231
|
*/
|
|
@@ -71,7 +71,7 @@ function Toggle(_ref) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
var isSm = size === 'sm';
|
|
74
|
-
var sideLabel = checked ? labelB : labelA;
|
|
74
|
+
var sideLabel = hideLabel ? labelText : checked ? labelB : labelA;
|
|
75
75
|
var wrapperClasses = cx__default["default"]("".concat(prefix, "--toggle"), (_classNames = {}, _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--toggle--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--toggle--readonly"), readOnly), _classNames), className);
|
|
76
76
|
var labelTextClasses = cx__default["default"]("".concat(prefix, "--toggle__label-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--visually-hidden"), hideLabel));
|
|
77
77
|
var appearanceClasses = cx__default["default"]("".concat(prefix, "--toggle__appearance"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--toggle__appearance--sm"), isSm));
|
package/lib/feature-flags.js
CHANGED
|
@@ -32,5 +32,6 @@ var FeatureFlags__namespace = /*#__PURE__*/_interopNamespace(FeatureFlags);
|
|
|
32
32
|
FeatureFlags__namespace.merge({
|
|
33
33
|
'enable-css-custom-properties': true,
|
|
34
34
|
'enable-css-grid': true,
|
|
35
|
-
'enable-v11-release': true
|
|
35
|
+
'enable-v11-release': true,
|
|
36
|
+
'enable-experimental-tile-contrast': false
|
|
36
37
|
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.19.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@babel/runtime": "^7.18.3",
|
|
46
|
-
"@carbon/feature-flags": "^0.
|
|
47
|
-
"@carbon/icons-react": "^11.
|
|
48
|
-
"@carbon/layout": "^11.
|
|
49
|
-
"@carbon/styles": "^1.
|
|
46
|
+
"@carbon/feature-flags": "^0.11.0",
|
|
47
|
+
"@carbon/icons-react": "^11.13.0",
|
|
48
|
+
"@carbon/layout": "^11.9.0",
|
|
49
|
+
"@carbon/styles": "^1.19.0",
|
|
50
50
|
"@carbon/telemetry": "0.1.0",
|
|
51
51
|
"classnames": "2.3.2",
|
|
52
52
|
"copy-to-clipboard": "^3.3.1",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
"@babel/preset-env": "^7.18.2",
|
|
74
74
|
"@babel/preset-react": "^7.17.12",
|
|
75
75
|
"@carbon/test-utils": "^10.26.0",
|
|
76
|
-
"@carbon/themes": "^11.
|
|
77
|
-
"@rollup/plugin-babel": "^
|
|
76
|
+
"@carbon/themes": "^11.14.0",
|
|
77
|
+
"@rollup/plugin-babel": "^6.0.0",
|
|
78
78
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
79
79
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
80
|
-
"@rollup/plugin-typescript": "^
|
|
80
|
+
"@rollup/plugin-typescript": "^10.0.0",
|
|
81
81
|
"@storybook/addon-a11y": "^6.5.6",
|
|
82
82
|
"@storybook/addon-actions": "^6.5.6",
|
|
83
83
|
"@storybook/addon-docs": "^6.5.6",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
|
93
93
|
"@typescript-eslint/parser": "^5.38.1",
|
|
94
94
|
"autoprefixer": "^10.4.0",
|
|
95
|
-
"babel-loader": "^
|
|
95
|
+
"babel-loader": "^9.0.0",
|
|
96
96
|
"babel-plugin-dev-expression": "^0.2.3",
|
|
97
97
|
"babel-preset-carbon": "^0.3.0",
|
|
98
98
|
"browserify-zlib": "^0.2.0",
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"**/*.scss",
|
|
136
136
|
"**/*.css"
|
|
137
137
|
],
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "8206000d08eba6a443d7846b692a3543a47a6e66"
|
|
139
139
|
}
|