@rolster/react-components 18.13.4 → 18.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/cjs/assets/{index-LjAadYQE.css → index-L7r-Teuk.css} +413 -421
  2. package/dist/cjs/index.js +1089 -1059
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/es/assets/{index-LjAadYQE.css → index-L7r-Teuk.css} +413 -421
  5. package/dist/es/index.js +1070 -1040
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/esm/components/atoms/Input/Input.css +2 -2
  8. package/dist/esm/components/atoms/Input/Input.js +1 -8
  9. package/dist/esm/components/atoms/Input/Input.js.map +1 -1
  10. package/dist/esm/components/atoms/InputMoney/InputMoney.css +0 -2
  11. package/dist/esm/components/atoms/InputNumber/InputNumber.css +0 -2
  12. package/dist/esm/components/atoms/InputPassword/InputPassword.css +0 -2
  13. package/dist/esm/components/atoms/InputText/InputText.css +0 -2
  14. package/dist/esm/components/molecules/FieldMoney/FieldMoney.css +6 -0
  15. package/dist/esm/components/molecules/{MoneyField/MoneyField.d.ts → FieldMoney/FieldMoney.d.ts} +3 -3
  16. package/dist/esm/components/molecules/{MoneyField/MoneyField.js → FieldMoney/FieldMoney.js} +5 -5
  17. package/dist/esm/components/molecules/{MoneyField/MoneyField.js.map → FieldMoney/FieldMoney.js.map} +1 -1
  18. package/dist/esm/components/molecules/FieldNumber/FieldNumber.css +6 -0
  19. package/dist/esm/components/molecules/{NumberField/NumberField.d.ts → FieldNumber/FieldNumber.d.ts} +3 -3
  20. package/dist/esm/components/molecules/{NumberField/NumberField.js → FieldNumber/FieldNumber.js} +5 -5
  21. package/dist/esm/components/molecules/{NumberField/NumberField.js.map → FieldNumber/FieldNumber.js.map} +1 -1
  22. package/dist/esm/components/molecules/{PasswordField/PasswordField.css → FieldPassword/FieldPassword.css} +3 -3
  23. package/dist/esm/components/molecules/{PasswordField/PasswordField.d.ts → FieldPassword/FieldPassword.d.ts} +3 -3
  24. package/dist/esm/components/molecules/{PasswordField/PasswordField.js → FieldPassword/FieldPassword.js} +5 -5
  25. package/dist/esm/components/molecules/{PasswordField/PasswordField.js.map → FieldPassword/FieldPassword.js.map} +1 -1
  26. package/dist/esm/components/molecules/FieldText/FieldText.css +6 -0
  27. package/dist/esm/components/molecules/{TextField/TextField.d.ts → FieldText/FieldText.d.ts} +3 -3
  28. package/dist/esm/components/molecules/{TextField/TextField.js → FieldText/FieldText.js} +5 -5
  29. package/dist/esm/components/molecules/{TextField/TextField.js.map → FieldText/FieldText.js.map} +1 -1
  30. package/dist/esm/components/molecules/{CheckBoxLabel/CheckBoxLabel.css → LabelCheckBox/LabelCheckBox.css} +5 -5
  31. package/dist/esm/components/molecules/{CheckBoxLabel/CheckBoxLabel.d.ts → LabelCheckBox/LabelCheckBox.d.ts} +3 -3
  32. package/dist/esm/components/molecules/{CheckBoxLabel/CheckBoxLabel.js → LabelCheckBox/LabelCheckBox.js} +5 -5
  33. package/dist/esm/components/molecules/{CheckBoxLabel/CheckBoxLabel.js.map → LabelCheckBox/LabelCheckBox.js.map} +1 -1
  34. package/dist/esm/components/molecules/{RadioButtonLabel/RadioButtonLabel.css → LabelRadioButton/LabelRadioButton.css} +5 -5
  35. package/dist/esm/components/molecules/{RadioButtonLabel/RadioButtonLabel.d.ts → LabelRadioButton/LabelRadioButton.d.ts} +3 -3
  36. package/dist/esm/components/molecules/{RadioButtonLabel/RadioButtonLabel.js → LabelRadioButton/LabelRadioButton.js} +5 -5
  37. package/dist/esm/components/molecules/{RadioButtonLabel/RadioButtonLabel.js.map → LabelRadioButton/LabelRadioButton.js.map} +1 -1
  38. package/dist/esm/components/molecules/{SwitchLabel/SwitchLabel.css → LabelSwitch/LabelSwitch.css} +5 -5
  39. package/dist/esm/components/molecules/{SwitchLabel/SwitchLabel.d.ts → LabelSwitch/LabelSwitch.d.ts} +3 -3
  40. package/dist/esm/components/molecules/{SwitchLabel/SwitchLabel.js → LabelSwitch/LabelSwitch.js} +4 -4
  41. package/dist/esm/components/molecules/{SwitchLabel/SwitchLabel.js.map → LabelSwitch/LabelSwitch.js.map} +1 -1
  42. package/dist/esm/components/molecules/{DayPicker/DayPicker.css → PickerDay/PickerDay.css} +13 -13
  43. package/dist/esm/components/molecules/{DayPicker/DayPicker.d.ts → PickerDay/PickerDay.d.ts} +3 -3
  44. package/dist/esm/components/molecules/{DayPicker/DayPicker.js → PickerDay/PickerDay.js} +5 -5
  45. package/dist/esm/components/molecules/{DayPicker/DayPicker.js.map → PickerDay/PickerDay.js.map} +1 -1
  46. package/dist/esm/components/molecules/{DayRangePicker/DayRangePicker.css → PickerDayRange/PickerDayRange.css} +14 -14
  47. package/dist/esm/components/molecules/{DayRangePicker/DayRangePicker.d.ts → PickerDayRange/PickerDayRange.d.ts} +3 -3
  48. package/dist/esm/components/molecules/{DayRangePicker/DayRangePicker.js → PickerDayRange/PickerDayRange.js} +5 -5
  49. package/dist/esm/components/molecules/{DayRangePicker/DayRangePicker.js.map → PickerDayRange/PickerDayRange.js.map} +1 -1
  50. package/dist/esm/components/molecules/{MonthPicker/MonthPicker.css → PickerMonth/PickerMonth.css} +8 -8
  51. package/dist/esm/components/molecules/{MonthPicker/MonthPicker.d.ts → PickerMonth/PickerMonth.d.ts} +3 -3
  52. package/dist/esm/components/molecules/{MonthPicker/MonthPicker.js → PickerMonth/PickerMonth.js} +5 -5
  53. package/dist/esm/components/molecules/{MonthPicker/MonthPicker.js.map → PickerMonth/PickerMonth.js.map} +1 -1
  54. package/dist/esm/components/molecules/{MonthTitlePicker/MonthTitlePicker.css → PickerMonthTitle/PickerMonthTitle.css} +3 -3
  55. package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.d.ts +15 -0
  56. package/dist/esm/components/molecules/{MonthTitlePicker/MonthTitlePicker.js → PickerMonthTitle/PickerMonthTitle.js} +5 -5
  57. package/dist/esm/components/molecules/{MonthTitlePicker/MonthTitlePicker.js.map → PickerMonthTitle/PickerMonthTitle.js.map} +1 -1
  58. package/dist/esm/components/molecules/{YearPicker/YearPicker.css → PickerYear/PickerYear.css} +14 -14
  59. package/dist/esm/components/molecules/{YearPicker/YearPicker.d.ts → PickerYear/PickerYear.d.ts} +3 -3
  60. package/dist/esm/components/molecules/{YearPicker/YearPicker.js → PickerYear/PickerYear.js} +5 -5
  61. package/dist/esm/components/molecules/{YearPicker/YearPicker.js.map → PickerYear/PickerYear.js.map} +1 -1
  62. package/dist/esm/components/molecules/index.d.ts +12 -12
  63. package/dist/esm/components/molecules/index.js +12 -12
  64. package/dist/esm/components/molecules/index.js.map +1 -1
  65. package/dist/esm/components/organisms/{AutocompleteField/AutocompleteField.css → FieldAutocomplete/FieldAutocomplete.css} +15 -15
  66. package/dist/esm/components/organisms/{AutocompleteField/AutocompleteField.d.ts → FieldAutocomplete/FieldAutocomplete.d.ts} +5 -5
  67. package/dist/esm/components/organisms/{AutocompleteField/AutocompleteField.js → FieldAutocomplete/FieldAutocomplete.js} +11 -11
  68. package/dist/esm/components/organisms/{AutocompleteField/AutocompleteField.js.map → FieldAutocomplete/FieldAutocomplete.js.map} +1 -1
  69. package/dist/esm/components/organisms/{AutocompleteField/AutocompleteFieldHook.d.ts → FieldAutocomplete/FieldAutocompleteHook.d.ts} +3 -3
  70. package/dist/esm/components/organisms/{AutocompleteField/AutocompleteFieldHook.js → FieldAutocomplete/FieldAutocompleteHook.js} +43 -21
  71. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js.map +1 -0
  72. package/dist/esm/components/organisms/{DateField/DateField.css → FieldDate/FieldDate.css} +8 -8
  73. package/dist/esm/components/organisms/{DateField/DateField.d.ts → FieldDate/FieldDate.d.ts} +3 -3
  74. package/dist/esm/components/organisms/{DateField/DateField.js → FieldDate/FieldDate.js} +5 -5
  75. package/dist/esm/components/organisms/{DateField/DateField.js.map → FieldDate/FieldDate.js.map} +1 -1
  76. package/dist/esm/components/organisms/{DateRangeField/DateRangeField.css → FieldDateRange/FieldDateRange.css} +6 -6
  77. package/dist/esm/components/organisms/{DateRangeField/DateRangeField.d.ts → FieldDateRange/FieldDateRange.d.ts} +3 -3
  78. package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +33 -0
  79. package/dist/esm/components/organisms/{DateRangeField/DateRangeField.js.map → FieldDateRange/FieldDateRange.js.map} +1 -1
  80. package/dist/esm/components/organisms/FieldSelect/FieldSelect.css +10 -0
  81. package/dist/esm/components/organisms/{SelectField/SelectField.d.ts → FieldSelect/FieldSelect.d.ts} +5 -5
  82. package/dist/esm/components/organisms/{SelectField/SelectField.js → FieldSelect/FieldSelect.js} +10 -10
  83. package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -0
  84. package/dist/esm/components/organisms/{SelectField/SelectFieldHook.d.ts → FieldSelect/FieldSelectHook.d.ts} +3 -3
  85. package/dist/esm/components/organisms/{SelectField/SelectFieldHook.js → FieldSelect/FieldSelectHook.js} +30 -15
  86. package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js.map +1 -0
  87. package/dist/esm/components/organisms/{DatePicker/DatePicker.css → PickerDate/PickerDate.css} +17 -17
  88. package/dist/esm/components/organisms/{DatePicker/DatePicker.d.ts → PickerDate/PickerDate.d.ts} +3 -3
  89. package/dist/esm/components/organisms/{DatePicker/DatePicker.js → PickerDate/PickerDate.js} +6 -6
  90. package/dist/esm/components/organisms/{DatePicker/DatePicker.js.map → PickerDate/PickerDate.js.map} +1 -1
  91. package/dist/esm/components/organisms/{DateRangePicker/DateRangePicker.css → PickerDateRange/PickerDateRange.css} +16 -16
  92. package/dist/esm/components/organisms/{DateRangePicker/DateRangePicker.d.ts → PickerDateRange/PickerDateRange.d.ts} +3 -3
  93. package/dist/esm/components/organisms/{DateRangePicker/DateRangePicker.js → PickerDateRange/PickerDateRange.js} +7 -7
  94. package/dist/esm/components/organisms/{DateRangePicker/DateRangePicker.js.map → PickerDateRange/PickerDateRange.js.map} +1 -1
  95. package/dist/esm/components/organisms/index.d.ts +6 -6
  96. package/dist/esm/components/organisms/index.js +6 -6
  97. package/dist/esm/components/organisms/index.js.map +1 -1
  98. package/package.json +2 -2
  99. package/dist/esm/components/molecules/MoneyField/MoneyField.css +0 -6
  100. package/dist/esm/components/molecules/MonthTitlePicker/MonthTitlePicker.d.ts +0 -15
  101. package/dist/esm/components/molecules/NumberField/NumberField.css +0 -6
  102. package/dist/esm/components/molecules/TextField/TextField.css +0 -6
  103. package/dist/esm/components/organisms/AutocompleteField/AutocompleteFieldHook.js.map +0 -1
  104. package/dist/esm/components/organisms/DateRangeField/DateRangeField.js +0 -33
  105. package/dist/esm/components/organisms/SelectField/SelectField.css +0 -10
  106. package/dist/esm/components/organisms/SelectField/SelectField.js.map +0 -1
  107. 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 i18n = require('@rolster/i18n');
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
- switch (type) {
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,43 @@ 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 RlsCheckBoxLabel({ children, disabled, extended, formControl, rlsTheme }) {
252
+ function RlsFieldMoney({ children, decimals, disabled, formControl, placeholder, symbol, rlsTheme, value, onValue }) {
253
+ return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-box', {
254
+ focused: formControl?.focused,
255
+ error: formControl?.wrong,
256
+ disabled: formControl?.disabled || disabled
257
+ }, '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 }) }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-field-box__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }));
258
+ }
259
+
260
+ function RlsFieldNumber({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
261
+ return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-box', {
262
+ focused: formControl?.focused,
263
+ error: formControl?.wrong,
264
+ disabled: formControl?.disabled || disabled
265
+ }, '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 }) }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-field-box__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }));
266
+ }
267
+
268
+ function RlsFieldPassword({ children, disabled, formControl, placeholder, rlsTheme }) {
269
+ const [password, setPassword] = react.useState(true);
270
+ function onToggleInput() {
271
+ setPassword(!password);
272
+ }
273
+ return (jsxRuntime.jsxs("div", { className: renderClassStatus(' rls-field-box', {
274
+ focused: formControl?.focused,
275
+ error: formControl?.wrong,
276
+ disabled: formControl?.disabled || disabled
277
+ }, '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 })] }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-field-box__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }));
278
+ }
279
+
280
+ function RlsFieldText({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
281
+ return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-box', {
282
+ focused: formControl?.focused,
283
+ error: formControl?.wrong,
284
+ disabled: formControl?.disabled || disabled
285
+ }, '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 }) }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-field-box__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }));
286
+ }
287
+
288
+ function RlsLabelCheckBox({ children, disabled, extended, formControl, rlsTheme }) {
260
289
  const [checked, setChecked] = react.useState(formControl?.value || false);
261
290
  react.useEffect(() => {
262
291
  setChecked(formControl?.state || false);
@@ -269,217 +298,462 @@ function RlsCheckBoxLabel({ children, disabled, extended, formControl, rlsTheme
269
298
  setChecked(!checked);
270
299
  }
271
300
  }
272
- return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-checkbox-label', {
301
+ return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-label-checkbox', {
273
302
  disabled,
274
303
  extended
275
- }), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-checkbox-label__component", onClick: onToggle, children: jsxRuntime.jsx(RlsCheckBox, { checked: checked, disabled: disabled }) }), jsxRuntime.jsx("label", { className: "rls-checkbox-label__text", children: children })] }));
304
+ }), "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 })] }));
276
305
  }
277
306
 
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;
296
- }
297
-
298
- const DAYS_WEEK = 7;
299
- const COUNT_YEAR_RANGE = 4;
300
-
301
- function createDayState(props, today, value) {
302
- const { date, day, month, year } = props;
303
- const dateValue = value && new Date(year, month, value);
304
- return {
305
- disabled: dayIsOutside(props, value || 0),
306
- focused: !!value && day === value,
307
- forbidden: !value,
308
- selected: !!dateValue && helpersDate.dateIsEqualsWeight(date, dateValue),
309
- today: !!dateValue && helpersDate.dateIsEqualsWeight(today, dateValue),
310
- value
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];
307
+ function RlsLabelRadioButton({ children, disabled, extended, formControl, rlsTheme, value }) {
308
+ const [checked, setChecked] = react.useState(formControl?.state || false);
309
+ react.useEffect(() => {
310
+ setChecked(formControl?.state === value);
311
+ }, [formControl?.state]);
312
+ function onSelect() {
313
+ if (formControl) {
314
+ formControl?.setState(value);
315
+ }
316
+ }
317
+ return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-label-radiobutton', {
318
+ disabled,
319
+ extended
320
+ }), "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
321
  }
386
322
 
387
- function dateIsSelected(base, date, day) {
388
- return (date.getFullYear() === base.getFullYear() &&
389
- date.getMonth() === base.getMonth() &&
390
- day === date.getDate());
391
- }
392
- function sourceIsSelected({ sourceDate }, base, day) {
393
- return dateIsSelected(base, sourceDate, day);
394
- }
395
- function rangeIsSelected({ range }, base, day) {
396
- return (dateIsSelected(base, range.minDate, day) ||
397
- dateIsSelected(base, range.maxDate, day));
398
- }
399
- function dayIsRange({ range }, base, day) {
400
- return helpersDate.dateIsBetween(range.minDate, range.maxDate, helpersDate.assignDayInDate(base, day));
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];
323
+ function RlsLabelSwitch({ children, disabled, extended, formControl, rlsTheme }) {
324
+ const [checked, setChecked] = react.useState(formControl?.value || false);
325
+ react.useEffect(() => {
326
+ setChecked(formControl?.state || false);
327
+ }, [formControl?.state]);
328
+ function onToggle() {
329
+ if (formControl) {
330
+ formControl?.setState(!formControl.state);
331
+ }
332
+ else {
333
+ setChecked(!checked);
334
+ }
335
+ }
336
+ 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
337
  }
477
338
 
478
- function createMonthState(props, value) {
479
- const { date, month, year } = props;
480
- return {
481
- disabled: monthIsOutside(props, value),
482
- focused: value === month,
339
+ const DEFAULT_COUNT_ELEMENT = 20;
340
+ const MIN_NUMBER_PAGE = 1;
341
+ const FIRST_PAGE = 0;
342
+ const DEFAULT_MAX_VISIBLE = 4;
343
+ function RlsPagination({ elements, count: defaultCount, filter, onElements, onPagination }) {
344
+ const count = defaultCount || DEFAULT_COUNT_ELEMENT;
345
+ const [collection, setCollection] = react.useState([]);
346
+ const [index, setIndex] = react.useState(0);
347
+ const [maxPage, setMaxPage] = react.useState(calculateMaxPage(elements, count));
348
+ const [paginations, setPaginations] = react.useState([]);
349
+ const [currentPagination, setCurrentPagination] = react.useState();
350
+ const [description, setDescription] = react.useState('');
351
+ const [firstPage, setFirstPage] = react.useState(true);
352
+ const [lastPage, setLastPage] = react.useState(false);
353
+ react.useEffect(() => {
354
+ refreshFromElements(elements);
355
+ }, [elements]);
356
+ react.useEffect(() => {
357
+ const isFirstPage = currentPagination?.value === FIRST_PAGE;
358
+ const isLastPage = currentPagination?.value === maxPage - 1;
359
+ setFirstPage(isFirstPage);
360
+ setLastPage(isLastPage);
361
+ if (onPagination) {
362
+ onPagination({ firstPage: isFirstPage, lastPage: isLastPage });
363
+ }
364
+ }, [currentPagination]);
365
+ react.useEffect(() => {
366
+ refreshFromFilter(filter);
367
+ }, [filter]);
368
+ function onChangeElements(elements) {
369
+ if (onElements) {
370
+ onElements(elements);
371
+ }
372
+ }
373
+ function calculateMaxPage(collection, count) {
374
+ return collection.length ? Math.ceil(collection.length / count) : 0;
375
+ }
376
+ function onSelectPagination(pagination) {
377
+ const { value } = pagination;
378
+ pagination.active = true;
379
+ setIndex(value);
380
+ setCurrentPagination(pagination);
381
+ refreshFromChanged(clonePage({ index: value }));
382
+ }
383
+ function goPagination(pagination) {
384
+ if (currentPagination) {
385
+ currentPagination.active = false;
386
+ }
387
+ onSelectPagination(pagination);
388
+ }
389
+ function goPreviousPagination() {
390
+ if (currentPagination) {
391
+ const { prev, value } = currentPagination;
392
+ if (prev) {
393
+ onSelectPagination(prev);
394
+ currentPagination.active = false;
395
+ }
396
+ else {
397
+ const prevIndex = value - MIN_NUMBER_PAGE;
398
+ if (prevIndex >= FIRST_PAGE) {
399
+ refreshFromChanged(clonePageFromIndex(prevIndex));
400
+ }
401
+ }
402
+ }
403
+ }
404
+ function goFirstPagination() {
405
+ if (collection.length) {
406
+ refreshFromChanged(clonePageFromIndex(FIRST_PAGE));
407
+ }
408
+ }
409
+ function goNextPagination() {
410
+ if (currentPagination) {
411
+ const { next, value } = currentPagination;
412
+ if (next) {
413
+ onSelectPagination(next);
414
+ currentPagination.active = false;
415
+ }
416
+ else {
417
+ const nextIndex = value + 1;
418
+ if (nextIndex <= maxPage) {
419
+ refreshFromChanged(clonePageFromIndex(nextIndex));
420
+ }
421
+ }
422
+ }
423
+ }
424
+ function goLastPagination() {
425
+ if (collection.length) {
426
+ refreshFromChanged(clonePageFromIndex(maxPage - MIN_NUMBER_PAGE));
427
+ }
428
+ }
429
+ function createPageCollection(props) {
430
+ const { collection, count, index } = props;
431
+ if (collection.length) {
432
+ const finish = (index + MIN_NUMBER_PAGE) * count;
433
+ const start = index * count;
434
+ return collection.slice(start, finish);
435
+ }
436
+ return [];
437
+ }
438
+ function refreshFromElements(elements) {
439
+ elements.length
440
+ ? refreshFromChanged(refreshPage(elements, filter))
441
+ : rebootPagination();
442
+ }
443
+ function refreshFromFilter(filter) {
444
+ refreshFromChanged(refreshPage(elements, filter));
445
+ }
446
+ function refreshFromChanged(page) {
447
+ refreshPaginations(page);
448
+ refreshDescription(page);
449
+ onChangeElements(createPageCollection(page));
450
+ }
451
+ function refreshCollection(elements, filter) {
452
+ const collection = filter
453
+ ? elements.filter((element) => helpersString.hasPattern(JSON.stringify(element), filter))
454
+ : elements;
455
+ setCollection(collection);
456
+ return collection;
457
+ }
458
+ function refreshMaxPage(collection, count) {
459
+ const maxPage = calculateMaxPage(collection, count);
460
+ setMaxPage(maxPage);
461
+ return maxPage;
462
+ }
463
+ function refreshIndex(collection, currentMaxPage) {
464
+ const maxPage = currentMaxPage || refreshMaxPage(collection, count);
465
+ if (index < maxPage || index === FIRST_PAGE) {
466
+ return index;
467
+ }
468
+ const newIndex = maxPage - 1;
469
+ setIndex(newIndex);
470
+ return newIndex;
471
+ }
472
+ function refreshDescription(page) {
473
+ const { collection, count, index } = page;
474
+ const totalCount = elements.length;
475
+ const start = index * count + MIN_NUMBER_PAGE;
476
+ let end = (index + MIN_NUMBER_PAGE) * count;
477
+ if (end > collection.length) {
478
+ end = collection.length;
479
+ }
480
+ setDescription(`${start} - ${end} de ${totalCount}`);
481
+ }
482
+ function refreshPaginations({ index, maxPage }) {
483
+ let maxPageVisible = index + DEFAULT_MAX_VISIBLE;
484
+ if (maxPageVisible > maxPage) {
485
+ maxPageVisible = maxPage;
486
+ }
487
+ let minIndexPage = maxPageVisible - DEFAULT_MAX_VISIBLE;
488
+ if (minIndexPage < 0) {
489
+ minIndexPage = 0;
490
+ }
491
+ if (minIndexPage > index) {
492
+ minIndexPage = index;
493
+ }
494
+ let prevPagination = undefined;
495
+ const paginations = [];
496
+ for (let i = minIndexPage; i < maxPageVisible; i++) {
497
+ const pagination = createPagination(i, index);
498
+ paginations.push(pagination);
499
+ pagination.prev = prevPagination;
500
+ if (prevPagination) {
501
+ prevPagination.next = pagination;
502
+ }
503
+ prevPagination = pagination;
504
+ }
505
+ setPaginations(paginations);
506
+ }
507
+ function clonePage(pagePartial) {
508
+ return {
509
+ collection: pagePartial.collection || collection,
510
+ index: typeof pagePartial.index === 'number' ? pagePartial.index : index,
511
+ count: pagePartial.count || count,
512
+ maxPage: typeof pagePartial.maxPage === 'number' ? pagePartial.maxPage : maxPage
513
+ };
514
+ }
515
+ function clonePageFromIndex(index) {
516
+ return clonePage({ index });
517
+ }
518
+ function refreshPage(elements, filter) {
519
+ const collection = refreshCollection(elements, filter);
520
+ const maxPage = refreshMaxPage(collection, count);
521
+ const index = refreshIndex(collection, maxPage);
522
+ return clonePage({ collection, index, maxPage });
523
+ }
524
+ function createPagination(value, index) {
525
+ const active = value === index;
526
+ const pagination = {
527
+ label: (value + 1).toString(),
528
+ value,
529
+ active
530
+ };
531
+ if (active) {
532
+ setCurrentPagination(pagination);
533
+ }
534
+ return pagination;
535
+ }
536
+ function rebootPagination() {
537
+ setCollection([]);
538
+ setMaxPage(0);
539
+ setIndex(0);
540
+ setPaginations([]);
541
+ onChangeElements([]);
542
+ }
543
+ 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) => {
544
+ return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-pagination__page', {
545
+ active: page.active
546
+ }), onClick: () => {
547
+ goPagination(page);
548
+ }, children: page.label }, index));
549
+ }) }), 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" }) })] })] }));
550
+ }
551
+
552
+ function dateIsOutRangeMin(props) {
553
+ const { date, minDate } = props;
554
+ return !!minDate && helpersDate.dateIsBefore(helpersDate.normalizeMinTime(minDate), date);
555
+ }
556
+ function dateIsOutRangeMax(props) {
557
+ const { date, maxDate } = props;
558
+ return !!maxDate && helpersDate.dateIsAfter(helpersDate.normalizeMaxTime(maxDate), date);
559
+ }
560
+ function dateOutRange(props) {
561
+ return dateIsOutRangeMin(props) || dateIsOutRangeMax(props);
562
+ }
563
+ function checkDateRange(props) {
564
+ const { date, maxDate, minDate } = props;
565
+ return minDate && dateIsOutRangeMax(props)
566
+ ? minDate
567
+ : maxDate && dateIsOutRangeMax(props)
568
+ ? maxDate
569
+ : date;
570
+ }
571
+
572
+ const DAYS_WEEK = 7;
573
+ const COUNT_YEAR_RANGE = 4;
574
+
575
+ function createDayState(props, today, value) {
576
+ const { date, day, month, year } = props;
577
+ const dateValue = value && new Date(year, month, value);
578
+ return {
579
+ disabled: dayIsOutside(props, value || 0),
580
+ focused: !!value && day === value,
581
+ forbidden: !value,
582
+ selected: !!dateValue && helpersDate.dateIsEqualsWeight(date, dateValue),
583
+ today: !!dateValue && helpersDate.dateIsEqualsWeight(today, dateValue),
584
+ value
585
+ };
586
+ }
587
+ function createFirstWeek$1(props, date, today) {
588
+ const days = [];
589
+ let day = 1;
590
+ for (let start = 0; start < date.getDay(); start++) {
591
+ days.push(createDayState(props, today));
592
+ }
593
+ for (let end = date.getDay(); end < 7; end++) {
594
+ days.push(createDayState(props, today, day));
595
+ day++;
596
+ }
597
+ return { days };
598
+ }
599
+ function createDaysPending$1(props, today, days) {
600
+ const daysPending = [];
601
+ const length = 7 - days;
602
+ for (let index = 0; index < length; index++) {
603
+ daysPending.push(createDayState(props, today));
604
+ }
605
+ return daysPending;
606
+ }
607
+ function createNextWeeks$1(props, date, today) {
608
+ const daysMonth = helpersDate.getDaysOfMonth(date.getFullYear(), date.getMonth());
609
+ const weeks = [];
610
+ let days = [];
611
+ let countDays = 1;
612
+ let day = DAYS_WEEK - date.getDay() + 1;
613
+ do {
614
+ days.push(createDayState(props, today, day));
615
+ day++;
616
+ countDays++;
617
+ if (countDays > DAYS_WEEK) {
618
+ weeks.push({ days });
619
+ days = [];
620
+ countDays = 1;
621
+ }
622
+ } while (day <= daysMonth);
623
+ if (days.length && days.length < DAYS_WEEK) {
624
+ weeks.push({
625
+ days: [...days, ...createDaysPending$1(props, today, days.length)]
626
+ });
627
+ }
628
+ return weeks;
629
+ }
630
+ function dayIsOutsideMin(props, day) {
631
+ const { month, year, minDate } = props;
632
+ return minDate
633
+ ? helpersDate.getDateWeight(new Date(year, month, day)) < helpersDate.getDateWeight(minDate)
634
+ : false;
635
+ }
636
+ function dayIsOutsideMax(props, day) {
637
+ const { month, year, maxDate } = props;
638
+ return maxDate
639
+ ? helpersDate.getDateWeight(new Date(year, month, day)) > helpersDate.getDateWeight(maxDate)
640
+ : false;
641
+ }
642
+ function dayIsOutside(props, day) {
643
+ return dayIsOutsideMin(props, day) || dayIsOutsideMax(props, day);
644
+ }
645
+ function checkDayPicker(props) {
646
+ const { day, maxDate, minDate } = props;
647
+ return minDate && dayIsOutsideMin(props, day)
648
+ ? minDate.getDate()
649
+ : maxDate && dayIsOutsideMax(props, day)
650
+ ? maxDate.getDate()
651
+ : undefined;
652
+ }
653
+ function createDayPicker(props) {
654
+ const date = new Date(props.year, props.month, 1);
655
+ const today = new Date();
656
+ const firstWeek = createFirstWeek$1(props, date, today);
657
+ const nextWeeks = createNextWeeks$1(props, date, today);
658
+ return [firstWeek, ...nextWeeks];
659
+ }
660
+
661
+ function dateIsSelected(base, date, day) {
662
+ return (date.getFullYear() === base.getFullYear() &&
663
+ date.getMonth() === base.getMonth() &&
664
+ day === date.getDate());
665
+ }
666
+ function sourceIsSelected({ sourceDate }, base, day) {
667
+ return dateIsSelected(base, sourceDate, day);
668
+ }
669
+ function rangeIsSelected({ range }, base, day) {
670
+ return (dateIsSelected(base, range.minDate, day) ||
671
+ dateIsSelected(base, range.maxDate, day));
672
+ }
673
+ function dayIsRange({ range }, base, day) {
674
+ return helpersDate.dateIsBetween(range.minDate, range.maxDate, helpersDate.assignDayInDate(base, day));
675
+ }
676
+ function createDayRangeState(props, base, day) {
677
+ return {
678
+ disabled: dayRangeIsOutside(props, day || 0),
679
+ end: day ? rangeIsSelected(props, base, day) : false,
680
+ forbidden: !day,
681
+ ranged: day ? dayIsRange(props, base, day) : false,
682
+ source: day ? sourceIsSelected(props, base, day) : false,
683
+ value: day
684
+ };
685
+ }
686
+ function createFirstWeek(props, base) {
687
+ const days = [];
688
+ let day = 1;
689
+ for (let start = 0; start < base.getDay(); start++) {
690
+ days.push(createDayRangeState(props, base));
691
+ }
692
+ for (let end = base.getDay(); end < 7; end++) {
693
+ days.push(createDayRangeState(props, base, day));
694
+ day++;
695
+ }
696
+ return { days };
697
+ }
698
+ function createDaysPending(props, base, days) {
699
+ const daysPending = [];
700
+ const length = 7 - days;
701
+ for (let index = 0; index < length; index++) {
702
+ daysPending.push(createDayRangeState(props, base));
703
+ }
704
+ return daysPending;
705
+ }
706
+ function createNextWeeks(props, base) {
707
+ const weeks = [];
708
+ const { date } = props;
709
+ const dayCount = helpersDate.getDaysOfMonth(date.getFullYear(), date.getMonth());
710
+ let days = [];
711
+ let countDays = 1;
712
+ let day = DAYS_WEEK - base.getDay() + 1;
713
+ do {
714
+ days.push(createDayRangeState(props, date, day));
715
+ day++;
716
+ countDays++;
717
+ if (countDays > 7) {
718
+ weeks.push({ days });
719
+ days = [];
720
+ countDays = 1;
721
+ }
722
+ } while (day <= dayCount);
723
+ if (days.length && days.length < DAYS_WEEK) {
724
+ weeks.push({
725
+ days: [...days, ...createDaysPending(props, base, days.length)]
726
+ });
727
+ }
728
+ return weeks;
729
+ }
730
+ function dayRangeIsOutsideMin(props, day) {
731
+ const { date, minDate } = props;
732
+ return minDate
733
+ ? helpersDate.getDateWeight(helpersDate.assignDayInDate(date, day)) < helpersDate.getDateWeight(minDate)
734
+ : false;
735
+ }
736
+ function dayRangeIsOutsideMax(props, day) {
737
+ const { date, maxDate } = props;
738
+ return maxDate
739
+ ? helpersDate.getDateWeight(helpersDate.assignDayInDate(date, day)) > helpersDate.getDateWeight(maxDate)
740
+ : false;
741
+ }
742
+ function dayRangeIsOutside(props, day) {
743
+ return dayRangeIsOutsideMin(props, day) || dayRangeIsOutsideMax(props, day);
744
+ }
745
+ function createDayRangePicker(props) {
746
+ const date = new Date(props.date.getFullYear(), props.date.getMonth(), 1);
747
+ const firstWeek = createFirstWeek(props, date);
748
+ const nextWeeks = createNextWeeks(props, date);
749
+ return [firstWeek, ...nextWeeks];
750
+ }
751
+
752
+ function createMonthState(props, value) {
753
+ const { date, month, year } = props;
754
+ return {
755
+ disabled: monthIsOutside(props, value),
756
+ focused: value === month,
483
757
  label: helpersDate.MONTH_NAMES()[value],
484
758
  selected: date.getFullYear() === year && value === date.getMonth(),
485
759
  value
@@ -503,712 +777,427 @@ function monthIsOutside(props, month) {
503
777
  function checkMonthPicker(props) {
504
778
  const { maxDate, minDate, month } = props;
505
779
  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;
535
- }
536
- function monthIsLimitMax(props) {
537
- const { month, date, maxDate } = props;
538
- if (helpersAdvanced.itIsDefined(month) && date) {
539
- const maxYear = maxDate ? maxDate.getFullYear() : 10000;
540
- const maxMonth = maxDate ? maxDate.getMonth() : 11;
541
- return date.getFullYear() === maxYear && month >= maxMonth;
542
- }
543
- return false;
544
- }
545
- function monthLimitTemplate(props) {
546
- return {
547
- limitNext: monthIsLimitMax(props),
548
- limitPrevious: monthIsLimitMin(props)
549
- };
550
- }
551
-
552
- var PickerListenerType;
553
- (function (PickerListenerType) {
554
- PickerListenerType["Select"] = "PickerSelect";
555
- PickerListenerType["Now"] = "PickerNow";
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
- };
567
- }
568
- function yearIsOutlineMin(props) {
569
- const { year, minDate } = props;
570
- return minDate ? year < minDate.getFullYear() : false;
571
- }
572
- function yearIsOutlineMax(props) {
573
- const { year, maxDate } = props;
574
- return maxDate ? year > maxDate.getFullYear() : false;
575
- }
576
- function checkYearPicker(props) {
577
- const { maxDate, minDate } = props;
578
- return minDate && yearIsOutlineMin(props)
579
- ? minDate.getFullYear()
580
- : maxDate && yearIsOutlineMax(props)
581
- ? maxDate.getFullYear()
582
- : undefined;
583
- }
584
- function createYearPicker(props) {
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() {
619
- return {
620
- coincidences: undefined,
621
- pattern: '',
622
- previous: null
623
- };
624
- }
625
- function searchForPattern(props) {
626
- const { pattern, store } = props;
627
- if (!store?.pattern) {
628
- return null;
629
- }
630
- let newStore = store;
631
- let search = false;
632
- while (!search && newStore) {
633
- search = helpersString.hasPattern(pattern || '', newStore.pattern, true);
634
- if (!search) {
635
- newStore = newStore.previous;
636
- }
637
- }
638
- return newStore || createEmptyStore();
639
- }
640
- function createStoreAutocomplete(props) {
641
- const { pattern, suggestions, reboot } = props;
642
- if (!pattern) {
643
- return { collection: suggestions, store: createEmptyStore() };
644
- }
645
- const store = reboot ? createEmptyStore() : searchForPattern(props);
646
- const elements = store?.coincidences || suggestions;
647
- const coincidences = elements.filter((element) => element.hasCoincidence(pattern));
648
- return {
649
- collection: coincidences,
650
- store: {
651
- coincidences,
652
- pattern,
653
- previous: store
654
- }
655
- };
656
- }
657
-
658
- const classElement = '.rls-list-field__element';
659
- const POSITION_INITIAL = 0;
660
- function locationListIsBottom(contentElement, listElement) {
661
- if (contentElement && listElement) {
662
- const { top, height } = contentElement.getBoundingClientRect();
663
- const { clientHeight } = listElement;
664
- return top + height + clientHeight < window.innerHeight;
665
- }
666
- return true;
667
- }
668
- function navigationInputDown(props) {
669
- const { contentElement, listElement } = props;
670
- if (!locationListIsBottom(contentElement, listElement)) {
671
- return undefined;
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;
681
- }
682
- function navigationInputUp(props) {
683
- const { contentElement, listElement } = props;
684
- if (locationListIsBottom(contentElement, listElement)) {
685
- return undefined;
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;
701
- }
702
- function navigationElementDown(props) {
703
- const { contentElement, inputElement, listElement, position } = props;
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;
780
+ ? minDate.getMonth()
781
+ : maxDate && monthIsOutsideMax(props, month)
782
+ ? maxDate.getMonth()
783
+ : undefined;
714
784
  }
715
- function navigationElementUp(props) {
716
- const { contentElement, inputElement, listElement, position } = props;
717
- if (position > 0) {
718
- const elements = listElement?.querySelectorAll(classElement);
719
- const newPosition = position - 1;
720
- elements?.item(newPosition)?.focus();
721
- return newPosition;
722
- }
723
- if (locationListIsBottom(contentElement, listElement)) {
724
- inputElement?.focus();
725
- }
726
- return POSITION_INITIAL;
785
+ function createMonthPicker(props) {
786
+ return [
787
+ createMonthState(props, helpersDate.Month.January),
788
+ createMonthState(props, helpersDate.Month.February),
789
+ createMonthState(props, helpersDate.Month.March),
790
+ createMonthState(props, helpersDate.Month.April),
791
+ createMonthState(props, helpersDate.Month.May),
792
+ createMonthState(props, helpersDate.Month.June),
793
+ createMonthState(props, helpersDate.Month.July),
794
+ createMonthState(props, helpersDate.Month.August),
795
+ createMonthState(props, helpersDate.Month.September),
796
+ createMonthState(props, helpersDate.Month.October),
797
+ createMonthState(props, helpersDate.Month.November),
798
+ createMonthState(props, helpersDate.Month.December)
799
+ ];
727
800
  }
728
- function listNavigationInput(props) {
729
- switch (props.event.code) {
730
- case 'ArrowDown':
731
- return navigationInputDown(props);
732
- case 'ArrowUp':
733
- return navigationInputUp(props);
734
- default:
735
- return undefined;
801
+ function monthIsLimitMin(props) {
802
+ const { month, date, minDate } = props;
803
+ if (helpersAdvanced.itIsDefined(month) && date) {
804
+ const minYear = minDate ? minDate.getFullYear() : 0;
805
+ const minMonth = minDate ? minDate.getMonth() : 0;
806
+ return date.getFullYear() === minYear && month <= minMonth;
736
807
  }
808
+ return false;
737
809
  }
738
- function listNavigationElement(props) {
739
- const { event } = props;
740
- switch (event.code) {
741
- case 'ArrowDown':
742
- return navigationElementDown(props);
743
- case 'ArrowUp':
744
- return navigationElementUp(props);
745
- default:
746
- return POSITION_INITIAL;
747
- }
748
- }
749
-
750
- class ListCollection {
751
- constructor(value) {
752
- this.value = value;
753
- }
754
- find(element) {
755
- return this.value.find((current) => current.compareTo(element));
810
+ function monthIsLimitMax(props) {
811
+ const { month, date, maxDate } = props;
812
+ if (helpersAdvanced.itIsDefined(month) && date) {
813
+ const maxYear = maxDate ? maxDate.getFullYear() : 10000;
814
+ const maxMonth = maxDate ? maxDate.getMonth() : 11;
815
+ return date.getFullYear() === maxYear && month >= maxMonth;
756
816
  }
817
+ return false;
818
+ }
819
+ function monthLimitTemplate(props) {
820
+ return {
821
+ limitNext: monthIsLimitMax(props),
822
+ limitPrevious: monthIsLimitMin(props)
823
+ };
757
824
  }
758
825
 
759
- function RlsDayPicker({ date, disabled: disabledPicker, formControl, maxDate, month, minDate, onValue, rlsTheme, year }) {
760
- const currentDate = date || new Date(); // Initial date
761
- const [weeks, setWeeks] = react.useState([]);
762
- const [value, setValue] = react.useState(formControl?.state || currentDate.getDate());
763
- react.useEffect(() => {
764
- const props = createPickerProps();
765
- const day = checkDayPicker(props);
766
- day ? setDayValue(day) : setWeeks(createDayPicker(props));
767
- }, [date, month, year, value, minDate, maxDate]);
768
- react.useEffect(() => {
769
- const day = checkDayPicker(createPickerProps());
770
- day
771
- ? formControl?.setState(day)
772
- : setValue(formControl?.state || currentDate.getDate());
773
- }, [formControl?.state]);
774
- function createPickerProps() {
775
- return {
776
- date: currentDate,
777
- day: formControl?.state || value,
778
- month: helpersAdvanced.itIsDefined(month) ? month : currentDate.getMonth(),
779
- year: year || currentDate.getFullYear(),
780
- minDate,
781
- maxDate
782
- };
783
- }
784
- function setDayValue(value) {
785
- formControl ? formControl.setState(value) : setValue(value);
786
- }
787
- function onChange(value) {
788
- setDayValue(value);
789
- if (onValue) {
790
- onValue(value);
791
- }
792
- }
793
- return (jsxRuntime.jsxs("div", { className: "rls-day-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-day-picker__header", children: helpersDate.DAY_LABELS().map((title, index) => (jsxRuntime.jsx("label", { className: "rls-day-picker__label", children: title }, index))) }), jsxRuntime.jsx("div", { className: "rls-day-picker__component", children: weeks.map(({ days }, index) => (jsxRuntime.jsx("div", { className: "rls-day-picker__week", children: days.map(({ value, disabled, focused, forbidden, selected, today }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-day-picker__day', {
794
- disabled: disabled || disabledPicker,
795
- focused,
796
- forbidden,
797
- selected,
798
- today
799
- }), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-day-picker__day__span", children: value || '??' }) }, index))) }, index))) })] }));
800
- }
801
-
802
- const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
803
-
804
- function RlsDayRangePicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
805
- const currentRange = formControl?.state || helpersDate.DateRange.now();
806
- const currentDate = helpersDate.normalizeMinTime(date || currentRange.minDate);
807
- const sourceDate = react.useRef(currentRange.minDate);
808
- const [weeks, setWeeks] = react.useState([]);
809
- const [range, setRange] = react.useState(currentRange);
810
- react.useEffect(() => {
811
- setWeeks(createDayRangePicker({
812
- date: currentDate,
813
- range,
814
- sourceDate: sourceDate.current,
815
- minDate,
816
- maxDate
817
- }));
818
- }, [range, date, minDate, maxDate]);
819
- function onChange(value) {
820
- const date = helpersDate.assignDayInDate(currentDate, value);
821
- const range = helpersDate.dateIsBefore(date, sourceDate.current)
822
- ? new helpersDate.DateRange(sourceDate.current, date)
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
- }
826
+ var PickerListenerType;
827
+ (function (PickerListenerType) {
828
+ PickerListenerType["Select"] = "PickerSelect";
829
+ PickerListenerType["Now"] = "PickerNow";
830
+ PickerListenerType["Cancel"] = "PickerCancel";
831
+ })(PickerListenerType || (PickerListenerType = {}));
884
832
 
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 })] }));
833
+ function createYear(props, value) {
834
+ const { date, year } = props;
835
+ return {
836
+ disabled: !value,
837
+ focused: value === year,
838
+ selected: value === date.getFullYear(),
839
+ value
840
+ };
841
+ }
842
+ function yearIsOutlineMin(props) {
843
+ const { year, minDate } = props;
844
+ return minDate ? year < minDate.getFullYear() : false;
845
+ }
846
+ function yearIsOutlineMax(props) {
847
+ const { year, maxDate } = props;
848
+ return maxDate ? year > maxDate.getFullYear() : false;
849
+ }
850
+ function checkYearPicker(props) {
851
+ const { maxDate, minDate } = props;
852
+ return minDate && yearIsOutlineMin(props)
853
+ ? minDate.getFullYear()
854
+ : maxDate && yearIsOutlineMax(props)
855
+ ? maxDate.getFullYear()
856
+ : undefined;
857
+ }
858
+ function createYearPicker(props) {
859
+ const { year, maxDate, minDate } = props;
860
+ const prevYears = [];
861
+ const nextYears = [];
862
+ let minRange = year;
863
+ let maxRange = year;
864
+ const minYear = minDate?.getFullYear() || 0;
865
+ const maxYear = maxDate?.getFullYear() || 10000;
866
+ for (let index = 0; index < COUNT_YEAR_RANGE; index++) {
867
+ const prevValue = year - COUNT_YEAR_RANGE + index;
868
+ const nextValue = year + index + 1;
869
+ const prevYear = prevValue >= minYear ? prevValue : undefined;
870
+ const nextYear = nextValue <= maxYear ? nextValue : undefined;
871
+ const prevState = createYear(props, prevYear);
872
+ const nextState = createYear(props, nextYear);
873
+ prevYears.push(prevState);
874
+ nextYears.push(nextState);
875
+ if (!!prevState.value && minRange > prevState.value) {
876
+ minRange = prevState.value;
877
+ }
878
+ if (!!nextState.value && maxRange < nextState.value) {
879
+ maxRange = nextState.value;
880
+ }
881
+ }
882
+ const yearCenter = createYear(props, year);
883
+ return {
884
+ canPrevious: minYear < minRange,
885
+ canNext: maxYear > maxRange,
886
+ maxRange,
887
+ minRange,
888
+ years: [...prevYears, yearCenter, ...nextYears]
889
+ };
932
890
  }
933
891
 
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 }) }))] }));
892
+ function createEmptyStore() {
893
+ return {
894
+ coincidences: undefined,
895
+ pattern: '',
896
+ previous: null
897
+ };
898
+ }
899
+ function searchForPattern(props) {
900
+ const { pattern, store } = props;
901
+ if (!store?.pattern) {
902
+ return null;
903
+ }
904
+ let newStore = store;
905
+ let search = false;
906
+ while (!search && newStore) {
907
+ search = helpersString.hasPattern(pattern || '', newStore.pattern, true);
908
+ if (!search) {
909
+ newStore = newStore.previous;
910
+ }
911
+ }
912
+ return newStore || createEmptyStore();
913
+ }
914
+ function createStoreAutocomplete(props) {
915
+ const { pattern, suggestions, reboot } = props;
916
+ if (!pattern) {
917
+ return { collection: suggestions, store: createEmptyStore() };
918
+ }
919
+ const store = reboot ? createEmptyStore() : searchForPattern(props);
920
+ const elements = store?.coincidences || suggestions;
921
+ const coincidences = elements.filter((element) => element.hasCoincidence(pattern));
922
+ return {
923
+ collection: coincidences,
924
+ store: {
925
+ coincidences,
926
+ pattern,
927
+ previous: store
928
+ }
929
+ };
940
930
  }
941
931
 
942
- const DEFAULT_COUNT_ELEMENT = 20;
943
- const MIN_NUMBER_PAGE = 1;
944
- const FIRST_PAGE = 0;
945
- const DEFAULT_MAX_VISIBLE = 4;
946
- function RlsPagination({ elements, count: defaultCount, filter, onElements, onPagination }) {
947
- const count = defaultCount || DEFAULT_COUNT_ELEMENT;
948
- const [collection, setCollection] = react.useState([]);
949
- const [index, setIndex] = react.useState(0);
950
- const [maxPage, setMaxPage] = react.useState(calculateMaxPage(elements, count));
951
- const [paginations, setPaginations] = react.useState([]);
952
- const [currentPagination, setCurrentPagination] = react.useState();
953
- const [description, setDescription] = react.useState('');
954
- const [firstPage, setFirstPage] = react.useState(true);
955
- const [lastPage, setLastPage] = react.useState(false);
956
- react.useEffect(() => {
957
- refreshFromElements(elements);
958
- }, [elements]);
959
- react.useEffect(() => {
960
- const isFirstPage = currentPagination?.value === FIRST_PAGE;
961
- const isLastPage = currentPagination?.value === maxPage - 1;
962
- setFirstPage(isFirstPage);
963
- setLastPage(isLastPage);
964
- if (onPagination) {
965
- onPagination({ firstPage: isFirstPage, lastPage: isLastPage });
966
- }
967
- }, [currentPagination]);
968
- react.useEffect(() => {
969
- refreshFromFilter(filter);
970
- }, [filter]);
971
- function onChangeElements(elements) {
972
- if (onElements) {
973
- onElements(elements);
974
- }
975
- }
976
- function calculateMaxPage(collection, count) {
977
- return collection.length ? Math.ceil(collection.length / count) : 0;
978
- }
979
- function onSelectPagination(pagination) {
980
- const { value } = pagination;
981
- pagination.active = true;
982
- setIndex(value);
983
- setCurrentPagination(pagination);
984
- refreshFromChanged(clonePage({ index: value }));
985
- }
986
- function goPagination(pagination) {
987
- if (currentPagination) {
988
- currentPagination.active = false;
989
- }
990
- onSelectPagination(pagination);
991
- }
992
- function goPreviousPagination() {
993
- if (currentPagination) {
994
- const { prev, value } = currentPagination;
995
- if (prev) {
996
- onSelectPagination(prev);
997
- currentPagination.active = false;
998
- }
999
- else {
1000
- const prevIndex = value - MIN_NUMBER_PAGE;
1001
- if (prevIndex >= FIRST_PAGE) {
1002
- refreshFromChanged(clonePageFromIndex(prevIndex));
1003
- }
1004
- }
1005
- }
1006
- }
1007
- function goFirstPagination() {
1008
- if (collection.length) {
1009
- refreshFromChanged(clonePageFromIndex(FIRST_PAGE));
1010
- }
1011
- }
1012
- function goNextPagination() {
1013
- if (currentPagination) {
1014
- const { next, value } = currentPagination;
1015
- if (next) {
1016
- onSelectPagination(next);
1017
- currentPagination.active = false;
1018
- }
1019
- else {
1020
- const nextIndex = value + 1;
1021
- if (nextIndex <= maxPage) {
1022
- refreshFromChanged(clonePageFromIndex(nextIndex));
1023
- }
1024
- }
1025
- }
1026
- }
1027
- function goLastPagination() {
1028
- if (collection.length) {
1029
- refreshFromChanged(clonePageFromIndex(maxPage - MIN_NUMBER_PAGE));
1030
- }
1031
- }
1032
- function createPageCollection(props) {
1033
- const { collection, count, index } = props;
1034
- if (collection.length) {
1035
- const finish = (index + MIN_NUMBER_PAGE) * count;
1036
- const start = index * count;
1037
- return collection.slice(start, finish);
1038
- }
1039
- return [];
1040
- }
1041
- function refreshFromElements(elements) {
1042
- elements.length
1043
- ? refreshFromChanged(refreshPage(elements, filter))
1044
- : rebootPagination();
1045
- }
1046
- function refreshFromFilter(filter) {
1047
- refreshFromChanged(refreshPage(elements, filter));
1048
- }
1049
- function refreshFromChanged(page) {
1050
- refreshPaginations(page);
1051
- refreshDescription(page);
1052
- onChangeElements(createPageCollection(page));
1053
- }
1054
- function refreshCollection(elements, filter) {
1055
- const collection = filter
1056
- ? elements.filter((element) => helpersString.hasPattern(JSON.stringify(element), filter))
1057
- : elements;
1058
- setCollection(collection);
1059
- return collection;
1060
- }
1061
- function refreshMaxPage(collection, count) {
1062
- const maxPage = calculateMaxPage(collection, count);
1063
- setMaxPage(maxPage);
1064
- return maxPage;
1065
- }
1066
- function refreshIndex(collection, currentMaxPage) {
1067
- const maxPage = currentMaxPage || refreshMaxPage(collection, count);
1068
- if (index < maxPage || index === FIRST_PAGE) {
1069
- return index;
1070
- }
1071
- const newIndex = maxPage - 1;
1072
- setIndex(newIndex);
1073
- return newIndex;
1074
- }
1075
- function refreshDescription(page) {
1076
- const { collection, count, index } = page;
1077
- const totalCount = elements.length;
1078
- const start = index * count + MIN_NUMBER_PAGE;
1079
- let end = (index + MIN_NUMBER_PAGE) * count;
1080
- if (end > collection.length) {
1081
- end = collection.length;
1082
- }
1083
- setDescription(`${start} - ${end} de ${totalCount}`);
1084
- }
1085
- function refreshPaginations({ index, maxPage }) {
1086
- let maxPageVisible = index + DEFAULT_MAX_VISIBLE;
1087
- if (maxPageVisible > maxPage) {
1088
- maxPageVisible = maxPage;
1089
- }
1090
- let minIndexPage = maxPageVisible - DEFAULT_MAX_VISIBLE;
1091
- if (minIndexPage < 0) {
1092
- minIndexPage = 0;
1093
- }
1094
- if (minIndexPage > index) {
1095
- minIndexPage = index;
1096
- }
1097
- let prevPagination = undefined;
1098
- const paginations = [];
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) {
932
+ const classElement = '.rls-list-field__element';
933
+ const POSITION_INITIAL = 0;
934
+ function locationListIsBottom(contentElement, listElement) {
935
+ if (contentElement && listElement) {
936
+ const { top, height } = contentElement.getBoundingClientRect();
937
+ const { clientHeight } = listElement;
938
+ return top + height + clientHeight < window.innerHeight;
939
+ }
940
+ return true;
941
+ }
942
+ function navigationInputDown(props) {
943
+ const { contentElement, listElement } = props;
944
+ if (!locationListIsBottom(contentElement, listElement)) {
945
+ return undefined;
946
+ }
947
+ const elements = listElement?.querySelectorAll(classElement);
948
+ if (elements?.length) {
949
+ elements.item(0).focus();
950
+ setTimeout(() => {
951
+ listElement?.scroll({ top: 0, behavior: 'smooth' });
952
+ }, 100);
953
+ }
954
+ return POSITION_INITIAL;
955
+ }
956
+ function navigationInputUp(props) {
957
+ const { contentElement, listElement } = props;
958
+ if (locationListIsBottom(contentElement, listElement)) {
959
+ return undefined;
960
+ }
961
+ const elements = listElement?.querySelectorAll(classElement);
962
+ if (!elements?.length) {
963
+ return POSITION_INITIAL;
964
+ }
965
+ const position = elements.length - 1;
966
+ const element = elements.item(position);
967
+ element?.focus();
968
+ setTimeout(() => {
969
+ listElement?.scroll({
970
+ top: element?.offsetTop + element?.offsetLeft,
971
+ behavior: 'smooth'
972
+ });
973
+ }, 100);
974
+ return position;
975
+ }
976
+ function navigationElementDown(props) {
977
+ const { contentElement, inputElement, listElement, position } = props;
978
+ const elements = listElement?.querySelectorAll(classElement);
979
+ const newPosition = position + 1;
980
+ if (newPosition < (elements?.length || 0)) {
981
+ elements?.item(newPosition)?.focus();
982
+ return newPosition;
983
+ }
984
+ if (!locationListIsBottom(contentElement, listElement)) {
985
+ inputElement?.focus();
986
+ }
987
+ return position;
988
+ }
989
+ function navigationElementUp(props) {
990
+ const { contentElement, inputElement, listElement, position } = props;
991
+ if (position > 0) {
992
+ const elements = listElement?.querySelectorAll(classElement);
993
+ const newPosition = position - 1;
994
+ elements?.item(newPosition)?.focus();
995
+ return newPosition;
996
+ }
997
+ if (locationListIsBottom(contentElement, listElement)) {
998
+ inputElement?.focus();
999
+ }
1000
+ return POSITION_INITIAL;
1001
+ }
1002
+ function listNavigationInput(props) {
1003
+ switch (props.event.code) {
1004
+ case 'ArrowDown':
1005
+ return navigationInputDown(props);
1006
+ case 'ArrowUp':
1007
+ return navigationInputUp(props);
1008
+ default:
1009
+ return undefined;
1010
+ }
1011
+ }
1012
+ function listNavigationElement(props) {
1013
+ const { event } = props;
1014
+ switch (event.code) {
1015
+ case 'ArrowDown':
1016
+ return navigationElementDown(props);
1017
+ case 'ArrowUp':
1018
+ return navigationElementUp(props);
1019
+ default:
1020
+ return POSITION_INITIAL;
1021
+ }
1022
+ }
1023
+
1024
+ class ListCollection {
1025
+ constructor(value) {
1026
+ this.value = value;
1027
+ }
1028
+ find(element) {
1029
+ return this.value.find((current) => current.compareTo(element));
1030
+ }
1031
+ }
1032
+
1033
+ function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, month, minDate, onValue, rlsTheme, year }) {
1034
+ const currentDate = date || new Date(); // Initial date
1035
+ const [weeks, setWeeks] = react.useState([]);
1036
+ const [value, setValue] = react.useState(formControl?.state || currentDate.getDate());
1037
+ react.useEffect(() => {
1038
+ const props = createPickerProps();
1039
+ const day = checkDayPicker(props);
1040
+ day ? setDayValue(day) : setWeeks(createDayPicker(props));
1041
+ }, [date, month, year, value, minDate, maxDate]);
1042
+ react.useEffect(() => {
1043
+ const day = checkDayPicker(createPickerProps());
1044
+ day
1045
+ ? formControl?.setState(day)
1046
+ : setValue(formControl?.state || currentDate.getDate());
1047
+ }, [formControl?.state]);
1048
+ function createPickerProps() {
1111
1049
  return {
1112
- collection: pagePartial.collection || collection,
1113
- index: typeof pagePartial.index === 'number' ? pagePartial.index : index,
1114
- count: pagePartial.count || count,
1115
- maxPage: typeof pagePartial.maxPage === 'number' ? pagePartial.maxPage : maxPage
1050
+ date: currentDate,
1051
+ day: formControl?.state || value,
1052
+ month: helpersAdvanced.itIsDefined(month) ? month : currentDate.getMonth(),
1053
+ year: year || currentDate.getFullYear(),
1054
+ minDate,
1055
+ maxDate
1116
1056
  };
1117
1057
  }
1118
- function clonePageFromIndex(index) {
1119
- return clonePage({ index });
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 });
1058
+ function setDayValue(value) {
1059
+ formControl ? formControl.setState(value) : setValue(value);
1126
1060
  }
1127
- function createPagination(value, index) {
1128
- const active = value === index;
1129
- const pagination = {
1130
- label: (value + 1).toString(),
1131
- value,
1132
- active
1133
- };
1134
- if (active) {
1135
- setCurrentPagination(pagination);
1061
+ function onChange(value) {
1062
+ setDayValue(value);
1063
+ if (onValue) {
1064
+ onValue(value);
1136
1065
  }
1137
- return pagination;
1138
- }
1139
- function rebootPagination() {
1140
- setCollection([]);
1141
- setMaxPage(0);
1142
- setIndex(0);
1143
- setPaginations([]);
1144
- onChangeElements([]);
1145
1066
  }
1146
- 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) => {
1147
- return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-pagination__page', {
1148
- active: page.active
1149
- }), onClick: () => {
1150
- goPagination(page);
1151
- }, children: page.label }, index));
1152
- }) }), 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" }) })] })] }));
1067
+ 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', {
1068
+ disabled: disabled || disabledPicker,
1069
+ focused,
1070
+ forbidden,
1071
+ selected,
1072
+ today
1073
+ }), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-picker-day__element__span", children: value || '??' }) }, index))) }, index))) })] }));
1153
1074
  }
1154
1075
 
1155
- function RlsPasswordField({ children, disabled, formControl, placeholder, rlsTheme }) {
1156
- const [password, setPassword] = react.useState(true);
1157
- function onToggleInput() {
1158
- setPassword(!password);
1076
+ const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
1077
+
1078
+ function RlsPickerDayRange({ date, disabled: disabledPicker, formControl, maxDate, minDate, rlsTheme }) {
1079
+ const currentRange = formControl?.state || helpersDate.DateRange.now();
1080
+ const currentDate = helpersDate.normalizeMinTime(date || currentRange.minDate);
1081
+ const sourceDate = react.useRef(currentRange.minDate);
1082
+ const [weeks, setWeeks] = react.useState([]);
1083
+ const [range, setRange] = react.useState(currentRange);
1084
+ react.useEffect(() => {
1085
+ setWeeks(createDayRangePicker({
1086
+ date: currentDate,
1087
+ range,
1088
+ sourceDate: sourceDate.current,
1089
+ minDate,
1090
+ maxDate
1091
+ }));
1092
+ }, [range, date, minDate, maxDate]);
1093
+ function onChange(value) {
1094
+ const date = helpersDate.assignDayInDate(currentDate, value);
1095
+ const range = helpersDate.dateIsBefore(date, sourceDate.current)
1096
+ ? new helpersDate.DateRange(sourceDate.current, date)
1097
+ : new helpersDate.DateRange(date, sourceDate.current);
1098
+ sourceDate.current = date;
1099
+ setRange(range);
1100
+ formControl?.setState(range);
1159
1101
  }
1160
- return (jsxRuntime.jsxs("div", { className: renderClassStatus(' rls-box-field', {
1161
- focused: formControl?.focused,
1162
- error: formControl?.wrong,
1163
- disabled: formControl?.disabled || disabled
1164
- }, 'rls-password-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.jsxs("div", { className: "rls-box-field__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 })] }) }), 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 }) }))] }));
1102
+ 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', {
1103
+ disabled: disabled || disabledPicker,
1104
+ end,
1105
+ forbidden,
1106
+ ranged,
1107
+ source
1108
+ }), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-picker-day-range__element__span", children: value || '??' }) }, index))) }, index))) })] }));
1165
1109
  }
1166
1110
 
1167
- function RlsRadioButtonLabel({ children, disabled, extended, formControl, rlsTheme, value }) {
1168
- const [checked, setChecked] = react.useState(formControl?.state || false);
1111
+ function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme, year }) {
1112
+ const currentDate = date || new Date();
1113
+ const [months, setMonths] = react.useState([]);
1114
+ const [value, setValue] = react.useState(formControl?.state || currentDate.getMonth());
1169
1115
  react.useEffect(() => {
1170
- setChecked(formControl?.state === value);
1116
+ const props = createPickerProps(); // MonthPickerProps
1117
+ const month = checkMonthPicker(props);
1118
+ month ? setMonthValue(month) : setMonths(createMonthPicker(props));
1119
+ }, [date, year, value, minDate, maxDate]);
1120
+ react.useEffect(() => {
1121
+ const month = checkMonthPicker(createPickerProps());
1122
+ helpersAdvanced.itIsDefined(month)
1123
+ ? formControl?.setState(month)
1124
+ : setValue(formControl?.state || currentDate.getMonth());
1171
1125
  }, [formControl?.state]);
1172
- function onSelect() {
1173
- if (formControl) {
1174
- formControl?.setState(value);
1126
+ function createPickerProps() {
1127
+ return {
1128
+ date: currentDate,
1129
+ month: helpersAdvanced.itIsDefined(formControl?.state) ? formControl?.state : value,
1130
+ year: year || currentDate.getFullYear(),
1131
+ minDate,
1132
+ maxDate
1133
+ };
1134
+ }
1135
+ function setMonthValue(value) {
1136
+ formControl ? formControl.setState(value) : setValue(value);
1137
+ }
1138
+ function onChange(value) {
1139
+ setMonthValue(value);
1140
+ if (onValue) {
1141
+ onValue(value);
1142
+ }
1143
+ }
1144
+ 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', {
1145
+ disabled: disabled || disabledPicker,
1146
+ focused,
1147
+ selected
1148
+ }), onClick: !(disabled || disabledPicker) ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-picker-month__span", children: label }) }, index))) }));
1149
+ }
1150
+
1151
+ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
1152
+ const { limitNext, limitPrevious } = monthLimitTemplate({
1153
+ date,
1154
+ maxDate,
1155
+ minDate,
1156
+ month: monthControl.state
1157
+ });
1158
+ const monthName = helpersDate.MONTH_NAMES()[monthControl.state || 0];
1159
+ function onPreviousMonth() {
1160
+ if (helpersAdvanced.itIsDefined(monthControl.state) && helpersAdvanced.itIsDefined(yearControl.state)) {
1161
+ if (monthControl.state > helpersDate.Month.January) {
1162
+ monthControl.setState(monthControl.state - 1);
1163
+ }
1164
+ else {
1165
+ monthControl.setState(helpersDate.Month.December);
1166
+ yearControl.setState(yearControl.state - 1);
1167
+ }
1175
1168
  }
1176
1169
  }
1177
- return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-radiobutton-label', {
1178
- disabled,
1179
- extended
1180
- }), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-radiobutton-label__component", onClick: onSelect, children: jsxRuntime.jsx(RlsRadioButton, { checked: checked, disabled: disabled }) }), jsxRuntime.jsx("label", { className: "rls-radiobutton-label__text", children: children })] }));
1181
- }
1182
-
1183
- function RlsSwitchLabel({ children, disabled, extended, formControl, rlsTheme }) {
1184
- const [checked, setChecked] = react.useState(formControl?.value || false);
1185
- react.useEffect(() => {
1186
- setChecked(formControl?.state || false);
1187
- }, [formControl?.state]);
1188
- function onToggle() {
1189
- if (formControl) {
1190
- formControl?.setState(!formControl.state);
1170
+ function onPreviousYear() {
1171
+ if (helpersAdvanced.itIsDefined(yearControl.state)) {
1172
+ yearControl.setState(yearControl.state - 1);
1191
1173
  }
1192
- else {
1193
- setChecked(!checked);
1174
+ }
1175
+ function onPrevious() {
1176
+ type === 'month' ? onPreviousMonth() : onPreviousYear();
1177
+ }
1178
+ function onNextMonth() {
1179
+ if (helpersAdvanced.itIsDefined(monthControl.state) && helpersAdvanced.itIsDefined(yearControl.state)) {
1180
+ if (monthControl.state < helpersDate.Month.December) {
1181
+ monthControl.setState(monthControl.state + 1);
1182
+ }
1183
+ else {
1184
+ monthControl.setState(helpersDate.Month.January);
1185
+ yearControl.setState(yearControl.state + 1);
1186
+ }
1194
1187
  }
1195
1188
  }
1196
- return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-switch-label', { disabled, extended }), "rls-theme": rlsTheme, children: [jsxRuntime.jsx("div", { className: "rls-switch-label__component", onClick: onToggle, children: jsxRuntime.jsx(RlsSwitch, { checked: checked, disabled: disabled }) }), jsxRuntime.jsx("label", { className: "rls-switch-label__text", children: children })] }));
1197
- }
1198
-
1199
- function RlsTextField({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
1200
- return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', {
1201
- focused: formControl?.focused,
1202
- error: formControl?.wrong,
1203
- disabled: formControl?.disabled || disabled
1204
- }, 'rls-text-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(RlsInputText, { 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 }) }))] }));
1205
- }
1206
-
1207
- function RlsToolbar({ actions, children, subtitle }) {
1208
- 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))) }))] }));
1189
+ function onNextYear() {
1190
+ if (helpersAdvanced.itIsDefined(yearControl.state)) {
1191
+ yearControl.setState(yearControl.state + 1);
1192
+ }
1193
+ }
1194
+ function onNext() {
1195
+ type === 'month' ? onNextMonth() : onNextYear();
1196
+ }
1197
+ 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
1198
  }
1210
1199
 
1211
- function RlsYearPicker({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme }) {
1200
+ function RlsPickerYear({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme }) {
1212
1201
  const currentDate = date || new Date();
1213
1202
  const [value, setValue] = react.useState(formControl?.state || currentDate.getFullYear());
1214
1203
  const [year, setYear] = react.useState(formControl?.state || currentDate.getFullYear());
@@ -1250,11 +1239,19 @@ function RlsYearPicker({ date, disabled: disabledPicker, formControl, maxDate, m
1250
1239
  onValue(value);
1251
1240
  }
1252
1241
  }
1253
- return (jsxRuntime.jsxs("div", { className: "rls-year-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-year-picker__header", children: [jsxRuntime.jsx("div", { className: "rls-year-picker__action rls-year-picker__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-year-picker__action rls-year-picker__action--next", children: jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onClickNext, disabled: !template.canNext || disabledPicker }) })] }), jsxRuntime.jsx("div", { className: "rls-year-picker__component", children: template.years.map(({ value, disabled, focused, selected }, index) => (jsxRuntime.jsx("div", { className: renderClassStatus('rls-year-picker__year', {
1242
+ 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
1243
  disabled: disabled || disabledPicker,
1255
1244
  focused,
1256
1245
  selected
1257
- }), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-year-picker__year__span rls-body1-medium", children: value || '????' }) }, index))) })] }));
1246
+ }), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntime.jsx("span", { className: "rls-picker-year__year__span rls-body1-medium", children: value || '????' }) }, index))) })] }));
1247
+ }
1248
+
1249
+ function RlsToolbar({ actions, children, subtitle }) {
1250
+ 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))) }))] }));
1251
+ }
1252
+
1253
+ function RlsCard({ children, outline, rlsTheme }) {
1254
+ return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-card', { outline }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-card__content", children: children }) }));
1258
1255
  }
1259
1256
 
1260
1257
  const reactI18n = i18n.i18n({
@@ -1278,6 +1275,87 @@ const reactI18n = i18n.i18n({
1278
1275
  }
1279
1276
  });
1280
1277
 
1278
+ class ConfirmationResult extends helpersAdvanced.PartialSealed {
1279
+ static approved() {
1280
+ return new ConfirmationResult('approved');
1281
+ }
1282
+ static reject() {
1283
+ return new ConfirmationResult('reject');
1284
+ }
1285
+ }
1286
+ function RlsConfirmation({ approved, content, reject, rlsTheme, subtitle, title, visible }) {
1287
+ 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: () => {
1288
+ if (approved.onClick) {
1289
+ approved.onClick();
1290
+ }
1291
+ }, children: approved.label })), reject && (jsxRuntime.jsx(RlsButton, { type: "outline", onClick: () => {
1292
+ if (reject.onClick) {
1293
+ reject.onClick();
1294
+ }
1295
+ }, children: reject.label }))] }) }))] }), jsxRuntime.jsx("div", { className: "rls-confirmation__backdrop" })] }));
1296
+ }
1297
+ function useConfirmationService() {
1298
+ const [config, setConfig] = react.useState({});
1299
+ const [visible, setVisible] = react.useState(false);
1300
+ const rlsConfirmation = ReactDOM.createPortal(jsxRuntime.jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
1301
+ function confirmation(config) {
1302
+ return new Promise((resolve) => {
1303
+ const { content, rlsTheme, subtitle, title, approved, reject } = config;
1304
+ setConfig({
1305
+ content,
1306
+ rlsTheme,
1307
+ subtitle,
1308
+ title,
1309
+ approved: {
1310
+ label: approved || reactI18n('confirmationActionApproved'),
1311
+ onClick: () => {
1312
+ setVisible(false);
1313
+ resolve(ConfirmationResult.approved());
1314
+ }
1315
+ },
1316
+ reject: reject
1317
+ ? {
1318
+ label: reject,
1319
+ onClick: () => {
1320
+ setVisible(false);
1321
+ resolve(ConfirmationResult.reject());
1322
+ }
1323
+ }
1324
+ : undefined
1325
+ });
1326
+ setVisible(true);
1327
+ });
1328
+ }
1329
+ return {
1330
+ RlsConfirmation: rlsConfirmation,
1331
+ confirmation
1332
+ };
1333
+ }
1334
+
1335
+ function RlsDatatableHeader({ children }) {
1336
+ return jsxRuntime.jsx("tr", { className: "rls-datatable__header", children: children });
1337
+ }
1338
+ function RlsDatatableTitle({ children, className, control }) {
1339
+ return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__title', { control }, className).trim(), children: children }));
1340
+ }
1341
+ function RlsDatatableData({ children, className, error }) {
1342
+ return (jsxRuntime.jsx("tr", { className: renderClassStatus('rls-datatable__data', { error }, className).trim(), children: children }));
1343
+ }
1344
+ function RlsDatatableCell({ children, className, control, overflow }) {
1345
+ return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__cell', { control, overflow }, className).trim(), children: children }));
1346
+ }
1347
+ function RlsDatatableTotals({ children, className, error }) {
1348
+ return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-datatable__totals', { error }, className).trim(), children: children }));
1349
+ }
1350
+ function RlsDatatableInfo({ children, className, control, overflow }) {
1351
+ return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-datatable__info', { control, overflow }, className).trim(), children: children }));
1352
+ }
1353
+ function RlsDatatable({ children, datatable, footer, header, rlsTheme, summary }) {
1354
+ return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-datatable', {
1355
+ scrolleable: datatable?.scrolleable
1356
+ }), "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 })] }));
1357
+ }
1358
+
1281
1359
  function useDatatable() {
1282
1360
  const [scrolleable, setScrolleable] = react.useState(false);
1283
1361
  const bodyRef = react.useRef(null);
@@ -1368,44 +1446,66 @@ function useListControl({ suggestions, formControl }) {
1368
1446
 
1369
1447
  const DURATION_ANIMATION$1 = 240;
1370
1448
  const MAX_ELEMENTS = 6;
1371
- function useAutocompleteField({ disabled, formControl, onSelect, onValue, suggestions }) {
1449
+ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, suggestions }) {
1372
1450
  const [pattern, setPattern] = react.useState('');
1373
1451
  const [coincidences, setCoincidences] = react.useState([]);
1374
- const [store, setStore] = react.useState({
1452
+ const currentStore = react.useRef({
1375
1453
  pattern: '',
1376
1454
  coincidences: [],
1377
1455
  previous: null
1378
1456
  });
1379
1457
  const listControl = useListControl({ suggestions, formControl });
1380
1458
  const { collection, inputRef, navigationElement, navigationInput, setFocused, setValue, setVisible } = listControl;
1459
+ const initializedState = react.useRef(false);
1460
+ const initializedCollection = react.useRef(false);
1381
1461
  const changeInternal = react.useRef(false);
1382
- react.useEffect(() => filterSuggestions(pattern, true), [suggestions]);
1383
- react.useEffect(() => filterSuggestions(pattern), [pattern]);
1384
1462
  react.useEffect(() => {
1463
+ refreshCoincidences(pattern, true);
1464
+ }, [suggestions]);
1465
+ react.useEffect(() => {
1466
+ refreshCoincidences(pattern);
1467
+ }, [pattern]);
1468
+ react.useEffect(() => {
1469
+ if (!initializedState.current || !initializedCollection.current) {
1470
+ initializedState.current = true;
1471
+ return;
1472
+ }
1385
1473
  if (changeInternal.current) {
1386
1474
  changeInternal.current = false;
1475
+ return;
1387
1476
  }
1388
- else {
1389
- resetState(formControl?.state);
1390
- }
1477
+ refresh(collection, formControl?.state);
1391
1478
  }, [formControl?.state]);
1392
- react.useEffect(() => resetCollection(collection, formControl?.state), [collection]);
1479
+ react.useEffect(() => {
1480
+ if (!initializedCollection.current || !initializedState.current) {
1481
+ initializedCollection.current = true;
1482
+ return;
1483
+ }
1484
+ refresh(collection, formControl?.state);
1485
+ }, [collection]);
1486
+ function refresh(collection, state) {
1487
+ if (!state) {
1488
+ return setValue('');
1489
+ }
1490
+ const element = collection.find(state);
1491
+ if (element) {
1492
+ return setValue(element.description);
1493
+ }
1494
+ setValue('');
1495
+ setFormState(undefined);
1496
+ }
1393
1497
  function setFormState(value) {
1394
1498
  if (formControl) {
1395
1499
  changeInternal.current = true;
1396
1500
  formControl.setState(value);
1397
1501
  }
1398
1502
  }
1399
- function resetCollection(collection, state) {
1400
- setValue(state ? collection.find(state)?.description || '' : '');
1401
- }
1402
- function resetState(state) {
1403
- resetCollection(collection, state);
1404
- }
1405
1503
  function onClickControl() {
1406
1504
  if (!disabled) {
1407
1505
  setVisible(true);
1408
- setTimeout(() => inputRef?.current?.focus(), DURATION_ANIMATION$1);
1506
+ setTimeout(() => {
1507
+ inputRef?.current?.focus();
1508
+ }, DURATION_ANIMATION$1);
1409
1509
  }
1410
1510
  }
1411
1511
  function onFocusInput() {
@@ -1459,15 +1559,15 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
1459
1559
  onValue(value);
1460
1560
  }
1461
1561
  }
1462
- function filterSuggestions(pattern, reboot = false) {
1463
- const result = createStoreAutocomplete({
1562
+ function refreshCoincidences(pattern, reboot = false) {
1563
+ const { collection, store } = createStoreAutocomplete({
1464
1564
  pattern,
1465
1565
  suggestions,
1466
1566
  reboot,
1467
- store
1567
+ store: currentStore.current
1468
1568
  });
1469
- setCoincidences(result.collection.slice(0, MAX_ELEMENTS));
1470
- setStore(result.store);
1569
+ currentStore.current = store;
1570
+ setCoincidences(collection.slice(0, MAX_ELEMENTS));
1471
1571
  }
1472
1572
  return {
1473
1573
  coincidences,
@@ -1485,115 +1585,30 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
1485
1585
  };
1486
1586
  }
1487
1587
 
1488
- function RlsAutocompleteFieldTemplate({ suggestions, children, disabled, formControl, hiddenIcon, placeholder, searching, rlsTheme, onSearch, onSelect, onValue, render }) {
1489
- const { coincidences, listControl, pattern, onBlurInput, onClickAction, onClickBackdrop, onClickControl, onClickElement, onFocusInput, onKeydownElement, onKeydownInput, setPattern } = useAutocompleteField({
1588
+ function RlsFieldAutocompleteTemplate({ suggestions, children, disabled, formControl, hiddenIcon, placeholder, searching, rlsTheme, onSearch, onSelect, onValue, render }) {
1589
+ const { coincidences, listControl, pattern, onBlurInput, onClickAction, onClickBackdrop, onClickControl, onClickElement, onFocusInput, onKeydownElement, onKeydownInput, setPattern } = useFieldAutocomplete({
1490
1590
  suggestions,
1491
1591
  disabled,
1492
1592
  formControl,
1493
1593
  onSelect,
1494
1594
  onValue
1495
1595
  });
1496
- return (jsxRuntime.jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-box-field', {
1596
+ return (jsxRuntime.jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-field-box', {
1497
1597
  disabled,
1498
1598
  focused: listControl.focused,
1499
1599
  selected: !!listControl.value
1500
- }, 'rls-autocomplete-field rls-list-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.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("label", { className: "rls-list-field__control", onClick: onClickControl, children: listControl.value ? (jsxRuntime.jsx("span", { className: "rls-list-field__control__description", children: listControl.value })) : (jsxRuntime.jsx("span", { className: "rls-list-field__control__placeholder", children: placeholder })) }), !hiddenIcon && listControl.value && (jsxRuntime.jsx("button", { className: "rls-list-field__action", disabled: disabled, onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: "trash-2" }) }))] }) }), 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 }) })), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-list-field__suggestions', {
1600
+ }, '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" }) }))] }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-field-box__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) })), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
1501
1601
  visible: listControl.visible,
1502
1602
  hide: !listControl.visible,
1503
1603
  higher: listControl.higher
1504
- }), children: [jsxRuntime.jsx("div", { className: "rls-list-field__suggestions__body", children: jsxRuntime.jsxs("ul", { ref: listControl.listRef, className: "rls-list-field__ul", children: [jsxRuntime.jsxs("div", { className: "rls-list-field__ul__search", children: [jsxRuntime.jsx("input", { ref: listControl.inputRef, className: "rls-list-field__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: pattern, onChange: ({ target: { value } }) => {
1604
+ }), 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 } }) => {
1505
1605
  setPattern(value);
1506
1606
  }, disabled: disabled || searching, onFocus: onFocusInput, onBlur: onBlurInput, onKeyDown: onKeydownInput }), onSearch && (jsxRuntime.jsx("button", { disabled: disabled || searching, onClick: () => {
1507
1607
  onSearch(pattern);
1508
- }, children: jsxRuntime.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntime.jsx(RlsProgressBar, { indeterminate: true }), coincidences.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !coincidences.length && (jsxRuntime.jsx("li", { className: "rls-list-field__empty", children: jsxRuntime.jsxs("div", { className: "rls-list-field__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-list-field__backdrop", onClick: onClickBackdrop })] })] }));
1509
- }
1510
- function RlsAutocompleteField(props) {
1511
- return (jsxRuntime.jsx(RlsAutocompleteFieldTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
1512
- }
1513
-
1514
- function RlsCard({ children, outline, rlsTheme }) {
1515
- return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-card', { outline }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-card__content", children: children }) }));
1516
- }
1517
-
1518
- class ConfirmationResult extends helpersAdvanced.PartialSealed {
1519
- static approved() {
1520
- return new ConfirmationResult('approved');
1521
- }
1522
- static reject() {
1523
- return new ConfirmationResult('reject');
1524
- }
1525
- }
1526
- function RlsConfirmation({ approved, content, reject, rlsTheme, subtitle, title, visible }) {
1527
- 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: () => {
1528
- if (approved.onClick) {
1529
- approved.onClick();
1530
- }
1531
- }, children: approved.label })), reject && (jsxRuntime.jsx(RlsButton, { type: "outline", onClick: () => {
1532
- if (reject.onClick) {
1533
- reject.onClick();
1534
- }
1535
- }, children: reject.label }))] }) }))] }), jsxRuntime.jsx("div", { className: "rls-confirmation__backdrop" })] }));
1536
- }
1537
- function useConfirmationService() {
1538
- const [config, setConfig] = react.useState({});
1539
- const [visible, setVisible] = react.useState(false);
1540
- const rlsConfirmation = ReactDOM.createPortal(jsxRuntime.jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
1541
- function confirmation(config) {
1542
- return new Promise((resolve) => {
1543
- const { content, rlsTheme, subtitle, title, approved, reject } = config;
1544
- setConfig({
1545
- content,
1546
- rlsTheme,
1547
- subtitle,
1548
- title,
1549
- approved: {
1550
- label: approved || reactI18n('confirmationActionApproved'),
1551
- onClick: () => {
1552
- setVisible(false);
1553
- resolve(ConfirmationResult.approved());
1554
- }
1555
- },
1556
- reject: reject
1557
- ? {
1558
- label: reject,
1559
- onClick: () => {
1560
- setVisible(false);
1561
- resolve(ConfirmationResult.reject());
1562
- }
1563
- }
1564
- : undefined
1565
- });
1566
- setVisible(true);
1567
- });
1568
- }
1569
- return {
1570
- RlsConfirmation: rlsConfirmation,
1571
- confirmation
1572
- };
1573
- }
1574
-
1575
- function RlsDatatableHeader({ children }) {
1576
- return jsxRuntime.jsx("tr", { className: "rls-datatable__header", children: children });
1577
- }
1578
- function RlsDatatableTitle({ children, className, control }) {
1579
- return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__title', { control }, className).trim(), children: children }));
1580
- }
1581
- function RlsDatatableData({ children, className, error }) {
1582
- return (jsxRuntime.jsx("tr", { className: renderClassStatus('rls-datatable__data', { error }, className).trim(), children: children }));
1583
- }
1584
- function RlsDatatableCell({ children, className, control, overflow }) {
1585
- return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__cell', { control, overflow }, className).trim(), children: children }));
1586
- }
1587
- function RlsDatatableTotals({ children, className, error }) {
1588
- return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-datatable__totals', { error }, className).trim(), children: children }));
1608
+ }, 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 })] })] }));
1589
1609
  }
1590
- function RlsDatatableInfo({ children, className, control, overflow }) {
1591
- return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-datatable__info', { control, overflow }, className).trim(), children: children }));
1592
- }
1593
- function RlsDatatable({ children, datatable, footer, header, rlsTheme, summary }) {
1594
- return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-datatable', {
1595
- scrolleable: datatable?.scrolleable
1596
- }), "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 })] }));
1610
+ function RlsFieldAutocomplete(props) {
1611
+ return (jsxRuntime.jsx(RlsFieldAutocompleteTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
1597
1612
  }
1598
1613
 
1599
1614
  function rangeFormatTemplate({ maxDate, minDate }) {
@@ -1699,7 +1714,7 @@ function useReactControl(controlProps, controlValidators) {
1699
1714
  }
1700
1715
 
1701
1716
  const FORMAT_DESCRIPTION = '{dw}, {mx} {dd} de {aa}';
1702
- function RlsDatePicker({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
1717
+ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
1703
1718
  const today = new Date(); // Initial current date in component
1704
1719
  const dateInitial = formControl?.state || date || today;
1705
1720
  const yearControl = useReactControl(dateInitial.getFullYear());
@@ -1760,18 +1775,18 @@ function RlsDatePicker({ automatic, date, disabled, formControl, maxDate, minDat
1760
1775
  onListener({ type: PickerListenerType.Select, value });
1761
1776
  }
1762
1777
  }
1763
- return (jsxRuntime.jsxs("div", { className: "rls-date-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-date-picker__header", children: [jsxRuntime.jsx("div", { className: "rls-date-picker__title rls-date-picker__title--description", children: jsxRuntime.jsx("span", { onClick: onVisibilityDay, children: helpersDate.dateFormatTemplate(dateInitial, FORMAT_DESCRIPTION) }) }), jsxRuntime.jsx("div", { className: "rls-date-picker__title rls-date-picker__title--year", children: jsxRuntime.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntime.jsx(RlsMonthTitlePicker, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityMonth })] }), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-date-picker__component', {
1778
+ 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', {
1764
1779
  day: visibility === 'DAY',
1765
1780
  month: visibility === 'MONTH',
1766
1781
  year: visibility === 'YEAR'
1767
- }), children: [jsxRuntime.jsx(RlsDayPicker, { formControl: dayControl, date: dateInitial, month: monthControl.state, year: yearControl.state, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsMonthPicker, { formControl: monthControl, date: dateInitial, year: yearControl.state, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntime.jsx(RlsYearPicker, { formControl: yearControl, date: dateInitial, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntime.jsx("div", { className: renderClassStatus('rls-date-picker__footer', { automatic }), children: jsxRuntime.jsxs("div", { className: "rls-date-picker__actions", children: [jsxRuntime.jsx("div", { className: "rls-date-picker__actions--cancel", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntime.jsx("div", { className: "rls-date-picker__actions--today", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onToday, disabled: dateOutRange({ date: today, maxDate, minDate }), children: reactI18n('dateActionToday') }) }), jsxRuntime.jsx("div", { className: "rls-date-picker__actions--ok", children: jsxRuntime.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
1782
+ }), 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') }) })] }) })] }));
1768
1783
  }
1769
1784
 
1770
1785
  function RlsModal({ children, visible, rlsTheme }) {
1771
1786
  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);
1772
1787
  }
1773
1788
 
1774
- function RlsDateField({ children, date, disabled, formControl, maxDate, minDate, onValue, placeholder, rlsTheme }) {
1789
+ function RlsFieldDate({ children, date, disabled, formControl, maxDate, minDate, onValue, placeholder, rlsTheme }) {
1775
1790
  const today = new Date(); // Initial current date in component
1776
1791
  const [value, setValue] = react.useState();
1777
1792
  const [modalIsVisible, setModalIsVisible] = react.useState(false);
@@ -1807,7 +1822,7 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
1807
1822
  setModalIsVisible(true);
1808
1823
  }
1809
1824
  }
1810
- return (jsxRuntime.jsxs("div", { className: "rls-date-field", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', { disabled }), children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("input", { className: "rls-date-field__control", type: "text", value: value ? helpersDate.dateFormatTemplate(value, DATE_RANGE_FORMAT) : '', readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntime.jsx("button", { className: "rls-date-field__action", onClick: onClean, disabled: disabled, children: jsxRuntime.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), 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 }) }))] }), jsxRuntime.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntime.jsx(RlsDatePicker, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value, type }) => {
1825
+ 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' }) })] }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-field-box__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }), jsxRuntime.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntime.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value, type }) => {
1811
1826
  if (type !== PickerListenerType.Cancel) {
1812
1827
  onChange(value, true);
1813
1828
  }
@@ -1818,7 +1833,7 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
1818
1833
  } }) })] }));
1819
1834
  }
1820
1835
 
1821
- function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
1836
+ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
1822
1837
  const dateInitial = helpersDate.normalizeMinTime(datePicker || new Date());
1823
1838
  const rangeInitial = formControl?.state || helpersDate.DateRange.now();
1824
1839
  const yearControl = useReactControl(dateInitial.getFullYear());
@@ -1867,16 +1882,16 @@ function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl
1867
1882
  onListener({ type: PickerListenerType.Select, value });
1868
1883
  }
1869
1884
  }
1870
- return (jsxRuntime.jsxs("div", { className: "rls-date-range-picker", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-date-range-picker__header", children: [jsxRuntime.jsx("div", { className: "rls-date-range-picker__title rls-date-range-picker__title--description", children: jsxRuntime.jsx("span", { onClick: onVisibilityDay, children: rangeFormatTemplate(value) }) }), jsxRuntime.jsx("div", { className: "rls-date-range-picker__title rls-date-range-picker__title--year", children: jsxRuntime.jsx("span", { onClick: onVisibilityYear, children: yearControl.state }) }), jsxRuntime.jsx(RlsMonthTitlePicker, { 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-date-range-picker__component', {
1885
+ 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', {
1871
1886
  day: visibility === 'DAY',
1872
1887
  month: visibility === 'MONTH',
1873
1888
  year: visibility === 'YEAR'
1874
- }), children: [jsxRuntime.jsx(RlsDayRangePicker, { formControl: dayControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntime.jsx(RlsMonthPicker, { formControl: monthControl, year: yearControl.state, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntime.jsx(RlsYearPicker, { formControl: yearControl, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntime.jsx("div", { className: renderClassStatus('rls-date-range-picker__footer', {
1889
+ }), 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', {
1875
1890
  automatic
1876
- }), children: jsxRuntime.jsxs("div", { className: "rls-date-range-picker__actions", children: [jsxRuntime.jsx("div", { className: "rls-date-range-picker__actions--cancel", children: jsxRuntime.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntime.jsx("div", { className: "rls-date-range-picker__actions--ok", children: jsxRuntime.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
1891
+ }), 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') }) })] }) })] }));
1877
1892
  }
1878
1893
 
1879
- function RlsDateRangeField({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
1894
+ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
1880
1895
  const currentRange = formControl?.state || helpersDate.DateRange.now();
1881
1896
  const currentDate = datePicker || new Date();
1882
1897
  const [value, setValue] = react.useState(currentRange);
@@ -1893,7 +1908,7 @@ function RlsDateRangeField({ children, date: datePicker, disabled, formControl,
1893
1908
  setModalIsVisible(true);
1894
1909
  }
1895
1910
  }
1896
- return (jsxRuntime.jsxs("div", { className: "rls-date-field", "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', { disabled }), children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("input", { className: "rls-date-field__control", type: "text", value: value ? rangeFormatTemplate(value) : '', readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: disabled }), jsxRuntime.jsx("button", { className: "rls-date-field__action", onClick: onClickAction, disabled: disabled, children: jsxRuntime.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) })] }), jsxRuntime.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntime.jsx(RlsDateRangePicker, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
1911
+ 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(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntime.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: disabled, maxDate: maxDate, minDate: minDate, onListener: ({ value }) => {
1897
1912
  if (value) {
1898
1913
  setValue(value);
1899
1914
  }
@@ -1901,35 +1916,47 @@ function RlsDateRangeField({ children, date: datePicker, disabled, formControl,
1901
1916
  } }) })] }));
1902
1917
  }
1903
1918
 
1904
- function RlsFormNavigation({ children, visible, rlsTheme }) {
1905
- return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
1906
- }
1907
-
1908
- function useSelectField({ suggestions, formControl, onSelect, onValue }) {
1919
+ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
1909
1920
  const listControl = useListControl({ suggestions, formControl });
1910
1921
  const { collection, inputRef, visible, navigationElement, navigationInput, setFocused, setValue, setVisible } = listControl;
1922
+ const initializedState = react.useRef(false);
1923
+ const initializedCollection = react.useRef(false);
1911
1924
  const changeInternal = react.useRef(false);
1912
1925
  react.useEffect(() => {
1926
+ if (!initializedState.current || !initializedCollection.current) {
1927
+ initializedState.current = true;
1928
+ return;
1929
+ }
1913
1930
  if (changeInternal.current) {
1914
1931
  changeInternal.current = false;
1932
+ return;
1915
1933
  }
1916
- else {
1917
- resetState(formControl?.state);
1918
- }
1934
+ refresh(collection, formControl?.state);
1919
1935
  }, [formControl?.state]);
1920
- react.useEffect(() => resetCollection(collection, formControl?.state), [collection]);
1936
+ react.useEffect(() => {
1937
+ if (!initializedCollection.current || !initializedState.current) {
1938
+ initializedCollection.current = true;
1939
+ return;
1940
+ }
1941
+ refresh(collection, formControl?.state);
1942
+ }, [collection]);
1943
+ function refresh(collection, state) {
1944
+ if (!state) {
1945
+ return setValue('');
1946
+ }
1947
+ const element = collection.find(state);
1948
+ if (element) {
1949
+ return setValue(element.description);
1950
+ }
1951
+ setValue('');
1952
+ setFormState(undefined);
1953
+ }
1921
1954
  function setFormState(value) {
1922
1955
  if (formControl) {
1923
1956
  changeInternal.current = true;
1924
1957
  formControl.setState(value);
1925
1958
  }
1926
1959
  }
1927
- function resetCollection(collection, state) {
1928
- setValue(state ? collection.find(state)?.description || '' : '');
1929
- }
1930
- function resetState(state) {
1931
- resetCollection(collection, state);
1932
- }
1933
1960
  function onFocusInput() {
1934
1961
  setFocused(true);
1935
1962
  }
@@ -1955,9 +1982,8 @@ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
1955
1982
  }
1956
1983
  }
1957
1984
  function onClickAction() {
1958
- const newVisible = !visible;
1959
- setVisible(newVisible);
1960
- if (newVisible) {
1985
+ setVisible(!visible);
1986
+ if (!visible) {
1961
1987
  inputRef?.current?.focus();
1962
1988
  }
1963
1989
  }
@@ -2001,24 +2027,28 @@ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
2001
2027
  };
2002
2028
  }
2003
2029
 
2004
- function RlsSelectFieldTemplate({ suggestions, children, disabled, formControl, placeholder, rlsTheme, onSelect, onValue, render }) {
2005
- const { listControl, onBlurInput, onClickAction, onClickBackdrop, onClickElement, onClickInput, onFocusInput, onKeydownElement, onKeydownInput } = useSelectField({
2030
+ function RlsFieldSelectTemplate({ suggestions, children, disabled, formControl, placeholder, rlsTheme, onSelect, onValue, render }) {
2031
+ const { listControl, onBlurInput, onClickAction, onClickBackdrop, onClickElement, onClickInput, onFocusInput, onKeydownElement, onKeydownInput } = useFieldSelect({
2006
2032
  suggestions,
2007
2033
  disabled,
2008
2034
  formControl,
2009
2035
  onSelect,
2010
2036
  onValue
2011
2037
  });
2012
- return (jsxRuntime.jsxs("div", { ref: listControl.boxContentRef, className: renderClassStatus('rls-box-field', { focused: listControl.focused, disabled }, 'rls-select-field rls-list-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.jsxs("div", { className: "rls-box-field__body", children: [jsxRuntime.jsx("input", { ref: listControl.inputRef, className: "rls-list-field__control", readOnly: true, disabled: disabled, placeholder: placeholder, value: listControl.value, onFocus: onFocusInput, onBlur: onBlurInput, onClick: onClickInput, onKeyDown: onKeydownInput }), jsxRuntime.jsx("button", { className: renderClassStatus('rls-list-field__action', {
2038
+ 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', {
2013
2039
  visible: listControl.visible
2014
- }), disabled: disabled, onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }), 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 }) })), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-list-field__suggestions', {
2040
+ }), disabled: disabled, onClick: onClickAction, children: jsxRuntime.jsx(RlsIcon, { value: "arrow-ios-down" }) })] }) }), formControl?.wrong && (jsxRuntime.jsx("div", { className: "rls-field-box__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl?.error?.message }) })), jsxRuntime.jsxs("div", { className: renderClassStatus('rls-field-list__suggestions', {
2015
2041
  visible: listControl.visible,
2016
2042
  hide: !listControl.visible,
2017
2043
  higher: listControl.higher
2018
- }), children: [jsxRuntime.jsx("div", { className: "rls-list-field__suggestions__body", children: jsxRuntime.jsxs("ul", { ref: listControl.listRef, className: "rls-list-field__ul", children: [suggestions.map((element, index) => (jsxRuntime.jsx("li", { className: "rls-list-field__element", tabIndex: -1, onClick: onClickElement(element), onKeyDown: onKeydownElement(element), children: render(element) }, index))), !suggestions.length && (jsxRuntime.jsx("li", { className: "rls-list-field__empty", children: jsxRuntime.jsxs("div", { className: "rls-list-field__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-list-field__backdrop", onClick: onClickBackdrop })] })] }));
2044
+ }), 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 })] })] }));
2019
2045
  }
2020
- function RlsSelectField(props) {
2021
- return (jsxRuntime.jsx(RlsSelectFieldTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
2046
+ function RlsFieldSelect(props) {
2047
+ return (jsxRuntime.jsx(RlsFieldSelectTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
2048
+ }
2049
+
2050
+ function RlsFormNavigation({ children, visible, rlsTheme }) {
2051
+ return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
2022
2052
  }
2023
2053
 
2024
2054
  const DURATION_ANIMATION = 240;
@@ -2085,8 +2115,6 @@ function RlsApplication({ children }) {
2085
2115
  exports.ConfirmationResult = ConfirmationResult;
2086
2116
  exports.RlsAmount = RlsAmount;
2087
2117
  exports.RlsApplication = RlsApplication;
2088
- exports.RlsAutocompleteField = RlsAutocompleteField;
2089
- exports.RlsAutocompleteFieldTemplate = RlsAutocompleteFieldTemplate;
2090
2118
  exports.RlsAvatar = RlsAvatar;
2091
2119
  exports.RlsBadge = RlsBadge;
2092
2120
  exports.RlsBallot = RlsBallot;
@@ -2098,7 +2126,6 @@ exports.RlsButtonToggle = RlsButtonToggle;
2098
2126
  exports.RlsCard = RlsCard;
2099
2127
  exports.RlsCheckBox = RlsCheckBox;
2100
2128
  exports.RlsCheckBoxControl = RlsCheckBoxControl;
2101
- exports.RlsCheckBoxLabel = RlsCheckBoxLabel;
2102
2129
  exports.RlsConfirmation = RlsConfirmation;
2103
2130
  exports.RlsContext = RlsContext;
2104
2131
  exports.RlsDatatable = RlsDatatable;
@@ -2108,12 +2135,16 @@ exports.RlsDatatableHeader = RlsDatatableHeader;
2108
2135
  exports.RlsDatatableInfo = RlsDatatableInfo;
2109
2136
  exports.RlsDatatableTitle = RlsDatatableTitle;
2110
2137
  exports.RlsDatatableTotals = RlsDatatableTotals;
2111
- exports.RlsDateField = RlsDateField;
2112
- exports.RlsDatePicker = RlsDatePicker;
2113
- exports.RlsDateRangeField = RlsDateRangeField;
2114
- exports.RlsDateRangePicker = RlsDateRangePicker;
2115
- exports.RlsDayPicker = RlsDayPicker;
2116
- exports.RlsDayRangePicker = RlsDayRangePicker;
2138
+ exports.RlsFieldAutocomplete = RlsFieldAutocomplete;
2139
+ exports.RlsFieldAutocompleteTemplate = RlsFieldAutocompleteTemplate;
2140
+ exports.RlsFieldDate = RlsFieldDate;
2141
+ exports.RlsFieldDateRange = RlsFieldDateRange;
2142
+ exports.RlsFieldMoney = RlsFieldMoney;
2143
+ exports.RlsFieldNumber = RlsFieldNumber;
2144
+ exports.RlsFieldPassword = RlsFieldPassword;
2145
+ exports.RlsFieldSelect = RlsFieldSelect;
2146
+ exports.RlsFieldSelectTemplate = RlsFieldSelectTemplate;
2147
+ exports.RlsFieldText = RlsFieldText;
2117
2148
  exports.RlsFormNavigation = RlsFormNavigation;
2118
2149
  exports.RlsIcon = RlsIcon;
2119
2150
  exports.RlsInput = RlsInput;
@@ -2122,32 +2153,31 @@ exports.RlsInputNumber = RlsInputNumber;
2122
2153
  exports.RlsInputPassword = RlsInputPassword;
2123
2154
  exports.RlsInputText = RlsInputText;
2124
2155
  exports.RlsLabel = RlsLabel;
2156
+ exports.RlsLabelCheckBox = RlsLabelCheckBox;
2157
+ exports.RlsLabelRadioButton = RlsLabelRadioButton;
2158
+ exports.RlsLabelSwitch = RlsLabelSwitch;
2125
2159
  exports.RlsMessageIcon = RlsMessageIcon;
2126
2160
  exports.RlsModal = RlsModal;
2127
- exports.RlsMoneyField = RlsMoneyField;
2128
- exports.RlsMonthPicker = RlsMonthPicker;
2129
- exports.RlsMonthTitlePicker = RlsMonthTitlePicker;
2130
- exports.RlsNumberField = RlsNumberField;
2131
2161
  exports.RlsPagination = RlsPagination;
2132
- exports.RlsPasswordField = RlsPasswordField;
2162
+ exports.RlsPickerDate = RlsPickerDate;
2163
+ exports.RlsPickerDateRange = RlsPickerDateRange;
2164
+ exports.RlsPickerDay = RlsPickerDay;
2165
+ exports.RlsPickerDayRange = RlsPickerDayRange;
2166
+ exports.RlsPickerMonth = RlsPickerMonth;
2167
+ exports.RlsPickerMonthTitle = RlsPickerMonthTitle;
2168
+ exports.RlsPickerYear = RlsPickerYear;
2133
2169
  exports.RlsPoster = RlsPoster;
2134
2170
  exports.RlsProgressBar = RlsProgressBar;
2135
2171
  exports.RlsProgressCircular = RlsProgressCircular;
2136
2172
  exports.RlsRadioButton = RlsRadioButton;
2137
- exports.RlsRadioButtonLabel = RlsRadioButtonLabel;
2138
2173
  exports.RlsSearchInput = RlsSearchInput;
2139
- exports.RlsSelectField = RlsSelectField;
2140
- exports.RlsSelectFieldTemplate = RlsSelectFieldTemplate;
2141
2174
  exports.RlsSkeleton = RlsSkeleton;
2142
2175
  exports.RlsSkeletonText = RlsSkeletonText;
2143
2176
  exports.RlsSnackbar = RlsSnackbar;
2144
2177
  exports.RlsSwitch = RlsSwitch;
2145
2178
  exports.RlsSwitchControl = RlsSwitchControl;
2146
- exports.RlsSwitchLabel = RlsSwitchLabel;
2147
2179
  exports.RlsTabularText = RlsTabularText;
2148
- exports.RlsTextField = RlsTextField;
2149
2180
  exports.RlsToolbar = RlsToolbar;
2150
- exports.RlsYearPicker = RlsYearPicker;
2151
2181
  exports.rangeFormatTemplate = rangeFormatTemplate;
2152
2182
  exports.renderClassStatus = renderClassStatus;
2153
2183
  exports.useConfirmationService = useConfirmationService;