@carbon/react 1.81.0 → 1.82.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +892 -892
- package/es/components/AILabel/index.d.ts +1 -1
- package/es/components/AILabel/index.js +2 -9
- package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -3
- package/es/components/Breadcrumb/Breadcrumb.js +4 -4
- package/es/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
- package/es/components/Breadcrumb/BreadcrumbItem.js +5 -4
- package/es/components/Button/Button.js +2 -10
- package/es/components/ButtonSet/ButtonSet.d.ts +2 -3
- package/es/components/ButtonSet/ButtonSet.js +4 -4
- package/es/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/es/components/CodeSnippet/CodeSnippet.js +3 -19
- package/es/components/ComboBox/ComboBox.d.ts +1 -1
- package/es/components/ComboBox/ComboBox.js +2 -2
- package/es/components/ComboButton/index.d.ts +1 -1
- package/es/components/ComboButton/index.js +2 -18
- package/es/components/ComposedModal/ComposedModal.js +5 -3
- package/es/components/Copy/Copy.d.ts +1 -1
- package/es/components/Copy/Copy.js +2 -18
- package/es/components/CopyButton/CopyButton.d.ts +1 -1
- package/es/components/CopyButton/CopyButton.js +2 -18
- package/es/components/DataTable/DataTable.d.ts +7 -12
- package/es/components/DataTable/DataTable.js +0 -5
- package/es/components/DataTable/TableToolbarAction.d.ts +2 -4
- package/es/components/DataTable/TableToolbarAction.js +5 -4
- package/es/components/DataTable/tools/sorting.d.ts +42 -0
- package/es/components/DataTable/tools/sorting.js +24 -53
- package/es/components/DatePicker/DatePicker.d.ts +1 -1
- package/es/components/DatePicker/DatePicker.js +18 -18
- package/es/components/Dialog/index.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
- package/es/components/Dropdown/Dropdown.Skeleton.js +2 -2
- package/es/components/Dropdown/Dropdown.d.ts +7 -6
- package/es/components/Dropdown/Dropdown.js +7 -3
- package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +1 -1
- package/es/components/FluidDropdown/FluidDropdown.d.ts +1 -1
- package/es/components/FluidSearch/FluidSearch.d.ts +3 -6
- package/es/components/IconButton/index.d.ts +1 -1
- package/es/components/IconButton/index.js +2 -18
- package/es/components/ListBox/ListBox.d.ts +4 -5
- package/es/components/ListBox/ListBox.js +8 -7
- package/es/components/ListBox/ListBoxMenu.d.ts +4 -4
- package/es/components/ListBox/ListBoxMenu.js +4 -2
- package/es/components/ListBox/ListBoxMenuItem.d.ts +9 -8
- package/es/components/ListBox/ListBoxPropTypes.d.ts +3 -3
- package/es/components/ListBox/ListBoxPropTypes.js +3 -3
- package/es/components/ListBox/index.d.ts +7 -5
- package/es/components/ListBox/index.js +1 -1
- package/es/components/Menu/Menu.js +5 -0
- package/es/components/Modal/Modal.js +9 -9
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
- package/es/components/MultiSelect/FilterableMultiSelect.js +3 -2
- package/es/components/MultiSelect/MultiSelect.d.ts +8 -2
- package/es/components/MultiSelect/MultiSelect.js +3 -3
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/OverflowMenu/OverflowMenu.js +2 -21
- package/es/components/OverflowMenu/next/index.js +2 -18
- package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +5 -4
- package/es/components/PageHeader/PageHeader.d.ts +153 -8
- package/es/components/PageHeader/PageHeader.js +143 -21
- package/es/components/PageHeader/index.d.ts +2 -2
- package/es/components/PageHeader/index.js +1 -1
- package/es/components/Popover/index.js +4 -21
- package/es/components/Search/Search.d.ts +2 -5
- package/es/components/Search/Search.js +24 -8
- package/es/components/Stack/HStack.d.ts +2 -3
- package/es/components/Stack/HStack.js +4 -7
- package/es/components/Stack/Stack.d.ts +3 -4
- package/es/components/Stack/Stack.js +3 -6
- package/es/components/Stack/VStack.d.ts +2 -3
- package/es/components/Stack/VStack.js +3 -2
- package/es/components/Stack/index.d.ts +4 -4
- package/es/components/TextArea/TextArea.js +3 -5
- package/es/components/TimePicker/TimePicker.d.ts +3 -4
- package/es/components/TimePicker/TimePicker.js +5 -4
- package/es/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
- package/es/components/TimePickerSelect/TimePickerSelect.js +5 -4
- package/es/components/TreeView/TreeNode.js +13 -1
- package/es/components/TreeView/TreeView.js +1 -1
- package/es/index.js +1 -1
- package/es/internal/FloatingMenu.js +9 -5
- package/es/internal/environment.js +7 -0
- package/es/internal/keyboard/navigation.d.ts +0 -10
- package/es/internal/keyboard/navigation.js +1 -13
- package/es/internal/useId.js +1 -1
- package/es/internal/useNoInteractiveChildren.js +7 -0
- package/es/internal/useOutsideClick.js +3 -0
- package/es/internal/wrapFocus.d.ts +49 -0
- package/es/internal/wrapFocus.js +64 -51
- package/es/tools/events.d.ts +17 -0
- package/es/tools/events.js +10 -13
- package/es/tools/mapPopoverAlign.d.ts +15 -0
- package/es/tools/mapPopoverAlign.js +28 -0
- package/es/tools/uniqueId.d.ts +7 -0
- package/es/tools/uniqueId.js +3 -3
- package/es/types/common.d.ts +0 -2
- package/lib/components/AILabel/index.d.ts +1 -1
- package/lib/components/AILabel/index.js +2 -9
- package/lib/components/Breadcrumb/Breadcrumb.d.ts +2 -3
- package/lib/components/Breadcrumb/Breadcrumb.js +3 -3
- package/lib/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
- package/lib/components/Breadcrumb/BreadcrumbItem.js +4 -3
- package/lib/components/Button/Button.js +1 -9
- package/lib/components/ButtonSet/ButtonSet.d.ts +2 -3
- package/lib/components/ButtonSet/ButtonSet.js +3 -3
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/lib/components/CodeSnippet/CodeSnippet.js +3 -19
- package/lib/components/ComboBox/ComboBox.d.ts +1 -1
- package/lib/components/ComboBox/ComboBox.js +1 -1
- package/lib/components/ComboButton/index.d.ts +1 -1
- package/lib/components/ComboButton/index.js +2 -18
- package/lib/components/ComposedModal/ComposedModal.js +5 -3
- package/lib/components/Copy/Copy.d.ts +1 -1
- package/lib/components/Copy/Copy.js +2 -18
- package/lib/components/CopyButton/CopyButton.d.ts +1 -1
- package/lib/components/CopyButton/CopyButton.js +2 -18
- package/lib/components/DataTable/DataTable.d.ts +7 -12
- package/lib/components/DataTable/DataTable.js +0 -5
- package/lib/components/DataTable/TableToolbarAction.d.ts +2 -4
- package/lib/components/DataTable/TableToolbarAction.js +4 -3
- package/lib/components/DataTable/tools/sorting.d.ts +42 -0
- package/lib/components/DataTable/tools/sorting.js +23 -53
- package/lib/components/DatePicker/DatePicker.d.ts +1 -1
- package/lib/components/DatePicker/DatePicker.js +18 -18
- package/lib/components/Dialog/index.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
- package/lib/components/Dropdown/Dropdown.Skeleton.js +1 -1
- package/lib/components/Dropdown/Dropdown.d.ts +7 -6
- package/lib/components/Dropdown/Dropdown.js +6 -2
- package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +1 -1
- package/lib/components/FluidDropdown/FluidDropdown.d.ts +1 -1
- package/lib/components/FluidSearch/FluidSearch.d.ts +3 -6
- package/lib/components/IconButton/index.d.ts +1 -1
- package/lib/components/IconButton/index.js +2 -18
- package/lib/components/ListBox/ListBox.d.ts +4 -5
- package/lib/components/ListBox/ListBox.js +7 -6
- package/lib/components/ListBox/ListBoxMenu.d.ts +4 -4
- package/lib/components/ListBox/ListBoxMenu.js +3 -1
- package/lib/components/ListBox/ListBoxMenuItem.d.ts +9 -8
- package/lib/components/ListBox/ListBoxPropTypes.d.ts +3 -3
- package/lib/components/ListBox/ListBoxPropTypes.js +4 -4
- package/lib/components/ListBox/index.d.ts +7 -5
- package/lib/components/ListBox/index.js +2 -2
- package/lib/components/Menu/Menu.js +5 -0
- package/lib/components/Modal/Modal.js +9 -9
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.js +2 -1
- package/lib/components/MultiSelect/MultiSelect.d.ts +8 -2
- package/lib/components/MultiSelect/MultiSelect.js +2 -2
- package/lib/components/Notification/Notification.js +1 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -21
- package/lib/components/OverflowMenu/next/index.js +2 -18
- package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +4 -3
- package/lib/components/PageHeader/PageHeader.d.ts +153 -8
- package/lib/components/PageHeader/PageHeader.js +145 -19
- package/lib/components/PageHeader/index.d.ts +2 -2
- package/lib/components/PageHeader/index.js +4 -0
- package/lib/components/Popover/index.js +4 -21
- package/lib/components/Search/Search.d.ts +2 -5
- package/lib/components/Search/Search.js +24 -8
- package/lib/components/Stack/HStack.d.ts +2 -3
- package/lib/components/Stack/HStack.js +3 -6
- package/lib/components/Stack/Stack.d.ts +3 -4
- package/lib/components/Stack/Stack.js +2 -5
- package/lib/components/Stack/VStack.d.ts +2 -3
- package/lib/components/Stack/VStack.js +2 -1
- package/lib/components/Stack/index.d.ts +4 -4
- package/lib/components/TextArea/TextArea.js +2 -4
- package/lib/components/TimePicker/TimePicker.d.ts +3 -4
- package/lib/components/TimePicker/TimePicker.js +4 -3
- package/lib/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
- package/lib/components/TimePickerSelect/TimePickerSelect.js +4 -3
- package/lib/components/TreeView/TreeNode.js +13 -1
- package/lib/components/TreeView/TreeView.js +1 -1
- package/lib/index.js +2 -2
- package/lib/internal/FloatingMenu.js +9 -5
- package/lib/internal/environment.js +7 -0
- package/lib/internal/keyboard/navigation.d.ts +0 -10
- package/lib/internal/keyboard/navigation.js +0 -14
- package/lib/internal/useNoInteractiveChildren.js +7 -0
- package/lib/internal/useOutsideClick.js +3 -0
- package/lib/internal/wrapFocus.d.ts +49 -0
- package/lib/internal/wrapFocus.js +66 -53
- package/lib/tools/events.d.ts +17 -0
- package/lib/tools/events.js +10 -13
- package/lib/tools/mapPopoverAlign.d.ts +15 -0
- package/lib/tools/mapPopoverAlign.js +32 -0
- package/lib/tools/uniqueId.d.ts +7 -0
- package/lib/tools/uniqueId.js +3 -3
- package/lib/types/common.d.ts +0 -2
- package/package.json +7 -7
- package/telemetry.yml +3 -1
- package/es/tools/createPropAdapter.js +0 -40
- package/lib/tools/createPropAdapter.js +0 -44
|
@@ -9,76 +9,43 @@ import { getCellId } from './cells.js';
|
|
|
9
9
|
import { sortStates } from '../state/sortStates.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Compare two
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* string conversion.
|
|
16
|
-
*
|
|
17
|
-
* @param {number|string} a
|
|
18
|
-
* @param {number|string} b
|
|
19
|
-
* @param {string} locale
|
|
20
|
-
* @returns {number}
|
|
12
|
+
* Compare two values to determine their order. If both values have the same
|
|
13
|
+
* type, the default sort algorithm will be used for those types. Otherwise, the
|
|
14
|
+
* values will be converted to strings for comparison.
|
|
21
15
|
*/
|
|
22
16
|
const compare = function (a, b) {
|
|
23
17
|
let locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en';
|
|
24
18
|
// prevent multiple null values in one column (sorting breaks)
|
|
25
|
-
a === null
|
|
26
|
-
b === null
|
|
19
|
+
if (a === null) a = '';
|
|
20
|
+
if (b === null) b = '';
|
|
27
21
|
if (typeof a === 'number' && typeof b === 'number') {
|
|
28
22
|
return a - b;
|
|
29
23
|
}
|
|
30
24
|
if (typeof a === 'string' && typeof b === 'string') {
|
|
31
25
|
return compareStrings(a, b, locale);
|
|
32
26
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (typeof
|
|
36
|
-
|
|
37
|
-
return compareStrings(a.props.children, b.props.children, locale);
|
|
38
|
-
}
|
|
27
|
+
const aChild = a?.props?.children;
|
|
28
|
+
const bChild = b?.props?.children;
|
|
29
|
+
if (typeof aChild === 'string' && typeof bChild === 'string') {
|
|
30
|
+
return compareStrings(aChild, bChild, locale);
|
|
39
31
|
}
|
|
40
|
-
return compareStrings(
|
|
32
|
+
return compareStrings(String(a), String(b), locale);
|
|
41
33
|
};
|
|
42
34
|
|
|
43
35
|
/**
|
|
44
|
-
*
|
|
45
|
-
* strings.
|
|
36
|
+
* Compares two strings using `localeCompare`.
|
|
46
37
|
*
|
|
47
|
-
*
|
|
48
|
-
* @param {string} b
|
|
49
|
-
* @param {string} locale
|
|
50
|
-
* @returns {number}
|
|
38
|
+
* Note: Uses numeric comparison if strings are numeric.
|
|
51
39
|
*/
|
|
52
40
|
const compareStrings = function (a, b) {
|
|
53
41
|
let locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en';
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
numeric: true
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return a.localeCompare(b, locale);
|
|
42
|
+
const isNumeric = !isNaN(parseFloat(a)) && !isNaN(parseFloat(b));
|
|
43
|
+
return a.localeCompare(b, locale, {
|
|
44
|
+
numeric: isNumeric
|
|
45
|
+
});
|
|
62
46
|
};
|
|
63
|
-
|
|
64
47
|
/**
|
|
65
|
-
*
|
|
66
|
-
* implementation is to use the given list of row ids to look up the cells in
|
|
67
|
-
* the row by the given key. We then use the value of these cells and pipe them
|
|
68
|
-
* into our local `compareStrings` method, including the locale where
|
|
69
|
-
* appropriate.
|
|
70
|
-
*
|
|
71
|
-
* @param {object} config
|
|
72
|
-
* @param {Array[string]} config.rowIds array of all the row ids in the table
|
|
73
|
-
* @param {object} config.cellsById object containing a mapping of cell id to
|
|
74
|
-
* cell
|
|
75
|
-
* @param {string} config.key the header key that we use to lookup the cell
|
|
76
|
-
* @param {string} [config.locale] optional locale used in the comparison
|
|
77
|
-
* function
|
|
78
|
-
* @param {string} config.sortDirection the sort direction used to determine the
|
|
79
|
-
* order the comparison is called in
|
|
80
|
-
* @param {Function} config.sortRow
|
|
81
|
-
* @returns {Array[string]} array of sorted rowIds
|
|
48
|
+
* Sorts table rows based on the provided column key and direction.
|
|
82
49
|
*/
|
|
83
50
|
const sortRows = _ref => {
|
|
84
51
|
let {
|
|
@@ -92,16 +59,20 @@ const sortRows = _ref => {
|
|
|
92
59
|
return rowIds.slice().sort((a, b) => {
|
|
93
60
|
const cellA = cellsById[getCellId(a, key)];
|
|
94
61
|
const cellB = cellsById[getCellId(b, key)];
|
|
95
|
-
return sortRow(cellA
|
|
62
|
+
return sortRow(cellA?.value, cellB?.value, {
|
|
96
63
|
key,
|
|
97
64
|
sortDirection,
|
|
98
|
-
locale,
|
|
99
65
|
sortStates,
|
|
66
|
+
locale,
|
|
100
67
|
compare,
|
|
101
68
|
rowIds: [a, b]
|
|
102
69
|
});
|
|
103
70
|
});
|
|
104
71
|
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Sorts table rows based on the sort direction.
|
|
75
|
+
*/
|
|
105
76
|
const defaultSortRow = (cellA, cellB, _ref2) => {
|
|
106
77
|
let {
|
|
107
78
|
sortDirection,
|
|
@@ -114,4 +85,4 @@ const defaultSortRow = (cellA, cellB, _ref2) => {
|
|
|
114
85
|
return compare(cellB, cellA, locale);
|
|
115
86
|
};
|
|
116
87
|
|
|
117
|
-
export { compare,
|
|
88
|
+
export { compare, defaultSortRow, sortRows };
|
|
@@ -120,7 +120,7 @@ export interface DatePickerProps {
|
|
|
120
120
|
* The value of the date value provided to flatpickr, could
|
|
121
121
|
* be a date, a date number, a date string, an array of dates.
|
|
122
122
|
*/
|
|
123
|
-
value?:
|
|
123
|
+
value?: DateOption | DateOption[];
|
|
124
124
|
/**
|
|
125
125
|
* Specify whether the control is currently in warning state (Fluid only)
|
|
126
126
|
*/
|
|
@@ -173,13 +173,14 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
|
|
|
173
173
|
}
|
|
174
174
|
}, []);
|
|
175
175
|
const lastStartValue = useRef('');
|
|
176
|
+
const calendarRef = useRef(null);
|
|
176
177
|
const [calendarCloseEvent, setCalendarCloseEvent] = useState(null);
|
|
177
178
|
|
|
178
179
|
// fix datepicker deleting the selectedDate when the calendar closes
|
|
179
180
|
const handleCalendarClose = useCallback((selectedDates, dateStr, instance) => {
|
|
180
181
|
if (lastStartValue.current && selectedDates[0] && !startInputField.current.value) {
|
|
181
182
|
startInputField.current.value = lastStartValue.current;
|
|
182
|
-
calendarRef.current
|
|
183
|
+
calendarRef.current?.setDate([startInputField.current.value, endInputField?.current?.value], true, calendarRef.current.config.dateFormat);
|
|
183
184
|
}
|
|
184
185
|
if (onClose) {
|
|
185
186
|
onClose(selectedDates, dateStr, instance);
|
|
@@ -207,7 +208,6 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
|
|
|
207
208
|
}
|
|
208
209
|
}, [calendarCloseEvent, handleCalendarClose]);
|
|
209
210
|
const endInputField = useRef(null);
|
|
210
|
-
const calendarRef = useRef(null);
|
|
211
211
|
const savedOnChange = useSavedCallback(onChange);
|
|
212
212
|
const savedOnOpen = useSavedCallback(onOpen);
|
|
213
213
|
const datePickerClasses = cx(`${prefix}--date-picker`, {
|
|
@@ -324,7 +324,7 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
|
|
|
324
324
|
const {
|
|
325
325
|
current: end
|
|
326
326
|
} = endInputField;
|
|
327
|
-
const
|
|
327
|
+
const flatpickerConfig = {
|
|
328
328
|
inline: inline ?? false,
|
|
329
329
|
onClose: onCalendarClose,
|
|
330
330
|
disableMobile: true,
|
|
@@ -370,7 +370,7 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
|
|
|
370
370
|
},
|
|
371
371
|
onValueUpdate: onHook
|
|
372
372
|
};
|
|
373
|
-
const calendar = flatpickr(start,
|
|
373
|
+
const calendar = flatpickr(start, flatpickerConfig);
|
|
374
374
|
calendarRef.current = calendar;
|
|
375
375
|
function handleArrowDown(event) {
|
|
376
376
|
if (match(event, Escape)) {
|
|
@@ -383,10 +383,10 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
|
|
|
383
383
|
const {
|
|
384
384
|
calendarContainer,
|
|
385
385
|
selectedDateElem: fpSelectedDateElem,
|
|
386
|
-
todayDateElem:
|
|
386
|
+
todayDateElem: fpTodayDateElem
|
|
387
387
|
} = calendar;
|
|
388
388
|
const selectedDateElem = calendarContainer.querySelector('.selected') && fpSelectedDateElem;
|
|
389
|
-
const todayDateElem = calendarContainer.querySelector('.today') &&
|
|
389
|
+
const todayDateElem = calendarContainer.querySelector('.today') && fpTodayDateElem;
|
|
390
390
|
(selectedDateElem || todayDateElem || calendarContainer.querySelector('.flatpickr-day[tabindex]') || calendarContainer).focus();
|
|
391
391
|
}
|
|
392
392
|
}
|
|
@@ -472,44 +472,44 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
|
|
|
472
472
|
}
|
|
473
473
|
}));
|
|
474
474
|
useEffect(() => {
|
|
475
|
-
if (calendarRef
|
|
475
|
+
if (calendarRef.current?.set) {
|
|
476
476
|
calendarRef.current.set({
|
|
477
477
|
dateFormat
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
480
|
}, [dateFormat]);
|
|
481
481
|
useEffect(() => {
|
|
482
|
-
if (calendarRef
|
|
482
|
+
if (calendarRef.current?.set) {
|
|
483
483
|
calendarRef.current.set('minDate', minDate);
|
|
484
484
|
}
|
|
485
485
|
}, [minDate]);
|
|
486
486
|
useEffect(() => {
|
|
487
|
-
if (calendarRef
|
|
487
|
+
if (calendarRef.current?.set) {
|
|
488
488
|
calendarRef.current.set('allowInput', allowInput);
|
|
489
489
|
}
|
|
490
490
|
}, [allowInput]);
|
|
491
491
|
useEffect(() => {
|
|
492
|
-
if (calendarRef
|
|
492
|
+
if (calendarRef.current?.set) {
|
|
493
493
|
calendarRef.current.set('maxDate', maxDate);
|
|
494
494
|
}
|
|
495
495
|
}, [maxDate]);
|
|
496
496
|
useEffect(() => {
|
|
497
|
-
if (calendarRef
|
|
497
|
+
if (calendarRef.current?.set && disable) {
|
|
498
498
|
calendarRef.current.set('disable', disable);
|
|
499
499
|
}
|
|
500
500
|
}, [disable]);
|
|
501
501
|
useEffect(() => {
|
|
502
|
-
if (calendarRef
|
|
502
|
+
if (calendarRef.current?.set && enable) {
|
|
503
503
|
calendarRef.current.set('enable', enable);
|
|
504
504
|
}
|
|
505
505
|
}, [enable]);
|
|
506
506
|
useEffect(() => {
|
|
507
|
-
if (calendarRef
|
|
507
|
+
if (calendarRef.current?.set && inline) {
|
|
508
508
|
calendarRef.current.set('inline', inline);
|
|
509
509
|
}
|
|
510
510
|
}, [inline]);
|
|
511
511
|
useEffect(() => {
|
|
512
|
-
//when value prop is set to empty, this clears the
|
|
512
|
+
//when value prop is set to empty, this clears the flatpicker's calendar instance and text input
|
|
513
513
|
if (value === '') {
|
|
514
514
|
calendarRef.current?.clear();
|
|
515
515
|
if (startInputField.current) {
|
|
@@ -528,9 +528,9 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
|
|
|
528
528
|
}
|
|
529
529
|
};
|
|
530
530
|
const closeCalendar = event => {
|
|
531
|
-
calendarRef.current
|
|
531
|
+
calendarRef.current?.close();
|
|
532
532
|
// Remove focus from endDate calendar input
|
|
533
|
-
onCalendarClose(calendarRef.current
|
|
533
|
+
onCalendarClose(calendarRef.current?.selectedDates, '', calendarRef.current, {
|
|
534
534
|
type: 'clickOutside'
|
|
535
535
|
});
|
|
536
536
|
};
|
|
@@ -540,7 +540,7 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
|
|
|
540
540
|
};
|
|
541
541
|
}, [calendarRef, startInputField, endInputField, onCalendarClose]);
|
|
542
542
|
useEffect(() => {
|
|
543
|
-
if (calendarRef
|
|
543
|
+
if (calendarRef.current?.set) {
|
|
544
544
|
if (value !== undefined) {
|
|
545
545
|
calendarRef.current.setDate(value);
|
|
546
546
|
}
|
|
@@ -554,7 +554,7 @@ const DatePicker = /*#__PURE__*/React__default.forwardRef(function DatePicker(_r
|
|
|
554
554
|
useEffect(() => {
|
|
555
555
|
if (!calendarRef.current || !startInputField.current) return;
|
|
556
556
|
const handleKeyDown = event => {
|
|
557
|
-
if (match(event, Tab) && !event.shiftKey && document.activeElement === endInputField.current && calendarRef.current
|
|
557
|
+
if (match(event, Tab) && !event.shiftKey && document.activeElement === endInputField.current && calendarRef.current?.isOpen) {
|
|
558
558
|
calendarRef.current.close();
|
|
559
559
|
onCalendarClose(calendarRef.current.selectedDates, '', calendarRef.current, event);
|
|
560
560
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
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
7
|
import React from 'react';
|
|
8
|
-
import { ListBoxSize } from '../ListBox';
|
|
8
|
+
import { type ListBoxSize } from '../ListBox';
|
|
9
9
|
import { ReactAttr } from '../../types/common';
|
|
10
10
|
export interface DropdownSkeletonProps extends ReactAttr<HTMLDivElement> {
|
|
11
11
|
/**
|
|
@@ -11,7 +11,7 @@ import React__default from 'react';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import '../ListBox/index.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
-
import {
|
|
14
|
+
import { ListBoxSizePropType } from '../ListBox/ListBoxPropTypes.js';
|
|
15
15
|
|
|
16
16
|
const DropdownSkeleton = _ref => {
|
|
17
17
|
let {
|
|
@@ -44,7 +44,7 @@ DropdownSkeleton.propTypes = {
|
|
|
44
44
|
/**
|
|
45
45
|
* Specify the size of the ListBox.
|
|
46
46
|
*/
|
|
47
|
-
size:
|
|
47
|
+
size: ListBoxSizePropType
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export { DropdownSkeleton, DropdownSkeleton as default };
|
|
@@ -4,15 +4,15 @@
|
|
|
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
|
-
import React, { ReactNode } from 'react';
|
|
7
|
+
import React, { ReactNode, Ref } from 'react';
|
|
8
8
|
import { UseSelectProps } from 'downshift';
|
|
9
|
-
import { type ListBoxMenuIconTranslationKey, ListBoxSize, ListBoxType } from '../ListBox';
|
|
9
|
+
import { type ListBoxMenuIconTranslationKey, type ListBoxSize, type ListBoxType } from '../ListBox';
|
|
10
10
|
import { TranslateWithId, ReactAttr } from '../../types/common';
|
|
11
11
|
type ExcludedAttributes = 'id' | 'onChange';
|
|
12
12
|
export interface OnChangeData<ItemType> {
|
|
13
13
|
selectedItem: ItemType | null;
|
|
14
14
|
}
|
|
15
|
-
export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes>, TranslateWithId<ListBoxMenuIconTranslationKey
|
|
15
|
+
export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes>, TranslateWithId<ListBoxMenuIconTranslationKey> {
|
|
16
16
|
/**
|
|
17
17
|
* Specify a label to be read by screen readers on the container node
|
|
18
18
|
* 'aria-label' of the ListBox component.
|
|
@@ -147,9 +147,10 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
147
147
|
warnText?: ReactNode;
|
|
148
148
|
}
|
|
149
149
|
export type DropdownTranslationKey = ListBoxMenuIconTranslationKey;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
interface DropdownComponent {
|
|
151
|
+
<ItemType>(props: DropdownProps<ItemType> & {
|
|
152
|
+
ref?: Ref<HTMLButtonElement>;
|
|
153
|
+
}): React.ReactElement<any> | null;
|
|
153
154
|
}
|
|
154
155
|
declare const _default: DropdownComponent;
|
|
155
156
|
export default _default;
|
|
@@ -20,7 +20,7 @@ import { FormContext } from '../FluidForm/FormContext.js';
|
|
|
20
20
|
import { useId } from '../../internal/useId.js';
|
|
21
21
|
import { useFloating, size, flip, hide, autoUpdate } from '@floating-ui/react';
|
|
22
22
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
23
|
-
import {
|
|
23
|
+
import { ListBoxSizePropType, ListBoxTypePropType } from '../ListBox/ListBoxPropTypes.js';
|
|
24
24
|
|
|
25
25
|
const {
|
|
26
26
|
ItemMouseMove,
|
|
@@ -384,6 +384,10 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
384
384
|
}));
|
|
385
385
|
}))), !inline && !invalid && !warn && helper);
|
|
386
386
|
});
|
|
387
|
+
|
|
388
|
+
// Workaround problems with forwardRef() and generics. In the long term, should stop using forwardRef().
|
|
389
|
+
// See https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref.
|
|
390
|
+
|
|
387
391
|
Dropdown.displayName = 'Dropdown';
|
|
388
392
|
Dropdown.propTypes = {
|
|
389
393
|
/**
|
|
@@ -497,7 +501,7 @@ Dropdown.propTypes = {
|
|
|
497
501
|
/**
|
|
498
502
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
499
503
|
*/
|
|
500
|
-
size:
|
|
504
|
+
size: ListBoxSizePropType,
|
|
501
505
|
/**
|
|
502
506
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `Dropdown` component
|
|
503
507
|
*/
|
|
@@ -514,7 +518,7 @@ Dropdown.propTypes = {
|
|
|
514
518
|
/**
|
|
515
519
|
* The dropdown type, `default` or `inline`
|
|
516
520
|
*/
|
|
517
|
-
type:
|
|
521
|
+
type: ListBoxTypePropType,
|
|
518
522
|
/**
|
|
519
523
|
* Specify whether the control is currently in warning state
|
|
520
524
|
*/
|
|
@@ -12,7 +12,7 @@ import React__default, { useState, useRef } from 'react';
|
|
|
12
12
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
13
13
|
import { matches } from '../../internal/keyboard/match.js';
|
|
14
14
|
import { ButtonKinds } from '../../prop-types/types.js';
|
|
15
|
-
import uniqueId from '../../tools/uniqueId.js';
|
|
15
|
+
import { uniqueId } from '../../tools/uniqueId.js';
|
|
16
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
17
|
import deprecate from '../../prop-types/deprecate.js';
|
|
18
18
|
import { noopFn } from '../../internal/noopFn.js';
|
|
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
13
13
|
import { matches } from '../../internal/keyboard/match.js';
|
|
14
|
-
import uniqueId from '../../tools/uniqueId.js';
|
|
14
|
+
import { uniqueId } from '../../tools/uniqueId.js';
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
16
|
import { composeEventHandlers } from '../../tools/events.js';
|
|
17
17
|
import deprecate from '../../prop-types/deprecate.js';
|
|
@@ -12,7 +12,7 @@ import React__default, { useRef, useState, useLayoutEffect } from 'react';
|
|
|
12
12
|
import Filename from './Filename.js';
|
|
13
13
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
14
14
|
import { matches } from '../../internal/keyboard/match.js';
|
|
15
|
-
import uniqueId from '../../tools/uniqueId.js';
|
|
15
|
+
import { uniqueId } from '../../tools/uniqueId.js';
|
|
16
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
17
|
import { noopFn } from '../../internal/noopFn.js';
|
|
18
18
|
import '../Text/index.js';
|
|
@@ -97,5 +97,5 @@ export interface FluidDropdownProps<ItemType> extends DropdownProps<ItemType> {
|
|
|
97
97
|
*/
|
|
98
98
|
warnText?: React.ReactNode;
|
|
99
99
|
}
|
|
100
|
-
declare const FluidDropdown: React.ForwardRefExoticComponent<
|
|
100
|
+
declare const FluidDropdown: React.ForwardRefExoticComponent<FluidDropdownProps<unknown> & React.RefAttributes<HTMLButtonElement>>;
|
|
101
101
|
export default FluidDropdown;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2022
|
|
2
|
+
* Copyright IBM Corp. 2022, 2025
|
|
3
3
|
*
|
|
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
|
-
import React from 'react';
|
|
7
|
+
import React, { type ChangeEvent } from 'react';
|
|
8
8
|
export interface FluidSearchProps {
|
|
9
9
|
/**
|
|
10
10
|
* Specify an optional value for the `autocomplete` property on the underlying
|
|
@@ -38,10 +38,7 @@ export interface FluidSearchProps {
|
|
|
38
38
|
/**
|
|
39
39
|
* Optional callback called when the search value changes.
|
|
40
40
|
*/
|
|
41
|
-
onChange?(
|
|
42
|
-
target: HTMLInputElement;
|
|
43
|
-
type: 'change';
|
|
44
|
-
}): void;
|
|
41
|
+
onChange?(event: ChangeEvent<HTMLInputElement>): void;
|
|
45
42
|
/**
|
|
46
43
|
* Optional callback called when the search value is cleared.
|
|
47
44
|
*/
|
|
@@ -16,21 +16,9 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
16
16
|
import ButtonBase from '../Button/ButtonBase.js';
|
|
17
17
|
import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
|
|
18
18
|
import { BadgeIndicator } from '../BadgeIndicator/index.js';
|
|
19
|
+
import { mapPopoverAlign } from '../../tools/mapPopoverAlign.js';
|
|
19
20
|
|
|
20
21
|
const IconButtonKinds = ['primary', 'secondary', 'ghost', 'tertiary'];
|
|
21
|
-
const propMappingFunction = deprecatedValue => {
|
|
22
|
-
const mapping = {
|
|
23
|
-
'top-left': 'top-start',
|
|
24
|
-
'top-right': 'top-end',
|
|
25
|
-
'bottom-left': 'bottom-start',
|
|
26
|
-
'bottom-right': 'bottom-end',
|
|
27
|
-
'left-bottom': 'left-end',
|
|
28
|
-
'left-top': 'left-start',
|
|
29
|
-
'right-bottom': 'right-end',
|
|
30
|
-
'right-top': 'right-start'
|
|
31
|
-
};
|
|
32
|
-
return mapping[deprecatedValue];
|
|
33
|
-
};
|
|
34
22
|
const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_ref, ref) {
|
|
35
23
|
let {
|
|
36
24
|
align,
|
|
@@ -110,11 +98,7 @@ IconButton.propTypes = {
|
|
|
110
98
|
// deprecated use right-start instead
|
|
111
99
|
|
|
112
100
|
// new values to match floating-ui
|
|
113
|
-
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
|
|
114
|
-
//allowed prop values
|
|
115
|
-
['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
|
|
116
|
-
//optional mapper function
|
|
117
|
-
propMappingFunction),
|
|
101
|
+
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']), ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'], mapPopoverAlign),
|
|
118
102
|
/**
|
|
119
103
|
* **Experimental**: Will attempt to automatically align the tooltip
|
|
120
104
|
*/
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
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
7
|
import React from 'react';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { type ListBoxSize, type ListBoxType } from '.';
|
|
9
|
+
import { ReactAttr } from '../../types/common';
|
|
10
10
|
type ExcludedAttributes = 'onKeyDown' | 'onKeyPress' | 'ref';
|
|
11
11
|
export interface ListBoxProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes> {
|
|
12
12
|
/**
|
|
@@ -59,10 +59,9 @@ export interface ListBoxProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAt
|
|
|
59
59
|
*/
|
|
60
60
|
warnTextId?: string;
|
|
61
61
|
}
|
|
62
|
-
export type ListBoxComponent = ForwardRefReturn<HTMLDivElement, ListBoxProps>;
|
|
63
62
|
/**
|
|
64
63
|
* `ListBox` is a generic container component that handles creating the
|
|
65
64
|
* container class name in response to certain props.
|
|
66
65
|
*/
|
|
67
|
-
declare const ListBox:
|
|
66
|
+
declare const ListBox: React.ForwardRefExoticComponent<ListBoxProps & React.RefAttributes<HTMLDivElement>>;
|
|
68
67
|
export default ListBox;
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
|
-
import React__default, { useContext } from 'react';
|
|
10
|
+
import React__default, { forwardRef, useContext } from 'react';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import deprecate from '../../prop-types/deprecate.js';
|
|
13
|
-
import
|
|
13
|
+
import './index.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import '../FluidForm/FluidForm.js';
|
|
16
16
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
17
|
+
import { ListBoxSizePropType, ListBoxTypePropType } from './ListBoxPropTypes.js';
|
|
17
18
|
|
|
18
19
|
const handleOnKeyDown = event => {
|
|
19
20
|
if (event.keyCode === 27) {
|
|
@@ -28,8 +29,8 @@ const handleClick = event => {
|
|
|
28
29
|
* `ListBox` is a generic container component that handles creating the
|
|
29
30
|
* container class name in response to certain props.
|
|
30
31
|
*/
|
|
31
|
-
const ListBox = /*#__PURE__*/
|
|
32
|
-
|
|
32
|
+
const ListBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
33
|
+
const {
|
|
33
34
|
children,
|
|
34
35
|
className: containerClassName,
|
|
35
36
|
disabled = false,
|
|
@@ -44,7 +45,7 @@ const ListBox = /*#__PURE__*/React__default.forwardRef(function ListBox(_ref, re
|
|
|
44
45
|
light,
|
|
45
46
|
isOpen,
|
|
46
47
|
...rest
|
|
47
|
-
} =
|
|
48
|
+
} = props;
|
|
48
49
|
const prefix = usePrefix();
|
|
49
50
|
const {
|
|
50
51
|
isFluid
|
|
@@ -117,12 +118,12 @@ ListBox.propTypes = {
|
|
|
117
118
|
/**
|
|
118
119
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
119
120
|
*/
|
|
120
|
-
size:
|
|
121
|
+
size: ListBoxSizePropType,
|
|
121
122
|
/**
|
|
122
123
|
* Specify the "type" of the ListBox. Currently supports either `default` or
|
|
123
124
|
* `inline` as an option.
|
|
124
125
|
*/
|
|
125
|
-
type:
|
|
126
|
+
type: ListBoxTypePropType,
|
|
126
127
|
/**
|
|
127
128
|
* Specify whether the control is currently in warning state
|
|
128
129
|
*/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
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
|
-
import
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { ReactAttr } from '../../types/common';
|
|
8
9
|
type ExcludedAttributes = 'id';
|
|
9
10
|
export interface ListBoxMenuProps extends Omit<ReactAttr<HTMLUListElement>, ExcludedAttributes> {
|
|
10
11
|
children?: any;
|
|
@@ -13,11 +14,10 @@ export interface ListBoxMenuProps extends Omit<ReactAttr<HTMLUListElement>, Excl
|
|
|
13
14
|
*/
|
|
14
15
|
id: string;
|
|
15
16
|
}
|
|
16
|
-
export type ListBoxMenuComponent = ForwardRefReturn<HTMLUListElement, ListBoxMenuProps>;
|
|
17
17
|
/**
|
|
18
18
|
* `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
|
|
19
19
|
* class into a single component. It is also being used to validate given
|
|
20
20
|
* `children` components.
|
|
21
21
|
*/
|
|
22
|
-
declare const ListBoxMenu:
|
|
22
|
+
declare const ListBoxMenu: React.ForwardRefExoticComponent<ListBoxMenuProps & React.RefAttributes<HTMLUListElement>>;
|
|
23
23
|
export default ListBoxMenu;
|
|
@@ -6,17 +6,19 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default from 'react';
|
|
9
|
+
import React__default, { forwardRef } from 'react';
|
|
10
10
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import ListBoxMenuItem from './ListBoxMenuItem.js';
|
|
13
13
|
|
|
14
|
+
const frFn = forwardRef;
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
|
|
16
18
|
* class into a single component. It is also being used to validate given
|
|
17
19
|
* `children` components.
|
|
18
20
|
*/
|
|
19
|
-
const ListBoxMenu =
|
|
21
|
+
const ListBoxMenu = frFn((_ref, ref) => {
|
|
20
22
|
let {
|
|
21
23
|
children,
|
|
22
24
|
id,
|