@coreui/react-pro 4.9.0 → 4.11.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/calendar/CCalendar.d.ts +12 -0
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +6 -0
- package/dist/components/multi-select/CMultiSelect.d.ts +18 -1
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +1 -0
- package/dist/components/multi-select/types.d.ts +1 -0
- package/dist/components/multi-select/utils.d.ts +5 -0
- package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -1
- package/dist/components/time-picker/CTimePicker.d.ts +6 -0
- package/dist/index.es.js +126 -61
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +126 -61
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/calendar/CCalendar.tsx +79 -44
- package/src/components/calendar/utils.ts +1 -0
- package/src/components/date-range-picker/CDateRangePicker.tsx +14 -0
- package/src/components/dropdown/CDropdown.tsx +33 -30
- package/src/components/multi-select/CMultiSelect.tsx +99 -14
- package/src/components/multi-select/CMultiSelectOptions.tsx +29 -16
- package/src/components/multi-select/types.ts +1 -0
- package/src/components/multi-select/utils.ts +42 -25
- package/src/components/smart-table/CSmartTableInterface.tsx +1 -1
- package/src/components/time-picker/CTimePicker.tsx +9 -0
- package/src/components/virtual-scroller/CVirtualScroller.tsx +8 -7
- package/dist/components/Types.d.ts +0 -14
- package/dist/components/multi-select/CMultiSelectCleaner.d.ts +0 -2
- package/dist/components/multi-select/CMultiSelectSearchInput.d.ts +0 -5
- package/dist/components/pagination/CSmartPagination.d.ts +0 -80
- package/dist/components/time-picker/CTimePicker copy.d.ts +0 -46
- package/dist/utils/calendar.d.ts +0 -23
- package/dist/utils/getNextSibling.d.ts +0 -2
- package/dist/utils/getPreviousSibling.d.ts +0 -2
- package/dist/utils/hooks/index.d.ts +0 -3
- package/dist/utils/hooks/useForkedRef.d.ts +0 -7
- package/dist/utils/hooks/useStateWithCallback.d.ts +0 -2
- package/dist/utils/isVisible.d.ts +0 -2
- package/dist/utils/time.d.ts +0 -21
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,
|
|
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
|
|
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
|
|
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
|
|
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
|
|
7073
|
-
var
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
@@ -9936,6 +9941,10 @@ function Reference(_ref) {
|
|
|
9936
9941
|
});
|
|
9937
9942
|
}
|
|
9938
9943
|
|
|
9944
|
+
var PopperManagerWrapper = function (_a) {
|
|
9945
|
+
var children = _a.children, popper = _a.popper;
|
|
9946
|
+
return popper ? React$1.createElement(Manager, null, children) : React$1.createElement(React$1.Fragment, null, children);
|
|
9947
|
+
};
|
|
9939
9948
|
var CDropdownContext = React$1.createContext({});
|
|
9940
9949
|
var CDropdown = React$1.forwardRef(function (_a, ref) {
|
|
9941
9950
|
var children = _a.children, alignment = _a.alignment, _b = _a.autoClose, autoClose = _b === void 0 ? true : _b, className = _a.className, dark = _a.dark, direction = _a.direction, onHide = _a.onHide, onShow = _a.onShow, _c = _a.placement, placement = _c === void 0 ? 'bottom-start' : _c, _d = _a.popper, popper = _d === void 0 ? true : _d, _e = _a.variant, variant = _e === void 0 ? 'btn-group' : _e, _f = _a.component, component = _f === void 0 ? 'div' : _f, _g = _a.visible, visible = _g === void 0 ? false : _g, rest = __rest$1(_a, ["children", "alignment", "autoClose", "className", "dark", "direction", "onHide", "onShow", "placement", "popper", "variant", "component", "visible"]);
|
|
@@ -9967,16 +9976,13 @@ var CDropdown = React$1.forwardRef(function (_a, ref) {
|
|
|
9967
9976
|
_visible && onShow && onShow();
|
|
9968
9977
|
!_visible && onHide && onHide();
|
|
9969
9978
|
}, [_visible]);
|
|
9970
|
-
|
|
9971
|
-
|
|
9979
|
+
return (React$1.createElement(CDropdownContext.Provider, { value: contextValues },
|
|
9980
|
+
React$1.createElement(PopperManagerWrapper, { popper: popper }, variant === 'input-group' ? (React$1.createElement(React$1.Fragment, null, children)) : (React$1.createElement(Component, __assign$1({ className: classNames$1(variant === 'nav-item' ? 'nav-item dropdown' : variant, {
|
|
9972
9981
|
'dropdown-center': direction === 'center',
|
|
9973
9982
|
'dropup dropup-center': direction === 'dropup-center',
|
|
9974
9983
|
direction: direction && direction !== 'center' && direction !== 'dropup-center',
|
|
9975
9984
|
show: _visible,
|
|
9976
|
-
}, className) }, rest, { ref: forkedRef }), children));
|
|
9977
|
-
};
|
|
9978
|
-
return (React$1.createElement(CDropdownContext.Provider, { value: contextValues }, popper ? (React$1.createElement(Manager, null,
|
|
9979
|
-
React$1.createElement(DropdownContent, null))) : (React$1.createElement(DropdownContent, null))));
|
|
9985
|
+
}, className) }, rest, { ref: forkedRef }), children)))));
|
|
9980
9986
|
});
|
|
9981
9987
|
var alignmentDirection = propTypesExports.oneOf(['start', 'end']);
|
|
9982
9988
|
CDropdown.propTypes = {
|
|
@@ -10284,7 +10290,7 @@ var isValidTime = function (time) {
|
|
|
10284
10290
|
|
|
10285
10291
|
var CTimePicker = React$1.forwardRef(function (_a, ref) {
|
|
10286
10292
|
var _b;
|
|
10287
|
-
var _c = _a.ampm, ampm = _c === void 0 ? 'auto' : _c, className = _a.className, _d = _a.cleaner, cleaner = _d === void 0 ? true : _d, _e = _a.container, container = _e === void 0 ? 'dropdown' : _e, disabled = _a.disabled, feedback = _a.feedback, feedbackInvalid = _a.feedbackInvalid, feedbackValid = _a.feedbackValid, _f = _a.footer, footer = _f === void 0 ? true : _f, id = _a.id, _g = _a.indicator, indicator = _g === void 0 ? true : _g, inputReadOnly = _a.inputReadOnly, invalid = _a.invalid, label = _a.label, _h = _a.locale, locale = _h === void 0 ? 'default' : _h, onTimeChange = _a.onTimeChange, onHide = _a.onHide, onShow = _a.onShow, _j = _a.placeholder, placeholder = _j === void 0 ? 'Select time' : _j, _k = _a.seconds, seconds = _k === void 0 ? true : _k, size = _a.size, text = _a.text, time = _a.time, tooltipFeedback = _a.tooltipFeedback, valid = _a.valid, _l = _a.variant, variant = _l === void 0 ? 'roll' : _l, visible = _a.visible, rest = __rest$1(_a, ["ampm", "className", "cleaner", "container", "disabled", "feedback", "feedbackInvalid", "feedbackValid", "footer", "id", "indicator", "inputReadOnly", "invalid", "label", "locale", "onTimeChange", "onHide", "onShow", "placeholder", "seconds", "size", "text", "time", "tooltipFeedback", "valid", "variant", "visible"]);
|
|
10293
|
+
var _c = _a.ampm, ampm = _c === void 0 ? 'auto' : _c, className = _a.className, _d = _a.cleaner, cleaner = _d === void 0 ? true : _d, _e = _a.container, container = _e === void 0 ? 'dropdown' : _e, disabled = _a.disabled, feedback = _a.feedback, feedbackInvalid = _a.feedbackInvalid, feedbackValid = _a.feedbackValid, _f = _a.footer, footer = _f === void 0 ? true : _f, id = _a.id, _g = _a.indicator, indicator = _g === void 0 ? true : _g, inputReadOnly = _a.inputReadOnly, invalid = _a.invalid, label = _a.label, _h = _a.locale, locale = _h === void 0 ? 'default' : _h, onTimeChange = _a.onTimeChange, onHide = _a.onHide, onShow = _a.onShow, _j = _a.placeholder, placeholder = _j === void 0 ? 'Select time' : _j, required = _a.required, _k = _a.seconds, seconds = _k === void 0 ? true : _k, size = _a.size, text = _a.text, time = _a.time, tooltipFeedback = _a.tooltipFeedback, valid = _a.valid, _l = _a.variant, variant = _l === void 0 ? 'roll' : _l, visible = _a.visible, rest = __rest$1(_a, ["ampm", "className", "cleaner", "container", "disabled", "feedback", "feedbackInvalid", "feedbackValid", "footer", "id", "indicator", "inputReadOnly", "invalid", "label", "locale", "onTimeChange", "onHide", "onShow", "placeholder", "required", "seconds", "size", "text", "time", "tooltipFeedback", "valid", "variant", "visible"]);
|
|
10288
10294
|
var inputRef = React$1.useRef(null);
|
|
10289
10295
|
var _m = React$1.useState(convertTimeToDate(time)), date = _m[0], setDate = _m[1];
|
|
10290
10296
|
var _o = React$1.useState(null), initialDate = _o[0], setInitialDate = _o[1];
|
|
@@ -10343,7 +10349,7 @@ var CTimePicker = React$1.forwardRef(function (_a, ref) {
|
|
|
10343
10349
|
var InputGroup = function () { return (React$1.createElement(CInputGroup, { className: "picker-input-group", size: size },
|
|
10344
10350
|
React$1.createElement(CFormInput, { autoComplete: "off", delay: true, disabled: disabled, onChange: function (event) {
|
|
10345
10351
|
return isValidTime(event.target.value) && setDate(convertTimeToDate(event.target.value));
|
|
10346
|
-
}, placeholder: placeholder, readOnly: inputReadOnly, ref: inputRef }),
|
|
10352
|
+
}, placeholder: placeholder, readOnly: inputReadOnly, required: required, ref: inputRef }),
|
|
10347
10353
|
(indicator || cleaner) && (React$1.createElement(CInputGroupText, null,
|
|
10348
10354
|
indicator && (React$1.createElement("span", { className: "picker-input-group-indicator" }, typeof indicator === 'boolean' ? (React$1.createElement("span", { className: "picker-input-group-icon time-picker-input-icon" })) : (indicator))),
|
|
10349
10355
|
cleaner && date && (React$1.createElement("span", { className: "picker-input-group-cleaner", role: "button", onClick: function (event) { return handleClear(event); } }, typeof cleaner === 'boolean' ? (React$1.createElement("span", { className: "picker-input-group-icon time-picker-cleaner-icon" })) : (cleaner))))))); };
|
|
@@ -10415,7 +10421,7 @@ var CTimePicker = React$1.forwardRef(function (_a, ref) {
|
|
|
10415
10421
|
_b['time-picker-roll'] = variant === 'roll',
|
|
10416
10422
|
_b)) }, variant === 'select' ? React$1.createElement(TimePickerSelect, null) : TimePickerRoll()))));
|
|
10417
10423
|
});
|
|
10418
|
-
CTimePicker.propTypes = __assign$1(__assign$1(__assign$1({}, CFormControlWrapper.propTypes), CPicker.propTypes), { ampm: propTypesExports.oneOfType([propTypesExports.oneOf(['auto']), propTypesExports.bool]), className: propTypesExports.string, locale: propTypesExports.string, onTimeChange: propTypesExports.func, seconds: propTypesExports.bool, time: propTypesExports.oneOfType([propTypesExports.instanceOf(Date), propTypesExports.string]), variant: propTypesExports.oneOf(['roll', 'select']) });
|
|
10424
|
+
CTimePicker.propTypes = __assign$1(__assign$1(__assign$1({}, CFormControlWrapper.propTypes), CPicker.propTypes), { ampm: propTypesExports.oneOfType([propTypesExports.oneOf(['auto']), propTypesExports.bool]), className: propTypesExports.string, locale: propTypesExports.string, onTimeChange: propTypesExports.func, required: propTypesExports.bool, seconds: propTypesExports.bool, time: propTypesExports.oneOfType([propTypesExports.instanceOf(Date), propTypesExports.string]), variant: propTypesExports.oneOf(['roll', 'select']) });
|
|
10419
10425
|
CTimePicker.displayName = 'CTimePicker';
|
|
10420
10426
|
|
|
10421
10427
|
var getLocalDateFromString = function (string, locale, time) {
|
|
@@ -10453,7 +10459,7 @@ var getLocalDateFromString = function (string, locale, time) {
|
|
|
10453
10459
|
|
|
10454
10460
|
var _a, _b, _c, _d, _e, _f;
|
|
10455
10461
|
var CDateRangePicker = React$1.forwardRef(function (_a, ref) {
|
|
10456
|
-
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, _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", "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"]);
|
|
10457
10463
|
var _q = React$1.useState(visible), _visible = _q[0], setVisible = _q[1];
|
|
10458
10464
|
var inputStartRef = React$1.useRef(null);
|
|
10459
10465
|
var inputEndRef = React$1.useRef(null);
|
|
@@ -10554,7 +10560,7 @@ var CDateRangePicker = React$1.forwardRef(function (_a, ref) {
|
|
|
10554
10560
|
var InputGroup = function () { return (React$1.createElement(CInputGroup, { className: "picker-input-group", size: size },
|
|
10555
10561
|
React$1.createElement(CFormInput, __assign$1({ autoComplete: "off", className: classNames$1({
|
|
10556
10562
|
hover: inputStartHoverValue,
|
|
10557
|
-
}), delay: true, disabled: disabled }, (id && { name: range ? "".concat(id, "-start-date") : "".concat(id, "-date") }), { placeholder: Array.isArray(placeholder) ? placeholder[0] : placeholder, readOnly: inputReadOnly || typeof format === 'string', onChange: function (event) {
|
|
10563
|
+
}), delay: true, disabled: disabled }, (id && { name: range ? "".concat(id, "-start-date") : "".concat(id, "-date") }), { placeholder: Array.isArray(placeholder) ? placeholder[0] : placeholder, readOnly: inputReadOnly || typeof format === 'string', required: required, onChange: function (event) {
|
|
10558
10564
|
var date = getLocalDateFromString(event.target.value, locale, timepicker);
|
|
10559
10565
|
if (date instanceof Date && date.getTime()) {
|
|
10560
10566
|
setCalendarDate(date);
|
|
@@ -10564,7 +10570,7 @@ var CDateRangePicker = React$1.forwardRef(function (_a, ref) {
|
|
|
10564
10570
|
range && separator !== false && (React$1.createElement(CInputGroupText, null, typeof separator === 'boolean' ? (React$1.createElement("span", { className: "picker-input-group-icon date-picker-arrow-icon" })) : (separator))),
|
|
10565
10571
|
range && (React$1.createElement(CFormInput, __assign$1({ autoComplete: "off", className: classNames$1({
|
|
10566
10572
|
hover: inputEndHoverValue,
|
|
10567
|
-
}), delay: true, disabled: disabled }, (id && { name: "".concat(id, "-end-date") }), { placeholder: placeholder[1], readOnly: inputReadOnly || typeof format === 'string', onChange: function (event) {
|
|
10573
|
+
}), delay: true, disabled: disabled }, (id && { name: "".concat(id, "-end-date") }), { placeholder: placeholder[1], readOnly: inputReadOnly || typeof format === 'string', required: required, onChange: function (event) {
|
|
10568
10574
|
var date = getLocalDateFromString(event.target.value, locale, timepicker);
|
|
10569
10575
|
if (date instanceof Date && date.getTime()) {
|
|
10570
10576
|
setCalendarDate(date);
|
|
@@ -10601,7 +10607,7 @@ var CDateRangePicker = React$1.forwardRef(function (_a, ref) {
|
|
|
10601
10607
|
handleStartDateChange(ranges[key][0]);
|
|
10602
10608
|
handleEndDateChange(ranges[key][1]);
|
|
10603
10609
|
}, size: rangesButtonsSize, variant: rangesButtonsVariant }, key)); }))),
|
|
10604
|
-
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 }),
|
|
10605
10611
|
timepicker && (React$1.createElement("div", { className: "date-picker-timepickers" }, isMobile_1 || (range && calendars === 1) ? (React$1.createElement(React$1.Fragment, null,
|
|
10606
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" }),
|
|
10607
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
|
|
@@ -10617,7 +10623,7 @@ var CDateRangePicker = React$1.forwardRef(function (_a, ref) {
|
|
|
10617
10623
|
}, time: index === 0 ? _startDate : _endDate, variant: "select" })); }))))))));
|
|
10618
10624
|
});
|
|
10619
10625
|
CDateRangePicker.displayName = 'CDateRangePicker';
|
|
10620
|
-
CDateRangePicker.propTypes = __assign$1(__assign$1(__assign$1(__assign$1({}, CCalendar.propTypes), CFormControlWrapper.propTypes), CPicker.propTypes), { calendars: propTypesExports.number, className: propTypesExports.string, cleaner: propTypesExports.bool, closeOnSelect: propTypesExports.bool, id: propTypesExports.string, indicator: propTypesExports.oneOfType([propTypesExports.bool, propTypesExports.node]), inputReadOnly: propTypesExports.bool, placeholder: propTypesExports.oneOfType([propTypesExports.string, propTypesExports.arrayOf(propTypesExports.any)]), range: propTypesExports.bool, ranges: propTypesExports.object, rangesButtonsColor: (_a = CButton.propTypes) === null || _a === void 0 ? void 0 : _a.color, rangesButtonsSize: (_b = CButton.propTypes) === null || _b === void 0 ? void 0 : _b.size, rangesButtonsVariant: (_c = CButton.propTypes) === null || _c === void 0 ? void 0 : _c.variant, separator: propTypesExports.oneOfType([propTypesExports.bool, propTypesExports.node]), size: propTypesExports.oneOf(['sm', 'lg']), timepicker: propTypesExports.bool, todayButton: propTypesExports.oneOfType([propTypesExports.bool, propTypesExports.node]), todayButtonColor: (_d = CButton.propTypes) === null || _d === void 0 ? void 0 : _d.color, todayButtonSize: (_e = CButton.propTypes) === null || _e === void 0 ? void 0 : _e.size, todayButtonVariant: (_f = CButton.propTypes) === null || _f === void 0 ? void 0 : _f.variant });
|
|
10626
|
+
CDateRangePicker.propTypes = __assign$1(__assign$1(__assign$1(__assign$1({}, CCalendar.propTypes), CFormControlWrapper.propTypes), CPicker.propTypes), { calendars: propTypesExports.number, className: propTypesExports.string, cleaner: propTypesExports.bool, closeOnSelect: propTypesExports.bool, id: propTypesExports.string, indicator: propTypesExports.oneOfType([propTypesExports.bool, propTypesExports.node]), inputReadOnly: propTypesExports.bool, placeholder: propTypesExports.oneOfType([propTypesExports.string, propTypesExports.arrayOf(propTypesExports.any)]), range: propTypesExports.bool, ranges: propTypesExports.object, rangesButtonsColor: (_a = CButton.propTypes) === null || _a === void 0 ? void 0 : _a.color, rangesButtonsSize: (_b = CButton.propTypes) === null || _b === void 0 ? void 0 : _b.size, rangesButtonsVariant: (_c = CButton.propTypes) === null || _c === void 0 ? void 0 : _c.variant, required: propTypesExports.bool, separator: propTypesExports.oneOfType([propTypesExports.bool, propTypesExports.node]), size: propTypesExports.oneOf(['sm', 'lg']), timepicker: propTypesExports.bool, todayButton: propTypesExports.oneOfType([propTypesExports.bool, propTypesExports.node]), todayButtonColor: (_d = CButton.propTypes) === null || _d === void 0 ? void 0 : _d.color, todayButtonSize: (_e = CButton.propTypes) === null || _e === void 0 ? void 0 : _e.size, todayButtonVariant: (_f = CButton.propTypes) === null || _f === void 0 ? void 0 : _f.variant });
|
|
10621
10627
|
|
|
10622
10628
|
var CDatePicker = React$1.forwardRef(function (_a, ref) {
|
|
10623
10629
|
var date = _a.date, id = _a.id, onDateChange = _a.onDateChange, _b = _a.placeholder, placeholder = _b === void 0 ? 'Select date' : _b, rest = __rest$1(_a, ["date", "id", "onDateChange", "placeholder"]);
|
|
@@ -11293,15 +11299,15 @@ var CVirtualScroller = React$1.forwardRef(function (_a, ref) {
|
|
|
11293
11299
|
setViewportPadding(Number.parseFloat(getComputedStyle(virtualScrollRef.current).paddingTop));
|
|
11294
11300
|
});
|
|
11295
11301
|
React$1.useEffect(function () {
|
|
11296
|
-
setItemsNumber(
|
|
11297
|
-
}, [children
|
|
11302
|
+
setItemsNumber(React$1.Children.count(children));
|
|
11303
|
+
}, [children]);
|
|
11298
11304
|
React$1.useEffect(function () {
|
|
11299
|
-
setViewportHeight(visibleItems * itemHeight + 2 * viewportPadding);
|
|
11300
|
-
}, [viewportPadding, visibleItems
|
|
11305
|
+
setViewportHeight(Math.min(visibleItems, itemsNumber) * itemHeight + 2 * viewportPadding);
|
|
11306
|
+
}, [itemHeight, itemsNumber, viewportPadding, visibleItems]);
|
|
11301
11307
|
React$1.useEffect(function () {
|
|
11302
|
-
setMaxHeight(itemsNumber * itemHeight
|
|
11308
|
+
setMaxHeight(itemsNumber * itemHeight);
|
|
11303
11309
|
virtualScrollRef.current && virtualScrollRef.current.scrollTop;
|
|
11304
|
-
}, [
|
|
11310
|
+
}, [itemHeight, itemsNumber]);
|
|
11305
11311
|
React$1.useEffect(function () {
|
|
11306
11312
|
setBuffer(Math.floor(visibleItems / 2));
|
|
11307
11313
|
}, [visibleItems]);
|
|
@@ -11313,7 +11319,8 @@ var CVirtualScroller = React$1.forwardRef(function (_a, ref) {
|
|
|
11313
11319
|
return (React$1.createElement("div", { className: classNames$1('virtual-scroller', className), onScroll: function (event) {
|
|
11314
11320
|
return handleScroll(event.target.scrollTop);
|
|
11315
11321
|
}, ref: forkedRef, style: {
|
|
11316
|
-
height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
|
|
11322
|
+
// height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
|
|
11323
|
+
height: viewportHeight,
|
|
11317
11324
|
overflowY: 'auto',
|
|
11318
11325
|
} },
|
|
11319
11326
|
React$1.createElement("div", { className: "virtual-scroller-content", style: {
|
|
@@ -11348,14 +11355,28 @@ CVirtualScroller.propTypes = {
|
|
|
11348
11355
|
};
|
|
11349
11356
|
CVirtualScroller.displayName = 'CVirtualScroller';
|
|
11350
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
|
+
};
|
|
11351
11374
|
var filterOptionsList = function (search, _options) {
|
|
11352
11375
|
return search.length > 0
|
|
11353
11376
|
? _options &&
|
|
11354
11377
|
_options.reduce(function (acc, val) {
|
|
11355
11378
|
var options = val.options &&
|
|
11356
|
-
val.options.filter(function (element) {
|
|
11357
|
-
return element.text && element.text.toLowerCase().includes(search.toLowerCase());
|
|
11358
|
-
});
|
|
11379
|
+
val.options.filter(function (element) { return element.text && element.text.toLowerCase().includes(search.toLowerCase()); });
|
|
11359
11380
|
if ((val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
|
|
11360
11381
|
(options && options.length > 0)) {
|
|
11361
11382
|
acc.push(Object.assign({}, val, options && options.length > 0 && { options: options }));
|
|
@@ -11416,7 +11437,7 @@ var selectOptions = function (options, selected, deselected) {
|
|
|
11416
11437
|
};
|
|
11417
11438
|
|
|
11418
11439
|
var CMultiSelectOptions = React$1.forwardRef(function (_a, ref) {
|
|
11419
|
-
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;
|
|
11420
11441
|
var handleKeyDown = function (event, option) {
|
|
11421
11442
|
if (event.code === 'Space' || event.key === 'Enter') {
|
|
11422
11443
|
event.preventDefault();
|
|
@@ -11451,12 +11472,15 @@ var CMultiSelectOptions = React$1.forwardRef(function (_a, ref) {
|
|
|
11451
11472
|
}), key: index, onClick: function () { return handleOptionOnClick && handleOptionOnClick(option); }, onKeyDown: function (event) { return handleKeyDown(event, option); }, tabIndex: 0 }, option.text));
|
|
11452
11473
|
})) : (React$1.createElement("div", { className: "form-multi-select-options-empty" }, searchNoResultsLabel));
|
|
11453
11474
|
};
|
|
11454
|
-
return
|
|
11455
|
-
|
|
11456
|
-
|
|
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)));
|
|
11457
11480
|
});
|
|
11458
11481
|
CMultiSelectOptions.propTypes = {
|
|
11459
11482
|
handleOptionOnClick: propTypesExports.func,
|
|
11483
|
+
loading: propTypesExports.bool,
|
|
11460
11484
|
options: propTypesExports.array.isRequired,
|
|
11461
11485
|
optionsMaxHeight: propTypesExports.oneOfType([propTypesExports.number, propTypesExports.string]),
|
|
11462
11486
|
optionsStyle: propTypesExports.oneOf(['checkbox', 'text']),
|
|
@@ -11499,14 +11523,27 @@ CMultiSelectSelection.displayName = 'CMultiSelectSelection';
|
|
|
11499
11523
|
|
|
11500
11524
|
var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
11501
11525
|
var _b;
|
|
11502
|
-
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"]);
|
|
11503
11527
|
var isInitialMount = React$1.useRef(true);
|
|
11504
11528
|
var nativeSelectRef = React$1.useRef(null);
|
|
11505
11529
|
var searchRef = React$1.useRef(null);
|
|
11506
11530
|
var _r = React$1.useState(options), _options = _r[0], setOptions = _r[1];
|
|
11507
|
-
var _s = React$1.useState(
|
|
11508
|
-
var _t = React$1.useState(
|
|
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];
|
|
11509
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]);
|
|
11510
11547
|
React$1.useMemo(function () {
|
|
11511
11548
|
setOptions(options);
|
|
11512
11549
|
var _selected = options &&
|
|
@@ -11525,6 +11562,9 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
|
11525
11562
|
});
|
|
11526
11563
|
_selected && setSelected(selectOptions(_selected, selected, deselected));
|
|
11527
11564
|
}, [JSON.stringify(options)]);
|
|
11565
|
+
React$1.useEffect(function () {
|
|
11566
|
+
!isInitialMount.current && onFilterChange && onFilterChange(searchValue);
|
|
11567
|
+
}, [searchValue]);
|
|
11528
11568
|
React$1.useEffect(function () {
|
|
11529
11569
|
!isInitialMount.current &&
|
|
11530
11570
|
nativeSelectRef.current &&
|
|
@@ -11534,14 +11574,27 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
|
11534
11574
|
isInitialMount.current = false;
|
|
11535
11575
|
}, []);
|
|
11536
11576
|
var handleSearchChange = function (event) {
|
|
11537
|
-
var
|
|
11538
|
-
|
|
11539
|
-
setSearch(target.value.toLowerCase());
|
|
11540
|
-
}
|
|
11541
|
-
onFilterChange && onFilterChange(target.value);
|
|
11577
|
+
var value = event.target.value;
|
|
11578
|
+
setSearchValue(value);
|
|
11542
11579
|
};
|
|
11543
11580
|
var handleSearchKeyDown = function (event) {
|
|
11544
|
-
if (
|
|
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) {
|
|
11545
11598
|
return;
|
|
11546
11599
|
}
|
|
11547
11600
|
if (event.key === 'Backspace' || event.key === 'Delete') {
|
|
@@ -11553,12 +11606,22 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
|
11553
11606
|
if (!multiple) {
|
|
11554
11607
|
setSelected([{ value: option.value, text: option.text }]);
|
|
11555
11608
|
setVisible(false);
|
|
11556
|
-
|
|
11609
|
+
setSearchValue('');
|
|
11557
11610
|
if (searchRef.current) {
|
|
11558
11611
|
searchRef.current.value = '';
|
|
11559
11612
|
}
|
|
11560
11613
|
return;
|
|
11561
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
|
+
}
|
|
11562
11625
|
if (selected.some(function (_option) { return _option.value === option.value; })) {
|
|
11563
11626
|
setSelected(selected.filter(function (_option) { return _option.value !== option.value; }));
|
|
11564
11627
|
}
|
|
@@ -11567,7 +11630,7 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
|
11567
11630
|
}
|
|
11568
11631
|
};
|
|
11569
11632
|
var handleSelectAll = function () {
|
|
11570
|
-
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));
|
|
11571
11634
|
};
|
|
11572
11635
|
var handleDeselectAll = function () {
|
|
11573
11636
|
setSelected(selected.filter(function (option) { return option.disabled; }));
|
|
@@ -11597,12 +11660,14 @@ var CMultiSelect = React$1.forwardRef(function (_a, ref) {
|
|
|
11597
11660
|
}), (selected.length > 0 &&
|
|
11598
11661
|
!multiple && { placeholder: selected.map(function (option) { return option.text; })[0] }), (multiple &&
|
|
11599
11662
|
selected.length > 0 &&
|
|
11600
|
-
selectionType !== 'counter' && { size:
|
|
11663
|
+
selectionType !== 'counter' && { size: searchValue.length + 2 }), { ref: searchRef })))), visible: _visible, ref: ref },
|
|
11601
11664
|
React$1.createElement(React$1.Fragment, null,
|
|
11602
11665
|
multiple && selectAll && (React$1.createElement("button", { type: "button", className: "form-multi-select-all", onClick: function () { return handleSelectAll(); } }, selectAllLabel)),
|
|
11603
|
-
React$1.createElement(CMultiSelectOptions, { handleOptionOnClick: function (option) { return !disabled && handleOptionOnClick(option); },
|
|
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 })))));
|
|
11604
11669
|
});
|
|
11605
|
-
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);
|
|
11606
11671
|
CMultiSelect.displayName = 'CMultiSelect';
|
|
11607
11672
|
|
|
11608
11673
|
var CNav = React$1.forwardRef(function (_a, ref) {
|