@carbon/react 1.36.0 → 1.37.0-rc.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/es/components/Button/Button.js +12 -12
- package/es/components/ComboBox/ComboBox.js +2 -4
- package/es/components/DataTable/DataTable.d.ts +30 -0
- package/es/components/DataTable/DataTable.js +27 -0
- package/es/components/DataTable/TableBatchActions.d.ts +51 -0
- package/es/components/DataTable/TableBatchActions.js +39 -8
- package/es/components/DataTable/TableExpandHeader.d.ts +27 -5
- package/es/components/DataTable/TableExpandHeader.js +17 -3
- package/es/components/DataTable/TableExpandRow.d.ts +24 -3
- package/es/components/DataTable/TableExpandRow.js +18 -3
- package/es/components/DataTable/TableRow.js +1 -1
- package/es/components/DataTable/TableToolbarSearch.d.ts +176 -0
- package/es/components/DataTable/TableToolbarSearch.js +9 -4
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +40 -40
- package/es/components/FileUploader/FileUploader.Skeleton.d.ts +1 -4
- package/es/components/FileUploader/FileUploaderDropContainer.d.ts +9 -17
- package/es/components/FileUploader/FileUploaderDropContainer.js +21 -17
- package/es/components/FileUploader/FileUploaderItem.d.ts +3 -14
- package/es/components/FileUploader/FileUploaderItem.js +4 -4
- package/es/components/FormLabel/FormLabel.d.ts +40 -0
- package/es/components/FormLabel/index.d.ts +9 -0
- package/es/components/ListBox/ListBoxMenu.d.ts +2 -2
- package/es/components/ListBox/ListBoxMenu.js +1 -1
- package/es/components/ListBox/ListBoxMenuItem.d.ts +6 -2
- package/es/components/ListBox/ListBoxMenuItem.js +6 -3
- package/es/components/MultiSelect/FilterableMultiSelect.js +24 -4
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -3
- package/es/components/MultiSelect/MultiSelect.js +77 -56
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/NumberInput/NumberInput.js +18 -44
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.d.ts +24 -0
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +3 -5
- package/es/components/SkeletonPlaceholder/index.d.ts +9 -0
- package/es/components/Slider/Slider.d.ts +6 -0
- package/es/components/Slider/Slider.js +17 -2
- package/es/components/StructuredList/StructuredList.js +5 -2
- package/es/components/Tag/Tag.Skeleton.d.ts +35 -0
- package/es/components/Tag/Tag.d.ts +122 -0
- package/es/components/Tag/Tag.js +6 -6
- package/es/components/Tag/index.d.ts +11 -0
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/Tile/Tile.js +5 -5
- package/es/components/TimePicker/TimePicker.js +8 -6
- package/es/components/Toggle/Toggle.Skeleton.js +1 -4
- package/es/components/Toggle/Toggle.js +1 -1
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +0 -3
- package/es/components/UIShell/HeaderMenuItem.js +1 -2
- package/es/components/UIShell/Link.js +1 -2
- package/es/components/UIShell/SideNav.js +1 -3
- package/es/components/UIShell/index.d.ts +35 -0
- package/es/index.js +32 -32
- package/es/types/common.d.ts +7 -0
- package/lib/components/Button/Button.js +12 -12
- package/lib/components/ComboBox/ComboBox.js +2 -4
- package/lib/components/DataTable/DataTable.d.ts +30 -0
- package/lib/components/DataTable/DataTable.js +27 -0
- package/lib/components/DataTable/TableBatchActions.d.ts +51 -0
- package/lib/components/DataTable/TableBatchActions.js +39 -8
- package/lib/components/DataTable/TableExpandHeader.d.ts +27 -5
- package/lib/components/DataTable/TableExpandHeader.js +17 -3
- package/lib/components/DataTable/TableExpandRow.d.ts +24 -3
- package/lib/components/DataTable/TableExpandRow.js +18 -3
- package/lib/components/DataTable/TableRow.js +1 -1
- package/lib/components/DataTable/TableToolbarSearch.d.ts +176 -0
- package/lib/components/DataTable/TableToolbarSearch.js +9 -4
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +39 -39
- package/lib/components/FileUploader/FileUploader.Skeleton.d.ts +1 -4
- package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +9 -17
- package/lib/components/FileUploader/FileUploaderDropContainer.js +21 -17
- package/lib/components/FileUploader/FileUploaderItem.d.ts +3 -14
- package/lib/components/FileUploader/FileUploaderItem.js +4 -4
- package/lib/components/FormLabel/FormLabel.d.ts +40 -0
- package/lib/components/FormLabel/index.d.ts +9 -0
- package/lib/components/ListBox/ListBoxMenu.d.ts +2 -2
- package/lib/components/ListBox/ListBoxMenu.js +1 -1
- package/lib/components/ListBox/ListBoxMenuItem.d.ts +6 -2
- package/lib/components/ListBox/ListBoxMenuItem.js +6 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.js +24 -4
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -3
- package/lib/components/MultiSelect/MultiSelect.js +75 -55
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.js +18 -44
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.d.ts +24 -0
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +3 -5
- package/lib/components/SkeletonPlaceholder/index.d.ts +9 -0
- package/lib/components/Slider/Slider.d.ts +6 -0
- package/lib/components/Slider/Slider.js +17 -2
- package/lib/components/StructuredList/StructuredList.js +5 -2
- package/lib/components/Tag/Tag.Skeleton.d.ts +35 -0
- package/lib/components/Tag/Tag.d.ts +122 -0
- package/lib/components/Tag/Tag.js +6 -6
- package/lib/components/Tag/index.d.ts +11 -0
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/Tile/Tile.js +5 -5
- package/lib/components/TimePicker/TimePicker.js +8 -6
- package/lib/components/Toggle/Toggle.Skeleton.js +1 -4
- package/lib/components/Toggle/Toggle.js +1 -1
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.js +0 -3
- package/lib/components/UIShell/HeaderMenuItem.js +1 -2
- package/lib/components/UIShell/Link.js +1 -2
- package/lib/components/UIShell/SideNav.js +1 -3
- package/lib/components/UIShell/index.d.ts +35 -0
- package/lib/index.js +65 -65
- package/lib/types/common.d.ts +7 -0
- package/package.json +5 -5
|
@@ -32,11 +32,11 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
32
32
|
|
|
33
33
|
const getInstanceId = setupGetInstanceId["default"]();
|
|
34
34
|
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
ToggleButtonKeyDownArrowDown,
|
|
36
|
+
ToggleButtonKeyDownArrowUp,
|
|
37
|
+
ToggleButtonKeyDownHome,
|
|
38
|
+
ToggleButtonKeyDownEnd,
|
|
39
|
+
ItemMouseMove
|
|
40
40
|
} = Downshift.useSelect.stateChangeTypes;
|
|
41
41
|
const defaultItemToString = item => {
|
|
42
42
|
if (typeof item === 'string') {
|
|
@@ -82,7 +82,6 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
82
82
|
...other
|
|
83
83
|
} = _ref;
|
|
84
84
|
const prefix = usePrefix.usePrefix();
|
|
85
|
-
const [highlightedIndex, setHighlightedIndex] = React.useState();
|
|
86
85
|
const {
|
|
87
86
|
isFluid
|
|
88
87
|
} = React.useContext(FormContext.FormContext);
|
|
@@ -90,31 +89,43 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
90
89
|
...downshiftProps,
|
|
91
90
|
items,
|
|
92
91
|
itemToString,
|
|
93
|
-
highlightedIndex,
|
|
94
92
|
initialSelectedItem,
|
|
95
93
|
onSelectedItemChange,
|
|
96
|
-
|
|
94
|
+
stateReducer,
|
|
95
|
+
isItemDisabled(item, _index) {
|
|
96
|
+
const isObject = item !== null && typeof item === 'object';
|
|
97
|
+
return isObject && 'disabled' in item && item.disabled === true;
|
|
98
|
+
}
|
|
97
99
|
};
|
|
98
100
|
const {
|
|
99
101
|
current: dropdownInstanceId
|
|
100
102
|
} = React.useRef(getInstanceId());
|
|
101
|
-
function
|
|
103
|
+
function stateReducer(state, actionAndChanges) {
|
|
102
104
|
const {
|
|
105
|
+
changes,
|
|
106
|
+
props,
|
|
103
107
|
type
|
|
108
|
+
} = actionAndChanges;
|
|
109
|
+
const {
|
|
110
|
+
highlightedIndex
|
|
104
111
|
} = changes;
|
|
105
112
|
switch (type) {
|
|
106
|
-
case
|
|
107
|
-
case
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
case ToggleButtonKeyDownArrowDown:
|
|
114
|
+
case ToggleButtonKeyDownArrowUp:
|
|
115
|
+
case ToggleButtonKeyDownHome:
|
|
116
|
+
case ToggleButtonKeyDownEnd:
|
|
117
|
+
if (highlightedIndex > -1) {
|
|
118
|
+
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
119
|
+
props.scrollIntoView(itemArray[highlightedIndex]);
|
|
120
|
+
}
|
|
121
|
+
return changes;
|
|
122
|
+
case ItemMouseMove:
|
|
123
|
+
return {
|
|
124
|
+
...changes,
|
|
125
|
+
highlightedIndex: state.highlightedIndex
|
|
126
|
+
};
|
|
117
127
|
}
|
|
128
|
+
return changes;
|
|
118
129
|
}
|
|
119
130
|
|
|
120
131
|
// only set selectedItem if the prop is defined. Setting if it is undefined
|
|
@@ -128,7 +139,8 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
128
139
|
getLabelProps,
|
|
129
140
|
getMenuProps,
|
|
130
141
|
getItemProps,
|
|
131
|
-
selectedItem
|
|
142
|
+
selectedItem,
|
|
143
|
+
highlightedIndex
|
|
132
144
|
} = Downshift.useSelect(selectProps);
|
|
133
145
|
const inline = type === 'inline';
|
|
134
146
|
const showWarning = !invalid && warn;
|
|
@@ -172,14 +184,12 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
172
184
|
let {
|
|
173
185
|
selectedItem
|
|
174
186
|
} = _ref2;
|
|
175
|
-
setIsFocused(false);
|
|
176
187
|
if (onChange) {
|
|
177
188
|
onChange({
|
|
178
189
|
selectedItem: selectedItem ?? null
|
|
179
190
|
});
|
|
180
191
|
}
|
|
181
192
|
}
|
|
182
|
-
const menuItemOptionRefs = React.useRef(items.map(_ => /*#__PURE__*/React__default["default"].createRef()));
|
|
183
193
|
const handleFocus = evt => {
|
|
184
194
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
185
195
|
};
|
|
@@ -210,10 +220,6 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
210
220
|
setIsTyping(true);
|
|
211
221
|
}
|
|
212
222
|
if (isTyping && evt.code === 'Space' || !['ArrowDown', 'ArrowUp', ' ', 'Enter'].includes(evt.key)) {
|
|
213
|
-
if (evt.code === 'Space') {
|
|
214
|
-
evt.preventDefault();
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
223
|
if (currTimer) {
|
|
218
224
|
clearTimeout(currTimer);
|
|
219
225
|
}
|
|
@@ -221,7 +227,9 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
221
227
|
setIsTyping(false);
|
|
222
228
|
}, 3000));
|
|
223
229
|
}
|
|
224
|
-
toggleButtonProps.onKeyDown
|
|
230
|
+
if (toggleButtonProps.onKeyDown) {
|
|
231
|
+
toggleButtonProps.onKeyDown(evt);
|
|
232
|
+
}
|
|
225
233
|
}
|
|
226
234
|
};
|
|
227
235
|
const menuProps = getMenuProps();
|
|
@@ -250,16 +258,12 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
250
258
|
type: "button"
|
|
251
259
|
// aria-expanded is already being passed through {...toggleButtonProps}
|
|
252
260
|
,
|
|
253
|
-
role: "combobox" // eslint-disable-line jsx-a11y/role-has-required-aria-props
|
|
254
|
-
,
|
|
255
|
-
"aria-owns": getMenuProps().id,
|
|
256
|
-
"aria-controls": getMenuProps().id,
|
|
257
261
|
className: `${prefix}--list-box__field`,
|
|
258
262
|
disabled: disabled,
|
|
259
263
|
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
260
264
|
,
|
|
261
265
|
"aria-describedby": !inline && !invalid && !warn && helper ? helperId : undefined,
|
|
262
|
-
title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : label
|
|
266
|
+
title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : defaultItemToString(label)
|
|
263
267
|
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
264
268
|
ref: mergedRef
|
|
265
269
|
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -269,11 +273,9 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
269
273
|
translateWithId: translateWithId
|
|
270
274
|
})), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen && items.map((item, index$1) => {
|
|
271
275
|
const isObject = item !== null && typeof item === 'object';
|
|
272
|
-
const disabled = isObject && 'disabled' in item && item.disabled === true;
|
|
273
276
|
const itemProps = getItemProps({
|
|
274
277
|
item,
|
|
275
|
-
index: index$1
|
|
276
|
-
disabled
|
|
278
|
+
index: index$1
|
|
277
279
|
});
|
|
278
280
|
const title = isObject && 'text' in item && itemToElement ? item.text : itemToString(item);
|
|
279
281
|
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -281,9 +283,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
281
283
|
isActive: selectedItem === item,
|
|
282
284
|
isHighlighted: highlightedIndex === index$1,
|
|
283
285
|
title: title,
|
|
284
|
-
|
|
285
|
-
menuItemOptionRef: menuItemOptionRefs.current[index$1]
|
|
286
|
-
}
|
|
286
|
+
disabled: itemProps['aria-disabled']
|
|
287
287
|
}, itemProps), typeof item === 'object' && ItemToElement !== undefined && ItemToElement !== null ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
|
|
288
288
|
key: itemProps.id
|
|
289
289
|
}, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React__default["default"].createElement(iconsReact.Checkmark, {
|
|
@@ -13,10 +13,7 @@ export interface FileUploaderSkeletonProps extends ReactAttr<HTMLDivElement> {
|
|
|
13
13
|
*/
|
|
14
14
|
className?: string;
|
|
15
15
|
}
|
|
16
|
-
declare function FileUploaderSkeleton({ className, ...rest }:
|
|
17
|
-
[x: string]: any;
|
|
18
|
-
className: any;
|
|
19
|
-
}): JSX.Element;
|
|
16
|
+
declare function FileUploaderSkeleton({ className, ...rest }: FileUploaderSkeletonProps): JSX.Element;
|
|
20
17
|
declare namespace FileUploaderSkeleton {
|
|
21
18
|
var propTypes: {
|
|
22
19
|
/**
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
import React from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import { ReactAttr } from '../../types/common';
|
|
10
10
|
export interface FileUploaderDropContainerProps extends Omit<ReactAttr<HTMLButtonElement>, 'tabIndex'> {
|
|
@@ -39,9 +39,10 @@ export interface FileUploaderDropContainerProps extends Omit<ReactAttr<HTMLButto
|
|
|
39
39
|
name?: string;
|
|
40
40
|
/**
|
|
41
41
|
* Event handler that is called after files are added to the uploader
|
|
42
|
-
* The event handler signature looks like `onAddFiles(evt, { addedFiles })`
|
|
43
42
|
*/
|
|
44
|
-
onAddFiles?: (
|
|
43
|
+
onAddFiles?: (event: React.SyntheticEvent<HTMLElement>, content: {
|
|
44
|
+
addedFiles: File[];
|
|
45
|
+
}) => void;
|
|
45
46
|
/**
|
|
46
47
|
* Provide an optional function to be called when the button element
|
|
47
48
|
* is clicked
|
|
@@ -51,6 +52,10 @@ export interface FileUploaderDropContainerProps extends Omit<ReactAttr<HTMLButto
|
|
|
51
52
|
* Provide a custom regex pattern for the acceptedTypes
|
|
52
53
|
*/
|
|
53
54
|
pattern?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Ref to pass to the inner button element
|
|
57
|
+
*/
|
|
58
|
+
innerRef?: React.LegacyRef<HTMLButtonElement>;
|
|
54
59
|
/**
|
|
55
60
|
* @deprecated The `role` prop for `FileUploaderButton` has been deprecated since it now renders a button element by default, and has an implicit role of button.
|
|
56
61
|
*/
|
|
@@ -60,20 +65,7 @@ export interface FileUploaderDropContainerProps extends Omit<ReactAttr<HTMLButto
|
|
|
60
65
|
*/
|
|
61
66
|
tabIndex?: number | string;
|
|
62
67
|
}
|
|
63
|
-
declare function FileUploaderDropContainer({ accept, className, id, disabled, labelText, multiple, name, onAddFiles, onClick, pattern, innerRef, ...rest }:
|
|
64
|
-
[x: string]: any;
|
|
65
|
-
accept: any;
|
|
66
|
-
className: any;
|
|
67
|
-
id: any;
|
|
68
|
-
disabled: any;
|
|
69
|
-
labelText: any;
|
|
70
|
-
multiple: any;
|
|
71
|
-
name: any;
|
|
72
|
-
onAddFiles: any;
|
|
73
|
-
onClick: any;
|
|
74
|
-
pattern: any;
|
|
75
|
-
innerRef: any;
|
|
76
|
-
}): JSX.Element;
|
|
68
|
+
declare function FileUploaderDropContainer({ accept, className, id, disabled, labelText, multiple, name, onAddFiles, onClick, pattern, innerRef, ...rest }: FileUploaderDropContainerProps): JSX.Element;
|
|
77
69
|
declare namespace FileUploaderDropContainer {
|
|
78
70
|
var propTypes: {
|
|
79
71
|
/**
|
|
@@ -28,16 +28,16 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
28
28
|
|
|
29
29
|
function FileUploaderDropContainer(_ref) {
|
|
30
30
|
let {
|
|
31
|
-
accept,
|
|
31
|
+
accept = [],
|
|
32
32
|
className,
|
|
33
33
|
id,
|
|
34
34
|
disabled,
|
|
35
|
-
labelText,
|
|
36
|
-
multiple,
|
|
35
|
+
labelText = 'Add file',
|
|
36
|
+
multiple = false,
|
|
37
37
|
name,
|
|
38
|
-
onAddFiles,
|
|
38
|
+
onAddFiles = () => {},
|
|
39
39
|
onClick,
|
|
40
|
-
pattern,
|
|
40
|
+
pattern = '.[0-9a-z]+$',
|
|
41
41
|
// eslint-disable-next-line react/prop-types
|
|
42
42
|
innerRef,
|
|
43
43
|
...rest
|
|
@@ -50,16 +50,13 @@ function FileUploaderDropContainer(_ref) {
|
|
|
50
50
|
const [isActive, setActive] = React.useState(false);
|
|
51
51
|
const dropareaClasses = cx__default["default"](`${prefix}--file__drop-container`, `${prefix}--file-browse-btn`, {
|
|
52
52
|
[`${prefix}--file__drop-container--drag-over`]: isActive,
|
|
53
|
-
[`${prefix}--file-browse-btn--disabled`]: disabled
|
|
54
|
-
|
|
55
|
-
});
|
|
53
|
+
[`${prefix}--file-browse-btn--disabled`]: disabled
|
|
54
|
+
}, className);
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
57
|
* Filters the array of added files based on file type restrictions
|
|
59
|
-
* @param {Event} event - Event object, used to get the list of files added
|
|
60
58
|
*/
|
|
61
|
-
function validateFiles(
|
|
62
|
-
const transferredFiles = event.type === 'drop' ? [...event.dataTransfer.files] : [...event.target.files];
|
|
59
|
+
function validateFiles(transferredFiles) {
|
|
63
60
|
if (!accept.length) {
|
|
64
61
|
return transferredFiles;
|
|
65
62
|
}
|
|
@@ -70,11 +67,10 @@ function FileUploaderDropContainer(_ref) {
|
|
|
70
67
|
type: mimeType = ''
|
|
71
68
|
} = curr;
|
|
72
69
|
const fileExtensionRegExp = new RegExp(pattern, 'i');
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
70
|
+
const [fileExtension] = name.match(fileExtensionRegExp) ?? [];
|
|
71
|
+
if (fileExtension === undefined) {
|
|
75
72
|
return acc;
|
|
76
73
|
}
|
|
77
|
-
const [fileExtension] = name.match(fileExtensionRegExp);
|
|
78
74
|
if (acceptedTypes.has(mimeType) || acceptedTypes.has(fileExtension.toLowerCase())) {
|
|
79
75
|
return acc.concat([curr]);
|
|
80
76
|
}
|
|
@@ -83,7 +79,15 @@ function FileUploaderDropContainer(_ref) {
|
|
|
83
79
|
}, []);
|
|
84
80
|
}
|
|
85
81
|
function handleChange(event) {
|
|
86
|
-
const
|
|
82
|
+
const files = [...(event.target.files ?? [])];
|
|
83
|
+
const addedFiles = validateFiles(files);
|
|
84
|
+
return onAddFiles(event, {
|
|
85
|
+
addedFiles
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function handleDrop(event) {
|
|
89
|
+
const files = [...event.dataTransfer.files];
|
|
90
|
+
const addedFiles = validateFiles(files);
|
|
87
91
|
return onAddFiles(event, {
|
|
88
92
|
addedFiles
|
|
89
93
|
});
|
|
@@ -120,7 +124,7 @@ function FileUploaderDropContainer(_ref) {
|
|
|
120
124
|
return;
|
|
121
125
|
}
|
|
122
126
|
setActive(false);
|
|
123
|
-
|
|
127
|
+
handleDrop(evt);
|
|
124
128
|
}
|
|
125
129
|
}, /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({
|
|
126
130
|
type: "button",
|
|
@@ -143,7 +147,7 @@ function FileUploaderDropContainer(_ref) {
|
|
|
143
147
|
ref: inputRef,
|
|
144
148
|
tabIndex: -1,
|
|
145
149
|
disabled: disabled,
|
|
146
|
-
accept: accept,
|
|
150
|
+
accept: accept.join(','),
|
|
147
151
|
name: name,
|
|
148
152
|
multiple: multiple,
|
|
149
153
|
onChange: handleChange,
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
/// <reference types="react" />
|
|
8
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
9
9
|
import { ReactAttr } from '../../types/common';
|
|
10
10
|
export interface FileUploaderItemProps extends ReactAttr<HTMLSpanElement> {
|
|
11
11
|
/**
|
|
@@ -32,7 +32,7 @@ export interface FileUploaderItemProps extends ReactAttr<HTMLSpanElement> {
|
|
|
32
32
|
* Event handler that is called after removing a file from the file uploader
|
|
33
33
|
* The event handler signature looks like `onDelete(evt, { uuid })`
|
|
34
34
|
*/
|
|
35
|
-
onDelete?: (event:
|
|
35
|
+
onDelete?: (event: React.SyntheticEvent<HTMLElement>, opts: {
|
|
36
36
|
uuid: string;
|
|
37
37
|
}) => void;
|
|
38
38
|
/**
|
|
@@ -49,18 +49,7 @@ export interface FileUploaderItemProps extends ReactAttr<HTMLSpanElement> {
|
|
|
49
49
|
*/
|
|
50
50
|
uuid?: string;
|
|
51
51
|
}
|
|
52
|
-
declare function FileUploaderItem({ uuid, name, status, iconDescription, onDelete, invalid, errorSubject, errorBody, size, ...other }:
|
|
53
|
-
[x: string]: any;
|
|
54
|
-
uuid: any;
|
|
55
|
-
name: any;
|
|
56
|
-
status: any;
|
|
57
|
-
iconDescription: any;
|
|
58
|
-
onDelete: any;
|
|
59
|
-
invalid: any;
|
|
60
|
-
errorSubject: any;
|
|
61
|
-
errorBody: any;
|
|
62
|
-
size: any;
|
|
63
|
-
}): JSX.Element;
|
|
52
|
+
declare function FileUploaderItem({ uuid, name, status, iconDescription, onDelete, invalid, errorSubject, errorBody, size, ...other }: FileUploaderItemProps): JSX.Element;
|
|
64
53
|
declare namespace FileUploaderItem {
|
|
65
54
|
var propTypes: {
|
|
66
55
|
/**
|
|
@@ -29,9 +29,9 @@ function FileUploaderItem(_ref) {
|
|
|
29
29
|
let {
|
|
30
30
|
uuid,
|
|
31
31
|
name,
|
|
32
|
-
status,
|
|
32
|
+
status = 'uploading',
|
|
33
33
|
iconDescription,
|
|
34
|
-
onDelete,
|
|
34
|
+
onDelete = () => {},
|
|
35
35
|
invalid,
|
|
36
36
|
errorSubject,
|
|
37
37
|
errorBody,
|
|
@@ -44,8 +44,8 @@ function FileUploaderItem(_ref) {
|
|
|
44
44
|
} = React.useRef(uuid || uniqueId["default"]());
|
|
45
45
|
const classes = cx__default["default"](`${prefix}--file__selected-file`, {
|
|
46
46
|
[`${prefix}--file__selected-file--invalid`]: invalid,
|
|
47
|
-
[`${prefix}--file__selected-file--md`]: size === '
|
|
48
|
-
[`${prefix}--file__selected-file--sm`]: size === '
|
|
47
|
+
[`${prefix}--file__selected-file--md`]: size === 'md',
|
|
48
|
+
[`${prefix}--file__selected-file--sm`]: size === 'sm'
|
|
49
49
|
});
|
|
50
50
|
return /*#__PURE__*/React__default["default"].createElement("span", _rollupPluginBabelHelpers["extends"]({
|
|
51
51
|
className: classes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
export interface FormLabelProps extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'htmlFor'> {
|
|
10
|
+
/**
|
|
11
|
+
* Specify the content of the form label
|
|
12
|
+
*/
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Provide a custom className to be applied to the containing <label> node
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Provide a unique id for the given <FormLabel>
|
|
20
|
+
*/
|
|
21
|
+
id?: string;
|
|
22
|
+
}
|
|
23
|
+
declare function FormLabel({ className: customClassName, children, id, ...rest }: FormLabelProps): JSX.Element;
|
|
24
|
+
declare namespace FormLabel {
|
|
25
|
+
var propTypes: {
|
|
26
|
+
/**
|
|
27
|
+
* Specify the content of the form label
|
|
28
|
+
*/
|
|
29
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
30
|
+
/**
|
|
31
|
+
* Provide a custom className to be applied to the containing <label> node
|
|
32
|
+
*/
|
|
33
|
+
className: PropTypes.Requireable<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Provide a unique id for the given <FormLabel>
|
|
36
|
+
*/
|
|
37
|
+
id: PropTypes.Requireable<string>;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export default FormLabel;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import FormLabel from './FormLabel';
|
|
8
|
+
export default FormLabel;
|
|
9
|
+
export { FormLabel };
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { ForwardRefReturn, ReactAttr } from '../../types/common';
|
|
8
8
|
type ExcludedAttributes = 'id';
|
|
9
|
-
export interface ListBoxMenuProps extends Omit<ReactAttr<
|
|
9
|
+
export interface ListBoxMenuProps extends Omit<ReactAttr<HTMLUListElement>, ExcludedAttributes> {
|
|
10
10
|
/**
|
|
11
11
|
* Specify a custom `id`
|
|
12
12
|
*/
|
|
13
13
|
id: string;
|
|
14
14
|
}
|
|
15
|
-
export type ListBoxMenuComponent = ForwardRefReturn<
|
|
15
|
+
export type ListBoxMenuComponent = ForwardRefReturn<HTMLUListElement, ListBoxMenuProps>;
|
|
16
16
|
/**
|
|
17
17
|
* `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
|
|
18
18
|
* class into a single component. It is also being used to validate given
|
|
@@ -32,7 +32,7 @@ const ListBoxMenu = /*#__PURE__*/React__default["default"].forwardRef(function L
|
|
|
32
32
|
...rest
|
|
33
33
|
} = _ref;
|
|
34
34
|
const prefix = usePrefix.usePrefix();
|
|
35
|
-
return /*#__PURE__*/React__default["default"].createElement("
|
|
35
|
+
return /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["extends"]({
|
|
36
36
|
ref: ref,
|
|
37
37
|
id: id,
|
|
38
38
|
className: `${prefix}--list-box__menu`,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { ForwardedRef } from 'react';
|
|
8
8
|
import { ForwardRefReturn, ReactAttr } from '../../types/common';
|
|
9
|
-
export interface ListBoxMenuItemProps extends ReactAttr<
|
|
9
|
+
export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
|
|
10
10
|
/**
|
|
11
11
|
* Specify whether the current menu item is "active".
|
|
12
12
|
*/
|
|
@@ -15,8 +15,12 @@ export interface ListBoxMenuItemProps extends ReactAttr<HTMLDivElement> {
|
|
|
15
15
|
* Specify whether the current menu item is "highlighted".
|
|
16
16
|
*/
|
|
17
17
|
isHighlighted?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Specify whether the item should be disabled
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
18
22
|
}
|
|
19
|
-
export type ListBoxMenuItemForwardedRef = (ForwardedRef<
|
|
23
|
+
export type ListBoxMenuItemForwardedRef = (ForwardedRef<HTMLLIElement> & {
|
|
20
24
|
menuItemOptionRef?: React.Ref<HTMLDivElement>;
|
|
21
25
|
}) | null;
|
|
22
26
|
export type ListBoxMenuItemComponent = ForwardRefReturn<ListBoxMenuItemForwardedRef, ListBoxMenuItemProps>;
|
|
@@ -52,10 +52,9 @@ const ListBoxMenuItem = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
52
52
|
[`${prefix}--list-box__menu-item--active`]: isActive,
|
|
53
53
|
[`${prefix}--list-box__menu-item--highlighted`]: isHighlighted
|
|
54
54
|
});
|
|
55
|
-
return /*#__PURE__*/React__default["default"].createElement("
|
|
55
|
+
return /*#__PURE__*/React__default["default"].createElement("li", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
56
56
|
className: className,
|
|
57
|
-
title: isTruncated ? title : undefined
|
|
58
|
-
tabIndex: -1
|
|
57
|
+
title: isTruncated ? title : undefined
|
|
59
58
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
60
59
|
className: `${prefix}--list-box__menu-item__option`,
|
|
61
60
|
ref: forwardedRef?.menuItemOptionRef || ref
|
|
@@ -68,6 +67,10 @@ ListBoxMenuItem.propTypes = {
|
|
|
68
67
|
* Menu Item
|
|
69
68
|
*/
|
|
70
69
|
children: PropTypes__default["default"].node,
|
|
70
|
+
/**
|
|
71
|
+
* Specify if the item should be disabled
|
|
72
|
+
*/
|
|
73
|
+
disabled: PropTypes__default["default"].bool,
|
|
71
74
|
/**
|
|
72
75
|
* Specify whether the current menu item is "active".
|
|
73
76
|
*/
|
|
@@ -45,6 +45,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
45
45
|
const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function FilterableMultiSelect(_ref, ref) {
|
|
46
46
|
let {
|
|
47
47
|
className: containerClassName,
|
|
48
|
+
clearSelectionDescription,
|
|
49
|
+
clearSelectionText,
|
|
48
50
|
compareItems,
|
|
49
51
|
direction,
|
|
50
52
|
disabled,
|
|
@@ -332,11 +334,18 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
332
334
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
333
335
|
}
|
|
334
336
|
};
|
|
337
|
+
const clearSelectionContent = selectedItems.length > 0 ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
338
|
+
className: `${prefix}--visually-hidden`
|
|
339
|
+
}, clearSelectionDescription, " ", selectedItems.length, ",", clearSelectionText) : /*#__PURE__*/React__default["default"].createElement("span", {
|
|
340
|
+
className: `${prefix}--visually-hidden`
|
|
341
|
+
}, clearSelectionDescription, ": 0");
|
|
335
342
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
336
343
|
className: wrapperClasses
|
|
337
344
|
}, titleText ? /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
338
345
|
className: titleClasses
|
|
339
|
-
}, labelProps), titleText
|
|
346
|
+
}, labelProps), titleText, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
347
|
+
className: `${prefix}--visually-hidden`
|
|
348
|
+
}, clearSelectionContent)) : null, /*#__PURE__*/React__default["default"].createElement(index["default"], {
|
|
340
349
|
onFocus: isFluid ? handleFocus : null,
|
|
341
350
|
onBlur: isFluid ? handleFocus : null,
|
|
342
351
|
className: className,
|
|
@@ -397,12 +406,13 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
397
406
|
compareItems,
|
|
398
407
|
locale
|
|
399
408
|
}).map((item, index$1) => {
|
|
409
|
+
const isChecked = selectedItem.filter(selected => isEqual__default["default"](selected, item)).length > 0;
|
|
400
410
|
const itemProps = getItemProps({
|
|
401
411
|
item,
|
|
402
|
-
disabled: item.disabled
|
|
412
|
+
disabled: item.disabled,
|
|
413
|
+
['aria-selected']: isChecked
|
|
403
414
|
});
|
|
404
415
|
const itemText = itemToString(item);
|
|
405
|
-
const isChecked = selectedItem.filter(selected => isEqual__default["default"](selected, item)).length > 0;
|
|
406
416
|
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
407
417
|
key: itemProps.id,
|
|
408
418
|
"aria-label": itemText,
|
|
@@ -435,6 +445,14 @@ FilterableMultiSelect.propTypes = {
|
|
|
435
445
|
* Specify a label to be read by screen readers on the container note.
|
|
436
446
|
*/
|
|
437
447
|
ariaLabel: deprecate["default"](PropTypes__default["default"].string, 'ariaLabel / aria-label props are no longer required for FilterableMultiSelect'),
|
|
448
|
+
/**
|
|
449
|
+
* Specify the text that should be read for screen readers that describes total items selected
|
|
450
|
+
*/
|
|
451
|
+
clearSelectionDescription: PropTypes__default["default"].string,
|
|
452
|
+
/**
|
|
453
|
+
* Specify the text that should be read for screen readers to clear selection.
|
|
454
|
+
*/
|
|
455
|
+
clearSelectionText: PropTypes__default["default"].string,
|
|
438
456
|
/**
|
|
439
457
|
* Specify the direction of the multiselect dropdown. Can be either top or bottom.
|
|
440
458
|
*/
|
|
@@ -556,7 +574,9 @@ FilterableMultiSelect.defaultProps = {
|
|
|
556
574
|
locale: 'en',
|
|
557
575
|
sortItems: sorting.defaultSortItems,
|
|
558
576
|
open: false,
|
|
559
|
-
selectionFeedback: 'top-after-reopen'
|
|
577
|
+
selectionFeedback: 'top-after-reopen',
|
|
578
|
+
clearSelectionText: 'To clear selection, press Delete or Backspace,',
|
|
579
|
+
clearSelectionDescription: 'Total items selected: '
|
|
560
580
|
};
|
|
561
581
|
var FilterableMultiSelect$1 = FilterableMultiSelect;
|
|
562
582
|
|
|
@@ -9,15 +9,13 @@ import React from 'react';
|
|
|
9
9
|
import { ListBoxSize, ListBoxType } from '../ListBox';
|
|
10
10
|
import { ListBoxProps } from '../ListBox/ListBox';
|
|
11
11
|
import { OnChangeData } from '../Dropdown';
|
|
12
|
+
import type { InternationalProps } from '../../types/common';
|
|
12
13
|
interface SharedOptions {
|
|
13
14
|
locale: string;
|
|
14
15
|
}
|
|
15
16
|
interface DownshiftTypedProps<ItemType> {
|
|
16
17
|
itemToString?(item: ItemType): string;
|
|
17
18
|
}
|
|
18
|
-
interface InternationalProps<MID = string, ARGS = Record<string, unknown>> {
|
|
19
|
-
translateWithId?(messageId: MID, args?: ARGS): string;
|
|
20
|
-
}
|
|
21
19
|
interface SortItemsOptions<ItemType> extends SharedOptions, DownshiftTypedProps<ItemType> {
|
|
22
20
|
compareItems(item1: ItemType, item2: ItemType, options: SharedOptions): number;
|
|
23
21
|
selectedItems: ItemType[];
|