@widergy/energy-ui 3.69.7 → 3.70.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/CHANGELOG.md +7 -0
- package/dist/components/UTDatePicker/index.js +18 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [3.70.0](https://github.com/widergy/energy-ui/compare/v3.69.7...v3.70.0) (2025-05-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add helpText and change error to ut validations ([#607](https://github.com/widergy/energy-ui/issues/607)) ([bea2a56](https://github.com/widergy/energy-ui/commit/bea2a56b82f6fdca3ded911e2e39556fce296a98))
|
|
7
|
+
|
|
1
8
|
## [3.69.7](https://github.com/widergy/energy-ui/compare/v3.69.6...v3.69.7) (2025-04-30)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -12,17 +12,20 @@ var _dayjs2 = _interopRequireDefault(require("dayjs"));
|
|
|
12
12
|
var _es = _interopRequireDefault(require("dayjs/locale/es"));
|
|
13
13
|
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
14
14
|
var _form = require("@widergy/web-utils/lib/form");
|
|
15
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
15
16
|
var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
16
17
|
var _UTFieldLabel = _interopRequireDefault(require("../UTFieldLabel"));
|
|
17
18
|
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
18
19
|
var _buttonTypes = require("../../types/buttonTypes");
|
|
19
20
|
var _formTypes = require("../../types/formTypes");
|
|
20
21
|
var _classesUtils = require("../../utils/classesUtils");
|
|
22
|
+
var _UTValidation = _interopRequireDefault(require("../UTValidation"));
|
|
23
|
+
var _utils = require("../UTValidation/utils");
|
|
21
24
|
var _Day = _interopRequireDefault(require("./components/Day"));
|
|
22
25
|
var _theme = require("./theme");
|
|
23
26
|
var _types = require("./types");
|
|
24
27
|
var _constants = require("./constants");
|
|
25
|
-
var
|
|
28
|
+
var _utils2 = require("./utils");
|
|
26
29
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
30
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
28
31
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
@@ -65,6 +68,7 @@ const UTDatePicker = _ref => {
|
|
|
65
68
|
disableToolbar = true,
|
|
66
69
|
disabled,
|
|
67
70
|
field,
|
|
71
|
+
helpText,
|
|
68
72
|
iconAnchor,
|
|
69
73
|
input,
|
|
70
74
|
inputProps,
|
|
@@ -83,18 +87,18 @@ const UTDatePicker = _ref => {
|
|
|
83
87
|
} = _ref;
|
|
84
88
|
const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(themeClasses, classNames), [classNames]);
|
|
85
89
|
const configMask = (field === null || field === void 0 || (_field$configuration = field.configuration) === null || _field$configuration === void 0 ? void 0 : _field$configuration.date_mask) || _constants.OUTPUT_LABEL_MASK;
|
|
86
|
-
const onlyPastMonth = ((_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;
|
|
87
|
-
const avoidFutureDates = ((_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;
|
|
90
|
+
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
|
+
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;
|
|
88
92
|
const {
|
|
89
93
|
minDate,
|
|
90
94
|
maxDate
|
|
91
|
-
} = (onlyPastMonth ? (0,
|
|
95
|
+
} = (onlyPastMonth ? (0, _utils2.getPastMonthDates)() : avoidFutureDates ? (0, _utils2.getMaxDate)() : range) || {};
|
|
92
96
|
const [pickedDate, setPickedDate] = (0, _react.useState)(null);
|
|
93
97
|
const [internalError, setInternalError] = (0, _react.useState)(null);
|
|
94
98
|
const handleChange = date => {
|
|
95
99
|
setPickedDate(date);
|
|
96
100
|
const newValue = (0, _dayjs2.default)(date, _constants.OUTPUT_LABEL_MASK, true);
|
|
97
|
-
if ((0,
|
|
101
|
+
if ((0, _utils2.isValidDate)({
|
|
98
102
|
avoidFutureDates,
|
|
99
103
|
newValue,
|
|
100
104
|
onlyPastMonth,
|
|
@@ -102,7 +106,7 @@ const UTDatePicker = _ref => {
|
|
|
102
106
|
})) input.onChange(newValue.format(configMask));else input.onChange('');
|
|
103
107
|
};
|
|
104
108
|
(0, _react.useEffect)(() => {
|
|
105
|
-
if (!input.value && pickedDate !== null && pickedDate !== void 0 && pickedDate.isValid()) setPickedDate(null);else if ((0,
|
|
109
|
+
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));
|
|
106
110
|
}, [input.value]);
|
|
107
111
|
const renderDay = (date, _, dayInCurrentMonth) => /*#__PURE__*/_react.default.createElement(_Day.default, {
|
|
108
112
|
classes: classes,
|
|
@@ -131,11 +135,13 @@ const UTDatePicker = _ref => {
|
|
|
131
135
|
value: pickedDate,
|
|
132
136
|
label: inputVariant === 'standard' && (field === null || field === void 0 ? void 0 : field.title),
|
|
133
137
|
error: (0, _form.shouldShowErrors)(meta),
|
|
134
|
-
helperText:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}, errorMessage)
|
|
138
|
+
helperText: /*#__PURE__*/_react.default.createElement(_react.Fragment, null, helpText && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
139
|
+
colorTheme: "gray",
|
|
140
|
+
variant: "small",
|
|
141
|
+
withMarkdown: true
|
|
142
|
+
}, helpText), !(0, _isEmpty.default)(errorMessage) && /*#__PURE__*/_react.default.createElement(_UTValidation.default, {
|
|
143
|
+
validationData: (0, _utils.formatErrorToValidation)(errorMessage)
|
|
144
|
+
})),
|
|
139
145
|
onError: handleError,
|
|
140
146
|
onAccept: handleRemoveError,
|
|
141
147
|
disableToolbar: disableToolbar,
|
|
@@ -180,6 +186,7 @@ UTDatePicker.propTypes = {
|
|
|
180
186
|
disableToolbar: _propTypes.bool,
|
|
181
187
|
disabled: _propTypes.bool,
|
|
182
188
|
field: _formTypes.fieldType,
|
|
189
|
+
helpText: _propTypes.string,
|
|
183
190
|
iconAnchor: _propTypes.bool,
|
|
184
191
|
input: _formTypes.inputPropTypes.isRequired,
|
|
185
192
|
inputFormat: _propTypes.string,
|