@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/es/index.js
CHANGED
|
@@ -1,13 +1,55 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useState, useRef, useEffect, createContext } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { dateIsBefore, normalizeMinTime, dateIsAfter, normalizeMaxTime, getDaysOfMonth, getDateWeight, dateIsEqualsWeight, dateIsBetween, assignDayInDate, Month, MONTH_NAMES, DAY_LABELS, DateRange, dateFormatTemplate, assignYearInDate, assignMonthInDate } from '@rolster/helpers-date';
|
|
3
|
+
import { hasPattern as hasPattern$1 } from '@rolster/helpers-string';
|
|
4
|
+
import { i18n, i18nSubscribe } from '@rolster/i18n';
|
|
6
5
|
import ReactDOM from 'react-dom';
|
|
7
|
-
import { i18n } from '@rolster/i18n';
|
|
8
|
-
import { createFormControlProps } from '@rolster/helpers-forms';
|
|
9
6
|
import 'uuid';
|
|
10
|
-
|
|
7
|
+
|
|
8
|
+
function currencyFormat(currency) {
|
|
9
|
+
const { value, decimals, symbol } = currency;
|
|
10
|
+
const [integer, decimal] = Math.abs(value).toString().split('.');
|
|
11
|
+
let result = '';
|
|
12
|
+
let count = 0;
|
|
13
|
+
for (let i = 1; i <= integer.length; i++) {
|
|
14
|
+
const index = integer.length - i;
|
|
15
|
+
if (count === 3) {
|
|
16
|
+
count = 0;
|
|
17
|
+
result = `.${result}`;
|
|
18
|
+
}
|
|
19
|
+
count++;
|
|
20
|
+
result = `${integer.charAt(index)}${result}`;
|
|
21
|
+
}
|
|
22
|
+
if (decimals && decimal) {
|
|
23
|
+
result = `${result},${decimal.slice(0, 2)}`;
|
|
24
|
+
}
|
|
25
|
+
if (value < 0) {
|
|
26
|
+
result = `-${result}`;
|
|
27
|
+
}
|
|
28
|
+
return symbol ? `${symbol} ${result}` : result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class PartialSealed {
|
|
32
|
+
constructor(key, value) {
|
|
33
|
+
this.key = key;
|
|
34
|
+
this.value = value;
|
|
35
|
+
}
|
|
36
|
+
otherwise(otherwise) {
|
|
37
|
+
this.sealedOtherwise = otherwise;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
when(resolver, whenOtherwise) {
|
|
41
|
+
const handler = resolver[this.key];
|
|
42
|
+
const otherwise = whenOtherwise || this.sealedOtherwise;
|
|
43
|
+
if (otherwise) {
|
|
44
|
+
otherwise();
|
|
45
|
+
}
|
|
46
|
+
return handler ? handler(this.value) : undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function itIsDefined(object) {
|
|
51
|
+
return typeof object !== 'undefined' && object !== null;
|
|
52
|
+
}
|
|
11
53
|
|
|
12
54
|
const baseCls = 'rls-tabular-text';
|
|
13
55
|
const pointers = ['.', ','];
|
|
@@ -86,9 +128,6 @@ function RlsInput({ children, disabled, formControl, placeholder, type, value, o
|
|
|
86
128
|
setFocused(true);
|
|
87
129
|
}
|
|
88
130
|
function onBlur() {
|
|
89
|
-
if (formControl && !formControl.touched) {
|
|
90
|
-
formControl.touch();
|
|
91
|
-
}
|
|
92
131
|
formControl?.blur();
|
|
93
132
|
setFocused(false);
|
|
94
133
|
}
|
|
@@ -137,9 +176,6 @@ function RlsInputPassword({ disabled, formControl, placeholder, type, onValue })
|
|
|
137
176
|
setFocused(true);
|
|
138
177
|
}
|
|
139
178
|
function onBlur() {
|
|
140
|
-
if (formControl && !formControl.touched) {
|
|
141
|
-
formControl.touch();
|
|
142
|
-
}
|
|
143
179
|
formControl?.blur();
|
|
144
180
|
setFocused(false);
|
|
145
181
|
}
|
|
@@ -149,6 +185,10 @@ function RlsInputPassword({ disabled, formControl, placeholder, type, onValue })
|
|
|
149
185
|
}), children: jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type || 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
|
|
150
186
|
}
|
|
151
187
|
|
|
188
|
+
function RlsInputSearch({ formControl, placeholder, onSearch }) {
|
|
189
|
+
return (jsxs("div", { className: "rls-input-search", children: [jsx(RlsInput, { formControl: formControl, placeholder: placeholder }), onSearch && jsx(RlsButtonAction, { icon: "search", onClick: onSearch })] }));
|
|
190
|
+
}
|
|
191
|
+
|
|
152
192
|
function RlsInputText({ disabled, formControl, placeholder, value, onValue }) {
|
|
153
193
|
const [valueInput, setValueInput] = useState(value || '');
|
|
154
194
|
function onText(value) {
|
|
@@ -186,16 +226,12 @@ function RlsRadioButton({ checked, disabled, rlsTheme, onClick }) {
|
|
|
186
226
|
return (jsx("div", { className: renderClassStatus('rls-radiobutton', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsx("div", { className: "rls-radiobutton__component" }) }));
|
|
187
227
|
}
|
|
188
228
|
|
|
189
|
-
function RlsSearchInput({ formControl, placeholder, onSearch }) {
|
|
190
|
-
return (jsxs("div", { className: "rls-search-input", children: [jsx(RlsInput, { formControl: formControl, placeholder: placeholder }), onSearch && jsx(RlsButtonAction, { icon: "search", onClick: onSearch })] }));
|
|
191
|
-
}
|
|
192
|
-
|
|
193
229
|
function RlsSkeleton({ rlsTheme }) {
|
|
194
230
|
return jsx("div", { className: "rls-skeleton", "rls-theme": rlsTheme });
|
|
195
231
|
}
|
|
196
232
|
|
|
197
233
|
function RlsSkeletonText({ active, children, rlsTheme }) {
|
|
198
|
-
return (jsx("div", { className:
|
|
234
|
+
return (jsx("div", { className: "rls-skeleton-text", "rls-theme": rlsTheme, children: active ? (jsx(RlsSkeleton, {})) : (jsx("span", { className: "rls-skeleton-text__value", children: children })) }));
|
|
199
235
|
}
|
|
200
236
|
|
|
201
237
|
function RlsSwitch({ checked, disabled, rlsTheme, onClick }) {
|
|
@@ -288,9 +324,9 @@ function RlsFieldText({ children, disabled, formControl, placeholder, rlsTheme,
|
|
|
288
324
|
}
|
|
289
325
|
|
|
290
326
|
function RlsLabelCheckBox({ children, disabled, extended, formControl, rlsTheme }) {
|
|
291
|
-
const [checked, setChecked] = useState(formControl?.
|
|
327
|
+
const [checked, setChecked] = useState(!!formControl?.state);
|
|
292
328
|
useEffect(() => {
|
|
293
|
-
setChecked(formControl?.state
|
|
329
|
+
setChecked(!!formControl?.state);
|
|
294
330
|
}, [formControl?.state]);
|
|
295
331
|
function onToggle() {
|
|
296
332
|
if (formControl) {
|
|
@@ -307,7 +343,7 @@ function RlsLabelCheckBox({ children, disabled, extended, formControl, rlsTheme
|
|
|
307
343
|
}
|
|
308
344
|
|
|
309
345
|
function RlsLabelRadioButton({ children, disabled, extended, formControl, rlsTheme, value }) {
|
|
310
|
-
const [checked, setChecked] = useState(formControl?.state
|
|
346
|
+
const [checked, setChecked] = useState(formControl?.state === value);
|
|
311
347
|
useEffect(() => {
|
|
312
348
|
setChecked(formControl?.state === value);
|
|
313
349
|
}, [formControl?.state]);
|
|
@@ -323,9 +359,9 @@ function RlsLabelRadioButton({ children, disabled, extended, formControl, rlsThe
|
|
|
323
359
|
}
|
|
324
360
|
|
|
325
361
|
function RlsLabelSwitch({ children, disabled, extended, formControl, rlsTheme }) {
|
|
326
|
-
const [checked, setChecked] = useState(formControl?.
|
|
362
|
+
const [checked, setChecked] = useState(!!formControl?.state);
|
|
327
363
|
useEffect(() => {
|
|
328
|
-
setChecked(formControl?.state
|
|
364
|
+
setChecked(!!formControl?.state);
|
|
329
365
|
}, [formControl?.state]);
|
|
330
366
|
function onToggle() {
|
|
331
367
|
if (formControl) {
|
|
@@ -452,7 +488,7 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
452
488
|
}
|
|
453
489
|
function refreshCollection(elements, filter) {
|
|
454
490
|
const collection = filter
|
|
455
|
-
? elements.filter((element) => hasPattern(JSON.stringify(element), filter))
|
|
491
|
+
? elements.filter((element) => hasPattern$1(JSON.stringify(element), filter))
|
|
456
492
|
: elements;
|
|
457
493
|
setCollection(collection);
|
|
458
494
|
return collection;
|
|
@@ -551,6 +587,367 @@ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPa
|
|
|
551
587
|
}) }), jsx("div", { className: "rls-pagination__description", children: description }), jsxs("div", { className: "rls-pagination__actions", children: [jsx("button", { className: "rls-pagination__action", onClick: goNextPagination, disabled: lastPage, children: jsx(RlsIcon, { value: "arrow-ios-right" }) }), jsx("button", { className: "rls-pagination__action", onClick: goLastPagination, disabled: lastPage, children: jsx(RlsIcon, { value: "arrowhead-right" }) })] })] }));
|
|
552
588
|
}
|
|
553
589
|
|
|
590
|
+
const dateI18n = i18n({
|
|
591
|
+
es: {
|
|
592
|
+
// Months
|
|
593
|
+
january: 'Enero',
|
|
594
|
+
february: 'Febrero',
|
|
595
|
+
march: 'Marzo',
|
|
596
|
+
april: 'Abril',
|
|
597
|
+
may: 'Mayo',
|
|
598
|
+
june: 'Junio',
|
|
599
|
+
july: 'Julio',
|
|
600
|
+
august: 'Agosto',
|
|
601
|
+
september: 'Septiembre',
|
|
602
|
+
october: 'Octubre',
|
|
603
|
+
november: 'Noviembre',
|
|
604
|
+
december: 'Diciembre',
|
|
605
|
+
// Days
|
|
606
|
+
monday: 'Lunes',
|
|
607
|
+
tuesday: 'Martes',
|
|
608
|
+
wednesday: 'Miércoles',
|
|
609
|
+
thursday: 'Jueves',
|
|
610
|
+
friday: 'Viernes',
|
|
611
|
+
saturday: 'Sábado',
|
|
612
|
+
sunday: 'Domingo',
|
|
613
|
+
// Timestamps
|
|
614
|
+
year: 'año',
|
|
615
|
+
month: 'mes',
|
|
616
|
+
week: 'semana',
|
|
617
|
+
day: 'día',
|
|
618
|
+
hour: 'hora',
|
|
619
|
+
minute: 'minuto',
|
|
620
|
+
second: 'segundo'
|
|
621
|
+
},
|
|
622
|
+
en: {
|
|
623
|
+
// Months
|
|
624
|
+
january: 'January',
|
|
625
|
+
february: 'February',
|
|
626
|
+
march: 'March',
|
|
627
|
+
april: 'April',
|
|
628
|
+
may: 'May',
|
|
629
|
+
june: 'June',
|
|
630
|
+
july: 'July',
|
|
631
|
+
august: 'August',
|
|
632
|
+
september: 'September',
|
|
633
|
+
october: 'October',
|
|
634
|
+
november: 'November',
|
|
635
|
+
december: 'December',
|
|
636
|
+
// Days
|
|
637
|
+
monday: 'Monday',
|
|
638
|
+
tuesday: 'Tuesday',
|
|
639
|
+
wednesday: 'Wednesday',
|
|
640
|
+
thursday: 'Thursday',
|
|
641
|
+
friday: 'Friday',
|
|
642
|
+
saturday: 'Saturday',
|
|
643
|
+
sunday: 'Sunday',
|
|
644
|
+
// Timestamps
|
|
645
|
+
year: 'year',
|
|
646
|
+
month: 'month',
|
|
647
|
+
week: 'week',
|
|
648
|
+
day: 'day',
|
|
649
|
+
hour: 'hour',
|
|
650
|
+
minute: 'minute',
|
|
651
|
+
second: 'second'
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
var Miliseconds;
|
|
656
|
+
(function (Miliseconds) {
|
|
657
|
+
Miliseconds[Miliseconds["Year"] = 31536000000] = "Year";
|
|
658
|
+
Miliseconds[Miliseconds["Month"] = 2592000000] = "Month";
|
|
659
|
+
Miliseconds[Miliseconds["Week"] = 604800000] = "Week";
|
|
660
|
+
Miliseconds[Miliseconds["Day"] = 86400000] = "Day";
|
|
661
|
+
Miliseconds[Miliseconds["Hour"] = 3600000] = "Hour";
|
|
662
|
+
Miliseconds[Miliseconds["Minute"] = 60000] = "Minute";
|
|
663
|
+
Miliseconds[Miliseconds["Second"] = 1000] = "Second";
|
|
664
|
+
})(Miliseconds || (Miliseconds = {}));
|
|
665
|
+
var Day;
|
|
666
|
+
(function (Day) {
|
|
667
|
+
Day[Day["Sunday"] = 0] = "Sunday";
|
|
668
|
+
Day[Day["Monday"] = 1] = "Monday";
|
|
669
|
+
Day[Day["Tuesday"] = 2] = "Tuesday";
|
|
670
|
+
Day[Day["Wednesday"] = 3] = "Wednesday";
|
|
671
|
+
Day[Day["Thursday"] = 4] = "Thursday";
|
|
672
|
+
Day[Day["Friday"] = 5] = "Friday";
|
|
673
|
+
Day[Day["Saturday"] = 6] = "Saturday";
|
|
674
|
+
})(Day || (Day = {}));
|
|
675
|
+
var Month;
|
|
676
|
+
(function (Month) {
|
|
677
|
+
Month[Month["January"] = 0] = "January";
|
|
678
|
+
Month[Month["February"] = 1] = "February";
|
|
679
|
+
Month[Month["March"] = 2] = "March";
|
|
680
|
+
Month[Month["April"] = 3] = "April";
|
|
681
|
+
Month[Month["May"] = 4] = "May";
|
|
682
|
+
Month[Month["June"] = 5] = "June";
|
|
683
|
+
Month[Month["July"] = 6] = "July";
|
|
684
|
+
Month[Month["August"] = 7] = "August";
|
|
685
|
+
Month[Month["September"] = 8] = "September";
|
|
686
|
+
Month[Month["October"] = 9] = "October";
|
|
687
|
+
Month[Month["November"] = 10] = "November";
|
|
688
|
+
Month[Month["December"] = 11] = "December";
|
|
689
|
+
})(Month || (Month = {}));
|
|
690
|
+
var MonthDay;
|
|
691
|
+
(function (MonthDay) {
|
|
692
|
+
MonthDay[MonthDay["January"] = 31] = "January";
|
|
693
|
+
MonthDay[MonthDay["February"] = 28] = "February";
|
|
694
|
+
MonthDay[MonthDay["March"] = 31] = "March";
|
|
695
|
+
MonthDay[MonthDay["April"] = 30] = "April";
|
|
696
|
+
MonthDay[MonthDay["May"] = 31] = "May";
|
|
697
|
+
MonthDay[MonthDay["June"] = 30] = "June";
|
|
698
|
+
MonthDay[MonthDay["July"] = 31] = "July";
|
|
699
|
+
MonthDay[MonthDay["August"] = 31] = "August";
|
|
700
|
+
MonthDay[MonthDay["September"] = 30] = "September";
|
|
701
|
+
MonthDay[MonthDay["October"] = 31] = "October";
|
|
702
|
+
MonthDay[MonthDay["November"] = 30] = "November";
|
|
703
|
+
MonthDay[MonthDay["December"] = 31] = "December";
|
|
704
|
+
})(MonthDay || (MonthDay = {}));
|
|
705
|
+
|
|
706
|
+
let MONTH_NAMES_I18N = [];
|
|
707
|
+
let MONTH_LABELS_I18N = [];
|
|
708
|
+
let DAY_NAMES_I18N = [];
|
|
709
|
+
let DAY_LABELS_I18N = [];
|
|
710
|
+
function loadI18n(language = 'es') {
|
|
711
|
+
MONTH_NAMES_I18N = [
|
|
712
|
+
dateI18n('january', { language }),
|
|
713
|
+
dateI18n('february', { language }),
|
|
714
|
+
dateI18n('march', { language }),
|
|
715
|
+
dateI18n('april', { language }),
|
|
716
|
+
dateI18n('may', { language }),
|
|
717
|
+
dateI18n('june', { language }),
|
|
718
|
+
dateI18n('july', { language }),
|
|
719
|
+
dateI18n('august', { language }),
|
|
720
|
+
dateI18n('september', { language }),
|
|
721
|
+
dateI18n('october', { language }),
|
|
722
|
+
dateI18n('november', { language }),
|
|
723
|
+
dateI18n('december', { language })
|
|
724
|
+
];
|
|
725
|
+
MONTH_LABELS_I18N = MONTH_NAMES_I18N.map((name) => name.substring(0, 3));
|
|
726
|
+
DAY_NAMES_I18N = [
|
|
727
|
+
dateI18n('sunday', { language }),
|
|
728
|
+
dateI18n('monday', { language }),
|
|
729
|
+
dateI18n('tuesday', { language }),
|
|
730
|
+
dateI18n('wednesday', { language }),
|
|
731
|
+
dateI18n('thursday', { language }),
|
|
732
|
+
dateI18n('friday', { language }),
|
|
733
|
+
dateI18n('saturday', { language })
|
|
734
|
+
];
|
|
735
|
+
DAY_LABELS_I18N = DAY_NAMES_I18N.map((name) => name.substring(0, 3));
|
|
736
|
+
}
|
|
737
|
+
function isNumber(value) {
|
|
738
|
+
return value !== undefined && value !== null;
|
|
739
|
+
}
|
|
740
|
+
loadI18n();
|
|
741
|
+
i18nSubscribe((language) => loadI18n(language));
|
|
742
|
+
const MONTH_DAYS = [
|
|
743
|
+
MonthDay.January,
|
|
744
|
+
MonthDay.February,
|
|
745
|
+
MonthDay.March,
|
|
746
|
+
MonthDay.April,
|
|
747
|
+
MonthDay.May,
|
|
748
|
+
MonthDay.June,
|
|
749
|
+
MonthDay.July,
|
|
750
|
+
MonthDay.August,
|
|
751
|
+
MonthDay.September,
|
|
752
|
+
MonthDay.October,
|
|
753
|
+
MonthDay.November,
|
|
754
|
+
MonthDay.December
|
|
755
|
+
];
|
|
756
|
+
function MONTH_NAMES(index) {
|
|
757
|
+
return isNumber(index) ? MONTH_NAMES_I18N[index] || '' : MONTH_NAMES_I18N;
|
|
758
|
+
}
|
|
759
|
+
function MONTH_LABELS(index) {
|
|
760
|
+
return isNumber(index) ? MONTH_LABELS_I18N[index] || '' : MONTH_LABELS_I18N;
|
|
761
|
+
}
|
|
762
|
+
function DAY_NAMES(index) {
|
|
763
|
+
return isNumber(index) ? DAY_NAMES_I18N[index] || '' : DAY_NAMES_I18N;
|
|
764
|
+
}
|
|
765
|
+
function DAY_LABELS(index) {
|
|
766
|
+
return isNumber(index) ? DAY_LABELS_I18N[index] || '' : DAY_LABELS_I18N;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function completFormat(value, size) {
|
|
770
|
+
return value.toString().padStart(size, '0');
|
|
771
|
+
}
|
|
772
|
+
function hourFormat(date) {
|
|
773
|
+
const hour = date.getHours();
|
|
774
|
+
return hour > 12 ? hour - 12 : hour === 0 ? 12 : hour;
|
|
775
|
+
}
|
|
776
|
+
function verifyDayInYear(date, year) {
|
|
777
|
+
const days = getDaysOfMonth(year, date.getMonth());
|
|
778
|
+
if (days < date.getDate()) {
|
|
779
|
+
date.setDate(days);
|
|
780
|
+
}
|
|
781
|
+
date.setFullYear(year); // Establecer el año
|
|
782
|
+
}
|
|
783
|
+
function verifyDayInMonth(date, month) {
|
|
784
|
+
const days = getDaysOfMonth(date.getFullYear(), month);
|
|
785
|
+
if (days < date.getDate()) {
|
|
786
|
+
date.setDate(days);
|
|
787
|
+
}
|
|
788
|
+
date.setMonth(month); // Establecer el mes
|
|
789
|
+
}
|
|
790
|
+
const formatters = {
|
|
791
|
+
dd: (date) => {
|
|
792
|
+
return completFormat(date.getDate(), 2);
|
|
793
|
+
},
|
|
794
|
+
dw: (date) => {
|
|
795
|
+
return DAY_NAMES()[date.getDay()];
|
|
796
|
+
},
|
|
797
|
+
dx: (date) => {
|
|
798
|
+
return DAY_NAMES()[date.getDay()];
|
|
799
|
+
},
|
|
800
|
+
mm: (date) => {
|
|
801
|
+
return completFormat(date.getMonth() + 1, 2);
|
|
802
|
+
},
|
|
803
|
+
mn: (date) => {
|
|
804
|
+
return MONTH_NAMES(date.getMonth());
|
|
805
|
+
},
|
|
806
|
+
mx: (date) => {
|
|
807
|
+
return MONTH_LABELS(date.getMonth());
|
|
808
|
+
},
|
|
809
|
+
aa: (date) => {
|
|
810
|
+
return completFormat(date.getFullYear(), 4);
|
|
811
|
+
},
|
|
812
|
+
hh: (date) => {
|
|
813
|
+
return completFormat(date.getHours(), 2);
|
|
814
|
+
},
|
|
815
|
+
ii: (date) => {
|
|
816
|
+
return completFormat(date.getMinutes(), 2);
|
|
817
|
+
},
|
|
818
|
+
ss: (date) => {
|
|
819
|
+
return completFormat(date.getSeconds(), 2);
|
|
820
|
+
},
|
|
821
|
+
hz: (date) => {
|
|
822
|
+
return completFormat(hourFormat(date), 2);
|
|
823
|
+
},
|
|
824
|
+
zz: (date) => {
|
|
825
|
+
return date.getHours() > 11 ? 'PM' : 'AM';
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
const createElapsedTime = (value, single, charPlural = 's', plural) => {
|
|
829
|
+
plural = plural || `${single}${charPlural}`;
|
|
830
|
+
const label = `${single}(${charPlural})`;
|
|
831
|
+
return {
|
|
832
|
+
value,
|
|
833
|
+
label,
|
|
834
|
+
single,
|
|
835
|
+
plural
|
|
836
|
+
};
|
|
837
|
+
};
|
|
838
|
+
[
|
|
839
|
+
createElapsedTime(Miliseconds.Year, 'año'),
|
|
840
|
+
createElapsedTime(Miliseconds.Month, 'mes', 'es'),
|
|
841
|
+
createElapsedTime(Miliseconds.Week, 'semana'),
|
|
842
|
+
createElapsedTime(Miliseconds.Day, 'día', 's', 'dias'),
|
|
843
|
+
createElapsedTime(Miliseconds.Hour, 'hora'),
|
|
844
|
+
createElapsedTime(Miliseconds.Minute, 'minuto'),
|
|
845
|
+
createElapsedTime(Miliseconds.Second, 'segundo')
|
|
846
|
+
];
|
|
847
|
+
function getDateWeight(date) {
|
|
848
|
+
return date.getFullYear() * 365 + (date.getMonth() + 1) * 30 + date.getDate();
|
|
849
|
+
}
|
|
850
|
+
function dateIsEquals(date, compare = new Date()) {
|
|
851
|
+
return date.getTime() === compare.getTime();
|
|
852
|
+
}
|
|
853
|
+
function dateIsEqualsWeight(date, compare = new Date()) {
|
|
854
|
+
return getDateWeight(date) === getDateWeight(compare);
|
|
855
|
+
}
|
|
856
|
+
function dateIsBefore(date, compare = new Date()) {
|
|
857
|
+
return date.getTime() > compare.getTime();
|
|
858
|
+
}
|
|
859
|
+
function dateIsAfter(date, compare = new Date()) {
|
|
860
|
+
return date.getTime() < compare.getTime();
|
|
861
|
+
}
|
|
862
|
+
function dateIsBetween(minDate, maxDate, compare = new Date()) {
|
|
863
|
+
return dateIsAfter(minDate, compare) && dateIsBefore(maxDate, compare);
|
|
864
|
+
}
|
|
865
|
+
function getTimeDifference(date, compare = new Date()) {
|
|
866
|
+
return date.getTime() - compare.getTime();
|
|
867
|
+
}
|
|
868
|
+
function normalizeMinTime(date) {
|
|
869
|
+
const normalize = new Date(date.getTime());
|
|
870
|
+
normalize.setHours(0);
|
|
871
|
+
normalize.setMinutes(0);
|
|
872
|
+
normalize.setSeconds(0);
|
|
873
|
+
normalize.setMilliseconds(0);
|
|
874
|
+
return normalize;
|
|
875
|
+
}
|
|
876
|
+
function normalizeMaxTime(date) {
|
|
877
|
+
const normalize = new Date(date.getTime());
|
|
878
|
+
normalize.setHours(23);
|
|
879
|
+
normalize.setMinutes(59);
|
|
880
|
+
normalize.setSeconds(59);
|
|
881
|
+
normalize.setMilliseconds(0);
|
|
882
|
+
return normalize;
|
|
883
|
+
}
|
|
884
|
+
function getDaysOfMonth(year, month) {
|
|
885
|
+
return month === 1 && isLeapYear(year) ? 29 : MONTH_DAYS[month];
|
|
886
|
+
}
|
|
887
|
+
function isLeapYear(value) {
|
|
888
|
+
const year = value instanceof Date ? value.getFullYear() : value;
|
|
889
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
890
|
+
}
|
|
891
|
+
const regInterpolation = /{([^{}]*)}/g;
|
|
892
|
+
function dateFormatTemplate(date, template) {
|
|
893
|
+
return template.replace(regInterpolation, (value, key) => formatters[key] ? formatters[key](date) : value);
|
|
894
|
+
}
|
|
895
|
+
function assignYearInDate(date, year) {
|
|
896
|
+
const newDate = new Date(date.getTime());
|
|
897
|
+
verifyDayInYear(newDate, year);
|
|
898
|
+
newDate.setFullYear(year);
|
|
899
|
+
return newDate;
|
|
900
|
+
}
|
|
901
|
+
function assignMonthInDate(date, month) {
|
|
902
|
+
const newDate = new Date(date.getTime());
|
|
903
|
+
verifyDayInMonth(newDate, month);
|
|
904
|
+
newDate.setMonth(month);
|
|
905
|
+
return newDate;
|
|
906
|
+
}
|
|
907
|
+
function assignDayInDate(date, day) {
|
|
908
|
+
const newDate = new Date(date.getTime());
|
|
909
|
+
newDate.setDate(day);
|
|
910
|
+
return newDate;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
class DateRange {
|
|
914
|
+
constructor(minDate, maxDate) {
|
|
915
|
+
this.minDate = normalizeMinTime(minDate);
|
|
916
|
+
this.maxDate =
|
|
917
|
+
maxDate && dateIsBefore(maxDate, minDate)
|
|
918
|
+
? normalizeMinTime(maxDate)
|
|
919
|
+
: normalizeMinTime(minDate);
|
|
920
|
+
}
|
|
921
|
+
get minISOFormat() {
|
|
922
|
+
return this.minDate.toISOString();
|
|
923
|
+
}
|
|
924
|
+
get maxISOFormat() {
|
|
925
|
+
return this.maxDate.toISOString();
|
|
926
|
+
}
|
|
927
|
+
between(date) {
|
|
928
|
+
return dateIsBetween(this.minDate, this.maxDate, date);
|
|
929
|
+
}
|
|
930
|
+
equals({ maxDate, minDate }) {
|
|
931
|
+
return dateIsEquals(this.minDate, minDate) && dateIsEquals(this.maxDate, maxDate);
|
|
932
|
+
}
|
|
933
|
+
recalculate(date) {
|
|
934
|
+
if (dateIsBefore(this.minDate, date)) {
|
|
935
|
+
return new DateRange(date, this.maxDate);
|
|
936
|
+
}
|
|
937
|
+
if (dateIsAfter(this.maxDate, date)) {
|
|
938
|
+
return new DateRange(this.minDate, date);
|
|
939
|
+
}
|
|
940
|
+
const minDifference = getTimeDifference(date, this.minDate);
|
|
941
|
+
const maxDifference = getTimeDifference(this.maxDate, date);
|
|
942
|
+
return minDifference > maxDifference
|
|
943
|
+
? new DateRange(this.minDate, date)
|
|
944
|
+
: new DateRange(date, this.maxDate);
|
|
945
|
+
}
|
|
946
|
+
static now() {
|
|
947
|
+
return new DateRange(new Date());
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
|
|
554
951
|
function dateIsOutRangeMin(props) {
|
|
555
952
|
const { date, minDate } = props;
|
|
556
953
|
return !!minDate && dateIsBefore(normalizeMinTime(minDate), date);
|
|
@@ -891,6 +1288,30 @@ function createYearPicker(props) {
|
|
|
891
1288
|
};
|
|
892
1289
|
}
|
|
893
1290
|
|
|
1291
|
+
const normalize = (word) => {
|
|
1292
|
+
return word
|
|
1293
|
+
.slice()
|
|
1294
|
+
.replace(/á/g, 'a')
|
|
1295
|
+
.replace(/Á/g, 'A')
|
|
1296
|
+
.replace(/é/g, 'e')
|
|
1297
|
+
.replace(/É/g, 'E')
|
|
1298
|
+
.replace(/í/g, 'i')
|
|
1299
|
+
.replace(/Í/g, 'I')
|
|
1300
|
+
.replace(/ó/g, 'o')
|
|
1301
|
+
.replace(/Ó/g, 'O')
|
|
1302
|
+
.replace(/ú/g, 'u')
|
|
1303
|
+
.replace(/Ú/g, 'U');
|
|
1304
|
+
};
|
|
1305
|
+
const hasPattern = (word, pattern, force = false) => {
|
|
1306
|
+
let filter = pattern.toLowerCase();
|
|
1307
|
+
let test = word.toLowerCase();
|
|
1308
|
+
if (force) {
|
|
1309
|
+
test = normalize(test);
|
|
1310
|
+
filter = normalize(filter);
|
|
1311
|
+
}
|
|
1312
|
+
return !!test.match(`^.*${filter}.*$`);
|
|
1313
|
+
};
|
|
1314
|
+
|
|
894
1315
|
function createEmptyStore() {
|
|
895
1316
|
return {
|
|
896
1317
|
coincidences: undefined,
|
|
@@ -1286,15 +1707,7 @@ class ConfirmationResult extends PartialSealed {
|
|
|
1286
1707
|
}
|
|
1287
1708
|
}
|
|
1288
1709
|
function RlsConfirmation({ approved, content, reject, rlsTheme, subtitle, title, visible }) {
|
|
1289
|
-
return (jsxs("div", { className: renderClassStatus('rls-confirmation', { visible }), "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-confirmation__component", children: [jsxs("div", { className: "rls-confirmation__header", children: [title &&
|
|
1290
|
-
if (approved.onClick) {
|
|
1291
|
-
approved.onClick();
|
|
1292
|
-
}
|
|
1293
|
-
}, children: approved.label })), reject && (jsx(RlsButton, { type: "outline", onClick: () => {
|
|
1294
|
-
if (reject.onClick) {
|
|
1295
|
-
reject.onClick();
|
|
1296
|
-
}
|
|
1297
|
-
}, children: reject.label }))] }) }))] }), jsx("div", { className: "rls-confirmation__backdrop" })] }));
|
|
1710
|
+
return (jsxs("div", { className: renderClassStatus('rls-confirmation', { visible }), "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-confirmation__component", children: [jsxs("div", { className: "rls-confirmation__header", children: [title && jsx("div", { className: "rls-confirmation__title", children: title }), subtitle && (jsx("div", { className: "rls-confirmation__subtitle", children: subtitle }))] }), jsx("div", { className: "rls-confirmation__body", children: content && (jsx("div", { className: "rls-confirmation__message", children: content })) }), (approved || reject) && (jsx("div", { className: "rls-confirmation__footer", children: jsxs("div", { className: "rls-confirmation__actions", children: [approved && (jsx(RlsButton, { type: "raised", onClick: approved.onClick, children: approved.label })), reject && (jsx(RlsButton, { type: "outline", onClick: reject.onClick, children: reject.label }))] }) }))] }), jsx("div", { className: "rls-confirmation__backdrop" })] }));
|
|
1298
1711
|
}
|
|
1299
1712
|
function useConfirmationService() {
|
|
1300
1713
|
const [config, setConfig] = useState({});
|
|
@@ -1363,15 +1776,18 @@ function useDatatable() {
|
|
|
1363
1776
|
const bodyRef = useRef(null);
|
|
1364
1777
|
useEffect(() => {
|
|
1365
1778
|
let observer;
|
|
1366
|
-
|
|
1779
|
+
const body = bodyRef?.current;
|
|
1780
|
+
if (body) {
|
|
1367
1781
|
observer = new ResizeObserver(() => {
|
|
1368
|
-
const scrollHeight =
|
|
1369
|
-
const clientHeight =
|
|
1782
|
+
const scrollHeight = body.scrollHeight || 0;
|
|
1783
|
+
const clientHeight = body.clientHeight || 0;
|
|
1370
1784
|
setScrolleable(scrollHeight > clientHeight);
|
|
1371
1785
|
});
|
|
1372
1786
|
observer.observe(bodyRef?.current);
|
|
1373
1787
|
}
|
|
1374
|
-
return () =>
|
|
1788
|
+
return () => {
|
|
1789
|
+
observer?.disconnect();
|
|
1790
|
+
};
|
|
1375
1791
|
}, []);
|
|
1376
1792
|
return { bodyRef, scrolleable };
|
|
1377
1793
|
}
|
|
@@ -1380,17 +1796,18 @@ function useListControl({ suggestions, formControl }) {
|
|
|
1380
1796
|
const boxContentRef = useRef(null);
|
|
1381
1797
|
const listRef = useRef(null);
|
|
1382
1798
|
const inputRef = useRef(null);
|
|
1383
|
-
const [
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1799
|
+
const [listState, setListState] = useState({
|
|
1800
|
+
collection: new ListCollection([]),
|
|
1801
|
+
focused: false,
|
|
1802
|
+
higher: false,
|
|
1803
|
+
value: '',
|
|
1804
|
+
visible: false
|
|
1805
|
+
});
|
|
1389
1806
|
const position = useRef(0);
|
|
1390
1807
|
useEffect(() => {
|
|
1391
1808
|
function onCloseSuggestions({ target }) {
|
|
1392
1809
|
if (!boxContentRef?.current?.contains(target)) {
|
|
1393
|
-
|
|
1810
|
+
setListState((state) => ({ ...state, visible: false }));
|
|
1394
1811
|
}
|
|
1395
1812
|
}
|
|
1396
1813
|
document.addEventListener('click', onCloseSuggestions);
|
|
@@ -1399,25 +1816,37 @@ function useListControl({ suggestions, formControl }) {
|
|
|
1399
1816
|
};
|
|
1400
1817
|
}, []);
|
|
1401
1818
|
useEffect(() => {
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
}, [visible]);
|
|
1819
|
+
const boxContent = boxContentRef.current;
|
|
1820
|
+
const list = listRef.current;
|
|
1821
|
+
formControl?.touch();
|
|
1822
|
+
setListState((state) => ({
|
|
1823
|
+
...state,
|
|
1824
|
+
higher: !locationListIsBottom(boxContent, list)
|
|
1825
|
+
}));
|
|
1826
|
+
}, [listState.visible]);
|
|
1410
1827
|
useEffect(() => {
|
|
1411
|
-
|
|
1828
|
+
setListState((state) => ({
|
|
1829
|
+
...state,
|
|
1830
|
+
collection: new ListCollection(suggestions)
|
|
1831
|
+
}));
|
|
1412
1832
|
}, [suggestions]);
|
|
1833
|
+
function setFocused(focused) {
|
|
1834
|
+
setListState((state) => ({ ...state, focused }));
|
|
1835
|
+
}
|
|
1836
|
+
function setValue(value) {
|
|
1837
|
+
setListState((state) => ({ ...state, value }));
|
|
1838
|
+
}
|
|
1839
|
+
function setVisible(visible) {
|
|
1840
|
+
setListState((state) => ({ ...state, visible }));
|
|
1841
|
+
}
|
|
1413
1842
|
function navigationInput(event) {
|
|
1414
|
-
if (visible) {
|
|
1843
|
+
if (listState.visible) {
|
|
1415
1844
|
const newPosition = listNavigationInput({
|
|
1416
1845
|
contentElement: boxContentRef.current,
|
|
1417
1846
|
event: event,
|
|
1418
1847
|
listElement: listRef.current
|
|
1419
1848
|
});
|
|
1420
|
-
position.current =
|
|
1849
|
+
position.current = newPosition || 0;
|
|
1421
1850
|
}
|
|
1422
1851
|
}
|
|
1423
1852
|
function navigationElement(event) {
|
|
@@ -1430,19 +1859,15 @@ function useListControl({ suggestions, formControl }) {
|
|
|
1430
1859
|
});
|
|
1431
1860
|
}
|
|
1432
1861
|
return {
|
|
1862
|
+
...listState,
|
|
1433
1863
|
boxContentRef,
|
|
1434
|
-
collection,
|
|
1435
|
-
focused,
|
|
1436
|
-
higher,
|
|
1437
1864
|
inputRef,
|
|
1438
1865
|
listRef,
|
|
1439
1866
|
navigationElement,
|
|
1440
1867
|
navigationInput,
|
|
1441
1868
|
setFocused,
|
|
1442
1869
|
setValue,
|
|
1443
|
-
setVisible
|
|
1444
|
-
value,
|
|
1445
|
-
visible
|
|
1870
|
+
setVisible
|
|
1446
1871
|
};
|
|
1447
1872
|
}
|
|
1448
1873
|
|
|
@@ -1623,8 +2048,24 @@ function RlsModal({ children, visible, rlsTheme }) {
|
|
|
1623
2048
|
return ReactDOM.createPortal(jsxs("div", { className: renderClassStatus('rls-modal', { visible }), "rls-theme": rlsTheme, children: [jsx("div", { className: "rls-modal__component", children: children }), jsx("div", { className: "rls-modal__backdrop" })] }), document.body);
|
|
1624
2049
|
}
|
|
1625
2050
|
|
|
1626
|
-
|
|
1627
|
-
|
|
2051
|
+
function itIsFormControlOptions(props) {
|
|
2052
|
+
return (typeof props === 'object' && ('state' in props || 'validators' in props));
|
|
2053
|
+
}
|
|
2054
|
+
function createFormControlOptions(...argsProps) {
|
|
2055
|
+
const [props, validators] = argsProps;
|
|
2056
|
+
if (!props) {
|
|
2057
|
+
return { state: props, validators };
|
|
2058
|
+
}
|
|
2059
|
+
if (!validators && itIsFormControlOptions(props)) {
|
|
2060
|
+
return props;
|
|
2061
|
+
}
|
|
2062
|
+
return {
|
|
2063
|
+
state: props,
|
|
2064
|
+
validators
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
const controlIsValid = ({ state, validators }) => {
|
|
1628
2069
|
return validators.reduce((errors, validator) => {
|
|
1629
2070
|
const error = validator(state);
|
|
1630
2071
|
if (error) {
|
|
@@ -1634,89 +2075,77 @@ const controlIsValid = (props) => {
|
|
|
1634
2075
|
}, []);
|
|
1635
2076
|
};
|
|
1636
2077
|
|
|
1637
|
-
function useControl(
|
|
1638
|
-
const
|
|
1639
|
-
const [
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
const
|
|
2078
|
+
function useControl(controlOptions, controlValidators) {
|
|
2079
|
+
const { state, touched, validators } = createFormControlOptions(controlOptions, controlValidators);
|
|
2080
|
+
const [controlState, setControlState] = useState({
|
|
2081
|
+
dirty: false,
|
|
2082
|
+
disabled: false,
|
|
2083
|
+
focused: false,
|
|
2084
|
+
state: state,
|
|
2085
|
+
touched: !!touched,
|
|
2086
|
+
validators: validators
|
|
2087
|
+
});
|
|
2088
|
+
const initialState = useRef(state);
|
|
1648
2089
|
const elementRef = useRef(null);
|
|
1649
|
-
const errors =
|
|
1650
|
-
const
|
|
1651
|
-
const valid = (() => errors.length === 0)();
|
|
1652
|
-
useEffect(() => {
|
|
1653
|
-
if (state !== null && state !== undefined) {
|
|
1654
|
-
setValue(state);
|
|
1655
|
-
}
|
|
1656
|
-
subscribers.next(state);
|
|
1657
|
-
}, [state]);
|
|
2090
|
+
const errors = validators ? controlIsValid({ state, validators }) : [];
|
|
2091
|
+
const valid = errors.length === 0;
|
|
1658
2092
|
function focus() {
|
|
1659
|
-
|
|
2093
|
+
setControlState((state) => ({ ...state, focused: true }));
|
|
1660
2094
|
}
|
|
1661
2095
|
function blur() {
|
|
1662
|
-
|
|
2096
|
+
setControlState((state) => ({ ...state, focused: false, touched: true }));
|
|
1663
2097
|
}
|
|
1664
2098
|
function disable() {
|
|
1665
|
-
|
|
2099
|
+
setControlState((state) => ({ ...state, disabled: true }));
|
|
1666
2100
|
}
|
|
1667
2101
|
function enable() {
|
|
1668
|
-
|
|
2102
|
+
setControlState((state) => ({ ...state, disabled: false }));
|
|
1669
2103
|
}
|
|
1670
2104
|
function touch() {
|
|
1671
|
-
|
|
1672
|
-
}
|
|
1673
|
-
function untouch() {
|
|
1674
|
-
setTouched(false);
|
|
2105
|
+
setControlState((state) => ({ ...state, touched: true }));
|
|
1675
2106
|
}
|
|
1676
2107
|
function setState(state) {
|
|
1677
|
-
|
|
1678
|
-
|
|
2108
|
+
setControlState((currentState) => ({
|
|
2109
|
+
...currentState,
|
|
2110
|
+
dirty: true,
|
|
2111
|
+
state
|
|
2112
|
+
}));
|
|
1679
2113
|
}
|
|
1680
|
-
function
|
|
1681
|
-
|
|
1682
|
-
setDirty(false);
|
|
1683
|
-
setCurrentState(initialValue);
|
|
2114
|
+
function setValidators(validators) {
|
|
2115
|
+
setControlState((state) => ({ ...state, validators }));
|
|
1684
2116
|
}
|
|
1685
|
-
function
|
|
1686
|
-
|
|
1687
|
-
|
|
2117
|
+
function reset() {
|
|
2118
|
+
setControlState((currentState) => ({
|
|
2119
|
+
...currentState,
|
|
2120
|
+
dirty: false,
|
|
2121
|
+
state: initialState.current,
|
|
2122
|
+
touched: false
|
|
2123
|
+
}));
|
|
1688
2124
|
}
|
|
1689
2125
|
return {
|
|
2126
|
+
...controlState,
|
|
1690
2127
|
blur,
|
|
1691
|
-
dirty,
|
|
1692
2128
|
disable,
|
|
1693
|
-
disabled,
|
|
1694
2129
|
elementRef,
|
|
1695
2130
|
enable,
|
|
1696
|
-
enabled: !disabled,
|
|
1697
|
-
error,
|
|
2131
|
+
enabled: !controlState.disabled,
|
|
2132
|
+
error: errors[0],
|
|
1698
2133
|
errors,
|
|
1699
2134
|
focus,
|
|
1700
|
-
focused,
|
|
1701
2135
|
invalid: !valid,
|
|
1702
|
-
pristine: !dirty,
|
|
2136
|
+
pristine: !controlState.dirty,
|
|
1703
2137
|
reset,
|
|
1704
2138
|
setState,
|
|
1705
2139
|
setValidators,
|
|
1706
|
-
state,
|
|
1707
|
-
subscribe,
|
|
1708
2140
|
touch,
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
untouch,
|
|
1712
|
-
untouched: !touched,
|
|
2141
|
+
unfocused: !controlState.focused,
|
|
2142
|
+
untouched: !controlState.touched,
|
|
1713
2143
|
valid,
|
|
1714
|
-
|
|
1715
|
-
wrong: touched && !valid
|
|
2144
|
+
wrong: controlState.touched && !valid
|
|
1716
2145
|
};
|
|
1717
2146
|
}
|
|
1718
|
-
function useReactControl(
|
|
1719
|
-
return useControl(
|
|
2147
|
+
function useReactControl(options, validators) {
|
|
2148
|
+
return useControl(options, validators);
|
|
1720
2149
|
}
|
|
1721
2150
|
|
|
1722
2151
|
const FORMAT_DESCRIPTION = '{dw}, {mx} {dd} de {aa}';
|
|
@@ -1781,7 +2210,7 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
1781
2210
|
onListener({ type: PickerListenerType.Select, value });
|
|
1782
2211
|
}
|
|
1783
2212
|
}
|
|
1784
|
-
return (jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-picker-date__header", children: [jsx("div", { className: "rls-picker-date__title rls-picker-date__title--description", children: jsx("span", { onClick: onVisibilityDay, children: dateFormatTemplate(dateInitial, FORMAT_DESCRIPTION) }) }), jsx("div", { className: "rls-picker-date__title rls-picker-date__title--year", children: jsx("span", { onClick: onVisibilityYear, children: yearControl.
|
|
2213
|
+
return (jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxs("div", { className: "rls-picker-date__header", children: [jsx("div", { className: "rls-picker-date__title rls-picker-date__title--description", children: jsx("span", { onClick: onVisibilityDay, children: dateFormatTemplate(dateInitial, FORMAT_DESCRIPTION) }) }), jsx("div", { className: "rls-picker-date__title rls-picker-date__title--year", children: jsx("span", { onClick: onVisibilityYear, children: yearControl.state }) }), jsx(RlsPickerMonthTitle, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityMonth })] }), jsxs("div", { className: renderClassStatus('rls-picker-date__component', {
|
|
1785
2214
|
day: visibility === 'DAY',
|
|
1786
2215
|
month: visibility === 'MONTH',
|
|
1787
2216
|
year: visibility === 'YEAR'
|
|
@@ -1815,10 +2244,8 @@ function RlsFieldDate({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
1815
2244
|
}
|
|
1816
2245
|
function onClean() {
|
|
1817
2246
|
if (value) {
|
|
2247
|
+
formControl?.touch();
|
|
1818
2248
|
onChange(undefined);
|
|
1819
|
-
if (formControl && !formControl.touched) {
|
|
1820
|
-
formControl.touch();
|
|
1821
|
-
}
|
|
1822
2249
|
}
|
|
1823
2250
|
else {
|
|
1824
2251
|
setModalIsVisible(true);
|
|
@@ -1828,10 +2255,8 @@ function RlsFieldDate({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
1828
2255
|
if (type !== PickerListenerType.Cancel) {
|
|
1829
2256
|
onChange(value, true);
|
|
1830
2257
|
}
|
|
2258
|
+
formControl?.touch();
|
|
1831
2259
|
setModalIsVisible(false);
|
|
1832
|
-
if (!formControl?.touched) {
|
|
1833
|
-
formControl?.touch();
|
|
1834
|
-
}
|
|
1835
2260
|
} }) })] }));
|
|
1836
2261
|
}
|
|
1837
2262
|
|
|
@@ -2114,5 +2539,5 @@ function RlsApplication({ children }) {
|
|
|
2114
2539
|
return (jsxs(RlsContext.Provider, { value: { confirmation, snackbar }, children: [jsx("div", { className: "rls-app__body", children: children }), RlsSnackbar, RlsConfirmation] }));
|
|
2115
2540
|
}
|
|
2116
2541
|
|
|
2117
|
-
export { ConfirmationResult, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableInfo, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerMonthTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton,
|
|
2542
|
+
export { ConfirmationResult, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableInfo, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerMonthTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsTabularText, RlsToolbar, rangeFormatTemplate, renderClassStatus, useConfirmationService, useDatatable, useListControl, useSnackbarService };
|
|
2118
2543
|
//# sourceMappingURL=index.js.map
|