@rolster/react-components 18.14.1 → 18.15.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/dist/cjs/assets/{index--xgdaD5z.css → index-xOmRdBnF.css} +51 -86
- package/dist/cjs/index.js +610 -185
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/assets/{index--xgdaD5z.css → index-xOmRdBnF.css} +51 -86
- package/dist/es/index.js +548 -123
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/atoms/Amount/Amount.js +1 -1
- package/dist/esm/components/atoms/Amount/Amount.js.map +1 -1
- package/dist/esm/components/atoms/Avatar/Avatar.css +1 -1
- package/dist/esm/components/atoms/Button/Button.d.ts +2 -2
- package/dist/esm/components/atoms/Input/Input.js +0 -3
- package/dist/esm/components/atoms/Input/Input.js.map +1 -1
- package/dist/esm/components/atoms/InputMoney/InputMoney.css +2 -0
- package/dist/esm/components/atoms/InputPassword/InputPassword.js +0 -3
- package/dist/esm/components/atoms/InputPassword/InputPassword.js.map +1 -1
- package/dist/esm/components/atoms/{SearchInput/SearchInput.css → InputSearch/InputSearch.css} +1 -2
- package/dist/esm/components/atoms/InputSearch/InputSearch.d.ts +9 -0
- package/dist/esm/components/atoms/{SearchInput/SearchInput.js → InputSearch/InputSearch.js} +4 -4
- package/dist/esm/components/atoms/{SearchInput/SearchInput.js.map → InputSearch/InputSearch.js.map} +1 -1
- package/dist/esm/components/atoms/Label/Label.css +6 -0
- package/dist/esm/components/atoms/Poster/Poster.css +4 -3
- package/dist/esm/components/atoms/ProgressBar/ProgressBar.css +1 -2
- package/dist/esm/components/atoms/RadioButton/RadioButton.css +0 -1
- package/dist/esm/components/atoms/Skeleton/Skeleton.css +3 -4
- package/dist/esm/components/atoms/SkeletonText/SkeletonText.css +8 -48
- package/dist/esm/components/atoms/SkeletonText/SkeletonText.js +2 -2
- package/dist/esm/components/atoms/SkeletonText/SkeletonText.js.map +1 -1
- package/dist/esm/components/atoms/TabularText/TabularText.css +5 -2
- package/dist/esm/components/atoms/index.d.ts +1 -1
- package/dist/esm/components/atoms/index.js +1 -1
- package/dist/esm/components/atoms/index.js.map +1 -1
- package/dist/esm/components/molecules/Ballot/Ballot.css +1 -1
- package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.d.ts +2 -2
- package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js.map +1 -1
- package/dist/esm/components/molecules/FieldMoney/FieldMoney.js +1 -1
- package/dist/esm/components/molecules/FieldMoney/FieldMoney.js.map +1 -1
- package/dist/esm/components/molecules/FieldNumber/FieldNumber.js +1 -1
- package/dist/esm/components/molecules/FieldNumber/FieldNumber.js.map +1 -1
- package/dist/esm/components/molecules/FieldPassword/FieldPassword.js +1 -1
- package/dist/esm/components/molecules/FieldPassword/FieldPassword.js.map +1 -1
- package/dist/esm/components/molecules/FieldText/FieldText.js +1 -1
- package/dist/esm/components/molecules/FieldText/FieldText.js.map +1 -1
- package/dist/esm/components/molecules/LabelCheckBox/LabelCheckBox.js +2 -2
- package/dist/esm/components/molecules/LabelCheckBox/LabelCheckBox.js.map +1 -1
- package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.js +1 -1
- package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.js.map +1 -1
- package/dist/esm/components/molecules/LabelSwitch/LabelSwitch.js +2 -2
- package/dist/esm/components/molecules/LabelSwitch/LabelSwitch.js.map +1 -1
- package/dist/esm/components/molecules/MessageFormError/{MesageFormError.js → MessageFormError.js} +1 -1
- package/dist/esm/components/molecules/MessageFormError/MessageFormError.js.map +1 -0
- package/dist/esm/components/molecules/PickerDay/PickerDay.js +3 -3
- package/dist/esm/components/molecules/PickerDay/PickerDay.js.map +1 -1
- package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.d.ts +1 -1
- package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js +2 -2
- package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js.map +1 -1
- package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +2 -2
- package/dist/esm/components/molecules/PickerMonth/PickerMonth.js.map +1 -1
- package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js +3 -3
- package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js.map +1 -1
- package/dist/esm/components/molecules/PickerYear/PickerYear.js +2 -2
- package/dist/esm/components/molecules/PickerYear/PickerYear.js.map +1 -1
- package/dist/esm/components/molecules/index.d.ts +1 -1
- package/dist/esm/components/molecules/index.js +1 -1
- package/dist/esm/components/molecules/index.js.map +1 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.css +15 -12
- package/dist/esm/components/organisms/Confirmation/Confirmation.d.ts +1 -1
- package/dist/esm/components/organisms/Confirmation/Confirmation.js +2 -10
- package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.d.ts +4 -4
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.d.ts +4 -4
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js +1 -1
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js.map +1 -1
- package/dist/esm/components/organisms/FieldDate/FieldDate.d.ts +1 -1
- package/dist/esm/components/organisms/FieldDate/FieldDate.js +4 -8
- package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.d.ts +2 -2
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +1 -1
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js.map +1 -1
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.d.ts +2 -2
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.d.ts +2 -2
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js.map +1 -1
- package/dist/esm/components/organisms/PickerDate/PickerDate.d.ts +2 -2
- package/dist/esm/components/organisms/PickerDate/PickerDate.js +4 -4
- package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.d.ts +3 -3
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js +2 -2
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js.map +1 -1
- package/dist/esm/helpers/date-range-picker.d.ts +1 -1
- package/dist/esm/helpers/date-range-picker.js +1 -1
- package/dist/esm/helpers/date-range-picker.js.map +1 -1
- package/dist/esm/hooks/DatatableHook.js +7 -4
- package/dist/esm/hooks/DatatableHook.js.map +1 -1
- package/dist/esm/hooks/ListControlHook.d.ts +14 -12
- package/dist/esm/hooks/ListControlHook.js +34 -26
- package/dist/esm/hooks/ListControlHook.js.map +1 -1
- package/package.json +12 -9
- package/dist/esm/components/atoms/SearchInput/SearchInput.d.ts +0 -9
- package/dist/esm/components/molecules/MessageFormError/MesageFormError.css +0 -0
- package/dist/esm/components/molecules/MessageFormError/MesageFormError.js.map +0 -1
- /package/dist/esm/components/molecules/MessageFormError/{MesageFormError.d.ts → MessageFormError.d.ts} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -2,14 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var react = require('react');
|
|
5
|
-
var helpersAdvanced = require('@rolster/helpers-advanced');
|
|
6
5
|
var helpersString = require('@rolster/helpers-string');
|
|
7
|
-
var helpersDate = require('@rolster/helpers-date');
|
|
8
|
-
var ReactDOM = require('react-dom');
|
|
9
6
|
var i18n = require('@rolster/i18n');
|
|
10
|
-
var
|
|
7
|
+
var ReactDOM = require('react-dom');
|
|
11
8
|
require('uuid');
|
|
12
|
-
|
|
9
|
+
|
|
10
|
+
function currencyFormat(currency) {
|
|
11
|
+
const { value, decimals, symbol } = currency;
|
|
12
|
+
const [integer, decimal] = Math.abs(value).toString().split('.');
|
|
13
|
+
let result = '';
|
|
14
|
+
let count = 0;
|
|
15
|
+
for (let i = 1; i <= integer.length; i++) {
|
|
16
|
+
const index = integer.length - i;
|
|
17
|
+
if (count === 3) {
|
|
18
|
+
count = 0;
|
|
19
|
+
result = `.${result}`;
|
|
20
|
+
}
|
|
21
|
+
count++;
|
|
22
|
+
result = `${integer.charAt(index)}${result}`;
|
|
23
|
+
}
|
|
24
|
+
if (decimals && decimal) {
|
|
25
|
+
result = `${result},${decimal.slice(0, 2)}`;
|
|
26
|
+
}
|
|
27
|
+
if (value < 0) {
|
|
28
|
+
result = `-${result}`;
|
|
29
|
+
}
|
|
30
|
+
return symbol ? `${symbol} ${result}` : result;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class PartialSealed {
|
|
34
|
+
constructor(key, value) {
|
|
35
|
+
this.key = key;
|
|
36
|
+
this.value = value;
|
|
37
|
+
}
|
|
38
|
+
otherwise(otherwise) {
|
|
39
|
+
this.sealedOtherwise = otherwise;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
when(resolver, whenOtherwise) {
|
|
43
|
+
const handler = resolver[this.key];
|
|
44
|
+
const otherwise = whenOtherwise || this.sealedOtherwise;
|
|
45
|
+
if (otherwise) {
|
|
46
|
+
otherwise();
|
|
47
|
+
}
|
|
48
|
+
return handler ? handler(this.value) : undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function itIsDefined(object) {
|
|
53
|
+
return typeof object !== 'undefined' && object !== null;
|
|
54
|
+
}
|
|
13
55
|
|
|
14
56
|
const baseCls = 'rls-tabular-text';
|
|
15
57
|
const pointers = ['.', ','];
|
|
@@ -21,7 +63,7 @@ function RlsTabularText({ value }) {
|
|
|
21
63
|
}
|
|
22
64
|
|
|
23
65
|
function RlsAmount({ value, decimals, rlsTheme, symbol }) {
|
|
24
|
-
return (jsxRuntime.jsxs("div", { className: "rls-amount", "rls-theme": rlsTheme, children: [symbol && jsxRuntime.jsx("span", { children: symbol }), jsxRuntime.jsx(RlsTabularText, { value:
|
|
66
|
+
return (jsxRuntime.jsxs("div", { className: "rls-amount", "rls-theme": rlsTheme, children: [symbol && jsxRuntime.jsx("span", { children: symbol }), jsxRuntime.jsx(RlsTabularText, { value: currencyFormat({ value, decimals }) })] }));
|
|
25
67
|
}
|
|
26
68
|
|
|
27
69
|
function renderClassStatus(base, status = {}, aditionals) {
|
|
@@ -88,9 +130,6 @@ function RlsInput({ children, disabled, formControl, placeholder, type, value, o
|
|
|
88
130
|
setFocused(true);
|
|
89
131
|
}
|
|
90
132
|
function onBlur() {
|
|
91
|
-
if (formControl && !formControl.touched) {
|
|
92
|
-
formControl.touch();
|
|
93
|
-
}
|
|
94
133
|
formControl?.blur();
|
|
95
134
|
setFocused(false);
|
|
96
135
|
}
|
|
@@ -139,9 +178,6 @@ function RlsInputPassword({ disabled, formControl, placeholder, type, onValue })
|
|
|
139
178
|
setFocused(true);
|
|
140
179
|
}
|
|
141
180
|
function onBlur() {
|
|
142
|
-
if (formControl && !formControl.touched) {
|
|
143
|
-
formControl.touch();
|
|
144
|
-
}
|
|
145
181
|
formControl?.blur();
|
|
146
182
|
setFocused(false);
|
|
147
183
|
}
|
|
@@ -151,6 +187,10 @@ function RlsInputPassword({ disabled, formControl, placeholder, type, onValue })
|
|
|
151
187
|
}), children: jsxRuntime.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type || 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
|
|
152
188
|
}
|
|
153
189
|
|
|
190
|
+
function RlsInputSearch({ formControl, placeholder, onSearch }) {
|
|
191
|
+
return (jsxRuntime.jsxs("div", { className: "rls-input-search", children: [jsxRuntime.jsx(RlsInput, { formControl: formControl, placeholder: placeholder }), onSearch && jsxRuntime.jsx(RlsButtonAction, { icon: "search", onClick: onSearch })] }));
|
|
192
|
+
}
|
|
193
|
+
|
|
154
194
|
function RlsInputText({ disabled, formControl, placeholder, value, onValue }) {
|
|
155
195
|
const [valueInput, setValueInput] = react.useState(value || '');
|
|
156
196
|
function onText(value) {
|
|
@@ -188,16 +228,12 @@ function RlsRadioButton({ checked, disabled, rlsTheme, onClick }) {
|
|
|
188
228
|
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-radiobutton', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-radiobutton__component" }) }));
|
|
189
229
|
}
|
|
190
230
|
|
|
191
|
-
function RlsSearchInput({ formControl, placeholder, onSearch }) {
|
|
192
|
-
return (jsxRuntime.jsxs("div", { className: "rls-search-input", children: [jsxRuntime.jsx(RlsInput, { formControl: formControl, placeholder: placeholder }), onSearch && jsxRuntime.jsx(RlsButtonAction, { icon: "search", onClick: onSearch })] }));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
231
|
function RlsSkeleton({ rlsTheme }) {
|
|
196
232
|
return jsxRuntime.jsx("div", { className: "rls-skeleton", "rls-theme": rlsTheme });
|
|
197
233
|
}
|
|
198
234
|
|
|
199
235
|
function RlsSkeletonText({ active, children, rlsTheme }) {
|
|
200
|
-
return (jsxRuntime.jsx("div", { className:
|
|
236
|
+
return (jsxRuntime.jsx("div", { className: "rls-skeleton-text", "rls-theme": rlsTheme, children: active ? (jsxRuntime.jsx(RlsSkeleton, {})) : (jsxRuntime.jsx("span", { className: "rls-skeleton-text__value", children: children })) }));
|
|
201
237
|
}
|
|
202
238
|
|
|
203
239
|
function RlsSwitch({ checked, disabled, rlsTheme, onClick }) {
|
|
@@ -290,9 +326,9 @@ function RlsFieldText({ children, disabled, formControl, placeholder, rlsTheme,
|
|
|
290
326
|
}
|
|
291
327
|
|
|
292
328
|
function RlsLabelCheckBox({ children, disabled, extended, formControl, rlsTheme }) {
|
|
293
|
-
const [checked, setChecked] = react.useState(formControl?.
|
|
329
|
+
const [checked, setChecked] = react.useState(!!formControl?.state);
|
|
294
330
|
react.useEffect(() => {
|
|
295
|
-
setChecked(formControl?.state
|
|
331
|
+
setChecked(!!formControl?.state);
|
|
296
332
|
}, [formControl?.state]);
|
|
297
333
|
function onToggle() {
|
|
298
334
|
if (formControl) {
|
|
@@ -309,7 +345,7 @@ function RlsLabelCheckBox({ children, disabled, extended, formControl, rlsTheme
|
|
|
309
345
|
}
|
|
310
346
|
|
|
311
347
|
function RlsLabelRadioButton({ children, disabled, extended, formControl, rlsTheme, value }) {
|
|
312
|
-
const [checked, setChecked] = react.useState(formControl?.state
|
|
348
|
+
const [checked, setChecked] = react.useState(formControl?.state === value);
|
|
313
349
|
react.useEffect(() => {
|
|
314
350
|
setChecked(formControl?.state === value);
|
|
315
351
|
}, [formControl?.state]);
|
|
@@ -325,9 +361,9 @@ function RlsLabelRadioButton({ children, disabled, extended, formControl, rlsThe
|
|
|
325
361
|
}
|
|
326
362
|
|
|
327
363
|
function RlsLabelSwitch({ children, disabled, extended, formControl, rlsTheme }) {
|
|
328
|
-
const [checked, setChecked] = react.useState(formControl?.
|
|
364
|
+
const [checked, setChecked] = react.useState(!!formControl?.state);
|
|
329
365
|
react.useEffect(() => {
|
|
330
|
-
setChecked(formControl?.state
|
|
366
|
+
setChecked(!!formControl?.state);
|
|
331
367
|
}, [formControl?.state]);
|
|
332
368
|
function onToggle() {
|
|
333
369
|
if (formControl) {
|
|
@@ -553,13 +589,374 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
553
589
|
}) }), jsxRuntime.jsx("div", { className: "rls-pagination__description", children: description }), jsxRuntime.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntime.jsx("button", { className: "rls-pagination__action", onClick: goNextPagination, disabled: lastPage, children: jsxRuntime.jsx(RlsIcon, { value: "arrow-ios-right" }) }), jsxRuntime.jsx("button", { className: "rls-pagination__action", onClick: goLastPagination, disabled: lastPage, children: jsxRuntime.jsx(RlsIcon, { value: "arrowhead-right" }) })] })] }));
|
|
554
590
|
}
|
|
555
591
|
|
|
592
|
+
const dateI18n = i18n.i18n({
|
|
593
|
+
es: {
|
|
594
|
+
// Months
|
|
595
|
+
january: 'Enero',
|
|
596
|
+
february: 'Febrero',
|
|
597
|
+
march: 'Marzo',
|
|
598
|
+
april: 'Abril',
|
|
599
|
+
may: 'Mayo',
|
|
600
|
+
june: 'Junio',
|
|
601
|
+
july: 'Julio',
|
|
602
|
+
august: 'Agosto',
|
|
603
|
+
september: 'Septiembre',
|
|
604
|
+
october: 'Octubre',
|
|
605
|
+
november: 'Noviembre',
|
|
606
|
+
december: 'Diciembre',
|
|
607
|
+
// Days
|
|
608
|
+
monday: 'Lunes',
|
|
609
|
+
tuesday: 'Martes',
|
|
610
|
+
wednesday: 'Miércoles',
|
|
611
|
+
thursday: 'Jueves',
|
|
612
|
+
friday: 'Viernes',
|
|
613
|
+
saturday: 'Sábado',
|
|
614
|
+
sunday: 'Domingo',
|
|
615
|
+
// Timestamps
|
|
616
|
+
year: 'año',
|
|
617
|
+
month: 'mes',
|
|
618
|
+
week: 'semana',
|
|
619
|
+
day: 'día',
|
|
620
|
+
hour: 'hora',
|
|
621
|
+
minute: 'minuto',
|
|
622
|
+
second: 'segundo'
|
|
623
|
+
},
|
|
624
|
+
en: {
|
|
625
|
+
// Months
|
|
626
|
+
january: 'January',
|
|
627
|
+
february: 'February',
|
|
628
|
+
march: 'March',
|
|
629
|
+
april: 'April',
|
|
630
|
+
may: 'May',
|
|
631
|
+
june: 'June',
|
|
632
|
+
july: 'July',
|
|
633
|
+
august: 'August',
|
|
634
|
+
september: 'September',
|
|
635
|
+
october: 'October',
|
|
636
|
+
november: 'November',
|
|
637
|
+
december: 'December',
|
|
638
|
+
// Days
|
|
639
|
+
monday: 'Monday',
|
|
640
|
+
tuesday: 'Tuesday',
|
|
641
|
+
wednesday: 'Wednesday',
|
|
642
|
+
thursday: 'Thursday',
|
|
643
|
+
friday: 'Friday',
|
|
644
|
+
saturday: 'Saturday',
|
|
645
|
+
sunday: 'Sunday',
|
|
646
|
+
// Timestamps
|
|
647
|
+
year: 'year',
|
|
648
|
+
month: 'month',
|
|
649
|
+
week: 'week',
|
|
650
|
+
day: 'day',
|
|
651
|
+
hour: 'hour',
|
|
652
|
+
minute: 'minute',
|
|
653
|
+
second: 'second'
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
var Miliseconds;
|
|
658
|
+
(function (Miliseconds) {
|
|
659
|
+
Miliseconds[Miliseconds["Year"] = 31536000000] = "Year";
|
|
660
|
+
Miliseconds[Miliseconds["Month"] = 2592000000] = "Month";
|
|
661
|
+
Miliseconds[Miliseconds["Week"] = 604800000] = "Week";
|
|
662
|
+
Miliseconds[Miliseconds["Day"] = 86400000] = "Day";
|
|
663
|
+
Miliseconds[Miliseconds["Hour"] = 3600000] = "Hour";
|
|
664
|
+
Miliseconds[Miliseconds["Minute"] = 60000] = "Minute";
|
|
665
|
+
Miliseconds[Miliseconds["Second"] = 1000] = "Second";
|
|
666
|
+
})(Miliseconds || (Miliseconds = {}));
|
|
667
|
+
var Day;
|
|
668
|
+
(function (Day) {
|
|
669
|
+
Day[Day["Sunday"] = 0] = "Sunday";
|
|
670
|
+
Day[Day["Monday"] = 1] = "Monday";
|
|
671
|
+
Day[Day["Tuesday"] = 2] = "Tuesday";
|
|
672
|
+
Day[Day["Wednesday"] = 3] = "Wednesday";
|
|
673
|
+
Day[Day["Thursday"] = 4] = "Thursday";
|
|
674
|
+
Day[Day["Friday"] = 5] = "Friday";
|
|
675
|
+
Day[Day["Saturday"] = 6] = "Saturday";
|
|
676
|
+
})(Day || (Day = {}));
|
|
677
|
+
var Month;
|
|
678
|
+
(function (Month) {
|
|
679
|
+
Month[Month["January"] = 0] = "January";
|
|
680
|
+
Month[Month["February"] = 1] = "February";
|
|
681
|
+
Month[Month["March"] = 2] = "March";
|
|
682
|
+
Month[Month["April"] = 3] = "April";
|
|
683
|
+
Month[Month["May"] = 4] = "May";
|
|
684
|
+
Month[Month["June"] = 5] = "June";
|
|
685
|
+
Month[Month["July"] = 6] = "July";
|
|
686
|
+
Month[Month["August"] = 7] = "August";
|
|
687
|
+
Month[Month["September"] = 8] = "September";
|
|
688
|
+
Month[Month["October"] = 9] = "October";
|
|
689
|
+
Month[Month["November"] = 10] = "November";
|
|
690
|
+
Month[Month["December"] = 11] = "December";
|
|
691
|
+
})(Month || (Month = {}));
|
|
692
|
+
var MonthDay;
|
|
693
|
+
(function (MonthDay) {
|
|
694
|
+
MonthDay[MonthDay["January"] = 31] = "January";
|
|
695
|
+
MonthDay[MonthDay["February"] = 28] = "February";
|
|
696
|
+
MonthDay[MonthDay["March"] = 31] = "March";
|
|
697
|
+
MonthDay[MonthDay["April"] = 30] = "April";
|
|
698
|
+
MonthDay[MonthDay["May"] = 31] = "May";
|
|
699
|
+
MonthDay[MonthDay["June"] = 30] = "June";
|
|
700
|
+
MonthDay[MonthDay["July"] = 31] = "July";
|
|
701
|
+
MonthDay[MonthDay["August"] = 31] = "August";
|
|
702
|
+
MonthDay[MonthDay["September"] = 30] = "September";
|
|
703
|
+
MonthDay[MonthDay["October"] = 31] = "October";
|
|
704
|
+
MonthDay[MonthDay["November"] = 30] = "November";
|
|
705
|
+
MonthDay[MonthDay["December"] = 31] = "December";
|
|
706
|
+
})(MonthDay || (MonthDay = {}));
|
|
707
|
+
|
|
708
|
+
let MONTH_NAMES_I18N = [];
|
|
709
|
+
let MONTH_LABELS_I18N = [];
|
|
710
|
+
let DAY_NAMES_I18N = [];
|
|
711
|
+
let DAY_LABELS_I18N = [];
|
|
712
|
+
function loadI18n(language = 'es') {
|
|
713
|
+
MONTH_NAMES_I18N = [
|
|
714
|
+
dateI18n('january', { language }),
|
|
715
|
+
dateI18n('february', { language }),
|
|
716
|
+
dateI18n('march', { language }),
|
|
717
|
+
dateI18n('april', { language }),
|
|
718
|
+
dateI18n('may', { language }),
|
|
719
|
+
dateI18n('june', { language }),
|
|
720
|
+
dateI18n('july', { language }),
|
|
721
|
+
dateI18n('august', { language }),
|
|
722
|
+
dateI18n('september', { language }),
|
|
723
|
+
dateI18n('october', { language }),
|
|
724
|
+
dateI18n('november', { language }),
|
|
725
|
+
dateI18n('december', { language })
|
|
726
|
+
];
|
|
727
|
+
MONTH_LABELS_I18N = MONTH_NAMES_I18N.map((name) => name.substring(0, 3));
|
|
728
|
+
DAY_NAMES_I18N = [
|
|
729
|
+
dateI18n('sunday', { language }),
|
|
730
|
+
dateI18n('monday', { language }),
|
|
731
|
+
dateI18n('tuesday', { language }),
|
|
732
|
+
dateI18n('wednesday', { language }),
|
|
733
|
+
dateI18n('thursday', { language }),
|
|
734
|
+
dateI18n('friday', { language }),
|
|
735
|
+
dateI18n('saturday', { language })
|
|
736
|
+
];
|
|
737
|
+
DAY_LABELS_I18N = DAY_NAMES_I18N.map((name) => name.substring(0, 3));
|
|
738
|
+
}
|
|
739
|
+
function isNumber(value) {
|
|
740
|
+
return value !== undefined && value !== null;
|
|
741
|
+
}
|
|
742
|
+
loadI18n();
|
|
743
|
+
i18n.i18nSubscribe((language) => loadI18n(language));
|
|
744
|
+
const MONTH_DAYS = [
|
|
745
|
+
MonthDay.January,
|
|
746
|
+
MonthDay.February,
|
|
747
|
+
MonthDay.March,
|
|
748
|
+
MonthDay.April,
|
|
749
|
+
MonthDay.May,
|
|
750
|
+
MonthDay.June,
|
|
751
|
+
MonthDay.July,
|
|
752
|
+
MonthDay.August,
|
|
753
|
+
MonthDay.September,
|
|
754
|
+
MonthDay.October,
|
|
755
|
+
MonthDay.November,
|
|
756
|
+
MonthDay.December
|
|
757
|
+
];
|
|
758
|
+
function MONTH_NAMES(index) {
|
|
759
|
+
return isNumber(index) ? MONTH_NAMES_I18N[index] || '' : MONTH_NAMES_I18N;
|
|
760
|
+
}
|
|
761
|
+
function MONTH_LABELS(index) {
|
|
762
|
+
return isNumber(index) ? MONTH_LABELS_I18N[index] || '' : MONTH_LABELS_I18N;
|
|
763
|
+
}
|
|
764
|
+
function DAY_NAMES(index) {
|
|
765
|
+
return isNumber(index) ? DAY_NAMES_I18N[index] || '' : DAY_NAMES_I18N;
|
|
766
|
+
}
|
|
767
|
+
function DAY_LABELS(index) {
|
|
768
|
+
return isNumber(index) ? DAY_LABELS_I18N[index] || '' : DAY_LABELS_I18N;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function completFormat(value, size) {
|
|
772
|
+
return value.toString().padStart(size, '0');
|
|
773
|
+
}
|
|
774
|
+
function hourFormat(date) {
|
|
775
|
+
const hour = date.getHours();
|
|
776
|
+
return hour > 12 ? hour - 12 : hour === 0 ? 12 : hour;
|
|
777
|
+
}
|
|
778
|
+
function verifyDayInYear(date, year) {
|
|
779
|
+
const days = getDaysOfMonth(year, date.getMonth());
|
|
780
|
+
if (days < date.getDate()) {
|
|
781
|
+
date.setDate(days);
|
|
782
|
+
}
|
|
783
|
+
date.setFullYear(year); // Establecer el año
|
|
784
|
+
}
|
|
785
|
+
function verifyDayInMonth(date, month) {
|
|
786
|
+
const days = getDaysOfMonth(date.getFullYear(), month);
|
|
787
|
+
if (days < date.getDate()) {
|
|
788
|
+
date.setDate(days);
|
|
789
|
+
}
|
|
790
|
+
date.setMonth(month); // Establecer el mes
|
|
791
|
+
}
|
|
792
|
+
const formatters = {
|
|
793
|
+
dd: (date) => {
|
|
794
|
+
return completFormat(date.getDate(), 2);
|
|
795
|
+
},
|
|
796
|
+
dw: (date) => {
|
|
797
|
+
return DAY_NAMES()[date.getDay()];
|
|
798
|
+
},
|
|
799
|
+
dx: (date) => {
|
|
800
|
+
return DAY_NAMES()[date.getDay()];
|
|
801
|
+
},
|
|
802
|
+
mm: (date) => {
|
|
803
|
+
return completFormat(date.getMonth() + 1, 2);
|
|
804
|
+
},
|
|
805
|
+
mn: (date) => {
|
|
806
|
+
return MONTH_NAMES(date.getMonth());
|
|
807
|
+
},
|
|
808
|
+
mx: (date) => {
|
|
809
|
+
return MONTH_LABELS(date.getMonth());
|
|
810
|
+
},
|
|
811
|
+
aa: (date) => {
|
|
812
|
+
return completFormat(date.getFullYear(), 4);
|
|
813
|
+
},
|
|
814
|
+
hh: (date) => {
|
|
815
|
+
return completFormat(date.getHours(), 2);
|
|
816
|
+
},
|
|
817
|
+
ii: (date) => {
|
|
818
|
+
return completFormat(date.getMinutes(), 2);
|
|
819
|
+
},
|
|
820
|
+
ss: (date) => {
|
|
821
|
+
return completFormat(date.getSeconds(), 2);
|
|
822
|
+
},
|
|
823
|
+
hz: (date) => {
|
|
824
|
+
return completFormat(hourFormat(date), 2);
|
|
825
|
+
},
|
|
826
|
+
zz: (date) => {
|
|
827
|
+
return date.getHours() > 11 ? 'PM' : 'AM';
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
const createElapsedTime = (value, single, charPlural = 's', plural) => {
|
|
831
|
+
plural = plural || `${single}${charPlural}`;
|
|
832
|
+
const label = `${single}(${charPlural})`;
|
|
833
|
+
return {
|
|
834
|
+
value,
|
|
835
|
+
label,
|
|
836
|
+
single,
|
|
837
|
+
plural
|
|
838
|
+
};
|
|
839
|
+
};
|
|
840
|
+
[
|
|
841
|
+
createElapsedTime(Miliseconds.Year, 'año'),
|
|
842
|
+
createElapsedTime(Miliseconds.Month, 'mes', 'es'),
|
|
843
|
+
createElapsedTime(Miliseconds.Week, 'semana'),
|
|
844
|
+
createElapsedTime(Miliseconds.Day, 'día', 's', 'dias'),
|
|
845
|
+
createElapsedTime(Miliseconds.Hour, 'hora'),
|
|
846
|
+
createElapsedTime(Miliseconds.Minute, 'minuto'),
|
|
847
|
+
createElapsedTime(Miliseconds.Second, 'segundo')
|
|
848
|
+
];
|
|
849
|
+
function getDateWeight(date) {
|
|
850
|
+
return date.getFullYear() * 365 + (date.getMonth() + 1) * 30 + date.getDate();
|
|
851
|
+
}
|
|
852
|
+
function dateIsEquals(date, compare = new Date()) {
|
|
853
|
+
return date.getTime() === compare.getTime();
|
|
854
|
+
}
|
|
855
|
+
function dateIsEqualsWeight(date, compare = new Date()) {
|
|
856
|
+
return getDateWeight(date) === getDateWeight(compare);
|
|
857
|
+
}
|
|
858
|
+
function dateIsBefore(date, compare = new Date()) {
|
|
859
|
+
return date.getTime() > compare.getTime();
|
|
860
|
+
}
|
|
861
|
+
function dateIsAfter(date, compare = new Date()) {
|
|
862
|
+
return date.getTime() < compare.getTime();
|
|
863
|
+
}
|
|
864
|
+
function dateIsBetween(minDate, maxDate, compare = new Date()) {
|
|
865
|
+
return dateIsAfter(minDate, compare) && dateIsBefore(maxDate, compare);
|
|
866
|
+
}
|
|
867
|
+
function getTimeDifference(date, compare = new Date()) {
|
|
868
|
+
return date.getTime() - compare.getTime();
|
|
869
|
+
}
|
|
870
|
+
function normalizeMinTime(date) {
|
|
871
|
+
const normalize = new Date(date.getTime());
|
|
872
|
+
normalize.setHours(0);
|
|
873
|
+
normalize.setMinutes(0);
|
|
874
|
+
normalize.setSeconds(0);
|
|
875
|
+
normalize.setMilliseconds(0);
|
|
876
|
+
return normalize;
|
|
877
|
+
}
|
|
878
|
+
function normalizeMaxTime(date) {
|
|
879
|
+
const normalize = new Date(date.getTime());
|
|
880
|
+
normalize.setHours(23);
|
|
881
|
+
normalize.setMinutes(59);
|
|
882
|
+
normalize.setSeconds(59);
|
|
883
|
+
normalize.setMilliseconds(0);
|
|
884
|
+
return normalize;
|
|
885
|
+
}
|
|
886
|
+
function getDaysOfMonth(year, month) {
|
|
887
|
+
return month === 1 && isLeapYear(year) ? 29 : MONTH_DAYS[month];
|
|
888
|
+
}
|
|
889
|
+
function isLeapYear(value) {
|
|
890
|
+
const year = value instanceof Date ? value.getFullYear() : value;
|
|
891
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
892
|
+
}
|
|
893
|
+
const regInterpolation = /{([^{}]*)}/g;
|
|
894
|
+
function dateFormatTemplate(date, template) {
|
|
895
|
+
return template.replace(regInterpolation, (value, key) => formatters[key] ? formatters[key](date) : value);
|
|
896
|
+
}
|
|
897
|
+
function assignYearInDate(date, year) {
|
|
898
|
+
const newDate = new Date(date.getTime());
|
|
899
|
+
verifyDayInYear(newDate, year);
|
|
900
|
+
newDate.setFullYear(year);
|
|
901
|
+
return newDate;
|
|
902
|
+
}
|
|
903
|
+
function assignMonthInDate(date, month) {
|
|
904
|
+
const newDate = new Date(date.getTime());
|
|
905
|
+
verifyDayInMonth(newDate, month);
|
|
906
|
+
newDate.setMonth(month);
|
|
907
|
+
return newDate;
|
|
908
|
+
}
|
|
909
|
+
function assignDayInDate(date, day) {
|
|
910
|
+
const newDate = new Date(date.getTime());
|
|
911
|
+
newDate.setDate(day);
|
|
912
|
+
return newDate;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
class DateRange {
|
|
916
|
+
constructor(minDate, maxDate) {
|
|
917
|
+
this.minDate = normalizeMinTime(minDate);
|
|
918
|
+
this.maxDate =
|
|
919
|
+
maxDate && dateIsBefore(maxDate, minDate)
|
|
920
|
+
? normalizeMinTime(maxDate)
|
|
921
|
+
: normalizeMinTime(minDate);
|
|
922
|
+
}
|
|
923
|
+
get minISOFormat() {
|
|
924
|
+
return this.minDate.toISOString();
|
|
925
|
+
}
|
|
926
|
+
get maxISOFormat() {
|
|
927
|
+
return this.maxDate.toISOString();
|
|
928
|
+
}
|
|
929
|
+
between(date) {
|
|
930
|
+
return dateIsBetween(this.minDate, this.maxDate, date);
|
|
931
|
+
}
|
|
932
|
+
equals({ maxDate, minDate }) {
|
|
933
|
+
return dateIsEquals(this.minDate, minDate) && dateIsEquals(this.maxDate, maxDate);
|
|
934
|
+
}
|
|
935
|
+
recalculate(date) {
|
|
936
|
+
if (dateIsBefore(this.minDate, date)) {
|
|
937
|
+
return new DateRange(date, this.maxDate);
|
|
938
|
+
}
|
|
939
|
+
if (dateIsAfter(this.maxDate, date)) {
|
|
940
|
+
return new DateRange(this.minDate, date);
|
|
941
|
+
}
|
|
942
|
+
const minDifference = getTimeDifference(date, this.minDate);
|
|
943
|
+
const maxDifference = getTimeDifference(this.maxDate, date);
|
|
944
|
+
return minDifference > maxDifference
|
|
945
|
+
? new DateRange(this.minDate, date)
|
|
946
|
+
: new DateRange(date, this.maxDate);
|
|
947
|
+
}
|
|
948
|
+
static now() {
|
|
949
|
+
return new DateRange(new Date());
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
556
953
|
function dateIsOutRangeMin(props) {
|
|
557
954
|
const { date, minDate } = props;
|
|
558
|
-
return !!minDate &&
|
|
955
|
+
return !!minDate && dateIsBefore(normalizeMinTime(minDate), date);
|
|
559
956
|
}
|
|
560
957
|
function dateIsOutRangeMax(props) {
|
|
561
958
|
const { date, maxDate } = props;
|
|
562
|
-
return !!maxDate &&
|
|
959
|
+
return !!maxDate && dateIsAfter(normalizeMaxTime(maxDate), date);
|
|
563
960
|
}
|
|
564
961
|
function dateOutRange(props) {
|
|
565
962
|
return dateIsOutRangeMin(props) || dateIsOutRangeMax(props);
|
|
@@ -583,8 +980,8 @@ function createDayState(props, today, value) {
|
|
|
583
980
|
disabled: dayIsOutside(props, value || 0),
|
|
584
981
|
focused: !!value && day === value,
|
|
585
982
|
forbidden: !value,
|
|
586
|
-
selected: !!dateValue &&
|
|
587
|
-
today: !!dateValue &&
|
|
983
|
+
selected: !!dateValue && dateIsEqualsWeight(date, dateValue),
|
|
984
|
+
today: !!dateValue && dateIsEqualsWeight(today, dateValue),
|
|
588
985
|
value
|
|
589
986
|
};
|
|
590
987
|
}
|
|
@@ -609,7 +1006,7 @@ function createDaysPending$1(props, today, days) {
|
|
|
609
1006
|
return daysPending;
|
|
610
1007
|
}
|
|
611
1008
|
function createNextWeeks$1(props, date, today) {
|
|
612
|
-
const daysMonth =
|
|
1009
|
+
const daysMonth = getDaysOfMonth(date.getFullYear(), date.getMonth());
|
|
613
1010
|
const weeks = [];
|
|
614
1011
|
let days = [];
|
|
615
1012
|
let countDays = 1;
|
|
@@ -634,13 +1031,13 @@ function createNextWeeks$1(props, date, today) {
|
|
|
634
1031
|
function dayIsOutsideMin(props, day) {
|
|
635
1032
|
const { month, year, minDate } = props;
|
|
636
1033
|
return minDate
|
|
637
|
-
?
|
|
1034
|
+
? getDateWeight(new Date(year, month, day)) < getDateWeight(minDate)
|
|
638
1035
|
: false;
|
|
639
1036
|
}
|
|
640
1037
|
function dayIsOutsideMax(props, day) {
|
|
641
1038
|
const { month, year, maxDate } = props;
|
|
642
1039
|
return maxDate
|
|
643
|
-
?
|
|
1040
|
+
? getDateWeight(new Date(year, month, day)) > getDateWeight(maxDate)
|
|
644
1041
|
: false;
|
|
645
1042
|
}
|
|
646
1043
|
function dayIsOutside(props, day) {
|
|
@@ -675,7 +1072,7 @@ function rangeIsSelected({ range }, base, day) {
|
|
|
675
1072
|
dateIsSelected(base, range.maxDate, day));
|
|
676
1073
|
}
|
|
677
1074
|
function dayIsRange({ range }, base, day) {
|
|
678
|
-
return
|
|
1075
|
+
return dateIsBetween(range.minDate, range.maxDate, assignDayInDate(base, day));
|
|
679
1076
|
}
|
|
680
1077
|
function createDayRangeState(props, base, day) {
|
|
681
1078
|
return {
|
|
@@ -710,7 +1107,7 @@ function createDaysPending(props, base, days) {
|
|
|
710
1107
|
function createNextWeeks(props, base) {
|
|
711
1108
|
const weeks = [];
|
|
712
1109
|
const { date } = props;
|
|
713
|
-
const dayCount =
|
|
1110
|
+
const dayCount = getDaysOfMonth(date.getFullYear(), date.getMonth());
|
|
714
1111
|
let days = [];
|
|
715
1112
|
let countDays = 1;
|
|
716
1113
|
let day = DAYS_WEEK - base.getDay() + 1;
|
|
@@ -734,13 +1131,13 @@ function createNextWeeks(props, base) {
|
|
|
734
1131
|
function dayRangeIsOutsideMin(props, day) {
|
|
735
1132
|
const { date, minDate } = props;
|
|
736
1133
|
return minDate
|
|
737
|
-
?
|
|
1134
|
+
? getDateWeight(assignDayInDate(date, day)) < getDateWeight(minDate)
|
|
738
1135
|
: false;
|
|
739
1136
|
}
|
|
740
1137
|
function dayRangeIsOutsideMax(props, day) {
|
|
741
1138
|
const { date, maxDate } = props;
|
|
742
1139
|
return maxDate
|
|
743
|
-
?
|
|
1140
|
+
? getDateWeight(assignDayInDate(date, day)) > getDateWeight(maxDate)
|
|
744
1141
|
: false;
|
|
745
1142
|
}
|
|
746
1143
|
function dayRangeIsOutside(props, day) {
|
|
@@ -758,7 +1155,7 @@ function createMonthState(props, value) {
|
|
|
758
1155
|
return {
|
|
759
1156
|
disabled: monthIsOutside(props, value),
|
|
760
1157
|
focused: value === month,
|
|
761
|
-
label:
|
|
1158
|
+
label: MONTH_NAMES()[value],
|
|
762
1159
|
selected: date.getFullYear() === year && value === date.getMonth(),
|
|
763
1160
|
value
|
|
764
1161
|
};
|
|
@@ -788,23 +1185,23 @@ function checkMonthPicker(props) {
|
|
|
788
1185
|
}
|
|
789
1186
|
function createMonthPicker(props) {
|
|
790
1187
|
return [
|
|
791
|
-
createMonthState(props,
|
|
792
|
-
createMonthState(props,
|
|
793
|
-
createMonthState(props,
|
|
794
|
-
createMonthState(props,
|
|
795
|
-
createMonthState(props,
|
|
796
|
-
createMonthState(props,
|
|
797
|
-
createMonthState(props,
|
|
798
|
-
createMonthState(props,
|
|
799
|
-
createMonthState(props,
|
|
800
|
-
createMonthState(props,
|
|
801
|
-
createMonthState(props,
|
|
802
|
-
createMonthState(props,
|
|
1188
|
+
createMonthState(props, Month.January),
|
|
1189
|
+
createMonthState(props, Month.February),
|
|
1190
|
+
createMonthState(props, Month.March),
|
|
1191
|
+
createMonthState(props, Month.April),
|
|
1192
|
+
createMonthState(props, Month.May),
|
|
1193
|
+
createMonthState(props, Month.June),
|
|
1194
|
+
createMonthState(props, Month.July),
|
|
1195
|
+
createMonthState(props, Month.August),
|
|
1196
|
+
createMonthState(props, Month.September),
|
|
1197
|
+
createMonthState(props, Month.October),
|
|
1198
|
+
createMonthState(props, Month.November),
|
|
1199
|
+
createMonthState(props, Month.December)
|
|
803
1200
|
];
|
|
804
1201
|
}
|
|
805
1202
|
function monthIsLimitMin(props) {
|
|
806
1203
|
const { month, date, minDate } = props;
|
|
807
|
-
if (
|
|
1204
|
+
if (itIsDefined(month) && date) {
|
|
808
1205
|
const minYear = minDate ? minDate.getFullYear() : 0;
|
|
809
1206
|
const minMonth = minDate ? minDate.getMonth() : 0;
|
|
810
1207
|
return date.getFullYear() === minYear && month <= minMonth;
|
|
@@ -813,7 +1210,7 @@ function monthIsLimitMin(props) {
|
|
|
813
1210
|
}
|
|
814
1211
|
function monthIsLimitMax(props) {
|
|
815
1212
|
const { month, date, maxDate } = props;
|
|
816
|
-
if (
|
|
1213
|
+
if (itIsDefined(month) && date) {
|
|
817
1214
|
const maxYear = maxDate ? maxDate.getFullYear() : 10000;
|
|
818
1215
|
const maxMonth = maxDate ? maxDate.getMonth() : 11;
|
|
819
1216
|
return date.getFullYear() === maxYear && month >= maxMonth;
|
|
@@ -893,6 +1290,30 @@ function createYearPicker(props) {
|
|
|
893
1290
|
};
|
|
894
1291
|
}
|
|
895
1292
|
|
|
1293
|
+
const normalize = (word) => {
|
|
1294
|
+
return word
|
|
1295
|
+
.slice()
|
|
1296
|
+
.replace(/á/g, 'a')
|
|
1297
|
+
.replace(/Á/g, 'A')
|
|
1298
|
+
.replace(/é/g, 'e')
|
|
1299
|
+
.replace(/É/g, 'E')
|
|
1300
|
+
.replace(/í/g, 'i')
|
|
1301
|
+
.replace(/Í/g, 'I')
|
|
1302
|
+
.replace(/ó/g, 'o')
|
|
1303
|
+
.replace(/Ó/g, 'O')
|
|
1304
|
+
.replace(/ú/g, 'u')
|
|
1305
|
+
.replace(/Ú/g, 'U');
|
|
1306
|
+
};
|
|
1307
|
+
const hasPattern = (word, pattern, force = false) => {
|
|
1308
|
+
let filter = pattern.toLowerCase();
|
|
1309
|
+
let test = word.toLowerCase();
|
|
1310
|
+
if (force) {
|
|
1311
|
+
test = normalize(test);
|
|
1312
|
+
filter = normalize(filter);
|
|
1313
|
+
}
|
|
1314
|
+
return !!test.match(`^.*${filter}.*$`);
|
|
1315
|
+
};
|
|
1316
|
+
|
|
896
1317
|
function createEmptyStore() {
|
|
897
1318
|
return {
|
|
898
1319
|
coincidences: undefined,
|
|
@@ -908,7 +1329,7 @@ function searchForPattern(props) {
|
|
|
908
1329
|
let newStore = store;
|
|
909
1330
|
let search = false;
|
|
910
1331
|
while (!search && newStore) {
|
|
911
|
-
search =
|
|
1332
|
+
search = hasPattern(pattern || '', newStore.pattern, true);
|
|
912
1333
|
if (!search) {
|
|
913
1334
|
newStore = newStore.previous;
|
|
914
1335
|
}
|
|
@@ -1053,7 +1474,7 @@ function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, mo
|
|
|
1053
1474
|
return {
|
|
1054
1475
|
date: currentDate,
|
|
1055
1476
|
day: formControl?.state || value,
|
|
1056
|
-
month:
|
|
1477
|
+
month: itIsDefined(month) ? month : currentDate.getMonth(),
|
|
1057
1478
|
year: year || currentDate.getFullYear(),
|
|
1058
1479
|
minDate,
|
|
1059
1480
|
maxDate
|
|
@@ -1068,7 +1489,7 @@ function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, mo
|
|
|
1068
1489
|
onValue(value);
|
|
1069
1490
|
}
|
|
1070
1491
|
}
|
|
1071
|
-
return (jsxRuntime.jsxs("div", { className: "rls-picker-day", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-picker-day__header", children:
|
|
1492
|
+
return (jsxRuntime.jsxs("div", { className: "rls-picker-day", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-picker-day__header", children: DAY_LABELS().map((title, index) => (jsxRuntime.jsx("label", { className: "rls-picker-day__label", children: title }, index))) }), jsxRuntime.jsx("div", { className: "rls-picker-day__component", children: weeks.map(({ days }, index) => (jsxRuntime.jsx("div", { className: "rls-picker-day__week", children: days.map(({ value, disabled, focused, forbidden, selected, today }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-picker-day__element', {
|
|
1072
1493
|
disabled: disabled || disabledPicker,
|
|
1073
1494
|
focused,
|
|
1074
1495
|
forbidden,
|
|
@@ -1080,8 +1501,8 @@ function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, mo
|
|
|
1080
1501
|
const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
|
|
1081
1502
|
|
|
1082
1503
|
function RlsPickerDayRange({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
|
|
1083
|
-
const currentRange = formControl?.state ||
|
|
1084
|
-
const currentDate =
|
|
1504
|
+
const currentRange = formControl?.state || DateRange.now();
|
|
1505
|
+
const currentDate = normalizeMinTime(date || currentRange.minDate);
|
|
1085
1506
|
const sourceDate = react.useRef(currentRange.minDate);
|
|
1086
1507
|
const [weeks, setWeeks] = react.useState([]);
|
|
1087
1508
|
const [range, setRange] = react.useState(currentRange);
|
|
@@ -1095,15 +1516,15 @@ function RlsPickerDayRange({ date, disabled: disabledPicker, formControl, maxDat
|
|
|
1095
1516
|
}));
|
|
1096
1517
|
}, [range, date, minDate, maxDate]);
|
|
1097
1518
|
function onChange(value) {
|
|
1098
|
-
const date =
|
|
1099
|
-
const range =
|
|
1100
|
-
? new
|
|
1101
|
-
: new
|
|
1519
|
+
const date = assignDayInDate(currentDate, value);
|
|
1520
|
+
const range = dateIsBefore(date, sourceDate.current)
|
|
1521
|
+
? new DateRange(sourceDate.current, date)
|
|
1522
|
+
: new DateRange(date, sourceDate.current);
|
|
1102
1523
|
sourceDate.current = date;
|
|
1103
1524
|
setRange(range);
|
|
1104
1525
|
formControl?.setState(range);
|
|
1105
1526
|
}
|
|
1106
|
-
return (jsxRuntime.jsxs("div", { className: "rls-picker-day-range", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-picker-day-range__title", children:
|
|
1527
|
+
return (jsxRuntime.jsxs("div", { className: "rls-picker-day-range", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-picker-day-range__title", children: dateFormatTemplate(sourceDate.current, DATE_RANGE_FORMAT) }), jsxRuntime.jsx("div", { className: "rls-picker-day-range__header", children: DAY_LABELS().map((title, index) => (jsxRuntime.jsx("label", { className: "rls-picker-day-range__label", children: title }, index))) }), jsxRuntime.jsx("div", { className: "rls-picker-day-range__component", children: weeks.map(({ days }, index) => (jsxRuntime.jsx("div", { className: "rls-picker-day-range__week", children: days.map(({ disabled, end, forbidden, source, ranged, value }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-picker-day-range__element', {
|
|
1107
1528
|
disabled: disabled || disabledPicker,
|
|
1108
1529
|
end,
|
|
1109
1530
|
forbidden,
|
|
@@ -1123,14 +1544,14 @@ function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate,
|
|
|
1123
1544
|
}, [date, year, value, minDate, maxDate]);
|
|
1124
1545
|
react.useEffect(() => {
|
|
1125
1546
|
const month = checkMonthPicker(createPickerProps());
|
|
1126
|
-
|
|
1547
|
+
itIsDefined(month)
|
|
1127
1548
|
? formControl?.setState(month)
|
|
1128
1549
|
: setValue(formControl?.state || currentDate.getMonth());
|
|
1129
1550
|
}, [formControl?.state]);
|
|
1130
1551
|
function createPickerProps() {
|
|
1131
1552
|
return {
|
|
1132
1553
|
date: currentDate,
|
|
1133
|
-
month:
|
|
1554
|
+
month: itIsDefined(formControl?.state) ? formControl?.state : value,
|
|
1134
1555
|
year: year || currentDate.getFullYear(),
|
|
1135
1556
|
minDate,
|
|
1136
1557
|
maxDate
|
|
@@ -1159,20 +1580,20 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
|
|
|
1159
1580
|
minDate,
|
|
1160
1581
|
month: monthControl.state
|
|
1161
1582
|
});
|
|
1162
|
-
const monthName =
|
|
1583
|
+
const monthName = MONTH_NAMES()[monthControl.state || 0];
|
|
1163
1584
|
function onPreviousMonth() {
|
|
1164
|
-
if (
|
|
1165
|
-
if (monthControl.state >
|
|
1585
|
+
if (itIsDefined(monthControl.state) && itIsDefined(yearControl.state)) {
|
|
1586
|
+
if (monthControl.state > Month.January) {
|
|
1166
1587
|
monthControl.setState(monthControl.state - 1);
|
|
1167
1588
|
}
|
|
1168
1589
|
else {
|
|
1169
|
-
monthControl.setState(
|
|
1590
|
+
monthControl.setState(Month.December);
|
|
1170
1591
|
yearControl.setState(yearControl.state - 1);
|
|
1171
1592
|
}
|
|
1172
1593
|
}
|
|
1173
1594
|
}
|
|
1174
1595
|
function onPreviousYear() {
|
|
1175
|
-
if (
|
|
1596
|
+
if (itIsDefined(yearControl.state)) {
|
|
1176
1597
|
yearControl.setState(yearControl.state - 1);
|
|
1177
1598
|
}
|
|
1178
1599
|
}
|
|
@@ -1180,18 +1601,18 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
|
|
|
1180
1601
|
type === 'month' ? onPreviousMonth() : onPreviousYear();
|
|
1181
1602
|
}
|
|
1182
1603
|
function onNextMonth() {
|
|
1183
|
-
if (
|
|
1184
|
-
if (monthControl.state <
|
|
1604
|
+
if (itIsDefined(monthControl.state) && itIsDefined(yearControl.state)) {
|
|
1605
|
+
if (monthControl.state < Month.December) {
|
|
1185
1606
|
monthControl.setState(monthControl.state + 1);
|
|
1186
1607
|
}
|
|
1187
1608
|
else {
|
|
1188
|
-
monthControl.setState(
|
|
1609
|
+
monthControl.setState(Month.January);
|
|
1189
1610
|
yearControl.setState(yearControl.state + 1);
|
|
1190
1611
|
}
|
|
1191
1612
|
}
|
|
1192
1613
|
}
|
|
1193
1614
|
function onNextYear() {
|
|
1194
|
-
if (
|
|
1615
|
+
if (itIsDefined(yearControl.state)) {
|
|
1195
1616
|
yearControl.setState(yearControl.state + 1);
|
|
1196
1617
|
}
|
|
1197
1618
|
}
|
|
@@ -1215,7 +1636,7 @@ function RlsPickerYear({ date, disabled: disabledPicker, formControl, maxDate, m
|
|
|
1215
1636
|
}, [date, year, value, minDate, maxDate]);
|
|
1216
1637
|
react.useEffect(() => {
|
|
1217
1638
|
const year = checkYearPicker(createPickerProps());
|
|
1218
|
-
|
|
1639
|
+
itIsDefined(year)
|
|
1219
1640
|
? formControl?.setState(year)
|
|
1220
1641
|
: setValue(formControl?.state || currentDate.getFullYear());
|
|
1221
1642
|
}, [formControl?.state]);
|
|
@@ -1279,7 +1700,7 @@ const reactI18n = i18n.i18n({
|
|
|
1279
1700
|
}
|
|
1280
1701
|
});
|
|
1281
1702
|
|
|
1282
|
-
class ConfirmationResult extends
|
|
1703
|
+
class ConfirmationResult extends PartialSealed {
|
|
1283
1704
|
static approved() {
|
|
1284
1705
|
return new ConfirmationResult('approved');
|
|
1285
1706
|
}
|
|
@@ -1288,15 +1709,7 @@ class ConfirmationResult extends helpersAdvanced.PartialSealed {
|
|
|
1288
1709
|
}
|
|
1289
1710
|
}
|
|
1290
1711
|
function RlsConfirmation({ approved, content, reject, rlsTheme, subtitle, title, visible }) {
|
|
1291
|
-
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-confirmation', { visible }), "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-confirmation__component", children: [jsxRuntime.jsxs("div", { className: "rls-confirmation__header", children: [title &&
|
|
1292
|
-
if (approved.onClick) {
|
|
1293
|
-
approved.onClick();
|
|
1294
|
-
}
|
|
1295
|
-
}, children: approved.label })), reject && (jsxRuntime.jsx(RlsButton, { type: "outline", onClick: () => {
|
|
1296
|
-
if (reject.onClick) {
|
|
1297
|
-
reject.onClick();
|
|
1298
|
-
}
|
|
1299
|
-
}, children: reject.label }))] }) }))] }), jsxRuntime.jsx("div", { className: "rls-confirmation__backdrop" })] }));
|
|
1712
|
+
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-confirmation', { visible }), "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-confirmation__component", children: [jsxRuntime.jsxs("div", { className: "rls-confirmation__header", children: [title && jsxRuntime.jsx("div", { className: "rls-confirmation__title", children: title }), subtitle && (jsxRuntime.jsx("div", { className: "rls-confirmation__subtitle", children: subtitle }))] }), jsxRuntime.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntime.jsx("div", { className: "rls-confirmation__message", children: content })) }), (approved || reject) && (jsxRuntime.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntime.jsxs("div", { className: "rls-confirmation__actions", children: [approved && (jsxRuntime.jsx(RlsButton, { type: "raised", onClick: approved.onClick, children: approved.label })), reject && (jsxRuntime.jsx(RlsButton, { type: "outline", onClick: reject.onClick, children: reject.label }))] }) }))] }), jsxRuntime.jsx("div", { className: "rls-confirmation__backdrop" })] }));
|
|
1300
1713
|
}
|
|
1301
1714
|
function useConfirmationService() {
|
|
1302
1715
|
const [config, setConfig] = react.useState({});
|
|
@@ -1365,15 +1778,18 @@ function useDatatable() {
|
|
|
1365
1778
|
const bodyRef = react.useRef(null);
|
|
1366
1779
|
react.useEffect(() => {
|
|
1367
1780
|
let observer;
|
|
1368
|
-
|
|
1781
|
+
const body = bodyRef?.current;
|
|
1782
|
+
if (body) {
|
|
1369
1783
|
observer = new ResizeObserver(() => {
|
|
1370
|
-
const scrollHeight =
|
|
1371
|
-
const clientHeight =
|
|
1784
|
+
const scrollHeight = body.scrollHeight || 0;
|
|
1785
|
+
const clientHeight = body.clientHeight || 0;
|
|
1372
1786
|
setScrolleable(scrollHeight > clientHeight);
|
|
1373
1787
|
});
|
|
1374
1788
|
observer.observe(bodyRef?.current);
|
|
1375
1789
|
}
|
|
1376
|
-
return () =>
|
|
1790
|
+
return () => {
|
|
1791
|
+
observer?.disconnect();
|
|
1792
|
+
};
|
|
1377
1793
|
}, []);
|
|
1378
1794
|
return { bodyRef, scrolleable };
|
|
1379
1795
|
}
|
|
@@ -1382,17 +1798,18 @@ function useListControl({ suggestions, formControl }) {
|
|
|
1382
1798
|
const boxContentRef = react.useRef(null);
|
|
1383
1799
|
const listRef = react.useRef(null);
|
|
1384
1800
|
const inputRef = react.useRef(null);
|
|
1385
|
-
const [
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1801
|
+
const [listState, setListState] = react.useState({
|
|
1802
|
+
collection: new ListCollection([]),
|
|
1803
|
+
focused: false,
|
|
1804
|
+
higher: false,
|
|
1805
|
+
value: '',
|
|
1806
|
+
visible: false
|
|
1807
|
+
});
|
|
1391
1808
|
const position = react.useRef(0);
|
|
1392
1809
|
react.useEffect(() => {
|
|
1393
1810
|
function onCloseSuggestions({ target }) {
|
|
1394
1811
|
if (!boxContentRef?.current?.contains(target)) {
|
|
1395
|
-
|
|
1812
|
+
setListState((state) => ({ ...state, visible: false }));
|
|
1396
1813
|
}
|
|
1397
1814
|
}
|
|
1398
1815
|
document.addEventListener('click', onCloseSuggestions);
|
|
@@ -1401,25 +1818,37 @@ function useListControl({ suggestions, formControl }) {
|
|
|
1401
1818
|
};
|
|
1402
1819
|
}, []);
|
|
1403
1820
|
react.useEffect(() => {
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
}, [visible]);
|
|
1821
|
+
const boxContent = boxContentRef.current;
|
|
1822
|
+
const list = listRef.current;
|
|
1823
|
+
formControl?.touch();
|
|
1824
|
+
setListState((state) => ({
|
|
1825
|
+
...state,
|
|
1826
|
+
higher: !locationListIsBottom(boxContent, list)
|
|
1827
|
+
}));
|
|
1828
|
+
}, [listState.visible]);
|
|
1412
1829
|
react.useEffect(() => {
|
|
1413
|
-
|
|
1830
|
+
setListState((state) => ({
|
|
1831
|
+
...state,
|
|
1832
|
+
collection: new ListCollection(suggestions)
|
|
1833
|
+
}));
|
|
1414
1834
|
}, [suggestions]);
|
|
1835
|
+
function setFocused(focused) {
|
|
1836
|
+
setListState((state) => ({ ...state, focused }));
|
|
1837
|
+
}
|
|
1838
|
+
function setValue(value) {
|
|
1839
|
+
setListState((state) => ({ ...state, value }));
|
|
1840
|
+
}
|
|
1841
|
+
function setVisible(visible) {
|
|
1842
|
+
setListState((state) => ({ ...state, visible }));
|
|
1843
|
+
}
|
|
1415
1844
|
function navigationInput(event) {
|
|
1416
|
-
if (visible) {
|
|
1845
|
+
if (listState.visible) {
|
|
1417
1846
|
const newPosition = listNavigationInput({
|
|
1418
1847
|
contentElement: boxContentRef.current,
|
|
1419
1848
|
event: event,
|
|
1420
1849
|
listElement: listRef.current
|
|
1421
1850
|
});
|
|
1422
|
-
position.current =
|
|
1851
|
+
position.current = newPosition || 0;
|
|
1423
1852
|
}
|
|
1424
1853
|
}
|
|
1425
1854
|
function navigationElement(event) {
|
|
@@ -1432,19 +1861,15 @@ function useListControl({ suggestions, formControl }) {
|
|
|
1432
1861
|
});
|
|
1433
1862
|
}
|
|
1434
1863
|
return {
|
|
1864
|
+
...listState,
|
|
1435
1865
|
boxContentRef,
|
|
1436
|
-
collection,
|
|
1437
|
-
focused,
|
|
1438
|
-
higher,
|
|
1439
1866
|
inputRef,
|
|
1440
1867
|
listRef,
|
|
1441
1868
|
navigationElement,
|
|
1442
1869
|
navigationInput,
|
|
1443
1870
|
setFocused,
|
|
1444
1871
|
setValue,
|
|
1445
|
-
setVisible
|
|
1446
|
-
value,
|
|
1447
|
-
visible
|
|
1872
|
+
setVisible
|
|
1448
1873
|
};
|
|
1449
1874
|
}
|
|
1450
1875
|
|
|
@@ -1616,8 +2041,8 @@ function RlsFieldAutocomplete(props) {
|
|
|
1616
2041
|
}
|
|
1617
2042
|
|
|
1618
2043
|
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
1619
|
-
const minFormat =
|
|
1620
|
-
const maxFormat =
|
|
2044
|
+
const minFormat = dateFormatTemplate(minDate, DATE_RANGE_FORMAT);
|
|
2045
|
+
const maxFormat = dateFormatTemplate(maxDate, DATE_RANGE_FORMAT);
|
|
1621
2046
|
return `${minFormat} - ${maxFormat}`;
|
|
1622
2047
|
}
|
|
1623
2048
|
|
|
@@ -1625,8 +2050,24 @@ function RlsModal({ children, visible, rlsTheme }) {
|
|
|
1625
2050
|
return ReactDOM.createPortal(jsxRuntime.jsxs("div", { className: renderClassStatus('rls-modal', { visible }), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-modal__component", children: children }), jsxRuntime.jsx("div", { className: "rls-modal__backdrop" })] }), document.body);
|
|
1626
2051
|
}
|
|
1627
2052
|
|
|
1628
|
-
|
|
1629
|
-
|
|
2053
|
+
function itIsFormControlOptions(props) {
|
|
2054
|
+
return (typeof props === 'object' && ('state' in props || 'validators' in props));
|
|
2055
|
+
}
|
|
2056
|
+
function createFormControlOptions(...argsProps) {
|
|
2057
|
+
const [props, validators] = argsProps;
|
|
2058
|
+
if (!props) {
|
|
2059
|
+
return { state: props, validators };
|
|
2060
|
+
}
|
|
2061
|
+
if (!validators && itIsFormControlOptions(props)) {
|
|
2062
|
+
return props;
|
|
2063
|
+
}
|
|
2064
|
+
return {
|
|
2065
|
+
state: props,
|
|
2066
|
+
validators
|
|
2067
|
+
};
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
const controlIsValid = ({ state, validators }) => {
|
|
1630
2071
|
return validators.reduce((errors, validator) => {
|
|
1631
2072
|
const error = validator(state);
|
|
1632
2073
|
if (error) {
|
|
@@ -1636,89 +2077,77 @@ const controlIsValid = (props) => {
|
|
|
1636
2077
|
}, []);
|
|
1637
2078
|
};
|
|
1638
2079
|
|
|
1639
|
-
function useControl(
|
|
1640
|
-
const
|
|
1641
|
-
const [
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
const
|
|
2080
|
+
function useControl(controlOptions, controlValidators) {
|
|
2081
|
+
const { state, touched, validators } = createFormControlOptions(controlOptions, controlValidators);
|
|
2082
|
+
const [controlState, setControlState] = react.useState({
|
|
2083
|
+
dirty: false,
|
|
2084
|
+
disabled: false,
|
|
2085
|
+
focused: false,
|
|
2086
|
+
state: state,
|
|
2087
|
+
touched: !!touched,
|
|
2088
|
+
validators: validators
|
|
2089
|
+
});
|
|
2090
|
+
const initialState = react.useRef(state);
|
|
1650
2091
|
const elementRef = react.useRef(null);
|
|
1651
|
-
const errors =
|
|
1652
|
-
const
|
|
1653
|
-
const valid = (() => errors.length === 0)();
|
|
1654
|
-
react.useEffect(() => {
|
|
1655
|
-
if (state !== null && state !== undefined) {
|
|
1656
|
-
setValue(state);
|
|
1657
|
-
}
|
|
1658
|
-
subscribers.next(state);
|
|
1659
|
-
}, [state]);
|
|
2092
|
+
const errors = validators ? controlIsValid({ state, validators }) : [];
|
|
2093
|
+
const valid = errors.length === 0;
|
|
1660
2094
|
function focus() {
|
|
1661
|
-
|
|
2095
|
+
setControlState((state) => ({ ...state, focused: true }));
|
|
1662
2096
|
}
|
|
1663
2097
|
function blur() {
|
|
1664
|
-
|
|
2098
|
+
setControlState((state) => ({ ...state, focused: false, touched: true }));
|
|
1665
2099
|
}
|
|
1666
2100
|
function disable() {
|
|
1667
|
-
|
|
2101
|
+
setControlState((state) => ({ ...state, disabled: true }));
|
|
1668
2102
|
}
|
|
1669
2103
|
function enable() {
|
|
1670
|
-
|
|
2104
|
+
setControlState((state) => ({ ...state, disabled: false }));
|
|
1671
2105
|
}
|
|
1672
2106
|
function touch() {
|
|
1673
|
-
|
|
1674
|
-
}
|
|
1675
|
-
function untouch() {
|
|
1676
|
-
setTouched(false);
|
|
2107
|
+
setControlState((state) => ({ ...state, touched: true }));
|
|
1677
2108
|
}
|
|
1678
2109
|
function setState(state) {
|
|
1679
|
-
|
|
1680
|
-
|
|
2110
|
+
setControlState((currentState) => ({
|
|
2111
|
+
...currentState,
|
|
2112
|
+
dirty: true,
|
|
2113
|
+
state
|
|
2114
|
+
}));
|
|
1681
2115
|
}
|
|
1682
|
-
function
|
|
1683
|
-
|
|
1684
|
-
setDirty(false);
|
|
1685
|
-
setCurrentState(initialValue);
|
|
2116
|
+
function setValidators(validators) {
|
|
2117
|
+
setControlState((state) => ({ ...state, validators }));
|
|
1686
2118
|
}
|
|
1687
|
-
function
|
|
1688
|
-
|
|
1689
|
-
|
|
2119
|
+
function reset() {
|
|
2120
|
+
setControlState((currentState) => ({
|
|
2121
|
+
...currentState,
|
|
2122
|
+
dirty: false,
|
|
2123
|
+
state: initialState.current,
|
|
2124
|
+
touched: false
|
|
2125
|
+
}));
|
|
1690
2126
|
}
|
|
1691
2127
|
return {
|
|
2128
|
+
...controlState,
|
|
1692
2129
|
blur,
|
|
1693
|
-
dirty,
|
|
1694
2130
|
disable,
|
|
1695
|
-
disabled,
|
|
1696
2131
|
elementRef,
|
|
1697
2132
|
enable,
|
|
1698
|
-
enabled: !disabled,
|
|
1699
|
-
error,
|
|
2133
|
+
enabled: !controlState.disabled,
|
|
2134
|
+
error: errors[0],
|
|
1700
2135
|
errors,
|
|
1701
2136
|
focus,
|
|
1702
|
-
focused,
|
|
1703
2137
|
invalid: !valid,
|
|
1704
|
-
pristine: !dirty,
|
|
2138
|
+
pristine: !controlState.dirty,
|
|
1705
2139
|
reset,
|
|
1706
2140
|
setState,
|
|
1707
2141
|
setValidators,
|
|
1708
|
-
state,
|
|
1709
|
-
subscribe,
|
|
1710
2142
|
touch,
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
untouch,
|
|
1714
|
-
untouched: !touched,
|
|
2143
|
+
unfocused: !controlState.focused,
|
|
2144
|
+
untouched: !controlState.touched,
|
|
1715
2145
|
valid,
|
|
1716
|
-
|
|
1717
|
-
wrong: touched && !valid
|
|
2146
|
+
wrong: controlState.touched && !valid
|
|
1718
2147
|
};
|
|
1719
2148
|
}
|
|
1720
|
-
function useReactControl(
|
|
1721
|
-
return useControl(
|
|
2149
|
+
function useReactControl(options, validators) {
|
|
2150
|
+
return useControl(options, validators);
|
|
1722
2151
|
}
|
|
1723
2152
|
|
|
1724
2153
|
const FORMAT_DESCRIPTION = '{dw}, {mx} {dd} de {aa}';
|
|
@@ -1740,18 +2169,18 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
1740
2169
|
formControl?.setState(dateCheck);
|
|
1741
2170
|
}, []);
|
|
1742
2171
|
react.useEffect(() => {
|
|
1743
|
-
setValue((prevValue) =>
|
|
1744
|
-
?
|
|
2172
|
+
setValue((prevValue) => itIsDefined(yearControl.state)
|
|
2173
|
+
? assignYearInDate(prevValue, yearControl.state)
|
|
1745
2174
|
: prevValue);
|
|
1746
2175
|
}, [yearControl.state]);
|
|
1747
2176
|
react.useEffect(() => {
|
|
1748
|
-
setValue((prevValue) =>
|
|
1749
|
-
?
|
|
2177
|
+
setValue((prevValue) => itIsDefined(monthControl.state)
|
|
2178
|
+
? assignMonthInDate(prevValue, monthControl.state)
|
|
1750
2179
|
: prevValue);
|
|
1751
2180
|
}, [monthControl.state]);
|
|
1752
2181
|
react.useEffect(() => {
|
|
1753
|
-
setValue((prevValue) =>
|
|
1754
|
-
?
|
|
2182
|
+
setValue((prevValue) => itIsDefined(dayControl.state)
|
|
2183
|
+
? assignDayInDate(prevValue, dayControl.state)
|
|
1755
2184
|
: prevValue);
|
|
1756
2185
|
}, [dayControl.state]);
|
|
1757
2186
|
function onVisibilityDay() {
|
|
@@ -1783,7 +2212,7 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
1783
2212
|
onListener({ type: PickerListenerType.Select, value });
|
|
1784
2213
|
}
|
|
1785
2214
|
}
|
|
1786
|
-
return (jsxRuntime.jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-picker-date__header", children: [jsxRuntime.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--description", children: jsxRuntime.jsx("span", { onClick: onVisibilityDay, children:
|
|
2215
|
+
return (jsxRuntime.jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-picker-date__header", children: [jsxRuntime.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--description", children: jsxRuntime.jsx("span", { onClick: onVisibilityDay, children: dateFormatTemplate(dateInitial, FORMAT_DESCRIPTION) }) }), jsxRuntime.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--year", children: jsxRuntime.jsx("span", { onClick: onVisibilityYear, children: yearControl.state }) }), jsxRuntime.jsx(RlsPickerMonthTitle, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityMonth })] }), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-picker-date__component', {
|
|
1787
2216
|
day: visibility === 'DAY',
|
|
1788
2217
|
month: visibility === 'MONTH',
|
|
1789
2218
|
year: visibility === 'YEAR'
|
|
@@ -1817,29 +2246,25 @@ function RlsFieldDate({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
1817
2246
|
}
|
|
1818
2247
|
function onClean() {
|
|
1819
2248
|
if (value) {
|
|
2249
|
+
formControl?.touch();
|
|
1820
2250
|
onChange(undefined);
|
|
1821
|
-
if (formControl && !formControl.touched) {
|
|
1822
|
-
formControl.touch();
|
|
1823
|
-
}
|
|
1824
2251
|
}
|
|
1825
2252
|
else {
|
|
1826
2253
|
setModalIsVisible(true);
|
|
1827
2254
|
}
|
|
1828
2255
|
}
|
|
1829
|
-
return (jsxRuntime.jsxs("div", { className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsxRuntime.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntime.jsx("div", { className: "rls-field-box__component", children: jsxRuntime.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntime.jsx("input", { className: "rls-field-date__control", type: "text", value: value ?
|
|
2256
|
+
return (jsxRuntime.jsxs("div", { className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-box', { disabled }), children: [children && jsxRuntime.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntime.jsx("div", { className: "rls-field-box__component", children: jsxRuntime.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntime.jsx("input", { className: "rls-field-date__control", type: "text", value: value ? dateFormatTemplate(value, DATE_RANGE_FORMAT) : '', readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntime.jsx("button", { className: "rls-field-date__action", onClick: onClean, disabled: disabled, children: jsxRuntime.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), jsxRuntime.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }), jsxRuntime.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntime.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value, type }) => {
|
|
1830
2257
|
if (type !== PickerListenerType.Cancel) {
|
|
1831
2258
|
onChange(value, true);
|
|
1832
2259
|
}
|
|
2260
|
+
formControl?.touch();
|
|
1833
2261
|
setModalIsVisible(false);
|
|
1834
|
-
if (!formControl?.touched) {
|
|
1835
|
-
formControl?.touch();
|
|
1836
|
-
}
|
|
1837
2262
|
} }) })] }));
|
|
1838
2263
|
}
|
|
1839
2264
|
|
|
1840
2265
|
function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
1841
|
-
const dateInitial =
|
|
1842
|
-
const rangeInitial = formControl?.state ||
|
|
2266
|
+
const dateInitial = normalizeMinTime(datePicker || new Date());
|
|
2267
|
+
const rangeInitial = formControl?.state || DateRange.now();
|
|
1843
2268
|
const yearControl = useReactControl(dateInitial.getFullYear());
|
|
1844
2269
|
const monthControl = useReactControl(dateInitial.getMonth());
|
|
1845
2270
|
const dayControl = useReactControl(rangeInitial);
|
|
@@ -1849,14 +2274,14 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
|
|
|
1849
2274
|
react.useEffect(() => {
|
|
1850
2275
|
setDate((prevValue) => {
|
|
1851
2276
|
return typeof yearControl.state === 'number'
|
|
1852
|
-
?
|
|
2277
|
+
? assignYearInDate(prevValue, yearControl.state)
|
|
1853
2278
|
: prevValue;
|
|
1854
2279
|
});
|
|
1855
2280
|
}, [yearControl.state]);
|
|
1856
2281
|
react.useEffect(() => {
|
|
1857
2282
|
setDate((prevValue) => {
|
|
1858
2283
|
return typeof monthControl.state === 'number'
|
|
1859
|
-
?
|
|
2284
|
+
? assignMonthInDate(prevValue, monthControl.state)
|
|
1860
2285
|
: prevValue;
|
|
1861
2286
|
});
|
|
1862
2287
|
}, [monthControl.state]);
|
|
@@ -1896,7 +2321,7 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
|
|
|
1896
2321
|
}
|
|
1897
2322
|
|
|
1898
2323
|
function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
|
|
1899
|
-
const currentRange = formControl?.state ||
|
|
2324
|
+
const currentRange = formControl?.state || DateRange.now();
|
|
1900
2325
|
const currentDate = datePicker || new Date();
|
|
1901
2326
|
const [value, setValue] = react.useState(currentRange);
|
|
1902
2327
|
const [modalIsVisible, setModalIsVisible] = react.useState(false);
|
|
@@ -2155,6 +2580,7 @@ exports.RlsInput = RlsInput;
|
|
|
2155
2580
|
exports.RlsInputMoney = RlsInputMoney;
|
|
2156
2581
|
exports.RlsInputNumber = RlsInputNumber;
|
|
2157
2582
|
exports.RlsInputPassword = RlsInputPassword;
|
|
2583
|
+
exports.RlsInputSearch = RlsInputSearch;
|
|
2158
2584
|
exports.RlsInputText = RlsInputText;
|
|
2159
2585
|
exports.RlsLabel = RlsLabel;
|
|
2160
2586
|
exports.RlsLabelCheckBox = RlsLabelCheckBox;
|
|
@@ -2175,7 +2601,6 @@ exports.RlsPoster = RlsPoster;
|
|
|
2175
2601
|
exports.RlsProgressBar = RlsProgressBar;
|
|
2176
2602
|
exports.RlsProgressCircular = RlsProgressCircular;
|
|
2177
2603
|
exports.RlsRadioButton = RlsRadioButton;
|
|
2178
|
-
exports.RlsSearchInput = RlsSearchInput;
|
|
2179
2604
|
exports.RlsSkeleton = RlsSkeleton;
|
|
2180
2605
|
exports.RlsSkeletonText = RlsSkeletonText;
|
|
2181
2606
|
exports.RlsSnackbar = RlsSnackbar;
|