@widergy/energy-ui 3.83.0 → 3.83.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [3.83.1](https://github.com/widergy/energy-ui/compare/v3.83.0...v3.83.1) (2025-06-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * [OAG-1369] date search error ([#621](https://github.com/widergy/energy-ui/issues/621)) ([7133f09](https://github.com/widergy/energy-ui/commit/7133f09385cd3bee092abf55b2b05cd99b64a4db))
7
+
1
8
  # [3.83.0](https://github.com/widergy/energy-ui/compare/v3.82.2...v3.83.0) (2025-06-19)
2
9
 
3
10
 
@@ -11,6 +11,7 @@ var _dayjs = _interopRequireDefault(require("@date-io/dayjs"));
11
11
  var _dayjs2 = _interopRequireDefault(require("dayjs"));
12
12
  var _es = _interopRequireDefault(require("dayjs/locale/es"));
13
13
  var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
14
+ var _isBetween = _interopRequireDefault(require("dayjs/plugin/isBetween"));
14
15
  var _form = require("@widergy/web-utils/lib/form");
15
16
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
16
17
  var _UTLabel = _interopRequireDefault(require("../UTLabel"));
@@ -51,6 +52,7 @@ CalendarIcon.defaultProps = {
51
52
  xmlnsXlink: "http://www.w3.org/1999/xlink"
52
53
  };
53
54
  _dayjs2.default.extend(_customParseFormat.default);
55
+ _dayjs2.default.extend(_isBetween.default);
54
56
  class CustomUtils extends _dayjs.default {
55
57
  constructor() {
56
58
  super(...arguments);
@@ -90,20 +92,20 @@ const UTDatePicker = _ref => {
90
92
  const onlyPastMonth = (field === null || field === void 0 || (_field$configuration2 = field.configuration) === null || _field$configuration2 === void 0 || (_field$configuration2 = _field$configuration2.customDateValidations) === null || _field$configuration2 === void 0 || (_field$configuration2 = _field$configuration2.onlyPastMonth) === null || _field$configuration2 === void 0 ? void 0 : _field$configuration2.active) || false;
91
93
  const avoidFutureDates = (field === null || field === void 0 || (_field$configuration3 = field.configuration) === null || _field$configuration3 === void 0 || (_field$configuration3 = _field$configuration3.customDateValidations) === null || _field$configuration3 === void 0 || (_field$configuration3 = _field$configuration3.avoidFutureDates) === null || _field$configuration3 === void 0 ? void 0 : _field$configuration3.active) || false;
92
94
  const {
93
- minDate,
94
- maxDate
95
- } = (onlyPastMonth ? (0, _utils2.getPastMonthDates)() : avoidFutureDates ? (0, _utils2.getMaxDate)() : range) || {};
95
+ maxDate,
96
+ minDate
97
+ } = onlyPastMonth ? (0, _utils2.getPastMonthDates)() : avoidFutureDates ? (0, _utils2.getMaxDate)() : range || pickerProps || {};
96
98
  const [pickedDate, setPickedDate] = (0, _react.useState)(null);
97
99
  const [internalError, setInternalError] = (0, _react.useState)(null);
98
100
  const handleChange = date => {
99
- setPickedDate(date);
100
- const newValue = (0, _dayjs2.default)(date, _constants.OUTPUT_LABEL_MASK, true);
101
- if ((0, _utils2.isValidDate)({
102
- avoidFutureDates,
103
- newValue,
104
- onlyPastMonth,
105
- range
106
- })) input.onChange(newValue.format(configMask));else input.onChange('');
101
+ const finalDate = (0, _utils2.getFinalDate)({
102
+ date,
103
+ maxDate,
104
+ minDate
105
+ });
106
+ setPickedDate(finalDate);
107
+ const newValue = (0, _dayjs2.default)(finalDate, _constants.OUTPUT_LABEL_MASK, true);
108
+ if (newValue.isValid()) input.onChange(newValue.format(configMask));else input.onChange('');
107
109
  };
108
110
  (0, _react.useEffect)(() => {
109
111
  if (!input.value && pickedDate !== null && pickedDate !== void 0 && pickedDate.isValid()) setPickedDate(null);else if ((0, _utils2.dateMatchesFormat)(input.value, configMask)) setPickedDate((0, _dayjs2.default)(input.value, configMask));
@@ -172,10 +174,11 @@ const UTDatePicker = _ref => {
172
174
  PopoverProps: {
173
175
  ...(iconAnchor ? (0, _constants.iconAnchorProps)(operenerIconReference) : {}),
174
176
  ...popoverProps
175
- },
177
+ }
178
+ }, pickerProps, {
176
179
  minDate: minDate,
177
180
  maxDate: maxDate
178
- }, pickerProps))));
181
+ }))));
179
182
  };
180
183
  UTDatePicker.propTypes = {
181
184
  actions: (0, _propTypes.arrayOf)(_buttonTypes.buttonTypes),
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isValidDate = exports.isSelected = exports.getPastMonthDates = exports.getMaxDate = exports.dateMatchesFormat = void 0;
6
+ exports.isSelected = exports.getPastMonthDates = exports.getMaxDate = exports.getFinalDate = exports.dateMatchesFormat = void 0;
7
7
  var _dayjs = _interopRequireDefault(require("dayjs"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
9
  const isSelected = (date, selectedDate) => selectedDate && date.isSame(selectedDate, 'day');
@@ -27,24 +27,15 @@ const getMaxDate = () => {
27
27
  };
28
28
  };
29
29
  exports.getMaxDate = getMaxDate;
30
- const avoidFutureDatesValidation = date => !(0, _dayjs.default)().isBefore(date);
31
- const rangeValidation = (date, range) => {
32
- const {
33
- minDate,
34
- maxDate
35
- } = range;
36
- return date.isBetween(minDate, maxDate, null, '[]');
37
- };
38
- const isValidDate = _ref => {
30
+ const getFinalDate = _ref => {
39
31
  let {
40
- avoidFutureDates,
41
- newValue,
42
- onlyPastMonth,
43
- range
32
+ date,
33
+ maxDate,
34
+ minDate
44
35
  } = _ref;
45
- if (avoidFutureDates && !avoidFutureDatesValidation(newValue)) return false;
46
- if (onlyPastMonth && !rangeValidation(newValue, getPastMonthDates())) return false;
47
- if (range && !rangeValidation(newValue, range)) return false;
48
- return newValue.isValid();
36
+ const formattedDate = (0, _dayjs.default)(date);
37
+ if (maxDate && formattedDate !== null && formattedDate !== void 0 && formattedDate.isAfter(maxDate)) return (0, _dayjs.default)(maxDate);
38
+ if (minDate && formattedDate !== null && formattedDate !== void 0 && formattedDate.isBefore(minDate)) return (0, _dayjs.default)(minDate);
39
+ return formattedDate;
49
40
  };
50
- exports.isValidDate = isValidDate;
41
+ exports.getFinalDate = getFinalDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.83.0",
3
+ "version": "3.83.1",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",