@coreui/react-pro 4.10.0 → 4.11.0-next.1
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 +143 -58
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +143 -58
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/calendar/CCalendar.tsx +130 -59
- 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 +101 -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/dist/index.js
CHANGED
|
@@ -6941,7 +6941,7 @@ var isToday = function (date) {
|
|
|
6941
6941
|
};
|
|
6942
6942
|
|
|
6943
6943
|
var Calendar = function (props) {
|
|
6944
|
-
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;
|
|
6944
|
+
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, onMonthKeyDown = props.onMonthKeyDown, onYearClick = props.onYearClick, onYearKeyDown = props.onYearKeyDown, selectAdjacementDays = props.selectAdjacementDays, selectEndDate = props.selectEndDate, showAdjacementDays = props.showAdjacementDays, startDate = props.startDate, view = props.view, weekdayFormat = props.weekdayFormat;
|
|
6945
6945
|
var _a = React$1.useState(calendarDate), date = _a[0], setDate = _a[1];
|
|
6946
6946
|
var _b = React$1.useState([]), listOfMonths = _b[0], setListOfMonths = _b[1];
|
|
6947
6947
|
React$1.useEffect(function () {
|
|
@@ -6974,11 +6974,12 @@ var Calendar = function (props) {
|
|
|
6974
6974
|
return (React$1.createElement("tr", { key: index }, week.map(function (_a, idx) {
|
|
6975
6975
|
var _b;
|
|
6976
6976
|
var date = _a.date, month = _a.month;
|
|
6977
|
-
return (React$1.createElement("td", __assign$1({ className: classNames$1('calendar-cell', (_b = {
|
|
6977
|
+
return month === 'current' || showAdjacementDays ? (React$1.createElement("td", __assign$1({ className: classNames$1('calendar-cell', (_b = {
|
|
6978
6978
|
today: month === 'current' && isToday(date),
|
|
6979
6979
|
disabled: isDateDisabled(date, minDate, maxDate, disabledDates)
|
|
6980
6980
|
},
|
|
6981
6981
|
_b[month] = true,
|
|
6982
|
+
_b.clickable = month !== 'current' && selectAdjacementDays,
|
|
6982
6983
|
_b.last = isLastDayOfMonth(date),
|
|
6983
6984
|
_b['range-hover'] = month === 'current' &&
|
|
6984
6985
|
(hoverDate && selectEndDate
|
|
@@ -6988,34 +6989,40 @@ var Calendar = function (props) {
|
|
|
6988
6989
|
_b.selected = isDateSelected(date, startDate, endDate),
|
|
6989
6990
|
_b.start = isStartDate(date, startDate, endDate),
|
|
6990
6991
|
_b.end = isEndDate(date, startDate, endDate),
|
|
6991
|
-
_b)), key: idx, tabIndex:
|
|
6992
|
+
_b)), key: idx, tabIndex: (month === 'current' || selectAdjacementDays) &&
|
|
6993
|
+
!isDateDisabled(date, minDate, maxDate, disabledDates)
|
|
6994
|
+
? 0
|
|
6995
|
+
: -1, title: date.toLocaleDateString(locale) }, ((month === 'current' || selectAdjacementDays) && {
|
|
6992
6996
|
onBlur: function () { return onCellMouseLeave(); },
|
|
6993
6997
|
onClick: function () { return onCellClick(date); },
|
|
6994
6998
|
onFocus: function () { return onCellMouseEnter(date); },
|
|
6995
6999
|
onKeyDown: function (event) { return onCellKeyDown(event, date); },
|
|
6996
7000
|
onMouseEnter: function () { return onCellMouseEnter(date); },
|
|
6997
7001
|
onMouseLeave: function () { return onCellMouseLeave(); },
|
|
6998
|
-
}), (month !== 'current' &&
|
|
7002
|
+
}), (month !== 'current' &&
|
|
7003
|
+
!selectAdjacementDays && {
|
|
6999
7004
|
onMouseEnter: function () { return onCellMouseLeave(); },
|
|
7000
7005
|
})),
|
|
7001
7006
|
React$1.createElement("div", { className: "calendar-cell-inner" }, typeof dayFormat === 'function'
|
|
7002
7007
|
? dayFormat(date)
|
|
7003
|
-
: date.toLocaleDateString(locale, { day: dayFormat }))));
|
|
7008
|
+
: date.toLocaleDateString(locale, { day: dayFormat })))) : (React$1.createElement("td", { key: idx }));
|
|
7004
7009
|
})));
|
|
7005
7010
|
}),
|
|
7006
7011
|
view === 'months' &&
|
|
7007
7012
|
listOfMonths.map(function (row, index) {
|
|
7008
7013
|
return (React$1.createElement("tr", { key: index }, row.map(function (month, idx) {
|
|
7009
|
-
return (React$1.createElement("td", {
|
|
7014
|
+
return (React$1.createElement("td", { className: "calendar-cell month", key: idx, onClick: function () { return onMonthClick(index * 3 + idx - addMonths); }, onKeyDown: function (event) { return onMonthKeyDown(event, index * 3 + idx - addMonths); }, tabIndex: 0 },
|
|
7010
7015
|
React$1.createElement("div", { className: "calendar-cell-inner" }, month)));
|
|
7011
7016
|
})));
|
|
7012
7017
|
}),
|
|
7013
7018
|
view === 'years' &&
|
|
7014
7019
|
listOfYears.map(function (row, index) {
|
|
7015
7020
|
return (React$1.createElement("tr", { key: index }, row.map(function (year, idx) {
|
|
7016
|
-
return (React$1.createElement("td", {
|
|
7017
|
-
return onYearClick(new Date(year, date.getMonth() - addMonths, date.getDate())
|
|
7018
|
-
}
|
|
7021
|
+
return (React$1.createElement("td", { className: "calendar-cell year", key: idx, onClick: function () {
|
|
7022
|
+
return onYearClick(new Date(year, date.getMonth() - addMonths, date.getDate()));
|
|
7023
|
+
}, onKeyDown: function (event) {
|
|
7024
|
+
return onYearKeyDown(event, new Date(year, date.getMonth() - addMonths, date.getDate()));
|
|
7025
|
+
}, tabIndex: 0 },
|
|
7019
7026
|
React$1.createElement("div", { className: "calendar-cell-inner" }, new Date(year, 0, 1).toLocaleDateString(locale, { year: 'numeric' }))));
|
|
7020
7027
|
})));
|
|
7021
7028
|
}))));
|
|
@@ -7042,9 +7049,9 @@ var Navigation = function (props) {
|
|
|
7042
7049
|
React$1.createElement(CButton, { color: "transparent", size: "sm", onClick: function () { return onNavigationClick('next', true); } }, navNextDoubleIcon ? (navNextDoubleIcon) : (React$1.createElement("span", { className: "calendar-nav-icon calendar-nav-icon-double-next" })))))));
|
|
7043
7050
|
};
|
|
7044
7051
|
var CCalendar = React$1.forwardRef(function (_a, ref) {
|
|
7045
|
-
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,
|
|
7052
|
+
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;
|
|
7046
7053
|
var isInitialMount = React$1.useRef(true);
|
|
7047
|
-
var
|
|
7054
|
+
var _l = React$1.useState(null), _calendarDate = _l[0], setCalendarDate = _l[1];
|
|
7048
7055
|
React$1.useEffect(function () {
|
|
7049
7056
|
if (calendarDate === null) {
|
|
7050
7057
|
setCalendarDate(new Date());
|
|
@@ -7055,30 +7062,30 @@ var CCalendar = React$1.forwardRef(function (_a, ref) {
|
|
|
7055
7062
|
!isSameDateAs(_calendarDate, date) && setCalendarDate(date);
|
|
7056
7063
|
}
|
|
7057
7064
|
}, [calendarDate]);
|
|
7058
|
-
var
|
|
7065
|
+
var _m = useStateWithCallback(startDate ? new Date(startDate) : null, onStartDateChange, !isInitialMount.current), _startDate = _m[0], setStartDate = _m[1];
|
|
7059
7066
|
React$1.useEffect(function () {
|
|
7060
7067
|
var date = startDate ? new Date(startDate) : null;
|
|
7061
7068
|
if (!isSameDateAs(date, _startDate)) {
|
|
7062
7069
|
setStartDate(date);
|
|
7063
7070
|
}
|
|
7064
7071
|
}, [startDate]);
|
|
7065
|
-
var
|
|
7072
|
+
var _o = useStateWithCallback(endDate ? new Date(endDate) : null, onEndDateChange, !isInitialMount.current), _endDate = _o[0], setEndDate = _o[1];
|
|
7066
7073
|
React$1.useEffect(function () {
|
|
7067
7074
|
var date = endDate ? new Date(endDate) : null;
|
|
7068
7075
|
if (!isSameDateAs(date, _endDate)) {
|
|
7069
7076
|
setEndDate(date);
|
|
7070
7077
|
}
|
|
7071
7078
|
}, [endDate]);
|
|
7072
|
-
var
|
|
7073
|
-
var
|
|
7079
|
+
var _p = React$1.useState(null), _hoverDate = _p[0], setHoverDate = _p[1];
|
|
7080
|
+
var _q = React$1.useState(maxDate ? new Date(maxDate) : null), _maxDate = _q[0], setMaxDate = _q[1];
|
|
7074
7081
|
React$1.useEffect(function () {
|
|
7075
7082
|
maxDate && setMaxDate(new Date(maxDate));
|
|
7076
7083
|
}, [maxDate]);
|
|
7077
|
-
var
|
|
7084
|
+
var _r = React$1.useState(minDate ? new Date(minDate) : null), _minDate = _r[0], setMinDate = _r[1];
|
|
7078
7085
|
React$1.useEffect(function () {
|
|
7079
7086
|
minDate && setMinDate(new Date(minDate));
|
|
7080
7087
|
}, [minDate]);
|
|
7081
|
-
var
|
|
7088
|
+
var _s = useStateWithCallback(selectEndDate, onSelectEndChange), _selectEndDate = _s[0], setSelectEndDate = _s[1];
|
|
7082
7089
|
React$1.useEffect(function () {
|
|
7083
7090
|
setSelectEndDate(selectEndDate);
|
|
7084
7091
|
}, [selectEndDate]);
|
|
@@ -7088,7 +7095,7 @@ var CCalendar = React$1.forwardRef(function (_a, ref) {
|
|
|
7088
7095
|
onSelectEndChange &&
|
|
7089
7096
|
onSelectEndChange(_selectEndDate);
|
|
7090
7097
|
}, [_selectEndDate]);
|
|
7091
|
-
var
|
|
7098
|
+
var _t = useStateWithCallback('days', onViewChanged), view = _t[0], setView = _t[1];
|
|
7092
7099
|
React$1.useEffect(function () {
|
|
7093
7100
|
isInitialMount.current = false;
|
|
7094
7101
|
}, []);
|
|
@@ -7106,10 +7113,12 @@ var CCalendar = React$1.forwardRef(function (_a, ref) {
|
|
|
7106
7113
|
setCalendarDate(d);
|
|
7107
7114
|
onCalendarDateChange && onCalendarDateChange(d);
|
|
7108
7115
|
};
|
|
7109
|
-
var handleCellOnClick = function (date) {
|
|
7116
|
+
var handleCellOnClick = function (date, index) {
|
|
7110
7117
|
if (isDateDisabled(date, _minDate, _maxDate, disabledDates)) {
|
|
7111
7118
|
return;
|
|
7112
7119
|
}
|
|
7120
|
+
var _date = new Date(date);
|
|
7121
|
+
setCalendarDate(index ? new Date(_date.setMonth(_date.getMonth() - index)) : _date);
|
|
7113
7122
|
if (range) {
|
|
7114
7123
|
if (_selectEndDate) {
|
|
7115
7124
|
setSelectEndDate(false);
|
|
@@ -7153,13 +7162,23 @@ var CCalendar = React$1.forwardRef(function (_a, ref) {
|
|
|
7153
7162
|
setHoverDate(null);
|
|
7154
7163
|
onCalendarCellHover && onCalendarCellHover(null);
|
|
7155
7164
|
};
|
|
7156
|
-
var handleCellKeyDown = function (event, date) {
|
|
7165
|
+
var handleCellKeyDown = function (event, date, index) {
|
|
7157
7166
|
if (event.code === 'Space' || event.key === 'Enter') {
|
|
7158
7167
|
event.preventDefault();
|
|
7159
|
-
handleCellOnClick && handleCellOnClick(date);
|
|
7168
|
+
handleCellOnClick && handleCellOnClick(date, index);
|
|
7160
7169
|
return;
|
|
7161
7170
|
}
|
|
7162
7171
|
};
|
|
7172
|
+
var handleMonthClick = function (month) {
|
|
7173
|
+
setCalendarPage(0, 0, month);
|
|
7174
|
+
setView('days');
|
|
7175
|
+
};
|
|
7176
|
+
var handleMonthKeyDown = function (event, month) {
|
|
7177
|
+
if (event.code === 'Space' || event.key === 'Enter') {
|
|
7178
|
+
setCalendarPage(0, 0, month);
|
|
7179
|
+
setView('days');
|
|
7180
|
+
}
|
|
7181
|
+
};
|
|
7163
7182
|
var handleNavigationOnClick = function (direction, double) {
|
|
7164
7183
|
if (double === void 0) { double = false; }
|
|
7165
7184
|
if (direction === 'prev') {
|
|
@@ -7187,16 +7206,20 @@ var CCalendar = React$1.forwardRef(function (_a, ref) {
|
|
|
7187
7206
|
return;
|
|
7188
7207
|
}
|
|
7189
7208
|
};
|
|
7209
|
+
var handleYearClick = function (date) {
|
|
7210
|
+
setCalendarDate(date);
|
|
7211
|
+
setView('months');
|
|
7212
|
+
};
|
|
7213
|
+
var handleYearKeyDown = function (event, date) {
|
|
7214
|
+
if (event.code === 'Space' || event.key === 'Enter') {
|
|
7215
|
+
setCalendarDate(date);
|
|
7216
|
+
setView('months');
|
|
7217
|
+
}
|
|
7218
|
+
};
|
|
7190
7219
|
return (React$1.createElement("div", { className: classNames$1('calendars', className) }, _calendarDate &&
|
|
7191
7220
|
Array.from({ length: calendars }, function (_, index) { return (React$1.createElement("div", { className: classNames$1('calendar', view), key: index, ref: ref },
|
|
7192
7221
|
React$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 }),
|
|
7193
|
-
React$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:
|
|
7194
|
-
setCalendarPage(0, 0, month);
|
|
7195
|
-
setView(view);
|
|
7196
|
-
}, onYearClick: function (date, view) {
|
|
7197
|
-
setCalendarDate(date);
|
|
7198
|
-
setView(view);
|
|
7199
|
-
}, selectEndDate: _selectEndDate, startDate: _startDate, view: view, weekdayFormat: weekdayFormat }))); })));
|
|
7222
|
+
React$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: handleMonthClick, onMonthKeyDown: handleMonthKeyDown, onYearClick: handleYearClick, onYearKeyDown: handleYearKeyDown, selectEndDate: _selectEndDate, selectAdjacementDays: selectAdjacementDays, showAdjacementDays: showAdjacementDays, startDate: _startDate, view: view, weekdayFormat: weekdayFormat }))); })));
|
|
7200
7223
|
});
|
|
7201
7224
|
CCalendar.propTypes = {
|
|
7202
7225
|
className: propTypesExports.string,
|
|
@@ -7219,7 +7242,9 @@ CCalendar.propTypes = {
|
|
|
7219
7242
|
navPrevDoubleIcon: propTypesExports.node,
|
|
7220
7243
|
navYearFirst: propTypesExports.bool,
|
|
7221
7244
|
range: propTypesExports.bool,
|
|
7245
|
+
selectAdjacementDays: propTypesExports.bool,
|
|
7222
7246
|
selectEndDate: propTypesExports.bool,
|
|
7247
|
+
showAdjacementDays: propTypesExports.bool,
|
|
7223
7248
|
startDate: propTypesExports.oneOfType([propTypesExports.instanceOf(Date), propTypesExports.string]),
|
|
7224
7249
|
weekdayFormat: propTypesExports.oneOfType([
|
|
7225
7250
|
propTypesExports.func,
|
|
@@ -10454,7 +10479,7 @@ var getLocalDateFromString = function (string, locale, time) {
|
|
|
10454
10479
|
|
|
10455
10480
|
var _a, _b, _c, _d, _e, _f;
|
|
10456
10481
|
var CDateRangePicker = React$1.forwardRef(function (_a, ref) {
|
|
10457
|
-
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"]);
|
|
10482
|
+
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"]);
|
|
10458
10483
|
var _q = React$1.useState(visible), _visible = _q[0], setVisible = _q[1];
|
|
10459
10484
|
var inputStartRef = React$1.useRef(null);
|
|
10460
10485
|
var inputEndRef = React$1.useRef(null);
|
|
@@ -10602,7 +10627,7 @@ var CDateRangePicker = React$1.forwardRef(function (_a, ref) {
|
|
|
10602
10627
|
handleStartDateChange(ranges[key][0]);
|
|
10603
10628
|
handleEndDateChange(ranges[key][1]);
|
|
10604
10629
|
}, size: rangesButtonsSize, variant: rangesButtonsVariant }, key)); }))),
|
|
10605
|
-
React$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 }),
|
|
10630
|
+
React$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 }),
|
|
10606
10631
|
timepicker && (React$1.createElement("div", { className: "date-picker-timepickers" }, isMobile_1 || (range && calendars === 1) ? (React$1.createElement(React$1.Fragment, null,
|
|
10607
10632
|
React$1.createElement(CTimePicker, { container: "inline", disabled: _startDate === null ? true : false, locale: locale, onTimeChange: function (_, __, date) { return date && handleStartDateChange(date); }, time: _startDate, variant: "select" }),
|
|
10608
10633
|
React$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$1.createElement(CTimePicker, { container: "inline", disabled: index === 0
|
|
@@ -11294,15 +11319,15 @@ var CVirtualScroller = React$1.forwardRef(function (_a, ref) {
|
|
|
11294
11319
|
setViewportPadding(Number.parseFloat(getComputedStyle(virtualScrollRef.current).paddingTop));
|
|
11295
11320
|
});
|
|
11296
11321
|
React$1.useEffect(function () {
|
|
11297
|
-
setItemsNumber(
|
|
11298
|
-
}, [children
|
|
11322
|
+
setItemsNumber(React$1.Children.count(children));
|
|
11323
|
+
}, [children]);
|
|
11299
11324
|
React$1.useEffect(function () {
|
|
11300
|
-
setViewportHeight(visibleItems * itemHeight + 2 * viewportPadding);
|
|
11301
|
-
}, [viewportPadding, visibleItems
|
|
11325
|
+
setViewportHeight(Math.min(visibleItems, itemsNumber) * itemHeight + 2 * viewportPadding);
|
|
11326
|
+
}, [itemHeight, itemsNumber, viewportPadding, visibleItems]);
|
|
11302
11327
|
React$1.useEffect(function () {
|
|
11303
|
-
setMaxHeight(itemsNumber * itemHeight
|
|
11328
|
+
setMaxHeight(itemsNumber * itemHeight);
|
|
11304
11329
|
virtualScrollRef.current && virtualScrollRef.current.scrollTop;
|
|
11305
|
-
}, [
|
|
11330
|
+
}, [itemHeight, itemsNumber]);
|
|
11306
11331
|
React$1.useEffect(function () {
|
|
11307
11332
|
setBuffer(Math.floor(visibleItems / 2));
|
|
11308
11333
|
}, [visibleItems]);
|
|
@@ -11314,7 +11339,8 @@ var CVirtualScroller = React$1.forwardRef(function (_a, ref) {
|
|
|
11314
11339
|
return (React$1.createElement("div", { className: classNames$1('virtual-scroller', className), onScroll: function (event) {
|
|
11315
11340
|
return handleScroll(event.target.scrollTop);
|
|
11316
11341
|
}, ref: forkedRef, style: {
|
|
11317
|
-
height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
|
|
11342
|
+
// height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
|
|
11343
|
+
height: viewportHeight,
|
|
11318
11344
|
overflowY: 'auto',
|
|
11319
11345
|
} },
|
|
11320
11346
|
React$1.createElement("div", { className: "virtual-scroller-content", style: {
|
|
@@ -11349,14 +11375,28 @@ CVirtualScroller.propTypes = {
|
|
|
11349
11375
|
};
|
|
11350
11376
|
CVirtualScroller.displayName = 'CVirtualScroller';
|
|
11351
11377
|
|
|
11378
|
+
var createOption = function (text, options) {
|
|
11379
|
+
var value = text.toLowerCase().replace(/\s/g, '-');
|
|
11380
|
+
var uniqueValue = value;
|
|
11381
|
+
var i = 1;
|
|
11382
|
+
while (options.find(function (option) { return String(option.value) === uniqueValue; })) {
|
|
11383
|
+
uniqueValue = "".concat(value, "-").concat(i);
|
|
11384
|
+
i++;
|
|
11385
|
+
}
|
|
11386
|
+
return [
|
|
11387
|
+
{
|
|
11388
|
+
value: uniqueValue,
|
|
11389
|
+
text: text,
|
|
11390
|
+
custom: true,
|
|
11391
|
+
},
|
|
11392
|
+
];
|
|
11393
|
+
};
|
|
11352
11394
|
var filterOptionsList = function (search, _options) {
|
|
11353
11395
|
return search.length > 0
|
|
11354
11396
|
? _options &&
|
|
11355
11397
|
_options.reduce(function (acc, val) {
|
|
11356
11398
|
var options = val.options &&
|
|
11357
|
-
val.options.filter(function (element) {
|
|
11358
|
-
return element.text && element.text.toLowerCase().includes(search.toLowerCase());
|
|
11359
|
-
});
|
|
11399
|
+
val.options.filter(function (element) { return element.text && element.text.toLowerCase().includes(search.toLowerCase()); });
|
|
11360
11400
|
if ((val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
|
|
11361
11401
|
(options && options.length > 0)) {
|
|
11362
11402
|
acc.push(Object.assign({}, val, options && options.length > 0 && { options: options }));
|
|
@@ -11417,7 +11457,7 @@ var selectOptions = function (options, selected, deselected) {
|
|
|
11417
11457
|
};
|
|
11418
11458
|
|
|
11419
11459
|
var CMultiSelectOptions = React$1.forwardRef(function (_a, ref) {
|
|
11420
|
-
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;
|
|
11460
|
+
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;
|
|
11421
11461
|
var handleKeyDown = function (event, option) {
|
|
11422
11462
|
if (event.code === 'Space' || event.key === 'Enter') {
|
|
11423
11463
|
event.preventDefault();
|
|
@@ -11452,12 +11492,15 @@ var CMultiSelectOptions = React$1.forwardRef(function (_a, ref) {
|
|
|
11452
11492
|
}), key: index, onClick: function () { return handleOptionOnClick && handleOptionOnClick(option); }, onKeyDown: function (event) { return handleKeyDown(event, option); }, tabIndex: 0 }, option.text));
|
|
11453
11493
|
})) : (React$1.createElement("div", { className: "form-multi-select-options-empty" }, searchNoResultsLabel));
|
|
11454
11494
|
};
|
|
11455
|
-
return
|
|
11456
|
-
|
|
11457
|
-
|
|
11495
|
+
return (React$1.createElement(React$1.Fragment, null,
|
|
11496
|
+
virtualScroller ? (React$1.createElement(CVirtualScroller, { className: "form-multi-select-options", visibleItems: visibleItems, ref: ref }, createOptions(options))) : (React$1.createElement("div", __assign$1({ className: "form-multi-select-options" }, (optionsMaxHeight !== 'auto' && {
|
|
11497
|
+
style: { maxHeight: optionsMaxHeight, overflow: 'scroll' },
|
|
11498
|
+
}), { ref: ref }), createOptions(options))),
|
|
11499
|
+
loading && React$1.createElement(CElementCover, null)));
|
|
11458
11500
|
});
|
|
11459
11501
|
CMultiSelectOptions.propTypes = {
|
|
11460
11502
|
handleOptionOnClick: propTypesExports.func,
|
|
11503
|
+
loading: propTypesExports.bool,
|
|
11461
11504
|
options: propTypesExports.array.isRequired,
|
|
11462
11505
|
optionsMaxHeight: propTypesExports.oneOfType([propTypesExports.number, propTypesExports.string]),
|
|
11463
11506
|
optionsStyle: propTypesExports.oneOf(['checkbox', 'text']),
|
|
@@ -11500,14 +11543,27 @@ CMultiSelectSelection.displayName = 'CMultiSelectSelection';
|
|
|
11500
11543
|
|
|
11501
11544
|
var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
11502
11545
|
var _b;
|
|
11503
|
-
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"]);
|
|
11546
|
+
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"]);
|
|
11504
11547
|
var isInitialMount = React$1.useRef(true);
|
|
11505
11548
|
var nativeSelectRef = React$1.useRef(null);
|
|
11506
11549
|
var searchRef = React$1.useRef(null);
|
|
11507
11550
|
var _r = React$1.useState(options), _options = _r[0], setOptions = _r[1];
|
|
11508
|
-
var _s = React$1.useState(
|
|
11509
|
-
var _t = React$1.useState(
|
|
11551
|
+
var _s = React$1.useState(visible), _visible = _s[0], setVisible = _s[1];
|
|
11552
|
+
var _t = React$1.useState(''), searchValue = _t[0], setSearchValue = _t[1];
|
|
11510
11553
|
var _u = React$1.useState([]), selected = _u[0], setSelected = _u[1];
|
|
11554
|
+
var _v = React$1.useState([]), userOptions = _v[0], setUserOptions = _v[1];
|
|
11555
|
+
var filteredOptions = React$1.useMemo(function () {
|
|
11556
|
+
return search === 'external'
|
|
11557
|
+
? __spreadArray(__spreadArray([], _options, true), filterOptionsList(searchValue, userOptions), true) : filterOptionsList(searchValue, __spreadArray(__spreadArray([], _options, true), userOptions, true));
|
|
11558
|
+
}, [_options, searchValue, userOptions]);
|
|
11559
|
+
var userOption = React$1.useMemo(function () {
|
|
11560
|
+
if (allowCreateOptions &&
|
|
11561
|
+
filteredOptions.length > 0 &&
|
|
11562
|
+
flattenArray(filteredOptions).filter(function (option) { return option.text.toLowerCase() === searchValue.toLowerCase(); }).length > 0) {
|
|
11563
|
+
return false;
|
|
11564
|
+
}
|
|
11565
|
+
return searchRef.current && createOption(String(searchValue), flattenArray(_options));
|
|
11566
|
+
}, [filteredOptions, searchValue]);
|
|
11511
11567
|
React$1.useMemo(function () {
|
|
11512
11568
|
setOptions(options);
|
|
11513
11569
|
var _selected = options &&
|
|
@@ -11526,6 +11582,9 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
|
11526
11582
|
});
|
|
11527
11583
|
_selected && setSelected(selectOptions(_selected, selected, deselected));
|
|
11528
11584
|
}, [JSON.stringify(options)]);
|
|
11585
|
+
React$1.useEffect(function () {
|
|
11586
|
+
!isInitialMount.current && onFilterChange && onFilterChange(searchValue);
|
|
11587
|
+
}, [searchValue]);
|
|
11529
11588
|
React$1.useEffect(function () {
|
|
11530
11589
|
!isInitialMount.current &&
|
|
11531
11590
|
nativeSelectRef.current &&
|
|
@@ -11535,14 +11594,28 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
|
11535
11594
|
isInitialMount.current = false;
|
|
11536
11595
|
}, []);
|
|
11537
11596
|
var handleSearchChange = function (event) {
|
|
11538
|
-
var
|
|
11539
|
-
|
|
11540
|
-
setSearch(target.value.toLowerCase());
|
|
11541
|
-
}
|
|
11542
|
-
onFilterChange && onFilterChange(target.value);
|
|
11597
|
+
var value = event.target.value;
|
|
11598
|
+
setSearchValue(value);
|
|
11543
11599
|
};
|
|
11544
11600
|
var handleSearchKeyDown = function (event) {
|
|
11545
|
-
if (
|
|
11601
|
+
if (event.key === 'Enter' && searchValue && allowCreateOptions) {
|
|
11602
|
+
event.preventDefault();
|
|
11603
|
+
if (userOption) {
|
|
11604
|
+
setSelected(__spreadArray(__spreadArray([], selected, true), userOption, true));
|
|
11605
|
+
setUserOptions(__spreadArray(__spreadArray([], userOptions, true), userOption, true));
|
|
11606
|
+
}
|
|
11607
|
+
if (!userOption) {
|
|
11608
|
+
setSelected(__spreadArray(__spreadArray([], selected, true), [
|
|
11609
|
+
flattenArray(filteredOptions).filter(function (option) { return String(option.text).toLowerCase() === searchValue.toLowerCase(); })[0],
|
|
11610
|
+
], false));
|
|
11611
|
+
}
|
|
11612
|
+
setSearchValue('');
|
|
11613
|
+
if (searchRef.current) {
|
|
11614
|
+
searchRef.current.value = '';
|
|
11615
|
+
}
|
|
11616
|
+
return;
|
|
11617
|
+
}
|
|
11618
|
+
if (searchValue.length > 0) {
|
|
11546
11619
|
return;
|
|
11547
11620
|
}
|
|
11548
11621
|
if (event.key === 'Backspace' || event.key === 'Delete') {
|
|
@@ -11554,12 +11627,22 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
|
11554
11627
|
if (!multiple) {
|
|
11555
11628
|
setSelected([{ value: option.value, text: option.text }]);
|
|
11556
11629
|
setVisible(false);
|
|
11557
|
-
|
|
11630
|
+
setSearchValue('');
|
|
11558
11631
|
if (searchRef.current) {
|
|
11559
11632
|
searchRef.current.value = '';
|
|
11560
11633
|
}
|
|
11561
11634
|
return;
|
|
11562
11635
|
}
|
|
11636
|
+
if (option.custom && !userOptions.some(function (_option) { return _option.value === option.value; })) {
|
|
11637
|
+
setUserOptions(__spreadArray(__spreadArray([], userOptions, true), [option], false));
|
|
11638
|
+
}
|
|
11639
|
+
if (clearSearchOnSelect || option.custom) {
|
|
11640
|
+
setSearchValue('');
|
|
11641
|
+
if (searchRef.current) {
|
|
11642
|
+
searchRef.current.value = '';
|
|
11643
|
+
searchRef.current.focus();
|
|
11644
|
+
}
|
|
11645
|
+
}
|
|
11563
11646
|
if (selected.some(function (_option) { return _option.value === option.value; })) {
|
|
11564
11647
|
setSelected(selected.filter(function (_option) { return _option.value !== option.value; }));
|
|
11565
11648
|
}
|
|
@@ -11568,7 +11651,7 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
|
11568
11651
|
}
|
|
11569
11652
|
};
|
|
11570
11653
|
var handleSelectAll = function () {
|
|
11571
|
-
setSelected(selectOptions(flattenArray(options).filter(function (option) { return !option.disabled; }), selected));
|
|
11654
|
+
setSelected(selectOptions(__spreadArray(__spreadArray([], flattenArray(options).filter(function (option) { return !option.disabled; }), true), userOptions, true), selected));
|
|
11572
11655
|
};
|
|
11573
11656
|
var handleDeselectAll = function () {
|
|
11574
11657
|
setSelected(selected.filter(function (option) { return option.disabled; }));
|
|
@@ -11598,12 +11681,14 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
|
11598
11681
|
}), (selected.length > 0 &&
|
|
11599
11682
|
!multiple && { placeholder: selected.map(function (option) { return option.text; })[0] }), (multiple &&
|
|
11600
11683
|
selected.length > 0 &&
|
|
11601
|
-
selectionType !== 'counter' && { size:
|
|
11684
|
+
selectionType !== 'counter' && { size: searchValue.length + 2 }), { ref: searchRef })))), visible: _visible, ref: ref },
|
|
11602
11685
|
React$1.createElement(React$1.Fragment, null,
|
|
11603
11686
|
multiple && selectAll && (React$1.createElement("button", { type: "button", className: "form-multi-select-all", onClick: function () { return handleSelectAll(); } }, selectAllLabel)),
|
|
11604
|
-
React$1.createElement(CMultiSelectOptions, { handleOptionOnClick: function (option) { return !disabled && handleOptionOnClick(option); },
|
|
11687
|
+
React$1.createElement(CMultiSelectOptions, { handleOptionOnClick: function (option) { return !disabled && handleOptionOnClick(option); }, loading: loading, options: filteredOptions.length === 0 && allowCreateOptions
|
|
11688
|
+
? userOption || []
|
|
11689
|
+
: filteredOptions, optionsMaxHeight: optionsMaxHeight, optionsStyle: optionsStyle, searchNoResultsLabel: searchNoResultsLabel, selected: selected, virtualScroller: virtualScroller, visibleItems: visibleItems })))));
|
|
11605
11690
|
});
|
|
11606
|
-
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);
|
|
11691
|
+
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);
|
|
11607
11692
|
CMultiSelect.displayName = 'CMultiSelect';
|
|
11608
11693
|
|
|
11609
11694
|
var CNav = React$1.forwardRef(function (_a, ref) {
|