@coreui/react-pro 4.10.0 → 4.11.0-next.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/README.md +1 -1
- package/dist/components/calendar/CCalendar.d.ts +12 -0
- package/dist/components/multi-select/CMultiSelect.d.ts +18 -1
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +1 -0
- package/dist/components/multi-select/types.d.ts +1 -0
- package/dist/components/multi-select/utils.d.ts +5 -0
- package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -1
- package/dist/index.es.js +113 -49
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +113 -49
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/calendar/CCalendar.tsx +79 -44
- package/src/components/calendar/utils.ts +1 -0
- package/src/components/date-range-picker/CDateRangePicker.tsx +4 -0
- package/src/components/multi-select/CMultiSelect.tsx +99 -14
- package/src/components/multi-select/CMultiSelectOptions.tsx +29 -16
- package/src/components/multi-select/types.ts +1 -0
- package/src/components/multi-select/utils.ts +42 -25
- package/src/components/smart-table/CSmartTableInterface.tsx +1 -1
- package/src/components/virtual-scroller/CVirtualScroller.tsx +8 -7
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
|
|
43
43
|
Several quick start options are available:
|
|
44
44
|
|
|
45
|
-
- [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v4.
|
|
45
|
+
- [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v4.11.0-next.0.zip)
|
|
46
46
|
- Clone the repo: `git clone https://github.com/coreui/coreui-react.git`
|
|
47
47
|
- Install with [npm](https://www.npmjs.com/): `npm install @coreui/react`
|
|
48
48
|
- Install with [yarn](https://yarnpkg.com/): `yarn add @coreui/react`
|
|
@@ -80,6 +80,18 @@ export interface CCalendarProps {
|
|
|
80
80
|
* @since 4.3.0
|
|
81
81
|
*/
|
|
82
82
|
navYearFirst?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Set whether days in adjacent months shown before or after the current month are selectable. This only applies if the `showAdjacementDays` option is set to true.
|
|
85
|
+
*
|
|
86
|
+
* @since 4.11.0-next.0
|
|
87
|
+
*/
|
|
88
|
+
selectAdjacementDays?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Set whether to display dates in adjacent months (non-selectable) at the start and end of the current month.
|
|
91
|
+
*
|
|
92
|
+
* @since 4.11.0-next.0
|
|
93
|
+
*/
|
|
94
|
+
showAdjacementDays?: boolean;
|
|
83
95
|
/**
|
|
84
96
|
* Allow range selection.
|
|
85
97
|
*/
|
|
@@ -2,6 +2,12 @@ import React, { HTMLAttributes, ReactNode } from 'react';
|
|
|
2
2
|
import { CFormControlWrapperProps } from './../form/CFormControlWrapper';
|
|
3
3
|
import type { Option } from './types';
|
|
4
4
|
export interface CMultiSelectProps extends Omit<CFormControlWrapperProps, 'floatingClassName' | 'floatingLabel'>, Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
5
|
+
/**
|
|
6
|
+
* Allow users to create options if they are not in the list of options.
|
|
7
|
+
*
|
|
8
|
+
* @since 4.11.0-next.0
|
|
9
|
+
*/
|
|
10
|
+
allowCreateOptions?: boolean;
|
|
5
11
|
/**
|
|
6
12
|
* A string of all className you want applied to the base component.
|
|
7
13
|
*/
|
|
@@ -10,10 +16,22 @@ export interface CMultiSelectProps extends Omit<CFormControlWrapperProps, 'float
|
|
|
10
16
|
* Enables selection cleaner element.
|
|
11
17
|
*/
|
|
12
18
|
cleaner?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Clear current search on selecting an item.
|
|
21
|
+
*
|
|
22
|
+
* @since 4.11.0-next.0
|
|
23
|
+
*/
|
|
24
|
+
clearSearchOnSelect?: boolean;
|
|
13
25
|
/**
|
|
14
26
|
* Toggle the disabled state for the component.
|
|
15
27
|
*/
|
|
16
28
|
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* When set, the options list will have a loading style: loading spinner and reduced opacity.
|
|
31
|
+
*
|
|
32
|
+
* @since 4.11.0-next.0
|
|
33
|
+
*/
|
|
34
|
+
loading?: boolean;
|
|
17
35
|
/**
|
|
18
36
|
* It specifies that multiple options can be selected at once.
|
|
19
37
|
*/
|
|
@@ -83,7 +101,6 @@ export interface CMultiSelectProps extends Omit<CFormControlWrapperProps, 'float
|
|
|
83
101
|
*/
|
|
84
102
|
visible?: boolean;
|
|
85
103
|
/**
|
|
86
|
-
*
|
|
87
104
|
* Amount of visible items when virtualScroller is set to `true`.
|
|
88
105
|
*
|
|
89
106
|
* @since 4.8.0
|
|
@@ -2,6 +2,7 @@ import React, { HTMLAttributes, ReactNode } from 'react';
|
|
|
2
2
|
import type { Option } from './types';
|
|
3
3
|
export interface CMultiSelectOptionsProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
4
|
handleOptionOnClick?: (option: Option) => void;
|
|
5
|
+
loading?: boolean;
|
|
5
6
|
options: Option[];
|
|
6
7
|
optionsMaxHeight?: number | string;
|
|
7
8
|
optionsStyle?: 'checkbox' | 'text';
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { Option, SelectedOption } from './types';
|
|
2
|
+
export declare const createOption: (text: string, options: Option[]) => {
|
|
3
|
+
value: string;
|
|
4
|
+
text: string;
|
|
5
|
+
custom: boolean;
|
|
6
|
+
}[];
|
|
2
7
|
export declare const filterOptionsList: (search: string, _options: Option[]) => Option[];
|
|
3
8
|
export declare const flattenArray: (options: Option[]) => Option[];
|
|
4
9
|
export declare const getNextSibling: (elem: HTMLElement, selector?: string) => Element | null | undefined;
|
|
@@ -106,7 +106,7 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
106
106
|
*/
|
|
107
107
|
itemsPerPageSelect?: boolean | ItemsPerPageSelect;
|
|
108
108
|
/**
|
|
109
|
-
* When set, table will have loading style: loading spinner and reduced opacity.
|
|
109
|
+
* When set, table will have loading style: loading spinner and reduced opacity.
|
|
110
110
|
*/
|
|
111
111
|
loading?: boolean;
|
|
112
112
|
/**
|
package/dist/index.es.js
CHANGED
|
@@ -6921,7 +6921,7 @@ var isToday = function (date) {
|
|
|
6921
6921
|
};
|
|
6922
6922
|
|
|
6923
6923
|
var Calendar = function (props) {
|
|
6924
|
-
var addMonths = props.addMonths, calendarDate = props.calendarDate, dayFormat = props.dayFormat, disabledDates = props.disabledDates, endDate = props.endDate, firstDayOfWeek = props.firstDayOfWeek, hoverDate = props.hoverDate, locale = props.locale, maxDate = props.maxDate, minDate = props.minDate, onCellClick = props.onCellClick, onCellKeyDown = props.onCellKeyDown, onCellMouseEnter = props.onCellMouseEnter, onCellMouseLeave = props.onCellMouseLeave, onMonthClick = props.onMonthClick, onYearClick = props.onYearClick, selectEndDate = props.selectEndDate, startDate = props.startDate, view = props.view, weekdayFormat = props.weekdayFormat;
|
|
6924
|
+
var addMonths = props.addMonths, calendarDate = props.calendarDate, dayFormat = props.dayFormat, disabledDates = props.disabledDates, endDate = props.endDate, firstDayOfWeek = props.firstDayOfWeek, hoverDate = props.hoverDate, locale = props.locale, maxDate = props.maxDate, minDate = props.minDate, onCellClick = props.onCellClick, onCellKeyDown = props.onCellKeyDown, onCellMouseEnter = props.onCellMouseEnter, onCellMouseLeave = props.onCellMouseLeave, onMonthClick = props.onMonthClick, onYearClick = props.onYearClick, selectAdjacementDays = props.selectAdjacementDays, selectEndDate = props.selectEndDate, showAdjacementDays = props.showAdjacementDays, startDate = props.startDate, view = props.view, weekdayFormat = props.weekdayFormat;
|
|
6925
6925
|
var _a = useState(calendarDate), date = _a[0], setDate = _a[1];
|
|
6926
6926
|
var _b = useState([]), listOfMonths = _b[0], setListOfMonths = _b[1];
|
|
6927
6927
|
useEffect(function () {
|
|
@@ -6954,7 +6954,7 @@ var Calendar = function (props) {
|
|
|
6954
6954
|
return (React__default$1.createElement("tr", { key: index }, week.map(function (_a, idx) {
|
|
6955
6955
|
var _b;
|
|
6956
6956
|
var date = _a.date, month = _a.month;
|
|
6957
|
-
return (React__default$1.createElement("td", __assign$1({ className: classNames$1('calendar-cell', (_b = {
|
|
6957
|
+
return month === 'current' || showAdjacementDays ? (React__default$1.createElement("td", __assign$1({ className: classNames$1('calendar-cell', (_b = {
|
|
6958
6958
|
today: month === 'current' && isToday(date),
|
|
6959
6959
|
disabled: isDateDisabled(date, minDate, maxDate, disabledDates)
|
|
6960
6960
|
},
|
|
@@ -6968,19 +6968,20 @@ var Calendar = function (props) {
|
|
|
6968
6968
|
_b.selected = isDateSelected(date, startDate, endDate),
|
|
6969
6969
|
_b.start = isStartDate(date, startDate, endDate),
|
|
6970
6970
|
_b.end = isEndDate(date, startDate, endDate),
|
|
6971
|
-
_b)), key: idx, tabIndex: 0, title: date.toLocaleDateString(locale) }, (month === 'current' && {
|
|
6971
|
+
_b)), key: idx, tabIndex: 0, title: date.toLocaleDateString(locale) }, ((month === 'current' || selectAdjacementDays) && {
|
|
6972
6972
|
onBlur: function () { return onCellMouseLeave(); },
|
|
6973
6973
|
onClick: function () { return onCellClick(date); },
|
|
6974
6974
|
onFocus: function () { return onCellMouseEnter(date); },
|
|
6975
6975
|
onKeyDown: function (event) { return onCellKeyDown(event, date); },
|
|
6976
6976
|
onMouseEnter: function () { return onCellMouseEnter(date); },
|
|
6977
6977
|
onMouseLeave: function () { return onCellMouseLeave(); },
|
|
6978
|
-
}), (month !== 'current' &&
|
|
6978
|
+
}), (month !== 'current' &&
|
|
6979
|
+
!selectAdjacementDays && {
|
|
6979
6980
|
onMouseEnter: function () { return onCellMouseLeave(); },
|
|
6980
6981
|
})),
|
|
6981
6982
|
React__default$1.createElement("div", { className: "calendar-cell-inner" }, typeof dayFormat === 'function'
|
|
6982
6983
|
? dayFormat(date)
|
|
6983
|
-
: date.toLocaleDateString(locale, { day: dayFormat }))));
|
|
6984
|
+
: date.toLocaleDateString(locale, { day: dayFormat })))) : (React__default$1.createElement("td", { key: idx }));
|
|
6984
6985
|
})));
|
|
6985
6986
|
}),
|
|
6986
6987
|
view === 'months' &&
|
|
@@ -7022,9 +7023,9 @@ var Navigation = function (props) {
|
|
|
7022
7023
|
React__default$1.createElement(CButton, { color: "transparent", size: "sm", onClick: function () { return onNavigationClick('next', true); } }, navNextDoubleIcon ? (navNextDoubleIcon) : (React__default$1.createElement("span", { className: "calendar-nav-icon calendar-nav-icon-double-next" })))))));
|
|
7023
7024
|
};
|
|
7024
7025
|
var CCalendar = forwardRef(function (_a, ref) {
|
|
7025
|
-
var startDate = _a.startDate, endDate = _a.endDate, _b = _a.calendarDate, calendarDate = _b === void 0 ? startDate || endDate || null : _b, _c = _a.calendars, calendars = _c === void 0 ? 1 : _c, className = _a.className, _d = _a.dayFormat, dayFormat = _d === void 0 ? 'numeric' : _d, disabledDates = _a.disabledDates, _e = _a.firstDayOfWeek, firstDayOfWeek = _e === void 0 ? 1 : _e, _f = _a.locale, locale = _f === void 0 ? 'default' : _f, maxDate = _a.maxDate, minDate = _a.minDate, _g = _a.navigation, navigation = _g === void 0 ? true : _g, navNextIcon = _a.navNextIcon, navNextDoubleIcon = _a.navNextDoubleIcon, navPrevIcon = _a.navPrevIcon, navPrevDoubleIcon = _a.navPrevDoubleIcon, navYearFirst = _a.navYearFirst, range = _a.range, selectEndDate = _a.selectEndDate,
|
|
7026
|
+
var startDate = _a.startDate, endDate = _a.endDate, _b = _a.calendarDate, calendarDate = _b === void 0 ? startDate || endDate || null : _b, _c = _a.calendars, calendars = _c === void 0 ? 1 : _c, className = _a.className, _d = _a.dayFormat, dayFormat = _d === void 0 ? 'numeric' : _d, disabledDates = _a.disabledDates, _e = _a.firstDayOfWeek, firstDayOfWeek = _e === void 0 ? 1 : _e, _f = _a.locale, locale = _f === void 0 ? 'default' : _f, maxDate = _a.maxDate, minDate = _a.minDate, _g = _a.navigation, navigation = _g === void 0 ? true : _g, navNextIcon = _a.navNextIcon, navNextDoubleIcon = _a.navNextDoubleIcon, navPrevIcon = _a.navPrevIcon, navPrevDoubleIcon = _a.navPrevDoubleIcon, navYearFirst = _a.navYearFirst, range = _a.range, _h = _a.selectAdjacementDays, selectAdjacementDays = _h === void 0 ? false : _h, selectEndDate = _a.selectEndDate, _j = _a.showAdjacementDays, showAdjacementDays = _j === void 0 ? true : _j, _k = _a.weekdayFormat, weekdayFormat = _k === void 0 ? 2 : _k, onCalendarCellHover = _a.onCalendarCellHover, onCalendarDateChange = _a.onCalendarDateChange, onEndDateChange = _a.onEndDateChange, onStartDateChange = _a.onStartDateChange, onSelectEndChange = _a.onSelectEndChange, onViewChanged = _a.onViewChanged;
|
|
7026
7027
|
var isInitialMount = useRef(true);
|
|
7027
|
-
var
|
|
7028
|
+
var _l = useState(null), _calendarDate = _l[0], setCalendarDate = _l[1];
|
|
7028
7029
|
useEffect(function () {
|
|
7029
7030
|
if (calendarDate === null) {
|
|
7030
7031
|
setCalendarDate(new Date());
|
|
@@ -7035,30 +7036,30 @@ var CCalendar = forwardRef(function (_a, ref) {
|
|
|
7035
7036
|
!isSameDateAs(_calendarDate, date) && setCalendarDate(date);
|
|
7036
7037
|
}
|
|
7037
7038
|
}, [calendarDate]);
|
|
7038
|
-
var
|
|
7039
|
+
var _m = useStateWithCallback(startDate ? new Date(startDate) : null, onStartDateChange, !isInitialMount.current), _startDate = _m[0], setStartDate = _m[1];
|
|
7039
7040
|
useEffect(function () {
|
|
7040
7041
|
var date = startDate ? new Date(startDate) : null;
|
|
7041
7042
|
if (!isSameDateAs(date, _startDate)) {
|
|
7042
7043
|
setStartDate(date);
|
|
7043
7044
|
}
|
|
7044
7045
|
}, [startDate]);
|
|
7045
|
-
var
|
|
7046
|
+
var _o = useStateWithCallback(endDate ? new Date(endDate) : null, onEndDateChange, !isInitialMount.current), _endDate = _o[0], setEndDate = _o[1];
|
|
7046
7047
|
useEffect(function () {
|
|
7047
7048
|
var date = endDate ? new Date(endDate) : null;
|
|
7048
7049
|
if (!isSameDateAs(date, _endDate)) {
|
|
7049
7050
|
setEndDate(date);
|
|
7050
7051
|
}
|
|
7051
7052
|
}, [endDate]);
|
|
7052
|
-
var
|
|
7053
|
-
var
|
|
7053
|
+
var _p = useState(null), _hoverDate = _p[0], setHoverDate = _p[1];
|
|
7054
|
+
var _q = useState(maxDate ? new Date(maxDate) : null), _maxDate = _q[0], setMaxDate = _q[1];
|
|
7054
7055
|
useEffect(function () {
|
|
7055
7056
|
maxDate && setMaxDate(new Date(maxDate));
|
|
7056
7057
|
}, [maxDate]);
|
|
7057
|
-
var
|
|
7058
|
+
var _r = useState(minDate ? new Date(minDate) : null), _minDate = _r[0], setMinDate = _r[1];
|
|
7058
7059
|
useEffect(function () {
|
|
7059
7060
|
minDate && setMinDate(new Date(minDate));
|
|
7060
7061
|
}, [minDate]);
|
|
7061
|
-
var
|
|
7062
|
+
var _s = useStateWithCallback(selectEndDate, onSelectEndChange), _selectEndDate = _s[0], setSelectEndDate = _s[1];
|
|
7062
7063
|
useEffect(function () {
|
|
7063
7064
|
setSelectEndDate(selectEndDate);
|
|
7064
7065
|
}, [selectEndDate]);
|
|
@@ -7068,7 +7069,7 @@ var CCalendar = forwardRef(function (_a, ref) {
|
|
|
7068
7069
|
onSelectEndChange &&
|
|
7069
7070
|
onSelectEndChange(_selectEndDate);
|
|
7070
7071
|
}, [_selectEndDate]);
|
|
7071
|
-
var
|
|
7072
|
+
var _t = useStateWithCallback('days', onViewChanged), view = _t[0], setView = _t[1];
|
|
7072
7073
|
useEffect(function () {
|
|
7073
7074
|
isInitialMount.current = false;
|
|
7074
7075
|
}, []);
|
|
@@ -7086,10 +7087,12 @@ var CCalendar = forwardRef(function (_a, ref) {
|
|
|
7086
7087
|
setCalendarDate(d);
|
|
7087
7088
|
onCalendarDateChange && onCalendarDateChange(d);
|
|
7088
7089
|
};
|
|
7089
|
-
var handleCellOnClick = function (date) {
|
|
7090
|
+
var handleCellOnClick = function (date, index) {
|
|
7090
7091
|
if (isDateDisabled(date, _minDate, _maxDate, disabledDates)) {
|
|
7091
7092
|
return;
|
|
7092
7093
|
}
|
|
7094
|
+
var _date = new Date(date);
|
|
7095
|
+
setCalendarDate(index ? new Date(_date.setMonth(_date.getMonth() - index)) : _date);
|
|
7093
7096
|
if (range) {
|
|
7094
7097
|
if (_selectEndDate) {
|
|
7095
7098
|
setSelectEndDate(false);
|
|
@@ -7133,10 +7136,10 @@ var CCalendar = forwardRef(function (_a, ref) {
|
|
|
7133
7136
|
setHoverDate(null);
|
|
7134
7137
|
onCalendarCellHover && onCalendarCellHover(null);
|
|
7135
7138
|
};
|
|
7136
|
-
var handleCellKeyDown = function (event, date) {
|
|
7139
|
+
var handleCellKeyDown = function (event, date, index) {
|
|
7137
7140
|
if (event.code === 'Space' || event.key === 'Enter') {
|
|
7138
7141
|
event.preventDefault();
|
|
7139
|
-
handleCellOnClick && handleCellOnClick(date);
|
|
7142
|
+
handleCellOnClick && handleCellOnClick(date, index);
|
|
7140
7143
|
return;
|
|
7141
7144
|
}
|
|
7142
7145
|
};
|
|
@@ -7170,13 +7173,13 @@ var CCalendar = forwardRef(function (_a, ref) {
|
|
|
7170
7173
|
return (React__default$1.createElement("div", { className: classNames$1('calendars', className) }, _calendarDate &&
|
|
7171
7174
|
Array.from({ length: calendars }, function (_, index) { return (React__default$1.createElement("div", { className: classNames$1('calendar', view), key: index, ref: ref },
|
|
7172
7175
|
React__default$1.createElement(Navigation, { addMonths: index, calendarDate: _calendarDate, locale: locale, navigation: navigation, navNextDoubleIcon: navNextDoubleIcon, navNextIcon: navNextIcon, navPrevDoubleIcon: navPrevDoubleIcon, navPrevIcon: navPrevIcon, navYearFirst: navYearFirst, onMonthClick: function () { return setView('months'); }, onNavigationClick: handleNavigationOnClick, onYearClick: function () { return setView('years'); }, view: view }),
|
|
7173
|
-
React__default$1.createElement(Calendar, { addMonths: index, calendarDate: _calendarDate, dayFormat: dayFormat, disabledDates: disabledDates, endDate: _endDate, firstDayOfWeek: firstDayOfWeek, hoverDate: _hoverDate, locale: locale, maxDate: _maxDate, minDate: _minDate, onCellClick: handleCellOnClick, onCellKeyDown: handleCellKeyDown, onCellMouseEnter: handleCellMouseEnter, onCellMouseLeave: handleCellMouseLeave, onMonthClick: function (month, view) {
|
|
7176
|
+
React__default$1.createElement(Calendar, { addMonths: index, calendarDate: _calendarDate, dayFormat: dayFormat, disabledDates: disabledDates, endDate: _endDate, firstDayOfWeek: firstDayOfWeek, hoverDate: _hoverDate, locale: locale, maxDate: _maxDate, minDate: _minDate, onCellClick: function (date) { return handleCellOnClick(date, index); }, onCellKeyDown: function (event, date) { return handleCellKeyDown(event, date, index); }, onCellMouseEnter: handleCellMouseEnter, onCellMouseLeave: handleCellMouseLeave, onMonthClick: function (month, view) {
|
|
7174
7177
|
setCalendarPage(0, 0, month);
|
|
7175
7178
|
setView(view);
|
|
7176
7179
|
}, onYearClick: function (date, view) {
|
|
7177
7180
|
setCalendarDate(date);
|
|
7178
7181
|
setView(view);
|
|
7179
|
-
}, selectEndDate: _selectEndDate, startDate: _startDate, view: view, weekdayFormat: weekdayFormat }))); })));
|
|
7182
|
+
}, selectEndDate: _selectEndDate, selectAdjacementDays: selectAdjacementDays, showAdjacementDays: showAdjacementDays, startDate: _startDate, view: view, weekdayFormat: weekdayFormat }))); })));
|
|
7180
7183
|
});
|
|
7181
7184
|
CCalendar.propTypes = {
|
|
7182
7185
|
className: propTypesExports.string,
|
|
@@ -7199,7 +7202,9 @@ CCalendar.propTypes = {
|
|
|
7199
7202
|
navPrevDoubleIcon: propTypesExports.node,
|
|
7200
7203
|
navYearFirst: propTypesExports.bool,
|
|
7201
7204
|
range: propTypesExports.bool,
|
|
7205
|
+
selectAdjacementDays: propTypesExports.bool,
|
|
7202
7206
|
selectEndDate: propTypesExports.bool,
|
|
7207
|
+
showAdjacementDays: propTypesExports.bool,
|
|
7203
7208
|
startDate: propTypesExports.oneOfType([propTypesExports.instanceOf(Date), propTypesExports.string]),
|
|
7204
7209
|
weekdayFormat: propTypesExports.oneOfType([
|
|
7205
7210
|
propTypesExports.func,
|
|
@@ -10434,7 +10439,7 @@ var getLocalDateFromString = function (string, locale, time) {
|
|
|
10434
10439
|
|
|
10435
10440
|
var _a, _b, _c, _d, _e, _f;
|
|
10436
10441
|
var CDateRangePicker = forwardRef(function (_a, ref) {
|
|
10437
|
-
var _b = _a.calendars, calendars = _b === void 0 ? 2 : _b, className = _a.className, _c = _a.cleaner, cleaner = _c === void 0 ? true : _c, calendarDate = _a.calendarDate, _d = _a.closeOnSelect, closeOnSelect = _d === void 0 ? true : _d, _e = _a.indicator, indicator = _e === void 0 ? true : _e, dayFormat = _a.dayFormat, disabled = _a.disabled, disabledDates = _a.disabledDates, endDate = _a.endDate, feedback = _a.feedback, feedbackInvalid = _a.feedbackInvalid, feedbackValid = _a.feedbackValid, firstDayOfWeek = _a.firstDayOfWeek, format = _a.format, footer = _a.footer, id = _a.id, inputReadOnly = _a.inputReadOnly, invalid = _a.invalid, label = _a.label, _f = _a.locale, locale = _f === void 0 ? 'default' : _f, maxDate = _a.maxDate, minDate = _a.minDate, navigation = _a.navigation, navYearFirst = _a.navYearFirst, onEndDateChange = _a.onEndDateChange, onHide = _a.onHide, onStartDateChange = _a.onStartDateChange, onShow = _a.onShow, _g = _a.placeholder, placeholder = _g === void 0 ? ['Start date', 'End date'] : _g, _h = _a.range, range = _h === void 0 ? true : _h, ranges = _a.ranges, _j = _a.rangesButtonsColor, rangesButtonsColor = _j === void 0 ? 'secondary' : _j, rangesButtonsSize = _a.rangesButtonsSize, _k = _a.rangesButtonsVariant, rangesButtonsVariant = _k === void 0 ? 'ghost' : _k, required = _a.required, _l = _a.separator, separator = _l === void 0 ? true : _l, size = _a.size, startDate = _a.startDate, text = _a.text, timepicker = _a.timepicker, toggler = _a.toggler, _m = _a.todayButton, todayButton = _m === void 0 ? 'Today' : _m, _o = _a.todayButtonColor, todayButtonColor = _o === void 0 ? 'primary' : _o, _p = _a.todayButtonSize, todayButtonSize = _p === void 0 ? 'sm' : _p, todayButtonVariant = _a.todayButtonVariant, tooltipFeedback = _a.tooltipFeedback, valid = _a.valid, visible = _a.visible, weekdayFormat = _a.weekdayFormat, rest = __rest$1(_a, ["calendars", "className", "cleaner", "calendarDate", "closeOnSelect", "indicator", "dayFormat", "disabled", "disabledDates", "endDate", "feedback", "feedbackInvalid", "feedbackValid", "firstDayOfWeek", "format", "footer", "id", "inputReadOnly", "invalid", "label", "locale", "maxDate", "minDate", "navigation", "navYearFirst", "onEndDateChange", "onHide", "onStartDateChange", "onShow", "placeholder", "range", "ranges", "rangesButtonsColor", "rangesButtonsSize", "rangesButtonsVariant", "required", "separator", "size", "startDate", "text", "timepicker", "toggler", "todayButton", "todayButtonColor", "todayButtonSize", "todayButtonVariant", "tooltipFeedback", "valid", "visible", "weekdayFormat"]);
|
|
10442
|
+
var _b = _a.calendars, calendars = _b === void 0 ? 2 : _b, className = _a.className, _c = _a.cleaner, cleaner = _c === void 0 ? true : _c, calendarDate = _a.calendarDate, _d = _a.closeOnSelect, closeOnSelect = _d === void 0 ? true : _d, _e = _a.indicator, indicator = _e === void 0 ? true : _e, dayFormat = _a.dayFormat, disabled = _a.disabled, disabledDates = _a.disabledDates, endDate = _a.endDate, feedback = _a.feedback, feedbackInvalid = _a.feedbackInvalid, feedbackValid = _a.feedbackValid, firstDayOfWeek = _a.firstDayOfWeek, format = _a.format, footer = _a.footer, id = _a.id, inputReadOnly = _a.inputReadOnly, invalid = _a.invalid, label = _a.label, _f = _a.locale, locale = _f === void 0 ? 'default' : _f, maxDate = _a.maxDate, minDate = _a.minDate, navigation = _a.navigation, navYearFirst = _a.navYearFirst, onEndDateChange = _a.onEndDateChange, onHide = _a.onHide, onStartDateChange = _a.onStartDateChange, onShow = _a.onShow, _g = _a.placeholder, placeholder = _g === void 0 ? ['Start date', 'End date'] : _g, _h = _a.range, range = _h === void 0 ? true : _h, ranges = _a.ranges, _j = _a.rangesButtonsColor, rangesButtonsColor = _j === void 0 ? 'secondary' : _j, rangesButtonsSize = _a.rangesButtonsSize, _k = _a.rangesButtonsVariant, rangesButtonsVariant = _k === void 0 ? 'ghost' : _k, required = _a.required, _l = _a.separator, separator = _l === void 0 ? true : _l, selectAdjacementDays = _a.selectAdjacementDays, showAdjacementDays = _a.showAdjacementDays, size = _a.size, startDate = _a.startDate, text = _a.text, timepicker = _a.timepicker, toggler = _a.toggler, _m = _a.todayButton, todayButton = _m === void 0 ? 'Today' : _m, _o = _a.todayButtonColor, todayButtonColor = _o === void 0 ? 'primary' : _o, _p = _a.todayButtonSize, todayButtonSize = _p === void 0 ? 'sm' : _p, todayButtonVariant = _a.todayButtonVariant, tooltipFeedback = _a.tooltipFeedback, valid = _a.valid, visible = _a.visible, weekdayFormat = _a.weekdayFormat, rest = __rest$1(_a, ["calendars", "className", "cleaner", "calendarDate", "closeOnSelect", "indicator", "dayFormat", "disabled", "disabledDates", "endDate", "feedback", "feedbackInvalid", "feedbackValid", "firstDayOfWeek", "format", "footer", "id", "inputReadOnly", "invalid", "label", "locale", "maxDate", "minDate", "navigation", "navYearFirst", "onEndDateChange", "onHide", "onStartDateChange", "onShow", "placeholder", "range", "ranges", "rangesButtonsColor", "rangesButtonsSize", "rangesButtonsVariant", "required", "separator", "selectAdjacementDays", "showAdjacementDays", "size", "startDate", "text", "timepicker", "toggler", "todayButton", "todayButtonColor", "todayButtonSize", "todayButtonVariant", "tooltipFeedback", "valid", "visible", "weekdayFormat"]);
|
|
10438
10443
|
var _q = useState(visible), _visible = _q[0], setVisible = _q[1];
|
|
10439
10444
|
var inputStartRef = useRef(null);
|
|
10440
10445
|
var inputEndRef = useRef(null);
|
|
@@ -10582,7 +10587,7 @@ var CDateRangePicker = forwardRef(function (_a, ref) {
|
|
|
10582
10587
|
handleStartDateChange(ranges[key][0]);
|
|
10583
10588
|
handleEndDateChange(ranges[key][1]);
|
|
10584
10589
|
}, size: rangesButtonsSize, variant: rangesButtonsVariant }, key)); }))),
|
|
10585
|
-
React__default$1.createElement(CCalendar, { calendarDate: _calendarDate, calendars: isMobile_1 ? 1 : calendars, className: "date-picker-calendars", dayFormat: dayFormat, disabledDates: disabledDates, endDate: _endDate, firstDayOfWeek: firstDayOfWeek, locale: locale, maxDate: _maxDate, minDate: _minDate, navigation: navigation, navYearFirst: navYearFirst, range: range, selectEndDate: selectEndDate, startDate: _startDate, onCalendarCellHover: function (date) { return handleCalendarCellHover(date); }, onCalendarDateChange: function (date) { return handleCalendarDateChange(date); }, onStartDateChange: function (date) { return handleStartDateChange(date); }, onEndDateChange: function (date) { return handleEndDateChange(date); }, onSelectEndChange: function (value) { return setSelectEndDate(value); }, weekdayFormat: weekdayFormat }),
|
|
10590
|
+
React__default$1.createElement(CCalendar, { calendarDate: _calendarDate, calendars: isMobile_1 ? 1 : calendars, className: "date-picker-calendars", dayFormat: dayFormat, disabledDates: disabledDates, endDate: _endDate, firstDayOfWeek: firstDayOfWeek, locale: locale, maxDate: _maxDate, minDate: _minDate, navigation: navigation, navYearFirst: navYearFirst, range: range, selectAdjacementDays: selectAdjacementDays, selectEndDate: selectEndDate, showAdjacementDays: showAdjacementDays, startDate: _startDate, onCalendarCellHover: function (date) { return handleCalendarCellHover(date); }, onCalendarDateChange: function (date) { return handleCalendarDateChange(date); }, onStartDateChange: function (date) { return handleStartDateChange(date); }, onEndDateChange: function (date) { return handleEndDateChange(date); }, onSelectEndChange: function (value) { return setSelectEndDate(value); }, weekdayFormat: weekdayFormat }),
|
|
10586
10591
|
timepicker && (React__default$1.createElement("div", { className: "date-picker-timepickers" }, isMobile_1 || (range && calendars === 1) ? (React__default$1.createElement(React__default$1.Fragment, null,
|
|
10587
10592
|
React__default$1.createElement(CTimePicker, { container: "inline", disabled: _startDate === null ? true : false, locale: locale, onTimeChange: function (_, __, date) { return date && handleStartDateChange(date); }, time: _startDate, variant: "select" }),
|
|
10588
10593
|
React__default$1.createElement(CTimePicker, { container: "inline", disabled: _endDate === null ? true : false, locale: locale, onTimeChange: function (_, __, date) { return date && handleEndDateChange(date); }, time: _endDate, variant: "select" }))) : (__spreadArray([], Array(calendars), true).map(function (_, index) { return (React__default$1.createElement(CTimePicker, { container: "inline", disabled: index === 0
|
|
@@ -11274,15 +11279,15 @@ var CVirtualScroller = forwardRef(function (_a, ref) {
|
|
|
11274
11279
|
setViewportPadding(Number.parseFloat(getComputedStyle(virtualScrollRef.current).paddingTop));
|
|
11275
11280
|
});
|
|
11276
11281
|
useEffect(function () {
|
|
11277
|
-
setItemsNumber(
|
|
11278
|
-
}, [children
|
|
11282
|
+
setItemsNumber(React__default$1.Children.count(children));
|
|
11283
|
+
}, [children]);
|
|
11279
11284
|
useEffect(function () {
|
|
11280
|
-
setViewportHeight(visibleItems * itemHeight + 2 * viewportPadding);
|
|
11281
|
-
}, [viewportPadding, visibleItems
|
|
11285
|
+
setViewportHeight(Math.min(visibleItems, itemsNumber) * itemHeight + 2 * viewportPadding);
|
|
11286
|
+
}, [itemHeight, itemsNumber, viewportPadding, visibleItems]);
|
|
11282
11287
|
useEffect(function () {
|
|
11283
|
-
setMaxHeight(itemsNumber * itemHeight
|
|
11288
|
+
setMaxHeight(itemsNumber * itemHeight);
|
|
11284
11289
|
virtualScrollRef.current && virtualScrollRef.current.scrollTop;
|
|
11285
|
-
}, [
|
|
11290
|
+
}, [itemHeight, itemsNumber]);
|
|
11286
11291
|
useEffect(function () {
|
|
11287
11292
|
setBuffer(Math.floor(visibleItems / 2));
|
|
11288
11293
|
}, [visibleItems]);
|
|
@@ -11294,7 +11299,8 @@ var CVirtualScroller = forwardRef(function (_a, ref) {
|
|
|
11294
11299
|
return (React__default$1.createElement("div", { className: classNames$1('virtual-scroller', className), onScroll: function (event) {
|
|
11295
11300
|
return handleScroll(event.target.scrollTop);
|
|
11296
11301
|
}, ref: forkedRef, style: {
|
|
11297
|
-
height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
|
|
11302
|
+
// height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
|
|
11303
|
+
height: viewportHeight,
|
|
11298
11304
|
overflowY: 'auto',
|
|
11299
11305
|
} },
|
|
11300
11306
|
React__default$1.createElement("div", { className: "virtual-scroller-content", style: {
|
|
@@ -11329,14 +11335,28 @@ CVirtualScroller.propTypes = {
|
|
|
11329
11335
|
};
|
|
11330
11336
|
CVirtualScroller.displayName = 'CVirtualScroller';
|
|
11331
11337
|
|
|
11338
|
+
var createOption = function (text, options) {
|
|
11339
|
+
var value = text.toLowerCase().replace(/\s/g, '-');
|
|
11340
|
+
var uniqueValue = value;
|
|
11341
|
+
var i = 1;
|
|
11342
|
+
while (options.find(function (option) { return String(option.value) === uniqueValue; })) {
|
|
11343
|
+
uniqueValue = "".concat(value, "-").concat(i);
|
|
11344
|
+
i++;
|
|
11345
|
+
}
|
|
11346
|
+
return [
|
|
11347
|
+
{
|
|
11348
|
+
value: uniqueValue,
|
|
11349
|
+
text: text,
|
|
11350
|
+
custom: true,
|
|
11351
|
+
},
|
|
11352
|
+
];
|
|
11353
|
+
};
|
|
11332
11354
|
var filterOptionsList = function (search, _options) {
|
|
11333
11355
|
return search.length > 0
|
|
11334
11356
|
? _options &&
|
|
11335
11357
|
_options.reduce(function (acc, val) {
|
|
11336
11358
|
var options = val.options &&
|
|
11337
|
-
val.options.filter(function (element) {
|
|
11338
|
-
return element.text && element.text.toLowerCase().includes(search.toLowerCase());
|
|
11339
|
-
});
|
|
11359
|
+
val.options.filter(function (element) { return element.text && element.text.toLowerCase().includes(search.toLowerCase()); });
|
|
11340
11360
|
if ((val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
|
|
11341
11361
|
(options && options.length > 0)) {
|
|
11342
11362
|
acc.push(Object.assign({}, val, options && options.length > 0 && { options: options }));
|
|
@@ -11397,7 +11417,7 @@ var selectOptions = function (options, selected, deselected) {
|
|
|
11397
11417
|
};
|
|
11398
11418
|
|
|
11399
11419
|
var CMultiSelectOptions = forwardRef(function (_a, ref) {
|
|
11400
|
-
var handleOptionOnClick = _a.handleOptionOnClick, options = _a.options, optionsMaxHeight = _a.optionsMaxHeight, optionsStyle = _a.optionsStyle, searchNoResultsLabel = _a.searchNoResultsLabel, selected = _a.selected, virtualScroller = _a.virtualScroller, _b = _a.visibleItems, visibleItems = _b === void 0 ? 10 : _b;
|
|
11420
|
+
var handleOptionOnClick = _a.handleOptionOnClick, loading = _a.loading, options = _a.options, optionsMaxHeight = _a.optionsMaxHeight, optionsStyle = _a.optionsStyle, searchNoResultsLabel = _a.searchNoResultsLabel, selected = _a.selected, virtualScroller = _a.virtualScroller, _b = _a.visibleItems, visibleItems = _b === void 0 ? 10 : _b;
|
|
11401
11421
|
var handleKeyDown = function (event, option) {
|
|
11402
11422
|
if (event.code === 'Space' || event.key === 'Enter') {
|
|
11403
11423
|
event.preventDefault();
|
|
@@ -11432,12 +11452,15 @@ var CMultiSelectOptions = forwardRef(function (_a, ref) {
|
|
|
11432
11452
|
}), key: index, onClick: function () { return handleOptionOnClick && handleOptionOnClick(option); }, onKeyDown: function (event) { return handleKeyDown(event, option); }, tabIndex: 0 }, option.text));
|
|
11433
11453
|
})) : (React__default$1.createElement("div", { className: "form-multi-select-options-empty" }, searchNoResultsLabel));
|
|
11434
11454
|
};
|
|
11435
|
-
return
|
|
11436
|
-
|
|
11437
|
-
|
|
11455
|
+
return (React__default$1.createElement(React__default$1.Fragment, null,
|
|
11456
|
+
virtualScroller ? (React__default$1.createElement(CVirtualScroller, { className: "form-multi-select-options", visibleItems: visibleItems, ref: ref }, createOptions(options))) : (React__default$1.createElement("div", __assign$1({ className: "form-multi-select-options" }, (optionsMaxHeight !== 'auto' && {
|
|
11457
|
+
style: { maxHeight: optionsMaxHeight, overflow: 'scroll' },
|
|
11458
|
+
}), { ref: ref }), createOptions(options))),
|
|
11459
|
+
loading && React__default$1.createElement(CElementCover, null)));
|
|
11438
11460
|
});
|
|
11439
11461
|
CMultiSelectOptions.propTypes = {
|
|
11440
11462
|
handleOptionOnClick: propTypesExports.func,
|
|
11463
|
+
loading: propTypesExports.bool,
|
|
11441
11464
|
options: propTypesExports.array.isRequired,
|
|
11442
11465
|
optionsMaxHeight: propTypesExports.oneOfType([propTypesExports.number, propTypesExports.string]),
|
|
11443
11466
|
optionsStyle: propTypesExports.oneOf(['checkbox', 'text']),
|
|
@@ -11480,14 +11503,27 @@ CMultiSelectSelection.displayName = 'CMultiSelectSelection';
|
|
|
11480
11503
|
|
|
11481
11504
|
var CMultiSelect = forwardRef(function (_a, ref) {
|
|
11482
11505
|
var _b;
|
|
11483
|
-
var className = _a.className, _c = _a.cleaner, cleaner = _c === void 0 ? true : _c, disabled = _a.disabled, feedback = _a.feedback, feedbackInvalid = _a.feedbackInvalid, feedbackValid = _a.feedbackValid, _d = _a.multiple, multiple = _d === void 0 ? true : _d, id = _a.id, invalid = _a.invalid, label = _a.label, onChange = _a.onChange, onFilterChange = _a.onFilterChange, options = _a.options, _e = _a.optionsMaxHeight, optionsMaxHeight = _e === void 0 ? 'auto' : _e, _f = _a.optionsStyle, optionsStyle = _f === void 0 ? 'checkbox' : _f, _g = _a.placeholder, placeholder = _g === void 0 ? 'Select...' : _g, _h = _a.search, search = _h === void 0 ? true : _h, _j = _a.searchNoResultsLabel, searchNoResultsLabel = _j === void 0 ? 'No results found' : _j, _k = _a.selectAll, selectAll = _k === void 0 ? true : _k, _l = _a.selectAllLabel, selectAllLabel = _l === void 0 ? 'Select all options' : _l, _m = _a.selectionType, selectionType = _m === void 0 ? 'tags' : _m, _o = _a.selectionTypeCounterText, selectionTypeCounterText = _o === void 0 ? 'item(s) selected' : _o, size = _a.size, text = _a.text, tooltipFeedback = _a.tooltipFeedback, valid = _a.valid, virtualScroller = _a.virtualScroller, _p = _a.visible, visible = _p === void 0 ? false : _p, _q = _a.visibleItems, visibleItems = _q === void 0 ? 10 : _q, rest = __rest$1(_a, ["className", "cleaner", "disabled", "feedback", "feedbackInvalid", "feedbackValid", "multiple", "id", "invalid", "label", "onChange", "onFilterChange", "options", "optionsMaxHeight", "optionsStyle", "placeholder", "search", "searchNoResultsLabel", "selectAll", "selectAllLabel", "selectionType", "selectionTypeCounterText", "size", "text", "tooltipFeedback", "valid", "virtualScroller", "visible", "visibleItems"]);
|
|
11506
|
+
var allowCreateOptions = _a.allowCreateOptions, className = _a.className, _c = _a.cleaner, cleaner = _c === void 0 ? true : _c, clearSearchOnSelect = _a.clearSearchOnSelect, disabled = _a.disabled, feedback = _a.feedback, feedbackInvalid = _a.feedbackInvalid, feedbackValid = _a.feedbackValid, loading = _a.loading, _d = _a.multiple, multiple = _d === void 0 ? true : _d, id = _a.id, invalid = _a.invalid, label = _a.label, onChange = _a.onChange, onFilterChange = _a.onFilterChange, options = _a.options, _e = _a.optionsMaxHeight, optionsMaxHeight = _e === void 0 ? 'auto' : _e, _f = _a.optionsStyle, optionsStyle = _f === void 0 ? 'checkbox' : _f, _g = _a.placeholder, placeholder = _g === void 0 ? 'Select...' : _g, _h = _a.search, search = _h === void 0 ? true : _h, _j = _a.searchNoResultsLabel, searchNoResultsLabel = _j === void 0 ? 'No results found' : _j, _k = _a.selectAll, selectAll = _k === void 0 ? true : _k, _l = _a.selectAllLabel, selectAllLabel = _l === void 0 ? 'Select all options' : _l, _m = _a.selectionType, selectionType = _m === void 0 ? 'tags' : _m, _o = _a.selectionTypeCounterText, selectionTypeCounterText = _o === void 0 ? 'item(s) selected' : _o, size = _a.size, text = _a.text, tooltipFeedback = _a.tooltipFeedback, valid = _a.valid, virtualScroller = _a.virtualScroller, _p = _a.visible, visible = _p === void 0 ? false : _p, _q = _a.visibleItems, visibleItems = _q === void 0 ? 10 : _q, rest = __rest$1(_a, ["allowCreateOptions", "className", "cleaner", "clearSearchOnSelect", "disabled", "feedback", "feedbackInvalid", "feedbackValid", "loading", "multiple", "id", "invalid", "label", "onChange", "onFilterChange", "options", "optionsMaxHeight", "optionsStyle", "placeholder", "search", "searchNoResultsLabel", "selectAll", "selectAllLabel", "selectionType", "selectionTypeCounterText", "size", "text", "tooltipFeedback", "valid", "virtualScroller", "visible", "visibleItems"]);
|
|
11484
11507
|
var isInitialMount = useRef(true);
|
|
11485
11508
|
var nativeSelectRef = useRef(null);
|
|
11486
11509
|
var searchRef = useRef(null);
|
|
11487
11510
|
var _r = useState(options), _options = _r[0], setOptions = _r[1];
|
|
11488
|
-
var _s = useState(
|
|
11489
|
-
var _t = useState(
|
|
11511
|
+
var _s = useState(visible), _visible = _s[0], setVisible = _s[1];
|
|
11512
|
+
var _t = useState(''), searchValue = _t[0], setSearchValue = _t[1];
|
|
11490
11513
|
var _u = useState([]), selected = _u[0], setSelected = _u[1];
|
|
11514
|
+
var _v = useState([]), userOptions = _v[0], setUserOptions = _v[1];
|
|
11515
|
+
var filteredOptions = useMemo(function () {
|
|
11516
|
+
return search === 'external'
|
|
11517
|
+
? __spreadArray(__spreadArray([], _options, true), filterOptionsList(searchValue, userOptions), true) : filterOptionsList(searchValue, __spreadArray(__spreadArray([], _options, true), userOptions, true));
|
|
11518
|
+
}, [_options, searchValue, userOptions]);
|
|
11519
|
+
var userOption = useMemo(function () {
|
|
11520
|
+
if (allowCreateOptions &&
|
|
11521
|
+
filteredOptions.length > 0 &&
|
|
11522
|
+
flattenArray(filteredOptions).filter(function (option) { return option.text.toLowerCase() === searchValue.toLowerCase(); }).length > 0) {
|
|
11523
|
+
return false;
|
|
11524
|
+
}
|
|
11525
|
+
return searchRef.current && createOption(String(searchValue), flattenArray(_options));
|
|
11526
|
+
}, [filteredOptions, searchValue]);
|
|
11491
11527
|
useMemo(function () {
|
|
11492
11528
|
setOptions(options);
|
|
11493
11529
|
var _selected = options &&
|
|
@@ -11506,6 +11542,9 @@ var CMultiSelect = forwardRef(function (_a, ref) {
|
|
|
11506
11542
|
});
|
|
11507
11543
|
_selected && setSelected(selectOptions(_selected, selected, deselected));
|
|
11508
11544
|
}, [JSON.stringify(options)]);
|
|
11545
|
+
useEffect(function () {
|
|
11546
|
+
!isInitialMount.current && onFilterChange && onFilterChange(searchValue);
|
|
11547
|
+
}, [searchValue]);
|
|
11509
11548
|
useEffect(function () {
|
|
11510
11549
|
!isInitialMount.current &&
|
|
11511
11550
|
nativeSelectRef.current &&
|
|
@@ -11515,14 +11554,27 @@ var CMultiSelect = forwardRef(function (_a, ref) {
|
|
|
11515
11554
|
isInitialMount.current = false;
|
|
11516
11555
|
}, []);
|
|
11517
11556
|
var handleSearchChange = function (event) {
|
|
11518
|
-
var
|
|
11519
|
-
|
|
11520
|
-
setSearch(target.value.toLowerCase());
|
|
11521
|
-
}
|
|
11522
|
-
onFilterChange && onFilterChange(target.value);
|
|
11557
|
+
var value = event.target.value;
|
|
11558
|
+
setSearchValue(value);
|
|
11523
11559
|
};
|
|
11524
11560
|
var handleSearchKeyDown = function (event) {
|
|
11525
|
-
if (
|
|
11561
|
+
if (event.key === 'Enter' && searchValue && allowCreateOptions) {
|
|
11562
|
+
if (userOption) {
|
|
11563
|
+
setSelected(__spreadArray(__spreadArray([], selected, true), userOption, true));
|
|
11564
|
+
setUserOptions(__spreadArray(__spreadArray([], userOptions, true), userOption, true));
|
|
11565
|
+
}
|
|
11566
|
+
if (!userOption) {
|
|
11567
|
+
setSelected(__spreadArray(__spreadArray([], selected, true), [
|
|
11568
|
+
flattenArray(filteredOptions).filter(function (option) { return String(option.text).toLowerCase() === searchValue.toLowerCase(); })[0],
|
|
11569
|
+
], false));
|
|
11570
|
+
}
|
|
11571
|
+
setSearchValue('');
|
|
11572
|
+
if (searchRef.current) {
|
|
11573
|
+
searchRef.current.value = '';
|
|
11574
|
+
}
|
|
11575
|
+
return;
|
|
11576
|
+
}
|
|
11577
|
+
if (searchValue.length > 0) {
|
|
11526
11578
|
return;
|
|
11527
11579
|
}
|
|
11528
11580
|
if (event.key === 'Backspace' || event.key === 'Delete') {
|
|
@@ -11534,12 +11586,22 @@ var CMultiSelect = forwardRef(function (_a, ref) {
|
|
|
11534
11586
|
if (!multiple) {
|
|
11535
11587
|
setSelected([{ value: option.value, text: option.text }]);
|
|
11536
11588
|
setVisible(false);
|
|
11537
|
-
|
|
11589
|
+
setSearchValue('');
|
|
11538
11590
|
if (searchRef.current) {
|
|
11539
11591
|
searchRef.current.value = '';
|
|
11540
11592
|
}
|
|
11541
11593
|
return;
|
|
11542
11594
|
}
|
|
11595
|
+
if (option.custom && !userOptions.some(function (_option) { return _option.value === option.value; })) {
|
|
11596
|
+
setUserOptions(__spreadArray(__spreadArray([], userOptions, true), [option], false));
|
|
11597
|
+
}
|
|
11598
|
+
if (clearSearchOnSelect || option.custom) {
|
|
11599
|
+
setSearchValue('');
|
|
11600
|
+
if (searchRef.current) {
|
|
11601
|
+
searchRef.current.value = '';
|
|
11602
|
+
searchRef.current.focus();
|
|
11603
|
+
}
|
|
11604
|
+
}
|
|
11543
11605
|
if (selected.some(function (_option) { return _option.value === option.value; })) {
|
|
11544
11606
|
setSelected(selected.filter(function (_option) { return _option.value !== option.value; }));
|
|
11545
11607
|
}
|
|
@@ -11548,7 +11610,7 @@ var CMultiSelect = forwardRef(function (_a, ref) {
|
|
|
11548
11610
|
}
|
|
11549
11611
|
};
|
|
11550
11612
|
var handleSelectAll = function () {
|
|
11551
|
-
setSelected(selectOptions(flattenArray(options).filter(function (option) { return !option.disabled; }), selected));
|
|
11613
|
+
setSelected(selectOptions(__spreadArray(__spreadArray([], flattenArray(options).filter(function (option) { return !option.disabled; }), true), userOptions, true), selected));
|
|
11552
11614
|
};
|
|
11553
11615
|
var handleDeselectAll = function () {
|
|
11554
11616
|
setSelected(selected.filter(function (option) { return option.disabled; }));
|
|
@@ -11578,12 +11640,14 @@ var CMultiSelect = forwardRef(function (_a, ref) {
|
|
|
11578
11640
|
}), (selected.length > 0 &&
|
|
11579
11641
|
!multiple && { placeholder: selected.map(function (option) { return option.text; })[0] }), (multiple &&
|
|
11580
11642
|
selected.length > 0 &&
|
|
11581
|
-
selectionType !== 'counter' && { size:
|
|
11643
|
+
selectionType !== 'counter' && { size: searchValue.length + 2 }), { ref: searchRef })))), visible: _visible, ref: ref },
|
|
11582
11644
|
React__default$1.createElement(React__default$1.Fragment, null,
|
|
11583
11645
|
multiple && selectAll && (React__default$1.createElement("button", { type: "button", className: "form-multi-select-all", onClick: function () { return handleSelectAll(); } }, selectAllLabel)),
|
|
11584
|
-
React__default$1.createElement(CMultiSelectOptions, { handleOptionOnClick: function (option) { return !disabled && handleOptionOnClick(option); },
|
|
11646
|
+
React__default$1.createElement(CMultiSelectOptions, { handleOptionOnClick: function (option) { return !disabled && handleOptionOnClick(option); }, loading: loading, options: filteredOptions.length === 0 && allowCreateOptions
|
|
11647
|
+
? userOption || []
|
|
11648
|
+
: filteredOptions, optionsMaxHeight: optionsMaxHeight, optionsStyle: optionsStyle, searchNoResultsLabel: searchNoResultsLabel, selected: selected, virtualScroller: virtualScroller, visibleItems: visibleItems })))));
|
|
11585
11649
|
});
|
|
11586
|
-
CMultiSelect.propTypes = __assign$1({ className: propTypesExports.string, cleaner: propTypesExports.bool, disabled: propTypesExports.bool, multiple: propTypesExports.bool, onChange: propTypesExports.func, options: propTypesExports.array.isRequired, optionsMaxHeight: propTypesExports.oneOfType([propTypesExports.number, propTypesExports.string]), optionsStyle: propTypesExports.oneOf(['checkbox', 'text']), placeholder: propTypesExports.string, search: propTypesExports.oneOfType([propTypesExports.bool, propTypesExports.oneOf(['external'])]), searchNoResultsLabel: propTypesExports.oneOfType([propTypesExports.string, propTypesExports.node]), selectAll: propTypesExports.bool, selectAllLabel: propTypesExports.oneOfType([propTypesExports.string, propTypesExports.node]), selectionType: propTypesExports.oneOf(['counter', 'tags', 'text']), selectionTypeCounterText: propTypesExports.string, size: propTypesExports.oneOf(['sm', 'lg']), virtualScroller: propTypesExports.bool, visible: propTypesExports.bool, visibleItems: propTypesExports.number }, CFormControlWrapper.propTypes);
|
|
11650
|
+
CMultiSelect.propTypes = __assign$1({ className: propTypesExports.string, cleaner: propTypesExports.bool, clearSearchOnSelect: propTypesExports.bool, disabled: propTypesExports.bool, loading: propTypesExports.bool, multiple: propTypesExports.bool, onChange: propTypesExports.func, options: propTypesExports.array.isRequired, optionsMaxHeight: propTypesExports.oneOfType([propTypesExports.number, propTypesExports.string]), optionsStyle: propTypesExports.oneOf(['checkbox', 'text']), placeholder: propTypesExports.string, search: propTypesExports.oneOfType([propTypesExports.bool, propTypesExports.oneOf(['external'])]), searchNoResultsLabel: propTypesExports.oneOfType([propTypesExports.string, propTypesExports.node]), selectAll: propTypesExports.bool, selectAllLabel: propTypesExports.oneOfType([propTypesExports.string, propTypesExports.node]), selectionType: propTypesExports.oneOf(['counter', 'tags', 'text']), selectionTypeCounterText: propTypesExports.string, size: propTypesExports.oneOf(['sm', 'lg']), virtualScroller: propTypesExports.bool, visible: propTypesExports.bool, visibleItems: propTypesExports.number }, CFormControlWrapper.propTypes);
|
|
11587
11651
|
CMultiSelect.displayName = 'CMultiSelect';
|
|
11588
11652
|
|
|
11589
11653
|
var CNav = forwardRef(function (_a, ref) {
|