@rolster/react-components 18.20.7 → 18.21.5

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 (138) hide show
  1. package/dist/cjs/assets/{index-Cp7p-Y-D.css → index-B4R0Qgg4.css} +21 -21
  2. package/dist/cjs/index.js +1080 -651
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/es/assets/{index-Cp7p-Y-D.css → index-B4R0Qgg4.css} +21 -21
  5. package/dist/es/index.js +1078 -649
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/esm/components/atoms/Avatar/Avatar.js +6 -2
  8. package/dist/esm/components/atoms/Avatar/Avatar.js.map +1 -1
  9. package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.js +10 -3
  10. package/dist/esm/components/atoms/Breadcrumb/Breadcrumb.js.map +1 -1
  11. package/dist/esm/components/atoms/Button/Button.js +6 -2
  12. package/dist/esm/components/atoms/Button/Button.js.map +1 -1
  13. package/dist/esm/components/atoms/CheckBox/CheckBox.css +1 -1
  14. package/dist/esm/components/atoms/CheckBox/CheckBox.js +10 -5
  15. package/dist/esm/components/atoms/CheckBox/CheckBox.js.map +1 -1
  16. package/dist/esm/components/atoms/Icon/Icon.js +6 -2
  17. package/dist/esm/components/atoms/Icon/Icon.js.map +1 -1
  18. package/dist/esm/components/atoms/Input/Input.js +9 -6
  19. package/dist/esm/components/atoms/Input/Input.js.map +1 -1
  20. package/dist/esm/components/atoms/InputPassword/InputPassword.js +8 -5
  21. package/dist/esm/components/atoms/InputPassword/InputPassword.js.map +1 -1
  22. package/dist/esm/components/atoms/Poster/Poster.js +6 -2
  23. package/dist/esm/components/atoms/Poster/Poster.js.map +1 -1
  24. package/dist/esm/components/atoms/ProgressBar/ProgressBar.js +6 -2
  25. package/dist/esm/components/atoms/ProgressBar/ProgressBar.js.map +1 -1
  26. package/dist/esm/components/atoms/RadioButton/RadioButton.css +1 -1
  27. package/dist/esm/components/atoms/RadioButton/RadioButton.js +6 -2
  28. package/dist/esm/components/atoms/RadioButton/RadioButton.js.map +1 -1
  29. package/dist/esm/components/atoms/Switch/Switch.css +1 -1
  30. package/dist/esm/components/atoms/Switch/Switch.js +10 -5
  31. package/dist/esm/components/atoms/Switch/Switch.js.map +1 -1
  32. package/dist/esm/components/definitions.d.ts +1 -1
  33. package/dist/esm/components/molecules/Alert/Alert.js +7 -3
  34. package/dist/esm/components/molecules/Alert/Alert.js.map +1 -1
  35. package/dist/esm/components/molecules/Ballot/Ballot.js +8 -3
  36. package/dist/esm/components/molecules/Ballot/Ballot.js.map +1 -1
  37. package/dist/esm/components/molecules/ButtonProgress/ButtonProgress.js +8 -3
  38. package/dist/esm/components/molecules/ButtonProgress/ButtonProgress.js.map +1 -1
  39. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.css +2 -2
  40. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.d.ts +1 -1
  41. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js +11 -9
  42. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js.map +1 -1
  43. package/dist/esm/components/molecules/FieldMoney/FieldMoney.js +14 -5
  44. package/dist/esm/components/molecules/FieldMoney/FieldMoney.js.map +1 -1
  45. package/dist/esm/components/molecules/FieldNumber/FieldNumber.js +14 -5
  46. package/dist/esm/components/molecules/FieldNumber/FieldNumber.js.map +1 -1
  47. package/dist/esm/components/molecules/FieldPassword/FieldPassword.js +15 -6
  48. package/dist/esm/components/molecules/FieldPassword/FieldPassword.js.map +1 -1
  49. package/dist/esm/components/molecules/FieldText/FieldText.js +14 -5
  50. package/dist/esm/components/molecules/FieldText/FieldText.js.map +1 -1
  51. package/dist/esm/components/molecules/LabelCheckBox/LabelCheckBox.js +7 -7
  52. package/dist/esm/components/molecules/LabelCheckBox/LabelCheckBox.js.map +1 -1
  53. package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.js +7 -7
  54. package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.js.map +1 -1
  55. package/dist/esm/components/molecules/LabelSwitch/LabelSwitch.js +7 -7
  56. package/dist/esm/components/molecules/LabelSwitch/LabelSwitch.js.map +1 -1
  57. package/dist/esm/components/molecules/MessageFormError/MessageFormError.js +16 -2
  58. package/dist/esm/components/molecules/MessageFormError/MessageFormError.js.map +1 -1
  59. package/dist/esm/components/molecules/Pagination/Pagination.js +23 -32
  60. package/dist/esm/components/molecules/Pagination/Pagination.js.map +1 -1
  61. package/dist/esm/components/molecules/PickerDay/PickerDay.d.ts +1 -1
  62. package/dist/esm/components/molecules/PickerDay/PickerDay.js +53 -24
  63. package/dist/esm/components/molecules/PickerDay/PickerDay.js.map +1 -1
  64. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.d.ts +1 -1
  65. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js +55 -29
  66. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js.map +1 -1
  67. package/dist/esm/components/molecules/PickerMonth/PickerMonth.d.ts +1 -1
  68. package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +57 -34
  69. package/dist/esm/components/molecules/PickerMonth/PickerMonth.js.map +1 -1
  70. package/dist/esm/components/molecules/{PickerMonthTitle/PickerMonthTitle.css → PickerSelectorTitle/PickerSelectorTitle.css} +3 -3
  71. package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.d.ts +15 -0
  72. package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.js +65 -0
  73. package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.js.map +1 -0
  74. package/dist/esm/components/molecules/PickerYear/PickerYear.css +7 -7
  75. package/dist/esm/components/molecules/PickerYear/PickerYear.d.ts +1 -1
  76. package/dist/esm/components/molecules/PickerYear/PickerYear.js +45 -38
  77. package/dist/esm/components/molecules/PickerYear/PickerYear.js.map +1 -1
  78. package/dist/esm/components/molecules/index.d.ts +1 -1
  79. package/dist/esm/components/molecules/index.js +1 -1
  80. package/dist/esm/components/molecules/index.js.map +1 -1
  81. package/dist/esm/components/organisms/Card/Card.js +6 -2
  82. package/dist/esm/components/organisms/Card/Card.js.map +1 -1
  83. package/dist/esm/components/organisms/Confirmation/Confirmation.css +5 -5
  84. package/dist/esm/components/organisms/Confirmation/Confirmation.d.ts +1 -1
  85. package/dist/esm/components/organisms/Confirmation/Confirmation.js +7 -4
  86. package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
  87. package/dist/esm/components/organisms/Datatable/Datatable.js +31 -9
  88. package/dist/esm/components/organisms/Datatable/Datatable.js.map +1 -1
  89. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.d.ts +5 -5
  90. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +43 -18
  91. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
  92. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js +50 -41
  93. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js.map +1 -1
  94. package/dist/esm/components/organisms/FieldDate/FieldDate.d.ts +5 -4
  95. package/dist/esm/components/organisms/FieldDate/FieldDate.js +39 -30
  96. package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
  97. package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.d.ts +5 -4
  98. package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +35 -26
  99. package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js.map +1 -1
  100. package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +35 -13
  101. package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
  102. package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js +41 -29
  103. package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js.map +1 -1
  104. package/dist/esm/components/organisms/FormNavigation/FormNavigation.js +6 -2
  105. package/dist/esm/components/organisms/FormNavigation/FormNavigation.js.map +1 -1
  106. package/dist/esm/components/organisms/Modal/Modal.js +6 -2
  107. package/dist/esm/components/organisms/Modal/Modal.js.map +1 -1
  108. package/dist/esm/components/organisms/PickerDate/PickerDate.css +1 -1
  109. package/dist/esm/components/organisms/PickerDate/PickerDate.js +76 -53
  110. package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
  111. package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.d.ts +1 -1
  112. package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js +61 -40
  113. package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js.map +1 -1
  114. package/dist/esm/components/organisms/Snackbar/Snackbar.d.ts +1 -1
  115. package/dist/esm/components/organisms/Snackbar/Snackbar.js +32 -22
  116. package/dist/esm/components/organisms/Snackbar/Snackbar.js.map +1 -1
  117. package/dist/esm/context.js +6 -5
  118. package/dist/esm/context.js.map +1 -1
  119. package/dist/esm/controllers/ListController.js +7 -5
  120. package/dist/esm/controllers/ListController.js.map +1 -1
  121. package/dist/esm/controllers/index.d.ts +0 -1
  122. package/dist/esm/controllers/index.js +0 -1
  123. package/dist/esm/controllers/index.js.map +1 -1
  124. package/dist/esm/helpers/css.js +7 -10
  125. package/dist/esm/helpers/css.js.map +1 -1
  126. package/dist/esm/helpers/index.d.ts +1 -0
  127. package/dist/esm/helpers/index.js +1 -0
  128. package/dist/esm/helpers/index.js.map +1 -1
  129. package/dist/esm/helpers/language.d.ts +4 -0
  130. package/dist/esm/helpers/language.js +102 -0
  131. package/dist/esm/helpers/language.js.map +1 -0
  132. package/package.json +6 -6
  133. package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.d.ts +0 -15
  134. package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js +0 -53
  135. package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js.map +0 -1
  136. package/dist/esm/controllers/RenderClassStatusController.d.ts +0 -2
  137. package/dist/esm/controllers/RenderClassStatusController.js +0 -10
  138. package/dist/esm/controllers/RenderClassStatusController.js.map +0 -1
package/dist/es/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import require$$0, { useState, useEffect, useRef, useCallback, createContext } from 'react';
1
+ import require$$0, { useState, useEffect, useMemo, useCallback, useRef, createContext } from 'react';
2
2
  import { currencyFormat, itIsDefined, PartialSealed } from '@rolster/commons';
3
- import { ListCollection, locationListCanTop, navigationListFromInput, navigationListFromElement, PaginationController, verifyDayPicker, createDayPicker, createDayRangePicker, verifyMonthPicker, createMonthPicker, monthLimitTemplate, createYearPicker, verifyYearPicker, createAutocompleteStore, verifyDateRange, dateOutRange, PickerListenerEvent } from '@rolster/components';
4
3
  import { dateFormatTemplate, DAY_LABELS, DateRange, normalizeMinTime, assignDayInDate, dateIsBefore, MONTH_NAMES, Month, assignYearInDate, assignMonthInDate } from '@rolster/dates';
4
+ import { i18n, i18nSubscribe } from '@rolster/i18n';
5
+ import { PaginationController, verifyDayPicker, createDayPicker, createDayRangePicker, verifyMonthPicker, createMonthPicker, monthLimitTemplate, createYearPicker, verifyYearPicker, ListCollection, locationListCanTop, navigationListFromInput, navigationListFromElement, createAutocompleteStore, dateOutRange, verifyDateRange, PickerListenerEvent } from '@rolster/components';
5
6
  import ReactDOM from 'react-dom';
6
- import { i18n } from '@rolster/i18n';
7
7
  import { useReactControl } from '@rolster/react-forms';
8
8
 
9
9
  var jsxRuntime = {exports: {}};
@@ -1361,151 +1361,16 @@ function RlsAmount({ value, decimals, rlsTheme, symbol }) {
1361
1361
  return (jsxRuntimeExports.jsxs("div", { className: "rls-amount", "rls-theme": rlsTheme, children: [symbol && jsxRuntimeExports.jsx("span", { children: symbol }), jsxRuntimeExports.jsx(RlsTabularText, { value: currencyFormat({ value, decimals }) })] }));
1362
1362
  }
1363
1363
 
1364
- function createObserver(options) {
1365
- const { setScrolleable, table } = options;
1366
- const observer = new ResizeObserver(() => {
1367
- const scrollHeight = table.scrollHeight || 0;
1368
- const clientHeight = table.clientHeight || 0;
1369
- setScrolleable(scrollHeight > clientHeight);
1370
- });
1371
- observer.observe(table);
1372
- return observer;
1373
- }
1374
- function useDatatable() {
1375
- const [scrolleable, setScrolleable] = useState(false);
1376
- const tableRef = useRef(null);
1377
- useEffect(() => {
1378
- const observer = tableRef?.current &&
1379
- createObserver({ setScrolleable, table: tableRef?.current });
1380
- return () => {
1381
- observer?.disconnect();
1382
- };
1383
- }, []);
1384
- return { scrolleable, tableRef };
1385
- }
1386
-
1387
- function useListController(props) {
1388
- const { suggestions, automatic, formControl, reference } = props;
1389
- const listIsOpen = useRef(false);
1390
- const contentRef = useRef(null);
1391
- const listRef = useRef(null);
1392
- const inputRef = useRef(null);
1393
- const [collection, setCollection] = useState(new ListCollection(suggestions));
1394
- const [state, refreshState] = useState({
1395
- focused: false,
1396
- higher: false,
1397
- value: '',
1398
- modalIsVisible: false
1399
- });
1400
- const position = useRef(0);
1401
- const valueProtected = useRef();
1402
- const changeValueInternal = useRef(false);
1403
- useEffect(() => {
1404
- function onCloseSuggestions({ target }) {
1405
- !contentRef?.current?.contains(target) &&
1406
- refreshState((state) => ({ ...state, modalIsVisible: false }));
1407
- }
1408
- document.addEventListener('click', onCloseSuggestions);
1409
- return () => {
1410
- document.removeEventListener('click', onCloseSuggestions);
1411
- };
1412
- }, []);
1413
- useEffect(() => {
1414
- if (!listIsOpen.current && state.modalIsVisible) {
1415
- listIsOpen.current = true;
1416
- }
1417
- if (listIsOpen.current && !state.modalIsVisible) {
1418
- formControl?.touch();
1419
- }
1420
- refreshState((state) => ({
1421
- ...state,
1422
- higher: locationListCanTop(contentRef.current, listRef.current)
1423
- }));
1424
- }, [state.modalIsVisible]);
1425
- useEffect(() => {
1426
- setCollection(new ListCollection(suggestions, reference));
1427
- }, [suggestions]);
1428
- useEffect(() => {
1429
- if (!changeValueInternal.current) {
1430
- if (formControl?.value) {
1431
- const element = collection.find(formControl.value);
1432
- if (!element) {
1433
- valueProtected.current = formControl.value;
1434
- automatic
1435
- ? setFormValue(collection.value[0], true)
1436
- : setFormValue(undefined);
1437
- }
1438
- else {
1439
- refreshState((state) => ({ ...state, value: element.description }));
1440
- }
1441
- }
1442
- else if (valueProtected.current) {
1443
- const element = collection.find(valueProtected.current);
1444
- element && setFormValue(element);
1445
- }
1446
- else {
1447
- automatic && setFormValue(collection.value[0], true);
1448
- }
1449
- }
1450
- changeValueInternal.current = false;
1451
- }, [collection, formControl?.value]);
1452
- const setState = useCallback((state) => {
1453
- refreshState((_state) => ({ ..._state, ...state }));
1454
- }, []);
1455
- const setFormValue = useCallback((element, initialValue = false) => {
1456
- refreshState((state) => ({
1457
- ...state,
1458
- value: element?.description || ''
1459
- }));
1460
- changeValueInternal.current = true;
1461
- initialValue
1462
- ? formControl?.setInitialValue(element?.value)
1463
- : formControl?.setValue(element?.value);
1464
- }, [formControl]);
1465
- const navigationInput = useCallback((event) => {
1466
- if (state.modalIsVisible) {
1467
- const _position = navigationListFromInput({
1468
- content: contentRef.current,
1469
- event: event,
1470
- list: listRef.current
1471
- });
1472
- position.current = _position ?? 0;
1473
- }
1474
- }, [state.modalIsVisible]);
1475
- const navigationElement = useCallback((event) => {
1476
- position.current = navigationListFromElement({
1477
- content: contentRef.current,
1478
- event: event,
1479
- input: inputRef.current,
1480
- list: listRef.current,
1481
- position: position.current
1482
- });
1483
- }, [state.modalIsVisible]);
1484
- return {
1485
- ...state,
1486
- contentRef,
1487
- inputRef,
1488
- listRef,
1489
- navigationElement,
1490
- navigationInput,
1491
- setFormValue,
1492
- setState
1493
- };
1494
- }
1495
-
1496
1364
  function renderClassStatus(base, status = {}, additionals) {
1497
- const resultClass = [base];
1365
+ const _classElement = [base];
1498
1366
  Object.entries(status).forEach(([key, state]) => {
1499
- if (state) {
1500
- typeof state === 'string'
1501
- ? resultClass.push(`${base}--${state}`)
1502
- : resultClass.push(`${base}--${key}`);
1503
- }
1367
+ state &&
1368
+ (typeof state === 'string'
1369
+ ? _classElement.push(`${base}--${state}`)
1370
+ : _classElement.push(`${base}--${key}`));
1504
1371
  });
1505
- if (additionals) {
1506
- resultClass.push(additionals);
1507
- }
1508
- return resultClass.join(' ');
1372
+ additionals && _classElement.push(additionals);
1373
+ return _classElement.join(' ').trim();
1509
1374
  }
1510
1375
 
1511
1376
  const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
@@ -1516,34 +1381,142 @@ function rangeFormatTemplate({ maxDate, minDate }) {
1516
1381
  return `${minFormat} - ${maxFormat}`;
1517
1382
  }
1518
1383
 
1519
- function useRenderClassStatus(base, status = {}, additionals) {
1520
- const [className, setClassName] = useState('');
1521
- useEffect(() => {
1522
- setClassName(renderClassStatus(base, status, additionals));
1523
- }, [base, Object.values(status), additionals]);
1524
- return className;
1384
+ const errorsDictionary = {
1385
+ es: {
1386
+ alphabetic: 'Campo solo permite caracteres',
1387
+ alphanumber: 'Campo solo permite caracteres y número',
1388
+ decimal: 'Campo debe ser número decimal',
1389
+ defined: 'Campo debe estar definido',
1390
+ email: 'Campo debe ser correo electrónico',
1391
+ greaterThanValue: 'Campo debe tener un valor mayor a {thanValue}',
1392
+ greaterOrEqualsThanValue: 'Campo debe tener un valor mayor o igual a {thanValue}',
1393
+ lessThanValue: 'Campo debe tener un valor menor a {thanValue}',
1394
+ lessOrEqualsThanValue: 'Campo debe tener un valor menor o igual a {thanValue}',
1395
+ maxValue: 'Campo debe tener un valor máximo de {thanValue}',
1396
+ minValue: 'Campo debe tener un valor mínimo de {thanValue}',
1397
+ nickname: 'Campo inválido para nombre de usuario',
1398
+ onlynumber: 'Campo debe ser númerico',
1399
+ password: 'Campo no permitido para password',
1400
+ reqlength: 'Campo debe tener {length} caracter(es)',
1401
+ required: 'Campo es requerido',
1402
+ strMinlength: 'Campo debe tener mínimo {length} caracter(es)',
1403
+ strMaxlength: 'Campo debe tener máximo {length} caracter(es)',
1404
+ textonly: 'Campo solo permite caracteres (sin espacio)',
1405
+ _unknown: 'Campo inválido {error}'
1406
+ },
1407
+ en: {
1408
+ alphabetic: 'Field only allows characters',
1409
+ alphanumber: 'Field only allows characters and number',
1410
+ decimal: 'Field must be decimal number',
1411
+ defined: 'Field must be defined',
1412
+ email: 'Field must be email',
1413
+ greaterThanValue: 'Field must have a value greater than {thanValue}',
1414
+ greaterOrEqualsThanValue: 'Field must have a value greater than or equal to {thanValue}',
1415
+ lessThanValue: 'Field must have a value less than {thanValue}',
1416
+ lessOrEqualsThanValue: 'Field must have a value less than or equal to {thanValue}',
1417
+ minValue: 'Field must have a minimum value of {thanValue}',
1418
+ maxValue: 'Field must have a maximum value of {thanValue}',
1419
+ nickname: 'Invalid field for username',
1420
+ onlynumber: 'Field must be numeric',
1421
+ password: 'Field not allowed for password',
1422
+ reqlength: 'Field must be {length} characters',
1423
+ required: 'Field is required',
1424
+ strMinlength: 'Field must have minimum {length} characters',
1425
+ strMaxlength: 'Field must have maximum {length} characters',
1426
+ textonly: 'Field only allows characters (no space)',
1427
+ _unknown: 'Invalid field {error}'
1428
+ },
1429
+ fr: {
1430
+ alphabetic: 'Field only allows characters',
1431
+ alphanumber: 'Field only allows characters and number',
1432
+ decimal: 'Field must be decimal number',
1433
+ defined: 'Field must be defined',
1434
+ email: 'Field must be email',
1435
+ greaterThanValue: 'Field must have a value greater than {thanValue}',
1436
+ greaterOrEqualsThanValue: 'Field must have a value greater than or equal to {thanValue}',
1437
+ lessThanValue: 'Field must have a value less than {thanValue}',
1438
+ lessOrEqualsThanValue: 'Field must have a value less than or equal to {thanValue}',
1439
+ minValue: 'Field must have a minimum value of {thanValue}',
1440
+ maxValue: 'Field must have a maximum value of {thanValue}',
1441
+ nickname: 'Invalid field for username',
1442
+ onlynumber: 'Field must be numeric',
1443
+ password: 'Field not allowed for password',
1444
+ reqlength: 'Field must be {length} characters',
1445
+ required: 'Field is required',
1446
+ strMinlength: 'Field must have minimum {length} characters',
1447
+ strMaxlength: 'Field must have maximum {length} characters',
1448
+ textonly: 'Field only allows characters (no space)',
1449
+ _unknown: 'Invalid field {error}'
1450
+ },
1451
+ pt: {
1452
+ alphabetic: 'Field only allows characters',
1453
+ alphanumber: 'Field only allows characters and number',
1454
+ decimal: 'Field must be decimal number',
1455
+ defined: 'Field must be defined',
1456
+ email: 'Field must be email',
1457
+ greaterThanValue: 'Field must have a value greater than {thanValue}',
1458
+ greaterOrEqualsThanValue: 'Field must have a value greater than or equal to {thanValue}',
1459
+ lessThanValue: 'Field must have a value less than {thanValue}',
1460
+ lessOrEqualsThanValue: 'Field must have a value less than or equal to {thanValue}',
1461
+ minValue: 'Field must have a minimum value of {thanValue}',
1462
+ maxValue: 'Field must have a maximum value of {thanValue}',
1463
+ nickname: 'Invalid field for username',
1464
+ onlynumber: 'Field must be numeric',
1465
+ password: 'Field not allowed for password',
1466
+ reqlength: 'Field must be {thanValue} characters',
1467
+ required: 'Field is required',
1468
+ strMinlength: 'Field must have minimum {thanValue} characters',
1469
+ strMaxlength: 'Field must have maximum {thanValue} characters',
1470
+ textonly: 'Field only allows characters (no space)',
1471
+ _unknown: 'Invalid field {error}'
1472
+ }
1473
+ };
1474
+ let _msgErrorsI18n = i18n(errorsDictionary);
1475
+ function setErrorsI18n(dictionary) {
1476
+ _msgErrorsI18n = i18n(Object.entries(errorsDictionary).reduce((_dictionary, [key, value]) => {
1477
+ _dictionary[key] = { ...value, ...dictionary[key] };
1478
+ return _dictionary;
1479
+ }, {}));
1480
+ }
1481
+ function msgErrorsI18n(key, language, interpolators) {
1482
+ return _msgErrorsI18n(key, { language, interpolators });
1525
1483
  }
1526
1484
 
1527
1485
  function RlsAvatar({ children, rounded, skeleton, rlsTheme }) {
1528
- return (jsxRuntimeExports.jsx("div", { className: useRenderClassStatus('rls-avatar', { rounded, skeleton }), "rls-theme": rlsTheme, children: children }));
1486
+ const className = useMemo(() => {
1487
+ return renderClassStatus('rls-avatar', { rounded, skeleton });
1488
+ }, [rounded, skeleton]);
1489
+ return (jsxRuntimeExports.jsx("div", { className: className, "rls-theme": rlsTheme, children: children }));
1529
1490
  }
1530
1491
 
1531
1492
  function RlsBadge({ children, rlsTheme }) {
1532
1493
  return (jsxRuntimeExports.jsx("div", { className: "rls-badge", "rls-theme": rlsTheme, children: children }));
1533
1494
  }
1534
1495
 
1496
+ function RlsBreadcrumbLabel({ label }) {
1497
+ const className = useMemo(() => {
1498
+ return renderClassStatus('rls-breadcrumb__label__a', {
1499
+ actionable: !!label.onClick
1500
+ });
1501
+ }, [label.onClick]);
1502
+ return (jsxRuntimeExports.jsx("label", { className: "rls-breadcrumb__label", onClick: label.onClick, children: jsxRuntimeExports.jsx("a", { className: className, children: label.label }) }));
1503
+ }
1535
1504
  function RlsBreadcrumb({ labels }) {
1536
- return (jsxRuntimeExports.jsx("div", { className: "rls-breadcrumb", children: labels.map(({ label, onClick }, index) => (jsxRuntimeExports.jsx("label", { className: "rls-breadcrumb__label", onClick: onClick, children: jsxRuntimeExports.jsx("a", { className: renderClassStatus('rls-breadcrumb__label__a', {
1537
- actionable: !!onClick
1538
- }), children: label }) }, index))) }));
1505
+ return (jsxRuntimeExports.jsx("div", { className: "rls-breadcrumb", children: labels.map((label, index) => (jsxRuntimeExports.jsx(RlsBreadcrumbLabel, { label: label }, index))) }));
1539
1506
  }
1540
1507
 
1541
1508
  function RlsIcon({ value, skeleton }) {
1542
- return (jsxRuntimeExports.jsx("div", { className: useRenderClassStatus('rls-icon', { skeleton }), children: jsxRuntimeExports.jsx("i", { className: `rls-icon-${value}` }) }));
1509
+ const className = useMemo(() => {
1510
+ return renderClassStatus('rls-icon', { skeleton });
1511
+ }, [skeleton]);
1512
+ return (jsxRuntimeExports.jsx("div", { className: className, children: jsxRuntimeExports.jsx("i", { className: `rls-icon-${value}` }) }));
1543
1513
  }
1544
1514
 
1545
1515
  function RlsButton({ type, children, disabled, identifier, prefixIcon, suffixIcon, rlsTheme, onClick }) {
1546
- return (jsxRuntimeExports.jsx("button", { id: identifier, className: "rls-button", onClick: onClick, "rls-theme": rlsTheme, disabled: disabled, children: jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-button__content', { type }), children: [prefixIcon && jsxRuntimeExports.jsx(RlsIcon, { value: prefixIcon }), children && jsxRuntimeExports.jsx("div", { className: "rls-button__label", children: children }), suffixIcon && jsxRuntimeExports.jsx(RlsIcon, { value: suffixIcon })] }) }));
1516
+ const className = useMemo(() => {
1517
+ return renderClassStatus('rls-button__content', { type });
1518
+ }, [type]);
1519
+ return (jsxRuntimeExports.jsx("button", { id: identifier, className: "rls-button", onClick: onClick, "rls-theme": rlsTheme, disabled: disabled, children: jsxRuntimeExports.jsxs("div", { className: className, children: [prefixIcon && jsxRuntimeExports.jsx(RlsIcon, { value: prefixIcon }), children && jsxRuntimeExports.jsx("div", { className: "rls-button__label", children: children }), suffixIcon && jsxRuntimeExports.jsx(RlsIcon, { value: suffixIcon })] }) }));
1547
1520
  }
1548
1521
 
1549
1522
  function RlsButtonAction({ icon, disabled, identifier, onClick, tooltip }) {
@@ -1551,12 +1524,16 @@ function RlsButtonAction({ icon, disabled, identifier, onClick, tooltip }) {
1551
1524
  }
1552
1525
 
1553
1526
  function RlsCheckBox({ checked, disabled, identifier, onClick, rlsTheme }) {
1554
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: useRenderClassStatus('rls-checkbox', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-checkbox__component" }) }));
1527
+ const className = useMemo(() => {
1528
+ return renderClassStatus('rls-checkbox', { checked, disabled });
1529
+ }, [checked, disabled]);
1530
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: className, onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-checkbox__component" }) }));
1555
1531
  }
1556
1532
  function RlsCheckBoxControl({ formControl, disabled, identifier, rlsTheme }) {
1557
- return (jsxRuntimeExports.jsx(RlsCheckBox, { identifier: identifier, checked: !!formControl.value, disabled: disabled, onClick: () => {
1558
- formControl.setValue(!formControl.value);
1559
- }, rlsTheme: rlsTheme }));
1533
+ const onClick = useCallback(() => {
1534
+ formControl.setValue(!formControl.value);
1535
+ }, [formControl.value]);
1536
+ return (jsxRuntimeExports.jsx(RlsCheckBox, { identifier: identifier, checked: !!formControl.value, disabled: disabled, onClick: onClick, rlsTheme: rlsTheme }));
1560
1537
  }
1561
1538
 
1562
1539
  function RlsInput({ children, disabled, formControl, identifier, onValue, placeholder, type, value }) {
@@ -1574,10 +1551,13 @@ function RlsInput({ children, disabled, formControl, identifier, onValue, placeh
1574
1551
  formControl?.blur();
1575
1552
  setFocused(() => false);
1576
1553
  }, [formControl]);
1577
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: useRenderClassStatus('rls-input', {
1578
- focused: formControl?.focused ?? focused,
1579
- disabled: formControl?.disabled || disabled
1580
- }), children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type ?? 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: formControl?.value || value || '' }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
1554
+ const className = useMemo(() => {
1555
+ return renderClassStatus('rls-input', {
1556
+ disabled: formControl?.disabled || disabled,
1557
+ focused: formControl?.focused ?? focused
1558
+ });
1559
+ }, [formControl?.focused, formControl?.disabled, focused, disabled]);
1560
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, children: [jsxRuntimeExports.jsx("input", { ref: formControl?.elementRef, className: "rls-input__component", autoComplete: "off", type: type ?? 'text', placeholder: placeholder, disabled: formControl?.disabled || disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange, value: formControl?.value || value || '' }), jsxRuntimeExports.jsx("span", { className: "rls-input__value", children: children })] }));
1581
1561
  }
1582
1562
 
1583
1563
  function RlsInputMoney({ decimals, disabled, formControl, identifier, onValue, placeholder, symbol, value }) {
@@ -1612,10 +1592,13 @@ function RlsInputPassword({ disabled, formControl, identifier, onValue, placehol
1612
1592
  formControl?.blur();
1613
1593
  setFocused(() => false);
1614
1594
  }, [formControl]);
1615
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: renderClassStatus('rls-input-password', {
1616
- focused: formControl?.focused ?? focused,
1617
- disabled: formControl?.disabled || disabled
1618
- }), children: jsxRuntimeExports.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type ?? 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
1595
+ const className = useMemo(() => {
1596
+ return renderClassStatus('rls-input-password', {
1597
+ disabled: formControl?.disabled || disabled,
1598
+ focused: formControl?.focused ?? focused
1599
+ });
1600
+ }, [formControl?.focused, formControl?.disabled, focused, disabled]);
1601
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: className, children: jsxRuntimeExports.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type ?? 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
1619
1602
  }
1620
1603
 
1621
1604
  function RlsInputSearch({ formControl, identifier, onSearch, placeholder }) {
@@ -1644,11 +1627,17 @@ function RlsMessageIcon({ icon, children, rlsTheme }) {
1644
1627
  }
1645
1628
 
1646
1629
  function RlsPoster({ children, contrast, outline, rlsTheme }) {
1647
- return (jsxRuntimeExports.jsx("div", { className: useRenderClassStatus('rls-poster', { contrast, outline }), "rls-theme": rlsTheme, children: children }));
1630
+ const className = useMemo(() => {
1631
+ return renderClassStatus('rls-poster', { contrast, outline });
1632
+ }, [contrast, outline]);
1633
+ return (jsxRuntimeExports.jsx("div", { className: className, "rls-theme": rlsTheme, children: children }));
1648
1634
  }
1649
1635
 
1650
1636
  function RlsProgressBar({ indeterminate, percentage, rlsTheme }) {
1651
- return (jsxRuntimeExports.jsx("div", { className: useRenderClassStatus('rls-progress-bar', { indeterminate }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-progress-bar__component", style: { width: `${percentage || 0}%` } }) }));
1637
+ const className = useMemo(() => {
1638
+ return renderClassStatus('rls-progress-bar', { indeterminate });
1639
+ }, [indeterminate]);
1640
+ return (jsxRuntimeExports.jsx("div", { className: className, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-progress-bar__component", style: { width: `${percentage || 0}%` } }) }));
1652
1641
  }
1653
1642
 
1654
1643
  function RlsProgressCircular({ rlsTheme }) {
@@ -1656,7 +1645,10 @@ function RlsProgressCircular({ rlsTheme }) {
1656
1645
  }
1657
1646
 
1658
1647
  function RlsRadioButton({ checked, disabled, identifier, rlsTheme, onClick }) {
1659
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: useRenderClassStatus('rls-radiobutton', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-radiobutton__component" }) }));
1648
+ const className = useMemo(() => {
1649
+ return renderClassStatus('rls-radiobutton', { checked, disabled });
1650
+ }, [checked, disabled]);
1651
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: className, onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-radiobutton__component" }) }));
1660
1652
  }
1661
1653
 
1662
1654
  function RlsSkeleton({ rlsTheme }) {
@@ -1668,30 +1660,42 @@ function RlsSkeletonText({ active, children, rlsTheme }) {
1668
1660
  }
1669
1661
 
1670
1662
  function RlsSwitch({ checked, disabled, identifier, onClick, rlsTheme }) {
1671
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: useRenderClassStatus('rls-switch', { checked, disabled }), onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsxs("div", { className: "rls-switch__component", children: [jsxRuntimeExports.jsx("div", { className: "rls-switch__component__element" }), jsxRuntimeExports.jsx("div", { className: "rls-switch__component__bar" })] }) }));
1663
+ const className = useMemo(() => {
1664
+ return renderClassStatus('rls-switch', { checked, disabled });
1665
+ }, [checked, disabled]);
1666
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: className, onClick: onClick, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsxs("div", { className: "rls-switch__component", children: [jsxRuntimeExports.jsx("div", { className: "rls-switch__component__element" }), jsxRuntimeExports.jsx("div", { className: "rls-switch__component__bar" })] }) }));
1672
1667
  }
1673
1668
  function RlsSwitchControl({ formControl, disabled, identifier, rlsTheme }) {
1674
- return (jsxRuntimeExports.jsx(RlsSwitch, { identifier: identifier, checked: formControl.value || false, disabled: disabled, onClick: () => {
1675
- formControl.setValue(!formControl.value);
1676
- }, rlsTheme: rlsTheme }));
1669
+ const onClick = useCallback(() => {
1670
+ formControl.setValue(!formControl.value);
1671
+ }, [formControl.value]);
1672
+ return (jsxRuntimeExports.jsx(RlsSwitch, { identifier: identifier, checked: formControl.value || false, disabled: disabled, onClick: onClick, rlsTheme: rlsTheme }));
1677
1673
  }
1678
1674
 
1679
1675
  function RlsAlert({ bordered, children, icon, identifier, rlsTheme }) {
1680
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: useRenderClassStatus('rls-alert', { bordered }), "rls-theme": rlsTheme, children: [icon && (jsxRuntimeExports.jsx("div", { className: "rls-alert__icon", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) })), jsxRuntimeExports.jsx("div", { className: "rls-alert__content", children: children })] }));
1676
+ const className = useMemo(() => {
1677
+ return renderClassStatus('rls-alert', { bordered });
1678
+ }, [bordered]);
1679
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [icon && (jsxRuntimeExports.jsx("div", { className: "rls-alert__icon", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) })), jsxRuntimeExports.jsx("div", { className: "rls-alert__content", children: children })] }));
1681
1680
  }
1682
1681
 
1683
1682
  function RlsBallot({ bordered, children, img, initials, skeleton, subtitle, rlsTheme }) {
1684
- return (jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-ballot', { bordered, skeleton }), "rls-theme": rlsTheme, children: [(img || initials) && (jsxRuntimeExports.jsxs(RlsAvatar, { skeleton: skeleton, children: [img && jsxRuntimeExports.jsx("img", { src: img }), initials && jsxRuntimeExports.jsx("span", { children: initials })] })), jsxRuntimeExports.jsxs("div", { className: "rls-ballot__component", children: [jsxRuntimeExports.jsx("label", { className: "rls-ballot__title", children: jsxRuntimeExports.jsx(RlsSkeletonText, { active: skeleton, children: children }) }), subtitle && (jsxRuntimeExports.jsx("label", { className: "rls-ballot__subtitle", children: jsxRuntimeExports.jsx(RlsSkeletonText, { active: skeleton, children: jsxRuntimeExports.jsx("span", { children: subtitle }) }) }))] })] }));
1683
+ const className = useMemo(() => {
1684
+ return renderClassStatus('rls-ballot', { bordered, skeleton });
1685
+ }, [bordered, skeleton]);
1686
+ return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [(img || initials) && (jsxRuntimeExports.jsxs(RlsAvatar, { skeleton: skeleton, children: [img && jsxRuntimeExports.jsx("img", { src: img }), initials && jsxRuntimeExports.jsx("span", { children: initials })] })), jsxRuntimeExports.jsxs("div", { className: "rls-ballot__component", children: [jsxRuntimeExports.jsx("label", { className: "rls-ballot__title", children: jsxRuntimeExports.jsx(RlsSkeletonText, { active: skeleton, children: children }) }), subtitle && (jsxRuntimeExports.jsx("label", { className: "rls-ballot__subtitle", children: jsxRuntimeExports.jsx(RlsSkeletonText, { active: skeleton, children: jsxRuntimeExports.jsx("span", { children: subtitle }) }) }))] })] }));
1685
1687
  }
1686
1688
 
1687
1689
  function RlsButtonProgress({ icon, disabled, onClick, progressing, rlsTheme }) {
1688
- return (jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-button-progress', { progressing }), "rls-theme": rlsTheme, children: [!progressing && (jsxRuntimeExports.jsx(RlsButtonAction, { icon: icon, onClick: onClick, disabled: disabled })), progressing && jsxRuntimeExports.jsx(RlsProgressCircular, {})] }));
1690
+ const className = useMemo(() => {
1691
+ return renderClassStatus('rls-button-progress', { progressing });
1692
+ }, [progressing]);
1693
+ return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [!progressing && (jsxRuntimeExports.jsx(RlsButtonAction, { icon: icon, onClick: onClick, disabled: disabled })), progressing && jsxRuntimeExports.jsx(RlsProgressCircular, {})] }));
1689
1694
  }
1690
1695
 
1691
1696
  function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsTheme }) {
1692
1697
  const componentRef = useRef(null);
1693
- const [firstAction] = options;
1694
- const [action, setAction] = useState(firstAction);
1698
+ const [action, setAction] = useState(options[0]);
1695
1699
  const [visible, setVisible] = useState(false);
1696
1700
  useEffect(() => {
1697
1701
  function onCloseMenu({ target }) {
@@ -1702,6 +1706,12 @@ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsThem
1702
1706
  document.removeEventListener('click', onCloseMenu);
1703
1707
  };
1704
1708
  }, []);
1709
+ const classNameList = useMemo(() => {
1710
+ return renderClassStatus('rls-button-toggle__list', {
1711
+ hide: !visible,
1712
+ visible
1713
+ });
1714
+ }, [visible]);
1705
1715
  const onClickMenu = useCallback(() => {
1706
1716
  setVisible((visible) => !visible);
1707
1717
  }, []);
@@ -1712,34 +1722,58 @@ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsThem
1712
1722
  }, [onAction, automatic]);
1713
1723
  return (jsxRuntimeExports.jsxs("div", { className: "rls-button-toggle", ref: componentRef, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-button-toggle__content", children: [action && (jsxRuntimeExports.jsx("div", { className: "rls-button-toggle__action", children: jsxRuntimeExports.jsx(RlsButton, { disabled: disabled, type: type, onClick: () => {
1714
1724
  onAction(action.value);
1715
- }, children: action.label }) })), jsxRuntimeExports.jsx("div", { className: "rls-button-toggle__icon", children: jsxRuntimeExports.jsx(RlsButton, { type: type, prefixIcon: "arrow-ios-down", disabled: disabled, onClick: onClickMenu }) })] }), jsxRuntimeExports.jsx("div", { className: useRenderClassStatus('rls-button-toggle__list', {
1716
- visible,
1717
- hide: !visible
1718
- }), children: jsxRuntimeExports.jsx("ul", { children: options.map((action, index) => (jsxRuntimeExports.jsx("li", { className: "truncate", onClick: () => {
1725
+ }, children: action.label }) })), jsxRuntimeExports.jsx("div", { className: "rls-button-toggle__icon", children: jsxRuntimeExports.jsx(RlsButton, { type: type, prefixIcon: "arrow-ios-down", disabled: disabled, onClick: onClickMenu }) })] }), jsxRuntimeExports.jsx("div", { className: classNameList, children: jsxRuntimeExports.jsx("ul", { children: options.map((action, index) => (jsxRuntimeExports.jsx("li", { className: "truncate", onClick: () => {
1719
1726
  onSelectAction(action);
1720
1727
  }, children: action.label }, index))) }) })] }));
1721
1728
  }
1722
1729
 
1723
1730
  function RlsMessageFormError({ className, formControl }) {
1724
- return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: formControl?.wrong && (jsxRuntimeExports.jsx("div", { className: className, children: jsxRuntimeExports.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: formControl?.error?.message }) })) }));
1731
+ const [language, setLanguage] = useState('es');
1732
+ useEffect(() => {
1733
+ return i18nSubscribe((language) => {
1734
+ setLanguage(language);
1735
+ });
1736
+ }, []);
1737
+ const msgError = useMemo(() => {
1738
+ return (formControl?.error &&
1739
+ (msgErrorsI18n(formControl.error.id, language, formControl.error.data) ??
1740
+ msgErrorsI18n('_unknown', language, { error: formControl.error.id })));
1741
+ }, [formControl?.error, language]);
1742
+ return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: formControl?.wrong && (jsxRuntimeExports.jsx("div", { className: className, children: jsxRuntimeExports.jsx(RlsMessageIcon, { icon: "alert-triangle", rlsTheme: "danger", children: msgError }) })) }));
1725
1743
  }
1726
1744
 
1727
1745
  function RlsFieldMoney({ children, decimals, disabled, formControl, identifier, msgErrorDisabled, onValue, placeholder, symbol, rlsTheme, value }) {
1728
- const _disabled = formControl?.disabled || disabled;
1729
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: useRenderClassStatus('rls-field-box', {
1746
+ const className = useMemo(() => {
1747
+ const _disabled = formControl?.disabled || disabled;
1748
+ return renderClassStatus('rls-field-box', {
1730
1749
  focused: formControl?.focused && !_disabled,
1731
1750
  error: formControl?.wrong,
1732
1751
  disabled: _disabled
1733
- }, 'rls-field-money'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputMoney, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, symbol: symbol, decimals: decimals, onValue: onValue }) }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1752
+ }, 'rls-field-money');
1753
+ }, [
1754
+ formControl?.focused,
1755
+ formControl?.wrong,
1756
+ formControl?.disabled,
1757
+ disabled
1758
+ ]);
1759
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputMoney, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, symbol: symbol, decimals: decimals, onValue: onValue }) }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1734
1760
  }
1735
1761
 
1736
1762
  function RlsFieldNumber({ children, disabled, formControl, identifier, msgErrorDisabled, onValue, placeholder, rlsTheme, value }) {
1737
- const _disabled = formControl?.disabled || disabled;
1738
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: useRenderClassStatus('rls-field-box', {
1763
+ const className = useMemo(() => {
1764
+ const _disabled = formControl?.disabled || disabled;
1765
+ return renderClassStatus('rls-field-box', {
1739
1766
  focused: formControl?.focused && !_disabled,
1740
1767
  error: formControl?.wrong,
1741
1768
  disabled: _disabled
1742
- }, 'rls-field-number'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputNumber, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1769
+ }, 'rls-field-number');
1770
+ }, [
1771
+ formControl?.focused,
1772
+ formControl?.wrong,
1773
+ formControl?.disabled,
1774
+ disabled
1775
+ ]);
1776
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputNumber, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1743
1777
  }
1744
1778
 
1745
1779
  function RlsFieldPassword({ children, disabled, formControl, identifier, msgErrorDisabled, placeholder, rlsTheme }) {
@@ -1747,21 +1781,37 @@ function RlsFieldPassword({ children, disabled, formControl, identifier, msgErro
1747
1781
  const onToggleInput = useCallback(() => {
1748
1782
  setPassword((password) => !password);
1749
1783
  }, []);
1750
- const _disabled = formControl?.disabled || disabled;
1751
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: useRenderClassStatus(' rls-field-box', {
1784
+ const className = useMemo(() => {
1785
+ const _disabled = formControl?.disabled || disabled;
1786
+ return renderClassStatus('rls-field-box', {
1752
1787
  focused: formControl?.focused && !_disabled,
1753
1788
  error: formControl?.wrong,
1754
1789
  disabled: _disabled
1755
- }, 'rls-field-password'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx(RlsInputPassword, { formControl: formControl, disabled: disabled, placeholder: placeholder, type: password ? 'password' : 'text' }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: password ? 'eye' : 'eye-off', onClick: onToggleInput })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1790
+ }, 'rls-field-password');
1791
+ }, [
1792
+ formControl?.focused,
1793
+ formControl?.wrong,
1794
+ formControl?.disabled,
1795
+ disabled
1796
+ ]);
1797
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx(RlsInputPassword, { formControl: formControl, disabled: disabled, placeholder: placeholder, type: password ? 'password' : 'text' }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: password ? 'eye' : 'eye-off', onClick: onToggleInput })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1756
1798
  }
1757
1799
 
1758
1800
  function RlsFieldText({ children, disabled, formControl, identifier, msgErrorDisabled, onValue, placeholder, rlsTheme, value }) {
1759
- const _disabled = formControl?.disabled || disabled;
1760
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: useRenderClassStatus('rls-field-box', {
1801
+ const className = useMemo(() => {
1802
+ const _disabled = formControl?.disabled || disabled;
1803
+ return renderClassStatus('rls-field-box', {
1761
1804
  focused: formControl?.focused && !_disabled,
1762
1805
  error: formControl?.wrong,
1763
1806
  disabled: _disabled
1764
- }, 'rls-field-text'), "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputText, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1807
+ }, 'rls-field-text');
1808
+ }, [
1809
+ formControl?.focused,
1810
+ formControl?.wrong,
1811
+ formControl?.disabled,
1812
+ disabled
1813
+ ]);
1814
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsx("div", { className: "rls-field-box__body", children: jsxRuntimeExports.jsx(RlsInputText, { formControl: formControl, value: value, disabled: disabled, placeholder: placeholder, onValue: onValue }) }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }));
1765
1815
  }
1766
1816
 
1767
1817
  function RlsLabelCheckBox({ children, disabled, extended, identifier, formControl, rlsTheme }) {
@@ -1774,10 +1824,10 @@ function RlsLabelCheckBox({ children, disabled, extended, identifier, formContro
1774
1824
  ? formControl?.setValue(!formControl.value)
1775
1825
  : setChecked((checked) => !checked);
1776
1826
  }, [formControl]);
1777
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: useRenderClassStatus('rls-label-checkbox', {
1778
- disabled,
1779
- extended
1780
- }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-label-checkbox__component", onClick: onToggle, children: jsxRuntimeExports.jsx(RlsCheckBox, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-label-checkbox__text", children: children })] }));
1827
+ const className = useMemo(() => {
1828
+ return renderClassStatus('rls-label-checkbox', { disabled, extended });
1829
+ }, [disabled, extended]);
1830
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-label-checkbox__component", onClick: onToggle, children: jsxRuntimeExports.jsx(RlsCheckBox, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-label-checkbox__text", children: children })] }));
1781
1831
  }
1782
1832
 
1783
1833
  function RlsLabelRadioButton({ children, disabled, extended, identifier, formControl, rlsTheme, value }) {
@@ -1788,10 +1838,10 @@ function RlsLabelRadioButton({ children, disabled, extended, identifier, formCon
1788
1838
  const onSelect = useCallback(() => {
1789
1839
  formControl && formControl?.setValue(value);
1790
1840
  }, [formControl, value]);
1791
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: useRenderClassStatus('rls-label-radiobutton', {
1792
- disabled,
1793
- extended
1794
- }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-label-radiobutton__component", onClick: onSelect, children: jsxRuntimeExports.jsx(RlsRadioButton, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-label-radiobutton__text", children: children })] }));
1841
+ const className = useMemo(() => {
1842
+ return renderClassStatus('rls-label-radiobutton', { disabled, extended });
1843
+ }, [disabled, extended]);
1844
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-label-radiobutton__component", onClick: onSelect, children: jsxRuntimeExports.jsx(RlsRadioButton, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-label-radiobutton__text", children: children })] }));
1795
1845
  }
1796
1846
 
1797
1847
  function RlsLabelSwitch({ children, disabled, extended, identifier, formControl, rlsTheme }) {
@@ -1804,62 +1854,53 @@ function RlsLabelSwitch({ children, disabled, extended, identifier, formControl,
1804
1854
  ? formControl?.setValue(!formControl.value)
1805
1855
  : setChecked((checked) => !checked);
1806
1856
  }, [formControl]);
1807
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: useRenderClassStatus('rls-label-switch', {
1808
- disabled,
1809
- extended
1810
- }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-label-switch__component", onClick: onToggle, children: jsxRuntimeExports.jsx(RlsSwitch, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-label-switch__text", children: children })] }));
1857
+ const className = useMemo(() => {
1858
+ return renderClassStatus('rls-label-switch', { disabled, extended });
1859
+ }, [disabled, extended]);
1860
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: className, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-label-switch__component", onClick: onToggle, children: jsxRuntimeExports.jsx(RlsSwitch, { checked: checked, disabled: disabled }) }), jsxRuntimeExports.jsx("label", { className: "rls-label-switch__text", children: children })] }));
1811
1861
  }
1812
1862
 
1813
1863
  function RlsPagination({ suggestions, count, filter, onPagination }) {
1814
1864
  const controller = useRef(new PaginationController({ suggestions, count }));
1815
1865
  const [template, setTemplate] = useState(controller.current.template);
1866
+ const refreshTemplate = useCallback((template, suggestions) => {
1867
+ const { firstPage, lastPage } = template;
1868
+ onPagination && onPagination({ firstPage, lastPage, suggestions });
1869
+ setTemplate(template);
1870
+ }, [onPagination]);
1816
1871
  useEffect(() => {
1817
1872
  controller.current = new PaginationController({
1818
1873
  suggestions,
1819
1874
  count,
1820
1875
  position: template.currentPage.value
1821
1876
  });
1822
- onPagination &&
1823
- onPagination({
1824
- firstPage: controller.current.template.firstPage,
1825
- lastPage: controller.current.template.lastPage,
1826
- suggestions: controller.current.page.collection
1827
- });
1828
- setTemplate(controller.current.template);
1877
+ refreshTemplate(controller.current.template, controller.current.page.collection);
1829
1878
  }, [suggestions, count]);
1830
1879
  useEffect(() => {
1831
1880
  refreshPagination(controller.current.filtrable(filter));
1832
1881
  }, [filter]);
1833
- function refreshPagination(pagination) {
1882
+ const refreshPagination = useCallback((pagination) => {
1834
1883
  if (pagination) {
1835
- const { page, template } = pagination;
1836
- const { firstPage, lastPage } = template;
1837
- onPagination &&
1838
- onPagination({
1839
- firstPage,
1840
- lastPage,
1841
- suggestions: page.collection
1842
- });
1843
- setTemplate(template);
1884
+ refreshTemplate(pagination.template, pagination.page.collection);
1844
1885
  }
1845
- }
1846
- function goToPagination(page) {
1886
+ }, []);
1887
+ const goToPagination = useCallback((page) => {
1847
1888
  refreshPagination(controller.current.goToPage(page));
1848
- }
1849
- function goFirstPagination() {
1889
+ }, []);
1890
+ const goFirstPagination = useCallback(() => {
1850
1891
  refreshPagination(controller.current.goFirstPage());
1851
- }
1852
- function goPreviousPagination() {
1892
+ }, []);
1893
+ const goPreviousPagination = useCallback(() => {
1853
1894
  refreshPagination(controller.current.goPreviousPage());
1854
- }
1855
- function goNextPagination() {
1895
+ }, []);
1896
+ const goNextPagination = useCallback(() => {
1856
1897
  refreshPagination(controller.current.goNextPage());
1857
- }
1858
- function goLastPagination() {
1898
+ }, []);
1899
+ const goLastPagination = useCallback(() => {
1859
1900
  refreshPagination(controller.current.goLastPage());
1860
- }
1901
+ }, []);
1861
1902
  return (jsxRuntimeExports.jsxs("div", { className: "rls-pagination", children: [jsxRuntimeExports.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goFirstPagination, disabled: template.firstPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrowhead-left" }) }), jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: template.firstPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-pagination__pages", children: template.pages.map((page, index) => {
1862
- return (jsxRuntimeExports.jsx("div", { className: useRenderClassStatus('rls-pagination__page', {
1903
+ return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-pagination__page', {
1863
1904
  active: page.active
1864
1905
  }), onClick: () => {
1865
1906
  goToPagination(page);
@@ -1867,10 +1908,45 @@ function RlsPagination({ suggestions, count, filter, onPagination }) {
1867
1908
  }) }), jsxRuntimeExports.jsx("div", { className: "rls-pagination__description", children: template.description }), jsxRuntimeExports.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goNextPagination, disabled: template.lastPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-right" }) }), jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goLastPagination, disabled: template.lastPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrowhead-right" }) })] })] }));
1868
1909
  }
1869
1910
 
1870
- function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, month, minDate, onValue, rlsTheme, year }) {
1871
- const currentDate = date || new Date(); // Initial date
1911
+ function RlsPickerDayItem({ day, onSelect, disabled }) {
1912
+ const className = useMemo(() => {
1913
+ return renderClassStatus('rls-picker-day__element', {
1914
+ disabled: day.disabled || disabled,
1915
+ focused: day.focused,
1916
+ forbidden: day.forbidden,
1917
+ selected: day.selected,
1918
+ today: day.today
1919
+ });
1920
+ }, [
1921
+ day.disabled,
1922
+ day.focused,
1923
+ day.forbidden,
1924
+ day.selected,
1925
+ day.today,
1926
+ disabled
1927
+ ]);
1928
+ const onClick = useCallback(() => {
1929
+ day.value && !day.disabled && !disabled && onSelect(day.value);
1930
+ }, [day.value, day.disabled, disabled, onSelect]);
1931
+ return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day__element__span", children: day.value || '??' }) }));
1932
+ }
1933
+ function RlsPickerDayHeaders() {
1934
+ return (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__header", children: DAY_LABELS().map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-picker-day__label", children: title }, index))) }));
1935
+ }
1936
+ function RlsPickerDay({ date: _date, disabled, formControl, maxDate, month, minDate, onValue, rlsTheme, year }) {
1937
+ const date = useMemo(() => _date ?? new Date(), [_date]);
1872
1938
  const [weeks, setWeeks] = useState([]);
1873
- const [value, setValue] = useState(formControl?.value || currentDate.getDate());
1939
+ const [value, setValue] = useState(formControl?.value || date.getDate());
1940
+ const [headers, setHeaders] = useState(jsxRuntimeExports.jsx(RlsPickerDayHeaders, {}));
1941
+ const [component, setComponent] = useState(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}));
1942
+ useEffect(() => {
1943
+ return i18nSubscribe(() => {
1944
+ setHeaders(jsxRuntimeExports.jsx(RlsPickerDayHeaders, {}));
1945
+ });
1946
+ }, []);
1947
+ useEffect(() => {
1948
+ setComponent(jsxRuntimeExports.jsx("div", { className: "rls-picker-day__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__week", children: days.map((day, index) => (jsxRuntimeExports.jsx(RlsPickerDayItem, { day: day, onSelect: onSelect, disabled: disabled }, index))) }, index))) }));
1949
+ }, [weeks]);
1874
1950
  useEffect(() => {
1875
1951
  const options = createPickerOptions();
1876
1952
  const day = verifyDayPicker(options);
@@ -1880,125 +1956,175 @@ function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, mo
1880
1956
  const day = verifyDayPicker(createPickerOptions());
1881
1957
  day
1882
1958
  ? formControl?.setValue(day)
1883
- : setValue(formControl?.value || currentDate.getDate());
1959
+ : setValue(formControl?.value || date.getDate());
1884
1960
  }, [formControl?.value]);
1885
- function createPickerOptions() {
1961
+ const createPickerOptions = useCallback(() => {
1886
1962
  return {
1887
- date: currentDate,
1888
- day: formControl?.value || value,
1889
- month: itIsDefined(month) ? month : currentDate.getMonth(),
1890
- year: year || currentDate.getFullYear(),
1963
+ date,
1964
+ day: formControl?.value ?? value,
1965
+ month: month ?? date.getMonth(),
1966
+ year: year ?? date.getFullYear(),
1891
1967
  minDate,
1892
1968
  maxDate
1893
1969
  };
1894
- }
1895
- function setDayValue(value) {
1970
+ }, [date, formControl?.value, value, month, year, minDate, maxDate]);
1971
+ const setDayValue = useCallback((value) => {
1896
1972
  formControl ? formControl.setValue(value) : setValue(value);
1897
- }
1898
- function onChange(value) {
1973
+ }, [formControl]);
1974
+ const onSelect = useCallback((value) => {
1899
1975
  setDayValue(value);
1900
1976
  onValue && onValue(value);
1901
- }
1902
- return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-day", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-day__header", children: DAY_LABELS().map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-picker-day__label", children: title }, index))) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-day__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__week", children: days.map(({ value, disabled, focused, forbidden, selected, today }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-day__element', {
1903
- disabled: disabled || disabledPicker,
1904
- focused,
1905
- forbidden,
1906
- selected,
1907
- today
1908
- }), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day__element__span", children: value || '??' }) }, index))) }, index))) })] }));
1909
- }
1910
-
1911
- const FORMAT_RANGE = '{dd}/{mx}/{aa}';
1912
- function RlsPickerDayRange({ date, disabled: _disabled, formControl, maxDate, minDate, rlsTheme }) {
1913
- const currentRange = formControl?.value || DateRange.now();
1914
- const currentDate = normalizeMinTime(date || currentRange.minDate);
1915
- const sourceDate = useRef(currentRange.minDate);
1977
+ }, [setDayValue, onValue]);
1978
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-day", "rls-theme": rlsTheme, children: [headers, component] }));
1979
+ }
1980
+
1981
+ const formatRange = '{dd}/{mx}/{aa}';
1982
+ function RlsPickerDayRangeHeaders() {
1983
+ return (jsxRuntimeExports.jsx("div", { className: "rls-picker-day__header", children: DAY_LABELS().map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-picker-day__label", children: title }, index))) }));
1984
+ }
1985
+ function RlsPickerDayRangeItem({ day, onSelect, disabled }) {
1986
+ const className = useMemo(() => {
1987
+ return renderClassStatus('rls-picker-day-range__element', {
1988
+ disabled: day.disabled || disabled,
1989
+ end: day.end,
1990
+ forbidden: day.forbidden,
1991
+ ranged: day.ranged,
1992
+ source: day.source
1993
+ });
1994
+ }, [day.disabled, day.end, day.forbidden, day.ranged, day.source, disabled]);
1995
+ const onClick = useCallback(() => {
1996
+ day.value && !day.disabled && !disabled && onSelect(day.value);
1997
+ }, [day.value, day.disabled, disabled, onSelect]);
1998
+ return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day-range__element__span", children: day.value || '??' }) }));
1999
+ }
2000
+ function RlsPickerDayRange({ date: _date, disabled, formControl, maxDate, minDate, rlsTheme }) {
2001
+ const _range = useMemo(() => {
2002
+ return formControl?.value ?? DateRange.now();
2003
+ }, [formControl?.value]);
2004
+ const date = useMemo(() => {
2005
+ return normalizeMinTime(_date ?? _range.minDate);
2006
+ }, [_date]);
2007
+ const sourceDate = useRef(_range.minDate);
1916
2008
  const [weeks, setWeeks] = useState([]);
1917
- const [range, setRange] = useState(currentRange);
2009
+ const [range, setRange] = useState(_range);
2010
+ const [headers, setHeaders] = useState(jsxRuntimeExports.jsx(RlsPickerDayRangeHeaders, {}));
2011
+ const [component, setComponent] = useState(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}));
2012
+ useEffect(() => {
2013
+ return i18nSubscribe(() => {
2014
+ setHeaders(jsxRuntimeExports.jsx(RlsPickerDayRangeHeaders, {}));
2015
+ });
2016
+ }, []);
2017
+ useEffect(() => {
2018
+ setComponent(jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__week", children: days.map((day, index) => (jsxRuntimeExports.jsx(RlsPickerDayRangeItem, { day: day, onSelect: onSelect, disabled: disabled }, index))) }, index))) }));
2019
+ }, [weeks]);
1918
2020
  useEffect(() => {
1919
2021
  setWeeks(createDayRangePicker({
1920
- date: currentDate,
2022
+ date,
1921
2023
  range,
1922
2024
  sourceDate: sourceDate.current,
1923
2025
  minDate,
1924
2026
  maxDate
1925
2027
  }));
1926
- }, [range, date, minDate, maxDate]);
1927
- function onChange(value) {
1928
- const date = assignDayInDate(currentDate, value);
1929
- const range = dateIsBefore(date, sourceDate.current)
1930
- ? new DateRange(sourceDate.current, date)
1931
- : new DateRange(date, sourceDate.current);
1932
- sourceDate.current = date;
2028
+ }, [date, range, minDate, maxDate]);
2029
+ const title = useMemo(() => {
2030
+ return (jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__title", children: dateFormatTemplate(sourceDate.current, formatRange) }));
2031
+ }, [sourceDate.current]);
2032
+ const onSelect = useCallback((value) => {
2033
+ const _date = assignDayInDate(date, value);
2034
+ const range = dateIsBefore(_date, sourceDate.current)
2035
+ ? new DateRange(sourceDate.current, _date)
2036
+ : new DateRange(_date, sourceDate.current);
2037
+ sourceDate.current = _date;
1933
2038
  setRange(range);
1934
2039
  formControl?.setValue(range);
1935
- }
1936
- return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-day-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__title", children: dateFormatTemplate(sourceDate.current, FORMAT_RANGE) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__header", children: DAY_LABELS().map((title, index) => (jsxRuntimeExports.jsx("label", { className: "rls-picker-day-range__label", children: title }, index))) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__component", children: weeks.map(({ days }, index) => (jsxRuntimeExports.jsx("div", { className: "rls-picker-day-range__week", children: days.map(({ disabled, end, forbidden, source, ranged, value }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-day-range__element', {
1937
- disabled: disabled || _disabled,
1938
- end,
1939
- forbidden,
1940
- ranged,
1941
- source
1942
- }), onClick: value && !_disabled
1943
- ? () => {
1944
- onChange(value);
1945
- }
1946
- : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day-range__element__span", children: value || '??' }) }, index))) }, index))) })] }));
1947
- }
1948
-
1949
- function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme, year }) {
1950
- const currentDate = date || new Date();
2040
+ }, [date, sourceDate.current, formControl]);
2041
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-day-range", "rls-theme": rlsTheme, children: [title, headers, component] }));
2042
+ }
2043
+
2044
+ function RlsPickerMonthItem({ month, onSelect, disabled }) {
2045
+ const [label, setLabel] = useState(MONTH_NAMES(month.value));
2046
+ useEffect(() => {
2047
+ return i18nSubscribe(() => {
2048
+ setLabel(MONTH_NAMES(month.value));
2049
+ });
2050
+ }, []);
2051
+ const className = useMemo(() => {
2052
+ return renderClassStatus('rls-picker-month__component', {
2053
+ disabled: month.disabled || disabled,
2054
+ focused: month.focused,
2055
+ selected: month.selected
2056
+ });
2057
+ }, [month.disabled, month.focused, month.selected, disabled]);
2058
+ const onClick = useCallback(() => {
2059
+ itIsDefined(month.value) &&
2060
+ !month.disabled &&
2061
+ !disabled &&
2062
+ onSelect(month.value);
2063
+ }, [month.value, month.disabled, disabled, onSelect]);
2064
+ return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-month__span", children: label }) }));
2065
+ }
2066
+ function RlsPickerMonth({ date: _date, disabled, formControl, maxDate, minDate, onValue, rlsTheme, year }) {
2067
+ const date = useMemo(() => _date || new Date(), [_date]);
1951
2068
  const [months, setMonths] = useState([]);
1952
- const [value, setValue] = useState(formControl?.value || currentDate.getMonth());
2069
+ const [value, setValue] = useState(formControl?.value ?? date.getMonth());
2070
+ const [component, setComponent] = useState(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}));
1953
2071
  useEffect(() => {
1954
- const options = createPickerOptions(); // MonthPickerProps
2072
+ setComponent(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: months.map((month, index) => (jsxRuntimeExports.jsx(RlsPickerMonthItem, { month: month, onSelect: onSelect, disabled: disabled }, index))) }));
2073
+ }, [months]);
2074
+ useEffect(() => {
2075
+ const options = {
2076
+ date,
2077
+ month: formControl?.value ?? value,
2078
+ year: year ?? date.getFullYear(),
2079
+ minDate,
2080
+ maxDate
2081
+ };
1955
2082
  const month = verifyMonthPicker(options);
1956
- month ? setMonthValue(month) : setMonths(createMonthPicker(options));
2083
+ itIsDefined(month)
2084
+ ? setMonthValue(month)
2085
+ : setMonths(createMonthPicker(options));
1957
2086
  }, [date, year, value, minDate, maxDate]);
1958
2087
  useEffect(() => {
1959
- const month = verifyMonthPicker(createPickerOptions());
2088
+ const month = verifyMonthPicker({
2089
+ date,
2090
+ month: formControl?.value ?? value,
2091
+ year: year ?? date.getFullYear(),
2092
+ minDate,
2093
+ maxDate
2094
+ });
1960
2095
  itIsDefined(month)
1961
2096
  ? formControl?.setValue(month)
1962
- : setValue(formControl?.value || currentDate.getMonth());
2097
+ : setValue(formControl?.value ?? date.getMonth());
1963
2098
  }, [formControl?.value]);
1964
- function createPickerOptions() {
1965
- return {
1966
- date: currentDate,
1967
- month: itIsDefined(formControl?.value) ? formControl?.value : value,
1968
- year: year || currentDate.getFullYear(),
1969
- minDate,
1970
- maxDate
1971
- };
1972
- }
1973
- function setMonthValue(value) {
2099
+ const setMonthValue = useCallback((value) => {
1974
2100
  formControl ? formControl.setValue(value) : setValue(value);
1975
- }
1976
- function onChange(value) {
2101
+ }, [formControl]);
2102
+ const onSelect = useCallback((value) => {
1977
2103
  setMonthValue(value);
1978
- if (onValue) {
1979
- onValue(value);
1980
- }
1981
- }
1982
- return (jsxRuntimeExports.jsx("div", { className: "rls-picker-month", "rls-theme": rlsTheme, children: months.map(({ label, value, disabled, focused, selected }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-month__component', {
1983
- disabled: disabled || disabledPicker,
1984
- focused,
1985
- selected
1986
- }), onClick: !(disabled || disabledPicker)
1987
- ? () => {
1988
- onChange(value);
1989
- }
1990
- : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-month__span", children: label }) }, index))) }));
2104
+ onValue && onValue(value);
2105
+ }, [setMonthValue, onValue]);
2106
+ return (jsxRuntimeExports.jsx("div", { className: "rls-picker-month", "rls-theme": rlsTheme, children: component }));
1991
2107
  }
1992
2108
 
1993
- function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
1994
- const { limitNext, limitPrevious } = monthLimitTemplate({
1995
- date,
1996
- maxDate,
1997
- minDate,
1998
- month: monthControl.value
1999
- });
2000
- const monthName = MONTH_NAMES()[monthControl.value || 0];
2001
- function onPreviousMonth() {
2109
+ function RlsPickerSelectorTitle({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
2110
+ const { limitNext, limitPrevious } = useMemo(() => {
2111
+ return monthLimitTemplate({
2112
+ date,
2113
+ maxDate,
2114
+ minDate,
2115
+ month: monthControl.value
2116
+ });
2117
+ }, [date, maxDate, minDate, monthControl.value]);
2118
+ const [label, setLabel] = useState(MONTH_NAMES(monthControl.value ?? Month.January));
2119
+ useEffect(() => {
2120
+ return i18nSubscribe(() => {
2121
+ setLabel(MONTH_NAMES(monthControl.value ?? Month.January));
2122
+ });
2123
+ }, []);
2124
+ useEffect(() => {
2125
+ setLabel(MONTH_NAMES(monthControl.value ?? Month.January));
2126
+ }, [monthControl.value]);
2127
+ const onPreviousMonth = useCallback(() => {
2002
2128
  if (itIsDefined(monthControl.value) && itIsDefined(yearControl.value)) {
2003
2129
  if (monthControl.value > Month.January) {
2004
2130
  monthControl.setValue(monthControl.value - 1);
@@ -2008,15 +2134,15 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
2008
2134
  yearControl.setValue(yearControl.value - 1);
2009
2135
  }
2010
2136
  }
2011
- }
2012
- function onPreviousYear() {
2137
+ }, [monthControl.value, yearControl.value]);
2138
+ const onPreviousYear = useCallback(() => {
2013
2139
  itIsDefined(yearControl.value) &&
2014
2140
  yearControl.setValue(yearControl.value - 1);
2015
- }
2016
- function onPrevious() {
2141
+ }, [yearControl.value]);
2142
+ const onPrevious = useCallback(() => {
2017
2143
  type === 'month' ? onPreviousMonth() : onPreviousYear();
2018
- }
2019
- function onNextMonth() {
2144
+ }, [type, onPreviousMonth, onPreviousYear]);
2145
+ const onNextMonth = useCallback(() => {
2020
2146
  if (itIsDefined(monthControl.value) && itIsDefined(yearControl.value)) {
2021
2147
  if (monthControl.value < Month.December) {
2022
2148
  monthControl.setValue(monthControl.value + 1);
@@ -2026,66 +2152,73 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
2026
2152
  yearControl.setValue(yearControl.value + 1);
2027
2153
  }
2028
2154
  }
2029
- }
2030
- function onNextYear() {
2155
+ }, [monthControl.value, yearControl.value]);
2156
+ const onNextYear = useCallback(() => {
2031
2157
  itIsDefined(yearControl.value) &&
2032
2158
  yearControl.setValue(yearControl.value + 1);
2033
- }
2034
- function onNext() {
2159
+ }, [yearControl.value]);
2160
+ const onNext = useCallback(() => {
2035
2161
  type === 'month' ? onNextMonth() : onNextYear();
2036
- }
2037
- return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-month-title", children: [jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsxRuntimeExports.jsx("span", { onClick: onClick, children: monthName }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
2162
+ }, [type, onNextMonth, onNextYear]);
2163
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-selector-title", children: [jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onPrevious, disabled: limitPrevious || disabled }), jsxRuntimeExports.jsx("span", { onClick: onClick, children: label }), jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onNext, disabled: limitNext || disabled })] }));
2038
2164
  }
2039
2165
 
2040
- function RlsPickerYear({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme }) {
2041
- const currentDate = date || new Date();
2042
- const [value, setValue] = useState(formControl?.value || currentDate.getFullYear());
2043
- const [year, setYear] = useState(formControl?.value || currentDate.getFullYear());
2166
+ function RlsPickerYearItem({ onSelect, year, disabled }) {
2167
+ const className = useMemo(() => {
2168
+ return renderClassStatus('rls-picker-year__element', {
2169
+ disabled: year.disabled || disabled,
2170
+ focused: year.focused,
2171
+ selected: year.selected
2172
+ });
2173
+ }, [year.disabled, year.focused, year.selected, disabled]);
2174
+ const onClick = useCallback(() => {
2175
+ year.value && !year.disabled && !disabled && onSelect(year.value);
2176
+ }, [year.value, year.disabled, disabled, onSelect]);
2177
+ return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-year__span rls-body1-medium", children: year.value || '????' }) }));
2178
+ }
2179
+ function RlsPickerYear({ date: _date, disabled, formControl, maxDate, minDate, onValue, rlsTheme }) {
2180
+ const date = useMemo(() => _date || new Date(), [_date]);
2181
+ const [value, setValue] = useState(formControl?.value ?? date.getFullYear());
2182
+ const [year, setYear] = useState(formControl?.value ?? date.getFullYear());
2183
+ const [component, setComponent] = useState(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}));
2184
+ const createPickerOptions = useCallback(() => {
2185
+ return {
2186
+ date,
2187
+ year,
2188
+ minDate,
2189
+ maxDate
2190
+ };
2191
+ }, [date, year, minDate, maxDate]);
2044
2192
  const [template, setTemplate] = useState(createYearPicker(createPickerOptions()));
2045
2193
  useEffect(() => {
2046
2194
  const options = createPickerOptions(); // YearPickerProps
2047
2195
  const year = verifyYearPicker(options);
2048
- year
2049
- ? setYearValue(year)
2050
- : setTemplate(createYearPicker(createPickerOptions()));
2196
+ year ? setYearValue(year) : setTemplate(createYearPicker(options));
2051
2197
  }, [date, year, value, minDate, maxDate]);
2198
+ useEffect(() => {
2199
+ setComponent(jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: template.years.map((year, index) => (jsxRuntimeExports.jsx(RlsPickerYearItem, { year: year, onSelect: onSelect, disabled: disabled }, index))) }));
2200
+ }, [template.years]);
2052
2201
  useEffect(() => {
2053
2202
  const year = verifyYearPicker(createPickerOptions());
2054
2203
  itIsDefined(year)
2055
2204
  ? formControl?.setValue(year)
2056
- : setValue(formControl?.value || currentDate.getFullYear());
2205
+ : setValue(formControl?.value ?? date.getFullYear());
2057
2206
  }, [formControl?.value]);
2058
- function createPickerOptions() {
2059
- return {
2060
- date: currentDate,
2061
- year,
2062
- minDate,
2063
- maxDate
2064
- };
2065
- }
2066
- function setYearValue(value) {
2207
+ const setYearValue = useCallback((value) => {
2067
2208
  formControl ? formControl.setValue(value) : setValue(value);
2068
2209
  setYear(value);
2069
- }
2070
- function onClickPrev() {
2071
- setYear(year - 8);
2072
- }
2073
- function onClickNext() {
2074
- setYear(year + 8);
2075
- }
2076
- function onChange(value) {
2210
+ }, [formControl]);
2211
+ const onClickPrev = useCallback(() => {
2212
+ setYear((year) => year - 8);
2213
+ }, []);
2214
+ const onClickNext = useCallback(() => {
2215
+ setYear((year) => year + 8);
2216
+ }, []);
2217
+ const onSelect = useCallback((value) => {
2077
2218
  setYearValue(value);
2078
2219
  onValue && onValue(value);
2079
- }
2080
- return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-year", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-year__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--prev", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onClickPrev, disabled: !template.canPrevious || disabledPicker }) }), jsxRuntimeExports.jsxs("label", { className: "rls-title-bold", children: [template.minRange, " - ", template.maxRange] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--next", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onClickNext, disabled: !template.canNext || disabledPicker }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__component", children: template.years.map(({ value, disabled, focused, selected }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-year__year', {
2081
- disabled: disabled || disabledPicker,
2082
- focused,
2083
- selected
2084
- }), onClick: value && !disabledPicker
2085
- ? () => {
2086
- onChange(value);
2087
- }
2088
- : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-year__year__span rls-body1-medium", children: value || '????' }) }, index))) })] }));
2220
+ }, [setYearValue, onValue]);
2221
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-year", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-year__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--prev", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-left", onClick: onClickPrev, disabled: !template.canPrevious || disabled }) }), jsxRuntimeExports.jsxs("label", { className: "rls-title-bold", children: [template.minRange, " - ", template.maxRange] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__action rls-picker-year__action--next", children: jsxRuntimeExports.jsx(RlsButtonAction, { icon: "arrow-ios-right", onClick: onClickNext, disabled: !template.canNext || disabled }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-picker-year__component", children: component })] }));
2089
2222
  }
2090
2223
 
2091
2224
  function RlsToolbar({ actions, children, subtitle }) {
@@ -2093,7 +2226,10 @@ function RlsToolbar({ actions, children, subtitle }) {
2093
2226
  }
2094
2227
 
2095
2228
  function RlsCard({ children, outline, rlsTheme }) {
2096
- return (jsxRuntimeExports.jsx("div", { className: useRenderClassStatus('rls-card', { outline }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-card__content", children: children }) }));
2229
+ const className = useMemo(() => {
2230
+ return renderClassStatus('rls-card', { outline });
2231
+ }, [outline]);
2232
+ return (jsxRuntimeExports.jsx("div", { className: className, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-card__content", children: children }) }));
2097
2233
  }
2098
2234
 
2099
2235
  const reactI18n = i18n({
@@ -2126,7 +2262,10 @@ class ConfirmationResult extends PartialSealed {
2126
2262
  }
2127
2263
  }
2128
2264
  function RlsConfirmation({ approved, content, reject, rlsTheme, subtitle, title, visible }) {
2129
- return (jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-confirmation', { visible }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__component", children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__header", children: [title && jsxRuntimeExports.jsx("div", { className: "rls-confirmation__title", children: title }), subtitle && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__subtitle", children: subtitle }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__message", children: content })) }), (approved || reject) && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__actions", children: [approved && (jsxRuntimeExports.jsx(RlsButton, { identifier: approved.identifier, type: "raised", onClick: approved.onClick, children: approved.label })), reject && (jsxRuntimeExports.jsx(RlsButton, { identifier: reject.identifier, type: "outline", onClick: reject.onClick, children: reject.label }))] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__backdrop" })] }));
2265
+ const className = useMemo(() => {
2266
+ return renderClassStatus('rls-confirmation', { visible });
2267
+ }, [visible]);
2268
+ return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__component", children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__header", children: [title && jsxRuntimeExports.jsx("div", { className: "rls-confirmation__title", children: title }), subtitle && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__subtitle", children: subtitle }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__message", children: content })) }), (approved || reject) && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__actions", children: [approved && (jsxRuntimeExports.jsx(RlsButton, { identifier: approved.identifier, type: "raised", onClick: approved.onClick, children: approved.label })), reject && (jsxRuntimeExports.jsx(RlsButton, { identifier: reject.identifier, type: "outline", onClick: reject.onClick, children: reject.label }))] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__backdrop" })] }));
2130
2269
  }
2131
2270
  function useConfirmation() {
2132
2271
  const [config, setConfig] = useState({});
@@ -2172,53 +2311,218 @@ function RlsDatatableHeader({ children, identifier }) {
2172
2311
  return (jsxRuntimeExports.jsx("tr", { id: identifier, className: "rls-datatable__header", children: children }));
2173
2312
  }
2174
2313
  function RlsDatatableTitle({ children, className, control, identifier }) {
2175
- return (jsxRuntimeExports.jsx("th", { id: identifier, className: useRenderClassStatus('rls-datatable__title', { control }, className).trim(), children: children }));
2314
+ const classDatatableName = useMemo(() => {
2315
+ return renderClassStatus('rls-datatable__title', { control }, className);
2316
+ }, [control, className]);
2317
+ return (jsxRuntimeExports.jsx("th", { id: identifier, className: classDatatableName, children: children }));
2176
2318
  }
2177
2319
  function RlsDatatableSubheader({ children, className, identifier }) {
2178
- return (jsxRuntimeExports.jsx("tr", { id: identifier, className: useRenderClassStatus('rls-datatable__subheader', {}, className).trim(), children: children }));
2320
+ const classDatatableName = useMemo(() => {
2321
+ return renderClassStatus('rls-datatable__subheader', {}, className);
2322
+ }, [className]);
2323
+ return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classDatatableName, children: children }));
2179
2324
  }
2180
2325
  function RlsDatatableRecord({ children, className, error, identifier, info, successs, warning }) {
2181
- return (jsxRuntimeExports.jsx("tr", { id: identifier, className: useRenderClassStatus('rls-datatable__record', { error, info, successs, warning }, className).trim(), children: children }));
2326
+ const classDatatableName = useMemo(() => {
2327
+ return renderClassStatus('rls-datatable__record', { error, info, successs, warning }, className);
2328
+ }, [error, info, successs, warning, className]);
2329
+ return (jsxRuntimeExports.jsx("tr", { id: identifier, className: classDatatableName, children: children }));
2182
2330
  }
2183
2331
  function RlsDatatableTotals({ children, className, error, identifier, info, successs, warning }) {
2184
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: useRenderClassStatus('rls-datatable__totals', { error, info, successs, warning }, className).trim(), children: children }));
2332
+ const classDatatableName = useMemo(() => {
2333
+ return renderClassStatus('rls-datatable__totals', { error, info, successs, warning }, className);
2334
+ }, [error, info, successs, warning, className]);
2335
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: classDatatableName, children: children }));
2185
2336
  }
2186
2337
  function RlsDatatableCell({ children, className, control, identifier, overflow }) {
2187
- return (jsxRuntimeExports.jsx("th", { id: identifier, className: useRenderClassStatus('rls-datatable__cell', { control, overflow }, className).trim(), children: children }));
2338
+ const classDatatableName = useMemo(() => {
2339
+ return renderClassStatus('rls-datatable__cell', { control, overflow }, className);
2340
+ }, [control, overflow, className]);
2341
+ return (jsxRuntimeExports.jsx("th", { id: identifier, className: classDatatableName, children: children }));
2188
2342
  }
2189
2343
  function RlsDatatableData({ children, className, control, identifier, overflow }) {
2190
- return (jsxRuntimeExports.jsx("div", { id: identifier, className: useRenderClassStatus('rls-datatable__data', { control, overflow }, className).trim(), children: children }));
2344
+ const classDatatableName = useMemo(() => {
2345
+ return renderClassStatus('rls-datatable__data', { control, overflow }, className);
2346
+ }, [control, overflow, className]);
2347
+ return (jsxRuntimeExports.jsx("div", { id: identifier, className: classDatatableName, children: children }));
2191
2348
  }
2192
2349
  function RlsDatatable({ children, datatable, footer, header, identifier, rlsTheme, summary, toolbar }) {
2193
- return (jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-datatable', {
2350
+ const className = useMemo(() => {
2351
+ return renderClassStatus('rls-datatable', {
2194
2352
  scrolleable: datatable?.scrolleable
2195
- }), "rls-theme": rlsTheme, children: [toolbar && jsxRuntimeExports.jsx("div", { className: "rls-datatable__toolbar", children: toolbar }), jsxRuntimeExports.jsxs("table", { id: identifier, children: [header && jsxRuntimeExports.jsx("thead", { className: "rls-datatable__head", children: header }), jsxRuntimeExports.jsx("tbody", { ref: datatable?.tableRef, className: "rls-datatable__body", children: children })] }), summary && jsxRuntimeExports.jsx("div", { className: "rls-datatable__summary", children: summary }), footer && jsxRuntimeExports.jsx("div", { className: "rls-datatable__footer", children: footer })] }));
2353
+ });
2354
+ }, [datatable]);
2355
+ return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [toolbar && jsxRuntimeExports.jsx("div", { className: "rls-datatable__toolbar", children: toolbar }), jsxRuntimeExports.jsxs("table", { id: identifier, children: [header && jsxRuntimeExports.jsx("thead", { className: "rls-datatable__head", children: header }), jsxRuntimeExports.jsx("tbody", { ref: datatable?.tableRef, className: "rls-datatable__body", children: children })] }), summary && jsxRuntimeExports.jsx("div", { className: "rls-datatable__summary", children: summary }), footer && jsxRuntimeExports.jsx("div", { className: "rls-datatable__footer", children: footer })] }));
2196
2356
  }
2197
2357
 
2198
- const DURATION_ANIMATION$1 = 240;
2199
- const MAX_ELEMENTS = 6;
2200
- function useFieldAutocomplete(props) {
2201
- const controller = useListController(props);
2202
- const [coincidences, setCoincidences] = useState([]);
2203
- const [pattern, setPattern] = useState('');
2204
- const currentStore = useRef({
2205
- coincidences: [],
2206
- pattern: '',
2207
- previous: null
2358
+ function createObserver(options) {
2359
+ const { setScrolleable, table } = options;
2360
+ const observer = new ResizeObserver(() => {
2361
+ const scrollHeight = table.scrollHeight || 0;
2362
+ const clientHeight = table.clientHeight || 0;
2363
+ setScrolleable(scrollHeight > clientHeight);
2208
2364
  });
2365
+ observer.observe(table);
2366
+ return observer;
2367
+ }
2368
+ function useDatatable() {
2369
+ const [scrolleable, setScrolleable] = useState(false);
2370
+ const tableRef = useRef(null);
2371
+ useEffect(() => {
2372
+ const observer = tableRef?.current &&
2373
+ createObserver({ setScrolleable, table: tableRef?.current });
2374
+ return () => {
2375
+ observer?.disconnect();
2376
+ };
2377
+ }, []);
2378
+ return { scrolleable, tableRef };
2379
+ }
2380
+
2381
+ function useListController(props) {
2382
+ const { suggestions, automatic, formControl, reference } = props;
2383
+ const listIsOpen = useRef(false);
2384
+ const contentRef = useRef(null);
2385
+ const listRef = useRef(null);
2386
+ const inputRef = useRef(null);
2387
+ const [collection, setCollection] = useState(new ListCollection(suggestions));
2388
+ const [state, refreshState] = useState({
2389
+ focused: false,
2390
+ higher: false,
2391
+ value: '',
2392
+ modalIsVisible: false
2393
+ });
2394
+ const position = useRef(0);
2395
+ const valueProtected = useRef();
2396
+ const changeValueInternal = useRef(false);
2397
+ useEffect(() => {
2398
+ function onCloseSuggestions({ target }) {
2399
+ !contentRef?.current?.contains(target) &&
2400
+ refreshState((state) => ({ ...state, modalIsVisible: false }));
2401
+ }
2402
+ document.addEventListener('click', onCloseSuggestions);
2403
+ return () => {
2404
+ document.removeEventListener('click', onCloseSuggestions);
2405
+ };
2406
+ }, []);
2407
+ useEffect(() => {
2408
+ if (!listIsOpen.current && state.modalIsVisible) {
2409
+ listIsOpen.current = true;
2410
+ }
2411
+ if (listIsOpen.current && !state.modalIsVisible) {
2412
+ formControl?.touch();
2413
+ }
2414
+ }, [state.modalIsVisible]);
2415
+ useEffect(() => {
2416
+ setCollection(new ListCollection(suggestions, reference));
2417
+ }, [suggestions]);
2209
2418
  useEffect(() => {
2210
- refreshCoincidences(pattern, true);
2419
+ if (!changeValueInternal.current) {
2420
+ if (formControl?.value) {
2421
+ const element = collection.find(formControl.value);
2422
+ if (!element) {
2423
+ valueProtected.current = formControl.value;
2424
+ automatic
2425
+ ? setFormValue(collection.value[0], true)
2426
+ : setFormValue(undefined);
2427
+ }
2428
+ else {
2429
+ refreshState((state) => ({ ...state, value: element.description }));
2430
+ }
2431
+ }
2432
+ else if (valueProtected.current) {
2433
+ const element = collection.find(valueProtected.current);
2434
+ element && setFormValue(element);
2435
+ }
2436
+ else {
2437
+ automatic && setFormValue(collection.value[0], true);
2438
+ }
2439
+ }
2440
+ changeValueInternal.current = false;
2441
+ }, [collection, formControl?.value]);
2442
+ const setState = useCallback((state) => {
2443
+ const _state = state.modalIsVisible
2444
+ ? {
2445
+ ...state,
2446
+ higher: locationListCanTop(contentRef.current, listRef.current)
2447
+ }
2448
+ : state;
2449
+ refreshState((state) => ({ ...state, ..._state }));
2450
+ }, []);
2451
+ const setFormValue = useCallback((element, initialValue = false) => {
2452
+ refreshState((state) => ({
2453
+ ...state,
2454
+ value: element?.description || ''
2455
+ }));
2456
+ changeValueInternal.current = true;
2457
+ initialValue
2458
+ ? formControl?.setInitialValue(element?.value)
2459
+ : formControl?.setValue(element?.value);
2460
+ }, [formControl]);
2461
+ const navigationInput = useCallback((event) => {
2462
+ if (state.modalIsVisible) {
2463
+ const _position = navigationListFromInput({
2464
+ content: contentRef.current,
2465
+ event: event,
2466
+ list: listRef.current
2467
+ });
2468
+ position.current = _position ?? 0;
2469
+ }
2470
+ }, [state.modalIsVisible]);
2471
+ const navigationElement = useCallback((event) => {
2472
+ position.current = navigationListFromElement({
2473
+ content: contentRef.current,
2474
+ event: event,
2475
+ input: inputRef.current,
2476
+ list: listRef.current,
2477
+ position: position.current
2478
+ });
2479
+ }, [state.modalIsVisible]);
2480
+ return {
2481
+ ...state,
2482
+ contentRef,
2483
+ inputRef,
2484
+ listRef,
2485
+ navigationElement,
2486
+ navigationInput,
2487
+ setFormValue,
2488
+ setState
2489
+ };
2490
+ }
2491
+
2492
+ const DURATION_ANIMATION$1 = 240;
2493
+ const MAX_ELEMENTS = 6;
2494
+ function useFieldAutocomplete(props) {
2495
+ const controller = useListController(props);
2496
+ const [coincidences, setCoincidences] = useState([]);
2497
+ const [pattern, setPattern] = useState('');
2498
+ const currentStore = useRef({
2499
+ coincidences: [],
2500
+ pattern: '',
2501
+ previous: null
2502
+ });
2503
+ const refreshCoincidences = useCallback((suggestions, pattern, reboot = false) => {
2504
+ const { collection, store } = createAutocompleteStore({
2505
+ pattern,
2506
+ suggestions,
2507
+ reboot,
2508
+ store: currentStore.current
2509
+ });
2510
+ currentStore.current = store;
2511
+ setCoincidences(collection.slice(0, MAX_ELEMENTS));
2512
+ }, []);
2513
+ useEffect(() => {
2514
+ refreshCoincidences(props.suggestions, pattern, true);
2211
2515
  }, [props.suggestions]);
2212
2516
  useEffect(() => {
2213
- refreshCoincidences(pattern);
2517
+ refreshCoincidences(props.suggestions, pattern);
2214
2518
  }, [pattern]);
2215
- function onFocusInput() {
2519
+ const onFocusInput = useCallback(() => {
2216
2520
  controller.setState({ focused: true });
2217
- }
2218
- function onBlurInput() {
2521
+ }, [controller.setState]);
2522
+ const onBlurInput = useCallback(() => {
2219
2523
  controller.setState({ focused: false });
2220
- }
2221
- function onKeydownInput(event) {
2524
+ }, [controller.setState]);
2525
+ const onKeydownInput = useCallback((event) => {
2222
2526
  switch (event.code) {
2223
2527
  case 'Escape':
2224
2528
  case 'Tab':
@@ -2228,14 +2532,14 @@ function useFieldAutocomplete(props) {
2228
2532
  controller.navigationInput(event);
2229
2533
  break;
2230
2534
  }
2231
- }
2232
- function onClickControl() {
2535
+ }, [controller.setState, controller.navigationInput]);
2536
+ const onClickControl = useCallback(() => {
2233
2537
  controller.setState({ modalIsVisible: true });
2234
2538
  setTimeout(() => {
2235
2539
  controller.inputRef?.current?.focus();
2236
2540
  }, DURATION_ANIMATION$1);
2237
- }
2238
- function onClickAction() {
2541
+ }, [controller.setState]);
2542
+ const onClickAction = useCallback(() => {
2239
2543
  if (controller.value) {
2240
2544
  controller.setState({ modalIsVisible: false });
2241
2545
  controller.setFormValue(undefined);
@@ -2244,44 +2548,43 @@ function useFieldAutocomplete(props) {
2244
2548
  else {
2245
2549
  onClickControl();
2246
2550
  }
2247
- }
2248
- function onClickBackdrop() {
2551
+ }, [
2552
+ controller.value,
2553
+ controller.setState,
2554
+ controller.setFormValue,
2555
+ props.onValue
2556
+ ]);
2557
+ const onClickBackdrop = useCallback(() => {
2249
2558
  controller.setState({ modalIsVisible: false });
2250
- }
2251
- function onClickElement(element) {
2559
+ }, [controller.setState]);
2560
+ const onChange = useCallback((element) => {
2561
+ if (props.onSelect) {
2562
+ controller.setState({ modalIsVisible: false });
2563
+ element.value && props.onSelect(element.value);
2564
+ }
2565
+ else {
2566
+ controller.setState({ modalIsVisible: false });
2567
+ controller.setFormValue(element);
2568
+ }
2569
+ props.onValue && props.onValue(element.value);
2570
+ }, [
2571
+ controller.setState,
2572
+ controller.setFormValue,
2573
+ props.onSelect,
2574
+ props.onValue
2575
+ ]);
2576
+ const onClickElement = useCallback((element) => {
2252
2577
  return () => {
2253
2578
  onChange(element);
2254
2579
  };
2255
- }
2256
- function onKeydownElement(element) {
2580
+ }, []);
2581
+ const onKeydownElement = useCallback((element) => {
2257
2582
  return (event) => {
2258
2583
  event.code === 'Enter'
2259
2584
  ? onChange(element)
2260
2585
  : controller.navigationElement(event);
2261
2586
  };
2262
- }
2263
- function onChange(element) {
2264
- const { onSelect, onValue } = props;
2265
- if (onSelect) {
2266
- controller.setState({ modalIsVisible: false });
2267
- element.value && onSelect(element.value);
2268
- }
2269
- else {
2270
- controller.setState({ modalIsVisible: false });
2271
- controller.setFormValue(element);
2272
- }
2273
- onValue && onValue(element.value);
2274
- }
2275
- function refreshCoincidences(pattern, reboot = false) {
2276
- const { collection, store } = createAutocompleteStore({
2277
- pattern,
2278
- suggestions: props.suggestions,
2279
- reboot,
2280
- store: currentStore.current
2281
- });
2282
- currentStore.current = store;
2283
- setCoincidences(collection.slice(0, MAX_ELEMENTS));
2284
- }
2587
+ }, [controller.navigationElement]);
2285
2588
  return {
2286
2589
  ...controller,
2287
2590
  coincidences,
@@ -2301,227 +2604,309 @@ function useFieldAutocomplete(props) {
2301
2604
  function RlsFieldAutocompleteTemplate(props) {
2302
2605
  const autocomplete = useFieldAutocomplete(props);
2303
2606
  const { render, children, formControl, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
2304
- const _disabled = formControl?.disabled || props.disabled;
2305
- const className = useRenderClassStatus('rls-field-box', {
2306
- focused: autocomplete.focused && !_disabled,
2307
- error: formControl?.wrong,
2308
- disabled: _disabled,
2309
- selected: !!autocomplete.value
2310
- }, 'rls-field-list rls-field-autocomplete');
2311
- return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: autocomplete.contentRef, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-list__control", readOnly: true, disabled: _disabled, placeholder: placeholder, value: autocomplete.value, onClick: autocomplete.onClickControl }), jsxRuntimeExports.jsx("button", { className: "rls-field-list__action", disabled: _disabled, onClick: autocomplete.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: autocomplete.value ? 'trash-2' : 'arrow-ios-down' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-field-list__suggestions', {
2312
- higher: autocomplete.higher,
2313
- visible: autocomplete.modalIsVisible
2314
- }), children: autocomplete.modalIsVisible && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: autocomplete.listRef, className: "rls-field-list__ul", children: [jsxRuntimeExports.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntimeExports.jsx("input", { ref: autocomplete.inputRef, className: "rls-field-list__ul__control", type: "text", placeholder: reactI18n('listInputPlaceholder'), value: autocomplete.pattern, onChange: (event) => {
2315
- autocomplete.setPattern(event.target.value);
2316
- }, disabled: _disabled || searching, onFocus: autocomplete.onFocusInput, onBlur: autocomplete.onBlurInput, onKeyDown: autocomplete.onKeydownInput }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: _disabled || searching, onClick: () => {
2317
- onSearch(autocomplete.pattern);
2318
- }, children: jsxRuntimeExports.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntimeExports.jsx(RlsProgressBar, { indeterminate: true }), autocomplete.coincidences.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: autocomplete.onClickElement(element), onKeyDown: autocomplete.onKeydownElement(element), children: render(element) }, index))), !autocomplete.coincidences.length && (jsxRuntimeExports.jsx("li", { className: "rls-field-list__empty", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntimeExports.jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: autocomplete.onClickBackdrop })] })) })] }));
2607
+ const [labels, setLabels] = useState({
2608
+ listEmptyDescription: reactI18n('listEmptyDescription'),
2609
+ listEmptyTitle: reactI18n('listEmptyTitle'),
2610
+ listInputPlaceholder: reactI18n('listInputPlaceholder')
2611
+ });
2612
+ useEffect(() => {
2613
+ return i18nSubscribe(() => {
2614
+ setLabels({
2615
+ listEmptyDescription: reactI18n('listEmptyDescription'),
2616
+ listEmptyTitle: reactI18n('listEmptyTitle'),
2617
+ listInputPlaceholder: reactI18n('listInputPlaceholder')
2618
+ });
2619
+ });
2620
+ }, []);
2621
+ const _disabled = useMemo(() => {
2622
+ return formControl?.disabled || props.disabled;
2623
+ }, [formControl?.disabled, props.disabled]);
2624
+ const className = useMemo(() => {
2625
+ return renderClassStatus('rls-field-box', {
2626
+ focused: autocomplete.focused && !_disabled,
2627
+ error: formControl?.wrong,
2628
+ disabled: _disabled,
2629
+ selected: !!autocomplete.value
2630
+ }, 'rls-field-list rls-field-autocomplete');
2631
+ }, [formControl?.wrong, autocomplete.value, autocomplete.focused, _disabled]);
2632
+ const classNameList = useMemo(() => {
2633
+ return renderClassStatus('rls-field-list__suggestions', {
2634
+ higher: autocomplete.higher,
2635
+ visible: autocomplete.modalIsVisible
2636
+ });
2637
+ }, [autocomplete.higher, autocomplete.modalIsVisible]);
2638
+ const onInputSearch = useCallback((event) => {
2639
+ autocomplete.setPattern(event.target.value);
2640
+ }, []);
2641
+ const onClickSearch = useCallback(() => {
2642
+ onSearch && onSearch(autocomplete.pattern);
2643
+ }, [onSearch, autocomplete.pattern]);
2644
+ return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: autocomplete.contentRef, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-list__control", readOnly: true, disabled: _disabled, placeholder: placeholder, value: autocomplete.value, onClick: autocomplete.onClickControl }), jsxRuntimeExports.jsx("button", { className: "rls-field-list__action", disabled: _disabled, onClick: autocomplete.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: autocomplete.value ? 'trash-2' : 'arrow-ios-down' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx("div", { className: classNameList, children: autocomplete.modalIsVisible && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: autocomplete.listRef, className: "rls-field-list__ul", children: [jsxRuntimeExports.jsxs("div", { className: "rls-field-list__ul__search", children: [jsxRuntimeExports.jsx("input", { ref: autocomplete.inputRef, className: "rls-field-list__ul__control", type: "text", placeholder: labels.listInputPlaceholder, value: autocomplete.pattern, onChange: onInputSearch, disabled: _disabled || searching, onFocus: autocomplete.onFocusInput, onBlur: autocomplete.onBlurInput, onKeyDown: autocomplete.onKeydownInput }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: _disabled || searching, onClick: onClickSearch, children: jsxRuntimeExports.jsx(RlsIcon, { value: "search" }) }))] }), searching && jsxRuntimeExports.jsx(RlsProgressBar, { indeterminate: true }), autocomplete.coincidences.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: autocomplete.onClickElement(element), onKeyDown: autocomplete.onKeydownElement(element), children: render(element) }, index))), !autocomplete.coincidences.length && (jsxRuntimeExports.jsx("li", { className: "rls-field-list__empty", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntimeExports.jsx("label", { className: "rls-label-bold truncate", children: labels.listEmptyTitle }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: labels.listEmptyDescription })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: autocomplete.onClickBackdrop })] })) })] }));
2319
2645
  }
2320
2646
  function RlsFieldAutocomplete(props) {
2321
2647
  return (jsxRuntimeExports.jsx(RlsFieldAutocompleteTemplate, { ...props, render: (element) => (jsxRuntimeExports.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })) }));
2322
2648
  }
2323
2649
 
2324
2650
  function RlsModal({ children, overflow, visible, rlsTheme }) {
2325
- return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-modal', { overflow, visible }), "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-modal__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-modal__backdrop" })] }), document.body);
2651
+ const className = useMemo(() => {
2652
+ return renderClassStatus('rls-modal', { overflow, visible });
2653
+ }, [overflow, visible]);
2654
+ return ReactDOM.createPortal(jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsx("div", { className: "rls-modal__component", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-modal__backdrop" })] }), document.body);
2326
2655
  }
2327
2656
 
2328
- const FORMAT_TITLE = '{dw}, {mx} {dd} de {aa}';
2657
+ const formatTitle = '{dw}, {mx} {dd} de {aa}';
2329
2658
  function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
2330
- const today = new Date(); // Initial current date in component
2331
- const dateInitial = formControl?.value || date || today;
2332
- const yearControl = useReactControl(dateInitial.getFullYear());
2333
- const dayControl = useReactControl(dateInitial.getDate());
2334
- const monthControl = useReactControl(dateInitial.getMonth());
2335
- const [value, setValue] = useState(dateInitial);
2659
+ const today = useRef(new Date()); // Initial current date in component
2660
+ const _date = useMemo(() => {
2661
+ return formControl?.value ?? date ?? today.current;
2662
+ }, [formControl?.value, date]);
2663
+ const yearControl = useReactControl(_date.getFullYear());
2664
+ const dayControl = useReactControl(_date.getDate());
2665
+ const monthControl = useReactControl(_date.getMonth());
2666
+ const [value, setValue] = useState(_date);
2336
2667
  const [visibility, setVisibility] = useState('DAY');
2668
+ const [labels, setLabels] = useState({
2669
+ dateActionCancel: reactI18n('dateActionCancel'),
2670
+ dateActionSelect: reactI18n('dateActionSelect'),
2671
+ dateActionToday: reactI18n('dateActionToday')
2672
+ });
2673
+ const classNameComponent = useMemo(() => {
2674
+ return renderClassStatus('rls-picker-date__component', {
2675
+ day: visibility === 'DAY',
2676
+ month: visibility === 'MONTH',
2677
+ year: visibility === 'YEAR'
2678
+ });
2679
+ }, [visibility]);
2680
+ const title = useMemo(() => {
2681
+ return dateFormatTemplate(_date, formatTitle);
2682
+ }, [_date]);
2683
+ const itIsDisabledToday = useMemo(() => dateOutRange({
2684
+ date: today.current,
2685
+ maxDate,
2686
+ minDate
2687
+ }), [today.current, maxDate, minDate]);
2337
2688
  useEffect(() => {
2338
- const dateRange = verifyDateRange({
2339
- date: formControl?.value || date || today,
2340
- minDate,
2341
- maxDate
2689
+ const date = verifyDateRange({ date: _date, minDate, maxDate });
2690
+ setValue(date);
2691
+ formControl?.setValue(date);
2692
+ return i18nSubscribe(() => {
2693
+ setLabels({
2694
+ dateActionCancel: reactI18n('dateActionCancel'),
2695
+ dateActionSelect: reactI18n('dateActionSelect'),
2696
+ dateActionToday: reactI18n('dateActionToday')
2697
+ });
2342
2698
  });
2343
- setValue(dateRange);
2344
- formControl?.setValue(dateRange);
2345
2699
  }, []);
2346
2700
  useEffect(() => {
2347
- itIsDefined(yearControl.value) &&
2348
- setValue(assignYearInDate(value, yearControl.value));
2349
- }, [yearControl.value]);
2350
- useEffect(() => {
2351
- itIsDefined(monthControl.value) &&
2352
- setValue(assignMonthInDate(value, monthControl.value));
2353
- }, [monthControl.value]);
2354
- useEffect(() => {
2355
- itIsDefined(dayControl.value) &&
2356
- setValue(assignDayInDate(value, dayControl.value));
2357
- }, [dayControl.value]);
2358
- function onVisibilityDay() {
2701
+ setValue(new Date(yearControl.value, monthControl.value, dayControl.value));
2702
+ }, [yearControl.value, monthControl.value, dayControl.value]);
2703
+ const onVisibilityDay = useCallback(() => {
2359
2704
  setVisibility('DAY');
2360
- }
2361
- function onVisibilityMonth() {
2705
+ }, []);
2706
+ const onVisibilityMonth = useCallback(() => {
2362
2707
  setVisibility('MONTH');
2363
- }
2364
- function onVisibilityYear() {
2708
+ }, []);
2709
+ const onVisibilityYear = useCallback(() => {
2365
2710
  setVisibility('YEAR');
2366
- }
2367
- function onCancel() {
2711
+ }, []);
2712
+ const onCancel = useCallback(() => {
2368
2713
  onListener && onListener({ event: PickerListenerEvent.Cancel });
2369
- }
2370
- function onToday() {
2371
- yearControl.setValue(today.getFullYear());
2372
- dayControl.setValue(today.getDate());
2373
- monthControl.setValue(today.getMonth());
2374
- formControl?.setValue(today);
2375
- onListener && onListener({ event: PickerListenerEvent.Now, value: today });
2376
- }
2377
- function onSelect() {
2714
+ }, [onListener]);
2715
+ const onToday = useCallback(() => {
2716
+ yearControl.setValue(today.current.getFullYear());
2717
+ dayControl.setValue(today.current.getDate());
2718
+ monthControl.setValue(today.current.getMonth());
2719
+ formControl?.setValue(today.current);
2720
+ onListener &&
2721
+ onListener({
2722
+ event: PickerListenerEvent.Now,
2723
+ value: today.current
2724
+ });
2725
+ }, [today.current, formControl, onListener]);
2726
+ const onSelect = useCallback(() => {
2378
2727
  formControl?.setValue(value);
2379
- onListener && onListener({ event: PickerListenerEvent.Select, value });
2380
- }
2381
- return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--description", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: dateFormatTemplate(dateInitial, FORMAT_TITLE) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--year", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntimeExports.jsx(RlsPickerMonthTitle, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityMonth })] }), jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-picker-date__component', {
2382
- day: visibility === 'DAY',
2383
- month: visibility === 'MONTH',
2384
- year: visibility === 'YEAR'
2385
- }), children: [jsxRuntimeExports.jsx(RlsPickerDay, { formControl: dayControl, date: dateInitial, month: monthControl.value, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, date: dateInitial, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, date: dateInitial, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), !automatic && (jsxRuntimeExports.jsx("div", { className: "rls-picker-date__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--today", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onToday, disabled: dateOutRange({ date: today, maxDate, minDate }), children: reactI18n('dateActionToday') }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) }))] }));
2728
+ onListener &&
2729
+ onListener({
2730
+ event: PickerListenerEvent.Select,
2731
+ value
2732
+ });
2733
+ }, [formControl, value, onListener]);
2734
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--description", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: title }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__title rls-picker-date__title--year", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntimeExports.jsx(RlsPickerSelectorTitle, { monthControl: monthControl, yearControl: yearControl, date: value, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: 'month', onClick: onVisibilityMonth })] }), jsxRuntimeExports.jsxs("div", { className: classNameComponent, children: [jsxRuntimeExports.jsx(RlsPickerDay, { formControl: dayControl, date: _date, month: monthControl.value, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, date: _date, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, date: _date, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), !automatic && (jsxRuntimeExports.jsx("div", { className: "rls-picker-date__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: labels.dateActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--today", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onToday, disabled: itIsDisabledToday, children: labels.dateActionToday }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: onSelect, children: labels.dateActionSelect }) })] }) }))] }));
2386
2735
  }
2387
2736
 
2388
- const FORMAT_DATE = '{dd}/{mx}/{aa}';
2389
- function RlsFieldDate({ children, date, disabled, formControl, format, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, rlsTheme, value: defaultValue }) {
2390
- const today = new Date(); // Initial current date in component
2391
- const [value, setValue] = useState(formControl?.value || defaultValue);
2737
+ const formatDate = '{dd}/{mx}/{aa}';
2738
+ function RlsFieldDate({ children, date, disabled, formControl, format, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, rlsTheme, value: _value }) {
2739
+ const today = useRef(new Date()); // Initial current date in component
2740
+ const [value, setValue] = useState(formControl?.value ?? _value);
2392
2741
  const [modalIsVisible, setModalIsVisible] = useState(false);
2742
+ const _disabled = useMemo(() => {
2743
+ return formControl?.disabled || disabled;
2744
+ }, [formControl?.disabled, disabled]);
2745
+ const className = useMemo(() => {
2746
+ return renderClassStatus('rls-field-box', { disabled: _disabled });
2747
+ }, [_disabled]);
2748
+ const { icon, valueInput } = useMemo(() => {
2749
+ return {
2750
+ icon: value ? 'trash-2' : 'calendar',
2751
+ valueInput: value ? dateFormatTemplate(value, format || formatDate) : ''
2752
+ };
2753
+ }, [value]);
2393
2754
  useEffect(() => {
2394
- const dateRange = verifyDateRange({
2395
- date: formControl?.value || date || today,
2755
+ const _date = verifyDateRange({
2756
+ date: formControl?.value ?? date ?? today.current,
2396
2757
  minDate,
2397
2758
  maxDate
2398
2759
  });
2399
- setValue(dateRange);
2400
- formControl?.setValue(dateRange);
2760
+ setValue(_date);
2761
+ formControl?.setValue(_date);
2401
2762
  }, []);
2402
- function onChange(value) {
2763
+ const onClickInput = useCallback(() => {
2764
+ setModalIsVisible(true);
2765
+ }, []);
2766
+ const onChange = useCallback((value) => {
2403
2767
  setValue(value);
2404
2768
  onValue && onValue(value);
2405
- }
2406
- function onClickInput() {
2407
- setModalIsVisible(true);
2408
- }
2409
- function onClickAction() {
2769
+ }, [onValue]);
2770
+ const onClickAction = useCallback(() => {
2410
2771
  if (value) {
2411
- formControl?.setValue(defaultValue);
2772
+ formControl?.setValue(_value);
2412
2773
  formControl?.touch();
2413
- onChange(defaultValue);
2774
+ onChange(_value);
2414
2775
  }
2415
2776
  else {
2416
2777
  setModalIsVisible(true);
2417
2778
  }
2418
- }
2419
- const valueInput = value
2420
- ? dateFormatTemplate(value, format || FORMAT_DATE)
2421
- : '';
2422
- const _disabled = formControl?.disabled || disabled;
2423
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-field-box', { disabled: _disabled }), children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-date__control", type: "text", value: valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: _disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date__action", onClick: onClickAction, disabled: disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: _disabled, maxDate: maxDate, minDate: minDate, onListener: ({ event, value }) => {
2424
- event !== PickerListenerEvent.Cancel && onChange(value);
2425
- formControl?.touch();
2426
- setModalIsVisible(false);
2427
- } }) })] }));
2428
- }
2429
-
2430
- function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
2431
- const dateInitial = normalizeMinTime(datePicker || new Date());
2432
- const rangeInitial = formControl?.value || DateRange.now();
2433
- const yearControl = useReactControl(dateInitial.getFullYear());
2434
- const monthControl = useReactControl(dateInitial.getMonth());
2435
- const dayControl = useReactControl(rangeInitial);
2436
- const [value, setValue] = useState(rangeInitial);
2437
- const [date, setDate] = useState(dateInitial);
2779
+ }, [value, formControl, _value, onChange]);
2780
+ const onListener = useCallback(({ event, value }) => {
2781
+ event !== PickerListenerEvent.Cancel && onChange(value);
2782
+ formControl?.touch();
2783
+ setModalIsVisible(false);
2784
+ }, [formControl, onChange]);
2785
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-date__control", type: "text", value: valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: _disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date__action", onClick: onClickAction, disabled: _disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDate, { formControl: formControl, date: date, disabled: _disabled, maxDate: maxDate, minDate: minDate, onListener: onListener }) })] }));
2786
+ }
2787
+
2788
+ function RlsPickerDateRange({ automatic, date: _picker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
2789
+ const _date = useMemo(() => normalizeMinTime(_picker ?? new Date()), [_picker]);
2790
+ const _range = useMemo(() => formControl?.value ?? DateRange.now(), [formControl?.value]);
2791
+ const yearControl = useReactControl(_date.getFullYear());
2792
+ const monthControl = useReactControl(_date.getMonth());
2793
+ const rangeControl = useReactControl(_range);
2794
+ const [value, setValue] = useState(_range);
2795
+ const [date, setDate] = useState(_date);
2438
2796
  const [visibility, setVisibility] = useState('DAY');
2797
+ const [labels, setLabels] = useState({
2798
+ dateActionCancel: reactI18n('dateActionCancel'),
2799
+ dateActionSelect: reactI18n('dateActionSelect')
2800
+ });
2801
+ const classNameComponent = useMemo(() => {
2802
+ return renderClassStatus('rls-picker-date-range__component', {
2803
+ day: visibility === 'DAY',
2804
+ month: visibility === 'MONTH',
2805
+ year: visibility === 'YEAR'
2806
+ });
2807
+ }, [visibility]);
2808
+ const classNameFooter = useMemo(() => {
2809
+ return renderClassStatus('rls-picker-date-range__footer', { automatic });
2810
+ }, [automatic]);
2811
+ const title = useMemo(() => rangeFormatTemplate(value), [value]);
2439
2812
  useEffect(() => {
2440
- setDate((prevValue) => {
2441
- return typeof yearControl.value === 'number'
2442
- ? assignYearInDate(prevValue, yearControl.value)
2443
- : prevValue;
2813
+ return i18nSubscribe(() => {
2814
+ setLabels({
2815
+ dateActionCancel: reactI18n('dateActionCancel'),
2816
+ dateActionSelect: reactI18n('dateActionSelect')
2817
+ });
2818
+ });
2819
+ }, []);
2820
+ useEffect(() => {
2821
+ setDate((date) => {
2822
+ return itIsDefined(yearControl.value)
2823
+ ? assignYearInDate(date, yearControl.value)
2824
+ : date;
2444
2825
  });
2445
2826
  }, [yearControl.value]);
2446
2827
  useEffect(() => {
2447
- setDate((prevValue) => {
2448
- return typeof monthControl.value === 'number'
2449
- ? assignMonthInDate(prevValue, monthControl.value)
2450
- : prevValue;
2828
+ setDate((date) => {
2829
+ return itIsDefined(monthControl.value)
2830
+ ? assignMonthInDate(date, monthControl.value)
2831
+ : date;
2451
2832
  });
2452
2833
  }, [monthControl.value]);
2453
2834
  useEffect(() => {
2454
- dayControl.value && setValue(dayControl.value);
2835
+ rangeControl.value && setValue(rangeControl.value);
2455
2836
  setVisibility('DAY');
2456
- }, [dayControl.value]);
2457
- function onVisibilityDay() {
2837
+ }, [rangeControl.value]);
2838
+ const onVisibilityDay = useCallback(() => {
2458
2839
  setVisibility('DAY');
2459
- }
2460
- function onVisibilityMonth() {
2840
+ }, []);
2841
+ const onVisibilityMonth = useCallback(() => {
2461
2842
  setVisibility('MONTH');
2462
- }
2463
- function onVisibilityYear() {
2843
+ }, []);
2844
+ const onVisibilityYear = useCallback(() => {
2464
2845
  setVisibility('YEAR');
2465
- }
2466
- function onCancel() {
2846
+ }, []);
2847
+ const onCancel = useCallback(() => {
2467
2848
  onListener && onListener({ event: PickerListenerEvent.Cancel });
2468
- }
2469
- function onSelect() {
2849
+ }, [onListener]);
2850
+ const onSelect = useCallback(() => {
2470
2851
  formControl?.setValue(value);
2471
2852
  onListener && onListener({ event: PickerListenerEvent.Select, value });
2472
- }
2473
- return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--description", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: rangeFormatTemplate(value) }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--year", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntimeExports.jsx(RlsPickerMonthTitle, { monthControl: monthControl, yearControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: visibility === 'MONTH' ? 'year' : 'month', onClick: onVisibilityMonth })] }), jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-picker-date-range__component', {
2474
- day: visibility === 'DAY',
2475
- month: visibility === 'MONTH',
2476
- year: visibility === 'YEAR'
2477
- }), children: [jsxRuntimeExports.jsx(RlsPickerDayRange, { formControl: dayControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntimeExports.jsx("div", { className: useRenderClassStatus('rls-picker-date-range__footer', {
2478
- automatic
2479
- }), children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: reactI18n('dateActionCancel') }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: onSelect, children: reactI18n('dateActionSelect') }) })] }) })] }));
2853
+ }, [formControl, value, onListener]);
2854
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--description", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityDay, children: title }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__title rls-picker-date-range__title--year", children: jsxRuntimeExports.jsx("span", { onClick: onVisibilityYear, children: yearControl.value }) }), jsxRuntimeExports.jsx(RlsPickerSelectorTitle, { monthControl: monthControl, yearControl: yearControl, date: date, maxDate: maxDate, minDate: minDate, disabled: visibility === 'YEAR', type: visibility === 'MONTH' ? 'year' : 'month', onClick: onVisibilityMonth })] }), jsxRuntimeExports.jsxs("div", { className: classNameComponent, children: [jsxRuntimeExports.jsx(RlsPickerDayRange, { formControl: rangeControl, date: date, maxDate: maxDate, minDate: minDate, disabled: disabled }), jsxRuntimeExports.jsx(RlsPickerMonth, { formControl: monthControl, year: yearControl.value, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay }), jsxRuntimeExports.jsx(RlsPickerYear, { formControl: yearControl, maxDate: maxDate, minDate: minDate, disabled: disabled, onValue: onVisibilityDay })] }), jsxRuntimeExports.jsx("div", { className: classNameFooter, children: jsxRuntimeExports.jsxs("div", { className: "rls-picker-date-range__actions", children: [jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--cancel", children: jsxRuntimeExports.jsx(RlsButton, { type: "ghost", onClick: onCancel, children: labels.dateActionCancel }) }), jsxRuntimeExports.jsx("div", { className: "rls-picker-date-range__actions--ok", children: jsxRuntimeExports.jsx(RlsButton, { type: "raised", onClick: onSelect, children: labels.dateActionSelect }) })] }) })] }));
2480
2855
  }
2481
2856
 
2482
- function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, rlsTheme, value: defaultValue }) {
2483
- const currentDate = datePicker || new Date();
2484
- const [value, setValue] = useState(formControl?.value || defaultValue);
2857
+ function RlsFieldDateRange({ children, date: _date, disabled, formControl, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, rlsTheme, value: _value }) {
2858
+ const currentDate = useMemo(() => _date ?? new Date(), [_date]);
2859
+ const [value, setValue] = useState(formControl?.value || _value);
2485
2860
  const [modalIsVisible, setModalIsVisible] = useState(false);
2486
- function onClickInput() {
2861
+ const _disabled = useMemo(() => {
2862
+ return formControl?.disabled || disabled;
2863
+ }, [formControl?.disabled, disabled]);
2864
+ const className = useMemo(() => {
2865
+ return renderClassStatus('rls-field-box', { disabled: _disabled });
2866
+ }, [_disabled]);
2867
+ const { icon, valueInput } = useMemo(() => {
2868
+ return {
2869
+ icon: value ? 'trash-2' : 'calendar',
2870
+ valueInput: value ? rangeFormatTemplate(value) : ''
2871
+ };
2872
+ }, [value]);
2873
+ const onClickInput = useCallback(() => {
2487
2874
  setModalIsVisible(true);
2488
- }
2489
- function onClickAction() {
2875
+ }, []);
2876
+ const onChange = useCallback((value) => {
2877
+ setValue(value);
2878
+ onValue && onValue(value);
2879
+ }, [onValue]);
2880
+ const onClickAction = useCallback(() => {
2490
2881
  if (value) {
2491
- formControl?.setValue(defaultValue);
2882
+ formControl?.setValue(_value);
2492
2883
  formControl?.touch();
2493
- onChange(defaultValue);
2884
+ onChange(_value);
2494
2885
  }
2495
2886
  else {
2496
2887
  setModalIsVisible(true);
2497
2888
  }
2498
- }
2499
- function onChange(value) {
2500
- setValue(value);
2501
- onValue && onValue(value);
2502
- }
2503
- const _disabled = formControl?.disabled || disabled;
2504
- return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-field-box', {
2505
- disabled: _disabled
2506
- }), children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-date-range__control", type: "text", value: value ? rangeFormatTemplate(value) : '', readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: _disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date-range__action", onClick: onClickAction, disabled: _disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: value ? 'trash-2' : 'calendar' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: _disabled, maxDate: maxDate, minDate: minDate, onListener: ({ event, value }) => {
2507
- event !== PickerListenerEvent.Cancel && onChange(value);
2508
- formControl?.touch();
2509
- setModalIsVisible(false);
2510
- } }) })] }));
2889
+ }, [value, formControl, _value, onChange]);
2890
+ const onListener = useCallback(({ event, value }) => {
2891
+ event !== PickerListenerEvent.Cancel && onChange(value);
2892
+ formControl?.touch();
2893
+ setModalIsVisible(false);
2894
+ }, [formControl, onChange]);
2895
+ return (jsxRuntimeExports.jsxs("div", { id: identifier, className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { className: "rls-field-date-range__control", type: "text", value: valueInput, readOnly: true, placeholder: placeholder, onClick: onClickInput, disabled: _disabled }), jsxRuntimeExports.jsx("button", { className: "rls-field-date-range__action", onClick: onClickAction, disabled: _disabled, children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl }))] }), jsxRuntimeExports.jsx(RlsModal, { visible: modalIsVisible, rlsTheme: rlsTheme, children: jsxRuntimeExports.jsx(RlsPickerDateRange, { formControl: formControl, date: currentDate, disabled: _disabled, maxDate: maxDate, minDate: minDate, onListener: onListener }) })] }));
2511
2896
  }
2512
2897
 
2513
2898
  function useFieldSelect(props) {
2514
2899
  const controller = useListController(props);
2515
- function onFocusInput() {
2900
+ const onFocusInput = useCallback(() => {
2516
2901
  controller.setState({ focused: true });
2517
- }
2518
- function onBlurInput() {
2902
+ }, [controller.setState]);
2903
+ const onBlurInput = useCallback(() => {
2519
2904
  controller.setState({ focused: false });
2520
- }
2521
- function onClickInput() {
2905
+ }, [controller.setState]);
2906
+ const onClickInput = useCallback(() => {
2522
2907
  controller.setState({ modalIsVisible: true });
2523
- }
2524
- function onKeydownInput(event) {
2908
+ }, [controller.setState]);
2909
+ const onKeydownInput = useCallback((event) => {
2525
2910
  switch (event.code) {
2526
2911
  case 'Space':
2527
2912
  case 'Enter':
@@ -2535,8 +2920,8 @@ function useFieldSelect(props) {
2535
2920
  controller.navigationInput(event);
2536
2921
  break;
2537
2922
  }
2538
- }
2539
- function onClickAction() {
2923
+ }, [controller.setState, controller.navigationInput]);
2924
+ const onClickAction = useCallback(() => {
2540
2925
  const removable = !props.unremovable && !!controller.value;
2541
2926
  if (removable) {
2542
2927
  controller.setState({ modalIsVisible: false });
@@ -2548,35 +2933,46 @@ function useFieldSelect(props) {
2548
2933
  controller.setState({ modalIsVisible });
2549
2934
  modalIsVisible && controller.inputRef?.current?.focus();
2550
2935
  }
2551
- }
2552
- function onClickBackdrop() {
2936
+ }, [
2937
+ controller.modalIsVisible,
2938
+ controller.value,
2939
+ controller.setState,
2940
+ controller.setFormValue,
2941
+ props.unremovable,
2942
+ props.onValue
2943
+ ]);
2944
+ const onClickBackdrop = useCallback(() => {
2553
2945
  controller.setState({ modalIsVisible: false });
2554
- }
2555
- function onClickElement(element) {
2946
+ }, [controller.setState]);
2947
+ const onChange = useCallback((element) => {
2948
+ controller.inputRef?.current?.focus();
2949
+ if (props.onSelect) {
2950
+ controller.setState({ modalIsVisible: false });
2951
+ element.value && props.onSelect(element.value);
2952
+ }
2953
+ else {
2954
+ controller.setFormValue(element);
2955
+ controller.setState({ modalIsVisible: false });
2956
+ }
2957
+ props.onValue && props.onValue(element.value);
2958
+ }, [
2959
+ controller.setState,
2960
+ controller.setFormValue,
2961
+ props.onSelect,
2962
+ props.onValue
2963
+ ]);
2964
+ const onClickElement = useCallback((element) => {
2556
2965
  return () => {
2557
2966
  onChange(element);
2558
2967
  };
2559
- }
2560
- function onKeydownElement(element) {
2968
+ }, []);
2969
+ const onKeydownElement = useCallback((element) => {
2561
2970
  return (event) => {
2562
2971
  event.code === 'Enter'
2563
2972
  ? onChange(element)
2564
2973
  : controller.navigationElement(event);
2565
2974
  };
2566
- }
2567
- function onChange(element) {
2568
- const { onSelect, onValue } = props;
2569
- controller.inputRef?.current?.focus();
2570
- if (onSelect) {
2571
- controller.setState({ modalIsVisible: false });
2572
- element.value && onSelect(element.value);
2573
- }
2574
- else {
2575
- controller.setFormValue(element);
2576
- controller.setState({ modalIsVisible: false });
2577
- }
2578
- onValue && onValue(element.value);
2579
- }
2975
+ }, [controller.navigationElement]);
2580
2976
  return {
2581
2977
  ...controller,
2582
2978
  onBlurInput,
@@ -2593,23 +2989,45 @@ function useFieldSelect(props) {
2593
2989
  function RlsFieldSelectTemplate(props) {
2594
2990
  const select = useFieldSelect(props);
2595
2991
  const { render, suggestions, children, formControl, msgErrorDisabled, placeholder, rlsTheme, unremovable } = props;
2596
- const _disabled = formControl?.disabled || props.disabled;
2597
- const className = useRenderClassStatus('rls-field-box', {
2598
- disabled: _disabled,
2599
- error: formControl?.wrong,
2600
- focused: select.focused && !_disabled
2601
- }, 'rls-field-list rls-field-select');
2602
- return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.contentRef, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { ref: select.inputRef, className: "rls-field-list__control", readOnly: true, disabled: _disabled, placeholder: placeholder, value: select.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput }), jsxRuntimeExports.jsx("button", { className: 'rls-field-list__action', disabled: _disabled, onClick: select.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: !unremovable && !!select.value ? 'close' : 'arrow-ios-down' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx("div", { className: useRenderClassStatus('rls-field-list__suggestions', {
2603
- higher: select.higher,
2604
- visible: select.modalIsVisible
2605
- }), children: select.modalIsVisible && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: select.listRef, className: "rls-field-list__ul", children: [suggestions.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: select.onClickElement(element), onKeyDown: select.onKeydownElement(element), children: render(element) }, index))), !suggestions.length && (jsxRuntimeExports.jsx("li", { className: "rls-field-list__empty", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntimeExports.jsx("label", { className: "rls-label-bold truncate", children: reactI18n('listEmptyTitle') }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: reactI18n('listEmptyDescription') })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: select.onClickBackdrop })] })) })] }));
2992
+ const [labels, setLabels] = useState({
2993
+ listEmptyDescription: reactI18n('listEmptyDescription'),
2994
+ listEmptyTitle: reactI18n('listEmptyTitle')
2995
+ });
2996
+ useEffect(() => {
2997
+ return i18nSubscribe(() => {
2998
+ setLabels({
2999
+ listEmptyDescription: reactI18n('listEmptyDescription'),
3000
+ listEmptyTitle: reactI18n('listEmptyTitle')
3001
+ });
3002
+ });
3003
+ }, []);
3004
+ const _disabled = useMemo(() => {
3005
+ return formControl?.disabled || props.disabled;
3006
+ }, [formControl?.disabled, props.disabled]);
3007
+ const className = useMemo(() => {
3008
+ return renderClassStatus('rls-field-box', {
3009
+ disabled: _disabled,
3010
+ error: formControl?.wrong,
3011
+ focused: select.focused && !_disabled
3012
+ }, 'rls-field-list rls-field-select');
3013
+ }, [formControl?.wrong, select.focused, _disabled]);
3014
+ const classNameList = useMemo(() => {
3015
+ return renderClassStatus('rls-field-list__suggestions', {
3016
+ higher: select.higher,
3017
+ visible: select.modalIsVisible
3018
+ });
3019
+ }, [select.modalIsVisible, select.higher]);
3020
+ return (jsxRuntimeExports.jsxs("div", { id: props.identifier, ref: select.contentRef, className: className, "rls-theme": rlsTheme, children: [children && jsxRuntimeExports.jsx("label", { className: "rls-field-box__label", children: children }), jsxRuntimeExports.jsx("div", { className: "rls-field-box__component", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-box__body", children: [jsxRuntimeExports.jsx("input", { ref: select.inputRef, className: "rls-field-list__control", readOnly: true, disabled: _disabled, placeholder: placeholder, value: select.value, onFocus: select.onFocusInput, onBlur: select.onBlurInput, onClick: select.onClickInput, onKeyDown: select.onKeydownInput }), jsxRuntimeExports.jsx("button", { className: 'rls-field-list__action', disabled: _disabled, onClick: select.onClickAction, children: jsxRuntimeExports.jsx(RlsIcon, { value: !unremovable && !!select.value ? 'close' : 'arrow-ios-down' }) })] }) }), !msgErrorDisabled && (jsxRuntimeExports.jsx(RlsMessageFormError, { className: "rls-field-box__error", formControl: formControl })), jsxRuntimeExports.jsx("div", { className: classNameList, children: select.modalIsVisible && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "rls-field-list__suggestions__body", children: jsxRuntimeExports.jsxs("ul", { ref: select.listRef, className: "rls-field-list__ul", children: [suggestions.map((element, index) => (jsxRuntimeExports.jsx("li", { className: "rls-field-list__element", tabIndex: -1, onClick: select.onClickElement(element), onKeyDown: select.onKeydownElement(element), children: render(element) }, index))), !suggestions.length && (jsxRuntimeExports.jsx("li", { className: "rls-field-list__empty", children: jsxRuntimeExports.jsxs("div", { className: "rls-field-list__empty__description", children: [jsxRuntimeExports.jsx("label", { className: "rls-label-bold truncate", children: labels.listEmptyTitle }), jsxRuntimeExports.jsx("p", { className: "rls-caption-regular", children: labels.listEmptyDescription })] }) }))] }) }), jsxRuntimeExports.jsx("div", { className: "rls-field-list__backdrop", onClick: select.onClickBackdrop })] })) })] }));
2606
3021
  }
2607
3022
  function RlsFieldSelect(props) {
2608
3023
  return (jsxRuntimeExports.jsx(RlsFieldSelectTemplate, { ...props, render: (element) => (jsxRuntimeExports.jsx(RlsBallot, { subtitle: element.subtitle, img: element.img, initials: element.initials, children: jsxRuntimeExports.jsx("span", { children: element.title }) })) }));
2609
3024
  }
2610
3025
 
2611
3026
  function RlsFormNavigation({ children, visible, rlsTheme }) {
2612
- return (jsxRuntimeExports.jsx("div", { className: useRenderClassStatus('rls-form-navigation', { visible }), "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
3027
+ const className = useMemo(() => {
3028
+ return renderClassStatus('rls-form-navigation', { visible });
3029
+ }, [visible]);
3030
+ return (jsxRuntimeExports.jsx("div", { className: className, "rls-theme": rlsTheme, children: jsxRuntimeExports.jsx("div", { className: "rls-form-navigation__body", children: children }) }));
2613
3031
  }
2614
3032
 
2615
3033
  const DURATION_ANIMATION = 240;
@@ -2628,32 +3046,42 @@ function calculateDuration({ length }) {
2628
3046
  return duration + DURATION_RESET;
2629
3047
  }
2630
3048
  function RlsSnackbar({ content, icon, title, visible, rlsTheme }) {
2631
- return (jsxRuntimeExports.jsxs("div", { className: useRenderClassStatus('rls-snackbar', { visible }), "rls-theme": rlsTheme, children: [icon && (jsxRuntimeExports.jsx("div", { className: "rls-snackbar__avatar", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) })), jsxRuntimeExports.jsxs("div", { className: "rls-snackbar__component", children: [title && jsxRuntimeExports.jsx("div", { className: "rls-snackbar__title", children: title }), jsxRuntimeExports.jsx("div", { className: "rls-snackbar__content", children: content })] })] }));
3049
+ const className = useMemo(() => {
3050
+ return renderClassStatus('rls-snackbar', { visible });
3051
+ }, [visible]);
3052
+ return (jsxRuntimeExports.jsxs("div", { className: className, "rls-theme": rlsTheme, children: [icon && (jsxRuntimeExports.jsx("div", { className: "rls-snackbar__avatar", children: jsxRuntimeExports.jsx(RlsIcon, { value: icon }) })), jsxRuntimeExports.jsxs("div", { className: "rls-snackbar__component", children: [title && jsxRuntimeExports.jsx("div", { className: "rls-snackbar__title", children: title }), jsxRuntimeExports.jsx("div", { className: "rls-snackbar__content", children: content })] })] }));
2632
3053
  }
2633
3054
  function useSnackbar() {
2634
- const [config, setConfig] = useState({});
2635
- const [duration, setDuration] = useState(4000);
2636
- const [timeoutId, setTimeoutId] = useState();
2637
- const [visible, setVisible] = useState(false);
2638
- const rlsSnackbar = jsxRuntimeExports.jsx(RlsSnackbar, { ...config, visible: visible });
3055
+ const [state, setState] = useState({
3056
+ config: {},
3057
+ duration: 4000,
3058
+ timeoutId: undefined,
3059
+ visible: false
3060
+ });
3061
+ const rlsSnackbar = jsxRuntimeExports.jsx(RlsSnackbar, { ...state.config, visible: state.visible });
2639
3062
  useEffect(() => {
2640
- if (visible) {
3063
+ if (state.visible) {
2641
3064
  const timeoutId = setTimeout(() => {
2642
- setVisible(false);
2643
- setTimeoutId(undefined);
2644
- }, duration);
2645
- setTimeoutId(timeoutId);
3065
+ setState((state) => ({
3066
+ ...state,
3067
+ visible: false,
3068
+ timeoutId: undefined
3069
+ }));
3070
+ }, state.duration);
3071
+ setState((state) => ({ ...state, timeoutId }));
2646
3072
  }
2647
- else if (timeoutId) {
2648
- clearTimeout(timeoutId);
2649
- setTimeout(() => snackbar(config), DURATION_ANIMATION);
3073
+ else if (state.timeoutId) {
3074
+ clearTimeout(state.timeoutId);
3075
+ setTimeout(() => snackbar(state.config), DURATION_ANIMATION);
2650
3076
  }
2651
- }, [visible]);
3077
+ }, [state.visible]);
2652
3078
  const snackbar = useCallback((config) => {
2653
- const { content } = config;
2654
- setConfig(config);
2655
- setDuration(calculateDuration(String(content)));
2656
- setVisible((visible) => !visible);
3079
+ setState((state) => ({
3080
+ ...state,
3081
+ config,
3082
+ duration: calculateDuration(String(config.content)),
3083
+ visible: !state.visible
3084
+ }));
2657
3085
  }, []);
2658
3086
  return {
2659
3087
  RlsSnackbar: rlsSnackbar,
@@ -2671,11 +3099,12 @@ const RlsContext = createContext({
2671
3099
  function RlsApplication({ children }) {
2672
3100
  const { RlsConfirmation, confirmation } = useConfirmation();
2673
3101
  const { RlsSnackbar, snackbar } = useSnackbar();
2674
- const [currentWithNavbar, withNavbar] = useState(false);
2675
- return (jsxRuntimeExports.jsxs(RlsContext.Provider, { value: { confirmation, snackbar, withNavbar }, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-app__body', {
2676
- snackbar: currentWithNavbar
2677
- }), children: [children, RlsSnackbar] }), RlsConfirmation] }));
3102
+ const [_withNavbar, withNavbar] = useState(false);
3103
+ const className = useMemo(() => {
3104
+ return renderClassStatus('rls-app__body', { snackbar: _withNavbar });
3105
+ }, [_withNavbar]);
3106
+ return (jsxRuntimeExports.jsxs(RlsContext.Provider, { value: { confirmation, snackbar, withNavbar }, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
2678
3107
  }
2679
3108
 
2680
- export { ConfirmationResult, RlsAlert, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerMonthTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsTabularText, RlsToolbar, rangeFormatTemplate, renderClassStatus, useConfirmation, useDatatable, useListController, useRenderClassStatus, useSnackbar };
3109
+ export { ConfirmationResult, RlsAlert, RlsAmount, RlsApplication, RlsAvatar, RlsBadge, RlsBallot, RlsBreadcrumb, RlsButton, RlsButtonAction, RlsButtonProgress, RlsButtonToggle, RlsCard, RlsCheckBox, RlsCheckBoxControl, RlsConfirmation, RlsContext, RlsDatatable, RlsDatatableCell, RlsDatatableData, RlsDatatableHeader, RlsDatatableRecord, RlsDatatableSubheader, RlsDatatableTitle, RlsDatatableTotals, RlsFieldAutocomplete, RlsFieldAutocompleteTemplate, RlsFieldDate, RlsFieldDateRange, RlsFieldMoney, RlsFieldNumber, RlsFieldPassword, RlsFieldSelect, RlsFieldSelectTemplate, RlsFieldText, RlsFormNavigation, RlsIcon, RlsInput, RlsInputMoney, RlsInputNumber, RlsInputPassword, RlsInputSearch, RlsInputText, RlsLabel, RlsLabelCheckBox, RlsLabelRadioButton, RlsLabelSwitch, RlsMessageFormError, RlsMessageIcon, RlsModal, RlsPagination, RlsPickerDate, RlsPickerDateRange, RlsPickerDay, RlsPickerDayRange, RlsPickerMonth, RlsPickerSelectorTitle, RlsPickerYear, RlsPoster, RlsProgressBar, RlsProgressCircular, RlsRadioButton, RlsSkeleton, RlsSkeletonText, RlsSnackbar, RlsSwitch, RlsSwitchControl, RlsTabularText, RlsToolbar, rangeFormatTemplate, renderClassStatus, setErrorsI18n, useConfirmation, useDatatable, useListController, useSnackbar };
2681
3110
  //# sourceMappingURL=index.js.map