@carbon/react 1.26.0 → 1.27.0-rc.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/Checkbox/Checkbox.d.ts +20 -0
- package/es/components/Checkbox/Checkbox.js +58 -4
- package/es/components/CheckboxGroup/CheckboxGroup.js +119 -0
- package/es/components/ComboBox/ComboBox.js +11 -2
- package/es/components/ContentSwitcher/ContentSwitcher.js +9 -4
- package/es/components/Copy/Copy.js +1 -1
- package/es/components/DataTable/DataTable.js +44 -2
- package/es/components/DataTable/Table.js +1 -2
- package/es/components/DataTable/TableCell.js +1 -2
- package/es/components/DataTable/TableExpandRow.js +1 -2
- package/es/components/DataTable/TableExpandedRow.js +1 -2
- package/es/components/DataTable/TableHead.js +1 -2
- package/es/components/DataTable/TableHeader.js +1 -2
- package/es/components/DataTable/TableRow.js +1 -2
- package/es/components/DataTable/TableSelectAll.js +1 -2
- package/es/components/DataTable/TableSelectRow.js +1 -2
- package/es/components/DataTable/TableToolbar.js +2 -3
- package/es/components/DataTable/TableToolbarAction.js +1 -2
- package/es/components/DataTable/TableToolbarContent.js +1 -2
- package/es/components/DataTable/TableToolbarMenu.js +1 -2
- package/es/components/DataTable/index.d.ts +29 -0
- package/es/components/DataTable/index.js +70 -0
- package/es/components/DatePicker/DatePicker.js +25 -3
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +15 -1
- package/es/components/DatePickerInput/DatePickerInput.js +7 -2
- package/es/components/Dropdown/Dropdown.js +16 -4
- package/es/components/ErrorBoundary/ErrorBoundary.js +1 -1
- package/es/components/FileUploader/FileUploader.js +1 -1
- package/es/components/FluidDatePicker/FluidDatePicker.js +9 -2
- package/es/components/IconButton/index.js +19 -5
- package/es/components/Modal/Modal.js +4 -2
- package/es/components/ModalWrapper/ModalWrapper.js +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +9 -1
- package/es/components/MultiSelect/MultiSelect.js +2 -1
- package/es/components/NumberInput/NumberInput.js +10 -2
- package/es/components/ProgressBar/ProgressBar.js +3 -0
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +2 -1
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/Select/Select.js +10 -1
- package/es/components/StructuredList/StructuredList.js +2 -1
- package/es/components/Switch/IconSwitch.js +174 -0
- package/es/components/TextArea/TextArea.js +16 -1
- package/es/components/TextInput/ControlledPasswordInput.js +11 -2
- package/es/components/TextInput/PasswordInput.js +4 -1
- package/es/components/TextInput/index.js +0 -3
- package/es/components/TextInput/util.js +15 -2
- package/es/components/Tile/Tile.js +6 -4
- package/es/components/Toggle/Toggle.Skeleton.d.ts +58 -0
- package/es/components/Toggle/Toggle.Skeleton.js +1 -1
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +1 -1
- package/es/components/Tooltip/Tooltip.d.ts +1 -1
- package/es/components/UIShell/HeaderMenu.js +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +4 -1
- package/lib/components/Checkbox/Checkbox.d.ts +20 -0
- package/lib/components/Checkbox/Checkbox.js +58 -4
- package/lib/components/CheckboxGroup/CheckboxGroup.js +129 -0
- package/lib/components/ComboBox/ComboBox.js +10 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.js +9 -4
- package/lib/components/Copy/Copy.js +1 -1
- package/lib/components/DataTable/DataTable.js +48 -6
- package/lib/components/DataTable/Table.js +1 -2
- package/lib/components/DataTable/TableCell.js +1 -2
- package/lib/components/DataTable/TableExpandRow.js +1 -2
- package/lib/components/DataTable/TableExpandedRow.js +1 -2
- package/lib/components/DataTable/TableHead.js +1 -2
- package/lib/components/DataTable/TableHeader.js +1 -2
- package/lib/components/DataTable/TableRow.js +1 -2
- package/lib/components/DataTable/TableSelectAll.js +1 -2
- package/lib/components/DataTable/TableSelectRow.js +1 -2
- package/lib/components/DataTable/TableToolbar.js +1 -2
- package/lib/components/DataTable/TableToolbarAction.js +1 -2
- package/lib/components/DataTable/TableToolbarContent.js +1 -2
- package/lib/components/DataTable/TableToolbarMenu.js +1 -2
- package/lib/components/DataTable/index.d.ts +29 -0
- package/lib/components/DataTable/index.js +76 -0
- package/lib/components/DatePicker/DatePicker.js +25 -3
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +15 -1
- package/lib/components/DatePickerInput/DatePickerInput.js +7 -2
- package/lib/components/Dropdown/Dropdown.js +15 -3
- package/lib/components/FluidDatePicker/FluidDatePicker.js +9 -2
- package/lib/components/IconButton/index.js +19 -5
- package/lib/components/Modal/Modal.js +4 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.js +8 -0
- package/lib/components/MultiSelect/MultiSelect.js +2 -1
- package/lib/components/NumberInput/NumberInput.js +10 -2
- package/lib/components/ProgressBar/ProgressBar.js +3 -0
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +2 -1
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Select/Select.js +9 -0
- package/lib/components/StructuredList/StructuredList.js +2 -1
- package/lib/components/Switch/IconSwitch.js +184 -0
- package/lib/components/TextArea/TextArea.js +16 -1
- package/lib/components/TextInput/ControlledPasswordInput.js +10 -1
- package/lib/components/TextInput/PasswordInput.js +4 -1
- package/lib/components/TextInput/index.js +0 -3
- package/lib/components/TextInput/util.js +15 -2
- package/lib/components/Tile/Tile.js +6 -4
- package/lib/components/Toggle/Toggle.Skeleton.d.ts +58 -0
- package/lib/components/Toggle/Toggle.Skeleton.js +1 -1
- package/lib/components/Tooltip/Tooltip.d.ts +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +6 -1
- package/package.json +12 -12
|
@@ -203,9 +203,24 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
203
203
|
}
|
|
204
204
|
}, []);
|
|
205
205
|
var endInputField = useRef(null);
|
|
206
|
+
var lastStartValue = useRef(''); // fix datepicker deleting the selectedDate when the calendar closes
|
|
207
|
+
|
|
208
|
+
var onCalendarClose = function onCalendarClose(selectedDates, dateStr) {
|
|
209
|
+
setTimeout(function () {
|
|
210
|
+
if (lastStartValue.current && selectedDates[0] && !startInputField.current.value) {
|
|
211
|
+
startInputField.current.value = lastStartValue.current;
|
|
212
|
+
calendarRef.current.setDate([startInputField.current.value, endInputField.current.value], true, calendarRef.current.config.dateFormat);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (onClose) {
|
|
216
|
+
onClose(calendarRef.current.selectedDates, dateStr, calendarRef.current);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
|
|
206
221
|
var calendarRef = useRef(null);
|
|
207
222
|
var savedOnChange = useSavedCallback(onChange);
|
|
208
|
-
var savedOnClose = useSavedCallback(onClose);
|
|
223
|
+
var savedOnClose = useSavedCallback(datePickerType === 'range' ? onCalendarClose : onClose);
|
|
209
224
|
var savedOnOpen = useSavedCallback(onOpen);
|
|
210
225
|
var datePickerClasses = cx("".concat(prefix, "--date-picker"), (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--date-picker--short"), short), _defineProperty(_cx, "".concat(prefix, "--date-picker--light"), light), _defineProperty(_cx, "".concat(prefix, "--date-picker--simple"), datePickerType === 'simple'), _defineProperty(_cx, "".concat(prefix, "--date-picker--single"), datePickerType === 'single'), _defineProperty(_cx, "".concat(prefix, "--date-picker--range"), datePickerType === 'range'), _defineProperty(_cx, "".concat(prefix, "--date-picker--nolabel"), datePickerType === 'range' && isLabelTextEmpty(children)), _cx));
|
|
211
226
|
var wrapperClasses = cx("".concat(prefix, "--form-item"), _defineProperty({}, className, className));
|
|
@@ -307,7 +322,8 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
307
322
|
classFlatpickrCurrentMonth: 'cur-month'
|
|
308
323
|
}), carbonFlatpickrFixEventsPlugin({
|
|
309
324
|
inputFrom: startInputField.current,
|
|
310
|
-
inputTo: endInputField.current
|
|
325
|
+
inputTo: endInputField.current,
|
|
326
|
+
lastStartValue: lastStartValue
|
|
311
327
|
})]), _defineProperty(_flatpickr, "clickOpens", !readOnly), _defineProperty(_flatpickr, "noCalendar", readOnly), _defineProperty(_flatpickr, "nextArrow", rightArrowHTML), _defineProperty(_flatpickr, "prevArrow", leftArrowHTML), _defineProperty(_flatpickr, "onChange", function onChange() {
|
|
312
328
|
if (savedOnChange && !readOnly) {
|
|
313
329
|
savedOnChange.apply(void 0, arguments);
|
|
@@ -333,11 +349,17 @@ var DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_ref
|
|
|
333
349
|
}
|
|
334
350
|
}
|
|
335
351
|
|
|
336
|
-
function handleOnChange() {
|
|
352
|
+
function handleOnChange(event) {
|
|
337
353
|
if (datePickerType == 'single') {
|
|
338
354
|
calendar.calendarContainer.classList.remove('open');
|
|
339
355
|
}
|
|
340
356
|
|
|
357
|
+
var target = event.target;
|
|
358
|
+
|
|
359
|
+
if (target === start) {
|
|
360
|
+
lastStartValue.current = start.value;
|
|
361
|
+
}
|
|
362
|
+
|
|
341
363
|
if (start.value !== '') {
|
|
342
364
|
return;
|
|
343
365
|
}
|
|
@@ -51,7 +51,8 @@ var carbonFlatpickrFixEventsPlugin = (function (config) {
|
|
|
51
51
|
|
|
52
52
|
var handleBlur = function handleBlur(event) {
|
|
53
53
|
var inputFrom = config.inputFrom,
|
|
54
|
-
inputTo = config.inputTo
|
|
54
|
+
inputTo = config.inputTo,
|
|
55
|
+
lastStartValue = config.lastStartValue;
|
|
55
56
|
var target = event.target; // Only fall into this logic if the event is on the `to` input and there is a
|
|
56
57
|
// `to` date selected
|
|
57
58
|
|
|
@@ -76,6 +77,19 @@ var carbonFlatpickrFixEventsPlugin = (function (config) {
|
|
|
76
77
|
if (currentEndDate.toString() !== 'Invalid Date') {
|
|
77
78
|
fp.setDate([inputFrom.value, inputTo.value], true, fp.config.dateFormat);
|
|
78
79
|
}
|
|
80
|
+
} // overriding the flatpickr bug where the startDate gets deleted on blur
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if (inputTo === target && !inputFrom.value && lastStartValue.current) {
|
|
84
|
+
var currentStartDate = new Date(lastStartValue.current);
|
|
85
|
+
|
|
86
|
+
if (currentStartDate.toString() !== 'Invalid Date') {
|
|
87
|
+
inputFrom.value = lastStartValue.current;
|
|
88
|
+
|
|
89
|
+
if (inputTo.value) {
|
|
90
|
+
fp.setDate([inputFrom.value, inputTo.value], true, fp.config.dateFormat);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
79
93
|
}
|
|
80
94
|
};
|
|
81
95
|
/**
|
|
@@ -13,8 +13,10 @@ import React__default, { useContext } from 'react';
|
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
14
|
import '../FluidForm/FluidForm.js';
|
|
15
15
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
16
|
+
import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
|
|
16
17
|
|
|
17
18
|
var _excluded = ["datePickerType", "disabled", "helperText", "hideLabel", "id", "invalid", "invalidText", "labelText", "onClick", "onChange", "pattern", "placeholder", "size", "type", "warn", "warnText"];
|
|
19
|
+
var getInstanceId = setupGetInstanceId();
|
|
18
20
|
var DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePickerInput(props, ref) {
|
|
19
21
|
var _cx, _cx2, _cx4, _cx5;
|
|
20
22
|
|
|
@@ -48,6 +50,7 @@ var DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePicker
|
|
|
48
50
|
var _useContext = useContext(FormContext),
|
|
49
51
|
isFluid = _useContext.isFluid;
|
|
50
52
|
|
|
53
|
+
var datePickerInputInstanceId = getInstanceId();
|
|
51
54
|
var datePickerInputProps = {
|
|
52
55
|
id: id,
|
|
53
56
|
onChange: function onChange(event) {
|
|
@@ -69,12 +72,13 @@ var DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePicker
|
|
|
69
72
|
var helperTextClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
70
73
|
var inputClasses = cx("".concat(prefix, "--date-picker__input"), (_cx4 = {}, _defineProperty(_cx4, "".concat(prefix, "--date-picker__input--").concat(size), size), _defineProperty(_cx4, "".concat(prefix, "--date-picker__input--invalid"), invalid), _defineProperty(_cx4, "".concat(prefix, "--date-picker__input--warn"), warn), _cx4));
|
|
71
74
|
var containerClasses = cx("".concat(prefix, "--date-picker-container"), (_cx5 = {}, _defineProperty(_cx5, "".concat(prefix, "--date-picker--nolabel"), !labelText), _defineProperty(_cx5, "".concat(prefix, "--date-picker--fluid--invalid"), isFluid && invalid), _defineProperty(_cx5, "".concat(prefix, "--date-picker--fluid--warn"), isFluid && warn), _cx5));
|
|
75
|
+
var datePickerInputHelperId = !helperText ? undefined : "detepicker-input-helper-text-".concat(datePickerInputInstanceId);
|
|
72
76
|
|
|
73
|
-
var inputProps = _objectSpread2(_objectSpread2(_objectSpread2({}, rest), datePickerInputProps), {}, {
|
|
77
|
+
var inputProps = _objectSpread2(_objectSpread2(_objectSpread2({}, rest), datePickerInputProps), {}, _defineProperty({
|
|
74
78
|
className: inputClasses,
|
|
75
79
|
disabled: disabled,
|
|
76
80
|
ref: ref
|
|
77
|
-
});
|
|
81
|
+
}, 'aria-describedby', helperText ? datePickerInputHelperId : undefined));
|
|
78
82
|
|
|
79
83
|
if (invalid) {
|
|
80
84
|
inputProps['data-invalid'] = true;
|
|
@@ -103,6 +107,7 @@ var DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePicker
|
|
|
103
107
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
104
108
|
className: "".concat(prefix, "--form-requirement")
|
|
105
109
|
}, warnText)), helperText && /*#__PURE__*/React__default.createElement("div", {
|
|
110
|
+
id: datePickerInputHelperId,
|
|
106
111
|
className: helperTextClasses
|
|
107
112
|
}, helperText));
|
|
108
113
|
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { defineProperty as _defineProperty, typeof as _typeof, objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, slicedToArray as _slicedToArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useContext,
|
|
9
|
+
import React__default, { useContext, useRef, useState } from 'react';
|
|
10
10
|
import { useSelect } from 'downshift';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
@@ -18,11 +18,13 @@ import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
|
18
18
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
19
19
|
import '../FluidForm/FluidForm.js';
|
|
20
20
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
21
|
+
import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
|
|
21
22
|
import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
|
|
22
23
|
|
|
23
24
|
var _Dropdown$propTypes;
|
|
24
25
|
|
|
25
26
|
var _excluded = ["className", "disabled", "direction", "items", "label", "aria-label", "ariaLabel", "itemToString", "itemToElement", "renderSelectedItem", "type", "size", "onChange", "id", "titleText", "hideLabel", "helperText", "translateWithId", "light", "invalid", "invalidText", "warn", "warnText", "initialSelectedItem", "selectedItem", "downshiftProps", "readOnly"];
|
|
27
|
+
var getInstanceId = setupGetInstanceId();
|
|
26
28
|
|
|
27
29
|
var defaultItemToString = function defaultItemToString(item) {
|
|
28
30
|
if (typeof item === 'string') {
|
|
@@ -83,7 +85,10 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
83
85
|
itemToString: itemToString,
|
|
84
86
|
initialSelectedItem: initialSelectedItem,
|
|
85
87
|
onSelectedItemChange: onSelectedItemChange
|
|
86
|
-
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
var _useRef = useRef(getInstanceId()),
|
|
91
|
+
dropdownInstanceId = _useRef.current; // only set selectedItem if the prop is defined. Setting if it is undefined
|
|
87
92
|
// will overwrite default selected items from useSelect
|
|
88
93
|
|
|
89
94
|
|
|
@@ -112,11 +117,13 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
112
117
|
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));
|
|
113
118
|
var titleClasses = cx("".concat(prefix, "--label"), (_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--label--disabled"), disabled), _defineProperty(_cx2, "".concat(prefix, "--visually-hidden"), hideLabel), _cx2));
|
|
114
119
|
var helperClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
115
|
-
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));
|
|
120
|
+
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));
|
|
121
|
+
var helperId = !helperText ? undefined : "dropdown-helper-text-".concat(dropdownInstanceId); // needs to be Capitalized for react to render it correctly
|
|
116
122
|
|
|
117
123
|
var ItemToElement = itemToElement;
|
|
118
124
|
var toggleButtonProps = getToggleButtonProps();
|
|
119
125
|
var helper = helperText && !isFluid ? /*#__PURE__*/React__default.createElement("div", {
|
|
126
|
+
id: helperId,
|
|
120
127
|
className: helperClasses
|
|
121
128
|
}, helperText) : null;
|
|
122
129
|
|
|
@@ -179,11 +186,16 @@ var Dropdown = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
179
186
|
}), showWarning && /*#__PURE__*/React__default.createElement(WarningAltFilled, {
|
|
180
187
|
className: "".concat(prefix, "--list-box__invalid-icon ").concat(prefix, "--list-box__invalid-icon--warning")
|
|
181
188
|
}), /*#__PURE__*/React__default.createElement("button", _extends({
|
|
182
|
-
type: "button"
|
|
189
|
+
type: "button" // aria-expanded is already being passed through {...toggleButtonProps}
|
|
190
|
+
,
|
|
191
|
+
role: "combobox" // eslint-disable-line jsx-a11y/role-has-required-aria-props
|
|
192
|
+
,
|
|
193
|
+
"aria-controls": getMenuProps().id,
|
|
183
194
|
className: "".concat(prefix, "--list-box__field"),
|
|
184
195
|
disabled: disabled,
|
|
185
196
|
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
186
197
|
,
|
|
198
|
+
"aria-describedby": !inline && !invalid && !warn && helper ? helperId : undefined,
|
|
187
199
|
title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : label
|
|
188
200
|
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
189
201
|
ref: mergedRef
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { inherits as _inherits, createSuper as _createSuper,
|
|
8
|
+
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import React__default from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import { ErrorBoundaryContext } from './ErrorBoundaryContext.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { inherits as _inherits, createSuper as _createSuper,
|
|
8
|
+
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import * as FeatureFlags from '@carbon/feature-flags';
|
|
@@ -13,7 +13,7 @@ import DatePicker from '../DatePicker/DatePicker.js';
|
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
14
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
15
15
|
|
|
16
|
-
var _excluded = ["className", "children", "invalid", "invalidText", "warn", "warnText"];
|
|
16
|
+
var _excluded = ["className", "children", "invalid", "invalidText", "readOnly", "warn", "warnText"];
|
|
17
17
|
var FluidDatePicker = /*#__PURE__*/React__default.forwardRef(function FluidDatePicker(_ref, ref) {
|
|
18
18
|
var _classnames;
|
|
19
19
|
|
|
@@ -21,12 +21,13 @@ var FluidDatePicker = /*#__PURE__*/React__default.forwardRef(function FluidDateP
|
|
|
21
21
|
children = _ref.children,
|
|
22
22
|
invalid = _ref.invalid,
|
|
23
23
|
invalidText = _ref.invalidText,
|
|
24
|
+
readOnly = _ref.readOnly,
|
|
24
25
|
warn = _ref.warn,
|
|
25
26
|
warnText = _ref.warnText,
|
|
26
27
|
other = _objectWithoutProperties(_ref, _excluded);
|
|
27
28
|
|
|
28
29
|
var prefix = usePrefix();
|
|
29
|
-
var classNames = cx(className, (_classnames = {}, _defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid"), true), _defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--invalid"), invalid), _defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--warn"), warn), _classnames));
|
|
30
|
+
var classNames = cx(className, (_classnames = {}, _defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid"), true), _defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--invalid"), invalid), _defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--readonly"), readOnly), _defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--warn"), warn), _classnames));
|
|
30
31
|
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
|
|
31
32
|
value: {
|
|
32
33
|
isFluid: true
|
|
@@ -34,6 +35,7 @@ var FluidDatePicker = /*#__PURE__*/React__default.forwardRef(function FluidDateP
|
|
|
34
35
|
}, /*#__PURE__*/React__default.createElement(DatePicker, _extends({
|
|
35
36
|
invalid: invalid,
|
|
36
37
|
invalidText: invalidText,
|
|
38
|
+
readOnly: readOnly,
|
|
37
39
|
warn: warn,
|
|
38
40
|
warnText: warnText,
|
|
39
41
|
className: classNames,
|
|
@@ -61,6 +63,11 @@ FluidDatePicker.propTypes = {
|
|
|
61
63
|
*/
|
|
62
64
|
invalidText: PropTypes.node,
|
|
63
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Whether the input should be read-only
|
|
68
|
+
*/
|
|
69
|
+
readOnly: PropTypes.bool,
|
|
70
|
+
|
|
64
71
|
/**
|
|
65
72
|
* Specify whether the control is currently in warning state
|
|
66
73
|
*/
|
|
@@ -9,31 +9,35 @@ import { objectWithoutProperties as _objectWithoutProperties, extends as _extend
|
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import React__default from 'react';
|
|
11
11
|
import Button from '../Button/Button.js';
|
|
12
|
+
import cx from 'classnames';
|
|
12
13
|
import '../Tooltip/DefinitionTooltip.js';
|
|
13
14
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
14
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
-
import cx from 'classnames';
|
|
16
16
|
|
|
17
|
-
var _excluded = ["align", "children", "className", "defaultOpen", "enterDelayMs", "kind", "label", "leaveDelayMs", "size"];
|
|
17
|
+
var _excluded = ["align", "children", "className", "closeOnActivation", "defaultOpen", "enterDelayMs", "kind", "label", "leaveDelayMs", "wrapperClasses", "size"];
|
|
18
18
|
var IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(props, ref) {
|
|
19
19
|
var align = props.align,
|
|
20
20
|
children = props.children,
|
|
21
21
|
className = props.className,
|
|
22
|
+
_props$closeOnActivat = props.closeOnActivation,
|
|
23
|
+
closeOnActivation = _props$closeOnActivat === void 0 ? true : _props$closeOnActivat,
|
|
22
24
|
_props$defaultOpen = props.defaultOpen,
|
|
23
25
|
defaultOpen = _props$defaultOpen === void 0 ? false : _props$defaultOpen,
|
|
24
26
|
enterDelayMs = props.enterDelayMs,
|
|
25
27
|
kind = props.kind,
|
|
26
28
|
label = props.label,
|
|
27
29
|
leaveDelayMs = props.leaveDelayMs,
|
|
30
|
+
wrapperClasses = props.wrapperClasses,
|
|
28
31
|
_props$size = props.size,
|
|
29
32
|
size = _props$size === void 0 ? 'md' : _props$size,
|
|
30
33
|
rest = _objectWithoutProperties(props, _excluded);
|
|
31
34
|
|
|
32
35
|
var prefix = usePrefix();
|
|
36
|
+
var tooltipClasses = cx(wrapperClasses, "".concat(prefix, "--icon-tooltip"));
|
|
33
37
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
34
38
|
align: align,
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
closeOnActivation: closeOnActivation,
|
|
40
|
+
className: tooltipClasses,
|
|
37
41
|
defaultOpen: defaultOpen,
|
|
38
42
|
enterDelayMs: enterDelayMs,
|
|
39
43
|
label: label,
|
|
@@ -61,6 +65,11 @@ IconButton.propTypes = {
|
|
|
61
65
|
*/
|
|
62
66
|
className: PropTypes.string,
|
|
63
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Determines whether the tooltip should close when inner content is activated (click, Enter or Space)
|
|
70
|
+
*/
|
|
71
|
+
closeOnActivation: PropTypes.bool,
|
|
72
|
+
|
|
64
73
|
/**
|
|
65
74
|
* Specify whether the tooltip should be open when it first renders
|
|
66
75
|
*/
|
|
@@ -92,7 +101,12 @@ IconButton.propTypes = {
|
|
|
92
101
|
/**
|
|
93
102
|
* Specify the size of the Button. Defaults to `md`.
|
|
94
103
|
*/
|
|
95
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg'])
|
|
104
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Specify an optional className to be added to your Tooltip wrapper
|
|
108
|
+
*/
|
|
109
|
+
wrapperClasses: PropTypes.string
|
|
96
110
|
};
|
|
97
111
|
|
|
98
112
|
export { IconButton };
|
|
@@ -17,6 +17,8 @@ import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsT
|
|
|
17
17
|
import wrapFocus, { elementOrParentIsFloatingMenu } from '../../internal/wrapFocus.js';
|
|
18
18
|
import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
|
|
19
19
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
20
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
21
|
+
import { Escape, Enter } from '../../internal/keyboard/keys.js';
|
|
20
22
|
|
|
21
23
|
var _Modal$propTypes;
|
|
22
24
|
|
|
@@ -70,11 +72,11 @@ var Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
70
72
|
|
|
71
73
|
function handleKeyDown(evt) {
|
|
72
74
|
if (open) {
|
|
73
|
-
if (evt
|
|
75
|
+
if (match(evt, Escape)) {
|
|
74
76
|
onRequestClose(evt);
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
if (evt
|
|
79
|
+
if (match(evt, Enter) && shouldSubmitOnEnter && !isCloseButton(evt.target)) {
|
|
78
80
|
onRequestSubmit(evt);
|
|
79
81
|
}
|
|
80
82
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { inherits as _inherits, createSuper as _createSuper,
|
|
8
|
+
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import React__default from 'react';
|
|
11
11
|
import Modal from '../Modal/Modal.js';
|
|
@@ -29,7 +29,7 @@ import { match } from '../../internal/keyboard/match.js';
|
|
|
29
29
|
import ListBoxSelection from '../ListBox/next/ListBoxSelection.js';
|
|
30
30
|
import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
|
|
31
31
|
import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
|
|
32
|
-
import { Space, Enter, Delete, Escape, Tab } from '../../internal/keyboard/keys.js';
|
|
32
|
+
import { Space, Enter, Delete, Escape, Tab, Home, End } from '../../internal/keyboard/keys.js';
|
|
33
33
|
|
|
34
34
|
var _objectSpread2, _FilterableMultiSelec;
|
|
35
35
|
var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function FilterableMultiSelect(_ref, ref) {
|
|
@@ -324,6 +324,14 @@ var FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Filt
|
|
|
324
324
|
if (match(event, Tab)) {
|
|
325
325
|
handleOnMenuChange(false);
|
|
326
326
|
}
|
|
327
|
+
|
|
328
|
+
if (match(event, Home)) {
|
|
329
|
+
event.target.setSelectionRange(0, 0);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (match(event, End)) {
|
|
333
|
+
event.target.setSelectionRange(event.target.value.length, event.target.value.length);
|
|
334
|
+
}
|
|
327
335
|
},
|
|
328
336
|
onFocus: function onFocus() {
|
|
329
337
|
setInputFocused(true);
|
|
@@ -332,7 +332,8 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
332
332
|
type: "button",
|
|
333
333
|
className: "".concat(prefix, "--list-box__field"),
|
|
334
334
|
disabled: disabled,
|
|
335
|
-
"aria-disabled": disabled || readOnly
|
|
335
|
+
"aria-disabled": disabled || readOnly,
|
|
336
|
+
"aria-describedby": !inline && !invalid && !warn && helperText ? helperId : undefined
|
|
336
337
|
}, toggleButtonProps, {
|
|
337
338
|
ref: mergedRef,
|
|
338
339
|
onKeyDown: onKeyDown
|
|
@@ -140,6 +140,10 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
140
140
|
ariaDescribedBy = normalizedProps.warnId;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
if (!normalizedProps.validation) {
|
|
144
|
+
ariaDescribedBy = helperText ? normalizedProps.helperId : undefined;
|
|
145
|
+
}
|
|
146
|
+
|
|
143
147
|
function handleOnChange(event) {
|
|
144
148
|
if (disabled) {
|
|
145
149
|
return;
|
|
@@ -274,6 +278,7 @@ var NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(pr
|
|
|
274
278
|
}))), isFluid && /*#__PURE__*/React__default.createElement("hr", {
|
|
275
279
|
className: "".concat(prefix, "--number-input__divider")
|
|
276
280
|
}), normalizedProps.validation ? normalizedProps.validation : /*#__PURE__*/React__default.createElement(HelperText, {
|
|
281
|
+
id: normalizedProps.helperId,
|
|
277
282
|
disabled: disabled,
|
|
278
283
|
description: helperText
|
|
279
284
|
})));
|
|
@@ -442,12 +447,14 @@ Label.propTypes = {
|
|
|
442
447
|
|
|
443
448
|
function HelperText(_ref3) {
|
|
444
449
|
var disabled = _ref3.disabled,
|
|
445
|
-
description = _ref3.description
|
|
450
|
+
description = _ref3.description,
|
|
451
|
+
id = _ref3.id;
|
|
446
452
|
var prefix = usePrefix();
|
|
447
453
|
var className = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
448
454
|
|
|
449
455
|
if (description) {
|
|
450
456
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
457
|
+
id: id,
|
|
451
458
|
className: className
|
|
452
459
|
}, description);
|
|
453
460
|
}
|
|
@@ -457,7 +464,8 @@ function HelperText(_ref3) {
|
|
|
457
464
|
|
|
458
465
|
HelperText.propTypes = {
|
|
459
466
|
description: PropTypes.node,
|
|
460
|
-
disabled: PropTypes.bool
|
|
467
|
+
disabled: PropTypes.bool,
|
|
468
|
+
id: PropTypes.string
|
|
461
469
|
};
|
|
462
470
|
/**
|
|
463
471
|
* Determine if the given value is invalid based on the given max, min and
|
|
@@ -32,6 +32,7 @@ function ProgressBar(_ref) {
|
|
|
32
32
|
value = _ref.value;
|
|
33
33
|
var labelId = useId('progress-bar');
|
|
34
34
|
var helperId = useId('progress-bar-helper');
|
|
35
|
+
var helperTextId = useId('progress-bar-helper-text');
|
|
35
36
|
var prefix = usePrefix();
|
|
36
37
|
var isFinished = status === 'finished';
|
|
37
38
|
var isError = status === 'error';
|
|
@@ -96,6 +97,7 @@ function ProgressBar(_ref) {
|
|
|
96
97
|
"aria-busy": !isFinished,
|
|
97
98
|
"aria-invalid": isError,
|
|
98
99
|
"aria-labelledby": labelId,
|
|
100
|
+
"aria-describedby": helperText ? helperTextId : undefined,
|
|
99
101
|
"aria-valuemin": !indeterminate ? 0 : null,
|
|
100
102
|
"aria-valuemax": !indeterminate ? max : null,
|
|
101
103
|
"aria-valuenow": !indeterminate ? cappedValue : null
|
|
@@ -103,6 +105,7 @@ function ProgressBar(_ref) {
|
|
|
103
105
|
className: "".concat(prefix, "--progress-bar__bar"),
|
|
104
106
|
ref: ref
|
|
105
107
|
})), helperText && /*#__PURE__*/React__default.createElement("div", {
|
|
108
|
+
id: helperTextId,
|
|
106
109
|
className: "".concat(prefix, "--progress-bar__helper-text")
|
|
107
110
|
}, helperText, /*#__PURE__*/React__default.createElement("div", {
|
|
108
111
|
className: "".concat(prefix, "--visually-hidden"),
|
|
@@ -121,7 +121,8 @@ var RadioButtonGroup = /*#__PURE__*/React__default.forwardRef(function (props, r
|
|
|
121
121
|
className: fieldsetClasses,
|
|
122
122
|
disabled: disabled,
|
|
123
123
|
"data-invalid": invalid ? true : undefined,
|
|
124
|
-
"aria-readonly": readOnly
|
|
124
|
+
"aria-readonly": readOnly,
|
|
125
|
+
"aria-describedby": showHelper && helperText ? helperId : undefined
|
|
125
126
|
}, rest), legendText && /*#__PURE__*/React__default.createElement(Legend, {
|
|
126
127
|
className: "".concat(prefix, "--label")
|
|
127
128
|
}, legendText), getRadioButtons()), /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -85,5 +85,5 @@ interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttr
|
|
|
85
85
|
*/
|
|
86
86
|
warnText?: ReactNode;
|
|
87
87
|
}
|
|
88
|
-
declare const Select: React.ForwardRefExoticComponent<Pick<SelectProps, "value" | "children" | "className" | "disabled" | "size" | "form" | "slot" | "style" | "title" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "autoComplete" | "multiple" | "key" | "id" | "onAnimationEnd" | "aria-controls" | "aria-expanded" | "onClick" | "onKeyDown" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "inline" | "name" | "readOnly" | "required" | "labelText" | "
|
|
88
|
+
declare const Select: React.ForwardRefExoticComponent<Pick<SelectProps, "value" | "children" | "className" | "disabled" | "size" | "form" | "slot" | "style" | "title" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "autoComplete" | "multiple" | "key" | "id" | "onAnimationEnd" | "aria-controls" | "aria-expanded" | "onClick" | "onKeyDown" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "inline" | "name" | "readOnly" | "required" | "labelText" | "helperText" | "invalid" | "invalidText" | "hideLabel" | "warn" | "warnText" | "light" | "noLabel"> & React.RefAttributes<HTMLSelectElement>>;
|
|
89
89
|
export default Select;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React__default, { useContext, useState } from 'react';
|
|
10
|
+
import React__default, { useContext, useState, useRef } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { ChevronDown, WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
13
13
|
import deprecate from '../../prop-types/deprecate.js';
|
|
@@ -15,8 +15,10 @@ import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
16
|
import '../FluidForm/FluidForm.js';
|
|
17
17
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
18
|
+
import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
|
|
18
19
|
|
|
19
20
|
var _excluded = ["className", "id", "inline", "labelText", "disabled", "children", "noLabel", "hideLabel", "invalid", "invalidText", "helperText", "light", "readOnly", "size", "warn", "warnText"];
|
|
21
|
+
var getInstanceId = setupGetInstanceId();
|
|
20
22
|
var Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref) {
|
|
21
23
|
var _classNames, _classNames2, _classNames3;
|
|
22
24
|
|
|
@@ -56,6 +58,9 @@ var Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref) {
|
|
|
56
58
|
isFocused = _useState2[0],
|
|
57
59
|
setIsFocused = _useState2[1];
|
|
58
60
|
|
|
61
|
+
var _useRef = useRef(getInstanceId()),
|
|
62
|
+
selectInstanceId = _useRef.current;
|
|
63
|
+
|
|
59
64
|
var selectClasses = cx((_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--select"), true), _defineProperty(_classNames, "".concat(prefix, "--select--inline"), inline), _defineProperty(_classNames, "".concat(prefix, "--select--light"), light), _defineProperty(_classNames, "".concat(prefix, "--select--invalid"), invalid), _defineProperty(_classNames, "".concat(prefix, "--select--disabled"), disabled), _defineProperty(_classNames, "".concat(prefix, "--select--readonly"), readOnly), _defineProperty(_classNames, "".concat(prefix, "--select--warning"), warn), _defineProperty(_classNames, "".concat(prefix, "--select--fluid--invalid"), isFluid && invalid), _defineProperty(_classNames, "".concat(prefix, "--select--fluid--focus"), isFluid && isFocused), _classNames), [enabled ? null : className]);
|
|
60
65
|
var labelClasses = cx("".concat(prefix, "--label"), (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefix, "--visually-hidden"), hideLabel), _defineProperty(_classNames2, "".concat(prefix, "--label--disabled"), disabled), _classNames2));
|
|
61
66
|
var inputClasses = cx((_classNames3 = {}, _defineProperty(_classNames3, "".concat(prefix, "--select-input"), true), _defineProperty(_classNames3, "".concat(prefix, "--select-input--").concat(size), size), _classNames3));
|
|
@@ -76,13 +81,17 @@ var Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref) {
|
|
|
76
81
|
id: errorId
|
|
77
82
|
}, errorText) : null;
|
|
78
83
|
var helperTextClasses = cx("".concat(prefix, "--form__helper-text"), _defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
84
|
+
var helperId = !helperText ? undefined : "select-helper-text-".concat(selectInstanceId);
|
|
79
85
|
var helper = helperText ? /*#__PURE__*/React__default.createElement("div", {
|
|
86
|
+
id: helperId,
|
|
80
87
|
className: helperTextClasses
|
|
81
88
|
}, helperText) : null;
|
|
82
89
|
var ariaProps = {};
|
|
83
90
|
|
|
84
91
|
if (invalid) {
|
|
85
92
|
ariaProps['aria-describedby'] = errorId;
|
|
93
|
+
} else if (!inline && !isFluid) {
|
|
94
|
+
ariaProps['aria-describedby'] = helper ? helperId : undefined;
|
|
86
95
|
}
|
|
87
96
|
|
|
88
97
|
var handleFocus = function handleFocus(evt) {
|
|
@@ -131,12 +131,13 @@ function StructuredListRow(props) {
|
|
|
131
131
|
setHasFocusWithin = _useState2[1];
|
|
132
132
|
|
|
133
133
|
var id = useId('grid-input');
|
|
134
|
+
var selectedRow = React__default.useContext(GridSelectedRowStateContext);
|
|
134
135
|
var setSelectedRow = React__default.useContext(GridSelectedRowDispatchContext);
|
|
135
136
|
var prefix = usePrefix();
|
|
136
137
|
var value = {
|
|
137
138
|
id: id
|
|
138
139
|
};
|
|
139
|
-
var classes = cx("".concat(prefix, "--structured-list-row"), className, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefix, "--structured-list-row--header-row"), head), _defineProperty(_classNames2, "".concat(prefix, "--structured-list-row--focused-within"), hasFocusWithin), _classNames2));
|
|
140
|
+
var classes = cx("".concat(prefix, "--structured-list-row"), className, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefix, "--structured-list-row--header-row"), head), _defineProperty(_classNames2, "".concat(prefix, "--structured-list-row--focused-within"), hasFocusWithin), _defineProperty(_classNames2, "".concat(prefix, "--structured-list-row--selected"), selectedRow === id), _classNames2));
|
|
140
141
|
return head ? /*#__PURE__*/React__default.createElement("div", _extends({
|
|
141
142
|
role: "row"
|
|
142
143
|
}, other, {
|