@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/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, onYearClick = props.onYearClick, 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,7 +6974,7 @@ 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
  },
@@ -6988,19 +6988,20 @@ var Calendar = function (props) {
6988
6988
  _b.selected = isDateSelected(date, startDate, endDate),
6989
6989
  _b.start = isStartDate(date, startDate, endDate),
6990
6990
  _b.end = isEndDate(date, startDate, endDate),
6991
- _b)), key: idx, tabIndex: 0, title: date.toLocaleDateString(locale) }, (month === 'current' && {
6991
+ _b)), key: idx, tabIndex: 0, title: date.toLocaleDateString(locale) }, ((month === 'current' || selectAdjacementDays) && {
6992
6992
  onBlur: function () { return onCellMouseLeave(); },
6993
6993
  onClick: function () { return onCellClick(date); },
6994
6994
  onFocus: function () { return onCellMouseEnter(date); },
6995
6995
  onKeyDown: function (event) { return onCellKeyDown(event, date); },
6996
6996
  onMouseEnter: function () { return onCellMouseEnter(date); },
6997
6997
  onMouseLeave: function () { return onCellMouseLeave(); },
6998
- }), (month !== 'current' && {
6998
+ }), (month !== 'current' &&
6999
+ !selectAdjacementDays && {
6999
7000
  onMouseEnter: function () { return onCellMouseLeave(); },
7000
7001
  })),
7001
7002
  React$1.createElement("div", { className: "calendar-cell-inner" }, typeof dayFormat === 'function'
7002
7003
  ? dayFormat(date)
7003
- : date.toLocaleDateString(locale, { day: dayFormat }))));
7004
+ : date.toLocaleDateString(locale, { day: dayFormat })))) : (React$1.createElement("td", { key: idx }));
7004
7005
  })));
7005
7006
  }),
7006
7007
  view === 'months' &&
@@ -7042,9 +7043,9 @@ var Navigation = function (props) {
7042
7043
  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
7044
  };
7044
7045
  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, _h = _a.weekdayFormat, weekdayFormat = _h === void 0 ? 2 : _h, onCalendarCellHover = _a.onCalendarCellHover, onCalendarDateChange = _a.onCalendarDateChange, onEndDateChange = _a.onEndDateChange, onStartDateChange = _a.onStartDateChange, onSelectEndChange = _a.onSelectEndChange, onViewChanged = _a.onViewChanged;
7046
+ 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
7047
  var isInitialMount = React$1.useRef(true);
7047
- var _j = React$1.useState(null), _calendarDate = _j[0], setCalendarDate = _j[1];
7048
+ var _l = React$1.useState(null), _calendarDate = _l[0], setCalendarDate = _l[1];
7048
7049
  React$1.useEffect(function () {
7049
7050
  if (calendarDate === null) {
7050
7051
  setCalendarDate(new Date());
@@ -7055,30 +7056,30 @@ var CCalendar = React$1.forwardRef(function (_a, ref) {
7055
7056
  !isSameDateAs(_calendarDate, date) && setCalendarDate(date);
7056
7057
  }
7057
7058
  }, [calendarDate]);
7058
- var _k = useStateWithCallback(startDate ? new Date(startDate) : null, onStartDateChange, !isInitialMount.current), _startDate = _k[0], setStartDate = _k[1];
7059
+ var _m = useStateWithCallback(startDate ? new Date(startDate) : null, onStartDateChange, !isInitialMount.current), _startDate = _m[0], setStartDate = _m[1];
7059
7060
  React$1.useEffect(function () {
7060
7061
  var date = startDate ? new Date(startDate) : null;
7061
7062
  if (!isSameDateAs(date, _startDate)) {
7062
7063
  setStartDate(date);
7063
7064
  }
7064
7065
  }, [startDate]);
7065
- var _l = useStateWithCallback(endDate ? new Date(endDate) : null, onEndDateChange, !isInitialMount.current), _endDate = _l[0], setEndDate = _l[1];
7066
+ var _o = useStateWithCallback(endDate ? new Date(endDate) : null, onEndDateChange, !isInitialMount.current), _endDate = _o[0], setEndDate = _o[1];
7066
7067
  React$1.useEffect(function () {
7067
7068
  var date = endDate ? new Date(endDate) : null;
7068
7069
  if (!isSameDateAs(date, _endDate)) {
7069
7070
  setEndDate(date);
7070
7071
  }
7071
7072
  }, [endDate]);
7072
- var _m = React$1.useState(null), _hoverDate = _m[0], setHoverDate = _m[1];
7073
- var _o = React$1.useState(maxDate ? new Date(maxDate) : null), _maxDate = _o[0], setMaxDate = _o[1];
7073
+ var _p = React$1.useState(null), _hoverDate = _p[0], setHoverDate = _p[1];
7074
+ var _q = React$1.useState(maxDate ? new Date(maxDate) : null), _maxDate = _q[0], setMaxDate = _q[1];
7074
7075
  React$1.useEffect(function () {
7075
7076
  maxDate && setMaxDate(new Date(maxDate));
7076
7077
  }, [maxDate]);
7077
- var _p = React$1.useState(minDate ? new Date(minDate) : null), _minDate = _p[0], setMinDate = _p[1];
7078
+ var _r = React$1.useState(minDate ? new Date(minDate) : null), _minDate = _r[0], setMinDate = _r[1];
7078
7079
  React$1.useEffect(function () {
7079
7080
  minDate && setMinDate(new Date(minDate));
7080
7081
  }, [minDate]);
7081
- var _q = useStateWithCallback(selectEndDate, onSelectEndChange), _selectEndDate = _q[0], setSelectEndDate = _q[1];
7082
+ var _s = useStateWithCallback(selectEndDate, onSelectEndChange), _selectEndDate = _s[0], setSelectEndDate = _s[1];
7082
7083
  React$1.useEffect(function () {
7083
7084
  setSelectEndDate(selectEndDate);
7084
7085
  }, [selectEndDate]);
@@ -7088,7 +7089,7 @@ var CCalendar = React$1.forwardRef(function (_a, ref) {
7088
7089
  onSelectEndChange &&
7089
7090
  onSelectEndChange(_selectEndDate);
7090
7091
  }, [_selectEndDate]);
7091
- var _r = useStateWithCallback('days', onViewChanged), view = _r[0], setView = _r[1];
7092
+ var _t = useStateWithCallback('days', onViewChanged), view = _t[0], setView = _t[1];
7092
7093
  React$1.useEffect(function () {
7093
7094
  isInitialMount.current = false;
7094
7095
  }, []);
@@ -7106,10 +7107,12 @@ var CCalendar = React$1.forwardRef(function (_a, ref) {
7106
7107
  setCalendarDate(d);
7107
7108
  onCalendarDateChange && onCalendarDateChange(d);
7108
7109
  };
7109
- var handleCellOnClick = function (date) {
7110
+ var handleCellOnClick = function (date, index) {
7110
7111
  if (isDateDisabled(date, _minDate, _maxDate, disabledDates)) {
7111
7112
  return;
7112
7113
  }
7114
+ var _date = new Date(date);
7115
+ setCalendarDate(index ? new Date(_date.setMonth(_date.getMonth() - index)) : _date);
7113
7116
  if (range) {
7114
7117
  if (_selectEndDate) {
7115
7118
  setSelectEndDate(false);
@@ -7153,10 +7156,10 @@ var CCalendar = React$1.forwardRef(function (_a, ref) {
7153
7156
  setHoverDate(null);
7154
7157
  onCalendarCellHover && onCalendarCellHover(null);
7155
7158
  };
7156
- var handleCellKeyDown = function (event, date) {
7159
+ var handleCellKeyDown = function (event, date, index) {
7157
7160
  if (event.code === 'Space' || event.key === 'Enter') {
7158
7161
  event.preventDefault();
7159
- handleCellOnClick && handleCellOnClick(date);
7162
+ handleCellOnClick && handleCellOnClick(date, index);
7160
7163
  return;
7161
7164
  }
7162
7165
  };
@@ -7190,13 +7193,13 @@ var CCalendar = React$1.forwardRef(function (_a, ref) {
7190
7193
  return (React$1.createElement("div", { className: classNames$1('calendars', className) }, _calendarDate &&
7191
7194
  Array.from({ length: calendars }, function (_, index) { return (React$1.createElement("div", { className: classNames$1('calendar', view), key: index, ref: ref },
7192
7195
  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: function (month, view) {
7196
+ 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: function (month, view) {
7194
7197
  setCalendarPage(0, 0, month);
7195
7198
  setView(view);
7196
7199
  }, onYearClick: function (date, view) {
7197
7200
  setCalendarDate(date);
7198
7201
  setView(view);
7199
- }, selectEndDate: _selectEndDate, startDate: _startDate, view: view, weekdayFormat: weekdayFormat }))); })));
7202
+ }, selectEndDate: _selectEndDate, selectAdjacementDays: selectAdjacementDays, showAdjacementDays: showAdjacementDays, startDate: _startDate, view: view, weekdayFormat: weekdayFormat }))); })));
7200
7203
  });
7201
7204
  CCalendar.propTypes = {
7202
7205
  className: propTypesExports.string,
@@ -7219,7 +7222,9 @@ CCalendar.propTypes = {
7219
7222
  navPrevDoubleIcon: propTypesExports.node,
7220
7223
  navYearFirst: propTypesExports.bool,
7221
7224
  range: propTypesExports.bool,
7225
+ selectAdjacementDays: propTypesExports.bool,
7222
7226
  selectEndDate: propTypesExports.bool,
7227
+ showAdjacementDays: propTypesExports.bool,
7223
7228
  startDate: propTypesExports.oneOfType([propTypesExports.instanceOf(Date), propTypesExports.string]),
7224
7229
  weekdayFormat: propTypesExports.oneOfType([
7225
7230
  propTypesExports.func,
@@ -10454,7 +10459,7 @@ var getLocalDateFromString = function (string, locale, time) {
10454
10459
 
10455
10460
  var _a, _b, _c, _d, _e, _f;
10456
10461
  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"]);
10462
+ 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
10463
  var _q = React$1.useState(visible), _visible = _q[0], setVisible = _q[1];
10459
10464
  var inputStartRef = React$1.useRef(null);
10460
10465
  var inputEndRef = React$1.useRef(null);
@@ -10602,7 +10607,7 @@ var CDateRangePicker = React$1.forwardRef(function (_a, ref) {
10602
10607
  handleStartDateChange(ranges[key][0]);
10603
10608
  handleEndDateChange(ranges[key][1]);
10604
10609
  }, 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 }),
10610
+ 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
10611
  timepicker && (React$1.createElement("div", { className: "date-picker-timepickers" }, isMobile_1 || (range && calendars === 1) ? (React$1.createElement(React$1.Fragment, null,
10607
10612
  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
10613
  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 +11299,15 @@ var CVirtualScroller = React$1.forwardRef(function (_a, ref) {
11294
11299
  setViewportPadding(Number.parseFloat(getComputedStyle(virtualScrollRef.current).paddingTop));
11295
11300
  });
11296
11301
  React$1.useEffect(function () {
11297
- setItemsNumber(itemsNumber || React$1.Children.count(children));
11298
- }, [children, itemsNumber]);
11302
+ setItemsNumber(React$1.Children.count(children));
11303
+ }, [children]);
11299
11304
  React$1.useEffect(function () {
11300
- setViewportHeight(visibleItems * itemHeight + 2 * viewportPadding);
11301
- }, [viewportPadding, visibleItems, itemHeight]);
11305
+ setViewportHeight(Math.min(visibleItems, itemsNumber) * itemHeight + 2 * viewportPadding);
11306
+ }, [itemHeight, itemsNumber, viewportPadding, visibleItems]);
11302
11307
  React$1.useEffect(function () {
11303
- setMaxHeight(itemsNumber * itemHeight + 2 * viewportPadding);
11308
+ setMaxHeight(itemsNumber * itemHeight);
11304
11309
  virtualScrollRef.current && virtualScrollRef.current.scrollTop;
11305
- }, [itemsNumber, itemHeight]);
11310
+ }, [itemHeight, itemsNumber]);
11306
11311
  React$1.useEffect(function () {
11307
11312
  setBuffer(Math.floor(visibleItems / 2));
11308
11313
  }, [visibleItems]);
@@ -11314,7 +11319,8 @@ var CVirtualScroller = React$1.forwardRef(function (_a, ref) {
11314
11319
  return (React$1.createElement("div", { className: classNames$1('virtual-scroller', className), onScroll: function (event) {
11315
11320
  return handleScroll(event.target.scrollTop);
11316
11321
  }, ref: forkedRef, style: {
11317
- height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
11322
+ // height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
11323
+ height: viewportHeight,
11318
11324
  overflowY: 'auto',
11319
11325
  } },
11320
11326
  React$1.createElement("div", { className: "virtual-scroller-content", style: {
@@ -11349,14 +11355,28 @@ CVirtualScroller.propTypes = {
11349
11355
  };
11350
11356
  CVirtualScroller.displayName = 'CVirtualScroller';
11351
11357
 
11358
+ var createOption = function (text, options) {
11359
+ var value = text.toLowerCase().replace(/\s/g, '-');
11360
+ var uniqueValue = value;
11361
+ var i = 1;
11362
+ while (options.find(function (option) { return String(option.value) === uniqueValue; })) {
11363
+ uniqueValue = "".concat(value, "-").concat(i);
11364
+ i++;
11365
+ }
11366
+ return [
11367
+ {
11368
+ value: uniqueValue,
11369
+ text: text,
11370
+ custom: true,
11371
+ },
11372
+ ];
11373
+ };
11352
11374
  var filterOptionsList = function (search, _options) {
11353
11375
  return search.length > 0
11354
11376
  ? _options &&
11355
11377
  _options.reduce(function (acc, val) {
11356
11378
  var options = val.options &&
11357
- val.options.filter(function (element) {
11358
- return element.text && element.text.toLowerCase().includes(search.toLowerCase());
11359
- });
11379
+ val.options.filter(function (element) { return element.text && element.text.toLowerCase().includes(search.toLowerCase()); });
11360
11380
  if ((val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
11361
11381
  (options && options.length > 0)) {
11362
11382
  acc.push(Object.assign({}, val, options && options.length > 0 && { options: options }));
@@ -11417,7 +11437,7 @@ var selectOptions = function (options, selected, deselected) {
11417
11437
  };
11418
11438
 
11419
11439
  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;
11440
+ 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
11441
  var handleKeyDown = function (event, option) {
11422
11442
  if (event.code === 'Space' || event.key === 'Enter') {
11423
11443
  event.preventDefault();
@@ -11452,12 +11472,15 @@ var CMultiSelectOptions = React$1.forwardRef(function (_a, ref) {
11452
11472
  }), key: index, onClick: function () { return handleOptionOnClick && handleOptionOnClick(option); }, onKeyDown: function (event) { return handleKeyDown(event, option); }, tabIndex: 0 }, option.text));
11453
11473
  })) : (React$1.createElement("div", { className: "form-multi-select-options-empty" }, searchNoResultsLabel));
11454
11474
  };
11455
- return 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' && {
11456
- style: { maxHeight: optionsMaxHeight, overflow: 'scroll' },
11457
- }), { ref: ref }), createOptions(options)));
11475
+ return (React$1.createElement(React$1.Fragment, null,
11476
+ 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' && {
11477
+ style: { maxHeight: optionsMaxHeight, overflow: 'scroll' },
11478
+ }), { ref: ref }), createOptions(options))),
11479
+ loading && React$1.createElement(CElementCover, null)));
11458
11480
  });
11459
11481
  CMultiSelectOptions.propTypes = {
11460
11482
  handleOptionOnClick: propTypesExports.func,
11483
+ loading: propTypesExports.bool,
11461
11484
  options: propTypesExports.array.isRequired,
11462
11485
  optionsMaxHeight: propTypesExports.oneOfType([propTypesExports.number, propTypesExports.string]),
11463
11486
  optionsStyle: propTypesExports.oneOf(['checkbox', 'text']),
@@ -11500,14 +11523,27 @@ CMultiSelectSelection.displayName = 'CMultiSelectSelection';
11500
11523
 
11501
11524
  var CMultiSelect = React$1.forwardRef(function (_a, ref) {
11502
11525
  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"]);
11526
+ 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
11527
  var isInitialMount = React$1.useRef(true);
11505
11528
  var nativeSelectRef = React$1.useRef(null);
11506
11529
  var searchRef = React$1.useRef(null);
11507
11530
  var _r = React$1.useState(options), _options = _r[0], setOptions = _r[1];
11508
- var _s = React$1.useState(''), _search = _s[0], setSearch = _s[1];
11509
- var _t = React$1.useState(visible), _visible = _t[0], setVisible = _t[1];
11531
+ var _s = React$1.useState(visible), _visible = _s[0], setVisible = _s[1];
11532
+ var _t = React$1.useState(''), searchValue = _t[0], setSearchValue = _t[1];
11510
11533
  var _u = React$1.useState([]), selected = _u[0], setSelected = _u[1];
11534
+ var _v = React$1.useState([]), userOptions = _v[0], setUserOptions = _v[1];
11535
+ var filteredOptions = React$1.useMemo(function () {
11536
+ return search === 'external'
11537
+ ? __spreadArray(__spreadArray([], _options, true), filterOptionsList(searchValue, userOptions), true) : filterOptionsList(searchValue, __spreadArray(__spreadArray([], _options, true), userOptions, true));
11538
+ }, [_options, searchValue, userOptions]);
11539
+ var userOption = React$1.useMemo(function () {
11540
+ if (allowCreateOptions &&
11541
+ filteredOptions.length > 0 &&
11542
+ flattenArray(filteredOptions).filter(function (option) { return option.text.toLowerCase() === searchValue.toLowerCase(); }).length > 0) {
11543
+ return false;
11544
+ }
11545
+ return searchRef.current && createOption(String(searchValue), flattenArray(_options));
11546
+ }, [filteredOptions, searchValue]);
11511
11547
  React$1.useMemo(function () {
11512
11548
  setOptions(options);
11513
11549
  var _selected = options &&
@@ -11526,6 +11562,9 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
11526
11562
  });
11527
11563
  _selected && setSelected(selectOptions(_selected, selected, deselected));
11528
11564
  }, [JSON.stringify(options)]);
11565
+ React$1.useEffect(function () {
11566
+ !isInitialMount.current && onFilterChange && onFilterChange(searchValue);
11567
+ }, [searchValue]);
11529
11568
  React$1.useEffect(function () {
11530
11569
  !isInitialMount.current &&
11531
11570
  nativeSelectRef.current &&
@@ -11535,14 +11574,27 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
11535
11574
  isInitialMount.current = false;
11536
11575
  }, []);
11537
11576
  var handleSearchChange = function (event) {
11538
- var target = event.target;
11539
- if (search !== 'external') {
11540
- setSearch(target.value.toLowerCase());
11541
- }
11542
- onFilterChange && onFilterChange(target.value);
11577
+ var value = event.target.value;
11578
+ setSearchValue(value);
11543
11579
  };
11544
11580
  var handleSearchKeyDown = function (event) {
11545
- if (_search.length > 0) {
11581
+ if (event.key === 'Enter' && searchValue && allowCreateOptions) {
11582
+ if (userOption) {
11583
+ setSelected(__spreadArray(__spreadArray([], selected, true), userOption, true));
11584
+ setUserOptions(__spreadArray(__spreadArray([], userOptions, true), userOption, true));
11585
+ }
11586
+ if (!userOption) {
11587
+ setSelected(__spreadArray(__spreadArray([], selected, true), [
11588
+ flattenArray(filteredOptions).filter(function (option) { return String(option.text).toLowerCase() === searchValue.toLowerCase(); })[0],
11589
+ ], false));
11590
+ }
11591
+ setSearchValue('');
11592
+ if (searchRef.current) {
11593
+ searchRef.current.value = '';
11594
+ }
11595
+ return;
11596
+ }
11597
+ if (searchValue.length > 0) {
11546
11598
  return;
11547
11599
  }
11548
11600
  if (event.key === 'Backspace' || event.key === 'Delete') {
@@ -11554,12 +11606,22 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
11554
11606
  if (!multiple) {
11555
11607
  setSelected([{ value: option.value, text: option.text }]);
11556
11608
  setVisible(false);
11557
- setSearch('');
11609
+ setSearchValue('');
11558
11610
  if (searchRef.current) {
11559
11611
  searchRef.current.value = '';
11560
11612
  }
11561
11613
  return;
11562
11614
  }
11615
+ if (option.custom && !userOptions.some(function (_option) { return _option.value === option.value; })) {
11616
+ setUserOptions(__spreadArray(__spreadArray([], userOptions, true), [option], false));
11617
+ }
11618
+ if (clearSearchOnSelect || option.custom) {
11619
+ setSearchValue('');
11620
+ if (searchRef.current) {
11621
+ searchRef.current.value = '';
11622
+ searchRef.current.focus();
11623
+ }
11624
+ }
11563
11625
  if (selected.some(function (_option) { return _option.value === option.value; })) {
11564
11626
  setSelected(selected.filter(function (_option) { return _option.value !== option.value; }));
11565
11627
  }
@@ -11568,7 +11630,7 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
11568
11630
  }
11569
11631
  };
11570
11632
  var handleSelectAll = function () {
11571
- setSelected(selectOptions(flattenArray(options).filter(function (option) { return !option.disabled; }), selected));
11633
+ setSelected(selectOptions(__spreadArray(__spreadArray([], flattenArray(options).filter(function (option) { return !option.disabled; }), true), userOptions, true), selected));
11572
11634
  };
11573
11635
  var handleDeselectAll = function () {
11574
11636
  setSelected(selected.filter(function (option) { return option.disabled; }));
@@ -11598,12 +11660,14 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
11598
11660
  }), (selected.length > 0 &&
11599
11661
  !multiple && { placeholder: selected.map(function (option) { return option.text; })[0] }), (multiple &&
11600
11662
  selected.length > 0 &&
11601
- selectionType !== 'counter' && { size: _search.length + 2 }), { ref: searchRef })))), visible: _visible, ref: ref },
11663
+ selectionType !== 'counter' && { size: searchValue.length + 2 }), { ref: searchRef })))), visible: _visible, ref: ref },
11602
11664
  React$1.createElement(React$1.Fragment, null,
11603
11665
  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); }, options: search === 'external' ? _options : filterOptionsList(_search, _options), optionsMaxHeight: optionsMaxHeight, optionsStyle: optionsStyle, searchNoResultsLabel: searchNoResultsLabel, selected: selected, virtualScroller: virtualScroller, visibleItems: visibleItems })))));
11666
+ React$1.createElement(CMultiSelectOptions, { handleOptionOnClick: function (option) { return !disabled && handleOptionOnClick(option); }, loading: loading, options: filteredOptions.length === 0 && allowCreateOptions
11667
+ ? userOption || []
11668
+ : filteredOptions, optionsMaxHeight: optionsMaxHeight, optionsStyle: optionsStyle, searchNoResultsLabel: searchNoResultsLabel, selected: selected, virtualScroller: virtualScroller, visibleItems: visibleItems })))));
11605
11669
  });
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);
11670
+ 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
11671
  CMultiSelect.displayName = 'CMultiSelect';
11608
11672
 
11609
11673
  var CNav = React$1.forwardRef(function (_a, ref) {