@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
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import React from 'react';
|
|
9
|
+
import { TranslateWithId } from '../../types/common';
|
|
10
|
+
declare const defaultTranslations: {
|
|
11
|
+
readonly 'carbon.progress-step.complete': "Complete";
|
|
12
|
+
readonly 'carbon.progress-step.incomplete': "Incomplete";
|
|
13
|
+
readonly 'carbon.progress-step.current': "Current";
|
|
14
|
+
readonly 'carbon.progress-step.invalid': "Invalid";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Message ids that will be passed to translateWithId().
|
|
18
|
+
*/
|
|
19
|
+
type TranslationKey = keyof typeof defaultTranslations;
|
|
9
20
|
export interface ProgressIndicatorProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'onChange'> {
|
|
10
21
|
/**
|
|
11
22
|
* Provide `<ProgressStep>` components to be rendered in the
|
|
@@ -63,7 +74,7 @@ declare namespace ProgressIndicator {
|
|
|
63
74
|
vertical: PropTypes.Requireable<boolean>;
|
|
64
75
|
};
|
|
65
76
|
}
|
|
66
|
-
export interface ProgressStepProps {
|
|
77
|
+
export interface ProgressStepProps extends TranslateWithId<TranslationKey> {
|
|
67
78
|
/**
|
|
68
79
|
* Provide an optional className to be applied to the containing `<li>` node
|
|
69
80
|
*/
|
|
@@ -112,11 +123,6 @@ export interface ProgressStepProps {
|
|
|
112
123
|
* The ID of the tooltip content.
|
|
113
124
|
*/
|
|
114
125
|
tooltipId?: string;
|
|
115
|
-
/**
|
|
116
|
-
* Optional method that takes in a message id and returns an
|
|
117
|
-
* internationalized string.
|
|
118
|
-
*/
|
|
119
|
-
translateWithId?: (id: string) => string;
|
|
120
126
|
}
|
|
121
127
|
declare function ProgressStep({ label, description, className, current, complete, invalid, secondaryLabel, disabled, onClick, translateWithId: t, ...rest }: ProgressStepProps): import("react/jsx-runtime").JSX.Element;
|
|
122
128
|
declare namespace ProgressStep {
|
|
@@ -22,6 +22,11 @@ const defaultTranslations = {
|
|
|
22
22
|
'carbon.progress-step.current': 'Current',
|
|
23
23
|
'carbon.progress-step.invalid': 'Invalid'
|
|
24
24
|
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Message ids that will be passed to translateWithId().
|
|
28
|
+
*/
|
|
29
|
+
|
|
25
30
|
function translateWithId(messageId) {
|
|
26
31
|
return defaultTranslations[messageId];
|
|
27
32
|
}
|
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { type KeyboardEventHandler, PureComponent, ReactNode } from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
|
+
import { TranslateWithId } from '../../types/common';
|
|
10
|
+
declare const translationIds: {
|
|
11
|
+
readonly autoCorrectAnnouncement: "carbon.slider.auto-correct-announcement";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Message ids that will be passed to translateWithId().
|
|
15
|
+
*/
|
|
16
|
+
type TranslationKey = (typeof translationIds)[keyof typeof translationIds];
|
|
9
17
|
/**
|
|
10
18
|
* Distinguish two handles by lower and upper positions.
|
|
11
19
|
*/
|
|
@@ -14,7 +22,9 @@ declare enum HandlePosition {
|
|
|
14
22
|
UPPER = "upper"
|
|
15
23
|
}
|
|
16
24
|
type ExcludedAttributes = 'onChange' | 'onBlur';
|
|
17
|
-
export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes
|
|
25
|
+
export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<TranslationKey, {
|
|
26
|
+
correctedValue?: string;
|
|
27
|
+
}> {
|
|
18
28
|
/**
|
|
19
29
|
* The `ariaLabel` for the `<input>`.
|
|
20
30
|
*/
|
|
@@ -136,14 +146,6 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
|
|
|
136
146
|
* which will be `(max - min) / stepMultiplier`.
|
|
137
147
|
*/
|
|
138
148
|
stepMultiplier?: number;
|
|
139
|
-
/**
|
|
140
|
-
* Supply a method to translate internal strings with your i18n tool of
|
|
141
|
-
* choice. Translation keys are available on the `translationIds` field for
|
|
142
|
-
* this component.
|
|
143
|
-
*/
|
|
144
|
-
translateWithId?: (translationId: string, translationState: {
|
|
145
|
-
correctedValue?: string;
|
|
146
|
-
}) => string;
|
|
147
149
|
/**
|
|
148
150
|
* The value of the slider. When there are two handles, value is the lower
|
|
149
151
|
* bound.
|
|
@@ -72,8 +72,13 @@ ThumbWrapper.propTypes = {
|
|
|
72
72
|
const translationIds = {
|
|
73
73
|
autoCorrectAnnouncement: 'carbon.slider.auto-correct-announcement'
|
|
74
74
|
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Message ids that will be passed to translateWithId().
|
|
78
|
+
*/
|
|
79
|
+
|
|
75
80
|
function translateWithId(translationId, translationState) {
|
|
76
|
-
if (
|
|
81
|
+
if (translationState?.correctedValue) {
|
|
77
82
|
const {
|
|
78
83
|
correctedValue
|
|
79
84
|
} = translationState;
|
package/es/internal/Selection.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { defineProperty as _defineProperty } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import React__default, { useRef, useState, useCallback, useEffect } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import isEqual from '
|
|
11
|
+
import isEqual from 'react-fast-compare';
|
|
12
12
|
|
|
13
13
|
function callOnChangeHandler(_ref) {
|
|
14
14
|
let {
|
package/es/types/common.d.ts
CHANGED
|
@@ -9,10 +9,15 @@ export type ForwardRefReturn<T, P = unknown> = React.ForwardRefExoticComponent<F
|
|
|
9
9
|
export type PolymorphicProps<Element extends React.ElementType, Props> = Props & Omit<React.ComponentProps<Element>, 'as'> & {
|
|
10
10
|
as?: Element;
|
|
11
11
|
};
|
|
12
|
-
export interface
|
|
12
|
+
export interface TranslateWithId<MID = string, ARGS = Record<string, unknown>> {
|
|
13
13
|
/**
|
|
14
14
|
* Supply a method to translate internal strings with your i18n tool of
|
|
15
15
|
* choice.
|
|
16
16
|
*/
|
|
17
17
|
translateWithId?(messageId: MID, args?: ARGS): string;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Alias of TranslateWithId. Will be removed in v12
|
|
21
|
+
* @deprecated Use TranslateWithId instead
|
|
22
|
+
*/
|
|
23
|
+
export type InternationalProps<MID = string, ARGS = Record<string, unknown>> = TranslateWithId<MID, ARGS>;
|
|
@@ -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
|
*/
|
|
@@ -92,6 +92,15 @@ const findHighlightedIndex = (_ref2, inputValue) => {
|
|
|
92
92
|
}
|
|
93
93
|
return -1;
|
|
94
94
|
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Message ids that will be passed to translateWithId().
|
|
98
|
+
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
99
|
+
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
100
|
+
* because those components aren't Typescript. (If you try, TranslationKey
|
|
101
|
+
* ends up just being defined as "string".)
|
|
102
|
+
*/
|
|
103
|
+
|
|
95
104
|
const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
96
105
|
const {
|
|
97
106
|
['aria-label']: ariaLabel = 'Choose an item',
|
|
@@ -397,7 +406,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
397
406
|
const menuProps = React.useMemo(() => getMenuProps({
|
|
398
407
|
'aria-label': deprecatedAriaLabel || ariaLabel,
|
|
399
408
|
ref: autoAlign ? refs.setFloating : null
|
|
400
|
-
}), [autoAlign, deprecatedAriaLabel, ariaLabel]);
|
|
409
|
+
}), [autoAlign, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
401
410
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
402
411
|
className: wrapperClasses
|
|
403
412
|
}, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["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 };
|
|
@@ -35,6 +35,11 @@ var _ChevronDown;
|
|
|
35
35
|
const defaultTranslations = {
|
|
36
36
|
'carbon.combo-button.additional-actions': 'Additional actions'
|
|
37
37
|
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Message ids that will be passed to translateWithId().
|
|
41
|
+
*/
|
|
42
|
+
|
|
38
43
|
function defaultTranslateWithId(messageId) {
|
|
39
44
|
return defaultTranslations[messageId];
|
|
40
45
|
}
|
|
@@ -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.
|
|
@@ -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
|
*/
|
|
@@ -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
|
|
@@ -154,10 +163,6 @@ export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSorting
|
|
|
154
163
|
* combobox via ARIA attributes.
|
|
155
164
|
*/
|
|
156
165
|
titleText?: ReactNode;
|
|
157
|
-
/**
|
|
158
|
-
* Callback function for translating ListBoxMenuIcon SVG title
|
|
159
|
-
*/
|
|
160
|
-
translateWithId?(messageId: string, args?: Record<string, unknown>): string;
|
|
161
166
|
type?: 'default' | 'inline';
|
|
162
167
|
/**
|
|
163
168
|
* Specify title to show title on hover
|
|
@@ -13,7 +13,7 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
13
13
|
var iconsReact = require('@carbon/icons-react');
|
|
14
14
|
var cx = require('classnames');
|
|
15
15
|
var Downshift = require('downshift');
|
|
16
|
-
var isEqual = require('
|
|
16
|
+
var isEqual = require('react-fast-compare');
|
|
17
17
|
var PropTypes = require('prop-types');
|
|
18
18
|
var React = require('react');
|
|
19
19
|
var filter = require('../ComboBox/tools/filter.js');
|
|
@@ -64,6 +64,15 @@ const {
|
|
|
64
64
|
DropdownKeyDownBackspace,
|
|
65
65
|
FunctionRemoveSelectedItem
|
|
66
66
|
} = Downshift.useMultipleSelection.stateChangeTypes;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Message ids that will be passed to translateWithId().
|
|
70
|
+
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
71
|
+
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
72
|
+
* because those components aren't Typescript. (If you try, TranslationKey
|
|
73
|
+
* ends up just being defined as "string".)
|
|
74
|
+
*/
|
|
75
|
+
|
|
67
76
|
const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function FilterableMultiSelect(_ref, ref) {
|
|
68
77
|
let {
|
|
69
78
|
autoAlign = false,
|
|
@@ -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);
|