@carbon/react 1.63.0-rc.0 → 1.63.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1043 -1014
- package/es/components/ComboBox/ComboBox.d.ts +14 -7
- package/es/components/ComboBox/ComboBox.js +31 -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 +5 -0
- package/es/components/DataTable/TableBatchActions.d.ts +2 -2
- package/es/components/DataTable/TableHeader.d.ts +7 -13
- package/es/components/DataTable/TableToolbarSearch.d.ts +5 -2
- package/es/components/DataTable/TableToolbarSearch.js +4 -0
- package/es/components/Dropdown/Dropdown.d.ts +6 -7
- package/es/components/Dropdown/Dropdown.js +23 -22
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +4 -1
- 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/MultiSelect/FilterableMultiSelect.d.ts +14 -6
- package/es/components/MultiSelect/FilterableMultiSelect.js +17 -5
- package/es/components/MultiSelect/MultiSelect.d.ts +6 -3
- package/es/components/MultiSelect/MultiSelect.js +7 -4
- package/es/components/NumberInput/NumberInput.d.ts +8 -7
- package/es/components/NumberInput/NumberInput.js +5 -0
- 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/Slider/Slider.d.ts +11 -9
- package/es/components/Slider/Slider.js +6 -1
- package/es/internal/Selection.js +1 -1
- package/es/internal/useId.js +39 -18
- package/es/types/common.d.ts +6 -1
- package/lib/components/ComboBox/ComboBox.d.ts +14 -7
- package/lib/components/ComboBox/ComboBox.js +31 -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 +5 -0
- package/lib/components/DataTable/TableBatchActions.d.ts +2 -2
- package/lib/components/DataTable/TableHeader.d.ts +7 -13
- package/lib/components/DataTable/TableToolbarSearch.d.ts +5 -2
- package/lib/components/DataTable/TableToolbarSearch.js +4 -0
- package/lib/components/Dropdown/Dropdown.d.ts +6 -7
- package/lib/components/Dropdown/Dropdown.js +23 -22
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +4 -1
- 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/MultiSelect/FilterableMultiSelect.d.ts +14 -6
- package/lib/components/MultiSelect/FilterableMultiSelect.js +17 -5
- package/lib/components/MultiSelect/MultiSelect.d.ts +6 -3
- package/lib/components/MultiSelect/MultiSelect.js +7 -4
- package/lib/components/NumberInput/NumberInput.d.ts +8 -7
- package/lib/components/NumberInput/NumberInput.js +5 -0
- 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/Slider/Slider.d.ts +11 -9
- package/lib/components/Slider/Slider.js +6 -1
- package/lib/internal/Selection.js +1 -1
- package/lib/internal/useId.js +39 -17
- package/lib/types/common.d.ts +6 -1
- package/package.json +8 -9
|
@@ -28,6 +28,21 @@ import TableToolbarAction from './TableToolbarAction';
|
|
|
28
28
|
import TableToolbarContent from './TableToolbarContent';
|
|
29
29
|
import TableToolbarSearch from './TableToolbarSearch';
|
|
30
30
|
import TableToolbarMenu from './TableToolbarMenu';
|
|
31
|
+
import { TranslateWithId } from '../../types/common';
|
|
32
|
+
declare const translationKeys: {
|
|
33
|
+
readonly expandRow: "carbon.table.row.expand";
|
|
34
|
+
readonly collapseRow: "carbon.table.row.collapse";
|
|
35
|
+
readonly expandAll: "carbon.table.all.expand";
|
|
36
|
+
readonly collapseAll: "carbon.table.all.collapse";
|
|
37
|
+
readonly selectAll: "carbon.table.all.select";
|
|
38
|
+
readonly unselectAll: "carbon.table.all.unselect";
|
|
39
|
+
readonly selectRow: "carbon.table.row.select";
|
|
40
|
+
readonly unselectRow: "carbon.table.row.unselect";
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Message ids that will be passed to translateWithId().
|
|
44
|
+
*/
|
|
45
|
+
type TranslationKey = (typeof translationKeys)[keyof typeof translationKeys];
|
|
31
46
|
export type DataTableSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
32
47
|
export interface DataTableCell<T> {
|
|
33
48
|
id: string;
|
|
@@ -168,7 +183,7 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
|
|
|
168
183
|
expandAll: () => void;
|
|
169
184
|
radio: boolean | undefined;
|
|
170
185
|
}
|
|
171
|
-
export interface DataTableProps<RowType, ColTypes extends any[]> {
|
|
186
|
+
export interface DataTableProps<RowType, ColTypes extends any[]> extends TranslateWithId<TranslationKey> {
|
|
172
187
|
children?: (renderProps: DataTableRenderProps<RowType, ColTypes>) => React.ReactElement;
|
|
173
188
|
experimentalAutoAlign?: boolean;
|
|
174
189
|
filterRows?: (filterRowsArgs: {
|
|
@@ -192,7 +207,6 @@ export interface DataTableProps<RowType, ColTypes extends any[]> {
|
|
|
192
207
|
locale: string;
|
|
193
208
|
}) => number;
|
|
194
209
|
stickyHeader?: boolean;
|
|
195
|
-
translateWithId?: (id: string) => string;
|
|
196
210
|
useStaticWidth?: boolean;
|
|
197
211
|
useZebraStyles?: boolean;
|
|
198
212
|
}
|
|
@@ -295,7 +309,7 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
|
|
|
295
309
|
*/
|
|
296
310
|
useZebraStyles: PropTypes.Requireable<boolean>;
|
|
297
311
|
};
|
|
298
|
-
static translationKeys:
|
|
312
|
+
static translationKeys: ("carbon.table.row.expand" | "carbon.table.row.collapse" | "carbon.table.all.expand" | "carbon.table.all.collapse" | "carbon.table.all.select" | "carbon.table.all.unselect" | "carbon.table.row.select" | "carbon.table.row.unselect")[];
|
|
299
313
|
static Table: typeof Table;
|
|
300
314
|
static TableActionList: typeof TableActionList;
|
|
301
315
|
static TableBatchAction: typeof TableBatchAction;
|
|
@@ -360,8 +374,8 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
|
|
|
360
374
|
}) => void) | undefined;
|
|
361
375
|
onExpand?: ((e: MouseEvent) => void) | undefined;
|
|
362
376
|
}) => {
|
|
363
|
-
ariaLabel:
|
|
364
|
-
'aria-label':
|
|
377
|
+
ariaLabel: any;
|
|
378
|
+
'aria-label': any;
|
|
365
379
|
'aria-controls': string;
|
|
366
380
|
isExpanded: boolean;
|
|
367
381
|
onExpand: any;
|
|
@@ -398,8 +412,8 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
|
|
|
398
412
|
key: string;
|
|
399
413
|
onExpand: any;
|
|
400
414
|
isExpanded: boolean | undefined;
|
|
401
|
-
ariaLabel:
|
|
402
|
-
'aria-label':
|
|
415
|
+
ariaLabel: any;
|
|
416
|
+
'aria-label': any;
|
|
403
417
|
'aria-controls': string;
|
|
404
418
|
isSelected: boolean | undefined;
|
|
405
419
|
disabled: boolean | undefined;
|
|
@@ -436,13 +450,13 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
|
|
|
436
450
|
onSelect: any;
|
|
437
451
|
id: string;
|
|
438
452
|
name: string;
|
|
439
|
-
ariaLabel:
|
|
440
|
-
'aria-label':
|
|
453
|
+
ariaLabel: any;
|
|
454
|
+
'aria-label': any;
|
|
441
455
|
disabled: boolean | undefined;
|
|
442
456
|
radio: true | null;
|
|
443
457
|
} | {
|
|
444
|
-
ariaLabel:
|
|
445
|
-
'aria-label':
|
|
458
|
+
ariaLabel: any;
|
|
459
|
+
'aria-label': any;
|
|
446
460
|
checked: boolean;
|
|
447
461
|
id: string;
|
|
448
462
|
indeterminate: boolean;
|
|
@@ -59,6 +59,11 @@ const translationKeys = {
|
|
|
59
59
|
selectRow: 'carbon.table.row.select',
|
|
60
60
|
unselectRow: 'carbon.table.row.unselect'
|
|
61
61
|
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Message ids that will be passed to translateWithId().
|
|
65
|
+
*/
|
|
66
|
+
|
|
62
67
|
const defaultTranslations = {
|
|
63
68
|
[translationKeys.expandAll]: 'Expand all rows',
|
|
64
69
|
[translationKeys.collapseAll]: 'Collapse all rows',
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { type MouseEventHandler } from 'react';
|
|
8
|
-
import type {
|
|
8
|
+
import type { TranslateWithId } from '../../types/common';
|
|
9
9
|
declare const TableBatchActionsTranslationKeys: readonly ["carbon.table.batch.cancel", "carbon.table.batch.items.selected", "carbon.table.batch.item.selected", "carbon.table.batch.selectAll"];
|
|
10
10
|
export type TableBatchActionsTranslationKey = (typeof TableBatchActionsTranslationKeys)[number];
|
|
11
11
|
export interface TableBatchActionsTranslationArgs {
|
|
12
12
|
totalSelected?: number;
|
|
13
13
|
totalCount?: number;
|
|
14
14
|
}
|
|
15
|
-
export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElement>,
|
|
15
|
+
export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElement>, TranslateWithId<TableBatchActionsTranslationKey, TableBatchActionsTranslationArgs> {
|
|
16
16
|
/**
|
|
17
17
|
* Provide elements to be rendered inside of the component.
|
|
18
18
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { type MouseEventHandler, ReactNode } from 'react';
|
|
8
8
|
import { sortStates } from './state/sorting';
|
|
9
|
-
import { ReactAttr } from '../../types/common';
|
|
9
|
+
import { TranslateWithId, ReactAttr } from '../../types/common';
|
|
10
10
|
import { DataTableSortState } from './state/sortStates';
|
|
11
11
|
export type TableHeaderTranslationKey = 'carbon.table.header.icon.description';
|
|
12
12
|
export interface TableHeaderTranslationArgs {
|
|
@@ -15,7 +15,12 @@ export interface TableHeaderTranslationArgs {
|
|
|
15
15
|
sortDirection?: DataTableSortState;
|
|
16
16
|
sortStates: typeof sortStates;
|
|
17
17
|
}
|
|
18
|
-
interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonElement
|
|
18
|
+
interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonElement>, TranslateWithId<TableHeaderTranslationKey, {
|
|
19
|
+
header: any;
|
|
20
|
+
sortDirection: any;
|
|
21
|
+
isSortHeader: any;
|
|
22
|
+
sortStates: any;
|
|
23
|
+
}> {
|
|
19
24
|
/**
|
|
20
25
|
* Pass in children that will be embedded in the table header label
|
|
21
26
|
*/
|
|
@@ -61,17 +66,6 @@ interface TableHeaderProps extends ReactAttr<HTMLTableCellElement & HTMLButtonEl
|
|
|
61
66
|
* NONE, or ASC.
|
|
62
67
|
*/
|
|
63
68
|
sortDirection?: string;
|
|
64
|
-
/**
|
|
65
|
-
* Supply a method to translate internal strings with your i18n tool of
|
|
66
|
-
* choice. Translation keys are available on the `translationKeys` field for
|
|
67
|
-
* this component.
|
|
68
|
-
*/
|
|
69
|
-
translateWithId?: (key: TableHeaderTranslationKey, { header, sortDirection, isSortHeader, sortStates }: {
|
|
70
|
-
header: any;
|
|
71
|
-
sortDirection: any;
|
|
72
|
-
isSortHeader: any;
|
|
73
|
-
sortStates: any;
|
|
74
|
-
}) => string;
|
|
75
69
|
}
|
|
76
70
|
declare const TableHeader: React.ForwardRefExoticComponent<TableHeaderProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
77
71
|
export default TableHeader;
|
|
@@ -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
|
*/
|
|
@@ -25,6 +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
|
+
/**
|
|
29
|
+
* Message ids that will be passed to translateWithId().
|
|
30
|
+
*/
|
|
31
|
+
|
|
28
32
|
const translationKeys = {
|
|
29
33
|
'carbon.table.toolbar.search.label': 'Filter table',
|
|
30
34
|
'carbon.table.toolbar.search.placeholder': 'Filter table'
|
|
@@ -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.
|
|
@@ -36,7 +36,10 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
36
36
|
*/
|
|
37
37
|
disabled?: boolean;
|
|
38
38
|
/**
|
|
39
|
-
* Additional props passed to Downshift
|
|
39
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
40
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
41
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
42
|
+
* to shield you from potentially breaking changes.
|
|
40
43
|
*/
|
|
41
44
|
downshiftProps?: Partial<UseSelectProps<ItemType>>;
|
|
42
45
|
/**
|
|
@@ -123,10 +126,6 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
123
126
|
* visiting this control
|
|
124
127
|
*/
|
|
125
128
|
titleText?: ReactNode;
|
|
126
|
-
/**
|
|
127
|
-
* Callback function for translating ListBoxMenuIcon SVG title
|
|
128
|
-
*/
|
|
129
|
-
translateWithId?(messageId: ListBoxMenuIconTranslationKey, args?: Record<string, unknown>): string;
|
|
130
129
|
/**
|
|
131
130
|
* The dropdown type, `default` or `inline`
|
|
132
131
|
*/
|
|
@@ -32,10 +32,6 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
32
32
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
33
33
|
|
|
34
34
|
const {
|
|
35
|
-
ToggleButtonKeyDownArrowDown,
|
|
36
|
-
ToggleButtonKeyDownArrowUp,
|
|
37
|
-
ToggleButtonKeyDownHome,
|
|
38
|
-
ToggleButtonKeyDownEnd,
|
|
39
35
|
ItemMouseMove,
|
|
40
36
|
MenuMouseLeave
|
|
41
37
|
} = Downshift.useSelect.stateChangeTypes;
|
|
@@ -123,7 +119,6 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
123
119
|
isFluid
|
|
124
120
|
} = React.useContext(FormContext.FormContext);
|
|
125
121
|
const selectProps = {
|
|
126
|
-
...downshiftProps,
|
|
127
122
|
items,
|
|
128
123
|
itemToString,
|
|
129
124
|
initialSelectedItem,
|
|
@@ -132,28 +127,31 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
132
127
|
isItemDisabled(item, _index) {
|
|
133
128
|
const isObject = item !== null && typeof item === 'object';
|
|
134
129
|
return isObject && 'disabled' in item && item.disabled === true;
|
|
135
|
-
}
|
|
130
|
+
},
|
|
131
|
+
onHighlightedIndexChange: _ref3 => {
|
|
132
|
+
let {
|
|
133
|
+
highlightedIndex
|
|
134
|
+
} = _ref3;
|
|
135
|
+
if (highlightedIndex > -1 && typeof window !== undefined) {
|
|
136
|
+
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
137
|
+
const highlightedItem = itemArray[highlightedIndex];
|
|
138
|
+
if (highlightedItem) {
|
|
139
|
+
highlightedItem.scrollIntoView({
|
|
140
|
+
behavior: 'smooth',
|
|
141
|
+
block: 'nearest'
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
...downshiftProps
|
|
136
147
|
};
|
|
137
148
|
const dropdownInstanceId = useId.useId();
|
|
138
149
|
function stateReducer(state, actionAndChanges) {
|
|
139
150
|
const {
|
|
140
151
|
changes,
|
|
141
|
-
props,
|
|
142
152
|
type
|
|
143
153
|
} = actionAndChanges;
|
|
144
|
-
const {
|
|
145
|
-
highlightedIndex
|
|
146
|
-
} = changes;
|
|
147
154
|
switch (type) {
|
|
148
|
-
case ToggleButtonKeyDownArrowDown:
|
|
149
|
-
case ToggleButtonKeyDownArrowUp:
|
|
150
|
-
case ToggleButtonKeyDownHome:
|
|
151
|
-
case ToggleButtonKeyDownEnd:
|
|
152
|
-
if (highlightedIndex > -1) {
|
|
153
|
-
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
154
|
-
props.scrollIntoView(itemArray[highlightedIndex]);
|
|
155
|
-
}
|
|
156
|
-
return changes;
|
|
157
155
|
case ItemMouseMove:
|
|
158
156
|
case MenuMouseLeave:
|
|
159
157
|
return {
|
|
@@ -218,10 +216,10 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
218
216
|
id: helperId,
|
|
219
217
|
className: helperClasses
|
|
220
218
|
}, helperText) : null;
|
|
221
|
-
function onSelectedItemChange(
|
|
219
|
+
function onSelectedItemChange(_ref4) {
|
|
222
220
|
let {
|
|
223
221
|
selectedItem
|
|
224
|
-
} =
|
|
222
|
+
} = _ref4;
|
|
225
223
|
if (onChange) {
|
|
226
224
|
onChange({
|
|
227
225
|
selectedItem: selectedItem ?? null
|
|
@@ -372,7 +370,10 @@ Dropdown.propTypes = {
|
|
|
372
370
|
*/
|
|
373
371
|
disabled: PropTypes__default["default"].bool,
|
|
374
372
|
/**
|
|
375
|
-
* Additional props passed to Downshift
|
|
373
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
374
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
375
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
376
|
+
* to shield you from potentially breaking changes.
|
|
376
377
|
*/
|
|
377
378
|
downshiftProps: PropTypes__default["default"].object,
|
|
378
379
|
/**
|
|
@@ -75,7 +75,10 @@ FluidMultiSelect.propTypes = {
|
|
|
75
75
|
*/
|
|
76
76
|
disabled: PropTypes__default["default"].bool,
|
|
77
77
|
/**
|
|
78
|
-
* Additional props passed to Downshift
|
|
78
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
79
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
80
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
81
|
+
* to shield you from potentially breaking changes.
|
|
79
82
|
*/
|
|
80
83
|
downshiftProps: PropTypes__default["default"].object,
|
|
81
84
|
/**
|
|
@@ -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'
|
|
@@ -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
|
|
@@ -39,7 +48,10 @@ export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSorting
|
|
|
39
48
|
*/
|
|
40
49
|
disabled?: boolean;
|
|
41
50
|
/**
|
|
42
|
-
* Additional props passed to Downshift
|
|
51
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
52
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
53
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
54
|
+
* to shield you from potentially breaking changes.
|
|
43
55
|
*/
|
|
44
56
|
downshiftProps?: UseMultipleSelectionProps<ItemType>;
|
|
45
57
|
/**
|
|
@@ -154,10 +166,6 @@ export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSorting
|
|
|
154
166
|
* combobox via ARIA attributes.
|
|
155
167
|
*/
|
|
156
168
|
titleText?: ReactNode;
|
|
157
|
-
/**
|
|
158
|
-
* Callback function for translating ListBoxMenuIcon SVG title
|
|
159
|
-
*/
|
|
160
|
-
translateWithId?(messageId: string, args?: Record<string, unknown>): string;
|
|
161
169
|
type?: 'default' | 'inline';
|
|
162
170
|
/**
|
|
163
171
|
* 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,
|
|
@@ -351,7 +360,6 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
351
360
|
const {
|
|
352
361
|
getDropdownProps
|
|
353
362
|
} = Downshift.useMultipleSelection({
|
|
354
|
-
...downshiftProps,
|
|
355
363
|
activeIndex: highlightedIndex,
|
|
356
364
|
initialSelectedItems,
|
|
357
365
|
selectedItems: controlledSelectedItems,
|
|
@@ -367,7 +375,8 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
367
375
|
break;
|
|
368
376
|
}
|
|
369
377
|
}
|
|
370
|
-
}
|
|
378
|
+
},
|
|
379
|
+
...downshiftProps
|
|
371
380
|
});
|
|
372
381
|
React.useEffect(() => {
|
|
373
382
|
if (isOpen && !isMenuOpen) {
|
|
@@ -478,7 +487,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
478
487
|
ref: autoAlign ? refs.setFloating : null
|
|
479
488
|
}, {
|
|
480
489
|
suppressRefError: true
|
|
481
|
-
}), [autoAlign]);
|
|
490
|
+
}), [autoAlign, getMenuProps, refs.setFloating]);
|
|
482
491
|
const handleFocus = evt => {
|
|
483
492
|
if (evt?.target.classList.contains(`${prefix}--tag__close-icon`) || evt?.target.classList.contains(`${prefix}--list-box__selection`)) {
|
|
484
493
|
setIsFocused(false);
|
|
@@ -625,7 +634,10 @@ FilterableMultiSelect.propTypes = {
|
|
|
625
634
|
*/
|
|
626
635
|
disabled: PropTypes__default["default"].bool,
|
|
627
636
|
/**
|
|
628
|
-
* Additional props passed to Downshift
|
|
637
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
638
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
639
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
640
|
+
* to shield you from potentially breaking changes.
|
|
629
641
|
*/
|
|
630
642
|
// @ts-ignore
|
|
631
643
|
downshiftProps: PropTypes__default["default"].shape(Downshift__default["default"].propTypes),
|
|
@@ -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
|
|
@@ -42,7 +42,10 @@ export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<Item
|
|
|
42
42
|
*/
|
|
43
43
|
disabled?: ListBoxProps['disabled'];
|
|
44
44
|
/**
|
|
45
|
-
* Additional props passed to Downshift
|
|
45
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
46
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
47
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
48
|
+
* to shield you from potentially breaking changes.
|
|
46
49
|
*/
|
|
47
50
|
downshiftProps?: Partial<UseSelectProps<ItemType>>;
|
|
48
51
|
/**
|
|
@@ -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 index = require('../ListBox/index.js');
|
|
@@ -177,7 +177,6 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
177
177
|
});
|
|
178
178
|
}, [items]);
|
|
179
179
|
const selectProps = {
|
|
180
|
-
...downshiftProps,
|
|
181
180
|
stateReducer,
|
|
182
181
|
isOpen,
|
|
183
182
|
itemToString: filteredItems => {
|
|
@@ -189,7 +188,8 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
189
188
|
items: filteredItems,
|
|
190
189
|
isItemDisabled(item, _index) {
|
|
191
190
|
return item.disabled;
|
|
192
|
-
}
|
|
191
|
+
},
|
|
192
|
+
...downshiftProps
|
|
193
193
|
};
|
|
194
194
|
const {
|
|
195
195
|
getToggleButtonProps,
|
|
@@ -529,7 +529,10 @@ MultiSelect.propTypes = {
|
|
|
529
529
|
*/
|
|
530
530
|
disabled: PropTypes__default["default"].bool,
|
|
531
531
|
/**
|
|
532
|
-
* Additional props passed to Downshift
|
|
532
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
533
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
534
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
535
|
+
* to shield you from potentially breaking changes.
|
|
533
536
|
*/
|
|
534
537
|
downshiftProps: PropTypes__default["default"].object,
|
|
535
538
|
/**
|