@carbon/react 1.36.0-rc.0 → 1.37.0-rc.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/es/components/Breadcrumb/index.d.ts +11 -0
- package/es/components/BreadcrumbItem/index.d.ts +7 -0
- package/es/components/ComboBox/ComboBox.js +2 -4
- package/es/components/DataTable/DataTable.d.ts +26 -0
- package/es/components/DataTable/DataTable.js +25 -0
- 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/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +40 -40
- 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.js +77 -56
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/NumberInput/NumberInput.js +18 -44
- package/es/components/Slider/Slider.d.ts +6 -0
- package/es/components/Slider/Slider.js +17 -2
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/Tile/Tile.js +5 -5
- package/es/components/UIShell/SideNav.js +5 -1
- package/es/index.js +3 -3
- package/lib/components/Breadcrumb/index.d.ts +11 -0
- package/lib/components/BreadcrumbItem/index.d.ts +7 -0
- package/lib/components/ComboBox/ComboBox.js +2 -4
- package/lib/components/DataTable/DataTable.d.ts +26 -0
- package/lib/components/DataTable/DataTable.js +25 -0
- 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/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +39 -39
- 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.js +75 -55
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.js +18 -44
- package/lib/components/Slider/Slider.d.ts +6 -0
- package/lib/components/Slider/Slider.js +17 -2
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/Tile/Tile.js +5 -5
- package/lib/components/UIShell/SideNav.js +5 -1
- package/lib/index.js +6 -6
- package/package.json +7 -7
|
@@ -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
|
|
|
@@ -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 };
|
|
@@ -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 {
|
|
@@ -59,7 +59,7 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
|
|
|
59
59
|
id,
|
|
60
60
|
onChange: evt => {
|
|
61
61
|
if (!other.disabled && onChange) {
|
|
62
|
-
evt
|
|
62
|
+
evt?.persist?.();
|
|
63
63
|
// delay textCount assignation to give the textarea element value time to catch up if is a controlled input
|
|
64
64
|
setTimeout(() => {
|
|
65
65
|
setTextCount(evt.target?.value?.length);
|
|
@@ -72,12 +72,12 @@ const ClickableTile = /*#__PURE__*/React__default.forwardRef(function ClickableT
|
|
|
72
72
|
const classes = cx(`${prefix}--tile`, `${prefix}--tile--clickable`, clicked && `${prefix}--tile--is-clicked`, light && `${prefix}--tile--light`, className);
|
|
73
73
|
const [isSelected, setIsSelected] = useState(clicked);
|
|
74
74
|
function handleOnClick(evt) {
|
|
75
|
-
evt
|
|
75
|
+
evt?.persist?.();
|
|
76
76
|
setIsSelected(!isSelected);
|
|
77
77
|
onClick(evt);
|
|
78
78
|
}
|
|
79
79
|
function handleOnKeyDown(evt) {
|
|
80
|
-
evt
|
|
80
|
+
evt?.persist?.();
|
|
81
81
|
if (matches(evt, [Enter, Space])) {
|
|
82
82
|
evt.preventDefault();
|
|
83
83
|
setIsSelected(!isSelected);
|
|
@@ -181,7 +181,7 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
|
|
|
181
181
|
// TODO: rename to handleClick when handleClick prop is deprecated
|
|
182
182
|
function handleOnClick(evt) {
|
|
183
183
|
evt.preventDefault();
|
|
184
|
-
evt
|
|
184
|
+
evt?.persist?.();
|
|
185
185
|
setIsSelected(!isSelected);
|
|
186
186
|
clickHandler(evt);
|
|
187
187
|
onChange(evt);
|
|
@@ -189,7 +189,7 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
|
|
|
189
189
|
|
|
190
190
|
// TODO: rename to handleKeyDown when handleKeyDown prop is deprecated
|
|
191
191
|
function handleOnKeyDown(evt) {
|
|
192
|
-
evt
|
|
192
|
+
evt?.persist?.();
|
|
193
193
|
if (matches(evt, [Enter, Space])) {
|
|
194
194
|
evt.preventDefault();
|
|
195
195
|
setIsSelected(!isSelected);
|
|
@@ -335,7 +335,7 @@ const ExpandableTile = /*#__PURE__*/React__default.forwardRef(function Expandabl
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
function handleClick(evt) {
|
|
338
|
-
evt
|
|
338
|
+
evt?.persist?.();
|
|
339
339
|
setIsExpanded(!isExpanded);
|
|
340
340
|
setMaxHeight();
|
|
341
341
|
}
|
|
@@ -15,6 +15,8 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
15
15
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
16
16
|
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
17
17
|
import { useDelayedState } from '../../internal/useDelayedState.js';
|
|
18
|
+
import { breakpoints } from '@carbon/layout';
|
|
19
|
+
import { useMatchMedia } from '../../internal/useMatchMedia.js';
|
|
18
20
|
import { match } from '../../internal/keyboard/match.js';
|
|
19
21
|
import { Tab, Escape } from '../../internal/keyboard/keys.js';
|
|
20
22
|
|
|
@@ -152,6 +154,8 @@ function SideNavRenderFunction(_ref, ref) {
|
|
|
152
154
|
sideNavRef.current.focus();
|
|
153
155
|
}
|
|
154
156
|
});
|
|
157
|
+
const lgMediaQuery = `(min-width: ${breakpoints.lg.width})`;
|
|
158
|
+
const isLg = useMatchMedia(lgMediaQuery);
|
|
155
159
|
return /*#__PURE__*/React__default.createElement(SideNavContext.Provider, {
|
|
156
160
|
value: {
|
|
157
161
|
isRail
|
|
@@ -166,7 +170,7 @@ function SideNavRenderFunction(_ref, ref) {
|
|
|
166
170
|
tabIndex: -1,
|
|
167
171
|
ref: navRef,
|
|
168
172
|
className: `${prefix}--side-nav__navigation ${className}`,
|
|
169
|
-
inert: !isRail && (expanded ? undefined : -1)
|
|
173
|
+
inert: !isRail && (expanded || isLg ? undefined : -1)
|
|
170
174
|
}, accessibilityLabel, eventHandlers, other), childrenToRender));
|
|
171
175
|
}
|
|
172
176
|
const SideNav = /*#__PURE__*/React__default.forwardRef(SideNavRenderFunction);
|
package/es/index.js
CHANGED
|
@@ -10,6 +10,9 @@ export { default as Accordion } from './components/Accordion/Accordion.js';
|
|
|
10
10
|
export { default as AccordionItem } from './components/Accordion/AccordionItem.js';
|
|
11
11
|
export { default as AccordionSkeleton } from './components/Accordion/Accordion.Skeleton.js';
|
|
12
12
|
export { default as AspectRatio } from './components/AspectRatio/AspectRatio.js';
|
|
13
|
+
export { default as Breadcrumb } from './components/Breadcrumb/Breadcrumb.js';
|
|
14
|
+
export { default as BreadcrumbItem } from './components/Breadcrumb/BreadcrumbItem.js';
|
|
15
|
+
export { default as BreadcrumbSkeleton } from './components/Breadcrumb/Breadcrumb.Skeleton.js';
|
|
13
16
|
export { default as Button, ButtonKinds, ButtonSizes, ButtonTooltipAlignments, ButtonTooltipPositions } from './components/Button/Button.js';
|
|
14
17
|
export { default as ButtonSkeleton } from './components/Button/Button.Skeleton.js';
|
|
15
18
|
export { default as ButtonSet } from './components/ButtonSet/ButtonSet.js';
|
|
@@ -107,7 +110,6 @@ export { default as unstable__FluidTextInput } from './components/FluidTextInput
|
|
|
107
110
|
export { default as unstable__FluidTextInputSkeleton } from './components/FluidTextInput/FluidTextInput.Skeleton.js';
|
|
108
111
|
export { default as unstable_PageSelector } from './components/Pagination/experimental/PageSelector.js';
|
|
109
112
|
export { default as unstable_Pagination } from './components/Pagination/experimental/Pagination.js';
|
|
110
|
-
export { default as BreadcrumbSkeleton } from './components/Breadcrumb/Breadcrumb.Skeleton.js';
|
|
111
113
|
export { default as CheckboxGroup } from './components/CheckboxGroup/CheckboxGroup.js';
|
|
112
114
|
export { default as CodeSnippetSkeleton } from './components/CodeSnippet/CodeSnippet.Skeleton.js';
|
|
113
115
|
export { default as CodeSnippet } from './components/CodeSnippet/CodeSnippet.js';
|
|
@@ -155,8 +157,6 @@ export { LayoutDirection as unstable_LayoutDirection } from './components/Layout
|
|
|
155
157
|
export { useLayoutDirection as unstable_useLayoutDirection } from './components/LayoutDirection/useLayoutDirection.js';
|
|
156
158
|
export { Text as unstable_Text } from './components/Text/Text.js';
|
|
157
159
|
export { TextDirection as unstable_TextDirection } from './components/Text/TextDirection.js';
|
|
158
|
-
export { default as Breadcrumb } from './components/Breadcrumb/Breadcrumb.js';
|
|
159
|
-
export { default as BreadcrumbItem } from './components/Breadcrumb/BreadcrumbItem.js';
|
|
160
160
|
export { default as DataTable } from './components/DataTable/DataTable.js';
|
|
161
161
|
export { Table } from './components/DataTable/Table.js';
|
|
162
162
|
export { default as TableActionList } from './components/DataTable/TableActionList.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
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 Breadcrumb from './Breadcrumb';
|
|
8
|
+
import BreadcrumbItem from './BreadcrumbItem';
|
|
9
|
+
import BreadcrumbSkeleton from './Breadcrumb.Skeleton';
|
|
10
|
+
export { Breadcrumb, BreadcrumbItem, BreadcrumbSkeleton };
|
|
11
|
+
export default Breadcrumb;
|
|
@@ -219,7 +219,7 @@ const ComboBox = /*#__PURE__*/React__default["default"].forwardRef((props, ref)
|
|
|
219
219
|
}
|
|
220
220
|
if (event.target === textInput.current && isOpen) {
|
|
221
221
|
event.preventDownshiftDefault = true;
|
|
222
|
-
event
|
|
222
|
+
event?.persist?.();
|
|
223
223
|
}
|
|
224
224
|
};
|
|
225
225
|
const showWarning = !invalid && warn;
|
|
@@ -300,8 +300,6 @@ const ComboBox = /*#__PURE__*/React__default["default"].forwardRef((props, ref)
|
|
|
300
300
|
}
|
|
301
301
|
});
|
|
302
302
|
const inputProps = getInputProps({
|
|
303
|
-
// Remove excess aria `aria-labelledby`. HTML <label for> provides this aria information.
|
|
304
|
-
'aria-labelledby': null,
|
|
305
303
|
disabled,
|
|
306
304
|
placeholder,
|
|
307
305
|
onClick() {
|
|
@@ -318,7 +316,7 @@ const ComboBox = /*#__PURE__*/React__default["default"].forwardRef((props, ref)
|
|
|
318
316
|
if (event.target === textInput.current && isOpen) {
|
|
319
317
|
toggleMenu();
|
|
320
318
|
event.preventDownshiftDefault = true;
|
|
321
|
-
event
|
|
319
|
+
event?.persist?.();
|
|
322
320
|
}
|
|
323
321
|
}
|
|
324
322
|
if (match.match(event, keys.Home)) {
|