@carbon/react 1.81.0-rc.0 → 1.81.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 +808 -808
- package/es/components/ComboBox/ComboBox.js +52 -30
- package/es/components/DataTable/TableCell.js +28 -4
- package/es/components/DataTable/tools/cells.d.ts +13 -0
- package/es/components/DataTable/tools/cells.js +3 -6
- package/es/components/DataTable/tools/filter.d.ts +26 -0
- package/es/components/DataTable/tools/filter.js +8 -17
- package/es/components/DatePicker/DatePicker.js +1 -1
- package/es/components/Dropdown/Dropdown.js +6 -6
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +1 -1
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +5 -6
- package/es/components/Menu/Menu.js +4 -14
- package/es/components/Menu/MenuItem.js +15 -4
- package/es/components/MultiSelect/MultiSelect.js +4 -1
- package/es/components/OverflowMenu/index.d.ts +1 -1
- package/es/components/OverflowMenu/index.js +2 -3
- package/es/components/PageHeader/PageHeader.d.ts +9 -2
- package/es/components/PageHeader/PageHeader.js +15 -3
- package/es/components/PageHeader/index.d.ts +2 -2
- package/es/components/PageHeader/index.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +52 -30
- package/lib/components/DataTable/TableCell.js +28 -3
- package/lib/components/DataTable/tools/cells.d.ts +13 -0
- package/lib/components/DataTable/tools/cells.js +3 -6
- package/lib/components/DataTable/tools/filter.d.ts +26 -0
- package/lib/components/DataTable/tools/filter.js +8 -17
- package/lib/components/DatePicker/DatePicker.js +1 -1
- package/lib/components/Dropdown/Dropdown.js +6 -6
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +1 -1
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +4 -5
- package/lib/components/Menu/Menu.js +4 -14
- package/lib/components/Menu/MenuItem.js +15 -4
- package/lib/components/MultiSelect/MultiSelect.js +4 -1
- package/lib/components/OverflowMenu/index.d.ts +1 -1
- package/lib/components/OverflowMenu/index.js +2 -3
- package/lib/components/PageHeader/PageHeader.d.ts +9 -2
- package/lib/components/PageHeader/PageHeader.js +16 -2
- package/lib/components/PageHeader/index.d.ts +2 -2
- package/lib/components/PageHeader/index.js +2 -0
- package/package.json +8 -8
|
@@ -48,7 +48,9 @@ const {
|
|
|
48
48
|
ItemMouseMove,
|
|
49
49
|
InputKeyDownArrowUp,
|
|
50
50
|
InputKeyDownArrowDown,
|
|
51
|
-
MenuMouseLeave
|
|
51
|
+
MenuMouseLeave,
|
|
52
|
+
ItemClick,
|
|
53
|
+
FunctionSelectItem
|
|
52
54
|
} = Downshift.useCombobox.stateChangeTypes;
|
|
53
55
|
const defaultItemToString = item => {
|
|
54
56
|
if (typeof item === 'string') {
|
|
@@ -219,6 +221,8 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
219
221
|
prevInputLengthRef.current = inputValue.length;
|
|
220
222
|
}
|
|
221
223
|
}, [typeahead, inputValue, items, itemToString, autocompleteCustomFilter]);
|
|
224
|
+
const isManualClearingRef = React.useRef(false);
|
|
225
|
+
const [isClearing, setIsClearing] = React.useState(false);
|
|
222
226
|
const prefix = usePrefix.usePrefix();
|
|
223
227
|
const {
|
|
224
228
|
isFluid
|
|
@@ -228,6 +232,14 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
228
232
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
229
233
|
const prevInputValue = React.useRef(inputValue);
|
|
230
234
|
const prevSelectedItemProp = React.useRef(selectedItemProp);
|
|
235
|
+
React.useEffect(() => {
|
|
236
|
+
isManualClearingRef.current = isClearing;
|
|
237
|
+
|
|
238
|
+
// Reset flag after render cycle
|
|
239
|
+
if (isClearing) {
|
|
240
|
+
setIsClearing(false);
|
|
241
|
+
}
|
|
242
|
+
}, [isClearing]);
|
|
231
243
|
|
|
232
244
|
// fully controlled combobox: handle changes to selectedItemProp
|
|
233
245
|
React.useEffect(() => {
|
|
@@ -313,31 +325,38 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
313
325
|
}
|
|
314
326
|
case InputKeyDownEnter:
|
|
315
327
|
if (!allowCustomValue) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
328
|
+
if (state.highlightedIndex !== -1) {
|
|
329
|
+
const filteredList = filterItems(items, itemToString, inputValue);
|
|
330
|
+
const highlightedItem = filteredList[state.highlightedIndex];
|
|
331
|
+
if (highlightedItem && !highlightedItem.disabled) {
|
|
332
|
+
return {
|
|
333
|
+
...changes,
|
|
334
|
+
selectedItem: highlightedItem,
|
|
335
|
+
inputValue: itemToString(highlightedItem)
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
} else {
|
|
339
|
+
const autoIndex = indexToHighlight(inputValue);
|
|
340
|
+
if (autoIndex !== -1) {
|
|
341
|
+
const matchingItem = items[autoIndex];
|
|
342
|
+
if (matchingItem && !matchingItem.disabled) {
|
|
343
|
+
return {
|
|
344
|
+
...changes,
|
|
345
|
+
selectedItem: matchingItem,
|
|
346
|
+
inputValue: itemToString(matchingItem)
|
|
347
|
+
};
|
|
348
|
+
}
|
|
323
349
|
}
|
|
324
350
|
|
|
325
|
-
//
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
// selection, clear the selection.
|
|
335
|
-
if (state.selectedItem !== null) {
|
|
336
|
-
return {
|
|
337
|
-
...changes,
|
|
338
|
-
selectedItem: null,
|
|
339
|
-
inputValue
|
|
340
|
-
};
|
|
351
|
+
// If no matching item is found and there is an existing
|
|
352
|
+
// selection, clear the selection.
|
|
353
|
+
if (state.selectedItem !== null) {
|
|
354
|
+
return {
|
|
355
|
+
...changes,
|
|
356
|
+
selectedItem: null,
|
|
357
|
+
inputValue
|
|
358
|
+
};
|
|
359
|
+
}
|
|
341
360
|
}
|
|
342
361
|
}
|
|
343
362
|
|
|
@@ -502,13 +521,10 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
502
521
|
type,
|
|
503
522
|
selectedItem: newSelectedItem
|
|
504
523
|
});
|
|
505
|
-
if (
|
|
506
|
-
|
|
507
|
-
selectedItem: newSelectedItem
|
|
508
|
-
});
|
|
524
|
+
if (isManualClearingRef.current) {
|
|
525
|
+
return;
|
|
509
526
|
}
|
|
510
|
-
if ((type ===
|
|
511
|
-
) {
|
|
527
|
+
if ((type === ItemClick || type === FunctionSelectItem || type === InputKeyDownEnter) && typeof newSelectedItem !== 'undefined' && !isEqual__default["default"](selectedItemProp, newSelectedItem)) {
|
|
512
528
|
onChange({
|
|
513
529
|
selectedItem: newSelectedItem
|
|
514
530
|
});
|
|
@@ -701,7 +717,13 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
701
717
|
className: `${prefix}--list-box__invalid-icon ${prefix}--list-box__invalid-icon--warning`
|
|
702
718
|
}), inputValue && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
|
|
703
719
|
clearSelection: () => {
|
|
720
|
+
setIsClearing(true); // This updates the state which syncs to the ref
|
|
721
|
+
setInputValue('');
|
|
722
|
+
onChange({
|
|
723
|
+
selectedItem: null
|
|
724
|
+
});
|
|
704
725
|
selectItem(null);
|
|
726
|
+
handleSelectionClear();
|
|
705
727
|
},
|
|
706
728
|
translateWithId: translateWithId,
|
|
707
729
|
disabled: disabled || readOnly,
|
|
@@ -13,20 +13,23 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
13
13
|
var React = require('react');
|
|
14
14
|
var cx = require('classnames');
|
|
15
15
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
16
|
+
var PropTypes = require('prop-types');
|
|
16
17
|
|
|
17
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
19
|
|
|
19
20
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
21
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
22
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
21
23
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
+
const frFn = React.forwardRef;
|
|
25
|
+
const TableCell = frFn((props, ref) => {
|
|
26
|
+
const {
|
|
24
27
|
children,
|
|
25
28
|
className,
|
|
26
29
|
hasAILabelHeader,
|
|
27
30
|
colSpan,
|
|
28
31
|
...rest
|
|
29
|
-
} =
|
|
32
|
+
} = props;
|
|
30
33
|
const prefix = usePrefix.usePrefix();
|
|
31
34
|
const tableCellClassNames = cx__default["default"](className, {
|
|
32
35
|
[`${prefix}--table-cell--column-slug`]: hasAILabelHeader
|
|
@@ -38,5 +41,27 @@ const TableCell = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref)
|
|
|
38
41
|
}, rest), children);
|
|
39
42
|
});
|
|
40
43
|
TableCell.displayName = 'TableCell';
|
|
44
|
+
TableCell.propTypes = {
|
|
45
|
+
/**
|
|
46
|
+
* Pass in children that will be embedded in the table header label
|
|
47
|
+
*/
|
|
48
|
+
children: PropTypes__default["default"].node,
|
|
49
|
+
/**
|
|
50
|
+
* Specify an optional className to be applied to the container node
|
|
51
|
+
*/
|
|
52
|
+
className: PropTypes__default["default"].string,
|
|
53
|
+
/**
|
|
54
|
+
* The width of the expanded row's internal cell
|
|
55
|
+
*/
|
|
56
|
+
colSpan: PropTypes__default["default"].number,
|
|
57
|
+
/**
|
|
58
|
+
* Specify if the table cell is in an AI column
|
|
59
|
+
*/
|
|
60
|
+
hasAILabelHeader: PropTypes__default["default"].bool,
|
|
61
|
+
/**
|
|
62
|
+
* The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
|
|
63
|
+
*/
|
|
64
|
+
headers: PropTypes__default["default"].string
|
|
65
|
+
};
|
|
41
66
|
|
|
42
67
|
exports["default"] = TableCell;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
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
|
+
/**
|
|
8
|
+
* Generates a unique cell ID by combining the row ID and header.
|
|
9
|
+
*
|
|
10
|
+
* Generic helper used to consolidate all call sites for getting a cell ID into
|
|
11
|
+
* one method.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getCellId: (rowId: string, header: string) => string;
|
|
@@ -10,13 +10,10 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* one method. The strategy currently is that a "cellId" is just the combination
|
|
15
|
-
* of the row id and the header key used to access this field in a row.
|
|
13
|
+
* Generates a unique cell ID by combining the row ID and header.
|
|
16
14
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @returns {string}
|
|
15
|
+
* Generic helper used to consolidate all call sites for getting a cell ID into
|
|
16
|
+
* one method.
|
|
20
17
|
*/
|
|
21
18
|
const getCellId = (rowId, header) => `${rowId}:${header}`;
|
|
22
19
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
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
|
+
/**
|
|
8
|
+
* Filters row IDs based on whether any of the cell values in the row include
|
|
9
|
+
* the input value as a substring. Boolean cell values are ignored.
|
|
10
|
+
*/
|
|
11
|
+
export declare const defaultFilterRows: ({ rowIds, headers, cellsById, inputValue, getCellId, }: {
|
|
12
|
+
/** Table row IDs. */
|
|
13
|
+
rowIds: string[];
|
|
14
|
+
/** Table headers. */
|
|
15
|
+
headers: {
|
|
16
|
+
key: string;
|
|
17
|
+
}[];
|
|
18
|
+
/** Mapping of cell IDs to their corresponding cells. */
|
|
19
|
+
cellsById: Record<string, {
|
|
20
|
+
value: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
/** Input value to search for. */
|
|
23
|
+
inputValue: string;
|
|
24
|
+
/** Function that returns a cell ID given a row ID and a header. */
|
|
25
|
+
getCellId: (rowId: string, header: string) => string;
|
|
26
|
+
}) => string[];
|
|
@@ -10,18 +10,8 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* individual cell values for a row. Then, we go through each cell value and see
|
|
16
|
-
* if any of them includes the given inputValue.
|
|
17
|
-
*
|
|
18
|
-
* @param {object} config
|
|
19
|
-
* @param {Array<string>} config.rowIds array of all the row ids in the table
|
|
20
|
-
* @param {Array<object>} config.headers
|
|
21
|
-
* @param {object} config.cellsById object containing a map of cell id to cell
|
|
22
|
-
* @param {string} config.inputValue the current input value in the Table Search
|
|
23
|
-
* @param {Function} config.getCellId
|
|
24
|
-
* @returns {Array<string>} rowIds
|
|
13
|
+
* Filters row IDs based on whether any of the cell values in the row include
|
|
14
|
+
* the input value as a substring. Boolean cell values are ignored.
|
|
25
15
|
*/
|
|
26
16
|
const defaultFilterRows = _ref => {
|
|
27
17
|
let {
|
|
@@ -31,15 +21,16 @@ const defaultFilterRows = _ref => {
|
|
|
31
21
|
inputValue,
|
|
32
22
|
getCellId
|
|
33
23
|
} = _ref;
|
|
24
|
+
const normalizedInput = inputValue.trim().toLowerCase();
|
|
25
|
+
if (!normalizedInput) return rowIds;
|
|
34
26
|
return rowIds.filter(rowId => headers.some(_ref2 => {
|
|
35
27
|
let {
|
|
36
28
|
key
|
|
37
29
|
} = _ref2;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return ('' + cellsById[id].value).toLowerCase().includes(inputValue.toLowerCase());
|
|
30
|
+
const cellId = getCellId(rowId, key);
|
|
31
|
+
const cell = cellsById[cellId];
|
|
32
|
+
if (typeof cell.value === 'boolean') return false;
|
|
33
|
+
return String(cell.value).toLowerCase().includes(normalizedInput);
|
|
43
34
|
}));
|
|
44
35
|
};
|
|
45
36
|
|
|
@@ -473,7 +473,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
|
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
475
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
476
|
-
}, [savedOnChange, savedOnOpen, readOnly, closeOnSelect, hasInput]);
|
|
476
|
+
}, [savedOnChange, savedOnOpen, readOnly, closeOnSelect, hasInput, datePickerType]);
|
|
477
477
|
|
|
478
478
|
// this hook allows consumers to access the flatpickr calendar
|
|
479
479
|
// instance for cases where functions like open() or close()
|
|
@@ -256,9 +256,9 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
256
256
|
|
|
257
257
|
// needs to be Capitalized for react to render it correctly
|
|
258
258
|
const ItemToElement = itemToElement;
|
|
259
|
-
const toggleButtonProps =
|
|
259
|
+
const toggleButtonProps = getToggleButtonProps({
|
|
260
260
|
'aria-label': ariaLabel || deprecatedAriaLabel
|
|
261
|
-
})
|
|
261
|
+
});
|
|
262
262
|
const helper = helperText && !isFluid ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
263
263
|
id: helperId,
|
|
264
264
|
className: helperClasses
|
|
@@ -330,7 +330,10 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
330
330
|
}
|
|
331
331
|
return /*#__PURE__*/React__default["default"].isValidElement(element) ? element : null;
|
|
332
332
|
}, [slug, decorator]);
|
|
333
|
-
const
|
|
333
|
+
const allLabelProps = getLabelProps();
|
|
334
|
+
const labelProps = /*#__PURE__*/React.isValidElement(titleText) ? {
|
|
335
|
+
id: allLabelProps.id
|
|
336
|
+
} : allLabelProps;
|
|
334
337
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
335
338
|
className: wrapperClasses
|
|
336
339
|
}, other), titleText && /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
@@ -377,9 +380,6 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
377
380
|
item,
|
|
378
381
|
index
|
|
379
382
|
});
|
|
380
|
-
if (item !== null && typeof item === 'object' && Object.prototype.hasOwnProperty.call(item, 'id')) {
|
|
381
|
-
itemProps.id = item['id'];
|
|
382
|
-
}
|
|
383
383
|
const title = isObject && 'text' in item && itemToElement ? item.text : itemToString(item);
|
|
384
384
|
return /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
385
385
|
key: itemProps.id,
|
|
@@ -18,17 +18,16 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
18
18
|
|
|
19
19
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
...other
|
|
24
|
-
} = _ref;
|
|
21
|
+
const frFn = React.forwardRef;
|
|
22
|
+
const FluidDatePickerInput = frFn((props, ref) => {
|
|
25
23
|
return /*#__PURE__*/React__default["default"].createElement(FormContext.FormContext.Provider, {
|
|
26
24
|
value: {
|
|
27
25
|
isFluid: true
|
|
28
26
|
}
|
|
29
27
|
}, /*#__PURE__*/React__default["default"].createElement(DatePickerInput["default"], _rollupPluginBabelHelpers["extends"]({
|
|
30
28
|
ref: ref
|
|
31
|
-
},
|
|
29
|
+
}, props)));
|
|
32
30
|
});
|
|
31
|
+
FluidDatePickerInput.propTypes = DatePickerInput["default"].propTypes;
|
|
33
32
|
|
|
34
33
|
exports["default"] = FluidDatePickerInput;
|
|
@@ -111,18 +111,8 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
function handleClose(
|
|
115
|
-
|
|
116
|
-
window.addEventListener('keyup', returnFocus, {
|
|
117
|
-
once: true
|
|
118
|
-
});
|
|
119
|
-
} else if (e.type === 'click' && menu.current) {
|
|
120
|
-
menu.current.addEventListener('focusout', returnFocus, {
|
|
121
|
-
once: true
|
|
122
|
-
});
|
|
123
|
-
} else {
|
|
124
|
-
returnFocus();
|
|
125
|
-
}
|
|
114
|
+
function handleClose() {
|
|
115
|
+
returnFocus();
|
|
126
116
|
if (onClose) {
|
|
127
117
|
onClose();
|
|
128
118
|
}
|
|
@@ -133,7 +123,7 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
|
133
123
|
// if the user presses escape or this is a submenu
|
|
134
124
|
// and the user presses ArrowLeft, close it
|
|
135
125
|
if ((match.match(e, keys.Escape) || !isRoot && match.match(e, keys.ArrowLeft)) && onClose) {
|
|
136
|
-
handleClose(
|
|
126
|
+
handleClose();
|
|
137
127
|
} else {
|
|
138
128
|
focusItem(e);
|
|
139
129
|
}
|
|
@@ -168,7 +158,7 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
|
168
158
|
}
|
|
169
159
|
function handleBlur(e) {
|
|
170
160
|
if (open && onClose && isRoot && !menu.current?.contains(e.relatedTarget)) {
|
|
171
|
-
handleClose(
|
|
161
|
+
handleClose();
|
|
172
162
|
}
|
|
173
163
|
}
|
|
174
164
|
function fitValue(range, axis) {
|
|
@@ -108,18 +108,28 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(_ref, forwardRe
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
// Avoid stray keyup event from MenuButton affecting MenuItem, and vice versa.
|
|
113
|
+
// Keyboard click is handled differently for <button> vs. <li> and for Enter vs. Space. See
|
|
114
|
+
// https://www.stefanjudis.com/today-i-learned/keyboard-button-clicks-with-space-and-enter-behave-differently/.
|
|
115
|
+
const pendingKeyboardClick = React.useRef(false);
|
|
116
|
+
const keyboardClickEvent = e => match.match(e, keys.Enter) || match.match(e, keys.Space);
|
|
111
117
|
function handleKeyDown(e) {
|
|
112
118
|
if (hasChildren && match.match(e, keys.ArrowRight)) {
|
|
113
119
|
openSubmenu();
|
|
114
120
|
e.stopPropagation();
|
|
115
121
|
}
|
|
116
|
-
|
|
117
|
-
handleClick(e);
|
|
118
|
-
}
|
|
122
|
+
pendingKeyboardClick.current = keyboardClickEvent(e);
|
|
119
123
|
if (rest.onKeyDown) {
|
|
120
124
|
rest.onKeyDown(e);
|
|
121
125
|
}
|
|
122
126
|
}
|
|
127
|
+
function handleKeyUp(e) {
|
|
128
|
+
if (pendingKeyboardClick.current && keyboardClickEvent(e)) {
|
|
129
|
+
handleClick(e);
|
|
130
|
+
}
|
|
131
|
+
pendingKeyboardClick.current = false;
|
|
132
|
+
}
|
|
123
133
|
const classNames = cx__default["default"](className, `${prefix}--menu-item`, {
|
|
124
134
|
[`${prefix}--menu-item--disabled`]: isDisabled,
|
|
125
135
|
[`${prefix}--menu-item--danger`]: isDanger
|
|
@@ -172,7 +182,8 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem(_ref, forwardRe
|
|
|
172
182
|
"aria-haspopup": hasChildren ?? undefined,
|
|
173
183
|
"aria-expanded": hasChildren ? submenuOpen : undefined,
|
|
174
184
|
onClick: handleClick,
|
|
175
|
-
onKeyDown: handleKeyDown
|
|
185
|
+
onKeyDown: handleKeyDown,
|
|
186
|
+
onKeyUp: handleKeyUp
|
|
176
187
|
}, getReferenceProps()), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
177
188
|
className: `${prefix}--menu-item__selection-icon`
|
|
178
189
|
}, rest['aria-checked'] && (_Checkmark || (_Checkmark = /*#__PURE__*/React__default["default"].createElement(iconsReact.Checkmark, null)))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -435,7 +435,10 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
435
435
|
const menuProps = React.useMemo(() => getMenuProps({
|
|
436
436
|
ref: enableFloatingStyles ? refs.setFloating : null
|
|
437
437
|
}), [enableFloatingStyles, getMenuProps, refs.setFloating]);
|
|
438
|
-
const
|
|
438
|
+
const allLabelProps = getLabelProps();
|
|
439
|
+
const labelProps = /*#__PURE__*/React.isValidElement(titleText) ? {
|
|
440
|
+
id: allLabelProps.id
|
|
441
|
+
} : allLabelProps;
|
|
439
442
|
const getSelectionStats = React.useCallback((selectedItems, filteredItems) => {
|
|
440
443
|
const hasIndividualSelections = selectedItems.some(selected => !selected.isSelectAll);
|
|
441
444
|
const nonSelectAllSelectedCount = selectedItems.filter(selected => !selected.isSelectAll).length;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import type
|
|
8
|
+
import { type OverflowMenuProps } from './OverflowMenu';
|
|
9
9
|
declare const OverflowMenu: React.ForwardRefExoticComponent<OverflowMenuProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
10
|
export default OverflowMenu;
|
|
11
11
|
export { OverflowMenu, type OverflowMenuProps };
|
|
@@ -14,22 +14,21 @@ var React = require('react');
|
|
|
14
14
|
var index = require('../FeatureFlags/index.js');
|
|
15
15
|
var index$1 = require('./next/index.js');
|
|
16
16
|
var OverflowMenu$1 = require('./OverflowMenu.js');
|
|
17
|
-
var createClassWrapper = require('../../internal/createClassWrapper.js');
|
|
18
17
|
|
|
19
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
19
|
|
|
21
20
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
21
|
|
|
23
|
-
const OverflowMenuV11 = createClassWrapper.createClassWrapper(OverflowMenu$1.OverflowMenu);
|
|
24
22
|
const OverflowMenu = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
25
23
|
const enableV12OverflowMenu = index.useFeatureFlag('enable-v12-overflowmenu');
|
|
26
24
|
return enableV12OverflowMenu ? /*#__PURE__*/React__default["default"].createElement(index$1.OverflowMenu, _rollupPluginBabelHelpers["extends"]({}, props, {
|
|
27
25
|
ref: ref
|
|
28
|
-
})) : /*#__PURE__*/React__default["default"].createElement(
|
|
26
|
+
})) : /*#__PURE__*/React__default["default"].createElement(OverflowMenu$1.OverflowMenu, _rollupPluginBabelHelpers["extends"]({}, props, {
|
|
29
27
|
ref: ref
|
|
30
28
|
}));
|
|
31
29
|
});
|
|
32
30
|
OverflowMenu.displayName = 'OverflowMenu';
|
|
31
|
+
OverflowMenu.propTypes = OverflowMenu$1.OverflowMenu.propTypes;
|
|
33
32
|
|
|
34
33
|
exports.OverflowMenu = OverflowMenu;
|
|
35
34
|
exports["default"] = OverflowMenu;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { type ComponentType, type FunctionComponent } from 'react';
|
|
8
|
+
import { Tabs as BaseTabs } from '../Tabs/Tabs';
|
|
8
9
|
/**
|
|
9
10
|
* ----------
|
|
10
11
|
* PageHeader
|
|
@@ -87,6 +88,11 @@ interface PageHeaderTabBarProps {
|
|
|
87
88
|
className?: string;
|
|
88
89
|
}
|
|
89
90
|
declare const PageHeaderTabBar: React.ForwardRefExoticComponent<PageHeaderTabBarProps & React.RefAttributes<HTMLDivElement>>;
|
|
91
|
+
interface PageHeaderTabsProps extends React.ComponentProps<typeof BaseTabs> {
|
|
92
|
+
children?: React.ReactNode;
|
|
93
|
+
className?: string;
|
|
94
|
+
}
|
|
95
|
+
declare const PageHeaderTabs: React.ForwardRefExoticComponent<PageHeaderTabsProps & React.RefAttributes<HTMLDivElement>>;
|
|
90
96
|
/**
|
|
91
97
|
* -------
|
|
92
98
|
* Exports
|
|
@@ -97,5 +103,6 @@ declare const BreadcrumbBar: React.ForwardRefExoticComponent<PageHeaderBreadcrum
|
|
|
97
103
|
declare const Content: React.ForwardRefExoticComponent<PageHeaderContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
98
104
|
declare const HeroImage: React.ForwardRefExoticComponent<PageHeaderHeroImageProps & React.RefAttributes<HTMLDivElement>>;
|
|
99
105
|
declare const TabBar: React.ForwardRefExoticComponent<PageHeaderTabBarProps & React.RefAttributes<HTMLDivElement>>;
|
|
100
|
-
|
|
101
|
-
export
|
|
106
|
+
declare const Tabs: React.ForwardRefExoticComponent<PageHeaderTabsProps & React.RefAttributes<HTMLDivElement>>;
|
|
107
|
+
export { PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderHeroImage, PageHeaderTabBar, PageHeaderTabs, Root, BreadcrumbBar, Content, HeroImage, TabBar, Tabs, };
|
|
108
|
+
export type { PageHeaderProps, PageHeaderBreadcrumbBarProps, PageHeaderContentProps, PageHeaderHeroImageProps, PageHeaderTabBarProps, PageHeaderTabsProps, };
|
|
@@ -20,6 +20,7 @@ require('../Text/index.js');
|
|
|
20
20
|
var DefinitionTooltip = require('../Tooltip/DefinitionTooltip.js');
|
|
21
21
|
require('../Tooltip/Tooltip.js');
|
|
22
22
|
var AspectRatio = require('../AspectRatio/AspectRatio.js');
|
|
23
|
+
var Tabs$1 = require('../Tabs/Tabs.js');
|
|
23
24
|
var Text = require('../Text/Text.js');
|
|
24
25
|
|
|
25
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -28,7 +29,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
28
29
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
29
30
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
30
31
|
|
|
31
|
-
var _p, _p2
|
|
32
|
+
var _p, _p2;
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* ----------
|
|
@@ -228,9 +229,18 @@ const PageHeaderTabBar = /*#__PURE__*/React__default["default"].forwardRef(funct
|
|
|
228
229
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
229
230
|
className: classNames,
|
|
230
231
|
ref: ref
|
|
231
|
-
}, other),
|
|
232
|
+
}, other), children);
|
|
232
233
|
});
|
|
233
234
|
PageHeaderTabBar.displayName = 'PageHeaderTabBar';
|
|
235
|
+
const PageHeaderTabs = /*#__PURE__*/React__default["default"].forwardRef(function PageHeaderTabs(_ref6, ref) {
|
|
236
|
+
let {
|
|
237
|
+
className,
|
|
238
|
+
children,
|
|
239
|
+
...other
|
|
240
|
+
} = _ref6;
|
|
241
|
+
return /*#__PURE__*/React__default["default"].createElement(Tabs$1.Tabs, other, children);
|
|
242
|
+
});
|
|
243
|
+
PageHeaderTabs.displayName = 'PageHeaderTabs';
|
|
234
244
|
|
|
235
245
|
/**
|
|
236
246
|
* -------
|
|
@@ -247,6 +257,8 @@ const HeroImage = PageHeaderHeroImage;
|
|
|
247
257
|
HeroImage.displayName = 'PageHeaderHeroImage';
|
|
248
258
|
const TabBar = PageHeaderTabBar;
|
|
249
259
|
TabBar.displayName = 'PageHeaderTabBar';
|
|
260
|
+
const Tabs = PageHeaderTabs;
|
|
261
|
+
Tabs.displayName = 'PageHeader.Tabs';
|
|
250
262
|
|
|
251
263
|
exports.BreadcrumbBar = BreadcrumbBar;
|
|
252
264
|
exports.Content = Content;
|
|
@@ -256,5 +268,7 @@ exports.PageHeaderBreadcrumbBar = PageHeaderBreadcrumbBar;
|
|
|
256
268
|
exports.PageHeaderContent = PageHeaderContent;
|
|
257
269
|
exports.PageHeaderHeroImage = PageHeaderHeroImage;
|
|
258
270
|
exports.PageHeaderTabBar = PageHeaderTabBar;
|
|
271
|
+
exports.PageHeaderTabs = PageHeaderTabs;
|
|
259
272
|
exports.Root = Root;
|
|
260
273
|
exports.TabBar = TabBar;
|
|
274
|
+
exports.Tabs = Tabs;
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
export { PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderTabBar, PageHeaderHeroImage, Root, BreadcrumbBar, Content, TabBar, HeroImage, } from './PageHeader';
|
|
8
|
-
export type { PageHeaderProps, PageHeaderBreadcrumbBarProps, PageHeaderContentProps, PageHeaderTabBarProps, PageHeaderHeroImageProps, } from './PageHeader';
|
|
7
|
+
export { PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderTabBar, PageHeaderHeroImage, PageHeaderTabs, Root, BreadcrumbBar, Content, TabBar, HeroImage, Tabs, } from './PageHeader';
|
|
8
|
+
export type { PageHeaderProps, PageHeaderBreadcrumbBarProps, PageHeaderContentProps, PageHeaderTabBarProps, PageHeaderHeroImageProps, PageHeaderTabsProps, } from './PageHeader';
|
|
@@ -21,5 +21,7 @@ exports.PageHeaderBreadcrumbBar = PageHeader.PageHeaderBreadcrumbBar;
|
|
|
21
21
|
exports.PageHeaderContent = PageHeader.PageHeaderContent;
|
|
22
22
|
exports.PageHeaderHeroImage = PageHeader.PageHeaderHeroImage;
|
|
23
23
|
exports.PageHeaderTabBar = PageHeader.PageHeaderTabBar;
|
|
24
|
+
exports.PageHeaderTabs = PageHeader.PageHeaderTabs;
|
|
24
25
|
exports.Root = PageHeader.Root;
|
|
25
26
|
exports.TabBar = PageHeader.TabBar;
|
|
27
|
+
exports.Tabs = PageHeader.Tabs;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.81.0
|
|
4
|
+
"version": "1.81.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@babel/runtime": "^7.24.7",
|
|
55
55
|
"@carbon/feature-flags": "^0.26.0",
|
|
56
|
-
"@carbon/icons-react": "^11.59.0
|
|
57
|
-
"@carbon/layout": "^11.33.0
|
|
58
|
-
"@carbon/styles": "^1.80.0
|
|
56
|
+
"@carbon/icons-react": "^11.59.0",
|
|
57
|
+
"@carbon/layout": "^11.33.0",
|
|
58
|
+
"@carbon/styles": "^1.80.0",
|
|
59
59
|
"@floating-ui/react": "^0.27.4",
|
|
60
60
|
"@ibm/telemetry-js": "^1.5.0",
|
|
61
61
|
"classnames": "2.5.1",
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
"@babel/preset-env": "^7.24.7",
|
|
80
80
|
"@babel/preset-react": "^7.24.7",
|
|
81
81
|
"@babel/preset-typescript": "^7.24.7",
|
|
82
|
-
"@carbon/test-utils": "^10.36.0
|
|
83
|
-
"@carbon/themes": "^11.51.0
|
|
84
|
-
"@figma/code-connect": "^1.2
|
|
82
|
+
"@carbon/test-utils": "^10.36.0",
|
|
83
|
+
"@carbon/themes": "^11.51.0",
|
|
84
|
+
"@figma/code-connect": "^1.3.2",
|
|
85
85
|
"@rollup/plugin-babel": "^6.0.0",
|
|
86
86
|
"@rollup/plugin-commonjs": "^28.0.0",
|
|
87
87
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
@@ -147,5 +147,5 @@
|
|
|
147
147
|
"**/*.scss",
|
|
148
148
|
"**/*.css"
|
|
149
149
|
],
|
|
150
|
-
"gitHead": "
|
|
150
|
+
"gitHead": "01b2d2b1c2d901921c615dcbdb85e0a2340b67e6"
|
|
151
151
|
}
|