@rolster/react-components 18.15.7 → 18.15.10

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 (59) hide show
  1. package/dist/cjs/assets/{index-Bi1j_H-P.css → index-l02yDX9t.css} +7 -4
  2. package/dist/cjs/index.js +122 -193
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/es/assets/{index-Bi1j_H-P.css → index-l02yDX9t.css} +7 -4
  5. package/dist/es/index.js +122 -193
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/esm/components/atoms/Input/Input.js +7 -9
  8. package/dist/esm/components/atoms/Input/Input.js.map +1 -1
  9. package/dist/esm/components/atoms/InputMoney/InputMoney.js +3 -7
  10. package/dist/esm/components/atoms/InputMoney/InputMoney.js.map +1 -1
  11. package/dist/esm/components/atoms/InputNumber/InputNumber.js +4 -8
  12. package/dist/esm/components/atoms/InputNumber/InputNumber.js.map +1 -1
  13. package/dist/esm/components/atoms/InputPassword/InputPassword.js +3 -5
  14. package/dist/esm/components/atoms/InputPassword/InputPassword.js.map +1 -1
  15. package/dist/esm/components/atoms/InputText/InputText.js +3 -7
  16. package/dist/esm/components/atoms/InputText/InputText.js.map +1 -1
  17. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js +8 -8
  18. package/dist/esm/components/molecules/ButtonToggle/ButtonToggle.js.map +1 -1
  19. package/dist/esm/components/molecules/FieldPassword/FieldPassword.css +6 -3
  20. package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.d.ts +4 -4
  21. package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.js +1 -3
  22. package/dist/esm/components/molecules/LabelRadioButton/LabelRadioButton.js.map +1 -1
  23. package/dist/esm/components/molecules/PickerDay/PickerDay.js +1 -3
  24. package/dist/esm/components/molecules/PickerDay/PickerDay.js.map +1 -1
  25. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js +5 -1
  26. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js.map +1 -1
  27. package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +5 -1
  28. package/dist/esm/components/molecules/PickerMonth/PickerMonth.js.map +1 -1
  29. package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js +2 -4
  30. package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js.map +1 -1
  31. package/dist/esm/components/molecules/PickerYear/PickerYear.js +6 -4
  32. package/dist/esm/components/molecules/PickerYear/PickerYear.js.map +1 -1
  33. package/dist/esm/components/organisms/Confirmation/Confirmation.css +1 -1
  34. package/dist/esm/components/organisms/Confirmation/Confirmation.js +1 -1
  35. package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
  36. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +1 -1
  37. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
  38. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.d.ts +1 -1
  39. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js +3 -45
  40. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteHook.js.map +1 -1
  41. package/dist/esm/components/organisms/FieldDate/FieldDate.js +2 -6
  42. package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
  43. package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +1 -3
  44. package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js.map +1 -1
  45. package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +1 -1
  46. package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
  47. package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js +3 -46
  48. package/dist/esm/components/organisms/FieldSelect/FieldSelectHook.js.map +1 -1
  49. package/dist/esm/components/organisms/PickerDate/PickerDate.js +7 -16
  50. package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
  51. package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js +4 -10
  52. package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js.map +1 -1
  53. package/dist/esm/hooks/ListControlHook.d.ts +4 -4
  54. package/dist/esm/hooks/ListControlHook.js +56 -10
  55. package/dist/esm/hooks/ListControlHook.js.map +1 -1
  56. package/dist/esm/i18n.d.ts +1 -2
  57. package/dist/esm/i18n.js +1 -2
  58. package/dist/esm/i18n.js.map +1 -1
  59. package/package.json +5 -5
@@ -1029,14 +1029,17 @@
1029
1029
 
1030
1030
  .rls-field-password {
1031
1031
  --rlc-fieldbox-body-padding: var(--rls-sizing-x3) var(--rls-sizing-x4);
1032
- --rlc-action-ripple-dimension: var(--rls-sizing-x16);
1033
- --rlc-action-ripple-position: -8rem;
1032
+ --rlc-action-ripple-dimension: var(--rls-sizing-x12);
1033
+ --rlc-action-ripple-position: -6rem;
1034
1034
  position: relative;
1035
1035
  width: 100%;
1036
1036
  box-sizing: border-box;
1037
1037
  }
1038
1038
  .rls-field-password .rls-button-action {
1039
- margin: auto var(--rls-sizing-x2) auto 0rem;
1039
+ padding: 0rem;
1040
+ width: var(--rls-sizing-x12);
1041
+ height: var(--rls-sizing-x12);
1042
+ z-index: 2;
1040
1043
  }
1041
1044
 
1042
1045
  .rls-field-text {
@@ -1697,7 +1700,7 @@
1697
1700
  }
1698
1701
  .rls-confirmation__subtitle {
1699
1702
  text-align: center;
1700
- color: var(--rls-theme-color-300);
1703
+ color: var(--rls-theme-color-400);
1701
1704
  font-weight: var(--rls-font-weight-bold);
1702
1705
  font-size: var(--pvt-subtitle-font-size);
1703
1706
  line-height: var(--pvt-subtitle-line-height);
package/dist/es/index.js CHANGED
@@ -1418,14 +1418,12 @@ function RlsCheckBoxControl({ formControl, disabled, rlsTheme }) {
1418
1418
 
1419
1419
  function RlsInput({ children, disabled, formControl, placeholder, type, value, onValue }) {
1420
1420
  const [focused, setFocused] = useState(false);
1421
- function onChange(event) {
1422
- setValue(type === 'number' ? +event.target.value : event.target.value);
1423
- }
1424
1421
  function setValue(value) {
1425
1422
  formControl?.setValue(value);
1426
- if (onValue) {
1427
- onValue(value);
1428
- }
1423
+ onValue && onValue(value);
1424
+ }
1425
+ function onChange(event) {
1426
+ setValue(type === 'number' ? +event.target.value : event.target.value);
1429
1427
  }
1430
1428
  function onFocus() {
1431
1429
  formControl?.focus();
@@ -1436,44 +1434,34 @@ function RlsInput({ children, disabled, formControl, placeholder, type, value, o
1436
1434
  setFocused(false);
1437
1435
  }
1438
1436
  return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-input', {
1439
- focused: formControl?.focused || focused,
1440
- disabled: formControl?.disabled || disabled
1441
- }), 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 })] }));
1437
+ focused: formControl?.focused ?? focused,
1438
+ disabled: formControl?.disabled ?? disabled
1439
+ }), 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 })] }));
1442
1440
  }
1443
1441
 
1444
1442
  function RlsInputMoney({ decimals, disabled, formControl, placeholder, symbol, value, onValue }) {
1445
1443
  const [valueInput, setValueInput] = useState(value || 0);
1446
1444
  function onChange(value) {
1447
- if (!formControl) {
1448
- setValueInput(value);
1449
- }
1450
- if (onValue) {
1451
- onValue(value);
1452
- }
1445
+ !formControl && setValueInput(value);
1446
+ onValue && onValue(value);
1453
1447
  }
1454
- return (jsxRuntimeExports.jsx("div", { className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.value || value || valueInput, symbol: symbol, decimals: decimals }) }) }));
1448
+ return (jsxRuntimeExports.jsx("div", { className: "rls-input-money", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: jsxRuntimeExports.jsx(RlsAmount, { value: formControl?.value ?? value ?? valueInput, symbol: symbol, decimals: decimals }) }) }));
1455
1449
  }
1456
1450
 
1457
1451
  function RlsInputNumber({ disabled, formControl, placeholder, value, onValue }) {
1458
- const [valueInput, setValueInput] = useState(value || 0);
1452
+ const [valueInput, setValueInput] = useState(value ?? 0);
1459
1453
  function onChange(value) {
1460
- if (!formControl) {
1461
- setValueInput(value);
1462
- }
1463
- if (onValue) {
1464
- onValue(value);
1465
- }
1454
+ !formControl && setValueInput(value);
1455
+ onValue && onValue(value);
1466
1456
  }
1467
- return (jsxRuntimeExports.jsx("div", { className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value || value || valueInput }) }));
1457
+ return (jsxRuntimeExports.jsx("div", { className: "rls-input-number", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "number", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value ?? value ?? valueInput }) }));
1468
1458
  }
1469
1459
 
1470
1460
  function RlsInputPassword({ disabled, formControl, placeholder, type, onValue }) {
1471
1461
  const [focused, setFocused] = useState(false);
1472
1462
  function onChange(event) {
1473
1463
  formControl?.setValue(event.target.value);
1474
- if (onValue) {
1475
- onValue(event.target.value);
1476
- }
1464
+ onValue && onValue(event.target.value);
1477
1465
  }
1478
1466
  function onFocus() {
1479
1467
  formControl?.focus();
@@ -1484,9 +1472,9 @@ function RlsInputPassword({ disabled, formControl, placeholder, type, onValue })
1484
1472
  setFocused(false);
1485
1473
  }
1486
1474
  return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-input-password', {
1487
- focused: formControl?.focused || focused,
1475
+ focused: formControl?.focused ?? focused,
1488
1476
  disabled
1489
- }), children: jsxRuntimeExports.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type || 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
1477
+ }), children: jsxRuntimeExports.jsx("input", { className: "rls-input-password__component", autoComplete: "off", type: type ?? 'password', placeholder: placeholder, disabled: disabled, onFocus: onFocus, onBlur: onBlur, onChange: onChange }) }));
1490
1478
  }
1491
1479
 
1492
1480
  function RlsInputSearch({ formControl, placeholder, onSearch }) {
@@ -1496,14 +1484,10 @@ function RlsInputSearch({ formControl, placeholder, onSearch }) {
1496
1484
  function RlsInputText({ disabled, formControl, placeholder, value, onValue }) {
1497
1485
  const [valueInput, setValueInput] = useState(value || '');
1498
1486
  function onChange(value) {
1499
- if (!formControl) {
1500
- setValueInput(value);
1501
- }
1502
- if (onValue) {
1503
- onValue(value);
1504
- }
1487
+ !formControl && setValueInput(value);
1488
+ onValue && onValue(value);
1505
1489
  }
1506
- return (jsxRuntimeExports.jsx("div", { className: "rls-input-text", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "text", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value || value || valueInput }) }));
1490
+ return (jsxRuntimeExports.jsx("div", { className: "rls-input-text", children: jsxRuntimeExports.jsx(RlsInput, { formControl: formControl, type: "text", value: value, disabled: disabled, placeholder: placeholder, onValue: onChange, children: formControl?.value ?? value ?? valueInput }) }));
1507
1491
  }
1508
1492
 
1509
1493
  function RlsLabel({ children, rlsTheme }) {
@@ -1562,9 +1546,7 @@ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsThem
1562
1546
  const [visible, setVisible] = useState(false);
1563
1547
  useEffect(() => {
1564
1548
  function onCloseMenu({ target }) {
1565
- if (!componentRef?.current?.contains(target)) {
1566
- setVisible(false);
1567
- }
1549
+ !componentRef?.current?.contains(target) && setVisible(false);
1568
1550
  }
1569
1551
  document.addEventListener('click', onCloseMenu);
1570
1552
  return () => {
@@ -1577,14 +1559,16 @@ function RlsButtonToggle({ onAction, options, type, automatic, disabled, rlsThem
1577
1559
  function onSelectAction(action) {
1578
1560
  setAction(action);
1579
1561
  setVisible(false);
1580
- if (automatic) {
1581
- onAction(action.value);
1582
- }
1562
+ automatic && onAction(action.value);
1583
1563
  }
1584
- 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: () => onAction(action.value), 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: renderClassStatus('rls-button-toggle__list', {
1564
+ 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: () => {
1565
+ onAction(action.value);
1566
+ }, 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: renderClassStatus('rls-button-toggle__list', {
1585
1567
  visible,
1586
1568
  hide: !visible
1587
- }), children: jsxRuntimeExports.jsx("ul", { children: options.map((action, index) => (jsxRuntimeExports.jsx("li", { className: "truncate", onClick: () => onSelectAction(action), children: action.label }, index))) }) })] }));
1569
+ }), children: jsxRuntimeExports.jsx("ul", { children: options.map((action, index) => (jsxRuntimeExports.jsx("li", { className: "truncate", onClick: () => {
1570
+ onSelectAction(action);
1571
+ }, children: action.label }, index))) }) })] }));
1588
1572
  }
1589
1573
 
1590
1574
  function RlsMessageFormError({ className, formControl }) {
@@ -1652,9 +1636,7 @@ function RlsLabelRadioButton({ children, disabled, extended, formControl, rlsThe
1652
1636
  setChecked(formControl?.value === value);
1653
1637
  }, [formControl?.value]);
1654
1638
  function onSelect() {
1655
- if (formControl) {
1656
- formControl?.setValue(value);
1657
- }
1639
+ formControl && formControl?.setValue(value);
1658
1640
  }
1659
1641
  return (jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-label-radiobutton', {
1660
1642
  disabled,
@@ -1765,9 +1747,7 @@ function RlsPickerDay({ date, disabled: disabledPicker, formControl, maxDate, mo
1765
1747
  }
1766
1748
  function onChange(value) {
1767
1749
  setDayValue(value);
1768
- if (onValue) {
1769
- onValue(value);
1770
- }
1750
+ onValue && onValue(value);
1771
1751
  }
1772
1752
  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', {
1773
1753
  disabled: disabled || disabledPicker,
@@ -1809,7 +1789,11 @@ function RlsPickerDayRange({ date, disabled: disabledPicker, formControl, maxDat
1809
1789
  forbidden,
1810
1790
  ranged,
1811
1791
  source
1812
- }), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day-range__element__span", children: value || '??' }) }, index))) }, index))) })] }));
1792
+ }), onClick: value && !disabledPicker
1793
+ ? () => {
1794
+ onChange(value);
1795
+ }
1796
+ : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day-range__element__span", children: value || '??' }) }, index))) }, index))) })] }));
1813
1797
  }
1814
1798
 
1815
1799
  function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate, minDate, onValue, rlsTheme, year }) {
@@ -1849,7 +1833,11 @@ function RlsPickerMonth({ date, disabled: disabledPicker, formControl, maxDate,
1849
1833
  disabled: disabled || disabledPicker,
1850
1834
  focused,
1851
1835
  selected
1852
- }), onClick: !(disabled || disabledPicker) ? () => onChange(value) : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-month__span", children: label }) }, index))) }));
1836
+ }), onClick: !(disabled || disabledPicker)
1837
+ ? () => {
1838
+ onChange(value);
1839
+ }
1840
+ : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-month__span", children: label }) }, index))) }));
1853
1841
  }
1854
1842
 
1855
1843
  function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
@@ -1872,9 +1860,8 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
1872
1860
  }
1873
1861
  }
1874
1862
  function onPreviousYear() {
1875
- if (itIsDefined(yearControl.value)) {
1863
+ itIsDefined(yearControl.value) &&
1876
1864
  yearControl.setValue(yearControl.value - 1);
1877
- }
1878
1865
  }
1879
1866
  function onPrevious() {
1880
1867
  type === 'month' ? onPreviousMonth() : onPreviousYear();
@@ -1891,9 +1878,8 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
1891
1878
  }
1892
1879
  }
1893
1880
  function onNextYear() {
1894
- if (itIsDefined(yearControl.value)) {
1881
+ itIsDefined(yearControl.value) &&
1895
1882
  yearControl.setValue(yearControl.value + 1);
1896
- }
1897
1883
  }
1898
1884
  function onNext() {
1899
1885
  type === 'month' ? onNextMonth() : onNextYear();
@@ -1939,15 +1925,17 @@ function RlsPickerYear({ date, disabled: disabledPicker, formControl, maxDate, m
1939
1925
  }
1940
1926
  function onChange(value) {
1941
1927
  setYearValue(value);
1942
- if (onValue) {
1943
- onValue(value);
1944
- }
1928
+ onValue && onValue(value);
1945
1929
  }
1946
1930
  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', {
1947
1931
  disabled: disabled || disabledPicker,
1948
1932
  focused,
1949
1933
  selected
1950
- }), onClick: value && !disabledPicker ? () => onChange(value) : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-year__year__span rls-body1-medium", children: value || '????' }) }, index))) })] }));
1934
+ }), onClick: value && !disabledPicker
1935
+ ? () => {
1936
+ onChange(value);
1937
+ }
1938
+ : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-year__year__span rls-body1-medium", children: value || '????' }) }, index))) })] }));
1951
1939
  }
1952
1940
 
1953
1941
  function RlsToolbar({ actions, children, subtitle }) {
@@ -2078,18 +2066,21 @@ function useListControl({ suggestions, formControl }) {
2078
2066
  const listRef = useRef(null);
2079
2067
  const inputRef = useRef(null);
2080
2068
  const [state, setState] = useState({
2081
- collection: new ListCollection([]),
2082
2069
  focused: false,
2083
2070
  higher: false,
2084
2071
  value: '',
2085
2072
  visible: false
2086
2073
  });
2074
+ const collection = useRef(new ListCollection([]));
2087
2075
  const position = useRef(0);
2076
+ const initializedState = useRef(false);
2077
+ const initializedCollection = useRef(false);
2078
+ const changeInternal = useRef(false);
2079
+ const protectedValue = useRef();
2088
2080
  useEffect(() => {
2089
2081
  function onCloseSuggestions({ target }) {
2090
- if (!contentRef?.current?.contains(target)) {
2082
+ !contentRef?.current?.contains(target) &&
2091
2083
  setState((state) => ({ ...state, visible: false }));
2092
- }
2093
2084
  }
2094
2085
  document.addEventListener('click', onCloseSuggestions);
2095
2086
  return () => {
@@ -2097,26 +2088,68 @@ function useListControl({ suggestions, formControl }) {
2097
2088
  };
2098
2089
  }, []);
2099
2090
  useEffect(() => {
2100
- const content = contentRef.current;
2101
- const list = listRef.current;
2102
2091
  formControl?.touch();
2103
2092
  setState((state) => ({
2104
2093
  ...state,
2105
- higher: locationListCanTop(content, list)
2094
+ higher: locationListCanTop(contentRef.current, listRef.current)
2106
2095
  }));
2107
2096
  }, [state.visible]);
2108
2097
  useEffect(() => {
2109
- setState((state) => ({
2110
- ...state,
2111
- collection: new ListCollection(suggestions)
2112
- }));
2098
+ if (!initializedState.current || !initializedCollection.current) {
2099
+ initializedState.current = true;
2100
+ return;
2101
+ }
2102
+ if (changeInternal.current) {
2103
+ changeInternal.current = false;
2104
+ return;
2105
+ }
2106
+ refresh(collection.current, formControl?.value);
2107
+ }, [formControl?.value]);
2108
+ useEffect(() => {
2109
+ collection.current = new ListCollection(suggestions);
2110
+ if (!initializedCollection.current || !initializedState.current) {
2111
+ initializedCollection.current = true;
2112
+ return;
2113
+ }
2114
+ refresh(collection.current, formControl?.value);
2113
2115
  }, [suggestions]);
2116
+ function refresh(collection, state) {
2117
+ if (!state) {
2118
+ return refreshProtected(collection) ? undefined : setValue('');
2119
+ }
2120
+ const element = collection.find(state);
2121
+ if (element) {
2122
+ return setValue(element.description);
2123
+ }
2124
+ if (!refreshProtected(collection)) {
2125
+ protectedValue.current = state;
2126
+ setValue('');
2127
+ setFormState(undefined);
2128
+ }
2129
+ }
2130
+ function refreshProtected(collection) {
2131
+ if (protectedValue.current) {
2132
+ const element = collection.find(protectedValue.current);
2133
+ if (element) {
2134
+ formControl?.setValue(protectedValue.current);
2135
+ protectedValue.current = undefined;
2136
+ return true;
2137
+ }
2138
+ }
2139
+ return false;
2140
+ }
2114
2141
  function setFocused(focused) {
2115
2142
  setState((state) => ({ ...state, focused }));
2116
2143
  }
2117
2144
  function setValue(value) {
2118
2145
  setState((state) => ({ ...state, value }));
2119
2146
  }
2147
+ function setFormState(value) {
2148
+ if (formControl) {
2149
+ changeInternal.current = true;
2150
+ formControl.setValue(value);
2151
+ }
2152
+ }
2120
2153
  function setVisible(visible) {
2121
2154
  setState((state) => ({ ...state, visible }));
2122
2155
  }
@@ -2147,6 +2180,7 @@ function useListControl({ suggestions, formControl }) {
2147
2180
  navigationElement,
2148
2181
  navigationInput,
2149
2182
  setFocused,
2183
+ setFormState,
2150
2184
  setValue,
2151
2185
  setVisible
2152
2186
  };
@@ -2163,51 +2197,13 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
2163
2197
  previous: null
2164
2198
  });
2165
2199
  const listControl = useListControl({ suggestions, formControl });
2166
- const { collection, inputRef, navigationElement, navigationInput, setFocused, setValue, setVisible } = listControl;
2167
- const initializedState = useRef(false);
2168
- const initializedCollection = useRef(false);
2169
- const changeInternal = useRef(false);
2200
+ const { inputRef, navigationElement, navigationInput, setFocused, setFormState, setValue, setVisible } = listControl;
2170
2201
  useEffect(() => {
2171
2202
  refreshCoincidences(pattern, true);
2172
2203
  }, [suggestions]);
2173
2204
  useEffect(() => {
2174
2205
  refreshCoincidences(pattern);
2175
2206
  }, [pattern]);
2176
- useEffect(() => {
2177
- if (!initializedState.current || !initializedCollection.current) {
2178
- initializedState.current = true;
2179
- return;
2180
- }
2181
- if (changeInternal.current) {
2182
- changeInternal.current = false;
2183
- return;
2184
- }
2185
- refresh(collection, formControl?.value);
2186
- }, [formControl?.value]);
2187
- useEffect(() => {
2188
- if (!initializedCollection.current || !initializedState.current) {
2189
- initializedCollection.current = true;
2190
- return;
2191
- }
2192
- refresh(collection, formControl?.value);
2193
- }, [collection]);
2194
- function refresh(collection, state) {
2195
- if (!state) {
2196
- return setValue('');
2197
- }
2198
- const element = collection.find(state);
2199
- if (element) {
2200
- return setValue(element.description);
2201
- }
2202
- setValue('');
2203
- setFormState(undefined);
2204
- }
2205
- function setFormState(value) {
2206
- if (formControl) {
2207
- changeInternal.current = true;
2208
- formControl.setValue(value);
2209
- }
2210
- }
2211
2207
  function onClickControl() {
2212
2208
  if (!disabled) {
2213
2209
  setVisible(true);
@@ -2237,9 +2233,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
2237
2233
  setVisible(false);
2238
2234
  setValue('');
2239
2235
  setFormState(undefined);
2240
- if (onValue) {
2241
- onValue(undefined);
2242
- }
2236
+ onValue && onValue(undefined);
2243
2237
  }
2244
2238
  function onClickBackdrop() {
2245
2239
  setVisible(false);
@@ -2263,9 +2257,7 @@ function useFieldAutocomplete({ disabled, formControl, onSelect, onValue, sugges
2263
2257
  setFormState(value);
2264
2258
  setValue(description);
2265
2259
  }
2266
- if (onValue) {
2267
- onValue(value);
2268
- }
2260
+ onValue && onValue(value);
2269
2261
  }
2270
2262
  function refreshCoincidences(pattern, reboot = false) {
2271
2263
  const { collection, store } = createAutocompleteStore({
@@ -2350,19 +2342,16 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
2350
2342
  formControl?.setValue(dateCheck);
2351
2343
  }, []);
2352
2344
  useEffect(() => {
2353
- if (itIsDefined(yearControl.value)) {
2345
+ itIsDefined(yearControl.value) &&
2354
2346
  setValue(assignYearInDate(value, yearControl.value));
2355
- }
2356
2347
  }, [yearControl.value]);
2357
2348
  useEffect(() => {
2358
- if (itIsDefined(monthControl.value)) {
2349
+ itIsDefined(monthControl.value) &&
2359
2350
  setValue(assignMonthInDate(value, monthControl.value));
2360
- }
2361
2351
  }, [monthControl.value]);
2362
2352
  useEffect(() => {
2363
- if (itIsDefined(dayControl.value)) {
2353
+ itIsDefined(dayControl.value) &&
2364
2354
  setValue(assignDayInDate(value, dayControl.value));
2365
- }
2366
2355
  }, [dayControl.value]);
2367
2356
  function onVisibilityDay() {
2368
2357
  setVisibility('DAY');
@@ -2374,24 +2363,18 @@ function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDat
2374
2363
  setVisibility('YEAR');
2375
2364
  }
2376
2365
  function onCancel() {
2377
- if (onListener) {
2378
- onListener({ type: PickerListenerType.Cancel });
2379
- }
2366
+ onListener && onListener({ type: PickerListenerType.Cancel });
2380
2367
  }
2381
2368
  function onToday() {
2382
2369
  yearControl.setValue(today.getFullYear());
2383
2370
  dayControl.setValue(today.getDate());
2384
2371
  monthControl.setValue(today.getMonth());
2385
2372
  formControl?.setValue(today);
2386
- if (onListener) {
2387
- onListener({ type: PickerListenerType.Now, value: today });
2388
- }
2373
+ onListener && onListener({ type: PickerListenerType.Now, value: today });
2389
2374
  }
2390
2375
  function onSelect() {
2391
2376
  formControl?.setValue(value);
2392
- if (onListener) {
2393
- onListener({ type: PickerListenerType.Select, value });
2394
- }
2377
+ onListener && onListener({ type: PickerListenerType.Select, value });
2395
2378
  }
2396
2379
  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: renderClassStatus('rls-picker-date__component', {
2397
2380
  day: visibility === 'DAY',
@@ -2416,9 +2399,7 @@ function RlsFieldDate({ children, date, disabled, formControl, format, maxDate,
2416
2399
  }, []);
2417
2400
  function onChange(value) {
2418
2401
  setValue(value);
2419
- if (onValue) {
2420
- onValue(value);
2421
- }
2402
+ onValue && onValue(value);
2422
2403
  }
2423
2404
  function onClickInput() {
2424
2405
  setModalIsVisible(true);
@@ -2437,9 +2418,7 @@ function RlsFieldDate({ children, date, disabled, formControl, format, maxDate,
2437
2418
  ? dateFormatTemplate(value, format || FORMAT_DATE)
2438
2419
  : '';
2439
2420
  return (jsxRuntimeExports.jsxs("div", { className: "rls-field-date", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', { 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' }) })] }) }), 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: ({ value, type }) => {
2440
- if (type !== PickerListenerType.Cancel) {
2441
- onChange(value);
2442
- }
2421
+ type !== PickerListenerType.Cancel && onChange(value);
2443
2422
  formControl?.touch();
2444
2423
  setModalIsVisible(false);
2445
2424
  } }) })] }));
@@ -2469,9 +2448,7 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
2469
2448
  });
2470
2449
  }, [monthControl.value]);
2471
2450
  useEffect(() => {
2472
- if (dayControl.value) {
2473
- setValue(dayControl.value);
2474
- }
2451
+ dayControl.value && setValue(dayControl.value);
2475
2452
  setVisibility('DAY');
2476
2453
  }, [dayControl.value]);
2477
2454
  function onVisibilityDay() {
@@ -2484,15 +2461,11 @@ function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl
2484
2461
  setVisibility('YEAR');
2485
2462
  }
2486
2463
  function onCancel() {
2487
- if (onListener) {
2488
- onListener({ type: PickerListenerType.Cancel });
2489
- }
2464
+ onListener && onListener({ type: PickerListenerType.Cancel });
2490
2465
  }
2491
2466
  function onSelect() {
2492
2467
  formControl?.setValue(value);
2493
- if (onListener) {
2494
- onListener({ type: PickerListenerType.Select, value });
2495
- }
2468
+ onListener && onListener({ type: PickerListenerType.Select, value });
2496
2469
  }
2497
2470
  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: renderClassStatus('rls-picker-date-range__component', {
2498
2471
  day: visibility === 'DAY',
@@ -2521,54 +2494,14 @@ function RlsFieldDateRange({ children, date: datePicker, disabled, formControl,
2521
2494
  }
2522
2495
  }
2523
2496
  return (jsxRuntimeExports.jsxs("div", { className: "rls-field-date-range", "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: renderClassStatus('rls-field-box', { 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-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' }) })] }) }), 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: ({ value }) => {
2524
- if (value) {
2525
- setValue(value);
2526
- }
2497
+ value && setValue(value);
2527
2498
  setModalIsVisible(false);
2528
2499
  } }) })] }));
2529
2500
  }
2530
2501
 
2531
2502
  function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
2532
2503
  const listControl = useListControl({ suggestions, formControl });
2533
- const { collection, inputRef, visible, navigationElement, navigationInput, setFocused, setValue, setVisible } = listControl;
2534
- const initializedState = useRef(false);
2535
- const initializedCollection = useRef(false);
2536
- const changeInternal = useRef(false);
2537
- useEffect(() => {
2538
- if (!initializedState.current || !initializedCollection.current) {
2539
- initializedState.current = true;
2540
- return;
2541
- }
2542
- if (changeInternal.current) {
2543
- changeInternal.current = false;
2544
- return;
2545
- }
2546
- refresh(collection, formControl?.value);
2547
- }, [formControl?.value]);
2548
- useEffect(() => {
2549
- if (!initializedCollection.current || !initializedState.current) {
2550
- initializedCollection.current = true;
2551
- return;
2552
- }
2553
- refresh(collection, formControl?.value);
2554
- }, [collection]);
2555
- function refresh(collection, state) {
2556
- if (!state) {
2557
- return setValue('');
2558
- }
2559
- const element = collection.find(state);
2560
- if (element) {
2561
- return setValue(element.description);
2562
- }
2563
- setValue('');
2564
- setFormState(undefined);
2565
- }
2566
- function setFormState(value) {
2567
- if (formControl) {
2568
- changeInternal.current = true;
2569
- formControl.setValue(value);
2570
- }
2571
- }
2504
+ const { inputRef, visible, navigationElement, navigationInput, setFocused, setFormState, setValue, setVisible } = listControl;
2572
2505
  function onFocusInput() {
2573
2506
  setFocused(true);
2574
2507
  }
@@ -2595,9 +2528,7 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
2595
2528
  }
2596
2529
  function onClickAction() {
2597
2530
  setVisible(!visible);
2598
- if (!visible) {
2599
- inputRef?.current?.focus();
2600
- }
2531
+ !visible && inputRef?.current?.focus();
2601
2532
  }
2602
2533
  function onClickBackdrop() {
2603
2534
  setVisible(false);
@@ -2622,9 +2553,7 @@ function useFieldSelect({ suggestions, formControl, onSelect, onValue }) {
2622
2553
  setFormState(value);
2623
2554
  setValue(description);
2624
2555
  }
2625
- if (onValue) {
2626
- onValue(value);
2627
- }
2556
+ onValue && onValue(value);
2628
2557
  }
2629
2558
  return {
2630
2559
  listControl,