@carbon/react 1.26.1 → 1.27.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/RadioTile/RadioTile.js +1 -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/Tabs/Tabs.js +29 -17
- 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/RadioTile/RadioTile.js +1 -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/Tabs/Tabs.js +29 -17
- 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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var DataTable = require('./DataTable.js');
|
|
13
|
+
var Table = require('./Table.js');
|
|
14
|
+
var TableActionList = require('./TableActionList.js');
|
|
15
|
+
var TableBatchAction = require('./TableBatchAction.js');
|
|
16
|
+
var TableBatchActions = require('./TableBatchActions.js');
|
|
17
|
+
var TableBody = require('./TableBody.js');
|
|
18
|
+
var TableCell = require('./TableCell.js');
|
|
19
|
+
var TableContainer = require('./TableContainer.js');
|
|
20
|
+
var TableExpandHeader = require('./TableExpandHeader.js');
|
|
21
|
+
var TableExpandRow = require('./TableExpandRow.js');
|
|
22
|
+
var TableExpandedRow = require('./TableExpandedRow.js');
|
|
23
|
+
var TableHead = require('./TableHead.js');
|
|
24
|
+
var TableHeader = require('./TableHeader.js');
|
|
25
|
+
var TableRow = require('./TableRow.js');
|
|
26
|
+
var TableSelectAll = require('./TableSelectAll.js');
|
|
27
|
+
var TableSelectRow = require('./TableSelectRow.js');
|
|
28
|
+
var TableToolbar = require('./TableToolbar.js');
|
|
29
|
+
var TableToolbarAction = require('./TableToolbarAction.js');
|
|
30
|
+
var TableToolbarContent = require('./TableToolbarContent.js');
|
|
31
|
+
var TableToolbarSearch = require('./TableToolbarSearch.js');
|
|
32
|
+
var TableToolbarMenu = require('./TableToolbarMenu.js');
|
|
33
|
+
|
|
34
|
+
DataTable["default"].Table = Table.Table;
|
|
35
|
+
DataTable["default"].TableActionList = TableActionList["default"];
|
|
36
|
+
DataTable["default"].TableBatchAction = TableBatchAction["default"];
|
|
37
|
+
DataTable["default"].TableBatchActions = TableBatchActions["default"];
|
|
38
|
+
DataTable["default"].TableBody = TableBody["default"];
|
|
39
|
+
DataTable["default"].TableCell = TableCell["default"];
|
|
40
|
+
DataTable["default"].TableContainer = TableContainer["default"];
|
|
41
|
+
DataTable["default"].TableExpandHeader = TableExpandHeader["default"];
|
|
42
|
+
DataTable["default"].TableExpandRow = TableExpandRow["default"];
|
|
43
|
+
DataTable["default"].TableExpandedRow = TableExpandedRow["default"];
|
|
44
|
+
DataTable["default"].TableHead = TableHead["default"];
|
|
45
|
+
DataTable["default"].TableHeader = TableHeader["default"];
|
|
46
|
+
DataTable["default"].TableRow = TableRow["default"];
|
|
47
|
+
DataTable["default"].TableSelectAll = TableSelectAll["default"];
|
|
48
|
+
DataTable["default"].TableSelectRow = TableSelectRow["default"];
|
|
49
|
+
DataTable["default"].TableToolbar = TableToolbar["default"];
|
|
50
|
+
DataTable["default"].TableToolbarAction = TableToolbarAction["default"];
|
|
51
|
+
DataTable["default"].TableToolbarContent = TableToolbarContent["default"];
|
|
52
|
+
DataTable["default"].TableToolbarSearch = TableToolbarSearch["default"];
|
|
53
|
+
DataTable["default"].TableToolbarMenu = TableToolbarMenu["default"];
|
|
54
|
+
|
|
55
|
+
exports.DataTable = DataTable["default"];
|
|
56
|
+
exports["default"] = DataTable["default"];
|
|
57
|
+
exports.Table = Table.Table;
|
|
58
|
+
exports.TableActionList = TableActionList["default"];
|
|
59
|
+
exports.TableBatchAction = TableBatchAction["default"];
|
|
60
|
+
exports.TableBatchActions = TableBatchActions["default"];
|
|
61
|
+
exports.TableBody = TableBody["default"];
|
|
62
|
+
exports.TableCell = TableCell["default"];
|
|
63
|
+
exports.TableContainer = TableContainer["default"];
|
|
64
|
+
exports.TableExpandHeader = TableExpandHeader["default"];
|
|
65
|
+
exports.TableExpandRow = TableExpandRow["default"];
|
|
66
|
+
exports.TableExpandedRow = TableExpandedRow["default"];
|
|
67
|
+
exports.TableHead = TableHead["default"];
|
|
68
|
+
exports.TableHeader = TableHeader["default"];
|
|
69
|
+
exports.TableRow = TableRow["default"];
|
|
70
|
+
exports.TableSelectAll = TableSelectAll["default"];
|
|
71
|
+
exports.TableSelectRow = TableSelectRow["default"];
|
|
72
|
+
exports.TableToolbar = TableToolbar["default"];
|
|
73
|
+
exports.TableToolbarAction = TableToolbarAction["default"];
|
|
74
|
+
exports.TableToolbarContent = TableToolbarContent["default"];
|
|
75
|
+
exports.TableToolbarSearch = TableToolbarSearch["default"];
|
|
76
|
+
exports.TableToolbarMenu = TableToolbarMenu["default"];
|
|
@@ -215,9 +215,24 @@ var DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Date
|
|
|
215
215
|
}
|
|
216
216
|
}, []);
|
|
217
217
|
var endInputField = React.useRef(null);
|
|
218
|
+
var lastStartValue = React.useRef(''); // fix datepicker deleting the selectedDate when the calendar closes
|
|
219
|
+
|
|
220
|
+
var onCalendarClose = function onCalendarClose(selectedDates, dateStr) {
|
|
221
|
+
setTimeout(function () {
|
|
222
|
+
if (lastStartValue.current && selectedDates[0] && !startInputField.current.value) {
|
|
223
|
+
startInputField.current.value = lastStartValue.current;
|
|
224
|
+
calendarRef.current.setDate([startInputField.current.value, endInputField.current.value], true, calendarRef.current.config.dateFormat);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (onClose) {
|
|
228
|
+
onClose(calendarRef.current.selectedDates, dateStr, calendarRef.current);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
|
|
218
233
|
var calendarRef = React.useRef(null);
|
|
219
234
|
var savedOnChange = useSavedCallback.useSavedCallback(onChange);
|
|
220
|
-
var savedOnClose = useSavedCallback.useSavedCallback(onClose);
|
|
235
|
+
var savedOnClose = useSavedCallback.useSavedCallback(datePickerType === 'range' ? onCalendarClose : onClose);
|
|
221
236
|
var savedOnOpen = useSavedCallback.useSavedCallback(onOpen);
|
|
222
237
|
var datePickerClasses = cx__default["default"]("".concat(prefix, "--date-picker"), (_cx = {}, _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--date-picker--short"), short), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--date-picker--light"), light), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--date-picker--simple"), datePickerType === 'simple'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--date-picker--single"), datePickerType === 'single'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--date-picker--range"), datePickerType === 'range'), _rollupPluginBabelHelpers.defineProperty(_cx, "".concat(prefix, "--date-picker--nolabel"), datePickerType === 'range' && isLabelTextEmpty(children)), _cx));
|
|
223
238
|
var wrapperClasses = cx__default["default"]("".concat(prefix, "--form-item"), _rollupPluginBabelHelpers.defineProperty({}, className, className));
|
|
@@ -319,7 +334,8 @@ var DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Date
|
|
|
319
334
|
classFlatpickrCurrentMonth: 'cur-month'
|
|
320
335
|
}), fixEventsPlugin["default"]({
|
|
321
336
|
inputFrom: startInputField.current,
|
|
322
|
-
inputTo: endInputField.current
|
|
337
|
+
inputTo: endInputField.current,
|
|
338
|
+
lastStartValue: lastStartValue
|
|
323
339
|
})]), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "clickOpens", !readOnly), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "noCalendar", readOnly), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "nextArrow", rightArrowHTML), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "prevArrow", leftArrowHTML), _rollupPluginBabelHelpers.defineProperty(_flatpickr, "onChange", function onChange() {
|
|
324
340
|
if (savedOnChange && !readOnly) {
|
|
325
341
|
savedOnChange.apply(void 0, arguments);
|
|
@@ -345,11 +361,17 @@ var DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Date
|
|
|
345
361
|
}
|
|
346
362
|
}
|
|
347
363
|
|
|
348
|
-
function handleOnChange() {
|
|
364
|
+
function handleOnChange(event) {
|
|
349
365
|
if (datePickerType == 'single') {
|
|
350
366
|
calendar.calendarContainer.classList.remove('open');
|
|
351
367
|
}
|
|
352
368
|
|
|
369
|
+
var target = event.target;
|
|
370
|
+
|
|
371
|
+
if (target === start) {
|
|
372
|
+
lastStartValue.current = start.value;
|
|
373
|
+
}
|
|
374
|
+
|
|
353
375
|
if (start.value !== '') {
|
|
354
376
|
return;
|
|
355
377
|
}
|
|
@@ -55,7 +55,8 @@ var carbonFlatpickrFixEventsPlugin = (function (config) {
|
|
|
55
55
|
|
|
56
56
|
var handleBlur = function handleBlur(event) {
|
|
57
57
|
var inputFrom = config.inputFrom,
|
|
58
|
-
inputTo = config.inputTo
|
|
58
|
+
inputTo = config.inputTo,
|
|
59
|
+
lastStartValue = config.lastStartValue;
|
|
59
60
|
var target = event.target; // Only fall into this logic if the event is on the `to` input and there is a
|
|
60
61
|
// `to` date selected
|
|
61
62
|
|
|
@@ -80,6 +81,19 @@ var carbonFlatpickrFixEventsPlugin = (function (config) {
|
|
|
80
81
|
if (currentEndDate.toString() !== 'Invalid Date') {
|
|
81
82
|
fp.setDate([inputFrom.value, inputTo.value], true, fp.config.dateFormat);
|
|
82
83
|
}
|
|
84
|
+
} // overriding the flatpickr bug where the startDate gets deleted on blur
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
if (inputTo === target && !inputFrom.value && lastStartValue.current) {
|
|
88
|
+
var currentStartDate = new Date(lastStartValue.current);
|
|
89
|
+
|
|
90
|
+
if (currentStartDate.toString() !== 'Invalid Date') {
|
|
91
|
+
inputFrom.value = lastStartValue.current;
|
|
92
|
+
|
|
93
|
+
if (inputTo.value) {
|
|
94
|
+
fp.setDate([inputFrom.value, inputTo.value], true, fp.config.dateFormat);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
83
97
|
}
|
|
84
98
|
};
|
|
85
99
|
/**
|
|
@@ -17,6 +17,7 @@ var React = require('react');
|
|
|
17
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
18
|
require('../FluidForm/FluidForm.js');
|
|
19
19
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
20
|
+
var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
|
|
20
21
|
|
|
21
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
23
|
|
|
@@ -25,6 +26,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
25
26
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
26
27
|
|
|
27
28
|
var _excluded = ["datePickerType", "disabled", "helperText", "hideLabel", "id", "invalid", "invalidText", "labelText", "onClick", "onChange", "pattern", "placeholder", "size", "type", "warn", "warnText"];
|
|
29
|
+
var getInstanceId = setupGetInstanceId["default"]();
|
|
28
30
|
var DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(function DatePickerInput(props, ref) {
|
|
29
31
|
var _cx, _cx2, _cx4, _cx5;
|
|
30
32
|
|
|
@@ -58,6 +60,7 @@ var DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
58
60
|
var _useContext = React.useContext(FormContext.FormContext),
|
|
59
61
|
isFluid = _useContext.isFluid;
|
|
60
62
|
|
|
63
|
+
var datePickerInputInstanceId = getInstanceId();
|
|
61
64
|
var datePickerInputProps = {
|
|
62
65
|
id: id,
|
|
63
66
|
onChange: function onChange(event) {
|
|
@@ -79,12 +82,13 @@ var DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
79
82
|
var helperTextClasses = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
80
83
|
var inputClasses = cx__default["default"]("".concat(prefix, "--date-picker__input"), (_cx4 = {}, _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--date-picker__input--").concat(size), size), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--date-picker__input--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_cx4, "".concat(prefix, "--date-picker__input--warn"), warn), _cx4));
|
|
81
84
|
var containerClasses = cx__default["default"]("".concat(prefix, "--date-picker-container"), (_cx5 = {}, _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--date-picker--nolabel"), !labelText), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--date-picker--fluid--invalid"), isFluid && invalid), _rollupPluginBabelHelpers.defineProperty(_cx5, "".concat(prefix, "--date-picker--fluid--warn"), isFluid && warn), _cx5));
|
|
85
|
+
var datePickerInputHelperId = !helperText ? undefined : "detepicker-input-helper-text-".concat(datePickerInputInstanceId);
|
|
82
86
|
|
|
83
|
-
var inputProps = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, rest), datePickerInputProps), {}, {
|
|
87
|
+
var inputProps = _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, rest), datePickerInputProps), {}, _rollupPluginBabelHelpers.defineProperty({
|
|
84
88
|
className: inputClasses,
|
|
85
89
|
disabled: disabled,
|
|
86
90
|
ref: ref
|
|
87
|
-
});
|
|
91
|
+
}, 'aria-describedby', helperText ? datePickerInputHelperId : undefined));
|
|
88
92
|
|
|
89
93
|
if (invalid) {
|
|
90
94
|
inputProps['data-invalid'] = true;
|
|
@@ -113,6 +117,7 @@ var DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
113
117
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
114
118
|
className: "".concat(prefix, "--form-requirement")
|
|
115
119
|
}, warnText)), helperText && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
120
|
+
id: datePickerInputHelperId,
|
|
116
121
|
className: helperTextClasses
|
|
117
122
|
}, helperText));
|
|
118
123
|
});
|
|
@@ -22,6 +22,7 @@ var index = require('../FeatureFlags/index.js');
|
|
|
22
22
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
23
23
|
require('../FluidForm/FluidForm.js');
|
|
24
24
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
25
|
+
var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
|
|
25
26
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
26
27
|
|
|
27
28
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -33,6 +34,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
33
34
|
var _Dropdown$propTypes;
|
|
34
35
|
|
|
35
36
|
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"];
|
|
37
|
+
var getInstanceId = setupGetInstanceId["default"]();
|
|
36
38
|
|
|
37
39
|
var defaultItemToString = function defaultItemToString(item) {
|
|
38
40
|
if (typeof item === 'string') {
|
|
@@ -93,7 +95,10 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
|
93
95
|
itemToString: itemToString,
|
|
94
96
|
initialSelectedItem: initialSelectedItem,
|
|
95
97
|
onSelectedItemChange: onSelectedItemChange
|
|
96
|
-
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
var _useRef = React.useRef(getInstanceId()),
|
|
101
|
+
dropdownInstanceId = _useRef.current; // only set selectedItem if the prop is defined. Setting if it is undefined
|
|
97
102
|
// will overwrite default selected items from useSelect
|
|
98
103
|
|
|
99
104
|
|
|
@@ -122,11 +127,13 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
|
122
127
|
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));
|
|
123
128
|
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));
|
|
124
129
|
var helperClasses = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
125
|
-
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));
|
|
130
|
+
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));
|
|
131
|
+
var helperId = !helperText ? undefined : "dropdown-helper-text-".concat(dropdownInstanceId); // needs to be Capitalized for react to render it correctly
|
|
126
132
|
|
|
127
133
|
var ItemToElement = itemToElement;
|
|
128
134
|
var toggleButtonProps = getToggleButtonProps();
|
|
129
135
|
var helper = helperText && !isFluid ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
136
|
+
id: helperId,
|
|
130
137
|
className: helperClasses
|
|
131
138
|
}, helperText) : null;
|
|
132
139
|
|
|
@@ -189,11 +196,16 @@ var Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
|
|
|
189
196
|
}), showWarning && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
|
|
190
197
|
className: "".concat(prefix, "--list-box__invalid-icon ").concat(prefix, "--list-box__invalid-icon--warning")
|
|
191
198
|
}), /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({
|
|
192
|
-
type: "button"
|
|
199
|
+
type: "button" // aria-expanded is already being passed through {...toggleButtonProps}
|
|
200
|
+
,
|
|
201
|
+
role: "combobox" // eslint-disable-line jsx-a11y/role-has-required-aria-props
|
|
202
|
+
,
|
|
203
|
+
"aria-controls": getMenuProps().id,
|
|
193
204
|
className: "".concat(prefix, "--list-box__field"),
|
|
194
205
|
disabled: disabled,
|
|
195
206
|
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
196
207
|
,
|
|
208
|
+
"aria-describedby": !inline && !invalid && !warn && helper ? helperId : undefined,
|
|
197
209
|
title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : label
|
|
198
210
|
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
199
211
|
ref: mergedRef
|
|
@@ -23,7 +23,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
23
23
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
24
24
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
25
25
|
|
|
26
|
-
var _excluded = ["className", "children", "invalid", "invalidText", "warn", "warnText"];
|
|
26
|
+
var _excluded = ["className", "children", "invalid", "invalidText", "readOnly", "warn", "warnText"];
|
|
27
27
|
var FluidDatePicker = /*#__PURE__*/React__default["default"].forwardRef(function FluidDatePicker(_ref, ref) {
|
|
28
28
|
var _classnames;
|
|
29
29
|
|
|
@@ -31,12 +31,13 @@ var FluidDatePicker = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
31
31
|
children = _ref.children,
|
|
32
32
|
invalid = _ref.invalid,
|
|
33
33
|
invalidText = _ref.invalidText,
|
|
34
|
+
readOnly = _ref.readOnly,
|
|
34
35
|
warn = _ref.warn,
|
|
35
36
|
warnText = _ref.warnText,
|
|
36
37
|
other = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
37
38
|
|
|
38
39
|
var prefix = usePrefix.usePrefix();
|
|
39
|
-
var classNames = cx__default["default"](className, (_classnames = {}, _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid"), true), _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--warn"), warn), _classnames));
|
|
40
|
+
var classNames = cx__default["default"](className, (_classnames = {}, _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid"), true), _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--readonly"), readOnly), _rollupPluginBabelHelpers.defineProperty(_classnames, "".concat(prefix, "--date-picker--fluid--warn"), warn), _classnames));
|
|
40
41
|
return /*#__PURE__*/React__default["default"].createElement(FormContext.FormContext.Provider, {
|
|
41
42
|
value: {
|
|
42
43
|
isFluid: true
|
|
@@ -44,6 +45,7 @@ var FluidDatePicker = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
44
45
|
}, /*#__PURE__*/React__default["default"].createElement(DatePicker["default"], _rollupPluginBabelHelpers["extends"]({
|
|
45
46
|
invalid: invalid,
|
|
46
47
|
invalidText: invalidText,
|
|
48
|
+
readOnly: readOnly,
|
|
47
49
|
warn: warn,
|
|
48
50
|
warnText: warnText,
|
|
49
51
|
className: classNames,
|
|
@@ -71,6 +73,11 @@ FluidDatePicker.propTypes = {
|
|
|
71
73
|
*/
|
|
72
74
|
invalidText: PropTypes__default["default"].node,
|
|
73
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Whether the input should be read-only
|
|
78
|
+
*/
|
|
79
|
+
readOnly: PropTypes__default["default"].bool,
|
|
80
|
+
|
|
74
81
|
/**
|
|
75
82
|
* Specify whether the control is currently in warning state
|
|
76
83
|
*/
|
|
@@ -13,10 +13,10 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
13
13
|
var PropTypes = require('prop-types');
|
|
14
14
|
var React = require('react');
|
|
15
15
|
var Button = require('../Button/Button.js');
|
|
16
|
+
var cx = require('classnames');
|
|
16
17
|
require('../Tooltip/DefinitionTooltip.js');
|
|
17
18
|
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
18
19
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
|
-
var cx = require('classnames');
|
|
20
20
|
|
|
21
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
22
|
|
|
@@ -24,26 +24,30 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
24
24
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
25
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
26
26
|
|
|
27
|
-
var _excluded = ["align", "children", "className", "defaultOpen", "enterDelayMs", "kind", "label", "leaveDelayMs", "size"];
|
|
27
|
+
var _excluded = ["align", "children", "className", "closeOnActivation", "defaultOpen", "enterDelayMs", "kind", "label", "leaveDelayMs", "wrapperClasses", "size"];
|
|
28
28
|
var IconButton = /*#__PURE__*/React__default["default"].forwardRef(function IconButton(props, ref) {
|
|
29
29
|
var align = props.align,
|
|
30
30
|
children = props.children,
|
|
31
31
|
className = props.className,
|
|
32
|
+
_props$closeOnActivat = props.closeOnActivation,
|
|
33
|
+
closeOnActivation = _props$closeOnActivat === void 0 ? true : _props$closeOnActivat,
|
|
32
34
|
_props$defaultOpen = props.defaultOpen,
|
|
33
35
|
defaultOpen = _props$defaultOpen === void 0 ? false : _props$defaultOpen,
|
|
34
36
|
enterDelayMs = props.enterDelayMs,
|
|
35
37
|
kind = props.kind,
|
|
36
38
|
label = props.label,
|
|
37
39
|
leaveDelayMs = props.leaveDelayMs,
|
|
40
|
+
wrapperClasses = props.wrapperClasses,
|
|
38
41
|
_props$size = props.size,
|
|
39
42
|
size = _props$size === void 0 ? 'md' : _props$size,
|
|
40
43
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
|
|
41
44
|
|
|
42
45
|
var prefix = usePrefix.usePrefix();
|
|
46
|
+
var tooltipClasses = cx__default["default"](wrapperClasses, "".concat(prefix, "--icon-tooltip"));
|
|
43
47
|
return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
44
48
|
align: align,
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
closeOnActivation: closeOnActivation,
|
|
50
|
+
className: tooltipClasses,
|
|
47
51
|
defaultOpen: defaultOpen,
|
|
48
52
|
enterDelayMs: enterDelayMs,
|
|
49
53
|
label: label,
|
|
@@ -71,6 +75,11 @@ IconButton.propTypes = {
|
|
|
71
75
|
*/
|
|
72
76
|
className: PropTypes__default["default"].string,
|
|
73
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Determines whether the tooltip should close when inner content is activated (click, Enter or Space)
|
|
80
|
+
*/
|
|
81
|
+
closeOnActivation: PropTypes__default["default"].bool,
|
|
82
|
+
|
|
74
83
|
/**
|
|
75
84
|
* Specify whether the tooltip should be open when it first renders
|
|
76
85
|
*/
|
|
@@ -102,7 +111,12 @@ IconButton.propTypes = {
|
|
|
102
111
|
/**
|
|
103
112
|
* Specify the size of the Button. Defaults to `md`.
|
|
104
113
|
*/
|
|
105
|
-
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
|
|
114
|
+
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg']),
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Specify an optional className to be added to your Tooltip wrapper
|
|
118
|
+
*/
|
|
119
|
+
wrapperClasses: PropTypes__default["default"].string
|
|
106
120
|
};
|
|
107
121
|
|
|
108
122
|
exports.IconButton = IconButton;
|
|
@@ -21,6 +21,8 @@ var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropI
|
|
|
21
21
|
var wrapFocus = require('../../internal/wrapFocus.js');
|
|
22
22
|
var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
|
|
23
23
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
24
|
+
var match = require('../../internal/keyboard/match.js');
|
|
25
|
+
var keys = require('../../internal/keyboard/keys.js');
|
|
24
26
|
|
|
25
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
28
|
|
|
@@ -80,11 +82,11 @@ var Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_re
|
|
|
80
82
|
|
|
81
83
|
function handleKeyDown(evt) {
|
|
82
84
|
if (open) {
|
|
83
|
-
if (evt.
|
|
85
|
+
if (match.match(evt, keys.Escape)) {
|
|
84
86
|
onRequestClose(evt);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
if (evt.
|
|
89
|
+
if (match.match(evt, keys.Enter) && shouldSubmitOnEnter && !isCloseButton(evt.target)) {
|
|
88
90
|
onRequestSubmit(evt);
|
|
89
91
|
}
|
|
90
92
|
}
|
|
@@ -336,6 +336,14 @@ var FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(fu
|
|
|
336
336
|
if (match.match(event, keys.Tab)) {
|
|
337
337
|
handleOnMenuChange(false);
|
|
338
338
|
}
|
|
339
|
+
|
|
340
|
+
if (match.match(event, keys.Home)) {
|
|
341
|
+
event.target.setSelectionRange(0, 0);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (match.match(event, keys.End)) {
|
|
345
|
+
event.target.setSelectionRange(event.target.value.length, event.target.value.length);
|
|
346
|
+
}
|
|
339
347
|
},
|
|
340
348
|
onFocus: function onFocus() {
|
|
341
349
|
setInputFocused(true);
|
|
@@ -344,7 +344,8 @@ var MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function Mul
|
|
|
344
344
|
type: "button",
|
|
345
345
|
className: "".concat(prefix, "--list-box__field"),
|
|
346
346
|
disabled: disabled,
|
|
347
|
-
"aria-disabled": disabled || readOnly
|
|
347
|
+
"aria-disabled": disabled || readOnly,
|
|
348
|
+
"aria-describedby": !inline && !invalid && !warn && helperText ? helperId : undefined
|
|
348
349
|
}, toggleButtonProps, {
|
|
349
350
|
ref: mergedRef,
|
|
350
351
|
onKeyDown: onKeyDown
|
|
@@ -150,6 +150,10 @@ var NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function Num
|
|
|
150
150
|
ariaDescribedBy = normalizedProps.warnId;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
if (!normalizedProps.validation) {
|
|
154
|
+
ariaDescribedBy = helperText ? normalizedProps.helperId : undefined;
|
|
155
|
+
}
|
|
156
|
+
|
|
153
157
|
function handleOnChange(event) {
|
|
154
158
|
if (disabled) {
|
|
155
159
|
return;
|
|
@@ -284,6 +288,7 @@ var NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function Num
|
|
|
284
288
|
}))), isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
|
|
285
289
|
className: "".concat(prefix, "--number-input__divider")
|
|
286
290
|
}), normalizedProps.validation ? normalizedProps.validation : /*#__PURE__*/React__default["default"].createElement(HelperText, {
|
|
291
|
+
id: normalizedProps.helperId,
|
|
287
292
|
disabled: disabled,
|
|
288
293
|
description: helperText
|
|
289
294
|
})));
|
|
@@ -452,12 +457,14 @@ Label.propTypes = {
|
|
|
452
457
|
|
|
453
458
|
function HelperText(_ref3) {
|
|
454
459
|
var disabled = _ref3.disabled,
|
|
455
|
-
description = _ref3.description
|
|
460
|
+
description = _ref3.description,
|
|
461
|
+
id = _ref3.id;
|
|
456
462
|
var prefix = usePrefix.usePrefix();
|
|
457
463
|
var className = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
458
464
|
|
|
459
465
|
if (description) {
|
|
460
466
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
467
|
+
id: id,
|
|
461
468
|
className: className
|
|
462
469
|
}, description);
|
|
463
470
|
}
|
|
@@ -467,7 +474,8 @@ function HelperText(_ref3) {
|
|
|
467
474
|
|
|
468
475
|
HelperText.propTypes = {
|
|
469
476
|
description: PropTypes__default["default"].node,
|
|
470
|
-
disabled: PropTypes__default["default"].bool
|
|
477
|
+
disabled: PropTypes__default["default"].bool,
|
|
478
|
+
id: PropTypes__default["default"].string
|
|
471
479
|
};
|
|
472
480
|
/**
|
|
473
481
|
* Determine if the given value is invalid based on the given max, min and
|
|
@@ -42,6 +42,7 @@ function ProgressBar(_ref) {
|
|
|
42
42
|
value = _ref.value;
|
|
43
43
|
var labelId = useId.useId('progress-bar');
|
|
44
44
|
var helperId = useId.useId('progress-bar-helper');
|
|
45
|
+
var helperTextId = useId.useId('progress-bar-helper-text');
|
|
45
46
|
var prefix = usePrefix.usePrefix();
|
|
46
47
|
var isFinished = status === 'finished';
|
|
47
48
|
var isError = status === 'error';
|
|
@@ -106,6 +107,7 @@ function ProgressBar(_ref) {
|
|
|
106
107
|
"aria-busy": !isFinished,
|
|
107
108
|
"aria-invalid": isError,
|
|
108
109
|
"aria-labelledby": labelId,
|
|
110
|
+
"aria-describedby": helperText ? helperTextId : undefined,
|
|
109
111
|
"aria-valuemin": !indeterminate ? 0 : null,
|
|
110
112
|
"aria-valuemax": !indeterminate ? max : null,
|
|
111
113
|
"aria-valuenow": !indeterminate ? cappedValue : null
|
|
@@ -113,6 +115,7 @@ function ProgressBar(_ref) {
|
|
|
113
115
|
className: "".concat(prefix, "--progress-bar__bar"),
|
|
114
116
|
ref: ref
|
|
115
117
|
})), helperText && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
118
|
+
id: helperTextId,
|
|
116
119
|
className: "".concat(prefix, "--progress-bar__helper-text")
|
|
117
120
|
}, helperText, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
118
121
|
className: "".concat(prefix, "--visually-hidden"),
|
|
@@ -131,7 +131,8 @@ var RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef(functio
|
|
|
131
131
|
className: fieldsetClasses,
|
|
132
132
|
disabled: disabled,
|
|
133
133
|
"data-invalid": invalid ? true : undefined,
|
|
134
|
-
"aria-readonly": readOnly
|
|
134
|
+
"aria-readonly": readOnly,
|
|
135
|
+
"aria-describedby": showHelper && helperText ? helperId : undefined
|
|
135
136
|
}, rest), legendText && /*#__PURE__*/React__default["default"].createElement(index.Legend, {
|
|
136
137
|
className: "".concat(prefix, "--label")
|
|
137
138
|
}, legendText), getRadioButtons()), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -59,7 +59,7 @@ var RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Radio
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
return /*#__PURE__*/React__default["default"].createElement(
|
|
62
|
+
return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
63
63
|
checked: checked,
|
|
64
64
|
className: "".concat(prefix, "--tile-input"),
|
|
65
65
|
disabled: disabled,
|
|
@@ -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;
|
|
@@ -19,6 +19,7 @@ var index = require('../FeatureFlags/index.js');
|
|
|
19
19
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
20
20
|
require('../FluidForm/FluidForm.js');
|
|
21
21
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
22
|
+
var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
|
|
22
23
|
|
|
23
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
25
|
|
|
@@ -27,6 +28,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
27
28
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
28
29
|
|
|
29
30
|
var _excluded = ["className", "id", "inline", "labelText", "disabled", "children", "noLabel", "hideLabel", "invalid", "invalidText", "helperText", "light", "readOnly", "size", "warn", "warnText"];
|
|
31
|
+
var getInstanceId = setupGetInstanceId["default"]();
|
|
30
32
|
var Select = /*#__PURE__*/React__default["default"].forwardRef(function Select(_ref, ref) {
|
|
31
33
|
var _classNames, _classNames2, _classNames3;
|
|
32
34
|
|
|
@@ -66,6 +68,9 @@ var Select = /*#__PURE__*/React__default["default"].forwardRef(function Select(_
|
|
|
66
68
|
isFocused = _useState2[0],
|
|
67
69
|
setIsFocused = _useState2[1];
|
|
68
70
|
|
|
71
|
+
var _useRef = React.useRef(getInstanceId()),
|
|
72
|
+
selectInstanceId = _useRef.current;
|
|
73
|
+
|
|
69
74
|
var selectClasses = cx__default["default"]((_classNames = {}, _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--select"), true), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--select--inline"), inline), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--select--light"), light), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--select--invalid"), invalid), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--select--disabled"), disabled), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--select--readonly"), readOnly), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--select--warning"), warn), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--select--fluid--invalid"), isFluid && invalid), _rollupPluginBabelHelpers.defineProperty(_classNames, "".concat(prefix, "--select--fluid--focus"), isFluid && isFocused), _classNames), [enabled ? null : className]);
|
|
70
75
|
var labelClasses = cx__default["default"]("".concat(prefix, "--label"), (_classNames2 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames2, "".concat(prefix, "--visually-hidden"), hideLabel), _rollupPluginBabelHelpers.defineProperty(_classNames2, "".concat(prefix, "--label--disabled"), disabled), _classNames2));
|
|
71
76
|
var inputClasses = cx__default["default"]((_classNames3 = {}, _rollupPluginBabelHelpers.defineProperty(_classNames3, "".concat(prefix, "--select-input"), true), _rollupPluginBabelHelpers.defineProperty(_classNames3, "".concat(prefix, "--select-input--").concat(size), size), _classNames3));
|
|
@@ -86,13 +91,17 @@ var Select = /*#__PURE__*/React__default["default"].forwardRef(function Select(_
|
|
|
86
91
|
id: errorId
|
|
87
92
|
}, errorText) : null;
|
|
88
93
|
var helperTextClasses = cx__default["default"]("".concat(prefix, "--form__helper-text"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(prefix, "--form__helper-text--disabled"), disabled));
|
|
94
|
+
var helperId = !helperText ? undefined : "select-helper-text-".concat(selectInstanceId);
|
|
89
95
|
var helper = helperText ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
96
|
+
id: helperId,
|
|
90
97
|
className: helperTextClasses
|
|
91
98
|
}, helperText) : null;
|
|
92
99
|
var ariaProps = {};
|
|
93
100
|
|
|
94
101
|
if (invalid) {
|
|
95
102
|
ariaProps['aria-describedby'] = errorId;
|
|
103
|
+
} else if (!inline && !isFluid) {
|
|
104
|
+
ariaProps['aria-describedby'] = helper ? helperId : undefined;
|
|
96
105
|
}
|
|
97
106
|
|
|
98
107
|
var handleFocus = function handleFocus(evt) {
|