@rolster/react-components 18.13.5 → 18.14.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-LjAadYQE.css → index--xgdaD5z.css} +460 -468
- package/dist/cjs/index.js +1023 -1025
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/assets/{index-LjAadYQE.css → index--xgdaD5z.css} +460 -468
- package/dist/es/index.js +1004 -1007
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/atoms/Input/Input.css +2 -2
- package/dist/esm/components/atoms/Input/Input.js +1 -8
- package/dist/esm/components/atoms/Input/Input.js.map +1 -1
- package/dist/esm/components/atoms/InputMoney/InputMoney.css +0 -2
- package/dist/esm/components/atoms/InputNumber/InputNumber.css +0 -2
- package/dist/esm/components/atoms/InputPassword/InputPassword.css +0 -2
- package/dist/esm/components/atoms/InputText/InputText.css +0 -2
- package/dist/esm/components/molecules/FieldMoney/FieldMoney.css +6 -0
- package/dist/esm/components/molecules/{MoneyField/MoneyField.d.ts → FieldMoney/FieldMoney.d.ts} +3 -3
- package/dist/esm/components/molecules/FieldMoney/FieldMoney.js +13 -0
- package/dist/esm/components/molecules/FieldMoney/FieldMoney.js.map +1 -0
- package/dist/esm/components/molecules/FieldNumber/FieldNumber.css +6 -0
- package/dist/esm/components/molecules/{NumberField/NumberField.d.ts → FieldNumber/FieldNumber.d.ts} +3 -3
- package/dist/esm/components/molecules/FieldNumber/FieldNumber.js +13 -0
- package/dist/esm/components/molecules/FieldNumber/FieldNumber.js.map +1 -0
- package/dist/esm/components/molecules/{PasswordField/PasswordField.css → FieldPassword/FieldPassword.css} +3 -3
- package/dist/esm/components/molecules/{PasswordField/PasswordField.d.ts → FieldPassword/FieldPassword.d.ts} +3 -3
- package/dist/esm/components/molecules/FieldPassword/FieldPassword.js +18 -0
- package/dist/esm/components/molecules/FieldPassword/FieldPassword.js.map +1 -0
- package/dist/esm/components/molecules/FieldText/FieldText.css +6 -0
- package/dist/esm/components/molecules/{TextField/TextField.d.ts → FieldText/FieldText.d.ts} +3 -3
- package/dist/esm/components/molecules/FieldText/FieldText.js +13 -0
- package/dist/esm/components/molecules/FieldText/FieldText.js.map +1 -0
- package/dist/esm/components/molecules/{CheckBoxLabel/CheckBoxLabel.css → LabelCheckBox/LabelCheckBox.css} +5 -5
- package/dist/esm/components/molecules/{CheckBoxLabel/CheckBoxLabel.d.ts → LabelCheckBox/LabelCheckBox.d.ts} +3 -3
- package/dist/esm/components/molecules/{CheckBoxLabel/CheckBoxLabel.js → LabelCheckBox/LabelCheckBox.js} +5 -5
- package/dist/esm/components/molecules/{CheckBoxLabel/CheckBoxLabel.js.map → LabelCheckBox/LabelCheckBox.js.map} +1 -1
- package/dist/esm/components/molecules/{RadioButtonLabel/RadioButtonLabel.css → LabelRadioButton/LabelRadioButton.css} +5 -5
- package/dist/esm/components/molecules/{RadioButtonLabel/RadioButtonLabel.d.ts → LabelRadioButton/LabelRadioButton.d.ts} +3 -3
- package/dist/esm/components/molecules/{RadioButtonLabel/RadioButtonLabel.js → LabelRadioButton/LabelRadioButton.js} +5 -5
- package/dist/esm/components/molecules/{RadioButtonLabel/RadioButtonLabel.js.map → LabelRadioButton/LabelRadioButton.js.map} +1 -1
- package/dist/esm/components/molecules/{SwitchLabel/SwitchLabel.css → LabelSwitch/LabelSwitch.css} +5 -5
- package/dist/esm/components/molecules/{SwitchLabel/SwitchLabel.d.ts → LabelSwitch/LabelSwitch.d.ts} +3 -3
- package/dist/esm/components/molecules/{SwitchLabel/SwitchLabel.js → LabelSwitch/LabelSwitch.js} +4 -4
- package/dist/esm/components/molecules/{SwitchLabel/SwitchLabel.js.map → LabelSwitch/LabelSwitch.js.map} +1 -1
- package/dist/esm/components/molecules/MessageFormError/MesageFormError.css +0 -0
- package/dist/esm/components/molecules/MessageFormError/MesageFormError.d.ts +7 -0
- package/dist/esm/components/molecules/MessageFormError/MesageFormError.js +6 -0
- package/dist/esm/components/molecules/MessageFormError/MesageFormError.js.map +1 -0
- package/dist/esm/components/molecules/{DayPicker/DayPicker.css → PickerDay/PickerDay.css} +13 -13
- package/dist/esm/components/molecules/{DayPicker/DayPicker.d.ts → PickerDay/PickerDay.d.ts} +3 -3
- package/dist/esm/components/molecules/{DayPicker/DayPicker.js → PickerDay/PickerDay.js} +5 -5
- package/dist/esm/components/molecules/{DayPicker/DayPicker.js.map → PickerDay/PickerDay.js.map} +1 -1
- package/dist/esm/components/molecules/{DayRangePicker/DayRangePicker.css → PickerDayRange/PickerDayRange.css} +14 -14
- package/dist/esm/components/molecules/{DayRangePicker/DayRangePicker.d.ts → PickerDayRange/PickerDayRange.d.ts} +3 -3
- package/dist/esm/components/molecules/{DayRangePicker/DayRangePicker.js → PickerDayRange/PickerDayRange.js} +5 -5
- package/dist/esm/components/molecules/{DayRangePicker/DayRangePicker.js.map → PickerDayRange/PickerDayRange.js.map} +1 -1
- package/dist/esm/components/molecules/{MonthPicker/MonthPicker.css → PickerMonth/PickerMonth.css} +8 -8
- package/dist/esm/components/molecules/{MonthPicker/MonthPicker.d.ts → PickerMonth/PickerMonth.d.ts} +3 -3
- package/dist/esm/components/molecules/{MonthPicker/MonthPicker.js → PickerMonth/PickerMonth.js} +5 -5
- package/dist/esm/components/molecules/{MonthPicker/MonthPicker.js.map → PickerMonth/PickerMonth.js.map} +1 -1
- package/dist/esm/components/molecules/{MonthTitlePicker/MonthTitlePicker.css → PickerMonthTitle/PickerMonthTitle.css} +3 -3
- package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.d.ts +15 -0
- package/dist/esm/components/molecules/{MonthTitlePicker/MonthTitlePicker.js → PickerMonthTitle/PickerMonthTitle.js} +5 -5
- package/dist/esm/components/molecules/{MonthTitlePicker/MonthTitlePicker.js.map → PickerMonthTitle/PickerMonthTitle.js.map} +1 -1
- package/dist/esm/components/molecules/{YearPicker/YearPicker.css → PickerYear/PickerYear.css} +14 -14
- package/dist/esm/components/molecules/{YearPicker/YearPicker.d.ts → PickerYear/PickerYear.d.ts} +3 -3
- package/dist/esm/components/molecules/{YearPicker/YearPicker.js → PickerYear/PickerYear.js} +5 -5
- package/dist/esm/components/molecules/{YearPicker/YearPicker.js.map → PickerYear/PickerYear.js.map} +1 -1
- package/dist/esm/components/molecules/index.d.ts +13 -12
- package/dist/esm/components/molecules/index.js +13 -12
- package/dist/esm/components/molecules/index.js.map +1 -1
- package/dist/esm/components/organisms/{AutocompleteField/AutocompleteField.css → FieldAutocomplete/FieldAutocomplete.css} +15 -15
- package/dist/esm/components/organisms/{AutocompleteField/AutocompleteField.d.ts → FieldAutocomplete/FieldAutocomplete.d.ts} +5 -5
- package/dist/esm/components/organisms/{AutocompleteField/AutocompleteField.js → FieldAutocomplete/FieldAutocomplete.js} +13 -13
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -0
- package/dist/esm/components/organisms/{AutocompleteField/AutocompleteFieldHook.d.ts → FieldAutocomplete/FieldAutocompleteHook.d.ts} +3 -3
- package/dist/esm/components/organisms/{AutocompleteField/AutocompleteFieldHook.js → FieldAutocomplete/FieldAutocompleteHook.js} +2 -2
- package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js.map +1 -0
- package/dist/esm/components/organisms/{DateField/DateField.css → FieldDate/FieldDate.css} +8 -8
- package/dist/esm/components/organisms/{DateField/DateField.d.ts → FieldDate/FieldDate.d.ts} +3 -3
- package/dist/esm/components/organisms/{DateField/DateField.js → FieldDate/FieldDate.js} +7 -6
- package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -0
- package/dist/esm/components/organisms/{DateRangeField/DateRangeField.css → FieldDateRange/FieldDateRange.css} +6 -6
- package/dist/esm/components/organisms/{DateRangeField/DateRangeField.d.ts → FieldDateRange/FieldDateRange.d.ts} +3 -3
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +34 -0
- package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js.map +1 -0
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.css +10 -0
- package/dist/esm/components/organisms/{SelectField/SelectField.d.ts → FieldSelect/FieldSelect.d.ts} +5 -5
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +27 -0
- package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -0
- package/dist/esm/components/organisms/{SelectField/SelectFieldHook.d.ts → FieldSelect/FieldSelectHook.d.ts} +3 -3
- package/dist/esm/components/organisms/{SelectField/SelectFieldHook.js → FieldSelect/FieldSelectHook.js} +2 -2
- package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js.map +1 -0
- package/dist/esm/components/organisms/{DatePicker/DatePicker.css → PickerDate/PickerDate.css} +17 -17
- package/dist/esm/components/organisms/{DatePicker/DatePicker.d.ts → PickerDate/PickerDate.d.ts} +3 -3
- package/dist/esm/components/organisms/{DatePicker/DatePicker.js → PickerDate/PickerDate.js} +6 -6
- package/dist/esm/components/organisms/{DatePicker/DatePicker.js.map → PickerDate/PickerDate.js.map} +1 -1
- package/dist/esm/components/organisms/{DateRangePicker/DateRangePicker.css → PickerDateRange/PickerDateRange.css} +16 -16
- package/dist/esm/components/organisms/{DateRangePicker/DateRangePicker.d.ts → PickerDateRange/PickerDateRange.d.ts} +3 -3
- package/dist/esm/components/organisms/{DateRangePicker/DateRangePicker.js → PickerDateRange/PickerDateRange.js} +7 -7
- package/dist/esm/components/organisms/{DateRangePicker/DateRangePicker.js.map → PickerDateRange/PickerDateRange.js.map} +1 -1
- package/dist/esm/components/organisms/index.d.ts +6 -6
- package/dist/esm/components/organisms/index.js +6 -6
- package/dist/esm/components/organisms/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/esm/components/molecules/MoneyField/MoneyField.css +0 -6
- package/dist/esm/components/molecules/MoneyField/MoneyField.js +0 -12
- package/dist/esm/components/molecules/MoneyField/MoneyField.js.map +0 -1
- package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.d.ts +0 -15
- package/dist/esm/components/molecules/NumberField/NumberField.css +0 -6
- package/dist/esm/components/molecules/NumberField/NumberField.js +0 -12
- package/dist/esm/components/molecules/NumberField/NumberField.js.map +0 -1
- package/dist/esm/components/molecules/PasswordField/PasswordField.js +0 -17
- package/dist/esm/components/molecules/PasswordField/PasswordField.js.map +0 -1
- package/dist/esm/components/molecules/TextField/TextField.css +0 -6
- package/dist/esm/components/molecules/TextField/TextField.js +0 -12
- package/dist/esm/components/molecules/TextField/TextField.js.map +0 -1
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteField.js.map +0 -1
- package/dist/esm/components/organisms/AutocompleteField/AutocompleteFieldHook.js.map +0 -1
- package/dist/esm/components/organisms/DateField/DateField.js.map +0 -1
- package/dist/esm/components/organisms/DateRangeField/DateRangeField.js +0 -33
- package/dist/esm/components/organisms/DateRangeField/DateRangeField.js.map +0 -1
- package/dist/esm/components/organisms/SelectField/SelectField.css +0 -10
- package/dist/esm/components/organisms/SelectField/SelectField.js +0 -27
- package/dist/esm/components/organisms/SelectField/SelectField.js.map +0 -1
- package/dist/esm/components/organisms/SelectField/SelectFieldHook.js.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var helpersAdvanced = require('@rolster/helpers-advanced');
|
|
6
|
-
var helpersDate = require('@rolster/helpers-date');
|
|
7
6
|
var helpersString = require('@rolster/helpers-string');
|
|
8
|
-
var
|
|
7
|
+
var helpersDate = require('@rolster/helpers-date');
|
|
9
8
|
var ReactDOM = require('react-dom');
|
|
9
|
+
var i18n = require('@rolster/i18n');
|
|
10
10
|
var helpersForms = require('@rolster/helpers-forms');
|
|
11
11
|
require('uuid');
|
|
12
12
|
var rxjs = require('rxjs');
|
|
@@ -75,14 +75,7 @@ function RlsCheckBoxControl({ formControl, disabled, rlsTheme }) {
|
|
|
75
75
|
function RlsInput({ children, disabled, formControl, placeholder, type, value, onValue }) {
|
|
76
76
|
const [focused, setFocused] = react.useState(false);
|
|
77
77
|
function onChange(event) {
|
|
78
|
-
|
|
79
|
-
case 'number':
|
|
80
|
-
setState(+event.target.value);
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
setState(event.target.value);
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
78
|
+
setState(type === 'number' ? +event.target.value : event.target.value);
|
|
86
79
|
}
|
|
87
80
|
function setState(value) {
|
|
88
81
|
formControl?.setState(value);
|
|
@@ -256,7 +249,47 @@ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsThem
|
|
|
256
249
|
}), children: jsxRuntime.jsx("ul", { children: options.map((action, index) => (jsxRuntime.jsx("li", { className: "truncate", onClick: () => onSelectAction(action), children: action.label }, index))) }) })] }));
|
|
257
250
|
}
|
|
258
251
|
|
|
259
|
-
function
|
|
252
|
+
function RlsMessageFormError({ className, formControl }) {
|
|
253
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: formControl?.wrong && (jsxRuntime.jsx("div", { className: className, children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl?.error?.message }) })) }));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function RlsFieldMoney({ children, decimals, disabled, formControl, placeholder, symbol, rlsTheme, value, onValue }) {
|
|
257
|
+
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
258
|
+
focused: formControl?.focused,
|
|
259
|
+
error: formControl?.wrong,
|
|
260
|
+
disabled: formControl?.disabled || disabled
|
|
261
|
+
}, 'rls-field-money'), "rls-theme": rlsTheme, children: [children && jsxRuntime.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntime.jsx("div", { className: "rls-field-box__component", children: jsxRuntime.jsx("div", { className: "rls-field-box__body", children: jsxRuntime.jsx(RlsInputMoney, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, symbol: symbol, decimals: decimals, onValue: onValue }) }) }), jsxRuntime.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function RlsFieldNumber({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
|
|
265
|
+
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
266
|
+
focused: formControl?.focused,
|
|
267
|
+
error: formControl?.wrong,
|
|
268
|
+
disabled: formControl?.disabled || disabled
|
|
269
|
+
}, 'rls-field-number'), "rls-theme": rlsTheme, children: [children && jsxRuntime.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntime.jsx("div", { className: "rls-field-box__component", children: jsxRuntime.jsx("div", { className: "rls-field-box__body", children: jsxRuntime.jsx(RlsInputNumber, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), jsxRuntime.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function RlsFieldPassword({ children, disabled, formControl, placeholder, rlsTheme }) {
|
|
273
|
+
const [password, setPassword] = react.useState(true);
|
|
274
|
+
function onToggleInput() {
|
|
275
|
+
setPassword(!password);
|
|
276
|
+
}
|
|
277
|
+
return (jsxRuntime.jsxs("div", { className: renderClassStatus(' rls-field-box', {
|
|
278
|
+
focused: formControl?.focused,
|
|
279
|
+
error: formControl?.wrong,
|
|
280
|
+
disabled: formControl?.disabled || disabled
|
|
281
|
+
}, 'rls-field-password'), "rls-theme": rlsTheme, 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(RlsInputPassword, { formControl: formControl, disabled: disabled, placeholder: placeholder, type: password ? 'password' : 'text' }), jsxRuntime.jsx(RlsButtonAction, { icon: password ? 'eye' : 'eye-off', onClick: onToggleInput })] }) }), jsxRuntime.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function RlsFieldText({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
|
|
285
|
+
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-box', {
|
|
286
|
+
focused: formControl?.focused,
|
|
287
|
+
error: formControl?.wrong,
|
|
288
|
+
disabled: formControl?.disabled || disabled
|
|
289
|
+
}, 'rls-field-text'), "rls-theme": rlsTheme, children: [children && jsxRuntime.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntime.jsx("div", { className: "rls-field-box__component", children: jsxRuntime.jsx("div", { className: "rls-field-box__body", children: jsxRuntime.jsx(RlsInputText, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), jsxRuntime.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })] }));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function RlsLabelCheckBox({ children, disabled, extended, formControl, rlsTheme }) {
|
|
260
293
|
const [checked, setChecked] = react.useState(formControl?.value || false);
|
|
261
294
|
react.useEffect(() => {
|
|
262
295
|
setChecked(formControl?.state || false);
|
|
@@ -269,946 +302,906 @@ function RlsCheckBoxLabel({ children, disabled, extended, formControl, rlsTheme
|
|
|
269
302
|
setChecked(!checked);
|
|
270
303
|
}
|
|
271
304
|
}
|
|
272
|
-
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-checkbox
|
|
305
|
+
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-label-checkbox', {
|
|
273
306
|
disabled,
|
|
274
307
|
extended
|
|
275
|
-
}), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function dateIsOutRangeMin(props) {
|
|
279
|
-
const { date, minDate } = props;
|
|
280
|
-
return !!minDate && helpersDate.dateIsBefore(helpersDate.normalizeMinTime(minDate), date);
|
|
281
|
-
}
|
|
282
|
-
function dateIsOutRangeMax(props) {
|
|
283
|
-
const { date, maxDate } = props;
|
|
284
|
-
return !!maxDate && helpersDate.dateIsAfter(helpersDate.normalizeMaxTime(maxDate), date);
|
|
285
|
-
}
|
|
286
|
-
function dateOutRange(props) {
|
|
287
|
-
return dateIsOutRangeMin(props) || dateIsOutRangeMax(props);
|
|
288
|
-
}
|
|
289
|
-
function checkDateRange(props) {
|
|
290
|
-
const { date, maxDate, minDate } = props;
|
|
291
|
-
return minDate && dateIsOutRangeMax(props)
|
|
292
|
-
? minDate
|
|
293
|
-
: maxDate && dateIsOutRangeMax(props)
|
|
294
|
-
? maxDate
|
|
295
|
-
: date;
|
|
308
|
+
}), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-label-checkbox__component", onClick: onToggle, children: jsxRuntime.jsx(RlsCheckBox, { checked: checked, disabled: disabled }) }), jsxRuntime.jsx("label", { className: "rls-label-checkbox__text", children: children })] }));
|
|
296
309
|
}
|
|
297
310
|
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
function createFirstWeek$1(props, date, today) {
|
|
314
|
-
const days = [];
|
|
315
|
-
let day = 1;
|
|
316
|
-
for (let start = 0; start < date.getDay(); start++) {
|
|
317
|
-
days.push(createDayState(props, today));
|
|
318
|
-
}
|
|
319
|
-
for (let end = date.getDay(); end < 7; end++) {
|
|
320
|
-
days.push(createDayState(props, today, day));
|
|
321
|
-
day++;
|
|
322
|
-
}
|
|
323
|
-
return { days };
|
|
324
|
-
}
|
|
325
|
-
function createDaysPending$1(props, today, days) {
|
|
326
|
-
const daysPending = [];
|
|
327
|
-
const length = 7 - days;
|
|
328
|
-
for (let index = 0; index < length; index++) {
|
|
329
|
-
daysPending.push(createDayState(props, today));
|
|
330
|
-
}
|
|
331
|
-
return daysPending;
|
|
332
|
-
}
|
|
333
|
-
function createNextWeeks$1(props, date, today) {
|
|
334
|
-
const daysMonth = helpersDate.getDaysOfMonth(date.getFullYear(), date.getMonth());
|
|
335
|
-
const weeks = [];
|
|
336
|
-
let days = [];
|
|
337
|
-
let countDays = 1;
|
|
338
|
-
let day = DAYS_WEEK - date.getDay() + 1;
|
|
339
|
-
do {
|
|
340
|
-
days.push(createDayState(props, today, day));
|
|
341
|
-
day++;
|
|
342
|
-
countDays++;
|
|
343
|
-
if (countDays > DAYS_WEEK) {
|
|
344
|
-
weeks.push({ days });
|
|
345
|
-
days = [];
|
|
346
|
-
countDays = 1;
|
|
347
|
-
}
|
|
348
|
-
} while (day <= daysMonth);
|
|
349
|
-
if (days.length && days.length < DAYS_WEEK) {
|
|
350
|
-
weeks.push({
|
|
351
|
-
days: [...days, ...createDaysPending$1(props, today, days.length)]
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
return weeks;
|
|
355
|
-
}
|
|
356
|
-
function dayIsOutsideMin(props, day) {
|
|
357
|
-
const { month, year, minDate } = props;
|
|
358
|
-
return minDate
|
|
359
|
-
? helpersDate.getDateWeight(new Date(year, month, day)) < helpersDate.getDateWeight(minDate)
|
|
360
|
-
: false;
|
|
361
|
-
}
|
|
362
|
-
function dayIsOutsideMax(props, day) {
|
|
363
|
-
const { month, year, maxDate } = props;
|
|
364
|
-
return maxDate
|
|
365
|
-
? helpersDate.getDateWeight(new Date(year, month, day)) > helpersDate.getDateWeight(maxDate)
|
|
366
|
-
: false;
|
|
367
|
-
}
|
|
368
|
-
function dayIsOutside(props, day) {
|
|
369
|
-
return dayIsOutsideMin(props, day) || dayIsOutsideMax(props, day);
|
|
370
|
-
}
|
|
371
|
-
function checkDayPicker(props) {
|
|
372
|
-
const { day, maxDate, minDate } = props;
|
|
373
|
-
return minDate && dayIsOutsideMin(props, day)
|
|
374
|
-
? minDate.getDate()
|
|
375
|
-
: maxDate && dayIsOutsideMax(props, day)
|
|
376
|
-
? maxDate.getDate()
|
|
377
|
-
: undefined;
|
|
378
|
-
}
|
|
379
|
-
function createDayPicker(props) {
|
|
380
|
-
const date = new Date(props.year, props.month, 1);
|
|
381
|
-
const today = new Date();
|
|
382
|
-
const firstWeek = createFirstWeek$1(props, date, today);
|
|
383
|
-
const nextWeeks = createNextWeeks$1(props, date, today);
|
|
384
|
-
return [firstWeek, ...nextWeeks];
|
|
311
|
+
function RlsLabelRadioButton({ children, disabled, extended, formControl, rlsTheme, value }) {
|
|
312
|
+
const [checked, setChecked] = react.useState(formControl?.state || false);
|
|
313
|
+
react.useEffect(() => {
|
|
314
|
+
setChecked(formControl?.state === value);
|
|
315
|
+
}, [formControl?.state]);
|
|
316
|
+
function onSelect() {
|
|
317
|
+
if (formControl) {
|
|
318
|
+
formControl?.setState(value);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-label-radiobutton', {
|
|
322
|
+
disabled,
|
|
323
|
+
extended
|
|
324
|
+
}), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-label-radiobutton__component", onClick: onSelect, children: jsxRuntime.jsx(RlsRadioButton, { checked: checked, disabled: disabled }) }), jsxRuntime.jsx("label", { className: "rls-label-radiobutton__text", children: children })] }));
|
|
385
325
|
}
|
|
386
326
|
|
|
387
|
-
function
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
function
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
return
|
|
401
|
-
}
|
|
402
|
-
function createDayRangeState(props, base, day) {
|
|
403
|
-
return {
|
|
404
|
-
disabled: dayRangeIsOutside(props, day || 0),
|
|
405
|
-
end: day ? rangeIsSelected(props, base, day) : false,
|
|
406
|
-
forbidden: !day,
|
|
407
|
-
ranged: day ? dayIsRange(props, base, day) : false,
|
|
408
|
-
source: day ? sourceIsSelected(props, base, day) : false,
|
|
409
|
-
value: day
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
function createFirstWeek(props, base) {
|
|
413
|
-
const days = [];
|
|
414
|
-
let day = 1;
|
|
415
|
-
for (let start = 0; start < base.getDay(); start++) {
|
|
416
|
-
days.push(createDayRangeState(props, base));
|
|
417
|
-
}
|
|
418
|
-
for (let end = base.getDay(); end < 7; end++) {
|
|
419
|
-
days.push(createDayRangeState(props, base, day));
|
|
420
|
-
day++;
|
|
421
|
-
}
|
|
422
|
-
return { days };
|
|
423
|
-
}
|
|
424
|
-
function createDaysPending(props, base, days) {
|
|
425
|
-
const daysPending = [];
|
|
426
|
-
const length = 7 - days;
|
|
427
|
-
for (let index = 0; index < length; index++) {
|
|
428
|
-
daysPending.push(createDayRangeState(props, base));
|
|
429
|
-
}
|
|
430
|
-
return daysPending;
|
|
431
|
-
}
|
|
432
|
-
function createNextWeeks(props, base) {
|
|
433
|
-
const weeks = [];
|
|
434
|
-
const { date } = props;
|
|
435
|
-
const dayCount = helpersDate.getDaysOfMonth(date.getFullYear(), date.getMonth());
|
|
436
|
-
let days = [];
|
|
437
|
-
let countDays = 1;
|
|
438
|
-
let day = DAYS_WEEK - base.getDay() + 1;
|
|
439
|
-
do {
|
|
440
|
-
days.push(createDayRangeState(props, date, day));
|
|
441
|
-
day++;
|
|
442
|
-
countDays++;
|
|
443
|
-
if (countDays > 7) {
|
|
444
|
-
weeks.push({ days });
|
|
445
|
-
days = [];
|
|
446
|
-
countDays = 1;
|
|
447
|
-
}
|
|
448
|
-
} while (day <= dayCount);
|
|
449
|
-
if (days.length && days.length < DAYS_WEEK) {
|
|
450
|
-
weeks.push({
|
|
451
|
-
days: [...days, ...createDaysPending(props, base, days.length)]
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
return weeks;
|
|
455
|
-
}
|
|
456
|
-
function dayRangeIsOutsideMin(props, day) {
|
|
457
|
-
const { date, minDate } = props;
|
|
458
|
-
return minDate
|
|
459
|
-
? helpersDate.getDateWeight(helpersDate.assignDayInDate(date, day)) < helpersDate.getDateWeight(minDate)
|
|
460
|
-
: false;
|
|
461
|
-
}
|
|
462
|
-
function dayRangeIsOutsideMax(props, day) {
|
|
463
|
-
const { date, maxDate } = props;
|
|
464
|
-
return maxDate
|
|
465
|
-
? helpersDate.getDateWeight(helpersDate.assignDayInDate(date, day)) > helpersDate.getDateWeight(maxDate)
|
|
466
|
-
: false;
|
|
467
|
-
}
|
|
468
|
-
function dayRangeIsOutside(props, day) {
|
|
469
|
-
return dayRangeIsOutsideMin(props, day) || dayRangeIsOutsideMax(props, day);
|
|
470
|
-
}
|
|
471
|
-
function createDayRangePicker(props) {
|
|
472
|
-
const date = new Date(props.date.getFullYear(), props.date.getMonth(), 1);
|
|
473
|
-
const firstWeek = createFirstWeek(props, date);
|
|
474
|
-
const nextWeeks = createNextWeeks(props, date);
|
|
475
|
-
return [firstWeek, ...nextWeeks];
|
|
327
|
+
function RlsLabelSwitch({ children, disabled, extended, formControl, rlsTheme }) {
|
|
328
|
+
const [checked, setChecked] = react.useState(formControl?.value || false);
|
|
329
|
+
react.useEffect(() => {
|
|
330
|
+
setChecked(formControl?.state || false);
|
|
331
|
+
}, [formControl?.state]);
|
|
332
|
+
function onToggle() {
|
|
333
|
+
if (formControl) {
|
|
334
|
+
formControl?.setState(!formControl.state);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
setChecked(!checked);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-label-switch', { disabled, extended }), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-label-switch__component", onClick: onToggle, children: jsxRuntime.jsx(RlsSwitch, { checked: checked, disabled: disabled }) }), jsxRuntime.jsx("label", { className: "rls-label-switch__text", children: children })] }));
|
|
476
341
|
}
|
|
477
342
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
343
|
+
const DEFAULT_COUNT_ELEMENT = 20;
|
|
344
|
+
const MIN_NUMBER_PAGE = 1;
|
|
345
|
+
const FIRST_PAGE = 0;
|
|
346
|
+
const DEFAULT_MAX_VISIBLE = 4;
|
|
347
|
+
function RlsPagination({ elements, count: defaultCount, filter, onElements, onPagination }) {
|
|
348
|
+
const count = defaultCount || DEFAULT_COUNT_ELEMENT;
|
|
349
|
+
const [collection, setCollection] = react.useState([]);
|
|
350
|
+
const [index, setIndex] = react.useState(0);
|
|
351
|
+
const [maxPage, setMaxPage] = react.useState(calculateMaxPage(elements, count));
|
|
352
|
+
const [paginations, setPaginations] = react.useState([]);
|
|
353
|
+
const [currentPagination, setCurrentPagination] = react.useState();
|
|
354
|
+
const [description, setDescription] = react.useState('');
|
|
355
|
+
const [firstPage, setFirstPage] = react.useState(true);
|
|
356
|
+
const [lastPage, setLastPage] = react.useState(false);
|
|
357
|
+
react.useEffect(() => {
|
|
358
|
+
refreshFromElements(elements);
|
|
359
|
+
}, [elements]);
|
|
360
|
+
react.useEffect(() => {
|
|
361
|
+
const isFirstPage = currentPagination?.value === FIRST_PAGE;
|
|
362
|
+
const isLastPage = currentPagination?.value === maxPage - 1;
|
|
363
|
+
setFirstPage(isFirstPage);
|
|
364
|
+
setLastPage(isLastPage);
|
|
365
|
+
if (onPagination) {
|
|
366
|
+
onPagination({ firstPage: isFirstPage, lastPage: isLastPage });
|
|
367
|
+
}
|
|
368
|
+
}, [currentPagination]);
|
|
369
|
+
react.useEffect(() => {
|
|
370
|
+
refreshFromFilter(filter);
|
|
371
|
+
}, [filter]);
|
|
372
|
+
function onChangeElements(elements) {
|
|
373
|
+
if (onElements) {
|
|
374
|
+
onElements(elements);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function calculateMaxPage(collection, count) {
|
|
378
|
+
return collection.length ? Math.ceil(collection.length / count) : 0;
|
|
379
|
+
}
|
|
380
|
+
function onSelectPagination(pagination) {
|
|
381
|
+
const { value } = pagination;
|
|
382
|
+
pagination.active = true;
|
|
383
|
+
setIndex(value);
|
|
384
|
+
setCurrentPagination(pagination);
|
|
385
|
+
refreshFromChanged(clonePage({ index: value }));
|
|
386
|
+
}
|
|
387
|
+
function goPagination(pagination) {
|
|
388
|
+
if (currentPagination) {
|
|
389
|
+
currentPagination.active = false;
|
|
390
|
+
}
|
|
391
|
+
onSelectPagination(pagination);
|
|
392
|
+
}
|
|
393
|
+
function goPreviousPagination() {
|
|
394
|
+
if (currentPagination) {
|
|
395
|
+
const { prev, value } = currentPagination;
|
|
396
|
+
if (prev) {
|
|
397
|
+
onSelectPagination(prev);
|
|
398
|
+
currentPagination.active = false;
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
const prevIndex = value - MIN_NUMBER_PAGE;
|
|
402
|
+
if (prevIndex >= FIRST_PAGE) {
|
|
403
|
+
refreshFromChanged(clonePageFromIndex(prevIndex));
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
function goFirstPagination() {
|
|
409
|
+
if (collection.length) {
|
|
410
|
+
refreshFromChanged(clonePageFromIndex(FIRST_PAGE));
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
function goNextPagination() {
|
|
414
|
+
if (currentPagination) {
|
|
415
|
+
const { next, value } = currentPagination;
|
|
416
|
+
if (next) {
|
|
417
|
+
onSelectPagination(next);
|
|
418
|
+
currentPagination.active = false;
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
const nextIndex = value + 1;
|
|
422
|
+
if (nextIndex <= maxPage) {
|
|
423
|
+
refreshFromChanged(clonePageFromIndex(nextIndex));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
function goLastPagination() {
|
|
429
|
+
if (collection.length) {
|
|
430
|
+
refreshFromChanged(clonePageFromIndex(maxPage - MIN_NUMBER_PAGE));
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
function createPageCollection(props) {
|
|
434
|
+
const { collection, count, index } = props;
|
|
435
|
+
if (collection.length) {
|
|
436
|
+
const finish = (index + MIN_NUMBER_PAGE) * count;
|
|
437
|
+
const start = index * count;
|
|
438
|
+
return collection.slice(start, finish);
|
|
439
|
+
}
|
|
440
|
+
return [];
|
|
441
|
+
}
|
|
442
|
+
function refreshFromElements(elements) {
|
|
443
|
+
elements.length
|
|
444
|
+
? refreshFromChanged(refreshPage(elements, filter))
|
|
445
|
+
: rebootPagination();
|
|
446
|
+
}
|
|
447
|
+
function refreshFromFilter(filter) {
|
|
448
|
+
refreshFromChanged(refreshPage(elements, filter));
|
|
449
|
+
}
|
|
450
|
+
function refreshFromChanged(page) {
|
|
451
|
+
refreshPaginations(page);
|
|
452
|
+
refreshDescription(page);
|
|
453
|
+
onChangeElements(createPageCollection(page));
|
|
454
|
+
}
|
|
455
|
+
function refreshCollection(elements, filter) {
|
|
456
|
+
const collection = filter
|
|
457
|
+
? elements.filter((element) => helpersString.hasPattern(JSON.stringify(element), filter))
|
|
458
|
+
: elements;
|
|
459
|
+
setCollection(collection);
|
|
460
|
+
return collection;
|
|
461
|
+
}
|
|
462
|
+
function refreshMaxPage(collection, count) {
|
|
463
|
+
const maxPage = calculateMaxPage(collection, count);
|
|
464
|
+
setMaxPage(maxPage);
|
|
465
|
+
return maxPage;
|
|
466
|
+
}
|
|
467
|
+
function refreshIndex(collection, currentMaxPage) {
|
|
468
|
+
const maxPage = currentMaxPage || refreshMaxPage(collection, count);
|
|
469
|
+
if (index < maxPage || index === FIRST_PAGE) {
|
|
470
|
+
return index;
|
|
471
|
+
}
|
|
472
|
+
const newIndex = maxPage - 1;
|
|
473
|
+
setIndex(newIndex);
|
|
474
|
+
return newIndex;
|
|
475
|
+
}
|
|
476
|
+
function refreshDescription(page) {
|
|
477
|
+
const { collection, count, index } = page;
|
|
478
|
+
const totalCount = elements.length;
|
|
479
|
+
const start = index * count + MIN_NUMBER_PAGE;
|
|
480
|
+
let end = (index + MIN_NUMBER_PAGE) * count;
|
|
481
|
+
if (end > collection.length) {
|
|
482
|
+
end = collection.length;
|
|
483
|
+
}
|
|
484
|
+
setDescription(`${start} - ${end} de ${totalCount}`);
|
|
485
|
+
}
|
|
486
|
+
function refreshPaginations({ index, maxPage }) {
|
|
487
|
+
let maxPageVisible = index + DEFAULT_MAX_VISIBLE;
|
|
488
|
+
if (maxPageVisible > maxPage) {
|
|
489
|
+
maxPageVisible = maxPage;
|
|
490
|
+
}
|
|
491
|
+
let minIndexPage = maxPageVisible - DEFAULT_MAX_VISIBLE;
|
|
492
|
+
if (minIndexPage < 0) {
|
|
493
|
+
minIndexPage = 0;
|
|
494
|
+
}
|
|
495
|
+
if (minIndexPage > index) {
|
|
496
|
+
minIndexPage = index;
|
|
497
|
+
}
|
|
498
|
+
let prevPagination = undefined;
|
|
499
|
+
const paginations = [];
|
|
500
|
+
for (let i = minIndexPage; i < maxPageVisible; i++) {
|
|
501
|
+
const pagination = createPagination(i, index);
|
|
502
|
+
paginations.push(pagination);
|
|
503
|
+
pagination.prev = prevPagination;
|
|
504
|
+
if (prevPagination) {
|
|
505
|
+
prevPagination.next = pagination;
|
|
506
|
+
}
|
|
507
|
+
prevPagination = pagination;
|
|
508
|
+
}
|
|
509
|
+
setPaginations(paginations);
|
|
510
|
+
}
|
|
511
|
+
function clonePage(pagePartial) {
|
|
512
|
+
return {
|
|
513
|
+
collection: pagePartial.collection || collection,
|
|
514
|
+
index: typeof pagePartial.index === 'number' ? pagePartial.index : index,
|
|
515
|
+
count: pagePartial.count || count,
|
|
516
|
+
maxPage: typeof pagePartial.maxPage === 'number' ? pagePartial.maxPage : maxPage
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
function clonePageFromIndex(index) {
|
|
520
|
+
return clonePage({ index });
|
|
521
|
+
}
|
|
522
|
+
function refreshPage(elements, filter) {
|
|
523
|
+
const collection = refreshCollection(elements, filter);
|
|
524
|
+
const maxPage = refreshMaxPage(collection, count);
|
|
525
|
+
const index = refreshIndex(collection, maxPage);
|
|
526
|
+
return clonePage({ collection, index, maxPage });
|
|
527
|
+
}
|
|
528
|
+
function createPagination(value, index) {
|
|
529
|
+
const active = value === index;
|
|
530
|
+
const pagination = {
|
|
531
|
+
label: (value + 1).toString(),
|
|
532
|
+
value,
|
|
533
|
+
active
|
|
534
|
+
};
|
|
535
|
+
if (active) {
|
|
536
|
+
setCurrentPagination(pagination);
|
|
537
|
+
}
|
|
538
|
+
return pagination;
|
|
539
|
+
}
|
|
540
|
+
function rebootPagination() {
|
|
541
|
+
setCollection([]);
|
|
542
|
+
setMaxPage(0);
|
|
543
|
+
setIndex(0);
|
|
544
|
+
setPaginations([]);
|
|
545
|
+
onChangeElements([]);
|
|
546
|
+
}
|
|
547
|
+
return (jsxRuntime.jsxs("div", { className: "rls-pagination", children: [jsxRuntime.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntime.jsx("button", { className: "rls-pagination__action", onClick: goFirstPagination, disabled: firstPage, children: jsxRuntime.jsx(RlsIcon, { value: "arrowhead-left" }) }), jsxRuntime.jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: firstPage, children: jsxRuntime.jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), jsxRuntime.jsx("div", { className: "rls-pagination__pages", children: paginations.map((page, index) => {
|
|
548
|
+
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-pagination__page', {
|
|
549
|
+
active: page.active
|
|
550
|
+
}), onClick: () => {
|
|
551
|
+
goPagination(page);
|
|
552
|
+
}, children: page.label }, index));
|
|
553
|
+
}) }), 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
|
+
}
|
|
555
|
+
|
|
556
|
+
function dateIsOutRangeMin(props) {
|
|
557
|
+
const { date, minDate } = props;
|
|
558
|
+
return !!minDate && helpersDate.dateIsBefore(helpersDate.normalizeMinTime(minDate), date);
|
|
559
|
+
}
|
|
560
|
+
function dateIsOutRangeMax(props) {
|
|
561
|
+
const { date, maxDate } = props;
|
|
562
|
+
return !!maxDate && helpersDate.dateIsAfter(helpersDate.normalizeMaxTime(maxDate), date);
|
|
563
|
+
}
|
|
564
|
+
function dateOutRange(props) {
|
|
565
|
+
return dateIsOutRangeMin(props) || dateIsOutRangeMax(props);
|
|
566
|
+
}
|
|
567
|
+
function checkDateRange(props) {
|
|
568
|
+
const { date, maxDate, minDate } = props;
|
|
569
|
+
return minDate && dateIsOutRangeMax(props)
|
|
570
|
+
? minDate
|
|
571
|
+
: maxDate && dateIsOutRangeMax(props)
|
|
572
|
+
? maxDate
|
|
573
|
+
: date;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
const DAYS_WEEK = 7;
|
|
577
|
+
const COUNT_YEAR_RANGE = 4;
|
|
578
|
+
|
|
579
|
+
function createDayState(props, today, value) {
|
|
580
|
+
const { date, day, month, year } = props;
|
|
581
|
+
const dateValue = value && new Date(year, month, value);
|
|
582
|
+
return {
|
|
583
|
+
disabled: dayIsOutside(props, value || 0),
|
|
584
|
+
focused: !!value && day === value,
|
|
585
|
+
forbidden: !value,
|
|
586
|
+
selected: !!dateValue && helpersDate.dateIsEqualsWeight(date, dateValue),
|
|
587
|
+
today: !!dateValue && helpersDate.dateIsEqualsWeight(today, dateValue),
|
|
485
588
|
value
|
|
486
589
|
};
|
|
487
590
|
}
|
|
488
|
-
function
|
|
489
|
-
const
|
|
591
|
+
function createFirstWeek$1(props, date, today) {
|
|
592
|
+
const days = [];
|
|
593
|
+
let day = 1;
|
|
594
|
+
for (let start = 0; start < date.getDay(); start++) {
|
|
595
|
+
days.push(createDayState(props, today));
|
|
596
|
+
}
|
|
597
|
+
for (let end = date.getDay(); end < 7; end++) {
|
|
598
|
+
days.push(createDayState(props, today, day));
|
|
599
|
+
day++;
|
|
600
|
+
}
|
|
601
|
+
return { days };
|
|
602
|
+
}
|
|
603
|
+
function createDaysPending$1(props, today, days) {
|
|
604
|
+
const daysPending = [];
|
|
605
|
+
const length = 7 - days;
|
|
606
|
+
for (let index = 0; index < length; index++) {
|
|
607
|
+
daysPending.push(createDayState(props, today));
|
|
608
|
+
}
|
|
609
|
+
return daysPending;
|
|
610
|
+
}
|
|
611
|
+
function createNextWeeks$1(props, date, today) {
|
|
612
|
+
const daysMonth = helpersDate.getDaysOfMonth(date.getFullYear(), date.getMonth());
|
|
613
|
+
const weeks = [];
|
|
614
|
+
let days = [];
|
|
615
|
+
let countDays = 1;
|
|
616
|
+
let day = DAYS_WEEK - date.getDay() + 1;
|
|
617
|
+
do {
|
|
618
|
+
days.push(createDayState(props, today, day));
|
|
619
|
+
day++;
|
|
620
|
+
countDays++;
|
|
621
|
+
if (countDays > DAYS_WEEK) {
|
|
622
|
+
weeks.push({ days });
|
|
623
|
+
days = [];
|
|
624
|
+
countDays = 1;
|
|
625
|
+
}
|
|
626
|
+
} while (day <= daysMonth);
|
|
627
|
+
if (days.length && days.length < DAYS_WEEK) {
|
|
628
|
+
weeks.push({
|
|
629
|
+
days: [...days, ...createDaysPending$1(props, today, days.length)]
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
return weeks;
|
|
633
|
+
}
|
|
634
|
+
function dayIsOutsideMin(props, day) {
|
|
635
|
+
const { month, year, minDate } = props;
|
|
490
636
|
return minDate
|
|
491
|
-
?
|
|
637
|
+
? helpersDate.getDateWeight(new Date(year, month, day)) < helpersDate.getDateWeight(minDate)
|
|
492
638
|
: false;
|
|
493
639
|
}
|
|
494
|
-
function
|
|
495
|
-
const { year, maxDate } = props;
|
|
640
|
+
function dayIsOutsideMax(props, day) {
|
|
641
|
+
const { month, year, maxDate } = props;
|
|
496
642
|
return maxDate
|
|
497
|
-
?
|
|
643
|
+
? helpersDate.getDateWeight(new Date(year, month, day)) > helpersDate.getDateWeight(maxDate)
|
|
498
644
|
: false;
|
|
499
645
|
}
|
|
500
|
-
function
|
|
501
|
-
return
|
|
502
|
-
}
|
|
503
|
-
function checkMonthPicker(props) {
|
|
504
|
-
const { maxDate, minDate, month } = props;
|
|
505
|
-
return minDate && monthIsOutsideMin(props, month)
|
|
506
|
-
? minDate.getMonth()
|
|
507
|
-
: maxDate && monthIsOutsideMax(props, month)
|
|
508
|
-
? maxDate.getMonth()
|
|
509
|
-
: undefined;
|
|
510
|
-
}
|
|
511
|
-
function createMonthPicker(props) {
|
|
512
|
-
return [
|
|
513
|
-
createMonthState(props, helpersDate.Month.January),
|
|
514
|
-
createMonthState(props, helpersDate.Month.February),
|
|
515
|
-
createMonthState(props, helpersDate.Month.March),
|
|
516
|
-
createMonthState(props, helpersDate.Month.April),
|
|
517
|
-
createMonthState(props, helpersDate.Month.May),
|
|
518
|
-
createMonthState(props, helpersDate.Month.June),
|
|
519
|
-
createMonthState(props, helpersDate.Month.July),
|
|
520
|
-
createMonthState(props, helpersDate.Month.August),
|
|
521
|
-
createMonthState(props, helpersDate.Month.September),
|
|
522
|
-
createMonthState(props, helpersDate.Month.October),
|
|
523
|
-
createMonthState(props, helpersDate.Month.November),
|
|
524
|
-
createMonthState(props, helpersDate.Month.December)
|
|
525
|
-
];
|
|
526
|
-
}
|
|
527
|
-
function monthIsLimitMin(props) {
|
|
528
|
-
const { month, date, minDate } = props;
|
|
529
|
-
if (helpersAdvanced.itIsDefined(month) && date) {
|
|
530
|
-
const minYear = minDate ? minDate.getFullYear() : 0;
|
|
531
|
-
const minMonth = minDate ? minDate.getMonth() : 0;
|
|
532
|
-
return date.getFullYear() === minYear && month <= minMonth;
|
|
533
|
-
}
|
|
534
|
-
return false;
|
|
646
|
+
function dayIsOutside(props, day) {
|
|
647
|
+
return dayIsOutsideMin(props, day) || dayIsOutsideMax(props, day);
|
|
535
648
|
}
|
|
536
|
-
function
|
|
537
|
-
const {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return false;
|
|
649
|
+
function checkDayPicker(props) {
|
|
650
|
+
const { day, maxDate, minDate } = props;
|
|
651
|
+
return minDate && dayIsOutsideMin(props, day)
|
|
652
|
+
? minDate.getDate()
|
|
653
|
+
: maxDate && dayIsOutsideMax(props, day)
|
|
654
|
+
? maxDate.getDate()
|
|
655
|
+
: undefined;
|
|
544
656
|
}
|
|
545
|
-
function
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
657
|
+
function createDayPicker(props) {
|
|
658
|
+
const date = new Date(props.year, props.month, 1);
|
|
659
|
+
const today = new Date();
|
|
660
|
+
const firstWeek = createFirstWeek$1(props, date, today);
|
|
661
|
+
const nextWeeks = createNextWeeks$1(props, date, today);
|
|
662
|
+
return [firstWeek, ...nextWeeks];
|
|
550
663
|
}
|
|
551
664
|
|
|
552
|
-
|
|
553
|
-
(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
PickerListenerType["Cancel"] = "PickerCancel";
|
|
557
|
-
})(PickerListenerType || (PickerListenerType = {}));
|
|
558
|
-
|
|
559
|
-
function createYear(props, value) {
|
|
560
|
-
const { date, year } = props;
|
|
561
|
-
return {
|
|
562
|
-
disabled: !value,
|
|
563
|
-
focused: value === year,
|
|
564
|
-
selected: value === date.getFullYear(),
|
|
565
|
-
value
|
|
566
|
-
};
|
|
665
|
+
function dateIsSelected(base, date, day) {
|
|
666
|
+
return (date.getFullYear() === base.getFullYear() &&
|
|
667
|
+
date.getMonth() === base.getMonth() &&
|
|
668
|
+
day === date.getDate());
|
|
567
669
|
}
|
|
568
|
-
function
|
|
569
|
-
|
|
570
|
-
return minDate ? year < minDate.getFullYear() : false;
|
|
670
|
+
function sourceIsSelected({ sourceDate }, base, day) {
|
|
671
|
+
return dateIsSelected(base, sourceDate, day);
|
|
571
672
|
}
|
|
572
|
-
function
|
|
573
|
-
|
|
574
|
-
|
|
673
|
+
function rangeIsSelected({ range }, base, day) {
|
|
674
|
+
return (dateIsSelected(base, range.minDate, day) ||
|
|
675
|
+
dateIsSelected(base, range.maxDate, day));
|
|
575
676
|
}
|
|
576
|
-
function
|
|
577
|
-
|
|
578
|
-
return minDate && yearIsOutlineMin(props)
|
|
579
|
-
? minDate.getFullYear()
|
|
580
|
-
: maxDate && yearIsOutlineMax(props)
|
|
581
|
-
? maxDate.getFullYear()
|
|
582
|
-
: undefined;
|
|
677
|
+
function dayIsRange({ range }, base, day) {
|
|
678
|
+
return helpersDate.dateIsBetween(range.minDate, range.maxDate, helpersDate.assignDayInDate(base, day));
|
|
583
679
|
}
|
|
584
|
-
function
|
|
585
|
-
const { year, maxDate, minDate } = props;
|
|
586
|
-
const prevYears = [];
|
|
587
|
-
const nextYears = [];
|
|
588
|
-
let minRange = year;
|
|
589
|
-
let maxRange = year;
|
|
590
|
-
const minYear = minDate?.getFullYear() || 0;
|
|
591
|
-
const maxYear = maxDate?.getFullYear() || 10000;
|
|
592
|
-
for (let index = 0; index < COUNT_YEAR_RANGE; index++) {
|
|
593
|
-
const prevValue = year - COUNT_YEAR_RANGE + index;
|
|
594
|
-
const nextValue = year + index + 1;
|
|
595
|
-
const prevYear = prevValue >= minYear ? prevValue : undefined;
|
|
596
|
-
const nextYear = nextValue <= maxYear ? nextValue : undefined;
|
|
597
|
-
const prevState = createYear(props, prevYear);
|
|
598
|
-
const nextState = createYear(props, nextYear);
|
|
599
|
-
prevYears.push(prevState);
|
|
600
|
-
nextYears.push(nextState);
|
|
601
|
-
if (!!prevState.value && minRange > prevState.value) {
|
|
602
|
-
minRange = prevState.value;
|
|
603
|
-
}
|
|
604
|
-
if (!!nextState.value && maxRange < nextState.value) {
|
|
605
|
-
maxRange = nextState.value;
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
const yearCenter = createYear(props, year);
|
|
609
|
-
return {
|
|
610
|
-
canPrevious: minYear < minRange,
|
|
611
|
-
canNext: maxYear > maxRange,
|
|
612
|
-
maxRange,
|
|
613
|
-
minRange,
|
|
614
|
-
years: [...prevYears, yearCenter, ...nextYears]
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
function createEmptyStore() {
|
|
680
|
+
function createDayRangeState(props, base, day) {
|
|
619
681
|
return {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
682
|
+
disabled: dayRangeIsOutside(props, day || 0),
|
|
683
|
+
end: day ? rangeIsSelected(props, base, day) : false,
|
|
684
|
+
forbidden: !day,
|
|
685
|
+
ranged: day ? dayIsRange(props, base, day) : false,
|
|
686
|
+
source: day ? sourceIsSelected(props, base, day) : false,
|
|
687
|
+
value: day
|
|
623
688
|
};
|
|
624
689
|
}
|
|
625
|
-
function
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
|
|
690
|
+
function createFirstWeek(props, base) {
|
|
691
|
+
const days = [];
|
|
692
|
+
let day = 1;
|
|
693
|
+
for (let start = 0; start < base.getDay(); start++) {
|
|
694
|
+
days.push(createDayRangeState(props, base));
|
|
629
695
|
}
|
|
630
|
-
let
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
search = helpersString.hasPattern(pattern || '', newStore.pattern, true);
|
|
634
|
-
if (!search) {
|
|
635
|
-
newStore = newStore.previous;
|
|
636
|
-
}
|
|
696
|
+
for (let end = base.getDay(); end < 7; end++) {
|
|
697
|
+
days.push(createDayRangeState(props, base, day));
|
|
698
|
+
day++;
|
|
637
699
|
}
|
|
638
|
-
return
|
|
700
|
+
return { days };
|
|
639
701
|
}
|
|
640
|
-
function
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
|
|
702
|
+
function createDaysPending(props, base, days) {
|
|
703
|
+
const daysPending = [];
|
|
704
|
+
const length = 7 - days;
|
|
705
|
+
for (let index = 0; index < length; index++) {
|
|
706
|
+
daysPending.push(createDayRangeState(props, base));
|
|
644
707
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
708
|
+
return daysPending;
|
|
709
|
+
}
|
|
710
|
+
function createNextWeeks(props, base) {
|
|
711
|
+
const weeks = [];
|
|
712
|
+
const { date } = props;
|
|
713
|
+
const dayCount = helpersDate.getDaysOfMonth(date.getFullYear(), date.getMonth());
|
|
714
|
+
let days = [];
|
|
715
|
+
let countDays = 1;
|
|
716
|
+
let day = DAYS_WEEK - base.getDay() + 1;
|
|
717
|
+
do {
|
|
718
|
+
days.push(createDayRangeState(props, date, day));
|
|
719
|
+
day++;
|
|
720
|
+
countDays++;
|
|
721
|
+
if (countDays > 7) {
|
|
722
|
+
weeks.push({ days });
|
|
723
|
+
days = [];
|
|
724
|
+
countDays = 1;
|
|
654
725
|
}
|
|
655
|
-
};
|
|
726
|
+
} while (day <= dayCount);
|
|
727
|
+
if (days.length && days.length < DAYS_WEEK) {
|
|
728
|
+
weeks.push({
|
|
729
|
+
days: [...days, ...createDaysPending(props, base, days.length)]
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
return weeks;
|
|
733
|
+
}
|
|
734
|
+
function dayRangeIsOutsideMin(props, day) {
|
|
735
|
+
const { date, minDate } = props;
|
|
736
|
+
return minDate
|
|
737
|
+
? helpersDate.getDateWeight(helpersDate.assignDayInDate(date, day)) < helpersDate.getDateWeight(minDate)
|
|
738
|
+
: false;
|
|
739
|
+
}
|
|
740
|
+
function dayRangeIsOutsideMax(props, day) {
|
|
741
|
+
const { date, maxDate } = props;
|
|
742
|
+
return maxDate
|
|
743
|
+
? helpersDate.getDateWeight(helpersDate.assignDayInDate(date, day)) > helpersDate.getDateWeight(maxDate)
|
|
744
|
+
: false;
|
|
745
|
+
}
|
|
746
|
+
function dayRangeIsOutside(props, day) {
|
|
747
|
+
return dayRangeIsOutsideMin(props, day) || dayRangeIsOutsideMax(props, day);
|
|
748
|
+
}
|
|
749
|
+
function createDayRangePicker(props) {
|
|
750
|
+
const date = new Date(props.date.getFullYear(), props.date.getMonth(), 1);
|
|
751
|
+
const firstWeek = createFirstWeek(props, date);
|
|
752
|
+
const nextWeeks = createNextWeeks(props, date);
|
|
753
|
+
return [firstWeek, ...nextWeeks];
|
|
656
754
|
}
|
|
657
755
|
|
|
658
|
-
|
|
659
|
-
const
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
756
|
+
function createMonthState(props, value) {
|
|
757
|
+
const { date, month, year } = props;
|
|
758
|
+
return {
|
|
759
|
+
disabled: monthIsOutside(props, value),
|
|
760
|
+
focused: value === month,
|
|
761
|
+
label: helpersDate.MONTH_NAMES()[value],
|
|
762
|
+
selected: date.getFullYear() === year && value === date.getMonth(),
|
|
763
|
+
value
|
|
764
|
+
};
|
|
667
765
|
}
|
|
668
|
-
function
|
|
669
|
-
const {
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
const elements = listElement?.querySelectorAll(classElement);
|
|
674
|
-
if (elements?.length) {
|
|
675
|
-
elements.item(0).focus();
|
|
676
|
-
setTimeout(() => {
|
|
677
|
-
listElement?.scroll({ top: 0, behavior: 'smooth' });
|
|
678
|
-
}, 100);
|
|
679
|
-
}
|
|
680
|
-
return POSITION_INITIAL;
|
|
766
|
+
function monthIsOutsideMin(props, month) {
|
|
767
|
+
const { year, minDate } = props;
|
|
768
|
+
return minDate
|
|
769
|
+
? minDate.getFullYear() === year && month < minDate.getMonth()
|
|
770
|
+
: false;
|
|
681
771
|
}
|
|
682
|
-
function
|
|
683
|
-
const {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
const elements = listElement?.querySelectorAll(classElement);
|
|
688
|
-
if (!elements?.length) {
|
|
689
|
-
return POSITION_INITIAL;
|
|
690
|
-
}
|
|
691
|
-
const position = elements.length - 1;
|
|
692
|
-
const element = elements.item(position);
|
|
693
|
-
element?.focus();
|
|
694
|
-
setTimeout(() => {
|
|
695
|
-
listElement?.scroll({
|
|
696
|
-
top: element?.offsetTop + element?.offsetLeft,
|
|
697
|
-
behavior: 'smooth'
|
|
698
|
-
});
|
|
699
|
-
}, 100);
|
|
700
|
-
return position;
|
|
772
|
+
function monthIsOutsideMax(props, month) {
|
|
773
|
+
const { year, maxDate } = props;
|
|
774
|
+
return maxDate
|
|
775
|
+
? maxDate.getFullYear() === year && month > maxDate.getMonth()
|
|
776
|
+
: false;
|
|
701
777
|
}
|
|
702
|
-
function
|
|
703
|
-
|
|
704
|
-
const elements = listElement?.querySelectorAll(classElement);
|
|
705
|
-
const newPosition = position + 1;
|
|
706
|
-
if (newPosition < (elements?.length || 0)) {
|
|
707
|
-
elements?.item(newPosition)?.focus();
|
|
708
|
-
return newPosition;
|
|
709
|
-
}
|
|
710
|
-
if (!locationListIsBottom(contentElement, listElement)) {
|
|
711
|
-
inputElement?.focus();
|
|
712
|
-
}
|
|
713
|
-
return position;
|
|
778
|
+
function monthIsOutside(props, month) {
|
|
779
|
+
return monthIsOutsideMin(props, month) || monthIsOutsideMax(props, month);
|
|
714
780
|
}
|
|
715
|
-
function
|
|
716
|
-
const {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
}
|
|
723
|
-
if (locationListIsBottom(contentElement, listElement)) {
|
|
724
|
-
inputElement?.focus();
|
|
725
|
-
}
|
|
726
|
-
return POSITION_INITIAL;
|
|
781
|
+
function checkMonthPicker(props) {
|
|
782
|
+
const { maxDate, minDate, month } = props;
|
|
783
|
+
return minDate && monthIsOutsideMin(props, month)
|
|
784
|
+
? minDate.getMonth()
|
|
785
|
+
: maxDate && monthIsOutsideMax(props, month)
|
|
786
|
+
? maxDate.getMonth()
|
|
787
|
+
: undefined;
|
|
727
788
|
}
|
|
728
|
-
function
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
789
|
+
function createMonthPicker(props) {
|
|
790
|
+
return [
|
|
791
|
+
createMonthState(props, helpersDate.Month.January),
|
|
792
|
+
createMonthState(props, helpersDate.Month.February),
|
|
793
|
+
createMonthState(props, helpersDate.Month.March),
|
|
794
|
+
createMonthState(props, helpersDate.Month.April),
|
|
795
|
+
createMonthState(props, helpersDate.Month.May),
|
|
796
|
+
createMonthState(props, helpersDate.Month.June),
|
|
797
|
+
createMonthState(props, helpersDate.Month.July),
|
|
798
|
+
createMonthState(props, helpersDate.Month.August),
|
|
799
|
+
createMonthState(props, helpersDate.Month.September),
|
|
800
|
+
createMonthState(props, helpersDate.Month.October),
|
|
801
|
+
createMonthState(props, helpersDate.Month.November),
|
|
802
|
+
createMonthState(props, helpersDate.Month.December)
|
|
803
|
+
];
|
|
737
804
|
}
|
|
738
|
-
function
|
|
739
|
-
const {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
return navigationElementUp(props);
|
|
745
|
-
default:
|
|
746
|
-
return POSITION_INITIAL;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
class ListCollection {
|
|
751
|
-
constructor(value) {
|
|
752
|
-
this.value = value;
|
|
805
|
+
function monthIsLimitMin(props) {
|
|
806
|
+
const { month, date, minDate } = props;
|
|
807
|
+
if (helpersAdvanced.itIsDefined(month) && date) {
|
|
808
|
+
const minYear = minDate ? minDate.getFullYear() : 0;
|
|
809
|
+
const minMonth = minDate ? minDate.getMonth() : 0;
|
|
810
|
+
return date.getFullYear() === minYear && month <= minMonth;
|
|
753
811
|
}
|
|
754
|
-
|
|
755
|
-
|
|
812
|
+
return false;
|
|
813
|
+
}
|
|
814
|
+
function monthIsLimitMax(props) {
|
|
815
|
+
const { month, date, maxDate } = props;
|
|
816
|
+
if (helpersAdvanced.itIsDefined(month) && date) {
|
|
817
|
+
const maxYear = maxDate ? maxDate.getFullYear() : 10000;
|
|
818
|
+
const maxMonth = maxDate ? maxDate.getMonth() : 11;
|
|
819
|
+
return date.getFullYear() === maxYear && month >= maxMonth;
|
|
756
820
|
}
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
823
|
+
function monthLimitTemplate(props) {
|
|
824
|
+
return {
|
|
825
|
+
limitNext: monthIsLimitMax(props),
|
|
826
|
+
limitPrevious: monthIsLimitMin(props)
|
|
827
|
+
};
|
|
757
828
|
}
|
|
758
829
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
const
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
: new helpersDate.DateRange(date, sourceDate.current);
|
|
824
|
-
sourceDate.current = date;
|
|
825
|
-
setRange(range);
|
|
826
|
-
formControl?.setState(range);
|
|
827
|
-
}
|
|
828
|
-
return (jsxRuntime.jsxs("div", { className: "rls-day-range-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-day-range-picker__title", children: helpersDate.dateFormatTemplate(sourceDate.current, DATE_RANGE_FORMAT) }), jsxRuntime.jsx("div", { className: "rls-day-range-picker__header", children: helpersDate.DAY_LABELS().map((title, index) => (jsxRuntime.jsx("label", { className: "rls-day-range-picker__label", children: title }, index))) }), jsxRuntime.jsx("div", { className: "rls-day-range-picker__component", children: weeks.map(({ days }, index) => (jsxRuntime.jsx("div", { className: "rls-day-range-picker__week", children: days.map(({ disabled, end, forbidden, source, ranged, value }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-day-range-picker__day', {
|
|
829
|
-
disabled: disabled || disabledPicker,
|
|
830
|
-
end,
|
|
831
|
-
forbidden,
|
|
832
|
-
ranged,
|
|
833
|
-
source
|
|
834
|
-
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-day-range-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
function RlsMoneyField({ children, decimals, disabled, formControl, placeholder, symbol, rlsTheme, value, onValue }) {
|
|
838
|
-
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', {
|
|
839
|
-
focused: formControl?.focused,
|
|
840
|
-
error: formControl?.wrong,
|
|
841
|
-
disabled: formControl?.disabled || disabled
|
|
842
|
-
}, 'rls-money-field'), "rls-theme": rlsTheme, children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsx("div", { className: "rls-box-field__body", children: jsxRuntime.jsx(RlsInputMoney, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, symbol: symbol, decimals: decimals, onValue: onValue }) }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }));
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
function RlsMonthPicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme, year }) {
|
|
846
|
-
const currentDate = date || new Date();
|
|
847
|
-
const [months, setMonths] = react.useState([]);
|
|
848
|
-
const [value, setValue] = react.useState(formControl?.state || currentDate.getMonth());
|
|
849
|
-
react.useEffect(() => {
|
|
850
|
-
const props = createPickerProps(); // MonthPickerProps
|
|
851
|
-
const month = checkMonthPicker(props);
|
|
852
|
-
month ? setMonthValue(month) : setMonths(createMonthPicker(props));
|
|
853
|
-
}, [date, year, value, minDate, maxDate]);
|
|
854
|
-
react.useEffect(() => {
|
|
855
|
-
const month = checkMonthPicker(createPickerProps());
|
|
856
|
-
helpersAdvanced.itIsDefined(month)
|
|
857
|
-
? formControl?.setState(month)
|
|
858
|
-
: setValue(formControl?.state || currentDate.getMonth());
|
|
859
|
-
}, [formControl?.state]);
|
|
860
|
-
function createPickerProps() {
|
|
861
|
-
return {
|
|
862
|
-
date: currentDate,
|
|
863
|
-
month: helpersAdvanced.itIsDefined(formControl?.state) ? formControl?.state : value,
|
|
864
|
-
year: year || currentDate.getFullYear(),
|
|
865
|
-
minDate,
|
|
866
|
-
maxDate
|
|
867
|
-
};
|
|
868
|
-
}
|
|
869
|
-
function setMonthValue(value) {
|
|
870
|
-
formControl ? formControl.setState(value) : setValue(value);
|
|
871
|
-
}
|
|
872
|
-
function onChange(value) {
|
|
873
|
-
setMonthValue(value);
|
|
874
|
-
if (onValue) {
|
|
875
|
-
onValue(value);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
return (jsxRuntime.jsx("div", { className: "rls-month-picker", "rls-theme": rlsTheme, children: months.map(({ label, value, disabled, focused, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-month-picker__component', {
|
|
879
|
-
disabled: disabled || disabledPicker,
|
|
880
|
-
focused,
|
|
881
|
-
selected
|
|
882
|
-
}), onClick: !(disabled || disabledPicker) ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-month-picker__span", children: label }) }, index))) }));
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
function RlsMonthTitlePicker({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
|
|
886
|
-
const { limitNext, limitPrevious } = monthLimitTemplate({
|
|
887
|
-
date,
|
|
888
|
-
maxDate,
|
|
889
|
-
minDate,
|
|
890
|
-
month: monthControl.state
|
|
891
|
-
});
|
|
892
|
-
const monthName = helpersDate.MONTH_NAMES()[monthControl.state || 0];
|
|
893
|
-
function onPreviousMonth() {
|
|
894
|
-
if (helpersAdvanced.itIsDefined(monthControl.state) && helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
895
|
-
if (monthControl.state > helpersDate.Month.January) {
|
|
896
|
-
monthControl.setState(monthControl.state - 1);
|
|
897
|
-
}
|
|
898
|
-
else {
|
|
899
|
-
monthControl.setState(helpersDate.Month.December);
|
|
900
|
-
yearControl.setState(yearControl.state - 1);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
function onPreviousYear() {
|
|
905
|
-
if (helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
906
|
-
yearControl.setState(yearControl.state - 1);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
function onPrevious() {
|
|
910
|
-
type === 'month' ? onPreviousMonth() : onPreviousYear();
|
|
911
|
-
}
|
|
912
|
-
function onNextMonth() {
|
|
913
|
-
if (helpersAdvanced.itIsDefined(monthControl.state) && helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
914
|
-
if (monthControl.state < helpersDate.Month.December) {
|
|
915
|
-
monthControl.setState(monthControl.state + 1);
|
|
916
|
-
}
|
|
917
|
-
else {
|
|
918
|
-
monthControl.setState(helpersDate.Month.January);
|
|
919
|
-
yearControl.setState(yearControl.state + 1);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
function onNextYear() {
|
|
924
|
-
if (helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
925
|
-
yearControl.setState(yearControl.state + 1);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
function onNext() {
|
|
929
|
-
type === 'month' ? onNextMonth() : onNextYear();
|
|
930
|
-
}
|
|
931
|
-
return (jsxRuntime.jsxs("div", { className: "rls-month-title-picker", children: [jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsxRuntime.jsx("span", { onClick: onClick, children: monthName }), jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
function RlsNumberField({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
|
|
935
|
-
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', {
|
|
936
|
-
focused: formControl?.focused,
|
|
937
|
-
error: formControl?.wrong,
|
|
938
|
-
disabled: formControl?.disabled || disabled
|
|
939
|
-
}, 'rls-number-field'), "rls-theme": rlsTheme, children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsx("div", { className: "rls-box-field__body", children: jsxRuntime.jsx(RlsInputNumber, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }));
|
|
830
|
+
var PickerListenerType;
|
|
831
|
+
(function (PickerListenerType) {
|
|
832
|
+
PickerListenerType["Select"] = "PickerSelect";
|
|
833
|
+
PickerListenerType["Now"] = "PickerNow";
|
|
834
|
+
PickerListenerType["Cancel"] = "PickerCancel";
|
|
835
|
+
})(PickerListenerType || (PickerListenerType = {}));
|
|
836
|
+
|
|
837
|
+
function createYear(props, value) {
|
|
838
|
+
const { date, year } = props;
|
|
839
|
+
return {
|
|
840
|
+
disabled: !value,
|
|
841
|
+
focused: value === year,
|
|
842
|
+
selected: value === date.getFullYear(),
|
|
843
|
+
value
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
function yearIsOutlineMin(props) {
|
|
847
|
+
const { year, minDate } = props;
|
|
848
|
+
return minDate ? year < minDate.getFullYear() : false;
|
|
849
|
+
}
|
|
850
|
+
function yearIsOutlineMax(props) {
|
|
851
|
+
const { year, maxDate } = props;
|
|
852
|
+
return maxDate ? year > maxDate.getFullYear() : false;
|
|
853
|
+
}
|
|
854
|
+
function checkYearPicker(props) {
|
|
855
|
+
const { maxDate, minDate } = props;
|
|
856
|
+
return minDate && yearIsOutlineMin(props)
|
|
857
|
+
? minDate.getFullYear()
|
|
858
|
+
: maxDate && yearIsOutlineMax(props)
|
|
859
|
+
? maxDate.getFullYear()
|
|
860
|
+
: undefined;
|
|
861
|
+
}
|
|
862
|
+
function createYearPicker(props) {
|
|
863
|
+
const { year, maxDate, minDate } = props;
|
|
864
|
+
const prevYears = [];
|
|
865
|
+
const nextYears = [];
|
|
866
|
+
let minRange = year;
|
|
867
|
+
let maxRange = year;
|
|
868
|
+
const minYear = minDate?.getFullYear() || 0;
|
|
869
|
+
const maxYear = maxDate?.getFullYear() || 10000;
|
|
870
|
+
for (let index = 0; index < COUNT_YEAR_RANGE; index++) {
|
|
871
|
+
const prevValue = year - COUNT_YEAR_RANGE + index;
|
|
872
|
+
const nextValue = year + index + 1;
|
|
873
|
+
const prevYear = prevValue >= minYear ? prevValue : undefined;
|
|
874
|
+
const nextYear = nextValue <= maxYear ? nextValue : undefined;
|
|
875
|
+
const prevState = createYear(props, prevYear);
|
|
876
|
+
const nextState = createYear(props, nextYear);
|
|
877
|
+
prevYears.push(prevState);
|
|
878
|
+
nextYears.push(nextState);
|
|
879
|
+
if (!!prevState.value && minRange > prevState.value) {
|
|
880
|
+
minRange = prevState.value;
|
|
881
|
+
}
|
|
882
|
+
if (!!nextState.value && maxRange < nextState.value) {
|
|
883
|
+
maxRange = nextState.value;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
const yearCenter = createYear(props, year);
|
|
887
|
+
return {
|
|
888
|
+
canPrevious: minYear < minRange,
|
|
889
|
+
canNext: maxYear > maxRange,
|
|
890
|
+
maxRange,
|
|
891
|
+
minRange,
|
|
892
|
+
years: [...prevYears, yearCenter, ...nextYears]
|
|
893
|
+
};
|
|
940
894
|
}
|
|
941
895
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
const
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
elements
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
for (let i = minIndexPage; i < maxPageVisible; i++) {
|
|
1100
|
-
const pagination = createPagination(i, index);
|
|
1101
|
-
paginations.push(pagination);
|
|
1102
|
-
pagination.prev = prevPagination;
|
|
1103
|
-
if (prevPagination) {
|
|
1104
|
-
prevPagination.next = pagination;
|
|
1105
|
-
}
|
|
1106
|
-
prevPagination = pagination;
|
|
1107
|
-
}
|
|
1108
|
-
setPaginations(paginations);
|
|
1109
|
-
}
|
|
1110
|
-
function clonePage(pagePartial) {
|
|
896
|
+
function createEmptyStore() {
|
|
897
|
+
return {
|
|
898
|
+
coincidences: undefined,
|
|
899
|
+
pattern: '',
|
|
900
|
+
previous: null
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
function searchForPattern(props) {
|
|
904
|
+
const { pattern, store } = props;
|
|
905
|
+
if (!store?.pattern) {
|
|
906
|
+
return null;
|
|
907
|
+
}
|
|
908
|
+
let newStore = store;
|
|
909
|
+
let search = false;
|
|
910
|
+
while (!search && newStore) {
|
|
911
|
+
search = helpersString.hasPattern(pattern || '', newStore.pattern, true);
|
|
912
|
+
if (!search) {
|
|
913
|
+
newStore = newStore.previous;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return newStore || createEmptyStore();
|
|
917
|
+
}
|
|
918
|
+
function createStoreAutocomplete(props) {
|
|
919
|
+
const { pattern, suggestions, reboot } = props;
|
|
920
|
+
if (!pattern) {
|
|
921
|
+
return { collection: suggestions, store: createEmptyStore() };
|
|
922
|
+
}
|
|
923
|
+
const store = reboot ? createEmptyStore() : searchForPattern(props);
|
|
924
|
+
const elements = store?.coincidences || suggestions;
|
|
925
|
+
const coincidences = elements.filter((element) => element.hasCoincidence(pattern));
|
|
926
|
+
return {
|
|
927
|
+
collection: coincidences,
|
|
928
|
+
store: {
|
|
929
|
+
coincidences,
|
|
930
|
+
pattern,
|
|
931
|
+
previous: store
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
const classElement = '.rls-list-field__element';
|
|
937
|
+
const POSITION_INITIAL = 0;
|
|
938
|
+
function locationListIsBottom(contentElement, listElement) {
|
|
939
|
+
if (contentElement && listElement) {
|
|
940
|
+
const { top, height } = contentElement.getBoundingClientRect();
|
|
941
|
+
const { clientHeight } = listElement;
|
|
942
|
+
return top + height + clientHeight < window.innerHeight;
|
|
943
|
+
}
|
|
944
|
+
return true;
|
|
945
|
+
}
|
|
946
|
+
function navigationInputDown(props) {
|
|
947
|
+
const { contentElement, listElement } = props;
|
|
948
|
+
if (!locationListIsBottom(contentElement, listElement)) {
|
|
949
|
+
return undefined;
|
|
950
|
+
}
|
|
951
|
+
const elements = listElement?.querySelectorAll(classElement);
|
|
952
|
+
if (elements?.length) {
|
|
953
|
+
elements.item(0).focus();
|
|
954
|
+
setTimeout(() => {
|
|
955
|
+
listElement?.scroll({ top: 0, behavior: 'smooth' });
|
|
956
|
+
}, 100);
|
|
957
|
+
}
|
|
958
|
+
return POSITION_INITIAL;
|
|
959
|
+
}
|
|
960
|
+
function navigationInputUp(props) {
|
|
961
|
+
const { contentElement, listElement } = props;
|
|
962
|
+
if (locationListIsBottom(contentElement, listElement)) {
|
|
963
|
+
return undefined;
|
|
964
|
+
}
|
|
965
|
+
const elements = listElement?.querySelectorAll(classElement);
|
|
966
|
+
if (!elements?.length) {
|
|
967
|
+
return POSITION_INITIAL;
|
|
968
|
+
}
|
|
969
|
+
const position = elements.length - 1;
|
|
970
|
+
const element = elements.item(position);
|
|
971
|
+
element?.focus();
|
|
972
|
+
setTimeout(() => {
|
|
973
|
+
listElement?.scroll({
|
|
974
|
+
top: element?.offsetTop + element?.offsetLeft,
|
|
975
|
+
behavior: 'smooth'
|
|
976
|
+
});
|
|
977
|
+
}, 100);
|
|
978
|
+
return position;
|
|
979
|
+
}
|
|
980
|
+
function navigationElementDown(props) {
|
|
981
|
+
const { contentElement, inputElement, listElement, position } = props;
|
|
982
|
+
const elements = listElement?.querySelectorAll(classElement);
|
|
983
|
+
const newPosition = position + 1;
|
|
984
|
+
if (newPosition < (elements?.length || 0)) {
|
|
985
|
+
elements?.item(newPosition)?.focus();
|
|
986
|
+
return newPosition;
|
|
987
|
+
}
|
|
988
|
+
if (!locationListIsBottom(contentElement, listElement)) {
|
|
989
|
+
inputElement?.focus();
|
|
990
|
+
}
|
|
991
|
+
return position;
|
|
992
|
+
}
|
|
993
|
+
function navigationElementUp(props) {
|
|
994
|
+
const { contentElement, inputElement, listElement, position } = props;
|
|
995
|
+
if (position > 0) {
|
|
996
|
+
const elements = listElement?.querySelectorAll(classElement);
|
|
997
|
+
const newPosition = position - 1;
|
|
998
|
+
elements?.item(newPosition)?.focus();
|
|
999
|
+
return newPosition;
|
|
1000
|
+
}
|
|
1001
|
+
if (locationListIsBottom(contentElement, listElement)) {
|
|
1002
|
+
inputElement?.focus();
|
|
1003
|
+
}
|
|
1004
|
+
return POSITION_INITIAL;
|
|
1005
|
+
}
|
|
1006
|
+
function listNavigationInput(props) {
|
|
1007
|
+
switch (props.event.code) {
|
|
1008
|
+
case 'ArrowDown':
|
|
1009
|
+
return navigationInputDown(props);
|
|
1010
|
+
case 'ArrowUp':
|
|
1011
|
+
return navigationInputUp(props);
|
|
1012
|
+
default:
|
|
1013
|
+
return undefined;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
function listNavigationElement(props) {
|
|
1017
|
+
const { event } = props;
|
|
1018
|
+
switch (event.code) {
|
|
1019
|
+
case 'ArrowDown':
|
|
1020
|
+
return navigationElementDown(props);
|
|
1021
|
+
case 'ArrowUp':
|
|
1022
|
+
return navigationElementUp(props);
|
|
1023
|
+
default:
|
|
1024
|
+
return POSITION_INITIAL;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
class ListCollection {
|
|
1029
|
+
constructor(value) {
|
|
1030
|
+
this.value = value;
|
|
1031
|
+
}
|
|
1032
|
+
find(element) {
|
|
1033
|
+
return this.value.find((current) => current.compareTo(element));
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, month, minDate, onValue, rlsTheme, year }) {
|
|
1038
|
+
const currentDate = date || new Date(); // Initial date
|
|
1039
|
+
const [weeks, setWeeks] = react.useState([]);
|
|
1040
|
+
const [value, setValue] = react.useState(formControl?.state || currentDate.getDate());
|
|
1041
|
+
react.useEffect(() => {
|
|
1042
|
+
const props = createPickerProps();
|
|
1043
|
+
const day = checkDayPicker(props);
|
|
1044
|
+
day ? setDayValue(day) : setWeeks(createDayPicker(props));
|
|
1045
|
+
}, [date, month, year, value, minDate, maxDate]);
|
|
1046
|
+
react.useEffect(() => {
|
|
1047
|
+
const day = checkDayPicker(createPickerProps());
|
|
1048
|
+
day
|
|
1049
|
+
? formControl?.setState(day)
|
|
1050
|
+
: setValue(formControl?.state || currentDate.getDate());
|
|
1051
|
+
}, [formControl?.state]);
|
|
1052
|
+
function createPickerProps() {
|
|
1111
1053
|
return {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1054
|
+
date: currentDate,
|
|
1055
|
+
day: formControl?.state || value,
|
|
1056
|
+
month: helpersAdvanced.itIsDefined(month) ? month : currentDate.getMonth(),
|
|
1057
|
+
year: year || currentDate.getFullYear(),
|
|
1058
|
+
minDate,
|
|
1059
|
+
maxDate
|
|
1116
1060
|
};
|
|
1117
1061
|
}
|
|
1118
|
-
function
|
|
1119
|
-
|
|
1120
|
-
}
|
|
1121
|
-
function refreshPage(elements, filter) {
|
|
1122
|
-
const collection = refreshCollection(elements, filter);
|
|
1123
|
-
const maxPage = refreshMaxPage(collection, count);
|
|
1124
|
-
const index = refreshIndex(collection, maxPage);
|
|
1125
|
-
return clonePage({ collection, index, maxPage });
|
|
1062
|
+
function setDayValue(value) {
|
|
1063
|
+
formControl ? formControl.setState(value) : setValue(value);
|
|
1126
1064
|
}
|
|
1127
|
-
function
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
value,
|
|
1132
|
-
active
|
|
1133
|
-
};
|
|
1134
|
-
if (active) {
|
|
1135
|
-
setCurrentPagination(pagination);
|
|
1065
|
+
function onChange(value) {
|
|
1066
|
+
setDayValue(value);
|
|
1067
|
+
if (onValue) {
|
|
1068
|
+
onValue(value);
|
|
1136
1069
|
}
|
|
1137
|
-
return pagination;
|
|
1138
|
-
}
|
|
1139
|
-
function rebootPagination() {
|
|
1140
|
-
setCollection([]);
|
|
1141
|
-
setMaxPage(0);
|
|
1142
|
-
setIndex(0);
|
|
1143
|
-
setPaginations([]);
|
|
1144
|
-
onChangeElements([]);
|
|
1145
1070
|
}
|
|
1146
|
-
return (jsxRuntime.jsxs("div", { className: "rls-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1071
|
+
return (jsxRuntime.jsxs("div", { className: "rls-picker-day", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-picker-day__header", children: helpersDate.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
|
+
disabled: disabled || disabledPicker,
|
|
1073
|
+
focused,
|
|
1074
|
+
forbidden,
|
|
1075
|
+
selected,
|
|
1076
|
+
today
|
|
1077
|
+
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-picker-day__element__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
1153
1078
|
}
|
|
1154
1079
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1080
|
+
const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
|
|
1081
|
+
|
|
1082
|
+
function RlsPickerDayRange({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
|
|
1083
|
+
const currentRange = formControl?.state || helpersDate.DateRange.now();
|
|
1084
|
+
const currentDate = helpersDate.normalizeMinTime(date || currentRange.minDate);
|
|
1085
|
+
const sourceDate = react.useRef(currentRange.minDate);
|
|
1086
|
+
const [weeks, setWeeks] = react.useState([]);
|
|
1087
|
+
const [range, setRange] = react.useState(currentRange);
|
|
1088
|
+
react.useEffect(() => {
|
|
1089
|
+
setWeeks(createDayRangePicker({
|
|
1090
|
+
date: currentDate,
|
|
1091
|
+
range,
|
|
1092
|
+
sourceDate: sourceDate.current,
|
|
1093
|
+
minDate,
|
|
1094
|
+
maxDate
|
|
1095
|
+
}));
|
|
1096
|
+
}, [range, date, minDate, maxDate]);
|
|
1097
|
+
function onChange(value) {
|
|
1098
|
+
const date = helpersDate.assignDayInDate(currentDate, value);
|
|
1099
|
+
const range = helpersDate.dateIsBefore(date, sourceDate.current)
|
|
1100
|
+
? new helpersDate.DateRange(sourceDate.current, date)
|
|
1101
|
+
: new helpersDate.DateRange(date, sourceDate.current);
|
|
1102
|
+
sourceDate.current = date;
|
|
1103
|
+
setRange(range);
|
|
1104
|
+
formControl?.setState(range);
|
|
1159
1105
|
}
|
|
1160
|
-
return (jsxRuntime.jsxs("div", { className: renderClassStatus('
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1106
|
+
return (jsxRuntime.jsxs("div", { className: "rls-picker-day-range", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-picker-day-range__title", children: helpersDate.dateFormatTemplate(sourceDate.current, DATE_RANGE_FORMAT) }), jsxRuntime.jsx("div", { className: "rls-picker-day-range__header", children: helpersDate.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
|
+
disabled: disabled || disabledPicker,
|
|
1108
|
+
end,
|
|
1109
|
+
forbidden,
|
|
1110
|
+
ranged,
|
|
1111
|
+
source
|
|
1112
|
+
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-picker-day-range__element__span", children: value || '??' }) }, index))) }, index))) })] }));
|
|
1165
1113
|
}
|
|
1166
1114
|
|
|
1167
|
-
function
|
|
1168
|
-
const
|
|
1115
|
+
function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme, year }) {
|
|
1116
|
+
const currentDate = date || new Date();
|
|
1117
|
+
const [months, setMonths] = react.useState([]);
|
|
1118
|
+
const [value, setValue] = react.useState(formControl?.state || currentDate.getMonth());
|
|
1169
1119
|
react.useEffect(() => {
|
|
1170
|
-
|
|
1120
|
+
const props = createPickerProps(); // MonthPickerProps
|
|
1121
|
+
const month = checkMonthPicker(props);
|
|
1122
|
+
month ? setMonthValue(month) : setMonths(createMonthPicker(props));
|
|
1123
|
+
}, [date, year, value, minDate, maxDate]);
|
|
1124
|
+
react.useEffect(() => {
|
|
1125
|
+
const month = checkMonthPicker(createPickerProps());
|
|
1126
|
+
helpersAdvanced.itIsDefined(month)
|
|
1127
|
+
? formControl?.setState(month)
|
|
1128
|
+
: setValue(formControl?.state || currentDate.getMonth());
|
|
1171
1129
|
}, [formControl?.state]);
|
|
1172
|
-
function
|
|
1173
|
-
|
|
1174
|
-
|
|
1130
|
+
function createPickerProps() {
|
|
1131
|
+
return {
|
|
1132
|
+
date: currentDate,
|
|
1133
|
+
month: helpersAdvanced.itIsDefined(formControl?.state) ? formControl?.state : value,
|
|
1134
|
+
year: year || currentDate.getFullYear(),
|
|
1135
|
+
minDate,
|
|
1136
|
+
maxDate
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
function setMonthValue(value) {
|
|
1140
|
+
formControl ? formControl.setState(value) : setValue(value);
|
|
1141
|
+
}
|
|
1142
|
+
function onChange(value) {
|
|
1143
|
+
setMonthValue(value);
|
|
1144
|
+
if (onValue) {
|
|
1145
|
+
onValue(value);
|
|
1175
1146
|
}
|
|
1176
1147
|
}
|
|
1177
|
-
return (jsxRuntime.
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1148
|
+
return (jsxRuntime.jsx("div", { className: "rls-picker-month", "rls-theme": rlsTheme, children: months.map(({ label, value, disabled, focused, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-picker-month__component', {
|
|
1149
|
+
disabled: disabled || disabledPicker,
|
|
1150
|
+
focused,
|
|
1151
|
+
selected
|
|
1152
|
+
}), onClick: !(disabled || disabledPicker) ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-picker-month__span", children: label }) }, index))) }));
|
|
1181
1153
|
}
|
|
1182
1154
|
|
|
1183
|
-
function
|
|
1184
|
-
const
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1155
|
+
function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
|
|
1156
|
+
const { limitNext, limitPrevious } = monthLimitTemplate({
|
|
1157
|
+
date,
|
|
1158
|
+
maxDate,
|
|
1159
|
+
minDate,
|
|
1160
|
+
month: monthControl.state
|
|
1161
|
+
});
|
|
1162
|
+
const monthName = helpersDate.MONTH_NAMES()[monthControl.state || 0];
|
|
1163
|
+
function onPreviousMonth() {
|
|
1164
|
+
if (helpersAdvanced.itIsDefined(monthControl.state) && helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
1165
|
+
if (monthControl.state > helpersDate.Month.January) {
|
|
1166
|
+
monthControl.setState(monthControl.state - 1);
|
|
1167
|
+
}
|
|
1168
|
+
else {
|
|
1169
|
+
monthControl.setState(helpersDate.Month.December);
|
|
1170
|
+
yearControl.setState(yearControl.state - 1);
|
|
1171
|
+
}
|
|
1191
1172
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1173
|
+
}
|
|
1174
|
+
function onPreviousYear() {
|
|
1175
|
+
if (helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
1176
|
+
yearControl.setState(yearControl.state - 1);
|
|
1194
1177
|
}
|
|
1195
1178
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
function
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1179
|
+
function onPrevious() {
|
|
1180
|
+
type === 'month' ? onPreviousMonth() : onPreviousYear();
|
|
1181
|
+
}
|
|
1182
|
+
function onNextMonth() {
|
|
1183
|
+
if (helpersAdvanced.itIsDefined(monthControl.state) && helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
1184
|
+
if (monthControl.state < helpersDate.Month.December) {
|
|
1185
|
+
monthControl.setState(monthControl.state + 1);
|
|
1186
|
+
}
|
|
1187
|
+
else {
|
|
1188
|
+
monthControl.setState(helpersDate.Month.January);
|
|
1189
|
+
yearControl.setState(yearControl.state + 1);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
function onNextYear() {
|
|
1194
|
+
if (helpersAdvanced.itIsDefined(yearControl.state)) {
|
|
1195
|
+
yearControl.setState(yearControl.state + 1);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
function onNext() {
|
|
1199
|
+
type === 'month' ? onNextMonth() : onNextYear();
|
|
1200
|
+
}
|
|
1201
|
+
return (jsxRuntime.jsxs("div", { className: "rls-picker-month-title", children: [jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsxRuntime.jsx("span", { onClick: onClick, children: monthName }), jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
|
|
1209
1202
|
}
|
|
1210
1203
|
|
|
1211
|
-
function
|
|
1204
|
+
function RlsPickerYear({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme }) {
|
|
1212
1205
|
const currentDate = date || new Date();
|
|
1213
1206
|
const [value, setValue] = react.useState(formControl?.state || currentDate.getFullYear());
|
|
1214
1207
|
const [year, setYear] = react.useState(formControl?.state || currentDate.getFullYear());
|
|
@@ -1250,11 +1243,19 @@ function RlsYearPicker({ date, disabled: disabledPicker, formControl, maxDate, m
|
|
|
1250
1243
|
onValue(value);
|
|
1251
1244
|
}
|
|
1252
1245
|
}
|
|
1253
|
-
return (jsxRuntime.jsxs("div", { className: "rls-year
|
|
1246
|
+
return (jsxRuntime.jsxs("div", { className: "rls-picker-year", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-picker-year__header", children: [jsxRuntime.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--prev", children: jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onClickPrev, disabled: !template.canPrevious || disabledPicker }) }), jsxRuntime.jsxs("label", { className: "rls-title-bold", children: [template.minRange, " - ", template.maxRange] }), jsxRuntime.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--next", children: jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onClickNext, disabled: !template.canNext || disabledPicker }) })] }), jsxRuntime.jsx("div", { className: "rls-picker-year__component", children: template.years.map(({ value, disabled, focused, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-picker-year__year', {
|
|
1254
1247
|
disabled: disabled || disabledPicker,
|
|
1255
1248
|
focused,
|
|
1256
1249
|
selected
|
|
1257
|
-
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-
|
|
1250
|
+
}), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-picker-year__year__span rls-body1-medium", children: value || '????' }) }, index))) })] }));
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
function RlsToolbar({ actions, children, subtitle }) {
|
|
1254
|
+
return (jsxRuntime.jsxs("div", { className: "rls-toolbar", children: [jsxRuntime.jsxs("div", { className: "rls-toolbar__description", children: [children && jsxRuntime.jsx("label", { className: "rls-toolbar__title", children: children }), subtitle && (jsxRuntime.jsx("label", { className: "rls-toolbar__subtitle smalltext-semibold", children: subtitle }))] }), actions && (jsxRuntime.jsx("div", { className: "rls-toolbar__actions", children: actions.map((action, index) => (jsxRuntime.jsx("div", { children: action }, index))) }))] }));
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
function RlsCard({ children, outline, rlsTheme }) {
|
|
1258
|
+
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-card', { outline }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-card__content", children: children }) }));
|
|
1258
1259
|
}
|
|
1259
1260
|
|
|
1260
1261
|
const reactI18n = i18n.i18n({
|
|
@@ -1278,6 +1279,87 @@ const reactI18n = i18n.i18n({
|
|
|
1278
1279
|
}
|
|
1279
1280
|
});
|
|
1280
1281
|
|
|
1282
|
+
class ConfirmationResult extends helpersAdvanced.PartialSealed {
|
|
1283
|
+
static approved() {
|
|
1284
|
+
return new ConfirmationResult('approved');
|
|
1285
|
+
}
|
|
1286
|
+
static reject() {
|
|
1287
|
+
return new ConfirmationResult('reject');
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
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 && (jsxRuntime.jsx("div", { className: "rls-confirmation__header__title", children: title })), subtitle && (jsxRuntime.jsx("div", { className: "rls-confirmation__header__subtitle", children: subtitle }))] }), jsxRuntime.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntime.jsx("div", { className: "rls-confirmation__body__content", children: content })) }), (approved || reject) && (jsxRuntime.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntime.jsxs("div", { className: "rls-confirmation__footer__actions", children: [approved && (jsxRuntime.jsx(RlsButton, { type: "raised", onClick: () => {
|
|
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" })] }));
|
|
1300
|
+
}
|
|
1301
|
+
function useConfirmationService() {
|
|
1302
|
+
const [config, setConfig] = react.useState({});
|
|
1303
|
+
const [visible, setVisible] = react.useState(false);
|
|
1304
|
+
const rlsConfirmation = ReactDOM.createPortal(jsxRuntime.jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
|
|
1305
|
+
function confirmation(config) {
|
|
1306
|
+
return new Promise((resolve) => {
|
|
1307
|
+
const { content, rlsTheme, subtitle, title, approved, reject } = config;
|
|
1308
|
+
setConfig({
|
|
1309
|
+
content,
|
|
1310
|
+
rlsTheme,
|
|
1311
|
+
subtitle,
|
|
1312
|
+
title,
|
|
1313
|
+
approved: {
|
|
1314
|
+
label: approved || reactI18n('confirmationActionApproved'),
|
|
1315
|
+
onClick: () => {
|
|
1316
|
+
setVisible(false);
|
|
1317
|
+
resolve(ConfirmationResult.approved());
|
|
1318
|
+
}
|
|
1319
|
+
},
|
|
1320
|
+
reject: reject
|
|
1321
|
+
? {
|
|
1322
|
+
label: reject,
|
|
1323
|
+
onClick: () => {
|
|
1324
|
+
setVisible(false);
|
|
1325
|
+
resolve(ConfirmationResult.reject());
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
: undefined
|
|
1329
|
+
});
|
|
1330
|
+
setVisible(true);
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
return {
|
|
1334
|
+
RlsConfirmation: rlsConfirmation,
|
|
1335
|
+
confirmation
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
function RlsDatatableHeader({ children }) {
|
|
1340
|
+
return jsxRuntime.jsx("tr", { className: "rls-datatable__header", children: children });
|
|
1341
|
+
}
|
|
1342
|
+
function RlsDatatableTitle({ children, className, control }) {
|
|
1343
|
+
return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__title', { control }, className).trim(), children: children }));
|
|
1344
|
+
}
|
|
1345
|
+
function RlsDatatableData({ children, className, error }) {
|
|
1346
|
+
return (jsxRuntime.jsx("tr", { className: renderClassStatus('rls-datatable__data', { error }, className).trim(), children: children }));
|
|
1347
|
+
}
|
|
1348
|
+
function RlsDatatableCell({ children, className, control, overflow }) {
|
|
1349
|
+
return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__cell', { control, overflow }, className).trim(), children: children }));
|
|
1350
|
+
}
|
|
1351
|
+
function RlsDatatableTotals({ children, className, error }) {
|
|
1352
|
+
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-datatable__totals', { error }, className).trim(), children: children }));
|
|
1353
|
+
}
|
|
1354
|
+
function RlsDatatableInfo({ children, className, control, overflow }) {
|
|
1355
|
+
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-datatable__info', { control, overflow }, className).trim(), children: children }));
|
|
1356
|
+
}
|
|
1357
|
+
function RlsDatatable({ children, datatable, footer, header, rlsTheme, summary }) {
|
|
1358
|
+
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-datatable', {
|
|
1359
|
+
scrolleable: datatable?.scrolleable
|
|
1360
|
+
}), "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("table", { children: [header && jsxRuntime.jsx("thead", { className: "rls-datatable__thead", children: header }), jsxRuntime.jsx("tbody", { ref: datatable?.bodyRef, className: "rls-datatable__tbody", children: children })] }), summary && jsxRuntime.jsx("div", { className: "rls-datatable__tsummary", children: summary }), footer && jsxRuntime.jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1281
1363
|
function useDatatable() {
|
|
1282
1364
|
const [scrolleable, setScrolleable] = react.useState(false);
|
|
1283
1365
|
const bodyRef = react.useRef(null);
|
|
@@ -1368,7 +1450,7 @@ function useListControl({ suggestions, formControl }) {
|
|
|
1368
1450
|
|
|
1369
1451
|
const DURATION_ANIMATION$1 = 240;
|
|
1370
1452
|
const MAX_ELEMENTS = 6;
|
|
1371
|
-
function
|
|
1453
|
+
function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, suggestions }) {
|
|
1372
1454
|
const [pattern, setPattern] = react.useState('');
|
|
1373
1455
|
const [coincidences, setCoincidences] = react.useState([]);
|
|
1374
1456
|
const currentStore = react.useRef({
|
|
@@ -1507,115 +1589,30 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
|
|
|
1507
1589
|
};
|
|
1508
1590
|
}
|
|
1509
1591
|
|
|
1510
|
-
function
|
|
1511
|
-
const { coincidences, listControl, pattern, onBlurInput, onClickAction, onClickBackdrop, onClickControl, onClickElement, onFocusInput, onKeydownElement, onKeydownInput, setPattern } =
|
|
1592
|
+
function RlsFieldAutocompleteTemplate({ suggestions, children, disabled, formControl, hiddenIcon, placeholder, searching, rlsTheme, onSearch, onSelect, onValue, render }) {
|
|
1593
|
+
const { coincidences, listControl, pattern, onBlurInput, onClickAction, onClickBackdrop, onClickControl, onClickElement, onFocusInput, onKeydownElement, onKeydownInput, setPattern } = useFieldAutocomplete({
|
|
1512
1594
|
suggestions,
|
|
1513
1595
|
disabled,
|
|
1514
1596
|
formControl,
|
|
1515
1597
|
onSelect,
|
|
1516
1598
|
onValue
|
|
1517
1599
|
});
|
|
1518
|
-
return (jsxRuntime.jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-box
|
|
1600
|
+
return (jsxRuntime.jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-field-box', {
|
|
1519
1601
|
disabled,
|
|
1520
1602
|
focused: listControl.focused,
|
|
1521
1603
|
selected: !!listControl.value
|
|
1522
|
-
}, 'rls-
|
|
1604
|
+
}, 'rls-field-list rls-field-autocomplete'), "rls-theme": rlsTheme, 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("label", { className: "rls-field-list__control", onClick: onClickControl, children: listControl.value ? (jsxRuntime.jsx("span", { className: "rls-field-list__control__description", children: listControl.value })) : (jsxRuntime.jsx("span", { className: "rls-field-list__control__placeholder", children: placeholder })) }), !hiddenIcon && listControl.value && (jsxRuntime.jsx("button", { className: "rls-field-list__action", disabled: disabled, onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: "trash-2" }) }))] }) }), jsxRuntime.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
1523
1605
|
visible: listControl.visible,
|
|
1524
1606
|
hide: !listControl.visible,
|
|
1525
1607
|
higher: listControl.higher
|
|
1526
|
-
}), children: [jsxRuntime.jsx("div", { className: "rls-
|
|
1608
|
+
}), children: [jsxRuntime.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntime.jsxs("ul", { ref: listControl.listRef, className: "rls-field-list__ul", children: [jsxRuntime.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntime.jsx("input", { ref: listControl.inputRef, className: "rls-field-list__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: pattern, onChange: ({ target: { value } }) => {
|
|
1527
1609
|
setPattern(value);
|
|
1528
1610
|
}, disabled: disabled || searching, onFocus: onFocusInput, onBlur: onBlurInput, onKeyDown: onKeydownInput }), onSearch && (jsxRuntime.jsx("button", { disabled: disabled || searching, onClick: () => {
|
|
1529
1611
|
onSearch(pattern);
|
|
1530
|
-
}, children: jsxRuntime.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntime.jsx(RlsProgressBar, { indeterminate: true }), coincidences.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-
|
|
1531
|
-
}
|
|
1532
|
-
function RlsAutocompleteField(props) {
|
|
1533
|
-
return (jsxRuntime.jsx(RlsAutocompleteFieldTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
function RlsCard({ children, outline, rlsTheme }) {
|
|
1537
|
-
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-card', { outline }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-card__content", children: children }) }));
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
class ConfirmationResult extends helpersAdvanced.PartialSealed {
|
|
1541
|
-
static approved() {
|
|
1542
|
-
return new ConfirmationResult('approved');
|
|
1543
|
-
}
|
|
1544
|
-
static reject() {
|
|
1545
|
-
return new ConfirmationResult('reject');
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
function RlsConfirmation({ approved, content, reject, rlsTheme, subtitle, title, visible }) {
|
|
1549
|
-
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__header__title", children: title })), subtitle && (jsxRuntime.jsx("div", { className: "rls-confirmation__header__subtitle", children: subtitle }))] }), jsxRuntime.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntime.jsx("div", { className: "rls-confirmation__body__content", children: content })) }), (approved || reject) && (jsxRuntime.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntime.jsxs("div", { className: "rls-confirmation__footer__actions", children: [approved && (jsxRuntime.jsx(RlsButton, { type: "raised", onClick: () => {
|
|
1550
|
-
if (approved.onClick) {
|
|
1551
|
-
approved.onClick();
|
|
1552
|
-
}
|
|
1553
|
-
}, children: approved.label })), reject && (jsxRuntime.jsx(RlsButton, { type: "outline", onClick: () => {
|
|
1554
|
-
if (reject.onClick) {
|
|
1555
|
-
reject.onClick();
|
|
1556
|
-
}
|
|
1557
|
-
}, children: reject.label }))] }) }))] }), jsxRuntime.jsx("div", { className: "rls-confirmation__backdrop" })] }));
|
|
1558
|
-
}
|
|
1559
|
-
function useConfirmationService() {
|
|
1560
|
-
const [config, setConfig] = react.useState({});
|
|
1561
|
-
const [visible, setVisible] = react.useState(false);
|
|
1562
|
-
const rlsConfirmation = ReactDOM.createPortal(jsxRuntime.jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
|
|
1563
|
-
function confirmation(config) {
|
|
1564
|
-
return new Promise((resolve) => {
|
|
1565
|
-
const { content, rlsTheme, subtitle, title, approved, reject } = config;
|
|
1566
|
-
setConfig({
|
|
1567
|
-
content,
|
|
1568
|
-
rlsTheme,
|
|
1569
|
-
subtitle,
|
|
1570
|
-
title,
|
|
1571
|
-
approved: {
|
|
1572
|
-
label: approved || reactI18n('confirmationActionApproved'),
|
|
1573
|
-
onClick: () => {
|
|
1574
|
-
setVisible(false);
|
|
1575
|
-
resolve(ConfirmationResult.approved());
|
|
1576
|
-
}
|
|
1577
|
-
},
|
|
1578
|
-
reject: reject
|
|
1579
|
-
? {
|
|
1580
|
-
label: reject,
|
|
1581
|
-
onClick: () => {
|
|
1582
|
-
setVisible(false);
|
|
1583
|
-
resolve(ConfirmationResult.reject());
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
: undefined
|
|
1587
|
-
});
|
|
1588
|
-
setVisible(true);
|
|
1589
|
-
});
|
|
1590
|
-
}
|
|
1591
|
-
return {
|
|
1592
|
-
RlsConfirmation: rlsConfirmation,
|
|
1593
|
-
confirmation
|
|
1594
|
-
};
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
function RlsDatatableHeader({ children }) {
|
|
1598
|
-
return jsxRuntime.jsx("tr", { className: "rls-datatable__header", children: children });
|
|
1599
|
-
}
|
|
1600
|
-
function RlsDatatableTitle({ children, className, control }) {
|
|
1601
|
-
return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__title', { control }, className).trim(), children: children }));
|
|
1612
|
+
}, children: jsxRuntime.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntime.jsx(RlsProgressBar, { indeterminate: true }), coincidences.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !coincidences.length && (jsxRuntime.jsx("li", { className: "rls-field-list__empty", children: jsxRuntime.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntime.jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntime.jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntime.jsx("div", { className: "rls-field-list__backdrop", onClick: onClickBackdrop })] })] }));
|
|
1602
1613
|
}
|
|
1603
|
-
function
|
|
1604
|
-
return (jsxRuntime.jsx(
|
|
1605
|
-
}
|
|
1606
|
-
function RlsDatatableCell({ children, className, control, overflow }) {
|
|
1607
|
-
return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__cell', { control, overflow }, className).trim(), children: children }));
|
|
1608
|
-
}
|
|
1609
|
-
function RlsDatatableTotals({ children, className, error }) {
|
|
1610
|
-
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-datatable__totals', { error }, className).trim(), children: children }));
|
|
1611
|
-
}
|
|
1612
|
-
function RlsDatatableInfo({ children, className, control, overflow }) {
|
|
1613
|
-
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-datatable__info', { control, overflow }, className).trim(), children: children }));
|
|
1614
|
-
}
|
|
1615
|
-
function RlsDatatable({ children, datatable, footer, header, rlsTheme, summary }) {
|
|
1616
|
-
return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-datatable', {
|
|
1617
|
-
scrolleable: datatable?.scrolleable
|
|
1618
|
-
}), "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("table", { children: [header && jsxRuntime.jsx("thead", { className: "rls-datatable__thead", children: header }), jsxRuntime.jsx("tbody", { ref: datatable?.bodyRef, className: "rls-datatable__tbody", children: children })] }), summary && jsxRuntime.jsx("div", { className: "rls-datatable__tsummary", children: summary }), footer && jsxRuntime.jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
|
|
1614
|
+
function RlsFieldAutocomplete(props) {
|
|
1615
|
+
return (jsxRuntime.jsx(RlsFieldAutocompleteTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
1619
1616
|
}
|
|
1620
1617
|
|
|
1621
1618
|
function rangeFormatTemplate({ maxDate, minDate }) {
|
|
@@ -1624,6 +1621,10 @@ function rangeFormatTemplate({ maxDate, minDate }) {
|
|
|
1624
1621
|
return `${minFormat} - ${maxFormat}`;
|
|
1625
1622
|
}
|
|
1626
1623
|
|
|
1624
|
+
function RlsModal({ children, visible, rlsTheme }) {
|
|
1625
|
+
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
|
+
}
|
|
1627
|
+
|
|
1627
1628
|
const controlIsValid = (props) => {
|
|
1628
1629
|
const { state, validators } = props;
|
|
1629
1630
|
return validators.reduce((errors, validator) => {
|
|
@@ -1721,7 +1722,7 @@ function useReactControl(controlProps, controlValidators) {
|
|
|
1721
1722
|
}
|
|
1722
1723
|
|
|
1723
1724
|
const FORMAT_DESCRIPTION = '{dw}, {mx} {dd} de {aa}';
|
|
1724
|
-
function
|
|
1725
|
+
function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
1725
1726
|
const today = new Date(); // Initial current date in component
|
|
1726
1727
|
const dateInitial = formControl?.state || date || today;
|
|
1727
1728
|
const yearControl = useReactControl(dateInitial.getFullYear());
|
|
@@ -1782,18 +1783,14 @@ function RlsDatePicker({ automatic, date, disabled, formControl, maxDate, minDat
|
|
|
1782
1783
|
onListener({ type: PickerListenerType.Select, value });
|
|
1783
1784
|
}
|
|
1784
1785
|
}
|
|
1785
|
-
return (jsxRuntime.jsxs("div", { className: "rls-date
|
|
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: helpersDate.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.value }) }), 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', {
|
|
1786
1787
|
day: visibility === 'DAY',
|
|
1787
1788
|
month: visibility === 'MONTH',
|
|
1788
1789
|
year: visibility === 'YEAR'
|
|
1789
|
-
}), children: [jsxRuntime.jsx(
|
|
1790
|
-
}
|
|
1791
|
-
|
|
1792
|
-
function RlsModal({ children, visible, rlsTheme }) {
|
|
1793
|
-
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);
|
|
1790
|
+
}), children: [jsxRuntime.jsx(RlsPickerDay, { formControl: dayControl, date: dateInitial, month: monthControl.state, year: yearControl.state, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsPickerMonth, { formControl: monthControl, date: dateInitial, year: yearControl.state, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntime.jsx(RlsPickerYear, { formControl: yearControl, date: dateInitial, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntime.jsx("div", { className: renderClassStatus('rls-picker-date__footer', { automatic }), children: jsxRuntime.jsxs("div", { className: "rls-picker-date__actions", children: [jsxRuntime.jsx("div", { className: "rls-picker-date__actions--cancel", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntime.jsx("div", { className: "rls-picker-date__actions--today", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onToday, disabled: dateOutRange({ date: today, maxDate, minDate }), children: reactI18n('dateActionToday') }) }), jsxRuntime.jsx("div", { className: "rls-picker-date__actions--ok", children: jsxRuntime.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
|
|
1794
1791
|
}
|
|
1795
1792
|
|
|
1796
|
-
function
|
|
1793
|
+
function RlsFieldDate({ children, date, disabled, formControl, maxDate, minDate, onValue, placeholder, rlsTheme }) {
|
|
1797
1794
|
const today = new Date(); // Initial current date in component
|
|
1798
1795
|
const [value, setValue] = react.useState();
|
|
1799
1796
|
const [modalIsVisible, setModalIsVisible] = react.useState(false);
|
|
@@ -1829,7 +1826,7 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
1829
1826
|
setModalIsVisible(true);
|
|
1830
1827
|
}
|
|
1831
1828
|
}
|
|
1832
|
-
return (jsxRuntime.jsxs("div", { className: "rls-date
|
|
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 ? helpersDate.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 }) => {
|
|
1833
1830
|
if (type !== PickerListenerType.Cancel) {
|
|
1834
1831
|
onChange(value, true);
|
|
1835
1832
|
}
|
|
@@ -1840,7 +1837,7 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
|
|
|
1840
1837
|
} }) })] }));
|
|
1841
1838
|
}
|
|
1842
1839
|
|
|
1843
|
-
function
|
|
1840
|
+
function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
|
|
1844
1841
|
const dateInitial = helpersDate.normalizeMinTime(datePicker || new Date());
|
|
1845
1842
|
const rangeInitial = formControl?.state || helpersDate.DateRange.now();
|
|
1846
1843
|
const yearControl = useReactControl(dateInitial.getFullYear());
|
|
@@ -1889,16 +1886,16 @@ function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl
|
|
|
1889
1886
|
onListener({ type: PickerListenerType.Select, value });
|
|
1890
1887
|
}
|
|
1891
1888
|
}
|
|
1892
|
-
return (jsxRuntime.jsxs("div", { className: "rls-date-range
|
|
1889
|
+
return (jsxRuntime.jsxs("div", { className: "rls-picker-date-range", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-picker-date-range__header", children: [jsxRuntime.jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--description", children: jsxRuntime.jsx("span", { onClick: onVisibilityDay, children: rangeFormatTemplate(value) }) }), jsxRuntime.jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--year", children: jsxRuntime.jsx("span", { onClick: onVisibilityYear, children: yearControl.state }) }), jsxRuntime.jsx(RlsPickerMonthTitle, { monthControl: monthControl, yearControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: visibility === 'MONTH' ? 'year' : 'month', onClick: onVisibilityMonth })] }), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-picker-date-range__component', {
|
|
1893
1890
|
day: visibility === 'DAY',
|
|
1894
1891
|
month: visibility === 'MONTH',
|
|
1895
1892
|
year: visibility === 'YEAR'
|
|
1896
|
-
}), children: [jsxRuntime.jsx(
|
|
1893
|
+
}), children: [jsxRuntime.jsx(RlsPickerDayRange, { formControl: dayControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsPickerMonth, { formControl: monthControl, year: yearControl.state, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntime.jsx(RlsPickerYear, { formControl: yearControl, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntime.jsx("div", { className: renderClassStatus('rls-picker-date-range__footer', {
|
|
1897
1894
|
automatic
|
|
1898
|
-
}), children: jsxRuntime.jsxs("div", { className: "rls-date-
|
|
1895
|
+
}), children: jsxRuntime.jsxs("div", { className: "rls-picker-date-range__actions", children: [jsxRuntime.jsx("div", { className: "rls-picker-date-range__actions--cancel", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntime.jsx("div", { className: "rls-picker-date-range__actions--ok", children: jsxRuntime.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
|
|
1899
1896
|
}
|
|
1900
1897
|
|
|
1901
|
-
function
|
|
1898
|
+
function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
|
|
1902
1899
|
const currentRange = formControl?.state || helpersDate.DateRange.now();
|
|
1903
1900
|
const currentDate = datePicker || new Date();
|
|
1904
1901
|
const [value, setValue] = react.useState(currentRange);
|
|
@@ -1915,7 +1912,7 @@ function RlsDateRangeField({ children, date: datePicker, disabled, formControl,
|
|
|
1915
1912
|
setModalIsVisible(true);
|
|
1916
1913
|
}
|
|
1917
1914
|
}
|
|
1918
|
-
return (jsxRuntime.jsxs("div", { className: "rls-date-
|
|
1915
|
+
return (jsxRuntime.jsxs("div", { className: "rls-field-date-range", "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-range__control", type: "text", value: value ? rangeFormatTemplate(value) : '', readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntime.jsx("button", { className: "rls-field-date-range__action", onClick: onClickAction, 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(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
|
|
1919
1916
|
if (value) {
|
|
1920
1917
|
setValue(value);
|
|
1921
1918
|
}
|
|
@@ -1923,11 +1920,7 @@ function RlsDateRangeField({ children, date: datePicker, disabled, formControl,
|
|
|
1923
1920
|
} }) })] }));
|
|
1924
1921
|
}
|
|
1925
1922
|
|
|
1926
|
-
function
|
|
1927
|
-
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
function useSelectField({ suggestions, formControl, onSelect, onValue }) {
|
|
1923
|
+
function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
|
|
1931
1924
|
const listControl = useListControl({ suggestions, formControl });
|
|
1932
1925
|
const { collection, inputRef, visible, navigationElement, navigationInput, setFocused, setValue, setVisible } = listControl;
|
|
1933
1926
|
const initializedState = react.useRef(false);
|
|
@@ -2038,24 +2031,28 @@ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
|
|
|
2038
2031
|
};
|
|
2039
2032
|
}
|
|
2040
2033
|
|
|
2041
|
-
function
|
|
2042
|
-
const { listControl, onBlurInput, onClickAction, onClickBackdrop, onClickElement, onClickInput, onFocusInput, onKeydownElement, onKeydownInput } =
|
|
2034
|
+
function RlsFieldSelectTemplate({ suggestions, children, disabled, formControl, placeholder, rlsTheme, onSelect, onValue, render }) {
|
|
2035
|
+
const { listControl, onBlurInput, onClickAction, onClickBackdrop, onClickElement, onClickInput, onFocusInput, onKeydownElement, onKeydownInput } = useFieldSelect({
|
|
2043
2036
|
suggestions,
|
|
2044
2037
|
disabled,
|
|
2045
2038
|
formControl,
|
|
2046
2039
|
onSelect,
|
|
2047
2040
|
onValue
|
|
2048
2041
|
});
|
|
2049
|
-
return (jsxRuntime.jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-box
|
|
2042
|
+
return (jsxRuntime.jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-field-box', { focused: listControl.focused, disabled }, 'rls-field-list rls-field-select'), "rls-theme": rlsTheme, 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", { ref: listControl.inputRef, className: "rls-field-list__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: listControl.value, onFocus: onFocusInput, onBlur: onBlurInput, onClick: onClickInput, onKeyDown: onKeydownInput }), jsxRuntime.jsx("button", { className: renderClassStatus('rls-field-list__action', {
|
|
2050
2043
|
visible: listControl.visible
|
|
2051
|
-
}), disabled: disabled, onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }),
|
|
2044
|
+
}), disabled: disabled, onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }), jsxRuntime.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
|
|
2052
2045
|
visible: listControl.visible,
|
|
2053
2046
|
hide: !listControl.visible,
|
|
2054
2047
|
higher: listControl.higher
|
|
2055
|
-
}), children: [jsxRuntime.jsx("div", { className: "rls-
|
|
2048
|
+
}), children: [jsxRuntime.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntime.jsxs("ul", { ref: listControl.listRef, className: "rls-field-list__ul", children: [suggestions.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !suggestions.length && (jsxRuntime.jsx("li", { className: "rls-field-list__empty", children: jsxRuntime.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntime.jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntime.jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntime.jsx("div", { className: "rls-field-list__backdrop", onClick: onClickBackdrop })] })] }));
|
|
2056
2049
|
}
|
|
2057
|
-
function
|
|
2058
|
-
return (jsxRuntime.jsx(
|
|
2050
|
+
function RlsFieldSelect(props) {
|
|
2051
|
+
return (jsxRuntime.jsx(RlsFieldSelectTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
function RlsFormNavigation({ children, visible, rlsTheme }) {
|
|
2055
|
+
return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
|
|
2059
2056
|
}
|
|
2060
2057
|
|
|
2061
2058
|
const DURATION_ANIMATION = 240;
|
|
@@ -2122,8 +2119,6 @@ function RlsApplication({ children }) {
|
|
|
2122
2119
|
exports.ConfirmationResult = ConfirmationResult;
|
|
2123
2120
|
exports.RlsAmount = RlsAmount;
|
|
2124
2121
|
exports.RlsApplication = RlsApplication;
|
|
2125
|
-
exports.RlsAutocompleteField = RlsAutocompleteField;
|
|
2126
|
-
exports.RlsAutocompleteFieldTemplate = RlsAutocompleteFieldTemplate;
|
|
2127
2122
|
exports.RlsAvatar = RlsAvatar;
|
|
2128
2123
|
exports.RlsBadge = RlsBadge;
|
|
2129
2124
|
exports.RlsBallot = RlsBallot;
|
|
@@ -2135,7 +2130,6 @@ exports.RlsButtonToggle = RlsButtonToggle;
|
|
|
2135
2130
|
exports.RlsCard = RlsCard;
|
|
2136
2131
|
exports.RlsCheckBox = RlsCheckBox;
|
|
2137
2132
|
exports.RlsCheckBoxControl = RlsCheckBoxControl;
|
|
2138
|
-
exports.RlsCheckBoxLabel = RlsCheckBoxLabel;
|
|
2139
2133
|
exports.RlsConfirmation = RlsConfirmation;
|
|
2140
2134
|
exports.RlsContext = RlsContext;
|
|
2141
2135
|
exports.RlsDatatable = RlsDatatable;
|
|
@@ -2145,12 +2139,16 @@ exports.RlsDatatableHeader = RlsDatatableHeader;
|
|
|
2145
2139
|
exports.RlsDatatableInfo = RlsDatatableInfo;
|
|
2146
2140
|
exports.RlsDatatableTitle = RlsDatatableTitle;
|
|
2147
2141
|
exports.RlsDatatableTotals = RlsDatatableTotals;
|
|
2148
|
-
exports.
|
|
2149
|
-
exports.
|
|
2150
|
-
exports.
|
|
2151
|
-
exports.
|
|
2152
|
-
exports.
|
|
2153
|
-
exports.
|
|
2142
|
+
exports.RlsFieldAutocomplete = RlsFieldAutocomplete;
|
|
2143
|
+
exports.RlsFieldAutocompleteTemplate = RlsFieldAutocompleteTemplate;
|
|
2144
|
+
exports.RlsFieldDate = RlsFieldDate;
|
|
2145
|
+
exports.RlsFieldDateRange = RlsFieldDateRange;
|
|
2146
|
+
exports.RlsFieldMoney = RlsFieldMoney;
|
|
2147
|
+
exports.RlsFieldNumber = RlsFieldNumber;
|
|
2148
|
+
exports.RlsFieldPassword = RlsFieldPassword;
|
|
2149
|
+
exports.RlsFieldSelect = RlsFieldSelect;
|
|
2150
|
+
exports.RlsFieldSelectTemplate = RlsFieldSelectTemplate;
|
|
2151
|
+
exports.RlsFieldText = RlsFieldText;
|
|
2154
2152
|
exports.RlsFormNavigation = RlsFormNavigation;
|
|
2155
2153
|
exports.RlsIcon = RlsIcon;
|
|
2156
2154
|
exports.RlsInput = RlsInput;
|
|
@@ -2159,32 +2157,32 @@ exports.RlsInputNumber = RlsInputNumber;
|
|
|
2159
2157
|
exports.RlsInputPassword = RlsInputPassword;
|
|
2160
2158
|
exports.RlsInputText = RlsInputText;
|
|
2161
2159
|
exports.RlsLabel = RlsLabel;
|
|
2160
|
+
exports.RlsLabelCheckBox = RlsLabelCheckBox;
|
|
2161
|
+
exports.RlsLabelRadioButton = RlsLabelRadioButton;
|
|
2162
|
+
exports.RlsLabelSwitch = RlsLabelSwitch;
|
|
2163
|
+
exports.RlsMessageFormError = RlsMessageFormError;
|
|
2162
2164
|
exports.RlsMessageIcon = RlsMessageIcon;
|
|
2163
2165
|
exports.RlsModal = RlsModal;
|
|
2164
|
-
exports.RlsMoneyField = RlsMoneyField;
|
|
2165
|
-
exports.RlsMonthPicker = RlsMonthPicker;
|
|
2166
|
-
exports.RlsMonthTitlePicker = RlsMonthTitlePicker;
|
|
2167
|
-
exports.RlsNumberField = RlsNumberField;
|
|
2168
2166
|
exports.RlsPagination = RlsPagination;
|
|
2169
|
-
exports.
|
|
2167
|
+
exports.RlsPickerDate = RlsPickerDate;
|
|
2168
|
+
exports.RlsPickerDateRange = RlsPickerDateRange;
|
|
2169
|
+
exports.RlsPickerDay = RlsPickerDay;
|
|
2170
|
+
exports.RlsPickerDayRange = RlsPickerDayRange;
|
|
2171
|
+
exports.RlsPickerMonth = RlsPickerMonth;
|
|
2172
|
+
exports.RlsPickerMonthTitle = RlsPickerMonthTitle;
|
|
2173
|
+
exports.RlsPickerYear = RlsPickerYear;
|
|
2170
2174
|
exports.RlsPoster = RlsPoster;
|
|
2171
2175
|
exports.RlsProgressBar = RlsProgressBar;
|
|
2172
2176
|
exports.RlsProgressCircular = RlsProgressCircular;
|
|
2173
2177
|
exports.RlsRadioButton = RlsRadioButton;
|
|
2174
|
-
exports.RlsRadioButtonLabel = RlsRadioButtonLabel;
|
|
2175
2178
|
exports.RlsSearchInput = RlsSearchInput;
|
|
2176
|
-
exports.RlsSelectField = RlsSelectField;
|
|
2177
|
-
exports.RlsSelectFieldTemplate = RlsSelectFieldTemplate;
|
|
2178
2179
|
exports.RlsSkeleton = RlsSkeleton;
|
|
2179
2180
|
exports.RlsSkeletonText = RlsSkeletonText;
|
|
2180
2181
|
exports.RlsSnackbar = RlsSnackbar;
|
|
2181
2182
|
exports.RlsSwitch = RlsSwitch;
|
|
2182
2183
|
exports.RlsSwitchControl = RlsSwitchControl;
|
|
2183
|
-
exports.RlsSwitchLabel = RlsSwitchLabel;
|
|
2184
2184
|
exports.RlsTabularText = RlsTabularText;
|
|
2185
|
-
exports.RlsTextField = RlsTextField;
|
|
2186
2185
|
exports.RlsToolbar = RlsToolbar;
|
|
2187
|
-
exports.RlsYearPicker = RlsYearPicker;
|
|
2188
2186
|
exports.rangeFormatTemplate = rangeFormatTemplate;
|
|
2189
2187
|
exports.renderClassStatus = renderClassStatus;
|
|
2190
2188
|
exports.useConfirmationService = useConfirmationService;
|