@carbon/react 1.63.1 → 1.63.2
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 +1022 -1092
- package/es/components/ComboBox/ComboBox.d.ts +21 -6
- package/es/components/ComboBox/ComboBox.js +48 -10
- package/es/components/DataTable/TableSelectRow.js +2 -1
- package/es/components/DataTable/TableToolbarSearch.js +2 -2
- package/es/components/DatePicker/DatePicker.js +65 -14
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +11 -0
- package/es/components/Dropdown/Dropdown.d.ts +6 -4
- package/es/components/Dropdown/Dropdown.js +6 -4
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +6 -4
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +6 -4
- package/es/components/MultiSelect/FilterableMultiSelect.js +6 -4
- package/es/components/MultiSelect/MultiSelect.d.ts +6 -4
- package/es/components/MultiSelect/MultiSelect.js +6 -4
- package/lib/components/ComboBox/ComboBox.d.ts +21 -6
- package/lib/components/ComboBox/ComboBox.js +48 -10
- package/lib/components/DataTable/TableSelectRow.js +2 -1
- package/lib/components/DataTable/TableToolbarSearch.js +2 -2
- package/lib/components/DatePicker/DatePicker.js +65 -14
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +11 -0
- package/lib/components/Dropdown/Dropdown.d.ts +6 -4
- package/lib/components/Dropdown/Dropdown.js +6 -4
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +6 -4
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +6 -4
- package/lib/components/MultiSelect/FilterableMultiSelect.js +6 -4
- package/lib/components/MultiSelect/MultiSelect.d.ts +6 -4
- package/lib/components/MultiSelect/MultiSelect.js +6 -4
- package/package.json +2 -2
|
@@ -185,25 +185,42 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
|
|
|
185
185
|
}
|
|
186
186
|
}, []);
|
|
187
187
|
const lastStartValue = React.useRef('');
|
|
188
|
+
const [calendarCloseEvent, setCalendarCloseEvent] = React.useState(null);
|
|
188
189
|
|
|
189
190
|
// fix datepicker deleting the selectedDate when the calendar closes
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
191
|
+
const handleCalendarClose = React.useCallback((selectedDates, dateStr, instance) => {
|
|
192
|
+
if (lastStartValue.current && selectedDates[0] && !startInputField.current.value) {
|
|
193
|
+
startInputField.current.value = lastStartValue.current;
|
|
194
|
+
calendarRef.current.setDate([startInputField.current.value, endInputField?.current?.value], true, calendarRef.current.config.dateFormat);
|
|
195
|
+
}
|
|
196
|
+
if (onClose) {
|
|
197
|
+
onClose(selectedDates, dateStr, instance);
|
|
198
|
+
}
|
|
199
|
+
}, [onClose]);
|
|
200
|
+
const onCalendarClose = (selectedDates, dateStr, instance, e) => {
|
|
201
|
+
if (e && e.type === 'clickOutside') {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
setCalendarCloseEvent({
|
|
205
|
+
selectedDates,
|
|
206
|
+
dateStr,
|
|
207
|
+
instance
|
|
201
208
|
});
|
|
202
209
|
};
|
|
210
|
+
React.useEffect(() => {
|
|
211
|
+
if (calendarCloseEvent) {
|
|
212
|
+
const {
|
|
213
|
+
selectedDates,
|
|
214
|
+
dateStr,
|
|
215
|
+
instance
|
|
216
|
+
} = calendarCloseEvent;
|
|
217
|
+
handleCalendarClose(selectedDates, dateStr, instance);
|
|
218
|
+
setCalendarCloseEvent(null);
|
|
219
|
+
}
|
|
220
|
+
}, [calendarCloseEvent, handleCalendarClose]);
|
|
203
221
|
const endInputField = React.useRef(null);
|
|
204
222
|
const calendarRef = React.useRef(null);
|
|
205
223
|
const savedOnChange = useSavedCallback.useSavedCallback(onChange);
|
|
206
|
-
const savedOnClose = useSavedCallback.useSavedCallback(datePickerType === 'range' ? onCalendarClose : onClose);
|
|
207
224
|
const savedOnOpen = useSavedCallback.useSavedCallback(onOpen);
|
|
208
225
|
const datePickerClasses = cx__default["default"](`${prefix}--date-picker`, {
|
|
209
226
|
[`${prefix}--date-picker--short`]: short,
|
|
@@ -321,6 +338,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
|
|
|
321
338
|
} = endInputField;
|
|
322
339
|
const flatpickerconfig = {
|
|
323
340
|
inline: inline ?? false,
|
|
341
|
+
onClose: onCalendarClose,
|
|
324
342
|
disableMobile: true,
|
|
325
343
|
defaultDate: value,
|
|
326
344
|
closeOnSelect: closeOnSelect,
|
|
@@ -355,7 +373,6 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
|
|
|
355
373
|
savedOnChange(...arguments);
|
|
356
374
|
}
|
|
357
375
|
},
|
|
358
|
-
onClose: savedOnClose,
|
|
359
376
|
onReady: onHook,
|
|
360
377
|
onMonthChange: onHook,
|
|
361
378
|
onYearChange: onHook,
|
|
@@ -452,7 +469,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
|
|
|
452
469
|
}
|
|
453
470
|
};
|
|
454
471
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
455
|
-
}, [savedOnChange,
|
|
472
|
+
}, [savedOnChange, savedOnOpen, readOnly, closeOnSelect, hasInput]);
|
|
456
473
|
|
|
457
474
|
// this hook allows consumers to access the flatpickr calendar
|
|
458
475
|
// instance for cases where functions like open() or close()
|
|
@@ -499,6 +516,40 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
|
|
|
499
516
|
calendarRef.current.set('inline', inline);
|
|
500
517
|
}
|
|
501
518
|
}, [inline]);
|
|
519
|
+
React.useEffect(() => {
|
|
520
|
+
//when value prop is set to empty, this clears the faltpicker's calendar instance and text input
|
|
521
|
+
if (value === '') {
|
|
522
|
+
calendarRef.current?.clear();
|
|
523
|
+
if (startInputField.current) {
|
|
524
|
+
startInputField.current.value = '';
|
|
525
|
+
}
|
|
526
|
+
if (endInputField.current) {
|
|
527
|
+
endInputField.current.value = '';
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}, [value]);
|
|
531
|
+
React.useEffect(() => {
|
|
532
|
+
const handleMouseDown = event => {
|
|
533
|
+
if (calendarRef.current && calendarRef.current.isOpen && !calendarRef.current.calendarContainer.contains(event.target) && !startInputField.current.contains(event.target) && !endInputField.current?.contains(event.target)) {
|
|
534
|
+
// Close the calendar immediately on mousedown
|
|
535
|
+
closeCalendar();
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
const closeCalendar = event => {
|
|
539
|
+
calendarRef.current.close();
|
|
540
|
+
// Remove focus from endDate calendar input
|
|
541
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
542
|
+
document.activeElement.blur();
|
|
543
|
+
}
|
|
544
|
+
onCalendarClose(calendarRef.current.selectedDates, '', calendarRef.current, {
|
|
545
|
+
type: 'clickOutside'
|
|
546
|
+
});
|
|
547
|
+
};
|
|
548
|
+
document.addEventListener('mousedown', handleMouseDown, true);
|
|
549
|
+
return () => {
|
|
550
|
+
document.removeEventListener('mousedown', handleMouseDown, true);
|
|
551
|
+
};
|
|
552
|
+
}, [calendarRef, startInputField, endInputField, onCalendarClose]);
|
|
502
553
|
React.useEffect(() => {
|
|
503
554
|
if (calendarRef?.current?.set) {
|
|
504
555
|
if (value !== undefined) {
|
|
@@ -22,6 +22,15 @@ var carbonFlatpickrFixEventsPlugin = (config => fp => {
|
|
|
22
22
|
inputTo,
|
|
23
23
|
lastStartValue
|
|
24
24
|
} = config;
|
|
25
|
+
/**
|
|
26
|
+
* Handles `click` outside to close calendar
|
|
27
|
+
*/
|
|
28
|
+
const handleClickOutside = event => {
|
|
29
|
+
if (!fp.isOpen || fp.calendarContainer.contains(event.target) || event.target === inputFrom || event.target === inputTo) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
fp.close();
|
|
33
|
+
};
|
|
25
34
|
/**
|
|
26
35
|
* Handles `keydown` event.
|
|
27
36
|
*/
|
|
@@ -115,6 +124,7 @@ var carbonFlatpickrFixEventsPlugin = (config => fp => {
|
|
|
115
124
|
inputTo.removeEventListener('blur', handleBlur, true);
|
|
116
125
|
}
|
|
117
126
|
inputFrom.removeEventListener('keydown', handleKeydown, true);
|
|
127
|
+
document.removeEventListener('click', handleClickOutside, true);
|
|
118
128
|
};
|
|
119
129
|
|
|
120
130
|
/**
|
|
@@ -131,6 +141,7 @@ var carbonFlatpickrFixEventsPlugin = (config => fp => {
|
|
|
131
141
|
inputTo.addEventListener('keydown', handleKeydown, true);
|
|
132
142
|
inputTo.addEventListener('blur', handleBlur, true);
|
|
133
143
|
}
|
|
144
|
+
document.addEventListener('click', handleClickOutside, true);
|
|
134
145
|
};
|
|
135
146
|
|
|
136
147
|
/**
|
|
@@ -36,10 +36,12 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
36
36
|
*/
|
|
37
37
|
disabled?: boolean;
|
|
38
38
|
/**
|
|
39
|
-
* Additional props passed to Downshift.
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
39
|
+
* Additional props passed to Downshift.
|
|
40
|
+
*
|
|
41
|
+
* **Use with caution:** anything you define here overrides the components'
|
|
42
|
+
* internal handling of that prop. Downshift APIs and internals are subject to
|
|
43
|
+
* change, and in some cases they can not be shimmed by Carbon to shield you
|
|
44
|
+
* from potentially breaking changes.
|
|
43
45
|
*/
|
|
44
46
|
downshiftProps?: Partial<UseSelectProps<ItemType>>;
|
|
45
47
|
/**
|
|
@@ -370,10 +370,12 @@ Dropdown.propTypes = {
|
|
|
370
370
|
*/
|
|
371
371
|
disabled: PropTypes__default["default"].bool,
|
|
372
372
|
/**
|
|
373
|
-
* Additional props passed to Downshift.
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
373
|
+
* Additional props passed to Downshift.
|
|
374
|
+
*
|
|
375
|
+
* **Use with caution:** anything you define here overrides the components'
|
|
376
|
+
* internal handling of that prop. Downshift APIs and internals are subject to
|
|
377
|
+
* change, and in some cases they can not be shimmed by Carbon to shield you
|
|
378
|
+
* from potentially breaking changes.
|
|
377
379
|
*/
|
|
378
380
|
downshiftProps: PropTypes__default["default"].object,
|
|
379
381
|
/**
|
|
@@ -75,10 +75,12 @@ FluidMultiSelect.propTypes = {
|
|
|
75
75
|
*/
|
|
76
76
|
disabled: PropTypes__default["default"].bool,
|
|
77
77
|
/**
|
|
78
|
-
* Additional props passed to Downshift.
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
78
|
+
* Additional props passed to Downshift.
|
|
79
|
+
*
|
|
80
|
+
* **Use with caution:** anything you define here overrides the components'
|
|
81
|
+
* internal handling of that prop. Downshift APIs and internals are subject to
|
|
82
|
+
* change, and in some cases they can not be shimmed by Carbon to shield you
|
|
83
|
+
* from potentially breaking changes.
|
|
82
84
|
*/
|
|
83
85
|
downshiftProps: PropTypes__default["default"].object,
|
|
84
86
|
/**
|
|
@@ -48,10 +48,12 @@ export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSorting
|
|
|
48
48
|
*/
|
|
49
49
|
disabled?: boolean;
|
|
50
50
|
/**
|
|
51
|
-
* Additional props passed to Downshift.
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
51
|
+
* Additional props passed to Downshift.
|
|
52
|
+
*
|
|
53
|
+
* **Use with caution:** anything you define here overrides the components'
|
|
54
|
+
* internal handling of that prop. Downshift APIs and internals are subject to
|
|
55
|
+
* change, and in some cases they can not be shimmed by Carbon to shield you
|
|
56
|
+
* from potentially breaking changes.
|
|
55
57
|
*/
|
|
56
58
|
downshiftProps?: UseMultipleSelectionProps<ItemType>;
|
|
57
59
|
/**
|
|
@@ -634,10 +634,12 @@ FilterableMultiSelect.propTypes = {
|
|
|
634
634
|
*/
|
|
635
635
|
disabled: PropTypes__default["default"].bool,
|
|
636
636
|
/**
|
|
637
|
-
* Additional props passed to Downshift.
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
637
|
+
* Additional props passed to Downshift.
|
|
638
|
+
*
|
|
639
|
+
* **Use with caution:** anything you define here overrides the components'
|
|
640
|
+
* internal handling of that prop. Downshift APIs and internals are subject to
|
|
641
|
+
* change, and in some cases they can not be shimmed by Carbon to shield you
|
|
642
|
+
* from potentially breaking changes.
|
|
641
643
|
*/
|
|
642
644
|
// @ts-ignore
|
|
643
645
|
downshiftProps: PropTypes__default["default"].shape(Downshift__default["default"].propTypes),
|
|
@@ -42,10 +42,12 @@ export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<Item
|
|
|
42
42
|
*/
|
|
43
43
|
disabled?: ListBoxProps['disabled'];
|
|
44
44
|
/**
|
|
45
|
-
* Additional props passed to Downshift.
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
45
|
+
* Additional props passed to Downshift.
|
|
46
|
+
*
|
|
47
|
+
* **Use with caution:** anything you define here overrides the components'
|
|
48
|
+
* internal handling of that prop. Downshift APIs and internals are subject to
|
|
49
|
+
* change, and in some cases they can not be shimmed by Carbon to shield you
|
|
50
|
+
* from potentially breaking changes.
|
|
49
51
|
*/
|
|
50
52
|
downshiftProps?: Partial<UseSelectProps<ItemType>>;
|
|
51
53
|
/**
|
|
@@ -529,10 +529,12 @@ MultiSelect.propTypes = {
|
|
|
529
529
|
*/
|
|
530
530
|
disabled: PropTypes__default["default"].bool,
|
|
531
531
|
/**
|
|
532
|
-
* Additional props passed to Downshift.
|
|
533
|
-
*
|
|
534
|
-
*
|
|
535
|
-
*
|
|
532
|
+
* Additional props passed to Downshift.
|
|
533
|
+
*
|
|
534
|
+
* **Use with caution:** anything you define here overrides the components'
|
|
535
|
+
* internal handling of that prop. Downshift APIs and internals are subject to
|
|
536
|
+
* change, and in some cases they can not be shimmed by Carbon to shield you
|
|
537
|
+
* from potentially breaking changes.
|
|
536
538
|
*/
|
|
537
539
|
downshiftProps: PropTypes__default["default"].object,
|
|
538
540
|
/**
|
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.63.
|
|
4
|
+
"version": "1.63.2",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -141,5 +141,5 @@
|
|
|
141
141
|
"**/*.scss",
|
|
142
142
|
"**/*.css"
|
|
143
143
|
],
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "7c34fa18ada2705e92d63a64c3b744a560759fbf"
|
|
145
145
|
}
|