@coreui/react-pro 4.13.2 → 4.14.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.13.2.zip)
45
+ - [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v4.14.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`
@@ -87,6 +87,24 @@ export interface CDateRangePickerProps extends Omit<CFormControlWrapperProps, 'f
87
87
  * Toggle visibility or set the content of the input indicator.
88
88
  */
89
89
  indicator?: ReactNode | boolean;
90
+ /**
91
+ * Custom function to format the selected date into a string according to a custom format.
92
+ *
93
+ * @since v4.14.0
94
+ */
95
+ inputDateFormat?: (date: Date) => string;
96
+ /**
97
+ * Custom function to parse the input value into a valid Date object.
98
+ *
99
+ * @since v4.14.0
100
+ */
101
+ inputDateParse?: (date: string | Date) => Date;
102
+ /**
103
+ * Defines the delay (in milliseconds) for the input field's onChange event.
104
+ *
105
+ * @since v4.14.0
106
+ */
107
+ inputOnChangeDelay?: number;
90
108
  /**
91
109
  * Toggle the readonly state for the component.
92
110
  */
@@ -1,4 +1,6 @@
1
+ import { useDebouncedCallback } from './useDebouncedCallback';
1
2
  import { useForkedRef } from './useForkedRef';
3
+ import { useIsVisible } from './useIsVisible';
2
4
  import { usePopper } from './usePopper';
3
5
  import { useStateWithCallback } from './useStateWithCallback';
4
- export { useForkedRef, usePopper, useStateWithCallback };
6
+ export { useDebouncedCallback, useForkedRef, useIsVisible, usePopper, useStateWithCallback };
@@ -0,0 +1 @@
1
+ export declare const useDebouncedCallback: <F extends Function>(callback: F, delay: number) => (...args: any[]) => void;
@@ -0,0 +1,2 @@
1
+ import { RefObject } from 'react';
2
+ export declare const useIsVisible: (ref: RefObject<HTMLElement>) => boolean;
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import React$1, { createContext, forwardRef, useState, useRef, useContext, useEffect, useMemo, Children, useLayoutEffect } from 'react';
1
+ import React$1, { createContext, forwardRef, useState, useRef, useContext, useEffect, useCallback, useMemo, Children, useLayoutEffect } from 'react';
2
2
  import ReactDOM, { createPortal } from 'react-dom';
3
3
 
4
4
  /******************************************************************************
@@ -2477,6 +2477,22 @@ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends$1({},
2477
2477
  }) : {};
2478
2478
  var CSSTransition$1 = CSSTransition;
2479
2479
 
2480
+ var useDebouncedCallback = function (callback, delay) {
2481
+ var timeout = useRef();
2482
+ return useCallback(function () {
2483
+ var args = [];
2484
+ for (var _i = 0; _i < arguments.length; _i++) {
2485
+ args[_i] = arguments[_i];
2486
+ }
2487
+ var handler = function () {
2488
+ clearTimeout(timeout.current);
2489
+ callback.apply(void 0, args);
2490
+ };
2491
+ clearTimeout(timeout.current);
2492
+ timeout.current = setTimeout(handler, delay);
2493
+ }, [callback, delay]);
2494
+ };
2495
+
2480
2496
  // code borrowed from https://github.com/reach/reach-ui
2481
2497
  // problem described https://github.com/facebook/react/issues/13029
2482
2498
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -2520,6 +2536,19 @@ function isFunction(value) {
2520
2536
  return !!(value && {}.toString.call(value) == '[object Function]');
2521
2537
  }
2522
2538
 
2539
+ var useIsVisible = function (ref) {
2540
+ var _a = useState(false), isIntersecting = _a[0], setIntersecting = _a[1];
2541
+ useEffect(function () {
2542
+ var observer = new IntersectionObserver(function (_a) {
2543
+ var entry = _a[0];
2544
+ return setIntersecting(entry.isIntersecting);
2545
+ });
2546
+ ref.current && observer.observe(ref.current);
2547
+ return function () { return observer.disconnect(); };
2548
+ }, []);
2549
+ return isIntersecting;
2550
+ };
2551
+
2523
2552
  var top = 'top';
2524
2553
  var bottom = 'bottom';
2525
2554
  var right = 'right';
@@ -9143,17 +9172,20 @@ var CTimePickerRollCol = forwardRef(function (_a, ref) {
9143
9172
  var init = useRef(true);
9144
9173
  var colRef = useRef(null);
9145
9174
  var forkedRef = useForkedRef(ref, colRef);
9175
+ var isVisible = useIsVisible(colRef);
9146
9176
  useEffect(function () {
9147
9177
  var _a, _b;
9148
9178
  var nodeEl = (_a = colRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.selected');
9149
- if (nodeEl && nodeEl instanceof HTMLElement) {
9179
+ if (isVisible && nodeEl && nodeEl instanceof HTMLElement) {
9150
9180
  (_b = colRef.current) === null || _b === void 0 ? void 0 : _b.scrollTo({
9151
9181
  top: nodeEl.offsetTop,
9152
9182
  behavior: init.current ? 'auto' : 'smooth',
9153
9183
  });
9154
9184
  }
9155
- init.current = false;
9156
- }, [selected]);
9185
+ if (isVisible) {
9186
+ init.current = false;
9187
+ }
9188
+ }, [isVisible, selected]);
9157
9189
  var handleKeyDown = function (event, value) {
9158
9190
  if (event.code === 'Space' || event.key === 'Enter') {
9159
9191
  event.preventDefault();
@@ -9263,7 +9295,7 @@ var CTimePicker = forwardRef(function (_a, ref) {
9263
9295
  hour12: false,
9264
9296
  }), localizedTimePartials = _0[0], setLocalizedTimePartials = _0[1];
9265
9297
  useEffect(function () {
9266
- setDate(convertTimeToDate(time));
9298
+ setDate(time ? convertTimeToDate(time) : null);
9267
9299
  }, [time]);
9268
9300
  useEffect(function () {
9269
9301
  setIsValid(valid !== null && valid !== void 0 ? valid : (invalid === true ? false : undefined));
@@ -9367,14 +9399,6 @@ var CTimePicker = forwardRef(function (_a, ref) {
9367
9399
  React$1.createElement("option", { value: "am" }, "AM"),
9368
9400
  React$1.createElement("option", { value: "pm" }, "PM")))));
9369
9401
  };
9370
- var TimePickerRoll = function () { return (React$1.createElement(React$1.Fragment, null,
9371
- React$1.createElement(CTimePickerRollCol, { elements: localizedTimePartials && localizedTimePartials.listOfHours, onClick: function (index) { return handleTimeChange('hours', index.toString()); }, selected: getSelectedHour(date, locale, ampm) }),
9372
- React$1.createElement(CTimePickerRollCol, { elements: localizedTimePartials && localizedTimePartials.listOfMinutes, onClick: function (index) { return handleTimeChange('minutes', index.toString()); }, selected: getSelectedMinutes(date) }),
9373
- seconds && (React$1.createElement(CTimePickerRollCol, { elements: localizedTimePartials && localizedTimePartials.listOfSeconds, onClick: function (index) { return handleTimeChange('seconds', index.toString()); }, selected: getSelectedSeconds(date) })),
9374
- localizedTimePartials && localizedTimePartials.hour12 && (React$1.createElement(CTimePickerRollCol, { elements: [
9375
- { value: 'am', label: 'AM' },
9376
- { value: 'pm', label: 'PM' },
9377
- ], onClick: function (value) { return handleTimeChange('toggle', value); }, selected: _ampm })))); };
9378
9402
  return (React$1.createElement(CFormControlWrapper, { describedby: rest['aria-describedby'], feedback: feedback, feedbackInvalid: feedbackInvalid, feedbackValid: feedbackValid, id: id, invalid: isValid === false ? true : false, label: label, text: text, tooltipFeedback: tooltipFeedback, valid: isValid },
9379
9403
  React$1.createElement(CPicker, __assign$1({ className: classNames$1('time-picker', (_b = {},
9380
9404
  _b["time-picker-".concat(size)] = size,
@@ -9398,7 +9422,14 @@ var CTimePicker = forwardRef(function (_a, ref) {
9398
9422
  }, toggler: InputGroup(), visible: _visible }, rest, { ref: ref }),
9399
9423
  React$1.createElement("div", { className: classNames$1('time-picker-body', (_c = {},
9400
9424
  _c['time-picker-roll'] = variant === 'roll',
9401
- _c)) }, variant === 'select' ? React$1.createElement(TimePickerSelect, null) : TimePickerRoll()))));
9425
+ _c)) }, variant === 'select' ? (React$1.createElement(TimePickerSelect, null)) : (React$1.createElement(React$1.Fragment, null,
9426
+ React$1.createElement(CTimePickerRollCol, { elements: localizedTimePartials && localizedTimePartials.listOfHours, onClick: function (index) { return handleTimeChange('hours', index.toString()); }, selected: getSelectedHour(date, locale, ampm) }),
9427
+ React$1.createElement(CTimePickerRollCol, { elements: localizedTimePartials && localizedTimePartials.listOfMinutes, onClick: function (index) { return handleTimeChange('minutes', index.toString()); }, selected: getSelectedMinutes(date) }),
9428
+ seconds && (React$1.createElement(CTimePickerRollCol, { elements: localizedTimePartials && localizedTimePartials.listOfSeconds, onClick: function (index) { return handleTimeChange('seconds', index.toString()); }, selected: getSelectedSeconds(date) })),
9429
+ localizedTimePartials && localizedTimePartials.hour12 && (React$1.createElement(CTimePickerRollCol, { elements: [
9430
+ { value: 'am', label: 'AM' },
9431
+ { value: 'pm', label: 'PM' },
9432
+ ], onClick: function (value) { return handleTimeChange('toggle', value); }, selected: _ampm }))))))));
9402
9433
  });
9403
9434
  CTimePicker.propTypes = __assign$1(__assign$1(__assign$1({}, CFormControlWrapper.propTypes), CPicker.propTypes), { ampm: PropTypes$1.oneOfType([PropTypes$1.oneOf(['auto']), PropTypes$1.bool]), cancelButton: PropTypes$1.oneOfType([PropTypes$1.bool, PropTypes$1.node]), cancelButtonColor: (_a$1 = CButton.propTypes) === null || _a$1 === void 0 ? void 0 : _a$1.color, cancelButtonSize: (_b$1 = CButton.propTypes) === null || _b$1 === void 0 ? void 0 : _b$1.size, cancelButtonVariant: (_c$1 = CButton.propTypes) === null || _c$1 === void 0 ? void 0 : _c$1.variant, className: PropTypes$1.string, confirmButton: PropTypes$1.oneOfType([PropTypes$1.bool, PropTypes$1.node]), confirmButtonColor: (_d$1 = CButton.propTypes) === null || _d$1 === void 0 ? void 0 : _d$1.color, confirmButtonSize: (_e$1 = CButton.propTypes) === null || _e$1 === void 0 ? void 0 : _e$1.size, confirmButtonVariant: (_f$1 = CButton.propTypes) === null || _f$1 === void 0 ? void 0 : _f$1.variant, locale: PropTypes$1.string, onTimeChange: PropTypes$1.func, required: PropTypes$1.bool, seconds: PropTypes$1.bool, time: PropTypes$1.oneOfType([PropTypes$1.instanceOf(Date), PropTypes$1.string]), variant: PropTypes$1.oneOf(['roll', 'select']) });
9404
9435
  CTimePicker.displayName = 'CTimePicker';
@@ -9439,36 +9470,32 @@ var getLocalDateFromString = function (string, locale, time) {
9439
9470
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
9440
9471
  var CDateRangePicker = forwardRef(function (_a, ref) {
9441
9472
  var _b;
9442
- var _c = _a.calendars, calendars = _c === void 0 ? 2 : _c, calendarDate = _a.calendarDate, _d = _a.cancelButton, cancelButton = _d === void 0 ? 'Cancel' : _d, _e = _a.cancelButtonColor, cancelButtonColor = _e === void 0 ? 'primary' : _e, _f = _a.cancelButtonSize, cancelButtonSize = _f === void 0 ? 'sm' : _f, _g = _a.cancelButtonVariant, cancelButtonVariant = _g === void 0 ? 'ghost' : _g, className = _a.className, _h = _a.cleaner, cleaner = _h === void 0 ? true : _h, _j = _a.closeOnSelect, closeOnSelect = _j === void 0 ? true : _j, _k = _a.confirmButton, confirmButton = _k === void 0 ? 'OK' : _k, _l = _a.confirmButtonColor, confirmButtonColor = _l === void 0 ? 'primary' : _l, _m = _a.confirmButtonSize, confirmButtonSize = _m === void 0 ? 'sm' : _m, confirmButtonVariant = _a.confirmButtonVariant, _o = _a.indicator, indicator = _o === void 0 ? true : _o, 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$1 = _a.format, footer = _a.footer, id = _a.id, inputReadOnly = _a.inputReadOnly, invalid = _a.invalid, label = _a.label, _p = _a.locale, locale = _p === void 0 ? 'default' : _p, maxDate = _a.maxDate, minDate = _a.minDate, navigation = _a.navigation, navYearFirst = _a.navYearFirst, onEndDateChange = _a.onEndDateChange, onHide = _a.onHide, onStartDateChange = _a.onStartDateChange, onShow = _a.onShow, _q = _a.placeholder, placeholder = _q === void 0 ? ['Start date', 'End date'] : _q, _r = _a.range, range = _r === void 0 ? true : _r, ranges = _a.ranges, _s = _a.rangesButtonsColor, rangesButtonsColor = _s === void 0 ? 'secondary' : _s, rangesButtonsSize = _a.rangesButtonsSize, _t = _a.rangesButtonsVariant, rangesButtonsVariant = _t === void 0 ? 'ghost' : _t, required = _a.required, _u = _a.separator, separator = _u === void 0 ? true : _u, selectAdjacementDays = _a.selectAdjacementDays, showAdjacementDays = _a.showAdjacementDays, size = _a.size, startDate = _a.startDate, text = _a.text, timepicker = _a.timepicker, toggler = _a.toggler, _v = _a.todayButton, todayButton = _v === void 0 ? 'Today' : _v, _w = _a.todayButtonColor, todayButtonColor = _w === void 0 ? 'primary' : _w, _x = _a.todayButtonSize, todayButtonSize = _x === void 0 ? 'sm' : _x, todayButtonVariant = _a.todayButtonVariant, tooltipFeedback = _a.tooltipFeedback, valid = _a.valid, visible = _a.visible, weekdayFormat = _a.weekdayFormat, rest = __rest$1(_a, ["calendars", "calendarDate", "cancelButton", "cancelButtonColor", "cancelButtonSize", "cancelButtonVariant", "className", "cleaner", "closeOnSelect", "confirmButton", "confirmButtonColor", "confirmButtonSize", "confirmButtonVariant", "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"]);
9473
+ var _c = _a.calendars, calendars = _c === void 0 ? 2 : _c, calendarDate = _a.calendarDate, _d = _a.cancelButton, cancelButton = _d === void 0 ? 'Cancel' : _d, _e = _a.cancelButtonColor, cancelButtonColor = _e === void 0 ? 'primary' : _e, _f = _a.cancelButtonSize, cancelButtonSize = _f === void 0 ? 'sm' : _f, _g = _a.cancelButtonVariant, cancelButtonVariant = _g === void 0 ? 'ghost' : _g, className = _a.className, _h = _a.cleaner, cleaner = _h === void 0 ? true : _h, _j = _a.closeOnSelect, closeOnSelect = _j === void 0 ? true : _j, _k = _a.confirmButton, confirmButton = _k === void 0 ? 'OK' : _k, _l = _a.confirmButtonColor, confirmButtonColor = _l === void 0 ? 'primary' : _l, _m = _a.confirmButtonSize, confirmButtonSize = _m === void 0 ? 'sm' : _m, confirmButtonVariant = _a.confirmButtonVariant, 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$1 = _a.format, footer = _a.footer, id = _a.id, _o = _a.indicator, indicator = _o === void 0 ? true : _o, inputDateFormat = _a.inputDateFormat, inputDateParse = _a.inputDateParse, _p = _a.inputOnChangeDelay, inputOnChangeDelay = _p === void 0 ? 750 : _p, inputReadOnly = _a.inputReadOnly, invalid = _a.invalid, label = _a.label, _q = _a.locale, locale = _q === void 0 ? 'default' : _q, maxDate = _a.maxDate, minDate = _a.minDate, navigation = _a.navigation, navYearFirst = _a.navYearFirst, onEndDateChange = _a.onEndDateChange, onHide = _a.onHide, onStartDateChange = _a.onStartDateChange, onShow = _a.onShow, _r = _a.placeholder, placeholder = _r === void 0 ? ['Start date', 'End date'] : _r, _s = _a.range, range = _s === void 0 ? true : _s, ranges = _a.ranges, _t = _a.rangesButtonsColor, rangesButtonsColor = _t === void 0 ? 'secondary' : _t, rangesButtonsSize = _a.rangesButtonsSize, _u = _a.rangesButtonsVariant, rangesButtonsVariant = _u === void 0 ? 'ghost' : _u, required = _a.required, _v = _a.separator, separator = _v === void 0 ? true : _v, selectAdjacementDays = _a.selectAdjacementDays, showAdjacementDays = _a.showAdjacementDays, size = _a.size, startDate = _a.startDate, text = _a.text, timepicker = _a.timepicker, toggler = _a.toggler, _w = _a.todayButton, todayButton = _w === void 0 ? 'Today' : _w, _x = _a.todayButtonColor, todayButtonColor = _x === void 0 ? 'primary' : _x, _y = _a.todayButtonSize, todayButtonSize = _y === void 0 ? 'sm' : _y, todayButtonVariant = _a.todayButtonVariant, tooltipFeedback = _a.tooltipFeedback, valid = _a.valid, visible = _a.visible, weekdayFormat = _a.weekdayFormat, rest = __rest$1(_a, ["calendars", "calendarDate", "cancelButton", "cancelButtonColor", "cancelButtonSize", "cancelButtonVariant", "className", "cleaner", "closeOnSelect", "confirmButton", "confirmButtonColor", "confirmButtonSize", "confirmButtonVariant", "dayFormat", "disabled", "disabledDates", "endDate", "feedback", "feedbackInvalid", "feedbackValid", "firstDayOfWeek", "format", "footer", "id", "indicator", "inputDateFormat", "inputDateParse", "inputOnChangeDelay", "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"]);
9443
9474
  var inputEndRef = useRef(null);
9444
9475
  var inputStartRef = useRef(null);
9445
9476
  var formRef = useRef();
9446
- var _y = useState(calendarDate ? new Date(calendarDate) : new Date()), _calendarDate = _y[0], setCalendarDate = _y[1];
9447
- var _z = useState(endDate ? new Date(endDate) : null), _endDate = _z[0], setEndDate = _z[1];
9448
- var _0 = useState(maxDate ? new Date(maxDate) : null), _maxDate = _0[0], setMaxDate = _0[1];
9449
- var _1 = useState(minDate ? new Date(minDate) : null), _minDate = _1[0], setMinDate = _1[1];
9450
- var _2 = useState(startDate ? new Date(startDate) : null), _startDate = _2[0], setStartDate = _2[1];
9451
- var _3 = useState(visible), _visible = _3[0], setVisible = _3[1];
9452
- var _4 = useState(startDate ? new Date(startDate) : null), initialStartDate = _4[0], setInitialStartDate = _4[1];
9453
- var _5 = useState(endDate ? new Date(endDate) : null), initialEndDate = _5[0], setInitialEndDate = _5[1];
9454
- var _6 = useState(null), inputStartHoverValue = _6[0], setInputStartHoverValue = _6[1];
9455
- var _7 = useState(null), inputEndHoverValue = _7[0], setInputEndHoverValue = _7[1];
9456
- var _8 = useState(valid !== null && valid !== void 0 ? valid : (invalid === true ? false : undefined)), isValid = _8[0], setIsValid = _8[1];
9457
- var _9 = useState(false), selectEndDate = _9[0], setSelectEndDate = _9[1];
9477
+ var _z = useState(calendarDate ? new Date(calendarDate) : new Date()), _calendarDate = _z[0], setCalendarDate = _z[1];
9478
+ var _0 = useState(endDate ? new Date(endDate) : null), _endDate = _0[0], setEndDate = _0[1];
9479
+ var _1 = useState(maxDate ? new Date(maxDate) : null), _maxDate = _1[0], setMaxDate = _1[1];
9480
+ var _2 = useState(minDate ? new Date(minDate) : null), _minDate = _2[0], setMinDate = _2[1];
9481
+ var _3 = useState(startDate ? new Date(startDate) : null), _startDate = _3[0], setStartDate = _3[1];
9482
+ var _4 = useState(visible), _visible = _4[0], setVisible = _4[1];
9483
+ var _5 = useState(startDate ? new Date(startDate) : null), initialStartDate = _5[0], setInitialStartDate = _5[1];
9484
+ var _6 = useState(endDate ? new Date(endDate) : null), initialEndDate = _6[0], setInitialEndDate = _6[1];
9485
+ var _7 = useState(null), inputStartHoverValue = _7[0], setInputStartHoverValue = _7[1];
9486
+ var _8 = useState(null), inputEndHoverValue = _8[0], setInputEndHoverValue = _8[1];
9487
+ var _9 = useState(valid !== null && valid !== void 0 ? valid : (invalid === true ? false : undefined)), isValid = _9[0], setIsValid = _9[1];
9488
+ var _10 = useState(false), selectEndDate = _10[0], setSelectEndDate = _10[1];
9458
9489
  useEffect(function () {
9459
9490
  setIsValid(valid !== null && valid !== void 0 ? valid : (invalid === true ? false : undefined));
9460
9491
  }, [valid, invalid]);
9461
9492
  useEffect(function () {
9462
- if (startDate) {
9463
- setStartDate(new Date(startDate));
9464
- setCalendarDate(new Date(startDate));
9465
- }
9493
+ setStartDate(startDate ? new Date(startDate) : null);
9494
+ setCalendarDate(startDate ? new Date(startDate) : new Date());
9466
9495
  }, [startDate]);
9467
9496
  useEffect(function () {
9468
- if (endDate) {
9469
- setEndDate(new Date(endDate));
9470
- setCalendarDate(new Date(endDate));
9471
- }
9497
+ setEndDate(endDate ? new Date(endDate) : null);
9498
+ setCalendarDate(endDate ? new Date(endDate) : new Date());
9472
9499
  }, [endDate]);
9473
9500
  useEffect(function () {
9474
9501
  maxDate && setMaxDate(new Date(maxDate));
@@ -9504,11 +9531,13 @@ var CDateRangePicker = forwardRef(function (_a, ref) {
9504
9531
  }
9505
9532
  }, [formRef, _startDate, _endDate]);
9506
9533
  var formatDate = function (date) {
9507
- return format$1
9508
- ? format(date, format$1)
9509
- : timepicker
9510
- ? date.toLocaleString(locale)
9511
- : date.toLocaleDateString(locale);
9534
+ return inputDateFormat
9535
+ ? inputDateFormat(date)
9536
+ : format$1
9537
+ ? format(date, format$1)
9538
+ : timepicker
9539
+ ? date.toLocaleString(locale)
9540
+ : date.toLocaleDateString(locale);
9512
9541
  };
9513
9542
  var setInputValue = function (el, date) {
9514
9543
  if (!el) {
@@ -9564,6 +9593,15 @@ var CDateRangePicker = forwardRef(function (_a, ref) {
9564
9593
  setVisible(false);
9565
9594
  }
9566
9595
  };
9596
+ var handleOnChange = useDebouncedCallback(function (value, input) {
9597
+ var date = inputDateParse
9598
+ ? inputDateParse(value)
9599
+ : getLocalDateFromString(value, locale, timepicker);
9600
+ if (date instanceof Date && date.getTime()) {
9601
+ setCalendarDate(date);
9602
+ input === 'start' ? setStartDate(date) : setEndDate(date);
9603
+ }
9604
+ }, inputOnChangeDelay);
9567
9605
  var InputGroup = function () {
9568
9606
  var _a;
9569
9607
  return (React$1.createElement("div", { className: classNames$1('input-group', 'picker-input-group', (_a = {},
@@ -9572,22 +9610,14 @@ var CDateRangePicker = forwardRef(function (_a, ref) {
9572
9610
  React$1.createElement("input", __assign$1({ autoComplete: "off", className: classNames$1('form-control date-picker-input', {
9573
9611
  hover: inputStartHoverValue,
9574
9612
  }), disabled: disabled }, (id && { name: range ? "".concat(id, "-start-date") : "".concat(id, "-date") }), { placeholder: Array.isArray(placeholder) ? placeholder[0] : placeholder, readOnly: inputReadOnly || typeof format$1 === 'string', required: required, onChange: function (event) {
9575
- var date = getLocalDateFromString(event.target.value, locale, timepicker);
9576
- if (date instanceof Date && date.getTime()) {
9577
- setCalendarDate(date);
9578
- setStartDate(date);
9579
- }
9613
+ handleOnChange(event.target.value, 'start');
9580
9614
  }, onClick: function () { return setSelectEndDate(false); }, ref: inputStartRef })),
9581
9615
  range && separator !== false && (React$1.createElement("span", { className: "input-group-text" },
9582
9616
  React$1.createElement("span", { className: "picker-input-group-icon date-picker-arrow-icon" }))),
9583
9617
  range && (React$1.createElement("input", __assign$1({ autoComplete: "off", className: classNames$1('form-control date-picker-input', {
9584
9618
  hover: inputEndHoverValue,
9585
9619
  }), disabled: disabled }, (id && { name: "".concat(id, "-end-date") }), { placeholder: placeholder[1], readOnly: inputReadOnly || typeof format$1 === 'string', required: required, onChange: function (event) {
9586
- var date = getLocalDateFromString(event.target.value, locale, timepicker);
9587
- if (date instanceof Date && date.getTime()) {
9588
- setCalendarDate(date);
9589
- setEndDate(date);
9590
- }
9620
+ handleOnChange(event.target.value, 'end');
9591
9621
  }, onClick: function () { return setSelectEndDate(true); }, ref: inputEndRef }))),
9592
9622
  (indicator || cleaner) && (React$1.createElement("span", { className: "input-group-text" },
9593
9623
  indicator && (React$1.createElement("span", { className: "picker-input-group-indicator" }, typeof indicator === 'boolean' ? (React$1.createElement("span", { className: "picker-input-group-icon date-picker-input-icon" })) : (indicator))),
@@ -9643,7 +9673,7 @@ var CDateRangePicker = forwardRef(function (_a, ref) {
9643
9673
  }, time: index === 0 ? _startDate : _endDate, variant: "select" })); }))))))));
9644
9674
  });
9645
9675
  CDateRangePicker.displayName = 'CDateRangePicker';
9646
- CDateRangePicker.propTypes = __assign$1(__assign$1(__assign$1(__assign$1({}, CCalendar.propTypes), CFormControlWrapper.propTypes), CPicker.propTypes), { cancelButton: PropTypes$1.oneOfType([PropTypes$1.bool, PropTypes$1.node]), cancelButtonColor: (_a = CButton.propTypes) === null || _a === void 0 ? void 0 : _a.color, cancelButtonSize: (_b = CButton.propTypes) === null || _b === void 0 ? void 0 : _b.size, cancelButtonVariant: (_c = CButton.propTypes) === null || _c === void 0 ? void 0 : _c.variant, calendars: PropTypes$1.number, className: PropTypes$1.string, cleaner: PropTypes$1.bool, closeOnSelect: PropTypes$1.bool, confirmButton: PropTypes$1.oneOfType([PropTypes$1.bool, PropTypes$1.node]), confirmButtonColor: (_d = CButton.propTypes) === null || _d === void 0 ? void 0 : _d.color, confirmButtonSize: (_e = CButton.propTypes) === null || _e === void 0 ? void 0 : _e.size, confirmButtonVariant: (_f = CButton.propTypes) === null || _f === void 0 ? void 0 : _f.variant, id: PropTypes$1.string, indicator: PropTypes$1.oneOfType([PropTypes$1.bool, PropTypes$1.node]), inputReadOnly: PropTypes$1.bool, placeholder: PropTypes$1.oneOfType([
9676
+ CDateRangePicker.propTypes = __assign$1(__assign$1(__assign$1(__assign$1({}, CCalendar.propTypes), CFormControlWrapper.propTypes), CPicker.propTypes), { cancelButton: PropTypes$1.oneOfType([PropTypes$1.bool, PropTypes$1.node]), cancelButtonColor: (_a = CButton.propTypes) === null || _a === void 0 ? void 0 : _a.color, cancelButtonSize: (_b = CButton.propTypes) === null || _b === void 0 ? void 0 : _b.size, cancelButtonVariant: (_c = CButton.propTypes) === null || _c === void 0 ? void 0 : _c.variant, calendars: PropTypes$1.number, className: PropTypes$1.string, cleaner: PropTypes$1.bool, closeOnSelect: PropTypes$1.bool, confirmButton: PropTypes$1.oneOfType([PropTypes$1.bool, PropTypes$1.node]), confirmButtonColor: (_d = CButton.propTypes) === null || _d === void 0 ? void 0 : _d.color, confirmButtonSize: (_e = CButton.propTypes) === null || _e === void 0 ? void 0 : _e.size, confirmButtonVariant: (_f = CButton.propTypes) === null || _f === void 0 ? void 0 : _f.variant, id: PropTypes$1.string, indicator: PropTypes$1.oneOfType([PropTypes$1.bool, PropTypes$1.node]), inputDateFormat: PropTypes$1.func, inputDateParse: PropTypes$1.func, inputOnChangeDelay: PropTypes$1.number, inputReadOnly: PropTypes$1.bool, placeholder: PropTypes$1.oneOfType([
9647
9677
  PropTypes$1.string,
9648
9678
  PropTypes$1.arrayOf(PropTypes$1.string.isRequired),
9649
9679
  ]), range: PropTypes$1.bool, ranges: PropTypes$1.object, rangesButtonsColor: (_g = CButton.propTypes) === null || _g === void 0 ? void 0 : _g.color, rangesButtonsSize: (_h = CButton.propTypes) === null || _h === void 0 ? void 0 : _h.size, rangesButtonsVariant: (_j = CButton.propTypes) === null || _j === void 0 ? void 0 : _j.variant, required: PropTypes$1.bool, separator: PropTypes$1.oneOfType([PropTypes$1.bool, PropTypes$1.node]), size: PropTypes$1.oneOf(['sm', 'lg']), timepicker: PropTypes$1.bool, todayButton: PropTypes$1.oneOfType([PropTypes$1.bool, PropTypes$1.node]), todayButtonColor: (_k = CButton.propTypes) === null || _k === void 0 ? void 0 : _k.color, todayButtonSize: (_l = CButton.propTypes) === null || _l === void 0 ? void 0 : _l.size, todayButtonVariant: (_m = CButton.propTypes) === null || _m === void 0 ? void 0 : _m.variant });
@@ -13967,7 +13997,7 @@ var CSmartTable = forwardRef(function (_a, ref) {
13967
13997
  { sides: ['bottom'], query: 'tbody' },
13968
13998
  ] }, elementCover))),
13969
13999
  (pagination || itemsPerPageSelect) && (React$1.createElement("div", { className: "row" },
13970
- React$1.createElement("div", { className: "col" }, ((pagination && numberOfPages > 1) || paginationProps) && (React$1.createElement(CSmartPagination, __assign$1({ activePage: _activePage, onActivePageChange: function (page) {
14000
+ React$1.createElement("div", { className: "col" }, ((pagination && numberOfPages > 1) || (paginationProps && paginationProps.pages > 1)) && (React$1.createElement(CSmartPagination, __assign$1({ activePage: _activePage, onActivePageChange: function (page) {
13971
14001
  pagination && typeof pagination === 'object' && pagination.external
13972
14002
  ? onActivePageChange && onActivePageChange(page)
13973
14003
  : setActivePage(page);
@@ -14563,5 +14593,5 @@ CWidgetStatsF.propTypes = {
14563
14593
  };
14564
14594
  CWidgetStatsF.displayName = 'CWidgetStatsF';
14565
14595
 
14566
- export { CAccordion, CAccordionBody, CAccordionButton, CAccordionHeader, CAccordionItem, CAlert, CAlertHeading, CAlertLink, CAvatar, CBackdrop, CBadge, CBreadcrumb, CBreadcrumbItem, CButton, CButtonGroup, CButtonToolbar, CCallout, CCard, CCardBody, CCardFooter, CCardGroup, CCardHeader, CCardImage, CCardImageOverlay, CCardLink, CCardSubtitle, CCardText, CCardTitle, CCarousel, CCarouselCaption, CCarouselItem, CCloseButton, CCol, CCollapse, CConditionalPortal, CContainer, CDatePicker, CDateRangePicker, CDropdown, CDropdownDivider, CDropdownHeader, CDropdownItem, CDropdownItemPlain, CDropdownMenu, CDropdownToggle, CElementCover, CFooter, CForm, CFormCheck, CFormControlValidation, CFormControlWrapper, CFormFeedback, CFormFloating, CFormInput, CFormLabel, CFormRange, CFormSelect, CFormSwitch, CFormText, CFormTextarea, CHeader, CHeaderBrand, CHeaderDivider, CHeaderNav, CHeaderText, CHeaderToggler, CImage, CInputGroup, CInputGroupText, CLink, CListGroup, CListGroupItem, CLoadingButton, CModal, CModalBody, CModalContent, CModalDialog, CModalFooter, CModalHeader, CModalTitle, CMultiSelect, CNav, CNavGroup, CNavGroupItems, CNavItem, CNavLink, CNavTitle, CNavbar, CNavbarBrand, CNavbarNav, CNavbarText, CNavbarToggler, COffcanvas, COffcanvasBody, COffcanvasHeader, COffcanvasTitle, CPagination, CPaginationItem, CPlaceholder, CPopover, CProgress, CProgressBar, CProgressStacked, CRow, CSidebar, CSidebarBrand, CSidebarFooter, CSidebarHeader, CSidebarNav, CSidebarToggler, CSmartPagination, CSmartTable, CSpinner, CTabContent, CTabPane, CTable, CTableBody, CTableCaption, CTableDataCell, CTableFoot, CTableHead, CTableHeaderCell, CTableRow, CTimePicker, CToast, CToastBody, CToastClose, CToastHeader, CToaster, CTooltip, CVirtualScroller, CWidgetStatsA, CWidgetStatsB, CWidgetStatsC, CWidgetStatsD, CWidgetStatsE, CWidgetStatsF, useForkedRef, usePopper, useStateWithCallback };
14596
+ export { CAccordion, CAccordionBody, CAccordionButton, CAccordionHeader, CAccordionItem, CAlert, CAlertHeading, CAlertLink, CAvatar, CBackdrop, CBadge, CBreadcrumb, CBreadcrumbItem, CButton, CButtonGroup, CButtonToolbar, CCallout, CCard, CCardBody, CCardFooter, CCardGroup, CCardHeader, CCardImage, CCardImageOverlay, CCardLink, CCardSubtitle, CCardText, CCardTitle, CCarousel, CCarouselCaption, CCarouselItem, CCloseButton, CCol, CCollapse, CConditionalPortal, CContainer, CDatePicker, CDateRangePicker, CDropdown, CDropdownDivider, CDropdownHeader, CDropdownItem, CDropdownItemPlain, CDropdownMenu, CDropdownToggle, CElementCover, CFooter, CForm, CFormCheck, CFormControlValidation, CFormControlWrapper, CFormFeedback, CFormFloating, CFormInput, CFormLabel, CFormRange, CFormSelect, CFormSwitch, CFormText, CFormTextarea, CHeader, CHeaderBrand, CHeaderDivider, CHeaderNav, CHeaderText, CHeaderToggler, CImage, CInputGroup, CInputGroupText, CLink, CListGroup, CListGroupItem, CLoadingButton, CModal, CModalBody, CModalContent, CModalDialog, CModalFooter, CModalHeader, CModalTitle, CMultiSelect, CNav, CNavGroup, CNavGroupItems, CNavItem, CNavLink, CNavTitle, CNavbar, CNavbarBrand, CNavbarNav, CNavbarText, CNavbarToggler, COffcanvas, COffcanvasBody, COffcanvasHeader, COffcanvasTitle, CPagination, CPaginationItem, CPlaceholder, CPopover, CProgress, CProgressBar, CProgressStacked, CRow, CSidebar, CSidebarBrand, CSidebarFooter, CSidebarHeader, CSidebarNav, CSidebarToggler, CSmartPagination, CSmartTable, CSpinner, CTabContent, CTabPane, CTable, CTableBody, CTableCaption, CTableDataCell, CTableFoot, CTableHead, CTableHeaderCell, CTableRow, CTimePicker, CToast, CToastBody, CToastClose, CToastHeader, CToaster, CTooltip, CVirtualScroller, CWidgetStatsA, CWidgetStatsB, CWidgetStatsC, CWidgetStatsD, CWidgetStatsE, CWidgetStatsF, useDebouncedCallback, useForkedRef, useIsVisible, usePopper, useStateWithCallback };
14567
14597
  //# sourceMappingURL=index.es.js.map