@carbon/react 1.63.0-rc.0 → 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 +852 -852
- package/es/components/ComboBox/ComboBox.d.ts +10 -6
- package/es/components/ComboBox/ComboBox.js +10 -1
- 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 +2 -6
- 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 +10 -5
- package/es/components/MultiSelect/FilterableMultiSelect.js +11 -2
- package/es/components/MultiSelect/MultiSelect.d.ts +2 -2
- package/es/components/MultiSelect/MultiSelect.js +1 -1
- 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/types/common.d.ts +6 -1
- package/lib/components/ComboBox/ComboBox.d.ts +10 -6
- package/lib/components/ComboBox/ComboBox.js +10 -1
- 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 +2 -6
- 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 +10 -5
- package/lib/components/MultiSelect/FilterableMultiSelect.js +11 -2
- package/lib/components/MultiSelect/MultiSelect.d.ts +2 -2
- package/lib/components/MultiSelect/MultiSelect.js +1 -1
- 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/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
|
|
@@ -150,11 +159,6 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
|
|
|
150
159
|
* combobox via ARIA attributes.
|
|
151
160
|
*/
|
|
152
161
|
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
162
|
/**
|
|
159
163
|
* Specify whether the control is currently in warning state
|
|
160
164
|
*/
|
|
@@ -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',
|
|
@@ -387,7 +396,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
387
396
|
const menuProps = useMemo(() => getMenuProps({
|
|
388
397
|
'aria-label': deprecatedAriaLabel || ariaLabel,
|
|
389
398
|
ref: autoAlign ? refs.setFloating : null
|
|
390
|
-
}), [autoAlign, deprecatedAriaLabel, ariaLabel]);
|
|
399
|
+
}), [autoAlign, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
391
400
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
392
401
|
className: wrapperClasses
|
|
393
402
|
}, titleText && /*#__PURE__*/React__default.createElement(Text, _extends({
|
|
@@ -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.
|
|
@@ -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
|
*/
|
|
@@ -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'
|
|
@@ -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
|
|
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
|
|
|
9
9
|
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import Downshift, { useCombobox, useMultipleSelection } from 'downshift';
|
|
12
|
-
import isEqual from '
|
|
12
|
+
import isEqual from 'react-fast-compare';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
14
|
import React__default, { useContext, useState, useLayoutEffect, useRef, useEffect, useMemo } from 'react';
|
|
15
15
|
import { defaultFilterItems } from '../ComboBox/tools/filter.js';
|
|
@@ -52,6 +52,15 @@ const {
|
|
|
52
52
|
DropdownKeyDownBackspace,
|
|
53
53
|
FunctionRemoveSelectedItem
|
|
54
54
|
} = useMultipleSelection.stateChangeTypes;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Message ids that will be passed to translateWithId().
|
|
58
|
+
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
59
|
+
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
60
|
+
* because those components aren't Typescript. (If you try, TranslationKey
|
|
61
|
+
* ends up just being defined as "string".)
|
|
62
|
+
*/
|
|
63
|
+
|
|
55
64
|
const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function FilterableMultiSelect(_ref, ref) {
|
|
56
65
|
let {
|
|
57
66
|
autoAlign = false,
|
|
@@ -466,7 +475,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
466
475
|
ref: autoAlign ? refs.setFloating : null
|
|
467
476
|
}, {
|
|
468
477
|
suppressRefError: true
|
|
469
|
-
}), [autoAlign]);
|
|
478
|
+
}), [autoAlign, getMenuProps, refs.setFloating]);
|
|
470
479
|
const handleFocus = evt => {
|
|
471
480
|
if (evt?.target.classList.contains(`${prefix}--tag__close-icon`) || evt?.target.classList.contains(`${prefix}--list-box__selection`)) {
|
|
472
481
|
setIsFocused(false);
|
|
@@ -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
|
|
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
|
|
|
9
9
|
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import { useSelect } from 'downshift';
|
|
12
|
-
import isEqual from '
|
|
12
|
+
import isEqual from 'react-fast-compare';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
14
|
import React__default, { useContext, useState, useLayoutEffect, useMemo } from 'react';
|
|
15
15
|
import ListBox from '../ListBox/index.js';
|
|
@@ -5,12 +5,17 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { ReactNode } from 'react';
|
|
8
|
+
import { TranslateWithId } from '../../types/common';
|
|
8
9
|
export declare const translationIds: {
|
|
9
|
-
'increment.number':
|
|
10
|
-
'decrement.number':
|
|
10
|
+
readonly 'increment.number': "increment.number";
|
|
11
|
+
readonly 'decrement.number': "decrement.number";
|
|
11
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Message ids that will be passed to translateWithId().
|
|
15
|
+
*/
|
|
16
|
+
type TranslationKey = keyof typeof translationIds;
|
|
12
17
|
type ExcludedAttributes = 'defaultValue' | 'id' | 'min' | 'max' | 'onChange' | 'onClick' | 'size' | 'step' | 'value';
|
|
13
|
-
export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
18
|
+
export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<TranslationKey> {
|
|
14
19
|
/**
|
|
15
20
|
* `true` to allow empty string.
|
|
16
21
|
*/
|
|
@@ -115,10 +120,6 @@ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
115
120
|
* Specify how much the values should increase/decrease upon clicking on up/down button
|
|
116
121
|
*/
|
|
117
122
|
step?: number;
|
|
118
|
-
/**
|
|
119
|
-
* Provide custom text for the component for each translation id
|
|
120
|
-
*/
|
|
121
|
-
translateWithId?: (id: string) => string;
|
|
122
123
|
/**
|
|
123
124
|
* Specify the value of the input
|
|
124
125
|
*/
|
|
@@ -24,6 +24,11 @@ const translationIds = {
|
|
|
24
24
|
'increment.number': 'increment.number',
|
|
25
25
|
'decrement.number': 'decrement.number'
|
|
26
26
|
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Message ids that will be passed to translateWithId().
|
|
30
|
+
*/
|
|
31
|
+
|
|
27
32
|
const defaultTranslations = {
|
|
28
33
|
[translationIds['increment.number']]: 'Increment number',
|
|
29
34
|
[translationIds['decrement.number']]: 'Decrement number'
|
|
@@ -5,7 +5,19 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
|
|
8
|
+
import { TranslateWithId } from '../../types/common';
|
|
9
|
+
declare const translationIds: {
|
|
10
|
+
readonly 'carbon.pagination-nav.next': "Next";
|
|
11
|
+
readonly 'carbon.pagination-nav.previous': "Previous";
|
|
12
|
+
readonly 'carbon.pagination-nav.item': "Page";
|
|
13
|
+
readonly 'carbon.pagination-nav.active': "Active";
|
|
14
|
+
readonly 'carbon.pagination-nav.of': "of";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Message ids that will be passed to translateWithId().
|
|
18
|
+
*/
|
|
19
|
+
type TranslationKey = keyof typeof translationIds;
|
|
20
|
+
interface PaginationNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'>, TranslateWithId<TranslationKey> {
|
|
9
21
|
/**
|
|
10
22
|
* Additional CSS class names.
|
|
11
23
|
*/
|
|
@@ -35,11 +47,6 @@ interface PaginationNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'on
|
|
|
35
47
|
* The total number of items.
|
|
36
48
|
*/
|
|
37
49
|
totalItems?: number;
|
|
38
|
-
/**
|
|
39
|
-
* Specify a custom translation function that takes in a message identifier
|
|
40
|
-
* and returns the localized string for the message
|
|
41
|
-
*/
|
|
42
|
-
translateWithId?: (id: string) => string;
|
|
43
50
|
}
|
|
44
51
|
declare const PaginationNav: React.ForwardRefExoticComponent<PaginationNavProps & React.RefAttributes<HTMLElement>>;
|
|
45
52
|
export default PaginationNav;
|
|
@@ -21,6 +21,11 @@ const translationIds = {
|
|
|
21
21
|
'carbon.pagination-nav.active': 'Active',
|
|
22
22
|
'carbon.pagination-nav.of': 'of'
|
|
23
23
|
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Message ids that will be passed to translateWithId().
|
|
27
|
+
*/
|
|
28
|
+
|
|
24
29
|
function translateWithId(messageId) {
|
|
25
30
|
return translationIds[messageId];
|
|
26
31
|
}
|