@widergy/energy-ui 3.155.0 → 3.156.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 +11 -6
- package/dist/components/UTDatePicker/index.js +12 -198
- package/dist/components/UTDatePicker/versions/V0/assets/calendar.svg +14 -0
- package/dist/components/UTDatePicker/{components → versions/V0/components}/Day/index.js +1 -1
- package/dist/components/UTDatePicker/versions/V0/index.js +213 -0
- package/dist/components/UTDatePicker/{theme.js → versions/V0/theme.js} +2 -2
- package/dist/components/UTDatePicker/versions/V1/README.md +89 -0
- package/dist/components/UTDatePicker/versions/V1/components/Calendar/index.js +97 -0
- package/dist/components/UTDatePicker/versions/V1/components/Day/index.js +46 -0
- package/dist/components/UTDatePicker/versions/V1/constants.js +16 -0
- package/dist/components/UTDatePicker/versions/V1/index.js +273 -0
- package/dist/components/UTDatePicker/versions/V1/stories/UTDatePickerV1.mdx +24 -0
- package/dist/components/UTDatePicker/versions/V1/stories/UTDatePickerV1.stories.js +249 -0
- package/dist/components/UTDatePicker/versions/V1/stories/storiesConstants.js +7 -0
- package/dist/components/UTDatePicker/versions/V1/styles.module.scss +68 -0
- package/dist/components/UTDatePicker/versions/V1/utils.js +41 -0
- package/dist/constants/testIds.js +9 -0
- package/dist/utils/hooks/useCSSVariables/constants.js +17 -1
- package/package.json +1 -1
- /package/dist/components/UTDatePicker/{components → versions/V0/components}/Day/constants.js +0 -0
- /package/dist/components/UTDatePicker/{constants.js → versions/V0/constants.js} +0 -0
- /package/dist/components/UTDatePicker/{types.js → versions/V0/types.js} +0 -0
- /package/dist/components/UTDatePicker/{utils.js → versions/V0/utils.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [3.156.0](https://github.com/widergy/energy-ui/compare/v3.155.0...v3.156.0) (2026-05-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* [AXCH-1404] Add UTDatePicker V1 ([#792](https://github.com/widergy/energy-ui/issues/792)) ([6727f5f](https://github.com/widergy/energy-ui/commit/6727f5fb3ff3df14e08548621efd2c6670cc91ac))
|
|
7
|
+
|
|
1
8
|
# [3.155.0](https://github.com/widergy/energy-ui/compare/v3.154.0...v3.155.0) (2026-05-13)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -7,10 +14,9 @@
|
|
|
7
14
|
|
|
8
15
|
# [3.154.0](https://github.com/widergy/energy-ui/compare/v3.153.0...v3.154.0) (2026-05-13)
|
|
9
16
|
|
|
17
|
+
### Novedades y Mejoras
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* add test id support ([#794](https://github.com/widergy/energy-ui/issues/794)) ([9c70e57](https://github.com/widergy/energy-ui/commit/9c70e5700274b390077c416eeeb65123cb102980))
|
|
19
|
+
* Se agregó soporte para identificar elementos de la barra superior y el menú lateral en pruebas automatizadas, mejorando la cobertura y confiabilidad del testing de la interfaz. [#794](https://github.com/widergy/Energy-UI/pull/794) [AUTO-235](https://widergy.atlassian.net/browse/AUTO-235)
|
|
14
20
|
|
|
15
21
|
# [3.153.0](https://github.com/widergy/energy-ui/compare/v3.152.0...v3.153.0) (2026-05-13)
|
|
16
22
|
|
|
@@ -28,10 +34,9 @@
|
|
|
28
34
|
|
|
29
35
|
# [3.151.0](https://github.com/widergy/energy-ui/compare/v3.150.0...v3.151.0) (2026-05-11)
|
|
30
36
|
|
|
37
|
+
### Novedades y Mejoras
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* [AXCH-1429] dot menu changes ([#786](https://github.com/widergy/energy-ui/issues/786)) ([da08cef](https://github.com/widergy/energy-ui/commit/da08cefc7b5f19bf69e7cb40aed0431f76322b8e)) [AXCH-1429](https://widergy.atlassian.net/browse/AXCH-1429)
|
|
39
|
+
* El menú de opciones contextual ahora admite íconos y colores personalizados por cada opción, incluyendo soporte para resaltar acciones destructivas. También es posible configurar el ícono del botón que abre el menú, su tamaño, y ajustar el estilo de las opciones y el contenedor del menú. [#786](https://github.com/widergy/Energy-UI/pull/786) [AXCH-1429](https://widergy.atlassian.net/browse/AXCH-1429)
|
|
35
40
|
|
|
36
41
|
# [3.150.0](https://github.com/widergy/energy-ui/compare/v3.149.0...v3.150.0) (2026-05-08)
|
|
37
42
|
|
|
@@ -4,210 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = require("prop-types");
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var _dayjs2 = _interopRequireDefault(require("dayjs"));
|
|
12
|
-
var _es = _interopRequireDefault(require("dayjs/locale/es"));
|
|
13
|
-
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
14
|
-
var _isBetween = _interopRequireDefault(require("dayjs/plugin/isBetween"));
|
|
15
|
-
var _form = require("@widergy/web-utils/lib/form");
|
|
16
|
-
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
17
|
-
var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
18
|
-
var _UTFieldLabel = _interopRequireDefault(require("../UTFieldLabel"));
|
|
19
|
-
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
20
|
-
var _buttonTypes = require("../../types/buttonTypes");
|
|
21
|
-
var _formTypes = require("../../types/formTypes");
|
|
22
|
-
var _classesUtils = require("../../utils/classesUtils");
|
|
23
|
-
var _UTValidation = _interopRequireDefault(require("../UTValidation"));
|
|
24
|
-
var _utils = require("../UTValidation/utils");
|
|
25
|
-
var _Day = _interopRequireDefault(require("./components/Day"));
|
|
26
|
-
var _theme = require("./theme");
|
|
27
|
-
var _types = require("./types");
|
|
28
|
-
var _constants = require("./constants");
|
|
29
|
-
var _utils2 = require("./utils");
|
|
9
|
+
var _V = _interopRequireDefault(require("./versions/V0"));
|
|
10
|
+
var _V2 = _interopRequireDefault(require("./versions/V1"));
|
|
30
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
35
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
36
|
-
var CalendarIcon = function CalendarIcon(props) {
|
|
37
|
-
return /*#__PURE__*/_react.default.createElement("svg", props, /*#__PURE__*/_react.default.createElement("defs", null, /*#__PURE__*/_react.default.createElement("path", {
|
|
38
|
-
d: "M8 15c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1Zm8 0c.55 0 1 .45 1 1s-.45 1-1 1h-4c-.55 0-1-.45-1-1s.45-1 1-1Zm2 5H6c-.551 0-1-.449-1-1v-6h14v6c0 .551-.449 1-1 1M6 6h1v1c0 .55.45 1 1 1s1-.45 1-1V6h6v1c0 .55.45 1 1 1s1-.45 1-1V6h1c.551 0 1 .449 1 1v4H5V7c0-.551.449-1 1-1m12-2h-1V3c0-.55-.45-1-1-1s-1 .45-1 1v1H9V3c0-.55-.45-1-1-1s-1 .45-1 1v1H6C4.346 4 3 5.346 3 7v12c0 1.654 1.346 3 3 3h12c1.654 0 3-1.346 3-3V7c0-1.654-1.346-3-3-3",
|
|
39
|
-
id: "a"
|
|
40
|
-
})), /*#__PURE__*/_react.default.createElement("use", {
|
|
41
|
-
fillRule: "nonzero",
|
|
42
|
-
xlinkHref: "#a",
|
|
43
|
-
transform: "translate(-3 -2)",
|
|
44
|
-
fill: "current"
|
|
45
|
-
}));
|
|
12
|
+
const VERSIONS = {
|
|
13
|
+
V0: _V.default,
|
|
14
|
+
V1: _V2.default
|
|
46
15
|
};
|
|
47
|
-
CalendarIcon.defaultProps = {
|
|
48
|
-
width: "18",
|
|
49
|
-
height: "20",
|
|
50
|
-
viewBox: "0 0 18 20",
|
|
51
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
52
|
-
xmlnsXlink: "http://www.w3.org/1999/xlink"
|
|
53
|
-
};
|
|
54
|
-
_dayjs2.default.extend(_customParseFormat.default);
|
|
55
|
-
_dayjs2.default.extend(_isBetween.default);
|
|
56
|
-
class CustomUtils extends _dayjs.default {
|
|
57
|
-
constructor() {
|
|
58
|
-
super(...arguments);
|
|
59
|
-
_defineProperty(this, "getCalendarHeaderText", date => date.format('MMMM'));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
16
|
const UTDatePicker = _ref => {
|
|
63
|
-
var _field$configuration, _field$configuration2, _field$configuration3;
|
|
64
17
|
let {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
classNames,
|
|
68
|
-
CustomIcon,
|
|
69
|
-
dayFormat,
|
|
70
|
-
disableToolbar = true,
|
|
71
|
-
disabled,
|
|
72
|
-
field,
|
|
73
|
-
helpText,
|
|
74
|
-
iconAnchor,
|
|
75
|
-
input,
|
|
76
|
-
inputProps,
|
|
77
|
-
inputVariant = _constants.INPUT_VARIANT,
|
|
78
|
-
invalidDateMessage,
|
|
79
|
-
maxDateMessage,
|
|
80
|
-
minDateMessage,
|
|
81
|
-
meta = {},
|
|
82
|
-
pickerProps,
|
|
83
|
-
placeholder,
|
|
84
|
-
popoverProps,
|
|
85
|
-
range,
|
|
86
|
-
titleVariant,
|
|
87
|
-
variant,
|
|
88
|
-
withUpperTitle
|
|
18
|
+
version = 'V0',
|
|
19
|
+
...props
|
|
89
20
|
} = _ref;
|
|
90
|
-
const
|
|
91
|
-
|
|
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;
|
|
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;
|
|
94
|
-
const {
|
|
95
|
-
maxDate,
|
|
96
|
-
minDate
|
|
97
|
-
} = onlyPastMonth ? (0, _utils2.getPastMonthDates)() : avoidFutureDates ? (0, _utils2.getMaxDate)() : range || pickerProps || {};
|
|
98
|
-
const [pickedDate, setPickedDate] = (0, _react.useState)(null);
|
|
99
|
-
const [internalError, setInternalError] = (0, _react.useState)(null);
|
|
100
|
-
const handleChange = date => {
|
|
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('');
|
|
109
|
-
};
|
|
110
|
-
(0, _react.useEffect)(() => {
|
|
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));
|
|
112
|
-
}, [input.value]);
|
|
113
|
-
const renderDay = (date, _, dayInCurrentMonth) => /*#__PURE__*/_react.default.createElement(_Day.default, {
|
|
114
|
-
classes: classes,
|
|
115
|
-
dayFormat: dayFormat,
|
|
116
|
-
date: date,
|
|
117
|
-
pickedDate: pickedDate,
|
|
118
|
-
dayInCurrentMonth: dayInCurrentMonth
|
|
119
|
-
});
|
|
120
|
-
const handleError = error => setInternalError(error);
|
|
121
|
-
const handleRemoveError = () => setInternalError(null);
|
|
122
|
-
const OpenerIcon = CustomIcon || CalendarIcon;
|
|
123
|
-
const operenerIconReference = (0, _react.useRef)();
|
|
124
|
-
const errorMessage = (0, _form.shouldShowErrors)(meta) && (internalError || meta.error) || '';
|
|
125
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, withUpperTitle && /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
|
|
126
|
-
actions: actions,
|
|
127
|
-
className: classes.upperTitle,
|
|
128
|
-
readOnly: field.read_only,
|
|
129
|
-
required: field.required,
|
|
130
|
-
size: titleVariant,
|
|
131
|
-
withMarkdown: true
|
|
132
|
-
}, field.title), /*#__PURE__*/_react.default.createElement(_pickers.MuiPickersUtilsProvider, {
|
|
133
|
-
utils: disableToolbar ? _dayjs.default : CustomUtils,
|
|
134
|
-
locale: _es.default
|
|
135
|
-
}, /*#__PURE__*/_react.default.createElement(_pickers.KeyboardDatePicker, _extends({
|
|
136
|
-
disabled: disabled,
|
|
137
|
-
value: pickedDate,
|
|
138
|
-
label: inputVariant === 'standard' && (field === null || field === void 0 ? void 0 : field.title),
|
|
139
|
-
error: (0, _form.shouldShowErrors)(meta),
|
|
140
|
-
helperText: /*#__PURE__*/_react.default.createElement(_react.Fragment, null, helpText && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
141
|
-
colorTheme: "gray",
|
|
142
|
-
variant: "small",
|
|
143
|
-
withMarkdown: true
|
|
144
|
-
}, helpText), !(0, _isEmpty.default)(errorMessage) && /*#__PURE__*/_react.default.createElement(_UTValidation.default, {
|
|
145
|
-
validationData: (0, _utils.formatErrorToValidation)(errorMessage)
|
|
146
|
-
})),
|
|
147
|
-
onError: handleError,
|
|
148
|
-
onAccept: handleRemoveError,
|
|
149
|
-
disableToolbar: disableToolbar,
|
|
150
|
-
keyboardIcon: /*#__PURE__*/_react.default.createElement("div", {
|
|
151
|
-
ref: operenerIconReference
|
|
152
|
-
}, /*#__PURE__*/_react.default.createElement(OpenerIcon, {
|
|
153
|
-
className: disabled ? classes.disabledOpenerIcon : classes.openerIcon
|
|
154
|
-
})),
|
|
155
|
-
variant: variant || _constants.VARIANT,
|
|
156
|
-
InputProps: {
|
|
157
|
-
classes: {
|
|
158
|
-
root: classes.input,
|
|
159
|
-
notchedOutline: classes.notchedOutline
|
|
160
|
-
},
|
|
161
|
-
placeholder: inputVariant === 'outlined' && (placeholder || (field === null || field === void 0 ? void 0 : field.placeholder)) || undefined,
|
|
162
|
-
...inputProps
|
|
163
|
-
},
|
|
164
|
-
invalidDateMessage: invalidDateMessage || _constants.WRONG_DATE_FORMAT,
|
|
165
|
-
inputVariant: inputVariant,
|
|
166
|
-
format: _constants.OUTPUT_LABEL_MASK,
|
|
167
|
-
maxDateMessage: maxDateMessage || _constants.MAX_DATE_MSG,
|
|
168
|
-
minDateMessage: minDateMessage || _constants.MIN_DATE_MSG,
|
|
169
|
-
InputAdornmentProps: {
|
|
170
|
-
position: _constants.BUTTON_POSITION
|
|
171
|
-
},
|
|
172
|
-
onChange: handleChange,
|
|
173
|
-
renderDay: renderDay,
|
|
174
|
-
PopoverProps: {
|
|
175
|
-
...(iconAnchor ? (0, _constants.iconAnchorProps)(operenerIconReference) : {}),
|
|
176
|
-
...popoverProps
|
|
177
|
-
}
|
|
178
|
-
}, pickerProps, {
|
|
179
|
-
minDate: minDate,
|
|
180
|
-
maxDate: maxDate
|
|
181
|
-
}))));
|
|
21
|
+
const Component = VERSIONS[version];
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(Component, props);
|
|
182
23
|
};
|
|
183
24
|
UTDatePicker.propTypes = {
|
|
184
|
-
|
|
185
|
-
classNames: _types.classesPropTypes,
|
|
186
|
-
classes: _types.classesPropTypes,
|
|
187
|
-
CustomIcon: _propTypes.node,
|
|
188
|
-
dayFormat: _propTypes.string,
|
|
189
|
-
disableToolbar: _propTypes.bool,
|
|
190
|
-
disabled: _propTypes.bool,
|
|
191
|
-
field: _formTypes.fieldType,
|
|
192
|
-
helpText: _propTypes.string,
|
|
193
|
-
iconAnchor: _propTypes.bool,
|
|
194
|
-
input: _formTypes.inputPropTypes.isRequired,
|
|
195
|
-
inputFormat: _propTypes.string,
|
|
196
|
-
inputProps: _propTypes.object,
|
|
197
|
-
inputVariant: _propTypes.string,
|
|
198
|
-
invalidDateMessage: _propTypes.string,
|
|
199
|
-
maxDateMessage: _propTypes.string,
|
|
200
|
-
meta: _formTypes.metaPropTypes,
|
|
201
|
-
minDateMessage: _propTypes.string,
|
|
202
|
-
pickerProps: _propTypes.object,
|
|
203
|
-
placeholder: _propTypes.string,
|
|
204
|
-
popoverProps: _propTypes.object,
|
|
205
|
-
range: (0, _propTypes.shape)({
|
|
206
|
-
maxDate: _propTypes.string,
|
|
207
|
-
minDate: _propTypes.string
|
|
208
|
-
}),
|
|
209
|
-
titleVariant: _propTypes.string,
|
|
210
|
-
variant: _propTypes.string,
|
|
211
|
-
withUpperTitle: _propTypes.bool
|
|
25
|
+
version: _propTypes.string
|
|
212
26
|
};
|
|
213
|
-
var _default = exports.default =
|
|
27
|
+
var _default = exports.default = UTDatePicker;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="18px" height="20px" viewBox="0 0 18 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<defs>
|
|
4
|
+
<path d="M8,15 C8.55,15 9,15.45 9,16 C9,16.55 8.55,17 8,17 C7.45,17 7,16.55 7,16 C7,15.45 7.45,15 8,15 Z M16,15 C16.55,15 17,15.45 17,16 C17,16.55 16.55,17 16,17 L16,17 L12,17 C11.45,17 11,16.55 11,16 C11,15.45 11.45,15 12,15 L12,15 Z M18,20 L6,20 C5.449,20 5,19.551 5,19 L5,13 L19,13 L19,19 C19,19.551 18.551,20 18,20 M6,6 L7,6 L7,7 C7,7.55 7.45,8 8,8 C8.55,8 9,7.55 9,7 L9,6 L15,6 L15,7 C15,7.55 15.45,8 16,8 C16.55,8 17,7.55 17,7 L17,6 L18,6 C18.551,6 19,6.449 19,7 L19,11 L5,11 L5,7 C5,6.449 5.449,6 6,6 M18,4 L17,4 L17,3 C17,2.45 16.55,2 16,2 C15.45,2 15,2.45 15,3 L15,4 L9,4 L9,3 C9,2.45 8.55,2 8,2 C7.45,2 7,2.45 7,3 L7,4 L6,4 C4.346,4 3,5.346 3,7 L3,19 C3,20.654 4.346,22 6,22 L18,22 C19.654,22 21,20.654 21,19 L21,7 C21,5.346 19.654,4 18,4" id="calendario"></path>
|
|
5
|
+
</defs>
|
|
6
|
+
<g id="Final" stroke="none" stroke-width="1" fill="current" fill-rule="evenodd">
|
|
7
|
+
<g id="Group" transform="translate(-3.000000, -2.000000)">
|
|
8
|
+
<mask id="mask-2" fill="white">
|
|
9
|
+
<use xlink:href="#calendario"></use>
|
|
10
|
+
</mask>
|
|
11
|
+
<use id="🎨-Icon-Сolor" fill="current" fill-rule="nonzero" xlink:href="#calendario"></use>
|
|
12
|
+
</g>
|
|
13
|
+
</g>
|
|
14
|
+
</svg>
|
|
@@ -22,7 +22,7 @@ const Day = _ref => {
|
|
|
22
22
|
} = _ref;
|
|
23
23
|
const todaySelected = (0, _utils.isSelected)(date, pickedDate);
|
|
24
24
|
return /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
25
|
-
className: "\n ".concat(classes.day, "
|
|
25
|
+
className: "\n ".concat(classes.day, "\n ").concat(!dayInCurrentMonth && classes.otherMonthDay, "\n ").concat(todaySelected && classes.selectedDay, "\n ")
|
|
26
26
|
}, /*#__PURE__*/_react.default.createElement("span", null, " ", (0, _dayjs.default)(date).format(dayFormat || _constants.DAY_NUMBER_FORMAT), " "));
|
|
27
27
|
};
|
|
28
28
|
Day.propTypes = {
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = require("prop-types");
|
|
9
|
+
var _pickers = require("@material-ui/pickers");
|
|
10
|
+
var _dayjs = _interopRequireDefault(require("@date-io/dayjs"));
|
|
11
|
+
var _dayjs2 = _interopRequireDefault(require("dayjs"));
|
|
12
|
+
var _es = _interopRequireDefault(require("dayjs/locale/es"));
|
|
13
|
+
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
14
|
+
var _isBetween = _interopRequireDefault(require("dayjs/plugin/isBetween"));
|
|
15
|
+
var _form = require("@widergy/web-utils/lib/form");
|
|
16
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
17
|
+
var _UTLabel = _interopRequireDefault(require("../../../UTLabel"));
|
|
18
|
+
var _UTFieldLabel = _interopRequireDefault(require("../../../UTFieldLabel"));
|
|
19
|
+
var _WithTheme = _interopRequireDefault(require("../../../WithTheme"));
|
|
20
|
+
var _buttonTypes = require("../../../../types/buttonTypes");
|
|
21
|
+
var _formTypes = require("../../../../types/formTypes");
|
|
22
|
+
var _classesUtils = require("../../../../utils/classesUtils");
|
|
23
|
+
var _UTValidation = _interopRequireDefault(require("../../../UTValidation"));
|
|
24
|
+
var _utils = require("../../../UTValidation/utils");
|
|
25
|
+
var _Day = _interopRequireDefault(require("./components/Day"));
|
|
26
|
+
var _theme = require("./theme");
|
|
27
|
+
var _types = require("./types");
|
|
28
|
+
var _constants = require("./constants");
|
|
29
|
+
var _utils2 = require("./utils");
|
|
30
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
31
|
+
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); }
|
|
32
|
+
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); }
|
|
33
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
34
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
35
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
36
|
+
var CalendarIcon = function CalendarIcon(props) {
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement("svg", props, /*#__PURE__*/_react.default.createElement("defs", null, /*#__PURE__*/_react.default.createElement("path", {
|
|
38
|
+
d: "M8 15c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1Zm8 0c.55 0 1 .45 1 1s-.45 1-1 1h-4c-.55 0-1-.45-1-1s.45-1 1-1Zm2 5H6c-.551 0-1-.449-1-1v-6h14v6c0 .551-.449 1-1 1M6 6h1v1c0 .55.45 1 1 1s1-.45 1-1V6h6v1c0 .55.45 1 1 1s1-.45 1-1V6h1c.551 0 1 .449 1 1v4H5V7c0-.551.449-1 1-1m12-2h-1V3c0-.55-.45-1-1-1s-1 .45-1 1v1H9V3c0-.55-.45-1-1-1s-1 .45-1 1v1H6C4.346 4 3 5.346 3 7v12c0 1.654 1.346 3 3 3h12c1.654 0 3-1.346 3-3V7c0-1.654-1.346-3-3-3",
|
|
39
|
+
id: "a"
|
|
40
|
+
})), /*#__PURE__*/_react.default.createElement("use", {
|
|
41
|
+
fillRule: "nonzero",
|
|
42
|
+
xlinkHref: "#a",
|
|
43
|
+
transform: "translate(-3 -2)",
|
|
44
|
+
fill: "current"
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
CalendarIcon.defaultProps = {
|
|
48
|
+
width: "18",
|
|
49
|
+
height: "20",
|
|
50
|
+
viewBox: "0 0 18 20",
|
|
51
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
52
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink"
|
|
53
|
+
};
|
|
54
|
+
_dayjs2.default.extend(_customParseFormat.default);
|
|
55
|
+
_dayjs2.default.extend(_isBetween.default);
|
|
56
|
+
class CustomUtils extends _dayjs.default {
|
|
57
|
+
constructor() {
|
|
58
|
+
super(...arguments);
|
|
59
|
+
_defineProperty(this, "getCalendarHeaderText", date => date.format('MMMM'));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const UTDatePickerV0 = _ref => {
|
|
63
|
+
var _field$configuration, _field$configuration2, _field$configuration3;
|
|
64
|
+
let {
|
|
65
|
+
actions,
|
|
66
|
+
classes: themeClasses,
|
|
67
|
+
classNames,
|
|
68
|
+
CustomIcon,
|
|
69
|
+
dayFormat,
|
|
70
|
+
disableToolbar = true,
|
|
71
|
+
disabled,
|
|
72
|
+
field,
|
|
73
|
+
helpText,
|
|
74
|
+
iconAnchor,
|
|
75
|
+
input,
|
|
76
|
+
inputProps,
|
|
77
|
+
inputVariant = _constants.INPUT_VARIANT,
|
|
78
|
+
invalidDateMessage,
|
|
79
|
+
maxDateMessage,
|
|
80
|
+
minDateMessage,
|
|
81
|
+
meta = {},
|
|
82
|
+
pickerProps,
|
|
83
|
+
placeholder,
|
|
84
|
+
popoverProps,
|
|
85
|
+
range,
|
|
86
|
+
titleVariant,
|
|
87
|
+
variant,
|
|
88
|
+
withUpperTitle
|
|
89
|
+
} = _ref;
|
|
90
|
+
const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(themeClasses, classNames), [classNames]);
|
|
91
|
+
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;
|
|
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;
|
|
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;
|
|
94
|
+
const {
|
|
95
|
+
maxDate,
|
|
96
|
+
minDate
|
|
97
|
+
} = onlyPastMonth ? (0, _utils2.getPastMonthDates)() : avoidFutureDates ? (0, _utils2.getMaxDate)() : range || pickerProps || {};
|
|
98
|
+
const [pickedDate, setPickedDate] = (0, _react.useState)(null);
|
|
99
|
+
const [internalError, setInternalError] = (0, _react.useState)(null);
|
|
100
|
+
const handleChange = date => {
|
|
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('');
|
|
109
|
+
};
|
|
110
|
+
(0, _react.useEffect)(() => {
|
|
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));
|
|
112
|
+
}, [input.value]);
|
|
113
|
+
const renderDay = (date, _, dayInCurrentMonth) => /*#__PURE__*/_react.default.createElement(_Day.default, {
|
|
114
|
+
classes: classes,
|
|
115
|
+
dayFormat: dayFormat,
|
|
116
|
+
date: date,
|
|
117
|
+
pickedDate: pickedDate,
|
|
118
|
+
dayInCurrentMonth: dayInCurrentMonth
|
|
119
|
+
});
|
|
120
|
+
const handleError = error => setInternalError(error);
|
|
121
|
+
const handleRemoveError = () => setInternalError(null);
|
|
122
|
+
const OpenerIcon = CustomIcon || CalendarIcon;
|
|
123
|
+
const operenerIconReference = (0, _react.useRef)();
|
|
124
|
+
const errorMessage = (0, _form.shouldShowErrors)(meta) && (internalError || meta.error) || '';
|
|
125
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, withUpperTitle && /*#__PURE__*/_react.default.createElement(_UTFieldLabel.default, {
|
|
126
|
+
actions: actions,
|
|
127
|
+
className: classes.upperTitle,
|
|
128
|
+
readOnly: field.read_only,
|
|
129
|
+
required: field.required,
|
|
130
|
+
size: titleVariant,
|
|
131
|
+
withMarkdown: true
|
|
132
|
+
}, field.title), /*#__PURE__*/_react.default.createElement(_pickers.MuiPickersUtilsProvider, {
|
|
133
|
+
utils: disableToolbar ? _dayjs.default : CustomUtils,
|
|
134
|
+
locale: _es.default
|
|
135
|
+
}, /*#__PURE__*/_react.default.createElement(_pickers.KeyboardDatePicker, _extends({
|
|
136
|
+
disabled: disabled,
|
|
137
|
+
value: pickedDate,
|
|
138
|
+
label: inputVariant === 'standard' && (field === null || field === void 0 ? void 0 : field.title),
|
|
139
|
+
error: (0, _form.shouldShowErrors)(meta),
|
|
140
|
+
helperText: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, helpText && /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
141
|
+
colorTheme: "gray",
|
|
142
|
+
variant: "small",
|
|
143
|
+
withMarkdown: true
|
|
144
|
+
}, helpText), !(0, _isEmpty.default)(errorMessage) && /*#__PURE__*/_react.default.createElement(_UTValidation.default, {
|
|
145
|
+
validationData: (0, _utils.formatErrorToValidation)(errorMessage)
|
|
146
|
+
})),
|
|
147
|
+
onError: handleError,
|
|
148
|
+
onAccept: handleRemoveError,
|
|
149
|
+
disableToolbar: disableToolbar,
|
|
150
|
+
keyboardIcon: /*#__PURE__*/_react.default.createElement("div", {
|
|
151
|
+
ref: operenerIconReference
|
|
152
|
+
}, /*#__PURE__*/_react.default.createElement(OpenerIcon, {
|
|
153
|
+
className: disabled ? classes.disabledOpenerIcon : classes.openerIcon
|
|
154
|
+
})),
|
|
155
|
+
variant: variant || _constants.VARIANT,
|
|
156
|
+
InputProps: {
|
|
157
|
+
classes: {
|
|
158
|
+
root: classes.input,
|
|
159
|
+
notchedOutline: classes.notchedOutline
|
|
160
|
+
},
|
|
161
|
+
placeholder: inputVariant === 'outlined' && (placeholder || (field === null || field === void 0 ? void 0 : field.placeholder)) || undefined,
|
|
162
|
+
...inputProps
|
|
163
|
+
},
|
|
164
|
+
invalidDateMessage: invalidDateMessage || _constants.WRONG_DATE_FORMAT,
|
|
165
|
+
inputVariant: inputVariant,
|
|
166
|
+
format: _constants.OUTPUT_LABEL_MASK,
|
|
167
|
+
maxDateMessage: maxDateMessage || _constants.MAX_DATE_MSG,
|
|
168
|
+
minDateMessage: minDateMessage || _constants.MIN_DATE_MSG,
|
|
169
|
+
InputAdornmentProps: {
|
|
170
|
+
position: _constants.BUTTON_POSITION
|
|
171
|
+
},
|
|
172
|
+
onChange: handleChange,
|
|
173
|
+
renderDay: renderDay,
|
|
174
|
+
PopoverProps: {
|
|
175
|
+
...(iconAnchor ? (0, _constants.iconAnchorProps)(operenerIconReference) : {}),
|
|
176
|
+
...popoverProps
|
|
177
|
+
}
|
|
178
|
+
}, pickerProps, {
|
|
179
|
+
minDate: minDate,
|
|
180
|
+
maxDate: maxDate
|
|
181
|
+
}))));
|
|
182
|
+
};
|
|
183
|
+
UTDatePickerV0.propTypes = {
|
|
184
|
+
actions: (0, _propTypes.arrayOf)(_buttonTypes.buttonTypes),
|
|
185
|
+
classNames: _types.classesPropTypes,
|
|
186
|
+
classes: _types.classesPropTypes,
|
|
187
|
+
CustomIcon: _propTypes.node,
|
|
188
|
+
dayFormat: _propTypes.string,
|
|
189
|
+
disableToolbar: _propTypes.bool,
|
|
190
|
+
disabled: _propTypes.bool,
|
|
191
|
+
field: _formTypes.fieldType,
|
|
192
|
+
helpText: _propTypes.string,
|
|
193
|
+
iconAnchor: _propTypes.bool,
|
|
194
|
+
input: _formTypes.inputPropTypes.isRequired,
|
|
195
|
+
inputFormat: _propTypes.string,
|
|
196
|
+
inputProps: _propTypes.object,
|
|
197
|
+
inputVariant: _propTypes.string,
|
|
198
|
+
invalidDateMessage: _propTypes.string,
|
|
199
|
+
maxDateMessage: _propTypes.string,
|
|
200
|
+
meta: _formTypes.metaPropTypes,
|
|
201
|
+
minDateMessage: _propTypes.string,
|
|
202
|
+
pickerProps: _propTypes.object,
|
|
203
|
+
placeholder: _propTypes.string,
|
|
204
|
+
popoverProps: _propTypes.object,
|
|
205
|
+
range: (0, _propTypes.shape)({
|
|
206
|
+
maxDate: _propTypes.string,
|
|
207
|
+
minDate: _propTypes.string
|
|
208
|
+
}),
|
|
209
|
+
titleVariant: _propTypes.string,
|
|
210
|
+
variant: _propTypes.string,
|
|
211
|
+
withUpperTitle: _propTypes.bool
|
|
212
|
+
};
|
|
213
|
+
var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle, _theme.materialTheme)(UTDatePickerV0);
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.retrieveStyle = exports.materialTheme = void 0;
|
|
7
7
|
var _seamlessImmutable = require("seamless-immutable");
|
|
8
8
|
var _styles = require("@material-ui/core/styles");
|
|
9
|
-
var _colorsModule = _interopRequireDefault(require("
|
|
10
|
-
var _classesUtils = require("
|
|
9
|
+
var _colorsModule = _interopRequireDefault(require("../../../../scss/variables/colors.module.scss"));
|
|
10
|
+
var _classesUtils = require("../../../../utils/classesUtils");
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
const retrieveStyle = _ref => {
|
|
13
13
|
let {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# UTDatePicker V1
|
|
2
|
+
|
|
3
|
+
Selector de fecha con input custom y calendario popup. Implementa los 5 estados visuales del design system mediante dos variantes de apariencia (`select` y `picker`).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Diferencias con V0
|
|
8
|
+
|
|
9
|
+
| Aspecto | V0 | V1 |
|
|
10
|
+
|---------|----|----|
|
|
11
|
+
| Input | `KeyboardDatePicker` de MUI Pickers | Input custom con estados visuales |
|
|
12
|
+
| Calendario | MUI Pickers (popup nativo) | Grid custom con `dayjs` |
|
|
13
|
+
| Estilos | `materialTheme` overrides | CSS Modules + design tokens |
|
|
14
|
+
| Estado visual | Sin distinción de estados | 5 estados: default, selected, focus, error, readOnly |
|
|
15
|
+
| Prop nueva | — | `readOnly`, `variant` |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Props
|
|
20
|
+
|
|
21
|
+
| Prop | Tipo | Default | Descripción |
|
|
22
|
+
|------|------|---------|-------------|
|
|
23
|
+
| `classNames` | `object` | — | Clases CSS para sobreescribir estilos internos |
|
|
24
|
+
| `CustomIcon` | `elementType` | — | Reemplaza el ícono de calendario |
|
|
25
|
+
| `disabled` | `bool` | — | Deshabilita toda interacción |
|
|
26
|
+
| `error` | `string` | `''` | Mensaje de error externo |
|
|
27
|
+
| `helpText` | `string` | — | Texto de ayuda debajo del input |
|
|
28
|
+
| `onChange` | `func` | `() => {}` | Callback al confirmar fecha. Recibe string `'DD/MM/YYYY'` |
|
|
29
|
+
| `placeholder` | `string` | `'DD/MM/AAAA'` | Texto cuando no hay fecha seleccionada |
|
|
30
|
+
| `popoverProps` | `object` | — | Props adicionales para el `Popover` de MUI Core |
|
|
31
|
+
| `range` | `{ minDate: string, maxDate: string }` | — | Limita el rango de fechas seleccionables. Formato `'DD/MM/YYYY'` |
|
|
32
|
+
| `readOnly` | `bool` | `false` | Muestra solo texto sin chrome ni interacción |
|
|
33
|
+
| `required` | `bool` | — | Marca el título como requerido |
|
|
34
|
+
| `size` | `'sm' \| 'md'` | `'sm'` | Tamaño del input |
|
|
35
|
+
| `title` | `string` | — | Etiqueta superior del campo |
|
|
36
|
+
| `value` | `string` | `''` | Fecha seleccionada en formato `'DD/MM/YYYY'` |
|
|
37
|
+
| `variant` | `'select' \| 'picker'` | `'select'` | Apariencia del campo. `select` muestra borde estándar con mensaje de error debajo; `picker` usa fondos de color por estado sin borde ni mensaje |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Estados visuales
|
|
42
|
+
|
|
43
|
+
### `variant='select'` (default)
|
|
44
|
+
|
|
45
|
+
| Estado | Condición | Fondo | Borde | Íconos |
|
|
46
|
+
|--------|-----------|-------|-------|--------|
|
|
47
|
+
| **default** | Sin valor, sin foco, sin error | blanco | `1px` gris | calendario (derecha) |
|
|
48
|
+
| **selected** | Tiene fecha seleccionada | blanco | `1px` gris | X/clear (derecha) |
|
|
49
|
+
| **focus** | Calendario abierto | blanco | `2px` azul | X (si hay valor) + calendario (derecha) |
|
|
50
|
+
| **error** | `error` prop o fecha inválida | rojo claro | `1px` rojo | alerta (izquierda) + calendario rojo + mensaje debajo |
|
|
51
|
+
| **readOnly/disabled** | `readOnly` o `disabled` | — | ninguno | sin íconos |
|
|
52
|
+
|
|
53
|
+
### `variant='picker'`
|
|
54
|
+
|
|
55
|
+
| Estado | Condición | Fondo | Borde | Íconos |
|
|
56
|
+
|--------|-----------|-------|-------|--------|
|
|
57
|
+
| **default** | Sin valor, sin foco, sin error | transparente | ninguno | calendario (derecha) |
|
|
58
|
+
| **selected** | Tiene fecha seleccionada, sin foco | azul claro | ninguno | X/clear (derecha) |
|
|
59
|
+
| **focus** | Calendario abierto, sin error | blanco | `2px` azul | X (si hay valor) + calendario (derecha) |
|
|
60
|
+
| **error** | `error` prop o fecha inválida | rojo claro | ninguno | alerta (izquierda) + calendario rojo |
|
|
61
|
+
| **readOnly/disabled** | `readOnly` o `disabled` | transparente | ninguno | sin íconos |
|
|
62
|
+
|
|
63
|
+
Prioridad cuando hay múltiples condiciones activas: `readOnly → disabled → error → focus → selected → default`
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Ejemplos de uso
|
|
68
|
+
|
|
69
|
+
```jsx
|
|
70
|
+
// Básico
|
|
71
|
+
<UTDatePicker version="V1" onChange={setValue} value={value} />
|
|
72
|
+
|
|
73
|
+
// Variante picker
|
|
74
|
+
<UTDatePicker version="V1" onChange={setValue} value={value} variant="picker" />
|
|
75
|
+
|
|
76
|
+
// Con rango de fechas
|
|
77
|
+
<UTDatePicker
|
|
78
|
+
version="V1"
|
|
79
|
+
onChange={setValue}
|
|
80
|
+
value={value}
|
|
81
|
+
range={{ minDate: '01/01/2024', maxDate: '31/12/2024' }}
|
|
82
|
+
/>
|
|
83
|
+
|
|
84
|
+
// Solo lectura con valor
|
|
85
|
+
<UTDatePicker version="V1" onChange={() => {}} value="15/06/2024" readOnly />
|
|
86
|
+
|
|
87
|
+
// Con error externo
|
|
88
|
+
<UTDatePicker version="V1" onChange={setValue} value={value} error="La fecha ingresada no es válida." />
|
|
89
|
+
```
|