@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
|
@@ -33,7 +33,6 @@ var keys = require('../../internal/keyboard/keys.js');
|
|
|
33
33
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
34
34
|
|
|
35
35
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
36
|
-
var Downshift__default = /*#__PURE__*/_interopDefaultLegacy(Downshift);
|
|
37
36
|
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
38
37
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
39
38
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
@@ -42,12 +41,16 @@ const noop = () => {};
|
|
|
42
41
|
const getInstanceId = setupGetInstanceId["default"]();
|
|
43
42
|
const {
|
|
44
43
|
ItemClick,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
ToggleButtonBlur,
|
|
45
|
+
ToggleButtonKeyDownArrowDown,
|
|
46
|
+
ToggleButtonKeyDownArrowUp,
|
|
47
|
+
ToggleButtonKeyDownEnter,
|
|
48
|
+
ToggleButtonKeyDownEscape,
|
|
49
|
+
ToggleButtonKeyDownSpaceButton,
|
|
50
|
+
ItemMouseMove,
|
|
51
|
+
ToggleButtonClick,
|
|
52
|
+
ToggleButtonKeyDownHome,
|
|
53
|
+
ToggleButtonKeyDownEnd
|
|
51
54
|
} = Downshift.useSelect.stateChangeTypes;
|
|
52
55
|
const defaultItemToString = item => {
|
|
53
56
|
if (typeof item === 'string') {
|
|
@@ -61,7 +64,7 @@ const defaultItemToString = item => {
|
|
|
61
64
|
}
|
|
62
65
|
return '';
|
|
63
66
|
};
|
|
64
|
-
const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
67
|
+
const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
65
68
|
let {
|
|
66
69
|
className: containerClassName,
|
|
67
70
|
id,
|
|
@@ -104,7 +107,6 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function M
|
|
|
104
107
|
const {
|
|
105
108
|
current: multiSelectInstanceId
|
|
106
109
|
} = React.useRef(getInstanceId());
|
|
107
|
-
const [highlightedIndex, setHighlightedIndex] = React.useState();
|
|
108
110
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
109
111
|
const [inputFocused, setInputFocused] = React.useState(false);
|
|
110
112
|
const [isOpen, setIsOpen] = React.useState(open || false);
|
|
@@ -120,31 +122,46 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function M
|
|
|
120
122
|
onChange,
|
|
121
123
|
selectedItems: selected
|
|
122
124
|
});
|
|
123
|
-
const {
|
|
124
|
-
getToggleButtonProps,
|
|
125
|
-
getLabelProps,
|
|
126
|
-
getMenuProps,
|
|
127
|
-
getItemProps,
|
|
128
|
-
selectedItem
|
|
129
|
-
} = Downshift.useSelect({
|
|
125
|
+
const selectProps = {
|
|
130
126
|
...downshiftProps,
|
|
131
|
-
|
|
127
|
+
stateReducer,
|
|
132
128
|
isOpen,
|
|
133
129
|
itemToString: items => {
|
|
134
130
|
return Array.isArray(items) && items.map(function (item) {
|
|
135
131
|
return itemToString(item);
|
|
136
132
|
}).join(', ') || '';
|
|
137
133
|
},
|
|
138
|
-
onStateChange,
|
|
139
134
|
selectedItem: controlledSelectedItems,
|
|
140
|
-
items
|
|
141
|
-
|
|
135
|
+
items,
|
|
136
|
+
isItemDisabled(item, _index) {
|
|
137
|
+
return item.disabled;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const {
|
|
141
|
+
getToggleButtonProps,
|
|
142
|
+
getLabelProps,
|
|
143
|
+
getMenuProps,
|
|
144
|
+
getItemProps,
|
|
145
|
+
selectedItem,
|
|
146
|
+
highlightedIndex
|
|
147
|
+
} = Downshift.useSelect(selectProps);
|
|
142
148
|
const toggleButtonProps = getToggleButtonProps({
|
|
143
149
|
onFocus: () => {
|
|
144
150
|
setInputFocused(true);
|
|
145
151
|
},
|
|
146
152
|
onBlur: () => {
|
|
147
153
|
setInputFocused(false);
|
|
154
|
+
},
|
|
155
|
+
onKeyDown: e => {
|
|
156
|
+
if (!disabled) {
|
|
157
|
+
if ((match.match(e, keys.Delete) || match.match(e, keys.Escape)) && !isOpen) {
|
|
158
|
+
clearSelection();
|
|
159
|
+
e.stopPropagation();
|
|
160
|
+
}
|
|
161
|
+
if ((match.match(e, keys.Space) || match.match(e, keys.ArrowDown) || match.match(e, keys.Enter)) && !isOpen) {
|
|
162
|
+
setIsOpenWrapper(true);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
148
165
|
}
|
|
149
166
|
});
|
|
150
167
|
const mergedRef = mergeRefs["default"](toggleButtonProps.ref, ref);
|
|
@@ -210,47 +227,54 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function M
|
|
|
210
227
|
} else if (selectionFeedback === 'top-after-reopen') {
|
|
211
228
|
sortOptions.selectedItems = topItems;
|
|
212
229
|
}
|
|
213
|
-
function
|
|
214
|
-
if (changes.isOpen && !isOpen) {
|
|
215
|
-
setTopItems(controlledSelectedItems);
|
|
216
|
-
}
|
|
230
|
+
function stateReducer(state, actionAndChanges) {
|
|
217
231
|
const {
|
|
232
|
+
changes,
|
|
233
|
+
props,
|
|
218
234
|
type
|
|
235
|
+
} = actionAndChanges;
|
|
236
|
+
const {
|
|
237
|
+
highlightedIndex
|
|
219
238
|
} = changes;
|
|
239
|
+
if (changes.isOpen && !isOpen) {
|
|
240
|
+
setTopItems(controlledSelectedItems);
|
|
241
|
+
}
|
|
220
242
|
switch (type) {
|
|
221
243
|
case ItemClick:
|
|
222
|
-
case
|
|
244
|
+
case ToggleButtonKeyDownSpaceButton:
|
|
245
|
+
case ToggleButtonKeyDownEnter:
|
|
223
246
|
if (changes.selectedItem === undefined) {
|
|
224
247
|
break;
|
|
225
248
|
}
|
|
226
249
|
onItemChange(changes.selectedItem);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
case
|
|
233
|
-
case MenuKeyDownEscape:
|
|
250
|
+
return {
|
|
251
|
+
...changes,
|
|
252
|
+
highlightedIndex: state.highlightedIndex
|
|
253
|
+
};
|
|
254
|
+
case ToggleButtonBlur:
|
|
255
|
+
case ToggleButtonKeyDownEscape:
|
|
234
256
|
setIsOpenWrapper(false);
|
|
235
|
-
setHighlightedIndex(changes.highlightedIndex);
|
|
236
257
|
break;
|
|
237
258
|
case ToggleButtonClick:
|
|
238
259
|
setIsOpenWrapper(changes.isOpen || false);
|
|
239
|
-
setHighlightedIndex(changes.highlightedIndex);
|
|
240
260
|
break;
|
|
261
|
+
case ToggleButtonKeyDownArrowDown:
|
|
262
|
+
case ToggleButtonKeyDownArrowUp:
|
|
263
|
+
case ToggleButtonKeyDownHome:
|
|
264
|
+
case ToggleButtonKeyDownEnd:
|
|
265
|
+
if (highlightedIndex > -1) {
|
|
266
|
+
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
267
|
+
props.scrollIntoView(itemArray[highlightedIndex]);
|
|
268
|
+
}
|
|
269
|
+
return changes;
|
|
270
|
+
case ItemMouseMove:
|
|
271
|
+
return {
|
|
272
|
+
...changes,
|
|
273
|
+
highlightedIndex: state.highlightedIndex
|
|
274
|
+
};
|
|
241
275
|
}
|
|
276
|
+
return changes;
|
|
242
277
|
}
|
|
243
|
-
const onKeyDown = e => {
|
|
244
|
-
if (!disabled) {
|
|
245
|
-
if (match.match(e, keys.Delete) || match.match(e, keys.Escape)) {
|
|
246
|
-
clearSelection();
|
|
247
|
-
e.stopPropagation();
|
|
248
|
-
}
|
|
249
|
-
if (match.match(e, keys.Space) || match.match(e, keys.ArrowDown)) {
|
|
250
|
-
setIsOpenWrapper(true);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
278
|
const multiSelectFieldWrapperClasses = cx__default["default"](`${prefix}--list-box__field--wrapper`, {
|
|
255
279
|
[`${prefix}--list-box__field--wrapper--input-focused`]: inputFocused
|
|
256
280
|
});
|
|
@@ -315,17 +339,14 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function M
|
|
|
315
339
|
"aria-disabled": disabled || readOnly,
|
|
316
340
|
"aria-describedby": !inline && !invalid && !warn && helperText ? helperId : undefined
|
|
317
341
|
}, toggleButtonProps, {
|
|
318
|
-
ref: mergedRef
|
|
319
|
-
onKeyDown: onKeyDown
|
|
342
|
+
ref: mergedRef
|
|
320
343
|
}, readOnlyEventHandlers), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
321
344
|
id: fieldLabelId,
|
|
322
345
|
className: `${prefix}--list-box__label`
|
|
323
346
|
}, label), /*#__PURE__*/React__default["default"].createElement(index["default"].MenuIcon, {
|
|
324
347
|
isOpen: isOpen,
|
|
325
348
|
translateWithId: translateWithId
|
|
326
|
-
}))), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu,
|
|
327
|
-
"aria-multiselectable": "true"
|
|
328
|
-
}, getMenuProps()), isOpen &&
|
|
349
|
+
}))), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, getMenuProps(), isOpen &&
|
|
329
350
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
330
351
|
sortItems(items, sortOptions).map((item, index$1) => {
|
|
331
352
|
const isChecked = selectedItems.filter(selected => isEqual__default["default"](selected, item)).length > 0;
|
|
@@ -333,8 +354,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function M
|
|
|
333
354
|
item,
|
|
334
355
|
// we don't want Downshift to set aria-selected for us
|
|
335
356
|
// we also don't want to set 'false' for reader verbosity's sake
|
|
336
|
-
['aria-selected']: isChecked
|
|
337
|
-
disabled: item.disabled
|
|
357
|
+
['aria-selected']: isChecked
|
|
338
358
|
});
|
|
339
359
|
const itemText = itemToString(item);
|
|
340
360
|
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -342,7 +362,8 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function M
|
|
|
342
362
|
isActive: isChecked,
|
|
343
363
|
"aria-label": itemText,
|
|
344
364
|
isHighlighted: highlightedIndex === index$1,
|
|
345
|
-
title: itemText
|
|
365
|
+
title: itemText,
|
|
366
|
+
disabled: itemProps['aria-disabled']
|
|
346
367
|
}, itemProps), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
347
368
|
className: `${prefix}--checkbox-wrapper`
|
|
348
369
|
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -385,8 +406,7 @@ MultiSelect.propTypes = {
|
|
|
385
406
|
/**
|
|
386
407
|
* Additional props passed to Downshift
|
|
387
408
|
*/
|
|
388
|
-
|
|
389
|
-
downshiftProps: PropTypes__default["default"].shape(Downshift__default["default"].propTypes),
|
|
409
|
+
downshiftProps: PropTypes__default["default"].object,
|
|
390
410
|
/**
|
|
391
411
|
* Provide helper text that is used alongside the control label for
|
|
392
412
|
* 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 };
|
|
@@ -159,6 +159,22 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
159
159
|
[`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
|
|
160
160
|
});
|
|
161
161
|
const Icon = normalizedProps.icon;
|
|
162
|
+
function handleStepperClick(event, direction) {
|
|
163
|
+
if (inputRef.current) {
|
|
164
|
+
direction === 'up' ? inputRef.current.stepUp() : inputRef.current.stepDown();
|
|
165
|
+
const state = {
|
|
166
|
+
value: Number(inputRef.current.value),
|
|
167
|
+
direction: direction
|
|
168
|
+
};
|
|
169
|
+
setValue(state.value);
|
|
170
|
+
if (onChange) {
|
|
171
|
+
onChange(event, state);
|
|
172
|
+
}
|
|
173
|
+
if (onClick) {
|
|
174
|
+
onClick(event, state);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
162
178
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
163
179
|
className: outerElementClasses,
|
|
164
180
|
onFocus: isFluid ? handleFocus : undefined,
|
|
@@ -214,19 +230,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
214
230
|
"aria-label": decrementNumLabel || iconDescription,
|
|
215
231
|
className: `${prefix}--number__control-btn down-icon`,
|
|
216
232
|
disabled: disabled || readOnly,
|
|
217
|
-
onClick: event =>
|
|
218
|
-
const state = {
|
|
219
|
-
value: clamp(max, min, parseInt(value) - step),
|
|
220
|
-
direction: 'down'
|
|
221
|
-
};
|
|
222
|
-
setValue(state.value);
|
|
223
|
-
if (onChange) {
|
|
224
|
-
onChange(event, state);
|
|
225
|
-
}
|
|
226
|
-
if (onClick) {
|
|
227
|
-
onClick(event, state);
|
|
228
|
-
}
|
|
229
|
-
},
|
|
233
|
+
onClick: event => handleStepperClick(event, 'down'),
|
|
230
234
|
tabIndex: -1,
|
|
231
235
|
title: decrementNumLabel || iconDescription,
|
|
232
236
|
type: "button"
|
|
@@ -238,19 +242,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
238
242
|
"aria-label": incrementNumLabel || iconDescription,
|
|
239
243
|
className: `${prefix}--number__control-btn up-icon`,
|
|
240
244
|
disabled: disabled || readOnly,
|
|
241
|
-
onClick: event =>
|
|
242
|
-
const state = {
|
|
243
|
-
value: clamp(max, min, parseInt(value) + step),
|
|
244
|
-
direction: 'up'
|
|
245
|
-
};
|
|
246
|
-
setValue(state.value);
|
|
247
|
-
if (onChange) {
|
|
248
|
-
onChange(event, state);
|
|
249
|
-
}
|
|
250
|
-
if (onClick) {
|
|
251
|
-
onClick(event, state);
|
|
252
|
-
}
|
|
253
|
-
},
|
|
245
|
+
onClick: event => handleStepperClick(event, 'up'),
|
|
254
246
|
tabIndex: -1,
|
|
255
247
|
title: incrementNumLabel || iconDescription,
|
|
256
248
|
type: "button"
|
|
@@ -477,23 +469,5 @@ function disableWheel(e) {
|
|
|
477
469
|
e.preventDefault();
|
|
478
470
|
}
|
|
479
471
|
|
|
480
|
-
/**
|
|
481
|
-
* Clamp the given value between the upper bound `max` and the lower bound `min`
|
|
482
|
-
*
|
|
483
|
-
* 16 digit min/max more precise than Infinity. Somewhere in 9 quadrillion,
|
|
484
|
-
* there will be integer display issues at runtime. 9quad is a safe cutoff.
|
|
485
|
-
* @param {number} max
|
|
486
|
-
* @param {number} min
|
|
487
|
-
* @param {number} value
|
|
488
|
-
*/
|
|
489
|
-
const boundLimit = 9000000000000000; // 16 digit, 9 quadrillion
|
|
490
|
-
|
|
491
|
-
function clamp() {
|
|
492
|
-
let max = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : boundLimit;
|
|
493
|
-
let min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -boundLimit;
|
|
494
|
-
let value = arguments.length > 2 ? arguments[2] : undefined;
|
|
495
|
-
return Math.min(max, Math.max(min, value));
|
|
496
|
-
}
|
|
497
|
-
|
|
498
472
|
exports.NumberInput = NumberInput;
|
|
499
473
|
exports.translationIds = 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;
|
|
@@ -28,9 +28,8 @@ const SkeletonPlaceholder = _ref => {
|
|
|
28
28
|
} = _ref;
|
|
29
29
|
const prefix = usePrefix.usePrefix();
|
|
30
30
|
const skeletonPlaceholderClasses = cx__default["default"]({
|
|
31
|
-
[`${prefix}--skeleton__placeholder`]: true
|
|
32
|
-
|
|
33
|
-
});
|
|
31
|
+
[`${prefix}--skeleton__placeholder`]: true
|
|
32
|
+
}, className);
|
|
34
33
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
35
34
|
className: skeletonPlaceholderClasses
|
|
36
35
|
}, other));
|
|
@@ -42,6 +41,5 @@ SkeletonPlaceholder.propTypes = {
|
|
|
42
41
|
*/
|
|
43
42
|
className: PropTypes__default["default"].string
|
|
44
43
|
};
|
|
45
|
-
var SkeletonPlaceholder$1 = SkeletonPlaceholder;
|
|
46
44
|
|
|
47
|
-
exports["default"] = SkeletonPlaceholder
|
|
45
|
+
exports["default"] = SkeletonPlaceholder;
|
|
@@ -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"
|
|
@@ -140,7 +140,7 @@ class Slider extends React.PureComponent {
|
|
|
140
140
|
clientX
|
|
141
141
|
});
|
|
142
142
|
this.setState({
|
|
143
|
-
value,
|
|
143
|
+
value: this.nearestStepValue(value),
|
|
144
144
|
left,
|
|
145
145
|
isValid: true
|
|
146
146
|
});
|
|
@@ -189,7 +189,7 @@ class Slider extends React.PureComponent {
|
|
|
189
189
|
value: (delta > 0 ? Math.floor(this.state.value / (this.props.step ?? Slider.defaultProps.step)) * (this.props.step ?? Slider.defaultProps.step) : this.state.value) + delta
|
|
190
190
|
});
|
|
191
191
|
this.setState({
|
|
192
|
-
value,
|
|
192
|
+
value: this.nearestStepValue(value),
|
|
193
193
|
left,
|
|
194
194
|
isValid: true
|
|
195
195
|
});
|
|
@@ -399,6 +399,21 @@ class Slider extends React.PureComponent {
|
|
|
399
399
|
clamp(val, min, max) {
|
|
400
400
|
return Math.max(min, Math.min(val, max));
|
|
401
401
|
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Takes a value and ensures it fits to the steps of the range
|
|
405
|
+
* @param value
|
|
406
|
+
* @returns value of the nearest step
|
|
407
|
+
*/
|
|
408
|
+
nearestStepValue(value) {
|
|
409
|
+
const tempInput = document.createElement('input');
|
|
410
|
+
tempInput.type = 'range';
|
|
411
|
+
tempInput.min = `${this.props.min}`;
|
|
412
|
+
tempInput.max = `${this.props.max}`;
|
|
413
|
+
tempInput.step = `${this.props.step}`;
|
|
414
|
+
tempInput.value = `${value}`;
|
|
415
|
+
return parseFloat(tempInput.value);
|
|
416
|
+
}
|
|
402
417
|
// syncs invalid state and prop
|
|
403
418
|
static getDerivedStateFromProps(props, state) {
|
|
404
419
|
const {
|
|
@@ -171,11 +171,14 @@ function StructuredListRow(props) {
|
|
|
171
171
|
return head ? /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
172
172
|
role: "row"
|
|
173
173
|
}, other, {
|
|
174
|
-
className: classes
|
|
174
|
+
className: classes,
|
|
175
|
+
"aria-busy": "true"
|
|
175
176
|
}), children) :
|
|
176
177
|
/*#__PURE__*/
|
|
177
178
|
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
178
|
-
React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
179
|
+
React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
180
|
+
"aria-busy": "true"
|
|
181
|
+
}, other, {
|
|
179
182
|
role: "row",
|
|
180
183
|
className: classes,
|
|
181
184
|
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 };
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
import { PolymorphicProps } from '../../types/common';
|
|
10
|
+
declare const TYPES: {
|
|
11
|
+
red: string;
|
|
12
|
+
magenta: string;
|
|
13
|
+
purple: string;
|
|
14
|
+
blue: string;
|
|
15
|
+
cyan: string;
|
|
16
|
+
teal: string;
|
|
17
|
+
green: string;
|
|
18
|
+
gray: string;
|
|
19
|
+
'cool-gray': string;
|
|
20
|
+
'warm-gray': string;
|
|
21
|
+
'high-contrast': string;
|
|
22
|
+
outline: string;
|
|
23
|
+
};
|
|
24
|
+
export interface TagBaseProps {
|
|
25
|
+
/**
|
|
26
|
+
* Provide content to be rendered inside of a <Tag>
|
|
27
|
+
*/
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Provide a custom className that is applied to the containing <span>
|
|
31
|
+
*/
|
|
32
|
+
className?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Specify if the <Tag> is disabled
|
|
35
|
+
*/
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Determine if <Tag> is a filter/chip
|
|
39
|
+
*/
|
|
40
|
+
filter?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Specify the id for the tag.
|
|
43
|
+
*/
|
|
44
|
+
id?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Click handler for filter tag close button.
|
|
47
|
+
*/
|
|
48
|
+
onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Optional prop to render a custom icon.
|
|
51
|
+
* Can be a React component class
|
|
52
|
+
*/
|
|
53
|
+
renderIcon?: React.ElementType;
|
|
54
|
+
/**
|
|
55
|
+
* Specify the size of the Tag. Currently supports either `sm` or
|
|
56
|
+
* 'md' (default) sizes.
|
|
57
|
+
*/
|
|
58
|
+
size?: 'sm' | 'md';
|
|
59
|
+
/**
|
|
60
|
+
* Text to show on clear filters
|
|
61
|
+
*/
|
|
62
|
+
title?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Specify the type of the <Tag>
|
|
65
|
+
*/
|
|
66
|
+
type?: keyof typeof TYPES;
|
|
67
|
+
}
|
|
68
|
+
export type TagProps<T extends React.ElementType> = PolymorphicProps<T, TagBaseProps>;
|
|
69
|
+
declare const Tag: {
|
|
70
|
+
<T extends React.ElementType<any>>({ children, className, id, type, filter, renderIcon: CustomIconElement, title, disabled, onClose, size, as: BaseComponent, ...other }: TagProps<T>): JSX.Element;
|
|
71
|
+
propTypes: {
|
|
72
|
+
/**
|
|
73
|
+
* Provide an alternative tag or component to use instead of the default
|
|
74
|
+
* wrapping element
|
|
75
|
+
*/
|
|
76
|
+
as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
77
|
+
/**
|
|
78
|
+
* Provide content to be rendered inside of a <Tag>
|
|
79
|
+
*/
|
|
80
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
81
|
+
/**
|
|
82
|
+
* Provide a custom className that is applied to the containing <span>
|
|
83
|
+
*/
|
|
84
|
+
className: PropTypes.Requireable<string>;
|
|
85
|
+
/**
|
|
86
|
+
* Specify if the <Tag> is disabled
|
|
87
|
+
*/
|
|
88
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
89
|
+
/**
|
|
90
|
+
* Determine if <Tag> is a filter/chip
|
|
91
|
+
*/
|
|
92
|
+
filter: PropTypes.Requireable<boolean>;
|
|
93
|
+
/**
|
|
94
|
+
* Specify the id for the tag.
|
|
95
|
+
*/
|
|
96
|
+
id: PropTypes.Requireable<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Click handler for filter tag close button.
|
|
99
|
+
*/
|
|
100
|
+
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
101
|
+
/**
|
|
102
|
+
* Optional prop to render a custom icon.
|
|
103
|
+
* Can be a React component class
|
|
104
|
+
*/
|
|
105
|
+
renderIcon: PropTypes.Requireable<object>;
|
|
106
|
+
/**
|
|
107
|
+
* Specify the size of the Tag. Currently supports either `sm` or
|
|
108
|
+
* 'md' (default) sizes.
|
|
109
|
+
*/
|
|
110
|
+
size: PropTypes.Requireable<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Text to show on clear filters
|
|
113
|
+
*/
|
|
114
|
+
title: PropTypes.Requireable<string>;
|
|
115
|
+
/**
|
|
116
|
+
* Specify the type of the <Tag>
|
|
117
|
+
*/
|
|
118
|
+
type: PropTypes.Requireable<string>;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export declare const types: string[];
|
|
122
|
+
export default Tag;
|
|
@@ -65,6 +65,7 @@ const Tag = _ref => {
|
|
|
65
65
|
[`${prefix}--tag--${type}`]: type,
|
|
66
66
|
[`${prefix}--tag--interactive`]: other.onClick && !filter
|
|
67
67
|
});
|
|
68
|
+
const typeText = type !== undefined && type in Object.keys(TYPES) ? TYPES[type] : '';
|
|
68
69
|
const handleClose = event => {
|
|
69
70
|
if (onClose) {
|
|
70
71
|
event.stopPropagation();
|
|
@@ -78,8 +79,8 @@ const Tag = _ref => {
|
|
|
78
79
|
id: tagId
|
|
79
80
|
}, other), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
80
81
|
className: `${prefix}--tag__label`,
|
|
81
|
-
title: typeof children === 'string' ? children :
|
|
82
|
-
}, children !== null && children !== undefined ? children :
|
|
82
|
+
title: typeof children === 'string' ? children : undefined
|
|
83
|
+
}, children !== null && children !== undefined ? children : typeText), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
83
84
|
type: "button",
|
|
84
85
|
className: `${prefix}--tag__close-icon`,
|
|
85
86
|
onClick: handleClose,
|
|
@@ -96,8 +97,8 @@ const Tag = _ref => {
|
|
|
96
97
|
}, other), CustomIconElement ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
97
98
|
className: `${prefix}--tag__custom-icon`
|
|
98
99
|
}, /*#__PURE__*/React__default["default"].createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default["default"].createElement("span", {
|
|
99
|
-
title: typeof children === 'string' ? children :
|
|
100
|
-
}, children !== null && children !== undefined ? children :
|
|
100
|
+
title: typeof children === 'string' ? children : undefined
|
|
101
|
+
}, children !== null && children !== undefined ? children : typeText));
|
|
101
102
|
};
|
|
102
103
|
Tag.propTypes = {
|
|
103
104
|
/**
|
|
@@ -149,7 +150,6 @@ Tag.propTypes = {
|
|
|
149
150
|
type: PropTypes__default["default"].oneOf(Object.keys(TYPES))
|
|
150
151
|
};
|
|
151
152
|
const types = Object.keys(TYPES);
|
|
152
|
-
var Tag$1 = Tag;
|
|
153
153
|
|
|
154
|
-
exports["default"] = Tag
|
|
154
|
+
exports["default"] = Tag;
|
|
155
155
|
exports.types = types;
|
|
@@ -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 Tag from './Tag';
|
|
8
|
+
export * from './Tag.Skeleton';
|
|
9
|
+
export * from './Tag';
|
|
10
|
+
export default Tag;
|
|
11
|
+
export { Tag };
|
|
@@ -69,7 +69,7 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
69
69
|
id,
|
|
70
70
|
onChange: evt => {
|
|
71
71
|
if (!other.disabled && onChange) {
|
|
72
|
-
evt
|
|
72
|
+
evt?.persist?.();
|
|
73
73
|
// delay textCount assignation to give the textarea element value time to catch up if is a controlled input
|
|
74
74
|
setTimeout(() => {
|
|
75
75
|
setTextCount(evt.target?.value?.length);
|