@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
|
@@ -7,13 +7,22 @@
|
|
|
7
7
|
import { UseComboboxProps } from 'downshift';
|
|
8
8
|
import { type ReactNode, type ComponentType, type ReactElement, type RefAttributes, type PropsWithChildren, type PropsWithRef, type InputHTMLAttributes, type MouseEvent } from 'react';
|
|
9
9
|
import { ListBoxSize } from '../ListBox';
|
|
10
|
+
import { TranslateWithId } from '../../types/common';
|
|
10
11
|
type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
|
|
11
12
|
interface OnChangeData<ItemType> {
|
|
12
13
|
selectedItem: ItemType | null | undefined;
|
|
13
14
|
inputValue?: string | null;
|
|
14
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Message ids that will be passed to translateWithId().
|
|
18
|
+
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
19
|
+
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
20
|
+
* because those components aren't Typescript. (If you try, TranslationKey
|
|
21
|
+
* ends up just being defined as "string".)
|
|
22
|
+
*/
|
|
23
|
+
type TranslationKey = 'close.menu' | 'open.menu' | 'clear.all' | 'clear.selection';
|
|
15
24
|
type ItemToStringHandler<ItemType> = (item: ItemType | null) => string;
|
|
16
|
-
export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
25
|
+
export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<TranslationKey> {
|
|
17
26
|
/**
|
|
18
27
|
* Specify whether or not the ComboBox should allow a value that is
|
|
19
28
|
* not in the list to be entered in the input
|
|
@@ -48,7 +57,10 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
|
|
|
48
57
|
*/
|
|
49
58
|
disabled?: boolean;
|
|
50
59
|
/**
|
|
51
|
-
* Additional props passed to Downshift
|
|
60
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
61
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
62
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
63
|
+
* to shield you from potentially breaking changes.
|
|
52
64
|
*/
|
|
53
65
|
downshiftProps?: Partial<UseComboboxProps<ItemType>>;
|
|
54
66
|
/**
|
|
@@ -150,11 +162,6 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
|
|
|
150
162
|
* combobox via ARIA attributes.
|
|
151
163
|
*/
|
|
152
164
|
titleText?: ReactNode;
|
|
153
|
-
/**
|
|
154
|
-
* Specify a custom translation function that takes in a message identifier
|
|
155
|
-
* and returns the localized string for the message
|
|
156
|
-
*/
|
|
157
|
-
translateWithId?: (id: string) => string;
|
|
158
165
|
/**
|
|
159
166
|
* Specify whether the control is currently in warning state
|
|
160
167
|
*/
|
|
@@ -82,6 +82,15 @@ const findHighlightedIndex = (_ref2, inputValue) => {
|
|
|
82
82
|
}
|
|
83
83
|
return -1;
|
|
84
84
|
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Message ids that will be passed to translateWithId().
|
|
88
|
+
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
89
|
+
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
90
|
+
* because those components aren't Typescript. (If you try, TranslationKey
|
|
91
|
+
* ends up just being defined as "string".)
|
|
92
|
+
*/
|
|
93
|
+
|
|
85
94
|
const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
86
95
|
const {
|
|
87
96
|
['aria-label']: ariaLabel = 'Choose an item',
|
|
@@ -320,7 +329,6 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
320
329
|
toggleMenu,
|
|
321
330
|
setHighlightedIndex
|
|
322
331
|
} = useCombobox({
|
|
323
|
-
...downshiftProps,
|
|
324
332
|
items: filterItems(items, itemToString, inputValue),
|
|
325
333
|
inputValue: inputValue,
|
|
326
334
|
itemToString: item => {
|
|
@@ -341,12 +349,28 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
341
349
|
selectedItem
|
|
342
350
|
});
|
|
343
351
|
},
|
|
352
|
+
onHighlightedIndexChange: _ref5 => {
|
|
353
|
+
let {
|
|
354
|
+
highlightedIndex
|
|
355
|
+
} = _ref5;
|
|
356
|
+
if (highlightedIndex > -1 && typeof window !== undefined) {
|
|
357
|
+
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
358
|
+
const highlightedItem = itemArray[highlightedIndex];
|
|
359
|
+
if (highlightedItem) {
|
|
360
|
+
highlightedItem.scrollIntoView({
|
|
361
|
+
behavior: 'smooth',
|
|
362
|
+
block: 'nearest'
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
},
|
|
344
367
|
initialSelectedItem: initialSelectedItem,
|
|
345
368
|
inputId: id,
|
|
346
369
|
stateReducer,
|
|
347
370
|
isItemDisabled(item, _index) {
|
|
348
371
|
return item.disabled;
|
|
349
|
-
}
|
|
372
|
+
},
|
|
373
|
+
...downshiftProps
|
|
350
374
|
});
|
|
351
375
|
const buttonProps = getToggleButtonProps({
|
|
352
376
|
disabled: disabled || readOnly,
|
|
@@ -387,7 +411,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
387
411
|
const menuProps = useMemo(() => getMenuProps({
|
|
388
412
|
'aria-label': deprecatedAriaLabel || ariaLabel,
|
|
389
413
|
ref: autoAlign ? refs.setFloating : null
|
|
390
|
-
}), [autoAlign, deprecatedAriaLabel, ariaLabel]);
|
|
414
|
+
}), [autoAlign, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
391
415
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
392
416
|
className: wrapperClasses
|
|
393
417
|
}, titleText && /*#__PURE__*/React__default.createElement(Text, _extends({
|
|
@@ -562,7 +586,10 @@ ComboBox.propTypes = {
|
|
|
562
586
|
*/
|
|
563
587
|
disabled: PropTypes.bool,
|
|
564
588
|
/**
|
|
565
|
-
* Additional props passed to Downshift
|
|
589
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
590
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
591
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
592
|
+
* to shield you from potentially breaking changes.
|
|
566
593
|
*/
|
|
567
594
|
downshiftProps: PropTypes.object,
|
|
568
595
|
/**
|
|
@@ -9,7 +9,15 @@ import { IconButton } from '../IconButton';
|
|
|
9
9
|
import Button from '../Button';
|
|
10
10
|
import { Menu } from '../Menu';
|
|
11
11
|
import { MenuAlignment } from '../MenuButton';
|
|
12
|
-
|
|
12
|
+
import { TranslateWithId } from '../../types/common';
|
|
13
|
+
declare const defaultTranslations: {
|
|
14
|
+
'carbon.combo-button.additional-actions': string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Message ids that will be passed to translateWithId().
|
|
18
|
+
*/
|
|
19
|
+
type TranslationKey = keyof typeof defaultTranslations;
|
|
20
|
+
interface ComboButtonProps extends TranslateWithId<TranslationKey> {
|
|
13
21
|
/**
|
|
14
22
|
* A collection of `MenuItems` to be rendered as additional actions for this `ComboButton`.
|
|
15
23
|
*/
|
|
@@ -42,11 +50,6 @@ interface ComboButtonProps {
|
|
|
42
50
|
* Specify how the trigger tooltip should be aligned.
|
|
43
51
|
*/
|
|
44
52
|
tooltipAlignment?: React.ComponentProps<typeof IconButton>['align'];
|
|
45
|
-
/**
|
|
46
|
-
* Optional method that takes in a message `id` and returns an
|
|
47
|
-
* internationalized string.
|
|
48
|
-
*/
|
|
49
|
-
translateWithId?: (id: string) => string;
|
|
50
53
|
}
|
|
51
54
|
declare const ComboButton: React.ForwardRefExoticComponent<ComboButtonProps & React.RefAttributes<HTMLDivElement>>;
|
|
52
55
|
export { ComboButton, type ComboButtonProps };
|
|
@@ -25,6 +25,11 @@ var _ChevronDown;
|
|
|
25
25
|
const defaultTranslations = {
|
|
26
26
|
'carbon.combo-button.additional-actions': 'Additional actions'
|
|
27
27
|
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Message ids that will be passed to translateWithId().
|
|
31
|
+
*/
|
|
32
|
+
|
|
28
33
|
function defaultTranslateWithId(messageId) {
|
|
29
34
|
return defaultTranslations[messageId];
|
|
30
35
|
}
|
|
@@ -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;
|
|
@@ -49,6 +49,11 @@ const translationKeys = {
|
|
|
49
49
|
selectRow: 'carbon.table.row.select',
|
|
50
50
|
unselectRow: 'carbon.table.row.unselect'
|
|
51
51
|
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Message ids that will be passed to translateWithId().
|
|
55
|
+
*/
|
|
56
|
+
|
|
52
57
|
const defaultTranslations = {
|
|
53
58
|
[translationKeys.expandAll]: 'Expand all rows',
|
|
54
59
|
[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
|
*/
|
|
@@ -15,6 +15,10 @@ import { useId } from '../../internal/useId.js';
|
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
16
|
import { noopFn } from '../../internal/noopFn.js';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Message ids that will be passed to translateWithId().
|
|
20
|
+
*/
|
|
21
|
+
|
|
18
22
|
const translationKeys = {
|
|
19
23
|
'carbon.table.toolbar.search.label': 'Filter table',
|
|
20
24
|
'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
|
*/
|
|
@@ -22,10 +22,6 @@ import { useFloating, size, flip, autoUpdate } from '@floating-ui/react';
|
|
|
22
22
|
import { ListBoxSize, ListBoxType } from '../ListBox/ListBoxPropTypes.js';
|
|
23
23
|
|
|
24
24
|
const {
|
|
25
|
-
ToggleButtonKeyDownArrowDown,
|
|
26
|
-
ToggleButtonKeyDownArrowUp,
|
|
27
|
-
ToggleButtonKeyDownHome,
|
|
28
|
-
ToggleButtonKeyDownEnd,
|
|
29
25
|
ItemMouseMove,
|
|
30
26
|
MenuMouseLeave
|
|
31
27
|
} = useSelect.stateChangeTypes;
|
|
@@ -113,7 +109,6 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
113
109
|
isFluid
|
|
114
110
|
} = useContext(FormContext);
|
|
115
111
|
const selectProps = {
|
|
116
|
-
...downshiftProps,
|
|
117
112
|
items,
|
|
118
113
|
itemToString,
|
|
119
114
|
initialSelectedItem,
|
|
@@ -122,28 +117,31 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
122
117
|
isItemDisabled(item, _index) {
|
|
123
118
|
const isObject = item !== null && typeof item === 'object';
|
|
124
119
|
return isObject && 'disabled' in item && item.disabled === true;
|
|
125
|
-
}
|
|
120
|
+
},
|
|
121
|
+
onHighlightedIndexChange: _ref3 => {
|
|
122
|
+
let {
|
|
123
|
+
highlightedIndex
|
|
124
|
+
} = _ref3;
|
|
125
|
+
if (highlightedIndex > -1 && typeof window !== undefined) {
|
|
126
|
+
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
127
|
+
const highlightedItem = itemArray[highlightedIndex];
|
|
128
|
+
if (highlightedItem) {
|
|
129
|
+
highlightedItem.scrollIntoView({
|
|
130
|
+
behavior: 'smooth',
|
|
131
|
+
block: 'nearest'
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
...downshiftProps
|
|
126
137
|
};
|
|
127
138
|
const dropdownInstanceId = useId();
|
|
128
139
|
function stateReducer(state, actionAndChanges) {
|
|
129
140
|
const {
|
|
130
141
|
changes,
|
|
131
|
-
props,
|
|
132
142
|
type
|
|
133
143
|
} = actionAndChanges;
|
|
134
|
-
const {
|
|
135
|
-
highlightedIndex
|
|
136
|
-
} = changes;
|
|
137
144
|
switch (type) {
|
|
138
|
-
case ToggleButtonKeyDownArrowDown:
|
|
139
|
-
case ToggleButtonKeyDownArrowUp:
|
|
140
|
-
case ToggleButtonKeyDownHome:
|
|
141
|
-
case ToggleButtonKeyDownEnd:
|
|
142
|
-
if (highlightedIndex > -1) {
|
|
143
|
-
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
144
|
-
props.scrollIntoView(itemArray[highlightedIndex]);
|
|
145
|
-
}
|
|
146
|
-
return changes;
|
|
147
145
|
case ItemMouseMove:
|
|
148
146
|
case MenuMouseLeave:
|
|
149
147
|
return {
|
|
@@ -208,10 +206,10 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
208
206
|
id: helperId,
|
|
209
207
|
className: helperClasses
|
|
210
208
|
}, helperText) : null;
|
|
211
|
-
function onSelectedItemChange(
|
|
209
|
+
function onSelectedItemChange(_ref4) {
|
|
212
210
|
let {
|
|
213
211
|
selectedItem
|
|
214
|
-
} =
|
|
212
|
+
} = _ref4;
|
|
215
213
|
if (onChange) {
|
|
216
214
|
onChange({
|
|
217
215
|
selectedItem: selectedItem ?? null
|
|
@@ -362,7 +360,10 @@ Dropdown.propTypes = {
|
|
|
362
360
|
*/
|
|
363
361
|
disabled: PropTypes.bool,
|
|
364
362
|
/**
|
|
365
|
-
* Additional props passed to Downshift
|
|
363
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
364
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
365
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
366
|
+
* to shield you from potentially breaking changes.
|
|
366
367
|
*/
|
|
367
368
|
downshiftProps: PropTypes.object,
|
|
368
369
|
/**
|
|
@@ -65,7 +65,10 @@ FluidMultiSelect.propTypes = {
|
|
|
65
65
|
*/
|
|
66
66
|
disabled: PropTypes.bool,
|
|
67
67
|
/**
|
|
68
|
-
* Additional props passed to Downshift
|
|
68
|
+
* Additional props passed to Downshift. Use with caution: anything you define
|
|
69
|
+
* here overrides the components' internal handling of that prop. Downshift
|
|
70
|
+
* internals are subject to change, and in some cases they can not be shimmed
|
|
71
|
+
* to shield you from potentially breaking changes.
|
|
69
72
|
*/
|
|
70
73
|
downshiftProps: PropTypes.object,
|
|
71
74
|
/**
|
|
@@ -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
|
*/
|
|
@@ -13,6 +13,7 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
13
13
|
|
|
14
14
|
const FormGroup = _ref => {
|
|
15
15
|
let {
|
|
16
|
+
disabled = false,
|
|
16
17
|
legendId,
|
|
17
18
|
legendText,
|
|
18
19
|
invalid = false,
|
|
@@ -24,7 +25,9 @@ const FormGroup = _ref => {
|
|
|
24
25
|
} = _ref;
|
|
25
26
|
const prefix = usePrefix();
|
|
26
27
|
const classNamesFieldset = cx(`${prefix}--fieldset`, className);
|
|
27
|
-
return /*#__PURE__*/React__default.createElement("fieldset", _extends({
|
|
28
|
+
return /*#__PURE__*/React__default.createElement("fieldset", _extends({
|
|
29
|
+
disabled: disabled
|
|
30
|
+
}, invalid && {
|
|
28
31
|
'data-invalid': ''
|
|
29
32
|
}, {
|
|
30
33
|
className: classNamesFieldset
|
|
@@ -46,6 +49,10 @@ FormGroup.propTypes = {
|
|
|
46
49
|
* Provide a custom className to be applied to the containing <fieldset> node
|
|
47
50
|
*/
|
|
48
51
|
className: PropTypes.string,
|
|
52
|
+
/**
|
|
53
|
+
* Specify whether the FormGroup should be disabled
|
|
54
|
+
*/
|
|
55
|
+
disabled: PropTypes.bool,
|
|
49
56
|
/**
|
|
50
57
|
* Specify whether the <FormGroup> is invalid
|
|
51
58
|
*/
|
|
@@ -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
|
|
@@ -16,6 +16,11 @@ const translationIds = {
|
|
|
16
16
|
'clear.all': 'clear.all',
|
|
17
17
|
'clear.selection': 'clear.selection'
|
|
18
18
|
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Message ids that will be passed to translateWithId().
|
|
22
|
+
*/
|
|
23
|
+
|
|
19
24
|
const defaultTranslations = {
|
|
20
25
|
[translationIds['clear.all']]: 'Clear all selected items',
|
|
21
26
|
[translationIds['clear.selection']]: 'Clear selected item'
|