@rolster/react-components 18.13.5 → 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 +1021 -1028
  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 +1002 -1009
  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} +2 -2
  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} +2 -2
  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,946 +298,906 @@ 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,
483
- label: helpersDate.MONTH_NAMES()[value],
484
- selected: date.getFullYear() === year && value === date.getMonth(),
485
- value
486
- };
487
- }
488
- function monthIsOutsideMin(props, month) {
489
- const { year, minDate } = props;
490
- return minDate
491
- ? minDate.getFullYear() === year && month < minDate.getMonth()
492
- : false;
493
- }
494
- function monthIsOutsideMax(props, month) {
495
- const { year, maxDate } = props;
496
- return maxDate
497
- ? maxDate.getFullYear() === year && month > maxDate.getMonth()
498
- : false;
499
- }
500
- function monthIsOutside(props, month) {
501
- return monthIsOutsideMin(props, month) || monthIsOutsideMax(props, month);
502
- }
503
- function checkMonthPicker(props) {
504
- const { maxDate, minDate, month } = props;
505
- return minDate && monthIsOutsideMin(props, month)
506
- ? minDate.getMonth()
507
- : maxDate && monthIsOutsideMax(props, month)
508
- ? maxDate.getMonth()
509
- : undefined;
510
- }
511
- function createMonthPicker(props) {
512
- return [
513
- createMonthState(props, helpersDate.Month.January),
514
- createMonthState(props, helpersDate.Month.February),
515
- createMonthState(props, helpersDate.Month.March),
516
- createMonthState(props, helpersDate.Month.April),
517
- createMonthState(props, helpersDate.Month.May),
518
- createMonthState(props, helpersDate.Month.June),
519
- createMonthState(props, helpersDate.Month.July),
520
- createMonthState(props, helpersDate.Month.August),
521
- createMonthState(props, helpersDate.Month.September),
522
- createMonthState(props, helpersDate.Month.October),
523
- createMonthState(props, helpersDate.Month.November),
524
- createMonthState(props, helpersDate.Month.December)
525
- ];
526
- }
527
- function monthIsLimitMin(props) {
528
- const { month, date, minDate } = props;
529
- if (helpersAdvanced.itIsDefined(month) && date) {
530
- const minYear = minDate ? minDate.getFullYear() : 0;
531
- const minMonth = minDate ? minDate.getMonth() : 0;
532
- return date.getFullYear() === minYear && month <= minMonth;
533
- }
534
- return false;
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
- };
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
550
  }
551
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;
552
+ function dateIsOutRangeMin(props) {
553
+ const { date, minDate } = props;
554
+ return !!minDate && helpersDate.dateIsBefore(helpersDate.normalizeMinTime(minDate), date);
583
555
  }
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
- };
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;
616
570
  }
617
571
 
618
- function createEmptyStore() {
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);
619
578
  return {
620
- coincidences: undefined,
621
- pattern: '',
622
- previous: null
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
623
585
  };
624
586
  }
625
- function searchForPattern(props) {
626
- const { pattern, store } = props;
627
- if (!store?.pattern) {
628
- return null;
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));
629
592
  }
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
- }
593
+ for (let end = date.getDay(); end < 7; end++) {
594
+ days.push(createDayState(props, today, day));
595
+ day++;
637
596
  }
638
- return newStore || createEmptyStore();
597
+ return { days };
639
598
  }
640
- function createStoreAutocomplete(props) {
641
- const { pattern, suggestions, reboot } = props;
642
- if (!pattern) {
643
- return { collection: suggestions, store: createEmptyStore() };
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));
644
604
  }
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
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;
654
621
  }
655
- };
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];
656
659
  }
657
660
 
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;
661
+ function dateIsSelected(base, date, day) {
662
+ return (date.getFullYear() === base.getFullYear() &&
663
+ date.getMonth() === base.getMonth() &&
664
+ day === date.getDate());
667
665
  }
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;
666
+ function sourceIsSelected({ sourceDate }, base, day) {
667
+ return dateIsSelected(base, sourceDate, day);
681
668
  }
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;
669
+ function rangeIsSelected({ range }, base, day) {
670
+ return (dateIsSelected(base, range.minDate, day) ||
671
+ dateIsSelected(base, range.maxDate, day));
701
672
  }
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;
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));
709
691
  }
710
- if (!locationListIsBottom(contentElement, listElement)) {
711
- inputElement?.focus();
692
+ for (let end = base.getDay(); end < 7; end++) {
693
+ days.push(createDayRangeState(props, base, day));
694
+ day++;
712
695
  }
713
- return position;
696
+ return { days };
714
697
  }
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;
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));
722
703
  }
723
- if (locationListIsBottom(contentElement, listElement)) {
724
- inputElement?.focus();
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
+ });
725
727
  }
726
- return POSITION_INITIAL;
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;
727
741
  }
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;
736
- }
742
+ function dayRangeIsOutside(props, day) {
743
+ return dayRangeIsOutsideMin(props, day) || dayRangeIsOutsideMax(props, day);
737
744
  }
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
- }
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];
748
750
  }
749
751
 
750
- class ListCollection {
751
- constructor(value) {
752
- this.value = value;
753
- }
754
- find(element) {
755
- return this.value.find((current) => current.compareTo(element));
752
+ function createMonthState(props, value) {
753
+ const { date, month, year } = props;
754
+ return {
755
+ disabled: monthIsOutside(props, value),
756
+ focused: value === month,
757
+ label: helpersDate.MONTH_NAMES()[value],
758
+ selected: date.getFullYear() === year && value === date.getMonth(),
759
+ value
760
+ };
761
+ }
762
+ function monthIsOutsideMin(props, month) {
763
+ const { year, minDate } = props;
764
+ return minDate
765
+ ? minDate.getFullYear() === year && month < minDate.getMonth()
766
+ : false;
767
+ }
768
+ function monthIsOutsideMax(props, month) {
769
+ const { year, maxDate } = props;
770
+ return maxDate
771
+ ? maxDate.getFullYear() === year && month > maxDate.getMonth()
772
+ : false;
773
+ }
774
+ function monthIsOutside(props, month) {
775
+ return monthIsOutsideMin(props, month) || monthIsOutsideMax(props, month);
776
+ }
777
+ function checkMonthPicker(props) {
778
+ const { maxDate, minDate, month } = props;
779
+ return minDate && monthIsOutsideMin(props, month)
780
+ ? minDate.getMonth()
781
+ : maxDate && monthIsOutsideMax(props, month)
782
+ ? maxDate.getMonth()
783
+ : undefined;
784
+ }
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
+ ];
800
+ }
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;
756
807
  }
808
+ return false;
809
+ }
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;
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
- }
884
-
885
- function RlsMonthTitlePicker({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
886
- const { limitNext, limitPrevious } = monthLimitTemplate({
887
- date,
888
- maxDate,
889
- minDate,
890
- month: monthControl.state
891
- });
892
- const monthName = helpersDate.MONTH_NAMES()[monthControl.state || 0];
893
- function onPreviousMonth() {
894
- if (helpersAdvanced.itIsDefined(monthControl.state) && helpersAdvanced.itIsDefined(yearControl.state)) {
895
- if (monthControl.state > helpersDate.Month.January) {
896
- monthControl.setState(monthControl.state - 1);
897
- }
898
- else {
899
- monthControl.setState(helpersDate.Month.December);
900
- yearControl.setState(yearControl.state - 1);
901
- }
902
- }
903
- }
904
- function onPreviousYear() {
905
- if (helpersAdvanced.itIsDefined(yearControl.state)) {
906
- yearControl.setState(yearControl.state - 1);
907
- }
908
- }
909
- function onPrevious() {
910
- type === 'month' ? onPreviousMonth() : onPreviousYear();
911
- }
912
- function onNextMonth() {
913
- if (helpersAdvanced.itIsDefined(monthControl.state) && helpersAdvanced.itIsDefined(yearControl.state)) {
914
- if (monthControl.state < helpersDate.Month.December) {
915
- monthControl.setState(monthControl.state + 1);
916
- }
917
- else {
918
- monthControl.setState(helpersDate.Month.January);
919
- yearControl.setState(yearControl.state + 1);
920
- }
921
- }
922
- }
923
- function onNextYear() {
924
- if (helpersAdvanced.itIsDefined(yearControl.state)) {
925
- yearControl.setState(yearControl.state + 1);
926
- }
927
- }
928
- function onNext() {
929
- type === 'month' ? onNextMonth() : onNextYear();
930
- }
931
- return (jsxRuntime.jsxs("div", { className: "rls-month-title-picker", children: [jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsxRuntime.jsx("span", { onClick: onClick, children: monthName }), jsxRuntime.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
932
- }
933
-
934
- function RlsNumberField({ children, disabled, formControl, placeholder, rlsTheme, value, onValue }) {
935
- return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-box-field', {
936
- focused: formControl?.focused,
937
- error: formControl?.wrong,
938
- disabled: formControl?.disabled || disabled
939
- }, 'rls-number-field'), "rls-theme": rlsTheme, children: [children && jsxRuntime.jsx("label", { className: "rls-box-field__label", children: children }), jsxRuntime.jsx("div", { className: "rls-box-field__component", children: jsxRuntime.jsx("div", { className: "rls-box-field__body", children: jsxRuntime.jsx(RlsInputNumber, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), formControl?.touched && formControl?.error && (jsxRuntime.jsx("div", { className: "rls-box-field__error", children: jsxRuntime.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl.error.message }) }))] }));
826
+ var PickerListenerType;
827
+ (function (PickerListenerType) {
828
+ PickerListenerType["Select"] = "PickerSelect";
829
+ PickerListenerType["Now"] = "PickerNow";
830
+ PickerListenerType["Cancel"] = "PickerCancel";
831
+ })(PickerListenerType || (PickerListenerType = {}));
832
+
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
+ };
940
890
  }
941
891
 
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) {
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
+ };
930
+ }
931
+
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);
1175
1142
  }
1176
1143
  }
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 })] }));
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))) }));
1181
1149
  }
1182
1150
 
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);
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
+ }
1191
1168
  }
1192
- else {
1193
- setChecked(!checked);
1169
+ }
1170
+ function onPreviousYear() {
1171
+ if (helpersAdvanced.itIsDefined(yearControl.state)) {
1172
+ yearControl.setState(yearControl.state - 1);
1194
1173
  }
1195
1174
  }
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))) }))] }));
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
+ }
1187
+ }
1188
+ }
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,7 +1446,7 @@ 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
1452
  const currentStore = react.useRef({
@@ -1507,115 +1585,30 @@ function useAutocompleteField({ disabled, formControl, onSelect, onValue, sugges
1507
1585
  };
1508
1586
  }
1509
1587
 
1510
- function RlsAutocompleteFieldTemplate({ suggestions, children, disabled, formControl, hiddenIcon, placeholder, searching, rlsTheme, onSearch, onSelect, onValue, render }) {
1511
- 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({
1512
1590
  suggestions,
1513
1591
  disabled,
1514
1592
  formControl,
1515
1593
  onSelect,
1516
1594
  onValue
1517
1595
  });
1518
- 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', {
1519
1597
  disabled,
1520
1598
  focused: listControl.focused,
1521
1599
  selected: !!listControl.value
1522
- }, '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', {
1523
1601
  visible: listControl.visible,
1524
1602
  hide: !listControl.visible,
1525
1603
  higher: listControl.higher
1526
- }), 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 } }) => {
1527
1605
  setPattern(value);
1528
1606
  }, disabled: disabled || searching, onFocus: onFocusInput, onBlur: onBlurInput, onKeyDown: onKeydownInput }), onSearch && (jsxRuntime.jsx("button", { disabled: disabled || searching, onClick: () => {
1529
1607
  onSearch(pattern);
1530
- }, 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 })] })] }));
1531
- }
1532
- function RlsAutocompleteField(props) {
1533
- return (jsxRuntime.jsx(RlsAutocompleteFieldTemplate, { ...props, render: (element) => (jsxRuntime.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: element.title })) }));
1534
- }
1535
-
1536
- function RlsCard({ children, outline, rlsTheme }) {
1537
- return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-card', { outline }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-card__content", children: children }) }));
1538
- }
1539
-
1540
- class ConfirmationResult extends helpersAdvanced.PartialSealed {
1541
- static approved() {
1542
- return new ConfirmationResult('approved');
1543
- }
1544
- static reject() {
1545
- return new ConfirmationResult('reject');
1546
- }
1547
- }
1548
- function RlsConfirmation({ approved, content, reject, rlsTheme, subtitle, title, visible }) {
1549
- return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-confirmation', { visible }), "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("div", { className: "rls-confirmation__component", children: [jsxRuntime.jsxs("div", { className: "rls-confirmation__header", children: [title && (jsxRuntime.jsx("div", { className: "rls-confirmation__header__title", children: title })), subtitle && (jsxRuntime.jsx("div", { className: "rls-confirmation__header__subtitle", children: subtitle }))] }), jsxRuntime.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntime.jsx("div", { className: "rls-confirmation__body__content", children: content })) }), (approved || reject) && (jsxRuntime.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntime.jsxs("div", { className: "rls-confirmation__footer__actions", children: [approved && (jsxRuntime.jsx(RlsButton, { type: "raised", onClick: () => {
1550
- if (approved.onClick) {
1551
- approved.onClick();
1552
- }
1553
- }, children: approved.label })), reject && (jsxRuntime.jsx(RlsButton, { type: "outline", onClick: () => {
1554
- if (reject.onClick) {
1555
- reject.onClick();
1556
- }
1557
- }, children: reject.label }))] }) }))] }), jsxRuntime.jsx("div", { className: "rls-confirmation__backdrop" })] }));
1558
- }
1559
- function useConfirmationService() {
1560
- const [config, setConfig] = react.useState({});
1561
- const [visible, setVisible] = react.useState(false);
1562
- const rlsConfirmation = ReactDOM.createPortal(jsxRuntime.jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
1563
- function confirmation(config) {
1564
- return new Promise((resolve) => {
1565
- const { content, rlsTheme, subtitle, title, approved, reject } = config;
1566
- setConfig({
1567
- content,
1568
- rlsTheme,
1569
- subtitle,
1570
- title,
1571
- approved: {
1572
- label: approved || reactI18n('confirmationActionApproved'),
1573
- onClick: () => {
1574
- setVisible(false);
1575
- resolve(ConfirmationResult.approved());
1576
- }
1577
- },
1578
- reject: reject
1579
- ? {
1580
- label: reject,
1581
- onClick: () => {
1582
- setVisible(false);
1583
- resolve(ConfirmationResult.reject());
1584
- }
1585
- }
1586
- : undefined
1587
- });
1588
- setVisible(true);
1589
- });
1590
- }
1591
- return {
1592
- RlsConfirmation: rlsConfirmation,
1593
- confirmation
1594
- };
1595
- }
1596
-
1597
- function RlsDatatableHeader({ children }) {
1598
- return jsxRuntime.jsx("tr", { className: "rls-datatable__header", children: children });
1599
- }
1600
- function RlsDatatableTitle({ children, className, control }) {
1601
- return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__title', { control }, className).trim(), children: children }));
1602
- }
1603
- function RlsDatatableData({ children, className, error }) {
1604
- return (jsxRuntime.jsx("tr", { className: renderClassStatus('rls-datatable__data', { error }, className).trim(), children: children }));
1605
- }
1606
- function RlsDatatableCell({ children, className, control, overflow }) {
1607
- return (jsxRuntime.jsx("th", { className: renderClassStatus('rls-datatable__cell', { control, overflow }, className).trim(), children: children }));
1608
- }
1609
- function RlsDatatableTotals({ children, className, error }) {
1610
- return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-datatable__totals', { error }, className).trim(), children: children }));
1611
- }
1612
- function RlsDatatableInfo({ children, className, control, overflow }) {
1613
- return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-datatable__info', { control, overflow }, className).trim(), children: children }));
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 })] })] }));
1614
1609
  }
1615
- function RlsDatatable({ children, datatable, footer, header, rlsTheme, summary }) {
1616
- return (jsxRuntime.jsxs("div", { className: renderClassStatus('rls-datatable', {
1617
- scrolleable: datatable?.scrolleable
1618
- }), "rls-theme": rlsTheme, children: [jsxRuntime.jsxs("table", { children: [header && jsxRuntime.jsx("thead", { className: "rls-datatable__thead", children: header }), jsxRuntime.jsx("tbody", { ref: datatable?.bodyRef, className: "rls-datatable__tbody", children: children })] }), summary && jsxRuntime.jsx("div", { className: "rls-datatable__tsummary", children: summary }), footer && jsxRuntime.jsx("div", { className: "rls-datatable__tfooter", children: footer })] }));
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 })) }));
1619
1612
  }
1620
1613
 
1621
1614
  function rangeFormatTemplate({ maxDate, minDate }) {
@@ -1721,7 +1714,7 @@ function useReactControl(controlProps, controlValidators) {
1721
1714
  }
1722
1715
 
1723
1716
  const FORMAT_DESCRIPTION = '{dw}, {mx} {dd} de {aa}';
1724
- function RlsDatePicker({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
1717
+ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
1725
1718
  const today = new Date(); // Initial current date in component
1726
1719
  const dateInitial = formControl?.state || date || today;
1727
1720
  const yearControl = useReactControl(dateInitial.getFullYear());
@@ -1782,18 +1775,18 @@ function RlsDatePicker({ automatic, date, disabled, formControl, maxDate, minDat
1782
1775
  onListener({ type: PickerListenerType.Select, value });
1783
1776
  }
1784
1777
  }
1785
- 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', {
1786
1779
  day: visibility === 'DAY',
1787
1780
  month: visibility === 'MONTH',
1788
1781
  year: visibility === 'YEAR'
1789
- }), 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') }) })] }) })] }));
1790
1783
  }
1791
1784
 
1792
1785
  function RlsModal({ children, visible, rlsTheme }) {
1793
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);
1794
1787
  }
1795
1788
 
1796
- function RlsDateField({ children, date, disabled, formControl, maxDate, minDate, onValue, placeholder, rlsTheme }) {
1789
+ function RlsFieldDate({ children, date, disabled, formControl, maxDate, minDate, onValue, placeholder, rlsTheme }) {
1797
1790
  const today = new Date(); // Initial current date in component
1798
1791
  const [value, setValue] = react.useState();
1799
1792
  const [modalIsVisible, setModalIsVisible] = react.useState(false);
@@ -1829,7 +1822,7 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
1829
1822
  setModalIsVisible(true);
1830
1823
  }
1831
1824
  }
1832
- 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 }) => {
1833
1826
  if (type !== PickerListenerType.Cancel) {
1834
1827
  onChange(value, true);
1835
1828
  }
@@ -1840,7 +1833,7 @@ function RlsDateField({ children, date, disabled, formControl, maxDate, minDate,
1840
1833
  } }) })] }));
1841
1834
  }
1842
1835
 
1843
- function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
1836
+ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
1844
1837
  const dateInitial = helpersDate.normalizeMinTime(datePicker || new Date());
1845
1838
  const rangeInitial = formControl?.state || helpersDate.DateRange.now();
1846
1839
  const yearControl = useReactControl(dateInitial.getFullYear());
@@ -1889,16 +1882,16 @@ function RlsDateRangePicker({ automatic, date: datePicker, disabled, formControl
1889
1882
  onListener({ type: PickerListenerType.Select, value });
1890
1883
  }
1891
1884
  }
1892
- 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', {
1893
1886
  day: visibility === 'DAY',
1894
1887
  month: visibility === 'MONTH',
1895
1888
  year: visibility === 'YEAR'
1896
- }), 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', {
1897
1890
  automatic
1898
- }), 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') }) })] }) })] }));
1899
1892
  }
1900
1893
 
1901
- function RlsDateRangeField({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
1894
+ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, maxDate, minDate, placeholder, rlsTheme }) {
1902
1895
  const currentRange = formControl?.state || helpersDate.DateRange.now();
1903
1896
  const currentDate = datePicker || new Date();
1904
1897
  const [value, setValue] = react.useState(currentRange);
@@ -1915,7 +1908,7 @@ function RlsDateRangeField({ children, date: datePicker, disabled, formControl,
1915
1908
  setModalIsVisible(true);
1916
1909
  }
1917
1910
  }
1918
- 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 }) => {
1919
1912
  if (value) {
1920
1913
  setValue(value);
1921
1914
  }
@@ -1923,11 +1916,7 @@ function RlsDateRangeField({ children, date: datePicker, disabled, formControl,
1923
1916
  } }) })] }));
1924
1917
  }
1925
1918
 
1926
- function RlsFormNavigation({ children, visible, rlsTheme }) {
1927
- return (jsxRuntime.jsx("div", { className: renderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsxRuntime.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
1928
- }
1929
-
1930
- function useSelectField({ suggestions, formControl, onSelect, onValue }) {
1919
+ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
1931
1920
  const listControl = useListControl({ suggestions, formControl });
1932
1921
  const { collection, inputRef, visible, navigationElement, navigationInput, setFocused, setValue, setVisible } = listControl;
1933
1922
  const initializedState = react.useRef(false);
@@ -2038,24 +2027,28 @@ function useSelectField({ suggestions, formControl, onSelect, onValue }) {
2038
2027
  };
2039
2028
  }
2040
2029
 
2041
- function RlsSelectFieldTemplate({ suggestions, children, disabled, formControl, placeholder, rlsTheme, onSelect, onValue, render }) {
2042
- 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({
2043
2032
  suggestions,
2044
2033
  disabled,
2045
2034
  formControl,
2046
2035
  onSelect,
2047
2036
  onValue
2048
2037
  });
2049
- 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', {
2050
2039
  visible: listControl.visible
2051
- }), 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', {
2052
2041
  visible: listControl.visible,
2053
2042
  hide: !listControl.visible,
2054
2043
  higher: listControl.higher
2055
- }), 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 })] })] }));
2056
2045
  }
2057
- function RlsSelectField(props) {
2058
- 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 }) }));
2059
2052
  }
2060
2053
 
2061
2054
  const DURATION_ANIMATION = 240;
@@ -2122,8 +2115,6 @@ function RlsApplication({ children }) {
2122
2115
  exports.ConfirmationResult = ConfirmationResult;
2123
2116
  exports.RlsAmount = RlsAmount;
2124
2117
  exports.RlsApplication = RlsApplication;
2125
- exports.RlsAutocompleteField = RlsAutocompleteField;
2126
- exports.RlsAutocompleteFieldTemplate = RlsAutocompleteFieldTemplate;
2127
2118
  exports.RlsAvatar = RlsAvatar;
2128
2119
  exports.RlsBadge = RlsBadge;
2129
2120
  exports.RlsBallot = RlsBallot;
@@ -2135,7 +2126,6 @@ exports.RlsButtonToggle = RlsButtonToggle;
2135
2126
  exports.RlsCard = RlsCard;
2136
2127
  exports.RlsCheckBox = RlsCheckBox;
2137
2128
  exports.RlsCheckBoxControl = RlsCheckBoxControl;
2138
- exports.RlsCheckBoxLabel = RlsCheckBoxLabel;
2139
2129
  exports.RlsConfirmation = RlsConfirmation;
2140
2130
  exports.RlsContext = RlsContext;
2141
2131
  exports.RlsDatatable = RlsDatatable;
@@ -2145,12 +2135,16 @@ exports.RlsDatatableHeader = RlsDatatableHeader;
2145
2135
  exports.RlsDatatableInfo = RlsDatatableInfo;
2146
2136
  exports.RlsDatatableTitle = RlsDatatableTitle;
2147
2137
  exports.RlsDatatableTotals = RlsDatatableTotals;
2148
- exports.RlsDateField = RlsDateField;
2149
- exports.RlsDatePicker = RlsDatePicker;
2150
- exports.RlsDateRangeField = RlsDateRangeField;
2151
- exports.RlsDateRangePicker = RlsDateRangePicker;
2152
- exports.RlsDayPicker = RlsDayPicker;
2153
- 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;
2154
2148
  exports.RlsFormNavigation = RlsFormNavigation;
2155
2149
  exports.RlsIcon = RlsIcon;
2156
2150
  exports.RlsInput = RlsInput;
@@ -2159,32 +2153,31 @@ exports.RlsInputNumber = RlsInputNumber;
2159
2153
  exports.RlsInputPassword = RlsInputPassword;
2160
2154
  exports.RlsInputText = RlsInputText;
2161
2155
  exports.RlsLabel = RlsLabel;
2156
+ exports.RlsLabelCheckBox = RlsLabelCheckBox;
2157
+ exports.RlsLabelRadioButton = RlsLabelRadioButton;
2158
+ exports.RlsLabelSwitch = RlsLabelSwitch;
2162
2159
  exports.RlsMessageIcon = RlsMessageIcon;
2163
2160
  exports.RlsModal = RlsModal;
2164
- exports.RlsMoneyField = RlsMoneyField;
2165
- exports.RlsMonthPicker = RlsMonthPicker;
2166
- exports.RlsMonthTitlePicker = RlsMonthTitlePicker;
2167
- exports.RlsNumberField = RlsNumberField;
2168
2161
  exports.RlsPagination = RlsPagination;
2169
- 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;
2170
2169
  exports.RlsPoster = RlsPoster;
2171
2170
  exports.RlsProgressBar = RlsProgressBar;
2172
2171
  exports.RlsProgressCircular = RlsProgressCircular;
2173
2172
  exports.RlsRadioButton = RlsRadioButton;
2174
- exports.RlsRadioButtonLabel = RlsRadioButtonLabel;
2175
2173
  exports.RlsSearchInput = RlsSearchInput;
2176
- exports.RlsSelectField = RlsSelectField;
2177
- exports.RlsSelectFieldTemplate = RlsSelectFieldTemplate;
2178
2174
  exports.RlsSkeleton = RlsSkeleton;
2179
2175
  exports.RlsSkeletonText = RlsSkeletonText;
2180
2176
  exports.RlsSnackbar = RlsSnackbar;
2181
2177
  exports.RlsSwitch = RlsSwitch;
2182
2178
  exports.RlsSwitchControl = RlsSwitchControl;
2183
- exports.RlsSwitchLabel = RlsSwitchLabel;
2184
2179
  exports.RlsTabularText = RlsTabularText;
2185
- exports.RlsTextField = RlsTextField;
2186
2180
  exports.RlsToolbar = RlsToolbar;
2187
- exports.RlsYearPicker = RlsYearPicker;
2188
2181
  exports.rangeFormatTemplate = rangeFormatTemplate;
2189
2182
  exports.renderClassStatus = renderClassStatus;
2190
2183
  exports.useConfirmationService = useConfirmationService;