@carbon/react 1.56.0-rc.0 → 1.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +986 -1109
- package/es/components/Button/Button.js +6 -1
- package/es/components/ExpandableSearch/ExpandableSearch.d.ts +1 -5
- package/es/components/ExpandableSearch/ExpandableSearch.js +4 -3
- package/es/components/MultiSelect/MultiSelect.js +21 -6
- package/es/components/NumberInput/NumberInput.js +5 -2
- package/es/components/RadioButton/RadioButton.d.ts +1 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
- package/es/components/Slider/Slider.js +6 -2
- package/es/components/TextInput/PasswordInput.js +25 -7
- package/es/components/Tile/Tile.d.ts +1 -1
- package/es/components/Tile/Tile.js +3 -3
- package/es/components/UIShell/HeaderMenu.d.ts +1 -1
- package/es/components/UIShell/HeaderMenu.js +1 -3
- package/lib/components/Button/Button.js +6 -1
- package/lib/components/ExpandableSearch/ExpandableSearch.d.ts +1 -5
- package/lib/components/ExpandableSearch/ExpandableSearch.js +4 -3
- package/lib/components/MultiSelect/MultiSelect.js +20 -5
- package/lib/components/NumberInput/NumberInput.js +5 -2
- package/lib/components/RadioButton/RadioButton.d.ts +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
- package/lib/components/Slider/Slider.js +6 -2
- package/lib/components/TextInput/PasswordInput.js +25 -7
- package/lib/components/Tile/Tile.d.ts +1 -1
- package/lib/components/Tile/Tile.js +3 -3
- package/lib/components/UIShell/HeaderMenu.d.ts +1 -1
- package/lib/components/UIShell/HeaderMenu.js +1 -3
- package/package.json +5 -5
- package/telemetry.yml +4 -1
|
@@ -49,9 +49,14 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Button(props, ref
|
|
|
49
49
|
};
|
|
50
50
|
const iconOnlyImage = !ButtonImageElement ? null : /*#__PURE__*/React__default.createElement(ButtonImageElement, null);
|
|
51
51
|
if (!isIconOnlyButton(hasIconOnly)) {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
|
+
const {
|
|
54
|
+
tooltipAlignment,
|
|
55
|
+
...propsWithoutTooltipAlignment
|
|
56
|
+
} = props;
|
|
52
57
|
return /*#__PURE__*/React__default.createElement(ButtonBase, _extends({
|
|
53
58
|
ref: ref
|
|
54
|
-
},
|
|
59
|
+
}, propsWithoutTooltipAlignment));
|
|
55
60
|
} else {
|
|
56
61
|
let align = undefined;
|
|
57
62
|
if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
|
|
@@ -6,9 +6,5 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { type SearchProps } from '../Search';
|
|
9
|
-
declare
|
|
10
|
-
declare namespace ExpandableSearch {
|
|
11
|
-
var propTypes: React.WeakValidationMap<SearchProps & React.RefAttributes<HTMLInputElement>> | undefined;
|
|
12
|
-
var displayName: string;
|
|
13
|
-
}
|
|
9
|
+
declare const ExpandableSearch: React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<HTMLInputElement>>;
|
|
14
10
|
export default ExpandableSearch;
|
|
@@ -12,10 +12,11 @@ import Search from '../Search/Search.js';
|
|
|
12
12
|
import '../Search/Search.Skeleton.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
14
|
import { composeEventHandlers } from '../../tools/events.js';
|
|
15
|
+
import mergeRefs from '../../tools/mergeRefs.js';
|
|
15
16
|
import { match } from '../../internal/keyboard/match.js';
|
|
16
17
|
import { Escape } from '../../internal/keyboard/keys.js';
|
|
17
18
|
|
|
18
|
-
function ExpandableSearch(_ref) {
|
|
19
|
+
const ExpandableSearch = /*#__PURE__*/React__default.forwardRef(function ExpandableSearch(_ref, forwardedRef) {
|
|
19
20
|
let {
|
|
20
21
|
onBlur,
|
|
21
22
|
onChange,
|
|
@@ -61,14 +62,14 @@ function ExpandableSearch(_ref) {
|
|
|
61
62
|
return /*#__PURE__*/React__default.createElement(Search, _extends({}, props, {
|
|
62
63
|
defaultValue: defaultValue,
|
|
63
64
|
isExpanded: expanded,
|
|
64
|
-
ref: searchRef,
|
|
65
|
+
ref: mergeRefs(searchRef, forwardedRef),
|
|
65
66
|
className: classes,
|
|
66
67
|
onBlur: composeEventHandlers([onBlur, handleBlur]),
|
|
67
68
|
onChange: composeEventHandlers([onChange, handleChange]),
|
|
68
69
|
onExpand: composeEventHandlers([onExpand, handleExpand]),
|
|
69
70
|
onKeyDown: composeEventHandlers([onKeyDown, handleKeyDown])
|
|
70
71
|
}));
|
|
71
|
-
}
|
|
72
|
+
});
|
|
72
73
|
ExpandableSearch.propTypes = Search.propTypes;
|
|
73
74
|
ExpandableSearch.displayName = 'ExpandableSearch';
|
|
74
75
|
|
|
@@ -11,7 +11,7 @@ import cx from 'classnames';
|
|
|
11
11
|
import { useSelect } from 'downshift';
|
|
12
12
|
import isEqual from 'lodash.isequal';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
|
-
import React__default, { useContext, useRef, useState } from 'react';
|
|
14
|
+
import React__default, { useContext, useRef, useState, useMemo } from 'react';
|
|
15
15
|
import ListBox from '../ListBox/index.js';
|
|
16
16
|
import { sortingPropTypes } from './MultiSelectPropTypes.js';
|
|
17
17
|
import { defaultSortItems, defaultCompareItems } from './tools/sorting.js';
|
|
@@ -116,17 +116,32 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
116
116
|
onChange,
|
|
117
117
|
selectedItems: selected
|
|
118
118
|
});
|
|
119
|
+
|
|
120
|
+
// Filter out items with an object having undefined values
|
|
121
|
+
const filteredItems = useMemo(() => {
|
|
122
|
+
return items.filter(item => {
|
|
123
|
+
if (typeof item === 'object' && item !== null) {
|
|
124
|
+
for (const key in item) {
|
|
125
|
+
if (Object.hasOwn(item, key) && item[key] === undefined) {
|
|
126
|
+
return false; // Return false if any property has an undefined value
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return true; // Return true if item is not an object with undefined values
|
|
132
|
+
});
|
|
133
|
+
}, [items]);
|
|
119
134
|
const selectProps = {
|
|
120
135
|
...downshiftProps,
|
|
121
136
|
stateReducer,
|
|
122
137
|
isOpen,
|
|
123
|
-
itemToString:
|
|
124
|
-
return Array.isArray(
|
|
138
|
+
itemToString: filteredItems => {
|
|
139
|
+
return Array.isArray(filteredItems) && filteredItems.map(function (item) {
|
|
125
140
|
return itemToString(item);
|
|
126
141
|
}).join(', ') || '';
|
|
127
142
|
},
|
|
128
143
|
selectedItem: controlledSelectedItems,
|
|
129
|
-
items,
|
|
144
|
+
items: filteredItems,
|
|
130
145
|
isItemDisabled(item, _index) {
|
|
131
146
|
return item.disabled;
|
|
132
147
|
}
|
|
@@ -342,7 +357,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
342
357
|
size: 'mini'
|
|
343
358
|
});
|
|
344
359
|
}
|
|
345
|
-
const itemsSelectedText = selectedItems.length > 0 && selectedItems.map(item => item
|
|
360
|
+
const itemsSelectedText = selectedItems.length > 0 && selectedItems.map(item => item?.text);
|
|
346
361
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
347
362
|
className: wrapperClasses
|
|
348
363
|
}, /*#__PURE__*/React__default.createElement("label", _extends({
|
|
@@ -393,7 +408,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
393
408
|
translateWithId: translateWithId
|
|
394
409
|
})), normalizedSlug), /*#__PURE__*/React__default.createElement(ListBox.Menu, getMenuProps(), isOpen &&
|
|
395
410
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
396
|
-
sortItems(
|
|
411
|
+
sortItems(filteredItems, sortOptions).map((item, index) => {
|
|
397
412
|
const isChecked = selectedItems.filter(selected => isEqual(selected, item)).length > 0;
|
|
398
413
|
const itemProps = getItemProps({
|
|
399
414
|
item,
|
|
@@ -71,6 +71,9 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
71
71
|
if (defaultValue !== undefined) {
|
|
72
72
|
return defaultValue;
|
|
73
73
|
}
|
|
74
|
+
if (allowEmpty) {
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
74
77
|
return 0;
|
|
75
78
|
});
|
|
76
79
|
const [prevControlledValue, setPrevControlledValue] = useState(controlledValue);
|
|
@@ -130,7 +133,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
130
133
|
return;
|
|
131
134
|
}
|
|
132
135
|
const state = {
|
|
133
|
-
value: Number(event.target.value),
|
|
136
|
+
value: allowEmpty && event.target.value === '' ? '' : Number(event.target.value),
|
|
134
137
|
direction: value < event.target.value ? 'up' : 'down'
|
|
135
138
|
};
|
|
136
139
|
setValue(state.value);
|
|
@@ -157,7 +160,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
157
160
|
if (inputRef.current) {
|
|
158
161
|
direction === 'up' ? inputRef.current.stepUp() : inputRef.current.stepDown();
|
|
159
162
|
const state = {
|
|
160
|
-
value: Number(inputRef.current.value),
|
|
163
|
+
value: allowEmpty && inputRef.current.value === '' ? '' : Number(inputRef.current.value),
|
|
161
164
|
direction: direction
|
|
162
165
|
};
|
|
163
166
|
setValue(state.value);
|
|
@@ -50,7 +50,7 @@ export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
50
50
|
* Provide an optional `onChange` hook that is called each time the value of
|
|
51
51
|
* the underlying `<input>` changes
|
|
52
52
|
*/
|
|
53
|
-
onChange?: (value: string | number, name: string | undefined, event:
|
|
53
|
+
onChange?: (value: string | number, name: string | undefined, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
54
54
|
/**
|
|
55
55
|
* Provide a handler that is invoked when a user clicks on the control
|
|
56
56
|
*/
|
|
@@ -54,7 +54,7 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
|
|
|
54
54
|
* Provide an optional `onChange` hook that is called whenever the value of
|
|
55
55
|
* the group changes
|
|
56
56
|
*/
|
|
57
|
-
onChange?: (selection:
|
|
57
|
+
onChange?: (selection: React.ReactNode, name: string, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
58
58
|
/**
|
|
59
59
|
* Provide where radio buttons should be placed
|
|
60
60
|
*/
|
|
@@ -427,6 +427,10 @@ class Slider extends PureComponent {
|
|
|
427
427
|
}
|
|
428
428
|
});
|
|
429
429
|
_defineProperty(this, "processNewInputValue", input => {
|
|
430
|
+
this.setState({
|
|
431
|
+
correctedValue: null,
|
|
432
|
+
correctedPosition: null
|
|
433
|
+
});
|
|
430
434
|
const targetValue = Number.parseFloat(input.value);
|
|
431
435
|
const validity = !isNaN(targetValue);
|
|
432
436
|
|
|
@@ -978,8 +982,8 @@ class Slider extends PureComponent {
|
|
|
978
982
|
correctedPosition,
|
|
979
983
|
isRtl
|
|
980
984
|
} = this.state;
|
|
981
|
-
const showWarning = !readOnly && warn
|
|
982
|
-
const showWarningUpper = !readOnly && warn
|
|
985
|
+
const showWarning = !readOnly && warn || typeof correctedValue !== null && correctedPosition === HandlePosition.LOWER && isValid;
|
|
986
|
+
const showWarningUpper = !readOnly && warn || typeof correctedValue !== null && correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
|
|
983
987
|
return /*#__PURE__*/React__default.createElement(PrefixContext.Consumer, null, prefix => {
|
|
984
988
|
const labelId = `${id}-label`;
|
|
985
989
|
const labelClasses = cx(`${prefix}--label`, {
|
|
@@ -14,6 +14,8 @@ import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.
|
|
|
14
14
|
import { textInputProps } from './util.js';
|
|
15
15
|
import '../FluidForm/FluidForm.js';
|
|
16
16
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
17
|
+
import '../Tooltip/DefinitionTooltip.js';
|
|
18
|
+
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
17
19
|
import deprecate from '../../prop-types/deprecate.js';
|
|
18
20
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
19
21
|
|
|
@@ -38,7 +40,7 @@ const PasswordInput = /*#__PURE__*/React__default.forwardRef(function PasswordIn
|
|
|
38
40
|
size = 'md',
|
|
39
41
|
showPasswordLabel = 'Show password',
|
|
40
42
|
tooltipPosition = 'bottom',
|
|
41
|
-
tooltipAlignment = '
|
|
43
|
+
tooltipAlignment = 'end',
|
|
42
44
|
type = 'password',
|
|
43
45
|
warn = false,
|
|
44
46
|
warnText,
|
|
@@ -127,11 +129,25 @@ const PasswordInput = /*#__PURE__*/React__default.forwardRef(function PasswordIn
|
|
|
127
129
|
}) : /*#__PURE__*/React__default.createElement(View, {
|
|
128
130
|
className: `${prefix}--icon-visibility-on`
|
|
129
131
|
});
|
|
130
|
-
const passwordVisibilityToggleClasses = cx(`${prefix}--text-input--password__visibility__toggle`, `${prefix}--btn`, `${prefix}--
|
|
131
|
-
[`${prefix}--btn--disabled`]: disabled,
|
|
132
|
+
const passwordVisibilityToggleClasses = cx(`${prefix}--text-input--password__visibility__toggle`, `${prefix}--btn`, `${prefix}--tooltip__trigger`, `${prefix}--tooltip--a11y`, {
|
|
132
133
|
[`${prefix}--tooltip--${tooltipPosition}`]: tooltipPosition,
|
|
133
134
|
[`${prefix}--tooltip--align-${tooltipAlignment}`]: tooltipAlignment
|
|
134
135
|
});
|
|
136
|
+
let align = undefined;
|
|
137
|
+
if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
|
|
138
|
+
if (tooltipAlignment === 'center') {
|
|
139
|
+
align = tooltipPosition;
|
|
140
|
+
}
|
|
141
|
+
if (tooltipAlignment === 'end') {
|
|
142
|
+
align = `${tooltipPosition}-right`;
|
|
143
|
+
}
|
|
144
|
+
if (tooltipAlignment === 'start') {
|
|
145
|
+
align = `${tooltipPosition}-left`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (tooltipPosition === 'right' || tooltipPosition === 'left') {
|
|
149
|
+
align = tooltipPosition;
|
|
150
|
+
}
|
|
135
151
|
const input = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("input", _extends({}, textInputProps({
|
|
136
152
|
sharedTextInputProps,
|
|
137
153
|
invalid: normalizedProps.invalid,
|
|
@@ -145,14 +161,16 @@ const PasswordInput = /*#__PURE__*/React__default.forwardRef(function PasswordIn
|
|
|
145
161
|
"data-toggle-password-visibility": inputType === 'password'
|
|
146
162
|
})), isFluid && /*#__PURE__*/React__default.createElement("hr", {
|
|
147
163
|
className: `${prefix}--text-input__divider`
|
|
148
|
-
}), /*#__PURE__*/React__default.createElement(
|
|
164
|
+
}), /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
165
|
+
align: align,
|
|
166
|
+
className: `${prefix}--toggle-password-tooltip`,
|
|
167
|
+
label: passwordIsVisible ? hidePasswordLabel : showPasswordLabel
|
|
168
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
149
169
|
type: "button",
|
|
150
170
|
className: passwordVisibilityToggleClasses,
|
|
151
171
|
disabled: disabled,
|
|
152
172
|
onClick: handleTogglePasswordVisibility
|
|
153
|
-
},
|
|
154
|
-
className: `${prefix}--assistive-text`
|
|
155
|
-
}, passwordIsVisible ? hidePasswordLabel : showPasswordLabel), passwordVisibilityIcon));
|
|
173
|
+
}, passwordVisibilityIcon)));
|
|
156
174
|
useEffect(() => {
|
|
157
175
|
setInputType(type);
|
|
158
176
|
}, [type]);
|
|
@@ -88,7 +88,7 @@ export interface SelectableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
88
88
|
/**
|
|
89
89
|
* The empty handler of the `<input>`.
|
|
90
90
|
*/
|
|
91
|
-
onChange?(event: ChangeEvent<HTMLDivElement
|
|
91
|
+
onChange?(event: ChangeEvent<HTMLDivElement>, selected?: boolean, id?: string): void;
|
|
92
92
|
/**
|
|
93
93
|
* Specify the function to run when the SelectableTile is clicked
|
|
94
94
|
*/
|
|
@@ -244,7 +244,7 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
|
|
|
244
244
|
}
|
|
245
245
|
setIsSelected(!isSelected);
|
|
246
246
|
clickHandler(evt);
|
|
247
|
-
onChange(evt);
|
|
247
|
+
onChange(evt, isSelected, id);
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// TODO: rename to handleKeyDown when handleKeyDown prop is deprecated
|
|
@@ -253,13 +253,13 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
|
|
|
253
253
|
if (matches(evt, [Enter, Space])) {
|
|
254
254
|
evt.preventDefault();
|
|
255
255
|
setIsSelected(!isSelected);
|
|
256
|
-
onChange(evt);
|
|
256
|
+
onChange(evt, isSelected, id);
|
|
257
257
|
}
|
|
258
258
|
keyDownHandler(evt);
|
|
259
259
|
}
|
|
260
260
|
function handleChange(event) {
|
|
261
261
|
setIsSelected(event.target.checked);
|
|
262
|
-
onChange(event);
|
|
262
|
+
onChange(event, isSelected, id);
|
|
263
263
|
}
|
|
264
264
|
if (selected !== prevSelected) {
|
|
265
265
|
setIsSelected(selected);
|
|
@@ -214,6 +214,6 @@ declare class HeaderMenu extends React.Component<HeaderMenuProps, HeaderMenuStat
|
|
|
214
214
|
*/
|
|
215
215
|
_renderMenuItem: (item: React.ReactNode, index: number) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
216
216
|
}
|
|
217
|
-
declare const HeaderMenuForwardRef: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
|
217
|
+
declare const HeaderMenuForwardRef: React.ForwardRefExoticComponent<HeaderMenuProps & React.RefAttributes<unknown>>;
|
|
218
218
|
export { HeaderMenu };
|
|
219
219
|
export default HeaderMenuForwardRef;
|
|
@@ -259,9 +259,7 @@ _defineProperty(HeaderMenu, "propTypes", {
|
|
|
259
259
|
});
|
|
260
260
|
_defineProperty(HeaderMenu, "contextType", PrefixContext);
|
|
261
261
|
const HeaderMenuForwardRef = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
262
|
-
return /*#__PURE__*/React__default.createElement(HeaderMenu, _extends({
|
|
263
|
-
menuLinkName: "link"
|
|
264
|
-
}, props, {
|
|
262
|
+
return /*#__PURE__*/React__default.createElement(HeaderMenu, _extends({}, props, {
|
|
265
263
|
focusRef: ref
|
|
266
264
|
}));
|
|
267
265
|
});
|
|
@@ -58,9 +58,14 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
|
|
|
58
58
|
};
|
|
59
59
|
const iconOnlyImage = !ButtonImageElement ? null : /*#__PURE__*/React__default["default"].createElement(ButtonImageElement, null);
|
|
60
60
|
if (!isIconOnlyButton(hasIconOnly)) {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
+
const {
|
|
63
|
+
tooltipAlignment,
|
|
64
|
+
...propsWithoutTooltipAlignment
|
|
65
|
+
} = props;
|
|
61
66
|
return /*#__PURE__*/React__default["default"].createElement(ButtonBase["default"], _rollupPluginBabelHelpers["extends"]({
|
|
62
67
|
ref: ref
|
|
63
|
-
},
|
|
68
|
+
}, propsWithoutTooltipAlignment));
|
|
64
69
|
} else {
|
|
65
70
|
let align = undefined;
|
|
66
71
|
if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
|
|
@@ -6,9 +6,5 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { type SearchProps } from '../Search';
|
|
9
|
-
declare
|
|
10
|
-
declare namespace ExpandableSearch {
|
|
11
|
-
var propTypes: React.WeakValidationMap<SearchProps & React.RefAttributes<HTMLInputElement>> | undefined;
|
|
12
|
-
var displayName: string;
|
|
13
|
-
}
|
|
9
|
+
declare const ExpandableSearch: React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<HTMLInputElement>>;
|
|
14
10
|
export default ExpandableSearch;
|
|
@@ -16,6 +16,7 @@ var Search = require('../Search/Search.js');
|
|
|
16
16
|
require('../Search/Search.Skeleton.js');
|
|
17
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
18
|
var events = require('../../tools/events.js');
|
|
19
|
+
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
19
20
|
var match = require('../../internal/keyboard/match.js');
|
|
20
21
|
var keys = require('../../internal/keyboard/keys.js');
|
|
21
22
|
|
|
@@ -24,7 +25,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
24
25
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
26
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
26
27
|
|
|
27
|
-
function ExpandableSearch(_ref) {
|
|
28
|
+
const ExpandableSearch = /*#__PURE__*/React__default["default"].forwardRef(function ExpandableSearch(_ref, forwardedRef) {
|
|
28
29
|
let {
|
|
29
30
|
onBlur,
|
|
30
31
|
onChange,
|
|
@@ -70,14 +71,14 @@ function ExpandableSearch(_ref) {
|
|
|
70
71
|
return /*#__PURE__*/React__default["default"].createElement(Search["default"], _rollupPluginBabelHelpers["extends"]({}, props, {
|
|
71
72
|
defaultValue: defaultValue,
|
|
72
73
|
isExpanded: expanded,
|
|
73
|
-
ref: searchRef,
|
|
74
|
+
ref: mergeRefs["default"](searchRef, forwardedRef),
|
|
74
75
|
className: classes,
|
|
75
76
|
onBlur: events.composeEventHandlers([onBlur, handleBlur]),
|
|
76
77
|
onChange: events.composeEventHandlers([onChange, handleChange]),
|
|
77
78
|
onExpand: events.composeEventHandlers([onExpand, handleExpand]),
|
|
78
79
|
onKeyDown: events.composeEventHandlers([onKeyDown, handleKeyDown])
|
|
79
80
|
}));
|
|
80
|
-
}
|
|
81
|
+
});
|
|
81
82
|
ExpandableSearch.propTypes = Search["default"].propTypes;
|
|
82
83
|
ExpandableSearch.displayName = 'ExpandableSearch';
|
|
83
84
|
|
|
@@ -127,17 +127,32 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
127
127
|
onChange,
|
|
128
128
|
selectedItems: selected
|
|
129
129
|
});
|
|
130
|
+
|
|
131
|
+
// Filter out items with an object having undefined values
|
|
132
|
+
const filteredItems = React.useMemo(() => {
|
|
133
|
+
return items.filter(item => {
|
|
134
|
+
if (typeof item === 'object' && item !== null) {
|
|
135
|
+
for (const key in item) {
|
|
136
|
+
if (Object.hasOwn(item, key) && item[key] === undefined) {
|
|
137
|
+
return false; // Return false if any property has an undefined value
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return true; // Return true if item is not an object with undefined values
|
|
143
|
+
});
|
|
144
|
+
}, [items]);
|
|
130
145
|
const selectProps = {
|
|
131
146
|
...downshiftProps,
|
|
132
147
|
stateReducer,
|
|
133
148
|
isOpen,
|
|
134
|
-
itemToString:
|
|
135
|
-
return Array.isArray(
|
|
149
|
+
itemToString: filteredItems => {
|
|
150
|
+
return Array.isArray(filteredItems) && filteredItems.map(function (item) {
|
|
136
151
|
return itemToString(item);
|
|
137
152
|
}).join(', ') || '';
|
|
138
153
|
},
|
|
139
154
|
selectedItem: controlledSelectedItems,
|
|
140
|
-
items,
|
|
155
|
+
items: filteredItems,
|
|
141
156
|
isItemDisabled(item, _index) {
|
|
142
157
|
return item.disabled;
|
|
143
158
|
}
|
|
@@ -353,7 +368,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
353
368
|
size: 'mini'
|
|
354
369
|
});
|
|
355
370
|
}
|
|
356
|
-
const itemsSelectedText = selectedItems.length > 0 && selectedItems.map(item => item
|
|
371
|
+
const itemsSelectedText = selectedItems.length > 0 && selectedItems.map(item => item?.text);
|
|
357
372
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
358
373
|
className: wrapperClasses
|
|
359
374
|
}, /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
@@ -404,7 +419,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
404
419
|
translateWithId: translateWithId
|
|
405
420
|
})), normalizedSlug), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, getMenuProps(), isOpen &&
|
|
406
421
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
407
|
-
sortItems(
|
|
422
|
+
sortItems(filteredItems, sortOptions).map((item, index$1) => {
|
|
408
423
|
const isChecked = selectedItems.filter(selected => isEqual__default["default"](selected, item)).length > 0;
|
|
409
424
|
const itemProps = getItemProps({
|
|
410
425
|
item,
|
|
@@ -81,6 +81,9 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
81
81
|
if (defaultValue !== undefined) {
|
|
82
82
|
return defaultValue;
|
|
83
83
|
}
|
|
84
|
+
if (allowEmpty) {
|
|
85
|
+
return '';
|
|
86
|
+
}
|
|
84
87
|
return 0;
|
|
85
88
|
});
|
|
86
89
|
const [prevControlledValue, setPrevControlledValue] = React.useState(controlledValue);
|
|
@@ -140,7 +143,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
140
143
|
return;
|
|
141
144
|
}
|
|
142
145
|
const state = {
|
|
143
|
-
value: Number(event.target.value),
|
|
146
|
+
value: allowEmpty && event.target.value === '' ? '' : Number(event.target.value),
|
|
144
147
|
direction: value < event.target.value ? 'up' : 'down'
|
|
145
148
|
};
|
|
146
149
|
setValue(state.value);
|
|
@@ -167,7 +170,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
167
170
|
if (inputRef.current) {
|
|
168
171
|
direction === 'up' ? inputRef.current.stepUp() : inputRef.current.stepDown();
|
|
169
172
|
const state = {
|
|
170
|
-
value: Number(inputRef.current.value),
|
|
173
|
+
value: allowEmpty && inputRef.current.value === '' ? '' : Number(inputRef.current.value),
|
|
171
174
|
direction: direction
|
|
172
175
|
};
|
|
173
176
|
setValue(state.value);
|
|
@@ -50,7 +50,7 @@ export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
50
50
|
* Provide an optional `onChange` hook that is called each time the value of
|
|
51
51
|
* the underlying `<input>` changes
|
|
52
52
|
*/
|
|
53
|
-
onChange?: (value: string | number, name: string | undefined, event:
|
|
53
|
+
onChange?: (value: string | number, name: string | undefined, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
54
54
|
/**
|
|
55
55
|
* Provide a handler that is invoked when a user clicks on the control
|
|
56
56
|
*/
|
|
@@ -54,7 +54,7 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
|
|
|
54
54
|
* Provide an optional `onChange` hook that is called whenever the value of
|
|
55
55
|
* the group changes
|
|
56
56
|
*/
|
|
57
|
-
onChange?: (selection:
|
|
57
|
+
onChange?: (selection: React.ReactNode, name: string, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
58
58
|
/**
|
|
59
59
|
* Provide where radio buttons should be placed
|
|
60
60
|
*/
|
|
@@ -438,6 +438,10 @@ class Slider extends React.PureComponent {
|
|
|
438
438
|
}
|
|
439
439
|
});
|
|
440
440
|
_rollupPluginBabelHelpers.defineProperty(this, "processNewInputValue", input => {
|
|
441
|
+
this.setState({
|
|
442
|
+
correctedValue: null,
|
|
443
|
+
correctedPosition: null
|
|
444
|
+
});
|
|
441
445
|
const targetValue = Number.parseFloat(input.value);
|
|
442
446
|
const validity = !isNaN(targetValue);
|
|
443
447
|
|
|
@@ -989,8 +993,8 @@ class Slider extends React.PureComponent {
|
|
|
989
993
|
correctedPosition,
|
|
990
994
|
isRtl
|
|
991
995
|
} = this.state;
|
|
992
|
-
const showWarning = !readOnly && warn
|
|
993
|
-
const showWarningUpper = !readOnly && warn
|
|
996
|
+
const showWarning = !readOnly && warn || typeof correctedValue !== null && correctedPosition === HandlePosition.LOWER && isValid;
|
|
997
|
+
const showWarningUpper = !readOnly && warn || typeof correctedValue !== null && correctedPosition === (twoHandles ? HandlePosition.UPPER : HandlePosition.LOWER) && (twoHandles ? isValidUpper : isValid);
|
|
994
998
|
return /*#__PURE__*/React__default["default"].createElement(usePrefix.PrefixContext.Consumer, null, prefix => {
|
|
995
999
|
const labelId = `${id}-label`;
|
|
996
1000
|
const labelClasses = cx__default["default"](`${prefix}--label`, {
|
|
@@ -18,6 +18,8 @@ var useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js
|
|
|
18
18
|
var util = require('./util.js');
|
|
19
19
|
require('../FluidForm/FluidForm.js');
|
|
20
20
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
21
|
+
require('../Tooltip/DefinitionTooltip.js');
|
|
22
|
+
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
21
23
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
22
24
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
23
25
|
|
|
@@ -48,7 +50,7 @@ const PasswordInput = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
48
50
|
size = 'md',
|
|
49
51
|
showPasswordLabel = 'Show password',
|
|
50
52
|
tooltipPosition = 'bottom',
|
|
51
|
-
tooltipAlignment = '
|
|
53
|
+
tooltipAlignment = 'end',
|
|
52
54
|
type = 'password',
|
|
53
55
|
warn = false,
|
|
54
56
|
warnText,
|
|
@@ -137,11 +139,25 @@ const PasswordInput = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
137
139
|
}) : /*#__PURE__*/React__default["default"].createElement(iconsReact.View, {
|
|
138
140
|
className: `${prefix}--icon-visibility-on`
|
|
139
141
|
});
|
|
140
|
-
const passwordVisibilityToggleClasses = cx__default["default"](`${prefix}--text-input--password__visibility__toggle`, `${prefix}--btn`, `${prefix}--
|
|
141
|
-
[`${prefix}--btn--disabled`]: disabled,
|
|
142
|
+
const passwordVisibilityToggleClasses = cx__default["default"](`${prefix}--text-input--password__visibility__toggle`, `${prefix}--btn`, `${prefix}--tooltip__trigger`, `${prefix}--tooltip--a11y`, {
|
|
142
143
|
[`${prefix}--tooltip--${tooltipPosition}`]: tooltipPosition,
|
|
143
144
|
[`${prefix}--tooltip--align-${tooltipAlignment}`]: tooltipAlignment
|
|
144
145
|
});
|
|
146
|
+
let align = undefined;
|
|
147
|
+
if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
|
|
148
|
+
if (tooltipAlignment === 'center') {
|
|
149
|
+
align = tooltipPosition;
|
|
150
|
+
}
|
|
151
|
+
if (tooltipAlignment === 'end') {
|
|
152
|
+
align = `${tooltipPosition}-right`;
|
|
153
|
+
}
|
|
154
|
+
if (tooltipAlignment === 'start') {
|
|
155
|
+
align = `${tooltipPosition}-left`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (tooltipPosition === 'right' || tooltipPosition === 'left') {
|
|
159
|
+
align = tooltipPosition;
|
|
160
|
+
}
|
|
145
161
|
const input = /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("input", _rollupPluginBabelHelpers["extends"]({}, util.textInputProps({
|
|
146
162
|
sharedTextInputProps,
|
|
147
163
|
invalid: normalizedProps.invalid,
|
|
@@ -155,14 +171,16 @@ const PasswordInput = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
155
171
|
"data-toggle-password-visibility": inputType === 'password'
|
|
156
172
|
})), isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
|
|
157
173
|
className: `${prefix}--text-input__divider`
|
|
158
|
-
}), /*#__PURE__*/React__default["default"].createElement(
|
|
174
|
+
}), /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
175
|
+
align: align,
|
|
176
|
+
className: `${prefix}--toggle-password-tooltip`,
|
|
177
|
+
label: passwordIsVisible ? hidePasswordLabel : showPasswordLabel
|
|
178
|
+
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
159
179
|
type: "button",
|
|
160
180
|
className: passwordVisibilityToggleClasses,
|
|
161
181
|
disabled: disabled,
|
|
162
182
|
onClick: handleTogglePasswordVisibility
|
|
163
|
-
},
|
|
164
|
-
className: `${prefix}--assistive-text`
|
|
165
|
-
}, passwordIsVisible ? hidePasswordLabel : showPasswordLabel), passwordVisibilityIcon));
|
|
183
|
+
}, passwordVisibilityIcon)));
|
|
166
184
|
React.useEffect(() => {
|
|
167
185
|
setInputType(type);
|
|
168
186
|
}, [type]);
|
|
@@ -88,7 +88,7 @@ export interface SelectableTileProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
88
88
|
/**
|
|
89
89
|
* The empty handler of the `<input>`.
|
|
90
90
|
*/
|
|
91
|
-
onChange?(event: ChangeEvent<HTMLDivElement
|
|
91
|
+
onChange?(event: ChangeEvent<HTMLDivElement>, selected?: boolean, id?: string): void;
|
|
92
92
|
/**
|
|
93
93
|
* Specify the function to run when the SelectableTile is clicked
|
|
94
94
|
*/
|
|
@@ -254,7 +254,7 @@ const SelectableTile = /*#__PURE__*/React__default["default"].forwardRef(functio
|
|
|
254
254
|
}
|
|
255
255
|
setIsSelected(!isSelected);
|
|
256
256
|
clickHandler(evt);
|
|
257
|
-
onChange(evt);
|
|
257
|
+
onChange(evt, isSelected, id);
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
// TODO: rename to handleKeyDown when handleKeyDown prop is deprecated
|
|
@@ -263,13 +263,13 @@ const SelectableTile = /*#__PURE__*/React__default["default"].forwardRef(functio
|
|
|
263
263
|
if (match.matches(evt, [keys.Enter, keys.Space])) {
|
|
264
264
|
evt.preventDefault();
|
|
265
265
|
setIsSelected(!isSelected);
|
|
266
|
-
onChange(evt);
|
|
266
|
+
onChange(evt, isSelected, id);
|
|
267
267
|
}
|
|
268
268
|
keyDownHandler(evt);
|
|
269
269
|
}
|
|
270
270
|
function handleChange(event) {
|
|
271
271
|
setIsSelected(event.target.checked);
|
|
272
|
-
onChange(event);
|
|
272
|
+
onChange(event, isSelected, id);
|
|
273
273
|
}
|
|
274
274
|
if (selected !== prevSelected) {
|
|
275
275
|
setIsSelected(selected);
|
|
@@ -214,6 +214,6 @@ declare class HeaderMenu extends React.Component<HeaderMenuProps, HeaderMenuStat
|
|
|
214
214
|
*/
|
|
215
215
|
_renderMenuItem: (item: React.ReactNode, index: number) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
216
216
|
}
|
|
217
|
-
declare const HeaderMenuForwardRef: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
|
217
|
+
declare const HeaderMenuForwardRef: React.ForwardRefExoticComponent<HeaderMenuProps & React.RefAttributes<unknown>>;
|
|
218
218
|
export { HeaderMenu };
|
|
219
219
|
export default HeaderMenuForwardRef;
|
|
@@ -269,9 +269,7 @@ _rollupPluginBabelHelpers.defineProperty(HeaderMenu, "propTypes", {
|
|
|
269
269
|
});
|
|
270
270
|
_rollupPluginBabelHelpers.defineProperty(HeaderMenu, "contextType", usePrefix.PrefixContext);
|
|
271
271
|
const HeaderMenuForwardRef = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
|
|
272
|
-
return /*#__PURE__*/React__default["default"].createElement(HeaderMenu, _rollupPluginBabelHelpers["extends"]({
|
|
273
|
-
menuLinkName: "link"
|
|
274
|
-
}, props, {
|
|
272
|
+
return /*#__PURE__*/React__default["default"].createElement(HeaderMenu, _rollupPluginBabelHelpers["extends"]({}, props, {
|
|
275
273
|
focusRef: ref
|
|
276
274
|
}));
|
|
277
275
|
});
|