@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
|
@@ -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
|
|
@@ -23,7 +23,7 @@ const ListBoxMenu = /*#__PURE__*/React__default.forwardRef(function ListBoxMenu(
|
|
|
23
23
|
...rest
|
|
24
24
|
} = _ref;
|
|
25
25
|
const prefix = usePrefix();
|
|
26
|
-
return /*#__PURE__*/React__default.createElement("
|
|
26
|
+
return /*#__PURE__*/React__default.createElement("ul", _extends({
|
|
27
27
|
ref: ref,
|
|
28
28
|
id: id,
|
|
29
29
|
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>;
|
|
@@ -42,10 +42,9 @@ const ListBoxMenuItem = /*#__PURE__*/React__default.forwardRef(function ListBoxM
|
|
|
42
42
|
[`${prefix}--list-box__menu-item--active`]: isActive,
|
|
43
43
|
[`${prefix}--list-box__menu-item--highlighted`]: isHighlighted
|
|
44
44
|
});
|
|
45
|
-
return /*#__PURE__*/React__default.createElement("
|
|
45
|
+
return /*#__PURE__*/React__default.createElement("li", _extends({}, rest, {
|
|
46
46
|
className: className,
|
|
47
|
-
title: isTruncated ? title : undefined
|
|
48
|
-
tabIndex: -1
|
|
47
|
+
title: isTruncated ? title : undefined
|
|
49
48
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
50
49
|
className: `${prefix}--list-box__menu-item__option`,
|
|
51
50
|
ref: forwardedRef?.menuItemOptionRef || ref
|
|
@@ -58,6 +57,10 @@ ListBoxMenuItem.propTypes = {
|
|
|
58
57
|
* Menu Item
|
|
59
58
|
*/
|
|
60
59
|
children: PropTypes.node,
|
|
60
|
+
/**
|
|
61
|
+
* Specify if the item should be disabled
|
|
62
|
+
*/
|
|
63
|
+
disabled: PropTypes.bool,
|
|
61
64
|
/**
|
|
62
65
|
* Specify whether the current menu item is "active".
|
|
63
66
|
*/
|
|
@@ -33,6 +33,8 @@ import { Space, Enter, Delete, Escape, Tab, Home, End } from '../../internal/key
|
|
|
33
33
|
const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function FilterableMultiSelect(_ref, ref) {
|
|
34
34
|
let {
|
|
35
35
|
className: containerClassName,
|
|
36
|
+
clearSelectionDescription,
|
|
37
|
+
clearSelectionText,
|
|
36
38
|
compareItems,
|
|
37
39
|
direction,
|
|
38
40
|
disabled,
|
|
@@ -320,11 +322,18 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
320
322
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
321
323
|
}
|
|
322
324
|
};
|
|
325
|
+
const clearSelectionContent = selectedItems.length > 0 ? /*#__PURE__*/React__default.createElement("span", {
|
|
326
|
+
className: `${prefix}--visually-hidden`
|
|
327
|
+
}, clearSelectionDescription, " ", selectedItems.length, ",", clearSelectionText) : /*#__PURE__*/React__default.createElement("span", {
|
|
328
|
+
className: `${prefix}--visually-hidden`
|
|
329
|
+
}, clearSelectionDescription, ": 0");
|
|
323
330
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
324
331
|
className: wrapperClasses
|
|
325
332
|
}, titleText ? /*#__PURE__*/React__default.createElement("label", _extends({
|
|
326
333
|
className: titleClasses
|
|
327
|
-
}, labelProps), titleText
|
|
334
|
+
}, labelProps), titleText, /*#__PURE__*/React__default.createElement("span", {
|
|
335
|
+
className: `${prefix}--visually-hidden`
|
|
336
|
+
}, clearSelectionContent)) : null, /*#__PURE__*/React__default.createElement(ListBox, {
|
|
328
337
|
onFocus: isFluid ? handleFocus : null,
|
|
329
338
|
onBlur: isFluid ? handleFocus : null,
|
|
330
339
|
className: className,
|
|
@@ -385,12 +394,13 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
385
394
|
compareItems,
|
|
386
395
|
locale
|
|
387
396
|
}).map((item, index) => {
|
|
397
|
+
const isChecked = selectedItem.filter(selected => isEqual(selected, item)).length > 0;
|
|
388
398
|
const itemProps = getItemProps({
|
|
389
399
|
item,
|
|
390
|
-
disabled: item.disabled
|
|
400
|
+
disabled: item.disabled,
|
|
401
|
+
['aria-selected']: isChecked
|
|
391
402
|
});
|
|
392
403
|
const itemText = itemToString(item);
|
|
393
|
-
const isChecked = selectedItem.filter(selected => isEqual(selected, item)).length > 0;
|
|
394
404
|
return /*#__PURE__*/React__default.createElement(ListBox.MenuItem, _extends({
|
|
395
405
|
key: itemProps.id,
|
|
396
406
|
"aria-label": itemText,
|
|
@@ -423,6 +433,14 @@ FilterableMultiSelect.propTypes = {
|
|
|
423
433
|
* Specify a label to be read by screen readers on the container note.
|
|
424
434
|
*/
|
|
425
435
|
ariaLabel: deprecate(PropTypes.string, 'ariaLabel / aria-label props are no longer required for FilterableMultiSelect'),
|
|
436
|
+
/**
|
|
437
|
+
* Specify the text that should be read for screen readers that describes total items selected
|
|
438
|
+
*/
|
|
439
|
+
clearSelectionDescription: PropTypes.string,
|
|
440
|
+
/**
|
|
441
|
+
* Specify the text that should be read for screen readers to clear selection.
|
|
442
|
+
*/
|
|
443
|
+
clearSelectionText: PropTypes.string,
|
|
426
444
|
/**
|
|
427
445
|
* Specify the direction of the multiselect dropdown. Can be either top or bottom.
|
|
428
446
|
*/
|
|
@@ -544,7 +562,9 @@ FilterableMultiSelect.defaultProps = {
|
|
|
544
562
|
locale: 'en',
|
|
545
563
|
sortItems: defaultSortItems,
|
|
546
564
|
open: false,
|
|
547
|
-
selectionFeedback: 'top-after-reopen'
|
|
565
|
+
selectionFeedback: 'top-after-reopen',
|
|
566
|
+
clearSelectionText: 'To clear selection, press Delete or Backspace,',
|
|
567
|
+
clearSelectionDescription: 'Total items selected: '
|
|
548
568
|
};
|
|
549
569
|
var FilterableMultiSelect$1 = FilterableMultiSelect;
|
|
550
570
|
|
|
@@ -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[];
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
|
-
import
|
|
11
|
+
import { useSelect } from 'downshift';
|
|
12
12
|
import isEqual from 'lodash.isequal';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
14
|
import React__default, { useContext, useRef, useState } from 'react';
|
|
@@ -24,18 +24,22 @@ import '../FluidForm/FluidForm.js';
|
|
|
24
24
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
25
25
|
import { match } from '../../internal/keyboard/match.js';
|
|
26
26
|
import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
|
|
27
|
-
import { Delete, Escape, Space, ArrowDown } from '../../internal/keyboard/keys.js';
|
|
27
|
+
import { Delete, Escape, Space, ArrowDown, Enter } from '../../internal/keyboard/keys.js';
|
|
28
28
|
|
|
29
29
|
const noop = () => {};
|
|
30
30
|
const getInstanceId = setupGetInstanceId();
|
|
31
31
|
const {
|
|
32
32
|
ItemClick,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
ToggleButtonBlur,
|
|
34
|
+
ToggleButtonKeyDownArrowDown,
|
|
35
|
+
ToggleButtonKeyDownArrowUp,
|
|
36
|
+
ToggleButtonKeyDownEnter,
|
|
37
|
+
ToggleButtonKeyDownEscape,
|
|
38
|
+
ToggleButtonKeyDownSpaceButton,
|
|
39
|
+
ItemMouseMove,
|
|
40
|
+
ToggleButtonClick,
|
|
41
|
+
ToggleButtonKeyDownHome,
|
|
42
|
+
ToggleButtonKeyDownEnd
|
|
39
43
|
} = useSelect.stateChangeTypes;
|
|
40
44
|
const defaultItemToString = item => {
|
|
41
45
|
if (typeof item === 'string') {
|
|
@@ -49,7 +53,7 @@ const defaultItemToString = item => {
|
|
|
49
53
|
}
|
|
50
54
|
return '';
|
|
51
55
|
};
|
|
52
|
-
const MultiSelect = /*#__PURE__*/React__default.forwardRef(
|
|
56
|
+
const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
53
57
|
let {
|
|
54
58
|
className: containerClassName,
|
|
55
59
|
id,
|
|
@@ -92,7 +96,6 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(
|
|
|
92
96
|
const {
|
|
93
97
|
current: multiSelectInstanceId
|
|
94
98
|
} = useRef(getInstanceId());
|
|
95
|
-
const [highlightedIndex, setHighlightedIndex] = useState();
|
|
96
99
|
const [isFocused, setIsFocused] = useState(false);
|
|
97
100
|
const [inputFocused, setInputFocused] = useState(false);
|
|
98
101
|
const [isOpen, setIsOpen] = useState(open || false);
|
|
@@ -108,31 +111,46 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(
|
|
|
108
111
|
onChange,
|
|
109
112
|
selectedItems: selected
|
|
110
113
|
});
|
|
111
|
-
const {
|
|
112
|
-
getToggleButtonProps,
|
|
113
|
-
getLabelProps,
|
|
114
|
-
getMenuProps,
|
|
115
|
-
getItemProps,
|
|
116
|
-
selectedItem
|
|
117
|
-
} = useSelect({
|
|
114
|
+
const selectProps = {
|
|
118
115
|
...downshiftProps,
|
|
119
|
-
|
|
116
|
+
stateReducer,
|
|
120
117
|
isOpen,
|
|
121
118
|
itemToString: items => {
|
|
122
119
|
return Array.isArray(items) && items.map(function (item) {
|
|
123
120
|
return itemToString(item);
|
|
124
121
|
}).join(', ') || '';
|
|
125
122
|
},
|
|
126
|
-
onStateChange,
|
|
127
123
|
selectedItem: controlledSelectedItems,
|
|
128
|
-
items
|
|
129
|
-
|
|
124
|
+
items,
|
|
125
|
+
isItemDisabled(item, _index) {
|
|
126
|
+
return item.disabled;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const {
|
|
130
|
+
getToggleButtonProps,
|
|
131
|
+
getLabelProps,
|
|
132
|
+
getMenuProps,
|
|
133
|
+
getItemProps,
|
|
134
|
+
selectedItem,
|
|
135
|
+
highlightedIndex
|
|
136
|
+
} = useSelect(selectProps);
|
|
130
137
|
const toggleButtonProps = getToggleButtonProps({
|
|
131
138
|
onFocus: () => {
|
|
132
139
|
setInputFocused(true);
|
|
133
140
|
},
|
|
134
141
|
onBlur: () => {
|
|
135
142
|
setInputFocused(false);
|
|
143
|
+
},
|
|
144
|
+
onKeyDown: e => {
|
|
145
|
+
if (!disabled) {
|
|
146
|
+
if ((match(e, Delete) || match(e, Escape)) && !isOpen) {
|
|
147
|
+
clearSelection();
|
|
148
|
+
e.stopPropagation();
|
|
149
|
+
}
|
|
150
|
+
if ((match(e, Space) || match(e, ArrowDown) || match(e, Enter)) && !isOpen) {
|
|
151
|
+
setIsOpenWrapper(true);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
136
154
|
}
|
|
137
155
|
});
|
|
138
156
|
const mergedRef = mergeRefs(toggleButtonProps.ref, ref);
|
|
@@ -198,47 +216,54 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(
|
|
|
198
216
|
} else if (selectionFeedback === 'top-after-reopen') {
|
|
199
217
|
sortOptions.selectedItems = topItems;
|
|
200
218
|
}
|
|
201
|
-
function
|
|
202
|
-
if (changes.isOpen && !isOpen) {
|
|
203
|
-
setTopItems(controlledSelectedItems);
|
|
204
|
-
}
|
|
219
|
+
function stateReducer(state, actionAndChanges) {
|
|
205
220
|
const {
|
|
221
|
+
changes,
|
|
222
|
+
props,
|
|
206
223
|
type
|
|
224
|
+
} = actionAndChanges;
|
|
225
|
+
const {
|
|
226
|
+
highlightedIndex
|
|
207
227
|
} = changes;
|
|
228
|
+
if (changes.isOpen && !isOpen) {
|
|
229
|
+
setTopItems(controlledSelectedItems);
|
|
230
|
+
}
|
|
208
231
|
switch (type) {
|
|
209
232
|
case ItemClick:
|
|
210
|
-
case
|
|
233
|
+
case ToggleButtonKeyDownSpaceButton:
|
|
234
|
+
case ToggleButtonKeyDownEnter:
|
|
211
235
|
if (changes.selectedItem === undefined) {
|
|
212
236
|
break;
|
|
213
237
|
}
|
|
214
238
|
onItemChange(changes.selectedItem);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
case
|
|
221
|
-
case MenuKeyDownEscape:
|
|
239
|
+
return {
|
|
240
|
+
...changes,
|
|
241
|
+
highlightedIndex: state.highlightedIndex
|
|
242
|
+
};
|
|
243
|
+
case ToggleButtonBlur:
|
|
244
|
+
case ToggleButtonKeyDownEscape:
|
|
222
245
|
setIsOpenWrapper(false);
|
|
223
|
-
setHighlightedIndex(changes.highlightedIndex);
|
|
224
246
|
break;
|
|
225
247
|
case ToggleButtonClick:
|
|
226
248
|
setIsOpenWrapper(changes.isOpen || false);
|
|
227
|
-
setHighlightedIndex(changes.highlightedIndex);
|
|
228
249
|
break;
|
|
250
|
+
case ToggleButtonKeyDownArrowDown:
|
|
251
|
+
case ToggleButtonKeyDownArrowUp:
|
|
252
|
+
case ToggleButtonKeyDownHome:
|
|
253
|
+
case ToggleButtonKeyDownEnd:
|
|
254
|
+
if (highlightedIndex > -1) {
|
|
255
|
+
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
256
|
+
props.scrollIntoView(itemArray[highlightedIndex]);
|
|
257
|
+
}
|
|
258
|
+
return changes;
|
|
259
|
+
case ItemMouseMove:
|
|
260
|
+
return {
|
|
261
|
+
...changes,
|
|
262
|
+
highlightedIndex: state.highlightedIndex
|
|
263
|
+
};
|
|
229
264
|
}
|
|
265
|
+
return changes;
|
|
230
266
|
}
|
|
231
|
-
const onKeyDown = e => {
|
|
232
|
-
if (!disabled) {
|
|
233
|
-
if (match(e, Delete) || match(e, Escape)) {
|
|
234
|
-
clearSelection();
|
|
235
|
-
e.stopPropagation();
|
|
236
|
-
}
|
|
237
|
-
if (match(e, Space) || match(e, ArrowDown)) {
|
|
238
|
-
setIsOpenWrapper(true);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
267
|
const multiSelectFieldWrapperClasses = cx(`${prefix}--list-box__field--wrapper`, {
|
|
243
268
|
[`${prefix}--list-box__field--wrapper--input-focused`]: inputFocused
|
|
244
269
|
});
|
|
@@ -303,17 +328,14 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(
|
|
|
303
328
|
"aria-disabled": disabled || readOnly,
|
|
304
329
|
"aria-describedby": !inline && !invalid && !warn && helperText ? helperId : undefined
|
|
305
330
|
}, toggleButtonProps, {
|
|
306
|
-
ref: mergedRef
|
|
307
|
-
onKeyDown: onKeyDown
|
|
331
|
+
ref: mergedRef
|
|
308
332
|
}, readOnlyEventHandlers), /*#__PURE__*/React__default.createElement("span", {
|
|
309
333
|
id: fieldLabelId,
|
|
310
334
|
className: `${prefix}--list-box__label`
|
|
311
335
|
}, label), /*#__PURE__*/React__default.createElement(ListBox.MenuIcon, {
|
|
312
336
|
isOpen: isOpen,
|
|
313
337
|
translateWithId: translateWithId
|
|
314
|
-
}))), /*#__PURE__*/React__default.createElement(ListBox.Menu,
|
|
315
|
-
"aria-multiselectable": "true"
|
|
316
|
-
}, getMenuProps()), isOpen &&
|
|
338
|
+
}))), /*#__PURE__*/React__default.createElement(ListBox.Menu, getMenuProps(), isOpen &&
|
|
317
339
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
318
340
|
sortItems(items, sortOptions).map((item, index) => {
|
|
319
341
|
const isChecked = selectedItems.filter(selected => isEqual(selected, item)).length > 0;
|
|
@@ -321,8 +343,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(
|
|
|
321
343
|
item,
|
|
322
344
|
// we don't want Downshift to set aria-selected for us
|
|
323
345
|
// we also don't want to set 'false' for reader verbosity's sake
|
|
324
|
-
['aria-selected']: isChecked
|
|
325
|
-
disabled: item.disabled
|
|
346
|
+
['aria-selected']: isChecked
|
|
326
347
|
});
|
|
327
348
|
const itemText = itemToString(item);
|
|
328
349
|
return /*#__PURE__*/React__default.createElement(ListBox.MenuItem, _extends({
|
|
@@ -330,7 +351,8 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(
|
|
|
330
351
|
isActive: isChecked,
|
|
331
352
|
"aria-label": itemText,
|
|
332
353
|
isHighlighted: highlightedIndex === index,
|
|
333
|
-
title: itemText
|
|
354
|
+
title: itemText,
|
|
355
|
+
disabled: itemProps['aria-disabled']
|
|
334
356
|
}, itemProps), /*#__PURE__*/React__default.createElement("div", {
|
|
335
357
|
className: `${prefix}--checkbox-wrapper`
|
|
336
358
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
@@ -373,8 +395,7 @@ MultiSelect.propTypes = {
|
|
|
373
395
|
/**
|
|
374
396
|
* Additional props passed to Downshift
|
|
375
397
|
*/
|
|
376
|
-
|
|
377
|
-
downshiftProps: PropTypes.shape(Downshift.propTypes),
|
|
398
|
+
downshiftProps: PropTypes.object,
|
|
378
399
|
/**
|
|
379
400
|
* Provide helper text that is used alongside the control label for
|
|
380
401
|
* additional help
|
|
@@ -128,5 +128,5 @@ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
128
128
|
*/
|
|
129
129
|
warnText?: ReactNode;
|
|
130
130
|
}
|
|
131
|
-
declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<
|
|
131
|
+
declare const NumberInput: React.ForwardRefExoticComponent<NumberInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
132
132
|
export { NumberInput };
|
|
@@ -149,6 +149,22 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
149
149
|
[`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
|
|
150
150
|
});
|
|
151
151
|
const Icon = normalizedProps.icon;
|
|
152
|
+
function handleStepperClick(event, direction) {
|
|
153
|
+
if (inputRef.current) {
|
|
154
|
+
direction === 'up' ? inputRef.current.stepUp() : inputRef.current.stepDown();
|
|
155
|
+
const state = {
|
|
156
|
+
value: Number(inputRef.current.value),
|
|
157
|
+
direction: direction
|
|
158
|
+
};
|
|
159
|
+
setValue(state.value);
|
|
160
|
+
if (onChange) {
|
|
161
|
+
onChange(event, state);
|
|
162
|
+
}
|
|
163
|
+
if (onClick) {
|
|
164
|
+
onClick(event, state);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
152
168
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
153
169
|
className: outerElementClasses,
|
|
154
170
|
onFocus: isFluid ? handleFocus : undefined,
|
|
@@ -204,19 +220,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
204
220
|
"aria-label": decrementNumLabel || iconDescription,
|
|
205
221
|
className: `${prefix}--number__control-btn down-icon`,
|
|
206
222
|
disabled: disabled || readOnly,
|
|
207
|
-
onClick: event =>
|
|
208
|
-
const state = {
|
|
209
|
-
value: clamp(max, min, parseInt(value) - step),
|
|
210
|
-
direction: 'down'
|
|
211
|
-
};
|
|
212
|
-
setValue(state.value);
|
|
213
|
-
if (onChange) {
|
|
214
|
-
onChange(event, state);
|
|
215
|
-
}
|
|
216
|
-
if (onClick) {
|
|
217
|
-
onClick(event, state);
|
|
218
|
-
}
|
|
219
|
-
},
|
|
223
|
+
onClick: event => handleStepperClick(event, 'down'),
|
|
220
224
|
tabIndex: -1,
|
|
221
225
|
title: decrementNumLabel || iconDescription,
|
|
222
226
|
type: "button"
|
|
@@ -228,19 +232,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
228
232
|
"aria-label": incrementNumLabel || iconDescription,
|
|
229
233
|
className: `${prefix}--number__control-btn up-icon`,
|
|
230
234
|
disabled: disabled || readOnly,
|
|
231
|
-
onClick: event =>
|
|
232
|
-
const state = {
|
|
233
|
-
value: clamp(max, min, parseInt(value) + step),
|
|
234
|
-
direction: 'up'
|
|
235
|
-
};
|
|
236
|
-
setValue(state.value);
|
|
237
|
-
if (onChange) {
|
|
238
|
-
onChange(event, state);
|
|
239
|
-
}
|
|
240
|
-
if (onClick) {
|
|
241
|
-
onClick(event, state);
|
|
242
|
-
}
|
|
243
|
-
},
|
|
235
|
+
onClick: event => handleStepperClick(event, 'up'),
|
|
244
236
|
tabIndex: -1,
|
|
245
237
|
title: incrementNumLabel || iconDescription,
|
|
246
238
|
type: "button"
|
|
@@ -467,22 +459,4 @@ function disableWheel(e) {
|
|
|
467
459
|
e.preventDefault();
|
|
468
460
|
}
|
|
469
461
|
|
|
470
|
-
/**
|
|
471
|
-
* Clamp the given value between the upper bound `max` and the lower bound `min`
|
|
472
|
-
*
|
|
473
|
-
* 16 digit min/max more precise than Infinity. Somewhere in 9 quadrillion,
|
|
474
|
-
* there will be integer display issues at runtime. 9quad is a safe cutoff.
|
|
475
|
-
* @param {number} max
|
|
476
|
-
* @param {number} min
|
|
477
|
-
* @param {number} value
|
|
478
|
-
*/
|
|
479
|
-
const boundLimit = 9000000000000000; // 16 digit, 9 quadrillion
|
|
480
|
-
|
|
481
|
-
function clamp() {
|
|
482
|
-
let max = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : boundLimit;
|
|
483
|
-
let min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -boundLimit;
|
|
484
|
-
let value = arguments.length > 2 ? arguments[2] : undefined;
|
|
485
|
-
return Math.min(max, Math.max(min, value));
|
|
486
|
-
}
|
|
487
|
-
|
|
488
462
|
export { NumberInput, translationIds };
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
export interface SkeletonPlaceholderProps {
|
|
9
|
+
/**
|
|
10
|
+
* Add a custom class to the component to set the height and width
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const SkeletonPlaceholder: {
|
|
15
|
+
({ className, ...other }: SkeletonPlaceholderProps): JSX.Element;
|
|
16
|
+
propTypes: {
|
|
17
|
+
/**
|
|
18
|
+
* Add a custom class to the component
|
|
19
|
+
* to set the height and width
|
|
20
|
+
*/
|
|
21
|
+
className: PropTypes.Requireable<string>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default SkeletonPlaceholder;
|
|
@@ -18,9 +18,8 @@ const SkeletonPlaceholder = _ref => {
|
|
|
18
18
|
} = _ref;
|
|
19
19
|
const prefix = usePrefix();
|
|
20
20
|
const skeletonPlaceholderClasses = cx({
|
|
21
|
-
[`${prefix}--skeleton__placeholder`]: true
|
|
22
|
-
|
|
23
|
-
});
|
|
21
|
+
[`${prefix}--skeleton__placeholder`]: true
|
|
22
|
+
}, className);
|
|
24
23
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
25
24
|
className: skeletonPlaceholderClasses
|
|
26
25
|
}, other));
|
|
@@ -32,6 +31,5 @@ SkeletonPlaceholder.propTypes = {
|
|
|
32
31
|
*/
|
|
33
32
|
className: PropTypes.string
|
|
34
33
|
};
|
|
35
|
-
var SkeletonPlaceholder$1 = SkeletonPlaceholder;
|
|
36
34
|
|
|
37
|
-
export { SkeletonPlaceholder
|
|
35
|
+
export { SkeletonPlaceholder as default };
|
|
@@ -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 SkeletonPlaceholder from './SkeletonPlaceholder';
|
|
8
|
+
export default SkeletonPlaceholder;
|
|
9
|
+
export { SkeletonPlaceholder };
|
|
@@ -300,6 +300,12 @@ export default class Slider extends PureComponent<SliderProps> {
|
|
|
300
300
|
* @returns `val` if `max>=val>=min`; `min` if `val<min`; `max` if `val>max`.
|
|
301
301
|
*/
|
|
302
302
|
clamp(val: any, min: any, max: any): number;
|
|
303
|
+
/**
|
|
304
|
+
* Takes a value and ensures it fits to the steps of the range
|
|
305
|
+
* @param value
|
|
306
|
+
* @returns value of the nearest step
|
|
307
|
+
*/
|
|
308
|
+
nearestStepValue(value: any): number;
|
|
303
309
|
/**
|
|
304
310
|
* Sets up "drag" event handlers and calls `this.onDrag` in case dragging
|
|
305
311
|
* started on somewhere other than the thumb without a corresponding "move"
|
|
@@ -129,7 +129,7 @@ class Slider extends PureComponent {
|
|
|
129
129
|
clientX
|
|
130
130
|
});
|
|
131
131
|
this.setState({
|
|
132
|
-
value,
|
|
132
|
+
value: this.nearestStepValue(value),
|
|
133
133
|
left,
|
|
134
134
|
isValid: true
|
|
135
135
|
});
|
|
@@ -178,7 +178,7 @@ class Slider extends PureComponent {
|
|
|
178
178
|
value: (delta > 0 ? Math.floor(this.state.value / (this.props.step ?? Slider.defaultProps.step)) * (this.props.step ?? Slider.defaultProps.step) : this.state.value) + delta
|
|
179
179
|
});
|
|
180
180
|
this.setState({
|
|
181
|
-
value,
|
|
181
|
+
value: this.nearestStepValue(value),
|
|
182
182
|
left,
|
|
183
183
|
isValid: true
|
|
184
184
|
});
|
|
@@ -388,6 +388,21 @@ class Slider extends PureComponent {
|
|
|
388
388
|
clamp(val, min, max) {
|
|
389
389
|
return Math.max(min, Math.min(val, max));
|
|
390
390
|
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Takes a value and ensures it fits to the steps of the range
|
|
394
|
+
* @param value
|
|
395
|
+
* @returns value of the nearest step
|
|
396
|
+
*/
|
|
397
|
+
nearestStepValue(value) {
|
|
398
|
+
const tempInput = document.createElement('input');
|
|
399
|
+
tempInput.type = 'range';
|
|
400
|
+
tempInput.min = `${this.props.min}`;
|
|
401
|
+
tempInput.max = `${this.props.max}`;
|
|
402
|
+
tempInput.step = `${this.props.step}`;
|
|
403
|
+
tempInput.value = `${value}`;
|
|
404
|
+
return parseFloat(tempInput.value);
|
|
405
|
+
}
|
|
391
406
|
// syncs invalid state and prop
|
|
392
407
|
static getDerivedStateFromProps(props, state) {
|
|
393
408
|
const {
|
|
@@ -161,11 +161,14 @@ function StructuredListRow(props) {
|
|
|
161
161
|
return head ? /*#__PURE__*/React__default.createElement("div", _extends({
|
|
162
162
|
role: "row"
|
|
163
163
|
}, other, {
|
|
164
|
-
className: classes
|
|
164
|
+
className: classes,
|
|
165
|
+
"aria-busy": "true"
|
|
165
166
|
}), children) :
|
|
166
167
|
/*#__PURE__*/
|
|
167
168
|
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
168
|
-
React__default.createElement("div", _extends({
|
|
169
|
+
React__default.createElement("div", _extends({
|
|
170
|
+
"aria-busy": "true"
|
|
171
|
+
}, other, {
|
|
169
172
|
role: "row",
|
|
170
173
|
className: classes,
|
|
171
174
|
onClick: () => {
|
|
@@ -0,0 +1,35 @@
|
|
|
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 TagSkeletonProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
10
|
+
/**
|
|
11
|
+
* Specify an optional className to add.
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Specify the size of the Tag. Currently supports either `sm` or
|
|
16
|
+
* default sizes.
|
|
17
|
+
*/
|
|
18
|
+
size?: 'sm';
|
|
19
|
+
}
|
|
20
|
+
declare function TagSkeleton({ className, size, ...rest }: TagSkeletonProps): JSX.Element;
|
|
21
|
+
declare namespace TagSkeleton {
|
|
22
|
+
var propTypes: {
|
|
23
|
+
/**
|
|
24
|
+
* Specify an optional className to add.
|
|
25
|
+
*/
|
|
26
|
+
className: PropTypes.Requireable<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Specify the size of the Tag. Currently supports either `sm` or
|
|
29
|
+
* default sizes.
|
|
30
|
+
*/
|
|
31
|
+
size: PropTypes.Requireable<string>;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export default TagSkeleton;
|
|
35
|
+
export { TagSkeleton };
|