@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 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.10.0.zip)
45
+ - [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v4.11.0-next.1.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,5 @@
1
1
  export type Option = {
2
+ custom?: boolean;
2
3
  disabled?: boolean;
3
4
  label?: string;
4
5
  options?: Option[];
@@ -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. When 'small' prop is enabled spinner will be also smaller.
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, 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;
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,11 +6954,12 @@ 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
  },
6961
6961
  _b[month] = true,
6962
+ _b.clickable = month !== 'current' && selectAdjacementDays,
6962
6963
  _b.last = isLastDayOfMonth(date),
6963
6964
  _b['range-hover'] = month === 'current' &&
6964
6965
  (hoverDate && selectEndDate
@@ -6968,34 +6969,40 @@ var Calendar = function (props) {
6968
6969
  _b.selected = isDateSelected(date, startDate, endDate),
6969
6970
  _b.start = isStartDate(date, startDate, endDate),
6970
6971
  _b.end = isEndDate(date, startDate, endDate),
6971
- _b)), key: idx, tabIndex: 0, title: date.toLocaleDateString(locale) }, (month === 'current' && {
6972
+ _b)), key: idx, tabIndex: (month === 'current' || selectAdjacementDays) &&
6973
+ !isDateDisabled(date, minDate, maxDate, disabledDates)
6974
+ ? 0
6975
+ : -1, title: date.toLocaleDateString(locale) }, ((month === 'current' || selectAdjacementDays) && {
6972
6976
  onBlur: function () { return onCellMouseLeave(); },
6973
6977
  onClick: function () { return onCellClick(date); },
6974
6978
  onFocus: function () { return onCellMouseEnter(date); },
6975
6979
  onKeyDown: function (event) { return onCellKeyDown(event, date); },
6976
6980
  onMouseEnter: function () { return onCellMouseEnter(date); },
6977
6981
  onMouseLeave: function () { return onCellMouseLeave(); },
6978
- }), (month !== 'current' && {
6982
+ }), (month !== 'current' &&
6983
+ !selectAdjacementDays && {
6979
6984
  onMouseEnter: function () { return onCellMouseLeave(); },
6980
6985
  })),
6981
6986
  React__default$1.createElement("div", { className: "calendar-cell-inner" }, typeof dayFormat === 'function'
6982
6987
  ? dayFormat(date)
6983
- : date.toLocaleDateString(locale, { day: dayFormat }))));
6988
+ : date.toLocaleDateString(locale, { day: dayFormat })))) : (React__default$1.createElement("td", { key: idx }));
6984
6989
  })));
6985
6990
  }),
6986
6991
  view === 'months' &&
6987
6992
  listOfMonths.map(function (row, index) {
6988
6993
  return (React__default$1.createElement("tr", { key: index }, row.map(function (month, idx) {
6989
- return (React__default$1.createElement("td", { key: idx, className: "calendar-cell month", onClick: function () { return onMonthClick(index * 3 + idx - addMonths, 'days'); } },
6994
+ return (React__default$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 },
6990
6995
  React__default$1.createElement("div", { className: "calendar-cell-inner" }, month)));
6991
6996
  })));
6992
6997
  }),
6993
6998
  view === 'years' &&
6994
6999
  listOfYears.map(function (row, index) {
6995
7000
  return (React__default$1.createElement("tr", { key: index }, row.map(function (year, idx) {
6996
- return (React__default$1.createElement("td", { key: idx, className: "calendar-cell year", onClick: function () {
6997
- return onYearClick(new Date(year, date.getMonth() - addMonths, date.getDate()), 'months');
6998
- } },
7001
+ return (React__default$1.createElement("td", { className: "calendar-cell year", key: idx, onClick: function () {
7002
+ return onYearClick(new Date(year, date.getMonth() - addMonths, date.getDate()));
7003
+ }, onKeyDown: function (event) {
7004
+ return onYearKeyDown(event, new Date(year, date.getMonth() - addMonths, date.getDate()));
7005
+ }, tabIndex: 0 },
6999
7006
  React__default$1.createElement("div", { className: "calendar-cell-inner" }, new Date(year, 0, 1).toLocaleDateString(locale, { year: 'numeric' }))));
7000
7007
  })));
7001
7008
  }))));
@@ -7022,9 +7029,9 @@ var Navigation = function (props) {
7022
7029
  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
7030
  };
7024
7031
  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, _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;
7032
+ 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
7033
  var isInitialMount = useRef(true);
7027
- var _j = useState(null), _calendarDate = _j[0], setCalendarDate = _j[1];
7034
+ var _l = useState(null), _calendarDate = _l[0], setCalendarDate = _l[1];
7028
7035
  useEffect(function () {
7029
7036
  if (calendarDate === null) {
7030
7037
  setCalendarDate(new Date());
@@ -7035,30 +7042,30 @@ var CCalendar = forwardRef(function (_a, ref) {
7035
7042
  !isSameDateAs(_calendarDate, date) && setCalendarDate(date);
7036
7043
  }
7037
7044
  }, [calendarDate]);
7038
- var _k = useStateWithCallback(startDate ? new Date(startDate) : null, onStartDateChange, !isInitialMount.current), _startDate = _k[0], setStartDate = _k[1];
7045
+ var _m = useStateWithCallback(startDate ? new Date(startDate) : null, onStartDateChange, !isInitialMount.current), _startDate = _m[0], setStartDate = _m[1];
7039
7046
  useEffect(function () {
7040
7047
  var date = startDate ? new Date(startDate) : null;
7041
7048
  if (!isSameDateAs(date, _startDate)) {
7042
7049
  setStartDate(date);
7043
7050
  }
7044
7051
  }, [startDate]);
7045
- var _l = useStateWithCallback(endDate ? new Date(endDate) : null, onEndDateChange, !isInitialMount.current), _endDate = _l[0], setEndDate = _l[1];
7052
+ var _o = useStateWithCallback(endDate ? new Date(endDate) : null, onEndDateChange, !isInitialMount.current), _endDate = _o[0], setEndDate = _o[1];
7046
7053
  useEffect(function () {
7047
7054
  var date = endDate ? new Date(endDate) : null;
7048
7055
  if (!isSameDateAs(date, _endDate)) {
7049
7056
  setEndDate(date);
7050
7057
  }
7051
7058
  }, [endDate]);
7052
- var _m = useState(null), _hoverDate = _m[0], setHoverDate = _m[1];
7053
- var _o = useState(maxDate ? new Date(maxDate) : null), _maxDate = _o[0], setMaxDate = _o[1];
7059
+ var _p = useState(null), _hoverDate = _p[0], setHoverDate = _p[1];
7060
+ var _q = useState(maxDate ? new Date(maxDate) : null), _maxDate = _q[0], setMaxDate = _q[1];
7054
7061
  useEffect(function () {
7055
7062
  maxDate && setMaxDate(new Date(maxDate));
7056
7063
  }, [maxDate]);
7057
- var _p = useState(minDate ? new Date(minDate) : null), _minDate = _p[0], setMinDate = _p[1];
7064
+ var _r = useState(minDate ? new Date(minDate) : null), _minDate = _r[0], setMinDate = _r[1];
7058
7065
  useEffect(function () {
7059
7066
  minDate && setMinDate(new Date(minDate));
7060
7067
  }, [minDate]);
7061
- var _q = useStateWithCallback(selectEndDate, onSelectEndChange), _selectEndDate = _q[0], setSelectEndDate = _q[1];
7068
+ var _s = useStateWithCallback(selectEndDate, onSelectEndChange), _selectEndDate = _s[0], setSelectEndDate = _s[1];
7062
7069
  useEffect(function () {
7063
7070
  setSelectEndDate(selectEndDate);
7064
7071
  }, [selectEndDate]);
@@ -7068,7 +7075,7 @@ var CCalendar = forwardRef(function (_a, ref) {
7068
7075
  onSelectEndChange &&
7069
7076
  onSelectEndChange(_selectEndDate);
7070
7077
  }, [_selectEndDate]);
7071
- var _r = useStateWithCallback('days', onViewChanged), view = _r[0], setView = _r[1];
7078
+ var _t = useStateWithCallback('days', onViewChanged), view = _t[0], setView = _t[1];
7072
7079
  useEffect(function () {
7073
7080
  isInitialMount.current = false;
7074
7081
  }, []);
@@ -7086,10 +7093,12 @@ var CCalendar = forwardRef(function (_a, ref) {
7086
7093
  setCalendarDate(d);
7087
7094
  onCalendarDateChange && onCalendarDateChange(d);
7088
7095
  };
7089
- var handleCellOnClick = function (date) {
7096
+ var handleCellOnClick = function (date, index) {
7090
7097
  if (isDateDisabled(date, _minDate, _maxDate, disabledDates)) {
7091
7098
  return;
7092
7099
  }
7100
+ var _date = new Date(date);
7101
+ setCalendarDate(index ? new Date(_date.setMonth(_date.getMonth() - index)) : _date);
7093
7102
  if (range) {
7094
7103
  if (_selectEndDate) {
7095
7104
  setSelectEndDate(false);
@@ -7133,13 +7142,23 @@ var CCalendar = forwardRef(function (_a, ref) {
7133
7142
  setHoverDate(null);
7134
7143
  onCalendarCellHover && onCalendarCellHover(null);
7135
7144
  };
7136
- var handleCellKeyDown = function (event, date) {
7145
+ var handleCellKeyDown = function (event, date, index) {
7137
7146
  if (event.code === 'Space' || event.key === 'Enter') {
7138
7147
  event.preventDefault();
7139
- handleCellOnClick && handleCellOnClick(date);
7148
+ handleCellOnClick && handleCellOnClick(date, index);
7140
7149
  return;
7141
7150
  }
7142
7151
  };
7152
+ var handleMonthClick = function (month) {
7153
+ setCalendarPage(0, 0, month);
7154
+ setView('days');
7155
+ };
7156
+ var handleMonthKeyDown = function (event, month) {
7157
+ if (event.code === 'Space' || event.key === 'Enter') {
7158
+ setCalendarPage(0, 0, month);
7159
+ setView('days');
7160
+ }
7161
+ };
7143
7162
  var handleNavigationOnClick = function (direction, double) {
7144
7163
  if (double === void 0) { double = false; }
7145
7164
  if (direction === 'prev') {
@@ -7167,16 +7186,20 @@ var CCalendar = forwardRef(function (_a, ref) {
7167
7186
  return;
7168
7187
  }
7169
7188
  };
7189
+ var handleYearClick = function (date) {
7190
+ setCalendarDate(date);
7191
+ setView('months');
7192
+ };
7193
+ var handleYearKeyDown = function (event, date) {
7194
+ if (event.code === 'Space' || event.key === 'Enter') {
7195
+ setCalendarDate(date);
7196
+ setView('months');
7197
+ }
7198
+ };
7170
7199
  return (React__default$1.createElement("div", { className: classNames$1('calendars', className) }, _calendarDate &&
7171
7200
  Array.from({ length: calendars }, function (_, index) { return (React__default$1.createElement("div", { className: classNames$1('calendar', view), key: index, ref: ref },
7172
7201
  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) {
7174
- setCalendarPage(0, 0, month);
7175
- setView(view);
7176
- }, onYearClick: function (date, view) {
7177
- setCalendarDate(date);
7178
- setView(view);
7179
- }, selectEndDate: _selectEndDate, startDate: _startDate, view: view, weekdayFormat: weekdayFormat }))); })));
7202
+ 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: handleMonthClick, onMonthKeyDown: handleMonthKeyDown, onYearClick: handleYearClick, onYearKeyDown: handleYearKeyDown, selectEndDate: _selectEndDate, selectAdjacementDays: selectAdjacementDays, showAdjacementDays: showAdjacementDays, startDate: _startDate, view: view, weekdayFormat: weekdayFormat }))); })));
7180
7203
  });
7181
7204
  CCalendar.propTypes = {
7182
7205
  className: propTypesExports.string,
@@ -7199,7 +7222,9 @@ CCalendar.propTypes = {
7199
7222
  navPrevDoubleIcon: propTypesExports.node,
7200
7223
  navYearFirst: propTypesExports.bool,
7201
7224
  range: propTypesExports.bool,
7225
+ selectAdjacementDays: propTypesExports.bool,
7202
7226
  selectEndDate: propTypesExports.bool,
7227
+ showAdjacementDays: propTypesExports.bool,
7203
7228
  startDate: propTypesExports.oneOfType([propTypesExports.instanceOf(Date), propTypesExports.string]),
7204
7229
  weekdayFormat: propTypesExports.oneOfType([
7205
7230
  propTypesExports.func,
@@ -10434,7 +10459,7 @@ var getLocalDateFromString = function (string, locale, time) {
10434
10459
 
10435
10460
  var _a, _b, _c, _d, _e, _f;
10436
10461
  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"]);
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"]);
10438
10463
  var _q = useState(visible), _visible = _q[0], setVisible = _q[1];
10439
10464
  var inputStartRef = useRef(null);
10440
10465
  var inputEndRef = useRef(null);
@@ -10582,7 +10607,7 @@ var CDateRangePicker = forwardRef(function (_a, ref) {
10582
10607
  handleStartDateChange(ranges[key][0]);
10583
10608
  handleEndDateChange(ranges[key][1]);
10584
10609
  }, 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 }),
10610
+ 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
10611
  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
10612
  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
10613
  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 +11299,15 @@ var CVirtualScroller = forwardRef(function (_a, ref) {
11274
11299
  setViewportPadding(Number.parseFloat(getComputedStyle(virtualScrollRef.current).paddingTop));
11275
11300
  });
11276
11301
  useEffect(function () {
11277
- setItemsNumber(itemsNumber || React__default$1.Children.count(children));
11278
- }, [children, itemsNumber]);
11302
+ setItemsNumber(React__default$1.Children.count(children));
11303
+ }, [children]);
11279
11304
  useEffect(function () {
11280
- setViewportHeight(visibleItems * itemHeight + 2 * viewportPadding);
11281
- }, [viewportPadding, visibleItems, itemHeight]);
11305
+ setViewportHeight(Math.min(visibleItems, itemsNumber) * itemHeight + 2 * viewportPadding);
11306
+ }, [itemHeight, itemsNumber, viewportPadding, visibleItems]);
11282
11307
  useEffect(function () {
11283
- setMaxHeight(itemsNumber * itemHeight + 2 * viewportPadding);
11308
+ setMaxHeight(itemsNumber * itemHeight);
11284
11309
  virtualScrollRef.current && virtualScrollRef.current.scrollTop;
11285
- }, [itemsNumber, itemHeight]);
11310
+ }, [itemHeight, itemsNumber]);
11286
11311
  useEffect(function () {
11287
11312
  setBuffer(Math.floor(visibleItems / 2));
11288
11313
  }, [visibleItems]);
@@ -11294,7 +11319,8 @@ var CVirtualScroller = forwardRef(function (_a, ref) {
11294
11319
  return (React__default$1.createElement("div", { className: classNames$1('virtual-scroller', className), onScroll: function (event) {
11295
11320
  return handleScroll(event.target.scrollTop);
11296
11321
  }, ref: forkedRef, style: {
11297
- height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
11322
+ // height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
11323
+ height: viewportHeight,
11298
11324
  overflowY: 'auto',
11299
11325
  } },
11300
11326
  React__default$1.createElement("div", { className: "virtual-scroller-content", style: {
@@ -11329,14 +11355,28 @@ CVirtualScroller.propTypes = {
11329
11355
  };
11330
11356
  CVirtualScroller.displayName = 'CVirtualScroller';
11331
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
+ };
11332
11374
  var filterOptionsList = function (search, _options) {
11333
11375
  return search.length > 0
11334
11376
  ? _options &&
11335
11377
  _options.reduce(function (acc, val) {
11336
11378
  var options = val.options &&
11337
- val.options.filter(function (element) {
11338
- return element.text && element.text.toLowerCase().includes(search.toLowerCase());
11339
- });
11379
+ val.options.filter(function (element) { return element.text && element.text.toLowerCase().includes(search.toLowerCase()); });
11340
11380
  if ((val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
11341
11381
  (options && options.length > 0)) {
11342
11382
  acc.push(Object.assign({}, val, options && options.length > 0 && { options: options }));
@@ -11397,7 +11437,7 @@ var selectOptions = function (options, selected, deselected) {
11397
11437
  };
11398
11438
 
11399
11439
  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;
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;
11401
11441
  var handleKeyDown = function (event, option) {
11402
11442
  if (event.code === 'Space' || event.key === 'Enter') {
11403
11443
  event.preventDefault();
@@ -11432,12 +11472,15 @@ var CMultiSelectOptions = forwardRef(function (_a, ref) {
11432
11472
  }), key: index, onClick: function () { return handleOptionOnClick && handleOptionOnClick(option); }, onKeyDown: function (event) { return handleKeyDown(event, option); }, tabIndex: 0 }, option.text));
11433
11473
  })) : (React__default$1.createElement("div", { className: "form-multi-select-options-empty" }, searchNoResultsLabel));
11434
11474
  };
11435
- return 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' && {
11436
- style: { maxHeight: optionsMaxHeight, overflow: 'scroll' },
11437
- }), { ref: ref }), createOptions(options)));
11475
+ return (React__default$1.createElement(React__default$1.Fragment, null,
11476
+ 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' && {
11477
+ style: { maxHeight: optionsMaxHeight, overflow: 'scroll' },
11478
+ }), { ref: ref }), createOptions(options))),
11479
+ loading && React__default$1.createElement(CElementCover, null)));
11438
11480
  });
11439
11481
  CMultiSelectOptions.propTypes = {
11440
11482
  handleOptionOnClick: propTypesExports.func,
11483
+ loading: propTypesExports.bool,
11441
11484
  options: propTypesExports.array.isRequired,
11442
11485
  optionsMaxHeight: propTypesExports.oneOfType([propTypesExports.number, propTypesExports.string]),
11443
11486
  optionsStyle: propTypesExports.oneOf(['checkbox', 'text']),
@@ -11480,14 +11523,27 @@ CMultiSelectSelection.displayName = 'CMultiSelectSelection';
11480
11523
 
11481
11524
  var CMultiSelect = forwardRef(function (_a, ref) {
11482
11525
  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"]);
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"]);
11484
11527
  var isInitialMount = useRef(true);
11485
11528
  var nativeSelectRef = useRef(null);
11486
11529
  var searchRef = useRef(null);
11487
11530
  var _r = useState(options), _options = _r[0], setOptions = _r[1];
11488
- var _s = useState(''), _search = _s[0], setSearch = _s[1];
11489
- var _t = useState(visible), _visible = _t[0], setVisible = _t[1];
11531
+ var _s = useState(visible), _visible = _s[0], setVisible = _s[1];
11532
+ var _t = useState(''), searchValue = _t[0], setSearchValue = _t[1];
11490
11533
  var _u = useState([]), selected = _u[0], setSelected = _u[1];
11534
+ var _v = useState([]), userOptions = _v[0], setUserOptions = _v[1];
11535
+ var filteredOptions = 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 = 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]);
11491
11547
  useMemo(function () {
11492
11548
  setOptions(options);
11493
11549
  var _selected = options &&
@@ -11506,6 +11562,9 @@ var CMultiSelect = forwardRef(function (_a, ref) {
11506
11562
  });
11507
11563
  _selected && setSelected(selectOptions(_selected, selected, deselected));
11508
11564
  }, [JSON.stringify(options)]);
11565
+ useEffect(function () {
11566
+ !isInitialMount.current && onFilterChange && onFilterChange(searchValue);
11567
+ }, [searchValue]);
11509
11568
  useEffect(function () {
11510
11569
  !isInitialMount.current &&
11511
11570
  nativeSelectRef.current &&
@@ -11515,14 +11574,28 @@ var CMultiSelect = forwardRef(function (_a, ref) {
11515
11574
  isInitialMount.current = false;
11516
11575
  }, []);
11517
11576
  var handleSearchChange = function (event) {
11518
- var target = event.target;
11519
- if (search !== 'external') {
11520
- setSearch(target.value.toLowerCase());
11521
- }
11522
- onFilterChange && onFilterChange(target.value);
11577
+ var value = event.target.value;
11578
+ setSearchValue(value);
11523
11579
  };
11524
11580
  var handleSearchKeyDown = function (event) {
11525
- if (_search.length > 0) {
11581
+ if (event.key === 'Enter' && searchValue && allowCreateOptions) {
11582
+ event.preventDefault();
11583
+ if (userOption) {
11584
+ setSelected(__spreadArray(__spreadArray([], selected, true), userOption, true));
11585
+ setUserOptions(__spreadArray(__spreadArray([], userOptions, true), userOption, true));
11586
+ }
11587
+ if (!userOption) {
11588
+ setSelected(__spreadArray(__spreadArray([], selected, true), [
11589
+ flattenArray(filteredOptions).filter(function (option) { return String(option.text).toLowerCase() === searchValue.toLowerCase(); })[0],
11590
+ ], false));
11591
+ }
11592
+ setSearchValue('');
11593
+ if (searchRef.current) {
11594
+ searchRef.current.value = '';
11595
+ }
11596
+ return;
11597
+ }
11598
+ if (searchValue.length > 0) {
11526
11599
  return;
11527
11600
  }
11528
11601
  if (event.key === 'Backspace' || event.key === 'Delete') {
@@ -11534,12 +11607,22 @@ var CMultiSelect = forwardRef(function (_a, ref) {
11534
11607
  if (!multiple) {
11535
11608
  setSelected([{ value: option.value, text: option.text }]);
11536
11609
  setVisible(false);
11537
- setSearch('');
11610
+ setSearchValue('');
11538
11611
  if (searchRef.current) {
11539
11612
  searchRef.current.value = '';
11540
11613
  }
11541
11614
  return;
11542
11615
  }
11616
+ if (option.custom && !userOptions.some(function (_option) { return _option.value === option.value; })) {
11617
+ setUserOptions(__spreadArray(__spreadArray([], userOptions, true), [option], false));
11618
+ }
11619
+ if (clearSearchOnSelect || option.custom) {
11620
+ setSearchValue('');
11621
+ if (searchRef.current) {
11622
+ searchRef.current.value = '';
11623
+ searchRef.current.focus();
11624
+ }
11625
+ }
11543
11626
  if (selected.some(function (_option) { return _option.value === option.value; })) {
11544
11627
  setSelected(selected.filter(function (_option) { return _option.value !== option.value; }));
11545
11628
  }
@@ -11548,7 +11631,7 @@ var CMultiSelect = forwardRef(function (_a, ref) {
11548
11631
  }
11549
11632
  };
11550
11633
  var handleSelectAll = function () {
11551
- setSelected(selectOptions(flattenArray(options).filter(function (option) { return !option.disabled; }), selected));
11634
+ setSelected(selectOptions(__spreadArray(__spreadArray([], flattenArray(options).filter(function (option) { return !option.disabled; }), true), userOptions, true), selected));
11552
11635
  };
11553
11636
  var handleDeselectAll = function () {
11554
11637
  setSelected(selected.filter(function (option) { return option.disabled; }));
@@ -11578,12 +11661,14 @@ var CMultiSelect = forwardRef(function (_a, ref) {
11578
11661
  }), (selected.length > 0 &&
11579
11662
  !multiple && { placeholder: selected.map(function (option) { return option.text; })[0] }), (multiple &&
11580
11663
  selected.length > 0 &&
11581
- selectionType !== 'counter' && { size: _search.length + 2 }), { ref: searchRef })))), visible: _visible, ref: ref },
11664
+ selectionType !== 'counter' && { size: searchValue.length + 2 }), { ref: searchRef })))), visible: _visible, ref: ref },
11582
11665
  React__default$1.createElement(React__default$1.Fragment, null,
11583
11666
  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); }, options: search === 'external' ? _options : filterOptionsList(_search, _options), optionsMaxHeight: optionsMaxHeight, optionsStyle: optionsStyle, searchNoResultsLabel: searchNoResultsLabel, selected: selected, virtualScroller: virtualScroller, visibleItems: visibleItems })))));
11667
+ React__default$1.createElement(CMultiSelectOptions, { handleOptionOnClick: function (option) { return !disabled && handleOptionOnClick(option); }, loading: loading, options: filteredOptions.length === 0 && allowCreateOptions
11668
+ ? userOption || []
11669
+ : filteredOptions, optionsMaxHeight: optionsMaxHeight, optionsStyle: optionsStyle, searchNoResultsLabel: searchNoResultsLabel, selected: selected, virtualScroller: virtualScroller, visibleItems: visibleItems })))));
11585
11670
  });
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);
11671
+ 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
11672
  CMultiSelect.displayName = 'CMultiSelect';
11588
11673
 
11589
11674
  var CNav = forwardRef(function (_a, ref) {