@carbon/react 1.62.1 → 1.63.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +836 -836
- package/es/components/Checkbox/Checkbox.js +2 -3
- package/es/components/CheckboxGroup/CheckboxGroup.js +2 -3
- package/es/components/ComboBox/ComboBox.d.ts +10 -6
- package/es/components/ComboBox/ComboBox.js +14 -4
- package/es/components/ComboButton/index.d.ts +9 -6
- package/es/components/ComboButton/index.js +5 -0
- package/es/components/DataTable/DataTable.d.ts +25 -11
- package/es/components/DataTable/DataTable.js +6 -1
- package/es/components/DataTable/TableBatchActions.d.ts +2 -2
- package/es/components/DataTable/TableHeader.d.ts +7 -13
- package/es/components/DataTable/TableSelectRow.js +3 -2
- package/es/components/DataTable/TableToolbarSearch.d.ts +5 -2
- package/es/components/DataTable/TableToolbarSearch.js +7 -4
- package/es/components/DatePickerInput/DatePickerInput.js +2 -3
- package/es/components/Dropdown/Dropdown.d.ts +2 -6
- package/es/components/Dropdown/Dropdown.js +3 -6
- package/es/components/FluidSearch/FluidSearch.Skeleton.js +40 -0
- package/es/components/FluidSearch/FluidSearch.js +96 -0
- package/es/components/FormGroup/FormGroup.d.ts +9 -1
- package/es/components/FormGroup/FormGroup.js +8 -1
- package/es/components/ListBox/ListBoxMenuIcon.d.ts +2 -7
- package/es/components/ListBox/ListBoxSelection.d.ts +8 -9
- package/es/components/ListBox/ListBoxSelection.js +5 -0
- package/es/components/Modal/Modal.js +2 -3
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +10 -5
- package/es/components/MultiSelect/FilterableMultiSelect.js +20 -8
- package/es/components/MultiSelect/MultiSelect.d.ts +2 -2
- package/es/components/MultiSelect/MultiSelect.js +11 -11
- package/es/components/NumberInput/NumberInput.d.ts +8 -7
- package/es/components/NumberInput/NumberInput.js +5 -0
- package/es/components/Pagination/experimental/PageSelector.js +2 -3
- package/es/components/PaginationNav/PaginationNav.d.ts +13 -6
- package/es/components/PaginationNav/PaginationNav.js +5 -0
- package/es/components/ProgressIndicator/ProgressIndicator.d.ts +12 -6
- package/es/components/ProgressIndicator/ProgressIndicator.js +5 -0
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +2 -5
- package/es/components/Select/Select.js +3 -6
- package/es/components/Slider/Slider.d.ts +11 -9
- package/es/components/Slider/Slider.js +6 -1
- package/es/components/Tag/DismissibleTag.js +2 -3
- package/es/components/Tag/OperationalTag.js +2 -3
- package/es/components/Tag/SelectableTag.js +2 -3
- package/es/components/Tag/Tag.js +3 -5
- package/es/components/TextArea/TextArea.js +32 -6
- package/es/components/TextInput/ControlledPasswordInput.js +3 -6
- package/es/components/TextInput/TextInput.js +29 -2
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/es/internal/Selection.js +1 -1
- package/es/internal/useAnnouncer.js +8 -3
- package/es/types/common.d.ts +6 -1
- package/lib/components/Checkbox/Checkbox.js +2 -3
- package/lib/components/CheckboxGroup/CheckboxGroup.js +2 -3
- package/lib/components/ComboBox/ComboBox.d.ts +10 -6
- package/lib/components/ComboBox/ComboBox.js +14 -4
- package/lib/components/ComboButton/index.d.ts +9 -6
- package/lib/components/ComboButton/index.js +5 -0
- package/lib/components/DataTable/DataTable.d.ts +25 -11
- package/lib/components/DataTable/DataTable.js +6 -1
- package/lib/components/DataTable/TableBatchActions.d.ts +2 -2
- package/lib/components/DataTable/TableHeader.d.ts +7 -13
- package/lib/components/DataTable/TableSelectRow.js +2 -1
- package/lib/components/DataTable/TableToolbarSearch.d.ts +5 -2
- package/lib/components/DataTable/TableToolbarSearch.js +6 -3
- package/lib/components/DatePickerInput/DatePickerInput.js +2 -3
- package/lib/components/Dropdown/Dropdown.d.ts +2 -6
- package/lib/components/Dropdown/Dropdown.js +2 -5
- package/lib/components/FluidSearch/FluidSearch.Skeleton.js +50 -0
- package/lib/components/FluidSearch/FluidSearch.js +106 -0
- package/lib/components/FormGroup/FormGroup.d.ts +9 -1
- package/lib/components/FormGroup/FormGroup.js +8 -1
- package/lib/components/ListBox/ListBoxMenuIcon.d.ts +2 -7
- package/lib/components/ListBox/ListBoxSelection.d.ts +8 -9
- package/lib/components/ListBox/ListBoxSelection.js +5 -0
- package/lib/components/Modal/Modal.js +2 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +10 -5
- package/lib/components/MultiSelect/FilterableMultiSelect.js +19 -7
- package/lib/components/MultiSelect/MultiSelect.d.ts +2 -2
- package/lib/components/MultiSelect/MultiSelect.js +10 -10
- package/lib/components/NumberInput/NumberInput.d.ts +8 -7
- package/lib/components/NumberInput/NumberInput.js +5 -0
- package/lib/components/Pagination/experimental/PageSelector.js +2 -3
- package/lib/components/PaginationNav/PaginationNav.d.ts +13 -6
- package/lib/components/PaginationNav/PaginationNav.js +5 -0
- package/lib/components/ProgressIndicator/ProgressIndicator.d.ts +12 -6
- package/lib/components/ProgressIndicator/ProgressIndicator.js +5 -0
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +2 -5
- package/lib/components/Select/Select.js +2 -5
- package/lib/components/Slider/Slider.d.ts +11 -9
- package/lib/components/Slider/Slider.js +6 -1
- package/lib/components/Tag/DismissibleTag.js +2 -3
- package/lib/components/Tag/OperationalTag.js +2 -3
- package/lib/components/Tag/SelectableTag.js +2 -3
- package/lib/components/Tag/Tag.js +3 -5
- package/lib/components/TextArea/TextArea.js +32 -6
- package/lib/components/TextInput/ControlledPasswordInput.js +2 -5
- package/lib/components/TextInput/TextInput.js +28 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -0
- package/lib/internal/Selection.js +1 -1
- package/lib/internal/useAnnouncer.js +8 -3
- package/lib/types/common.d.ts +6 -1
- package/package.json +18 -18
|
@@ -38,9 +38,10 @@ const TableSelectRow = _ref => {
|
|
|
38
38
|
className
|
|
39
39
|
} = _ref;
|
|
40
40
|
const prefix = usePrefix.usePrefix();
|
|
41
|
+
const uniqueNameId = React.useId();
|
|
41
42
|
const selectionInputProps = {
|
|
42
43
|
id,
|
|
43
|
-
name,
|
|
44
|
+
name: name ? name : uniqueNameId,
|
|
44
45
|
onClick: onSelect,
|
|
45
46
|
onChange,
|
|
46
47
|
checked,
|
|
@@ -7,11 +7,14 @@
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { ChangeEvent, FocusEvent, ReactNode } from 'react';
|
|
9
9
|
import { SearchProps } from '../Search';
|
|
10
|
-
import {
|
|
10
|
+
import { TranslateWithId } from '../../types/common';
|
|
11
|
+
/**
|
|
12
|
+
* Message ids that will be passed to translateWithId().
|
|
13
|
+
*/
|
|
11
14
|
export type TableToolbarTranslationKey = 'carbon.table.toolbar.search.label' | 'carbon.table.toolbar.search.placeholder';
|
|
12
15
|
type ExcludedInheritedProps = 'defaultValue' | 'labelText' | 'onBlur' | 'onChange' | 'onExpand' | 'onFocus' | 'tabIndex';
|
|
13
16
|
export type TableToolbarSearchHandleExpand = (event: FocusEvent<HTMLInputElement>, newValue?: boolean) => void;
|
|
14
|
-
export interface TableToolbarSearchProps extends Omit<SearchProps, ExcludedInheritedProps>,
|
|
17
|
+
export interface TableToolbarSearchProps extends Omit<SearchProps, ExcludedInheritedProps>, TranslateWithId<TableToolbarTranslationKey> {
|
|
15
18
|
/**
|
|
16
19
|
* Specifies if the search should initially render in an expanded state
|
|
17
20
|
*/
|
|
@@ -15,7 +15,7 @@ var PropTypes = require('prop-types');
|
|
|
15
15
|
var React = require('react');
|
|
16
16
|
var Search = require('../Search/Search.js');
|
|
17
17
|
require('../Search/Search.Skeleton.js');
|
|
18
|
-
var
|
|
18
|
+
var useId = require('../../internal/useId.js');
|
|
19
19
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
20
20
|
var noopFn = require('../../internal/noopFn.js');
|
|
21
21
|
|
|
@@ -25,7 +25,10 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
25
25
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
26
26
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Message ids that will be passed to translateWithId().
|
|
30
|
+
*/
|
|
31
|
+
|
|
29
32
|
const translationKeys = {
|
|
30
33
|
'carbon.table.toolbar.search.label': 'Filter table',
|
|
31
34
|
'carbon.table.toolbar.search.placeholder': 'Filter table'
|
|
@@ -61,7 +64,7 @@ const TableToolbarSearch = _ref => {
|
|
|
61
64
|
const [expandedState, setExpandedState] = React.useState(Boolean(defaultExpanded || defaultValue));
|
|
62
65
|
const expanded = controlled ? expandedProp : expandedState;
|
|
63
66
|
const [value, setValue] = React.useState(defaultValue || '');
|
|
64
|
-
const uniqueId =
|
|
67
|
+
const uniqueId = useId.useId();
|
|
65
68
|
const [focusTarget, setFocusTarget] = React.useState(null);
|
|
66
69
|
const prefix = usePrefix.usePrefix();
|
|
67
70
|
React.useEffect(() => {
|
|
@@ -16,7 +16,7 @@ var React = require('react');
|
|
|
16
16
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
17
|
require('../FluidForm/FluidForm.js');
|
|
18
18
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
19
|
-
var
|
|
19
|
+
var useId = require('../../internal/useId.js');
|
|
20
20
|
require('../Text/index.js');
|
|
21
21
|
var Text = require('../Text/Text.js');
|
|
22
22
|
|
|
@@ -26,7 +26,6 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
26
26
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
27
27
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
28
28
|
|
|
29
|
-
const getInstanceId = setupGetInstanceId["default"]();
|
|
30
29
|
const DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(function DatePickerInput(props, ref) {
|
|
31
30
|
const {
|
|
32
31
|
datePickerType,
|
|
@@ -52,7 +51,7 @@ const DatePickerInput = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
52
51
|
const {
|
|
53
52
|
isFluid
|
|
54
53
|
} = React.useContext(FormContext.FormContext);
|
|
55
|
-
const datePickerInputInstanceId =
|
|
54
|
+
const datePickerInputInstanceId = useId.useId();
|
|
56
55
|
const datePickerInputProps = {
|
|
57
56
|
id,
|
|
58
57
|
onChange: event => {
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
import React, { ReactNode } from 'react';
|
|
8
8
|
import { UseSelectProps } from 'downshift';
|
|
9
9
|
import { type ListBoxMenuIconTranslationKey, ListBoxSize, ListBoxType } from '../ListBox';
|
|
10
|
-
import { ReactAttr } from '../../types/common';
|
|
10
|
+
import { TranslateWithId, ReactAttr } from '../../types/common';
|
|
11
11
|
type ExcludedAttributes = 'id' | 'onChange';
|
|
12
12
|
export interface OnChangeData<ItemType> {
|
|
13
13
|
selectedItem: ItemType | null;
|
|
14
14
|
}
|
|
15
|
-
export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes> {
|
|
15
|
+
export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes>, TranslateWithId<ListBoxMenuIconTranslationKey> {
|
|
16
16
|
/**
|
|
17
17
|
* Specify a label to be read by screen readers on the container node
|
|
18
18
|
* 'aria-label' of the ListBox component.
|
|
@@ -123,10 +123,6 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
123
123
|
* visiting this control
|
|
124
124
|
*/
|
|
125
125
|
titleText?: ReactNode;
|
|
126
|
-
/**
|
|
127
|
-
* Callback function for translating ListBoxMenuIcon SVG title
|
|
128
|
-
*/
|
|
129
|
-
translateWithId?(messageId: ListBoxMenuIconTranslationKey, args?: Record<string, unknown>): string;
|
|
130
126
|
/**
|
|
131
127
|
* The dropdown type, `default` or `inline`
|
|
132
128
|
*/
|
|
@@ -21,7 +21,7 @@ var deprecate = require('../../prop-types/deprecate.js');
|
|
|
21
21
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
22
22
|
require('../FluidForm/FluidForm.js');
|
|
23
23
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
24
|
-
var
|
|
24
|
+
var useId = require('../../internal/useId.js');
|
|
25
25
|
var react = require('@floating-ui/react');
|
|
26
26
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
27
27
|
|
|
@@ -31,7 +31,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
31
31
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
32
32
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
33
33
|
|
|
34
|
-
const getInstanceId = setupGetInstanceId["default"]();
|
|
35
34
|
const {
|
|
36
35
|
ToggleButtonKeyDownArrowDown,
|
|
37
36
|
ToggleButtonKeyDownArrowUp,
|
|
@@ -135,9 +134,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
135
134
|
return isObject && 'disabled' in item && item.disabled === true;
|
|
136
135
|
}
|
|
137
136
|
};
|
|
138
|
-
const
|
|
139
|
-
current: dropdownInstanceId
|
|
140
|
-
} = React.useRef(getInstanceId());
|
|
137
|
+
const dropdownInstanceId = useId.useId();
|
|
141
138
|
function stateReducer(state, actionAndChanges) {
|
|
142
139
|
const {
|
|
143
140
|
changes,
|
|
@@ -0,0 +1,50 @@
|
|
|
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 _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var PropTypes = require('prop-types');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var cx = require('classnames');
|
|
16
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
|
+
var FormContext = require('../FluidForm/FormContext.js');
|
|
18
|
+
|
|
19
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
+
|
|
21
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
22
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
24
|
+
|
|
25
|
+
function FluidSearchSkeleton(_ref) {
|
|
26
|
+
let {
|
|
27
|
+
className,
|
|
28
|
+
...other
|
|
29
|
+
} = _ref;
|
|
30
|
+
const prefix = usePrefix.usePrefix();
|
|
31
|
+
return /*#__PURE__*/React__default["default"].createElement(FormContext.FormContext.Provider, {
|
|
32
|
+
value: {
|
|
33
|
+
isFluid: true
|
|
34
|
+
}
|
|
35
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
36
|
+
className: cx__default["default"](`${prefix}--form-item ${prefix}--text-input--fluid__skeleton`, className)
|
|
37
|
+
}, other), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
38
|
+
className: `${prefix}--label ${prefix}--skeleton`
|
|
39
|
+
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
40
|
+
className: `${prefix}--skeleton ${prefix}--text-input`
|
|
41
|
+
})));
|
|
42
|
+
}
|
|
43
|
+
FluidSearchSkeleton.propTypes = {
|
|
44
|
+
/**
|
|
45
|
+
* Specify an optional className to be applied to the outer FluidForm wrapper
|
|
46
|
+
*/
|
|
47
|
+
className: PropTypes__default["default"].string
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports["default"] = FluidSearchSkeleton;
|
|
@@ -0,0 +1,106 @@
|
|
|
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 _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var PropTypes = require('prop-types');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var cx = require('classnames');
|
|
16
|
+
var Search = require('../Search/Search.js');
|
|
17
|
+
require('../Search/Search.Skeleton.js');
|
|
18
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
|
+
var FormContext = require('../FluidForm/FormContext.js');
|
|
20
|
+
|
|
21
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
|
+
|
|
23
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
24
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
26
|
+
|
|
27
|
+
const FluidSearch = /*#__PURE__*/React__default["default"].forwardRef(function FluidSearch(_ref, ref) {
|
|
28
|
+
let {
|
|
29
|
+
className,
|
|
30
|
+
...other
|
|
31
|
+
} = _ref;
|
|
32
|
+
const prefix = usePrefix.usePrefix();
|
|
33
|
+
const classNames = cx__default["default"](`${prefix}--search--fluid`, className);
|
|
34
|
+
return /*#__PURE__*/React__default["default"].createElement(FormContext.FormContext.Provider, {
|
|
35
|
+
value: {
|
|
36
|
+
isFluid: true
|
|
37
|
+
}
|
|
38
|
+
}, /*#__PURE__*/React__default["default"].createElement(Search["default"], _rollupPluginBabelHelpers["extends"]({
|
|
39
|
+
ref: ref,
|
|
40
|
+
className: classNames
|
|
41
|
+
}, other)));
|
|
42
|
+
});
|
|
43
|
+
FluidSearch.propTypes = {
|
|
44
|
+
/**
|
|
45
|
+
* Specify an optional value for the `autocomplete` property on the underlying
|
|
46
|
+
* `<input>`, defaults to "off"
|
|
47
|
+
*/
|
|
48
|
+
autoComplete: PropTypes__default["default"].string,
|
|
49
|
+
/**
|
|
50
|
+
* Specify an optional className to be applied to the container node
|
|
51
|
+
*/
|
|
52
|
+
className: PropTypes__default["default"].string,
|
|
53
|
+
/**
|
|
54
|
+
* Specify a label to be read by screen readers on the "close" button
|
|
55
|
+
*/
|
|
56
|
+
closeButtonLabelText: PropTypes__default["default"].string,
|
|
57
|
+
/**
|
|
58
|
+
* Optionally provide the default value of the `<input>`
|
|
59
|
+
*/
|
|
60
|
+
defaultValue: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]),
|
|
61
|
+
/**
|
|
62
|
+
* Specify whether the `<input>` should be disabled
|
|
63
|
+
*/
|
|
64
|
+
disabled: PropTypes__default["default"].bool,
|
|
65
|
+
/**
|
|
66
|
+
* Specify a custom `id` for the input
|
|
67
|
+
*/
|
|
68
|
+
id: PropTypes__default["default"].string,
|
|
69
|
+
/**
|
|
70
|
+
* Provide the label text for the Search icon
|
|
71
|
+
*/
|
|
72
|
+
labelText: PropTypes__default["default"].node.isRequired,
|
|
73
|
+
/**
|
|
74
|
+
* Optional callback called when the search value changes.
|
|
75
|
+
*/
|
|
76
|
+
onChange: PropTypes__default["default"].func,
|
|
77
|
+
/**
|
|
78
|
+
* Optional callback called when the search value is cleared.
|
|
79
|
+
*/
|
|
80
|
+
onClear: PropTypes__default["default"].func,
|
|
81
|
+
/**
|
|
82
|
+
* Provide a handler that is invoked on the key down event for the input
|
|
83
|
+
*/
|
|
84
|
+
onKeyDown: PropTypes__default["default"].func,
|
|
85
|
+
/**
|
|
86
|
+
* Provide an optional placeholder text for the Search.
|
|
87
|
+
* Note: if the label and placeholder differ,
|
|
88
|
+
* VoiceOver on Mac will read both
|
|
89
|
+
*/
|
|
90
|
+
placeholder: PropTypes__default["default"].string,
|
|
91
|
+
/**
|
|
92
|
+
* Specify the role for the underlying `<input>`, defaults to `searchbox`
|
|
93
|
+
*/
|
|
94
|
+
role: PropTypes__default["default"].string,
|
|
95
|
+
/**
|
|
96
|
+
* Optional prop to specify the type of the `<input>`
|
|
97
|
+
*/
|
|
98
|
+
type: PropTypes__default["default"].string,
|
|
99
|
+
/**
|
|
100
|
+
* Specify the value of the `<input>`
|
|
101
|
+
*/
|
|
102
|
+
value: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number])
|
|
103
|
+
};
|
|
104
|
+
var FluidSearch$1 = FluidSearch;
|
|
105
|
+
|
|
106
|
+
exports["default"] = FluidSearch$1;
|
|
@@ -16,6 +16,10 @@ export interface FormGroupProps extends ReactAttr<HTMLFieldSetElement> {
|
|
|
16
16
|
* Provide a custom className to be applied to the containing <fieldset> node
|
|
17
17
|
*/
|
|
18
18
|
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Specify whether the FormGroup should be disabled
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
19
23
|
/**
|
|
20
24
|
* Specify whether the <FormGroup> is invalid
|
|
21
25
|
*/
|
|
@@ -39,7 +43,7 @@ export interface FormGroupProps extends ReactAttr<HTMLFieldSetElement> {
|
|
|
39
43
|
messageText?: string;
|
|
40
44
|
}
|
|
41
45
|
declare const FormGroup: {
|
|
42
|
-
({ legendId, legendText, invalid, children, className, message, messageText, ...rest }: FormGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
({ disabled, legendId, legendText, invalid, children, className, message, messageText, ...rest }: FormGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
43
47
|
propTypes: {
|
|
44
48
|
/**
|
|
45
49
|
* Provide the children form elements to be rendered inside of the <fieldset>
|
|
@@ -49,6 +53,10 @@ declare const FormGroup: {
|
|
|
49
53
|
* Provide a custom className to be applied to the containing <fieldset> node
|
|
50
54
|
*/
|
|
51
55
|
className: PropTypes.Requireable<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Specify whether the FormGroup should be disabled
|
|
58
|
+
*/
|
|
59
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
52
60
|
/**
|
|
53
61
|
* Specify whether the <FormGroup> is invalid
|
|
54
62
|
*/
|
|
@@ -23,6 +23,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
23
23
|
|
|
24
24
|
const FormGroup = _ref => {
|
|
25
25
|
let {
|
|
26
|
+
disabled = false,
|
|
26
27
|
legendId,
|
|
27
28
|
legendText,
|
|
28
29
|
invalid = false,
|
|
@@ -34,7 +35,9 @@ const FormGroup = _ref => {
|
|
|
34
35
|
} = _ref;
|
|
35
36
|
const prefix = usePrefix.usePrefix();
|
|
36
37
|
const classNamesFieldset = cx__default["default"](`${prefix}--fieldset`, className);
|
|
37
|
-
return /*#__PURE__*/React__default["default"].createElement("fieldset", _rollupPluginBabelHelpers["extends"]({
|
|
38
|
+
return /*#__PURE__*/React__default["default"].createElement("fieldset", _rollupPluginBabelHelpers["extends"]({
|
|
39
|
+
disabled: disabled
|
|
40
|
+
}, invalid && {
|
|
38
41
|
'data-invalid': ''
|
|
39
42
|
}, {
|
|
40
43
|
className: classNamesFieldset
|
|
@@ -56,6 +59,10 @@ FormGroup.propTypes = {
|
|
|
56
59
|
* Provide a custom className to be applied to the containing <fieldset> node
|
|
57
60
|
*/
|
|
58
61
|
className: PropTypes__default["default"].string,
|
|
62
|
+
/**
|
|
63
|
+
* Specify whether the FormGroup should be disabled
|
|
64
|
+
*/
|
|
65
|
+
disabled: PropTypes__default["default"].bool,
|
|
59
66
|
/**
|
|
60
67
|
* Specify whether the <FormGroup> is invalid
|
|
61
68
|
*/
|
|
@@ -5,19 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
+
import { TranslateWithId } from '../../types/common';
|
|
8
9
|
export type ListBoxMenuIconTranslationKey = 'close.menu' | 'open.menu';
|
|
9
|
-
export interface ListBoxMenuIconProps {
|
|
10
|
+
export interface ListBoxMenuIconProps extends TranslateWithId<ListBoxMenuIconTranslationKey> {
|
|
10
11
|
/**
|
|
11
12
|
* Specify whether the menu is currently open, which will influence the
|
|
12
13
|
* direction of the menu icon
|
|
13
14
|
*/
|
|
14
15
|
isOpen: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* i18n hook used to provide the appropriate description for the given menu
|
|
17
|
-
* icon. This function takes in a ListBoxMenuIconTranslationKey and should
|
|
18
|
-
* return a string message for that given message id.
|
|
19
|
-
*/
|
|
20
|
-
translateWithId?(messageId: ListBoxMenuIconTranslationKey, args?: Record<string, unknown>): string;
|
|
21
16
|
}
|
|
22
17
|
export type ListBoxMenuIconComponent = React.FC<ListBoxMenuIconProps>;
|
|
23
18
|
/**
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { KeyboardEvent, MouseEvent } from 'react';
|
|
9
|
-
|
|
9
|
+
import { TranslateWithId } from '../../types/common';
|
|
10
|
+
export interface ListBoxSelectionProps extends TranslateWithId<TranslationKey> {
|
|
10
11
|
/**
|
|
11
12
|
* Specify a function to be invoked when a user interacts with the clear
|
|
12
13
|
* selection element.
|
|
@@ -30,18 +31,16 @@ export interface ListBoxSelectionProps {
|
|
|
30
31
|
* whether the selection should display a badge or a single clear icon.
|
|
31
32
|
*/
|
|
32
33
|
selectionCount?: number;
|
|
33
|
-
/**
|
|
34
|
-
* i18n hook used to provide the appropriate description for the given menu
|
|
35
|
-
* icon. This function takes in an id defined in `translationIds` and should
|
|
36
|
-
* return a string message for that given message id.
|
|
37
|
-
*/
|
|
38
|
-
translateWithId?(messageId: string, args?: Record<string, unknown>): string;
|
|
39
34
|
}
|
|
40
35
|
export type ListBoxSelectionComponent = React.FC<ListBoxSelectionProps>;
|
|
41
36
|
export declare const translationIds: {
|
|
42
|
-
'clear.all':
|
|
43
|
-
'clear.selection':
|
|
37
|
+
readonly 'clear.all': "clear.all";
|
|
38
|
+
readonly 'clear.selection': "clear.selection";
|
|
44
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Message ids that will be passed to translateWithId().
|
|
42
|
+
*/
|
|
43
|
+
type TranslationKey = keyof typeof translationIds;
|
|
45
44
|
/**
|
|
46
45
|
* `ListBoxSelection` is used to provide controls for clearing a selection, in
|
|
47
46
|
* addition to conditionally rendering a badge if the control has more than one
|
|
@@ -26,6 +26,11 @@ const translationIds = {
|
|
|
26
26
|
'clear.all': 'clear.all',
|
|
27
27
|
'clear.selection': 'clear.selection'
|
|
28
28
|
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Message ids that will be passed to translateWithId().
|
|
32
|
+
*/
|
|
33
|
+
|
|
29
34
|
const defaultTranslations = {
|
|
30
35
|
[translationIds['clear.all']]: 'Clear all selected items',
|
|
31
36
|
[translationIds['clear.selection']]: 'Clear selected item'
|
|
@@ -24,7 +24,7 @@ var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropI
|
|
|
24
24
|
var wrapFocus = require('../../internal/wrapFocus.js');
|
|
25
25
|
var debounce = require('lodash.debounce');
|
|
26
26
|
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
27
|
-
var
|
|
27
|
+
var useId = require('../../internal/useId.js');
|
|
28
28
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
29
29
|
var index$2 = require('../IconButton/index.js');
|
|
30
30
|
var noopFn = require('../../internal/noopFn.js');
|
|
@@ -42,7 +42,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
42
42
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
43
43
|
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
44
44
|
|
|
45
|
-
const getInstanceId = setupGetInstanceId["default"]();
|
|
46
45
|
const ModalSizes = ['xs', 'sm', 'md', 'lg'];
|
|
47
46
|
const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_ref, ref) {
|
|
48
47
|
let {
|
|
@@ -87,7 +86,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
|
|
|
87
86
|
const startTrap = React.useRef(null);
|
|
88
87
|
const endTrap = React.useRef(null);
|
|
89
88
|
const [isScrollable, setIsScrollable] = React.useState(false);
|
|
90
|
-
const modalInstanceId = `modal-${
|
|
89
|
+
const modalInstanceId = `modal-${useId.useId()}`;
|
|
91
90
|
const modalLabelId = `${prefix}--modal-header__label--${modalInstanceId}`;
|
|
92
91
|
const modalHeadingId = `${prefix}--modal-header__heading--${modalInstanceId}`;
|
|
93
92
|
const modalBodyId = `${prefix}--modal-body--${modalInstanceId}`;
|
|
@@ -7,7 +7,16 @@
|
|
|
7
7
|
import { type UseComboboxProps, type UseMultipleSelectionProps } from 'downshift';
|
|
8
8
|
import { ReactNode, FunctionComponent, ReactElement } from 'react';
|
|
9
9
|
import { type MultiSelectSortingProps } from './MultiSelectPropTypes';
|
|
10
|
-
|
|
10
|
+
import { TranslateWithId } from '../../types/common';
|
|
11
|
+
/**
|
|
12
|
+
* Message ids that will be passed to translateWithId().
|
|
13
|
+
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
14
|
+
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
15
|
+
* because those components aren't Typescript. (If you try, TranslationKey
|
|
16
|
+
* ends up just being defined as "string".)
|
|
17
|
+
*/
|
|
18
|
+
type TranslationKey = 'close.menu' | 'open.menu' | 'clear.all' | 'clear.selection';
|
|
19
|
+
export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSortingProps<ItemType>, TranslateWithId<TranslationKey> {
|
|
11
20
|
/**
|
|
12
21
|
* Specify a label to be read by screen readers on the container node
|
|
13
22
|
* @deprecated
|
|
@@ -154,10 +163,6 @@ export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSorting
|
|
|
154
163
|
* combobox via ARIA attributes.
|
|
155
164
|
*/
|
|
156
165
|
titleText?: ReactNode;
|
|
157
|
-
/**
|
|
158
|
-
* Callback function for translating ListBoxMenuIcon SVG title
|
|
159
|
-
*/
|
|
160
|
-
translateWithId?(messageId: string, args?: Record<string, unknown>): string;
|
|
161
166
|
type?: 'default' | 'inline';
|
|
162
167
|
/**
|
|
163
168
|
* Specify title to show title on hover
|
|
@@ -13,7 +13,7 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
13
13
|
var iconsReact = require('@carbon/icons-react');
|
|
14
14
|
var cx = require('classnames');
|
|
15
15
|
var Downshift = require('downshift');
|
|
16
|
-
var isEqual = require('
|
|
16
|
+
var isEqual = require('react-fast-compare');
|
|
17
17
|
var PropTypes = require('prop-types');
|
|
18
18
|
var React = require('react');
|
|
19
19
|
var filter = require('../ComboBox/tools/filter.js');
|
|
@@ -64,6 +64,15 @@ const {
|
|
|
64
64
|
DropdownKeyDownBackspace,
|
|
65
65
|
FunctionRemoveSelectedItem
|
|
66
66
|
} = Downshift.useMultipleSelection.stateChangeTypes;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Message ids that will be passed to translateWithId().
|
|
70
|
+
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
71
|
+
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
72
|
+
* because those components aren't Typescript. (If you try, TranslationKey
|
|
73
|
+
* ends up just being defined as "string".)
|
|
74
|
+
*/
|
|
75
|
+
|
|
67
76
|
const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function FilterableMultiSelect(_ref, ref) {
|
|
68
77
|
let {
|
|
69
78
|
autoAlign = false,
|
|
@@ -472,9 +481,13 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
472
481
|
setInputValue('');
|
|
473
482
|
}
|
|
474
483
|
}));
|
|
475
|
-
|
|
484
|
+
|
|
485
|
+
// Memoize the value of getMenuProps to avoid an infinite loop
|
|
486
|
+
const menuProps = React.useMemo(() => getMenuProps({
|
|
487
|
+
ref: autoAlign ? refs.setFloating : null
|
|
488
|
+
}, {
|
|
476
489
|
suppressRefError: true
|
|
477
|
-
});
|
|
490
|
+
}), [autoAlign, getMenuProps, refs.setFloating]);
|
|
478
491
|
const handleFocus = evt => {
|
|
479
492
|
if (evt?.target.classList.contains(`${prefix}--tag__close-icon`) || evt?.target.classList.contains(`${prefix}--list-box__selection`)) {
|
|
480
493
|
setIsFocused(false);
|
|
@@ -500,6 +513,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
500
513
|
disabled: disabled,
|
|
501
514
|
light: light,
|
|
502
515
|
ref: ref,
|
|
516
|
+
id: id,
|
|
503
517
|
invalid: invalid,
|
|
504
518
|
invalidText: invalidText,
|
|
505
519
|
warn: warn,
|
|
@@ -508,7 +522,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
508
522
|
size: size
|
|
509
523
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
510
524
|
className: `${prefix}--list-box__field`,
|
|
511
|
-
ref: refs.setReference
|
|
525
|
+
ref: autoAlign ? refs.setReference : null
|
|
512
526
|
}, controlledSelectedItems.length > 0 &&
|
|
513
527
|
/*#__PURE__*/
|
|
514
528
|
// @ts-expect-error: It is expecting a non-required prop called: "onClearSelection"
|
|
@@ -549,9 +563,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
549
563
|
// @ts-expect-error
|
|
550
564
|
isOpen: isOpen,
|
|
551
565
|
translateWithId: translateWithId
|
|
552
|
-
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu,
|
|
553
|
-
ref: refs.setFloating
|
|
554
|
-
}), isOpen ? sortedItems.map((item, index$1) => {
|
|
566
|
+
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen ? sortedItems.map((item, index$1) => {
|
|
555
567
|
const isChecked = controlledSelectedItems.filter(selected => isEqual__default["default"](selected, item)).length > 0;
|
|
556
568
|
const itemProps = getItemProps({
|
|
557
569
|
item,
|
|
@@ -9,11 +9,11 @@ import React, { ReactNode } from 'react';
|
|
|
9
9
|
import { ListBoxSize, ListBoxType } from '../ListBox';
|
|
10
10
|
import { MultiSelectSortingProps } from './MultiSelectPropTypes';
|
|
11
11
|
import { ListBoxProps } from '../ListBox/ListBox';
|
|
12
|
-
import type {
|
|
12
|
+
import type { TranslateWithId } from '../../types/common';
|
|
13
13
|
interface OnChangeData<ItemType> {
|
|
14
14
|
selectedItems: ItemType[] | null;
|
|
15
15
|
}
|
|
16
|
-
export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<ItemType>,
|
|
16
|
+
export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<ItemType>, TranslateWithId<'close.menu' | 'open.menu' | 'clear.all' | 'clear.selection'> {
|
|
17
17
|
/**
|
|
18
18
|
* **Experimental**: Will attempt to automatically align the floating
|
|
19
19
|
* element to avoid collisions with the viewport and being clipped by
|
|
@@ -13,14 +13,14 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
13
13
|
var iconsReact = require('@carbon/icons-react');
|
|
14
14
|
var cx = require('classnames');
|
|
15
15
|
var Downshift = require('downshift');
|
|
16
|
-
var isEqual = require('
|
|
16
|
+
var isEqual = require('react-fast-compare');
|
|
17
17
|
var PropTypes = require('prop-types');
|
|
18
18
|
var React = require('react');
|
|
19
19
|
var index = require('../ListBox/index.js');
|
|
20
20
|
var MultiSelectPropTypes = require('./MultiSelectPropTypes.js');
|
|
21
21
|
var sorting = require('./tools/sorting.js');
|
|
22
22
|
var Selection = require('../../internal/Selection.js');
|
|
23
|
-
var
|
|
23
|
+
var useId = require('../../internal/useId.js');
|
|
24
24
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
25
25
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
26
26
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
@@ -39,7 +39,6 @@ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
|
39
39
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
40
40
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
41
41
|
|
|
42
|
-
const getInstanceId = setupGetInstanceId["default"]();
|
|
43
42
|
const {
|
|
44
43
|
ItemClick,
|
|
45
44
|
ToggleButtonBlur,
|
|
@@ -110,9 +109,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
110
109
|
const {
|
|
111
110
|
isFluid
|
|
112
111
|
} = React.useContext(FormContext.FormContext);
|
|
113
|
-
const
|
|
114
|
-
current: multiSelectInstanceId
|
|
115
|
-
} = React.useRef(getInstanceId());
|
|
112
|
+
const multiSelectInstanceId = useId.useId();
|
|
116
113
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
117
114
|
const [inputFocused, setInputFocused] = React.useState(false);
|
|
118
115
|
const [isOpen, setIsOpen] = React.useState(open || false);
|
|
@@ -406,6 +403,11 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
406
403
|
});
|
|
407
404
|
}
|
|
408
405
|
const itemsSelectedText = selectedItems.length > 0 && selectedItems.map(item => item?.text);
|
|
406
|
+
|
|
407
|
+
// Memoize the value of getMenuProps to avoid an infinite loop
|
|
408
|
+
const menuProps = React.useMemo(() => getMenuProps({
|
|
409
|
+
ref: autoAlign ? refs.setFloating : null
|
|
410
|
+
}), [autoAlign]);
|
|
409
411
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
410
412
|
className: wrapperClasses
|
|
411
413
|
}, /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
@@ -432,7 +434,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
432
434
|
className: `${prefix}--list-box__invalid-icon ${prefix}--list-box__invalid-icon--warning`
|
|
433
435
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
434
436
|
className: multiSelectFieldWrapperClasses,
|
|
435
|
-
ref: refs.setReference
|
|
437
|
+
ref: autoAlign ? refs.setReference : null
|
|
436
438
|
}, selectedItems.length > 0 && /*#__PURE__*/React__default["default"].createElement(index["default"].Selection, {
|
|
437
439
|
readOnly: readOnly,
|
|
438
440
|
clearSelection: !disabled && !readOnly ? clearSelection : noopFn.noopFn,
|
|
@@ -455,9 +457,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
455
457
|
}, label), /*#__PURE__*/React__default["default"].createElement(index["default"].MenuIcon, {
|
|
456
458
|
isOpen: isOpen,
|
|
457
459
|
translateWithId: translateWithId
|
|
458
|
-
})), normalizedSlug), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu,
|
|
459
|
-
ref: refs.setFloating
|
|
460
|
-
}), isOpen &&
|
|
460
|
+
})), normalizedSlug), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen &&
|
|
461
461
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
462
462
|
sortItems(filteredItems, sortOptions).map((item, index$1) => {
|
|
463
463
|
const isChecked = selectedItems.filter(selected => isEqual__default["default"](selected, item)).length > 0;
|