@rolster/react-components 18.21.0 → 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 (61) hide show
  1. package/dist/cjs/assets/{index-eohCf4O9.css → index-B4R0Qgg4.css} +11 -11
  2. package/dist/cjs/index.js +598 -415
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/es/assets/{index-eohCf4O9.css → index-B4R0Qgg4.css} +11 -11
  5. package/dist/es/index.js +599 -415
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/esm/components/definitions.d.ts +1 -1
  8. package/dist/esm/components/molecules/PickerDay/PickerDay.d.ts +1 -1
  9. package/dist/esm/components/molecules/PickerDay/PickerDay.js +53 -24
  10. package/dist/esm/components/molecules/PickerDay/PickerDay.js.map +1 -1
  11. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.d.ts +1 -1
  12. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js +55 -29
  13. package/dist/esm/components/molecules/PickerDayRange/PickerDayRange.js.map +1 -1
  14. package/dist/esm/components/molecules/PickerMonth/PickerMonth.d.ts +1 -1
  15. package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +57 -34
  16. package/dist/esm/components/molecules/PickerMonth/PickerMonth.js.map +1 -1
  17. package/dist/esm/components/molecules/{PickerMonthTitle/PickerMonthTitle.css → PickerSelectorTitle/PickerSelectorTitle.css} +3 -3
  18. package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.d.ts +15 -0
  19. package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.js +65 -0
  20. package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.js.map +1 -0
  21. package/dist/esm/components/molecules/PickerYear/PickerYear.css +7 -7
  22. package/dist/esm/components/molecules/PickerYear/PickerYear.d.ts +1 -1
  23. package/dist/esm/components/molecules/PickerYear/PickerYear.js +45 -38
  24. package/dist/esm/components/molecules/PickerYear/PickerYear.js.map +1 -1
  25. package/dist/esm/components/molecules/index.d.ts +1 -1
  26. package/dist/esm/components/molecules/index.js +1 -1
  27. package/dist/esm/components/molecules/index.js.map +1 -1
  28. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js +27 -14
  29. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocomplete.js.map +1 -1
  30. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js +50 -41
  31. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js.map +1 -1
  32. package/dist/esm/components/organisms/FieldDate/FieldDate.js +34 -28
  33. package/dist/esm/components/organisms/FieldDate/FieldDate.js.map +1 -1
  34. package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js +32 -23
  35. package/dist/esm/components/organisms/FieldDateRange/FieldDateRange.js.map +1 -1
  36. package/dist/esm/components/organisms/FieldSelect/FieldSelect.js +35 -13
  37. package/dist/esm/components/organisms/FieldSelect/FieldSelect.js.map +1 -1
  38. package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js +41 -29
  39. package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js.map +1 -1
  40. package/dist/esm/components/organisms/PickerDate/PickerDate.css +1 -1
  41. package/dist/esm/components/organisms/PickerDate/PickerDate.js +71 -54
  42. package/dist/esm/components/organisms/PickerDate/PickerDate.js.map +1 -1
  43. package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.d.ts +1 -1
  44. package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js +56 -43
  45. package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js.map +1 -1
  46. package/dist/esm/components/organisms/Snackbar/Snackbar.js +25 -18
  47. package/dist/esm/components/organisms/Snackbar/Snackbar.js.map +1 -1
  48. package/dist/esm/controllers/ListController.js +7 -5
  49. package/dist/esm/controllers/ListController.js.map +1 -1
  50. package/dist/esm/controllers/index.d.ts +0 -1
  51. package/dist/esm/controllers/index.js +0 -1
  52. package/dist/esm/controllers/index.js.map +1 -1
  53. package/dist/esm/helpers/css.js +7 -10
  54. package/dist/esm/helpers/css.js.map +1 -1
  55. package/package.json +3 -3
  56. package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.d.ts +0 -15
  57. package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js +0 -53
  58. package/dist/esm/components/molecules/PickerMonthTitle/PickerMonthTitle.js.map +0 -1
  59. package/dist/esm/controllers/RenderClassStatusController.d.ts +0 -2
  60. package/dist/esm/controllers/RenderClassStatusController.js +0 -10
  61. package/dist/esm/controllers/RenderClassStatusController.js.map +0 -1
package/dist/es/index.js CHANGED
@@ -2,7 +2,7 @@ import require$$0, { useState, useEffect, useMemo, useCallback, useRef, createCo
2
2
  import { currencyFormat, itIsDefined, PartialSealed } from '@rolster/commons';
3
3
  import { dateFormatTemplate, DAY_LABELS, DateRange, normalizeMinTime, assignDayInDate, dateIsBefore, MONTH_NAMES, Month, assignYearInDate, assignMonthInDate } from '@rolster/dates';
4
4
  import { i18n, i18nSubscribe } from '@rolster/i18n';
5
- import { PaginationController, verifyDayPicker, createDayPicker, createDayRangePicker, verifyMonthPicker, createMonthPicker, monthLimitTemplate, createYearPicker, verifyYearPicker, ListCollection, locationListCanTop, navigationListFromInput, navigationListFromElement, createAutocompleteStore, verifyDateRange, dateOutRange, PickerListenerEvent } from '@rolster/components';
5
+ import { PaginationController, verifyDayPicker, createDayPicker, createDayRangePicker, verifyMonthPicker, createMonthPicker, monthLimitTemplate, createYearPicker, verifyYearPicker, ListCollection, locationListCanTop, navigationListFromInput, navigationListFromElement, createAutocompleteStore, dateOutRange, verifyDateRange, PickerListenerEvent } from '@rolster/components';
6
6
  import ReactDOM from 'react-dom';
7
7
  import { useReactControl } from '@rolster/react-forms';
8
8
 
@@ -1362,18 +1362,15 @@ function RlsAmount({ value, decimals, rlsTheme, symbol }) {
1362
1362
  }
1363
1363
 
1364
1364
  function renderClassStatus(base, status = {}, additionals) {
1365
- const resultClass = [base];
1365
+ const _classElement = [base];
1366
1366
  Object.entries(status).forEach(([key, state]) => {
1367
- if (state) {
1368
- typeof state === 'string'
1369
- ? resultClass.push(`${base}--${state}`)
1370
- : resultClass.push(`${base}--${key}`);
1371
- }
1367
+ state &&
1368
+ (typeof state === 'string'
1369
+ ? _classElement.push(`${base}--${state}`)
1370
+ : _classElement.push(`${base}--${key}`));
1372
1371
  });
1373
- if (additionals) {
1374
- resultClass.push(additionals);
1375
- }
1376
- return resultClass.join(' ').trim();
1372
+ additionals && _classElement.push(additionals);
1373
+ return _classElement.join(' ').trim();
1377
1374
  }
1378
1375
 
1379
1376
  const DATE_RANGE_FORMAT = '{dd}/{mx}/{aa}';
@@ -1911,10 +1908,45 @@ function RlsPagination({ suggestions, count, filter, onPagination }) {
1911
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" }) })] })] }));
1912
1909
  }
1913
1910
 
1914
- function RlsPickerDay({ date, disabled: _disabled, formControl, maxDate, month, minDate, onValue, rlsTheme, year }) {
1915
- 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]);
1916
1938
  const [weeks, setWeeks] = useState([]);
1917
- 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]);
1918
1950
  useEffect(() => {
1919
1951
  const options = createPickerOptions();
1920
1952
  const day = verifyDayPicker(options);
@@ -1924,125 +1956,175 @@ function RlsPickerDay({ date, disabled: _disabled, formControl, maxDate, month,
1924
1956
  const day = verifyDayPicker(createPickerOptions());
1925
1957
  day
1926
1958
  ? formControl?.setValue(day)
1927
- : setValue(formControl?.value || currentDate.getDate());
1959
+ : setValue(formControl?.value || date.getDate());
1928
1960
  }, [formControl?.value]);
1929
- function createPickerOptions() {
1961
+ const createPickerOptions = useCallback(() => {
1930
1962
  return {
1931
- date: currentDate,
1932
- day: formControl?.value || value,
1933
- month: itIsDefined(month) ? month : currentDate.getMonth(),
1934
- year: year || currentDate.getFullYear(),
1963
+ date,
1964
+ day: formControl?.value ?? value,
1965
+ month: month ?? date.getMonth(),
1966
+ year: year ?? date.getFullYear(),
1935
1967
  minDate,
1936
1968
  maxDate
1937
1969
  };
1938
- }
1939
- function setDayValue(value) {
1970
+ }, [date, formControl?.value, value, month, year, minDate, maxDate]);
1971
+ const setDayValue = useCallback((value) => {
1940
1972
  formControl ? formControl.setValue(value) : setValue(value);
1941
- }
1942
- function onChange(value) {
1973
+ }, [formControl]);
1974
+ const onSelect = useCallback((value) => {
1943
1975
  setDayValue(value);
1944
1976
  onValue && onValue(value);
1945
- }
1946
- 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', {
1947
- disabled: disabled || _disabled,
1948
- focused,
1949
- forbidden,
1950
- selected,
1951
- today
1952
- }), onClick: value && !_disabled ? () => onChange(value) : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day__element__span", children: value || '??' }) }, index))) }, index))) })] }));
1953
- }
1954
-
1955
- const FORMAT_RANGE = '{dd}/{mx}/{aa}';
1956
- function RlsPickerDayRange({ date, disabled: _disabled, formControl, maxDate, minDate, rlsTheme }) {
1957
- const currentRange = formControl?.value || DateRange.now();
1958
- const currentDate = normalizeMinTime(date || currentRange.minDate);
1959
- 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);
1960
2008
  const [weeks, setWeeks] = useState([]);
1961
- 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]);
1962
2020
  useEffect(() => {
1963
2021
  setWeeks(createDayRangePicker({
1964
- date: currentDate,
2022
+ date,
1965
2023
  range,
1966
2024
  sourceDate: sourceDate.current,
1967
2025
  minDate,
1968
2026
  maxDate
1969
2027
  }));
1970
- }, [range, date, minDate, maxDate]);
1971
- function onChange(value) {
1972
- const date = assignDayInDate(currentDate, value);
1973
- const range = dateIsBefore(date, sourceDate.current)
1974
- ? new DateRange(sourceDate.current, date)
1975
- : new DateRange(date, sourceDate.current);
1976
- 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;
1977
2038
  setRange(range);
1978
2039
  formControl?.setValue(range);
1979
- }
1980
- 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', {
1981
- disabled: disabled || _disabled,
1982
- end,
1983
- forbidden,
1984
- ranged,
1985
- source
1986
- }), onClick: value && !_disabled
1987
- ? () => {
1988
- onChange(value);
1989
- }
1990
- : undefined, children: jsxRuntimeExports.jsx("span", { className: "rls-picker-day-range__element__span", children: value || '??' }) }, index))) }, index))) })] }));
1991
- }
1992
-
1993
- function RlsPickerMonth({ date, disabled: _disabled, formControl, maxDate, minDate, onValue, rlsTheme, year }) {
1994
- 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]);
1995
2068
  const [months, setMonths] = useState([]);
1996
- 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, {}));
1997
2071
  useEffect(() => {
1998
- 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
+ };
1999
2082
  const month = verifyMonthPicker(options);
2000
- month ? setMonthValue(month) : setMonths(createMonthPicker(options));
2083
+ itIsDefined(month)
2084
+ ? setMonthValue(month)
2085
+ : setMonths(createMonthPicker(options));
2001
2086
  }, [date, year, value, minDate, maxDate]);
2002
2087
  useEffect(() => {
2003
- 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
+ });
2004
2095
  itIsDefined(month)
2005
2096
  ? formControl?.setValue(month)
2006
- : setValue(formControl?.value || currentDate.getMonth());
2097
+ : setValue(formControl?.value ?? date.getMonth());
2007
2098
  }, [formControl?.value]);
2008
- function createPickerOptions() {
2009
- return {
2010
- date: currentDate,
2011
- month: itIsDefined(formControl?.value) ? formControl?.value : value,
2012
- year: year || currentDate.getFullYear(),
2013
- minDate,
2014
- maxDate
2015
- };
2016
- }
2017
- function setMonthValue(value) {
2099
+ const setMonthValue = useCallback((value) => {
2018
2100
  formControl ? formControl.setValue(value) : setValue(value);
2019
- }
2020
- function onChange(value) {
2101
+ }, [formControl]);
2102
+ const onSelect = useCallback((value) => {
2021
2103
  setMonthValue(value);
2022
- if (onValue) {
2023
- onValue(value);
2024
- }
2025
- }
2026
- 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', {
2027
- disabled: disabled || _disabled,
2028
- focused,
2029
- selected
2030
- }), onClick: !(disabled || _disabled)
2031
- ? () => {
2032
- onChange(value);
2033
- }
2034
- : 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 }));
2035
2107
  }
2036
2108
 
2037
- function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled, maxDate, minDate, onClick }) {
2038
- const { limitNext, limitPrevious } = monthLimitTemplate({
2039
- date,
2040
- maxDate,
2041
- minDate,
2042
- month: monthControl.value
2043
- });
2044
- const monthName = MONTH_NAMES()[monthControl.value || 0];
2045
- 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(() => {
2046
2128
  if (itIsDefined(monthControl.value) && itIsDefined(yearControl.value)) {
2047
2129
  if (monthControl.value > Month.January) {
2048
2130
  monthControl.setValue(monthControl.value - 1);
@@ -2052,15 +2134,15 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
2052
2134
  yearControl.setValue(yearControl.value - 1);
2053
2135
  }
2054
2136
  }
2055
- }
2056
- function onPreviousYear() {
2137
+ }, [monthControl.value, yearControl.value]);
2138
+ const onPreviousYear = useCallback(() => {
2057
2139
  itIsDefined(yearControl.value) &&
2058
2140
  yearControl.setValue(yearControl.value - 1);
2059
- }
2060
- function onPrevious() {
2141
+ }, [yearControl.value]);
2142
+ const onPrevious = useCallback(() => {
2061
2143
  type === 'month' ? onPreviousMonth() : onPreviousYear();
2062
- }
2063
- function onNextMonth() {
2144
+ }, [type, onPreviousMonth, onPreviousYear]);
2145
+ const onNextMonth = useCallback(() => {
2064
2146
  if (itIsDefined(monthControl.value) && itIsDefined(yearControl.value)) {
2065
2147
  if (monthControl.value < Month.December) {
2066
2148
  monthControl.setValue(monthControl.value + 1);
@@ -2070,66 +2152,73 @@ function RlsPickerMonthTitle({ monthControl, type, yearControl, date, disabled,
2070
2152
  yearControl.setValue(yearControl.value + 1);
2071
2153
  }
2072
2154
  }
2073
- }
2074
- function onNextYear() {
2155
+ }, [monthControl.value, yearControl.value]);
2156
+ const onNextYear = useCallback(() => {
2075
2157
  itIsDefined(yearControl.value) &&
2076
2158
  yearControl.setValue(yearControl.value + 1);
2077
- }
2078
- function onNext() {
2159
+ }, [yearControl.value]);
2160
+ const onNext = useCallback(() => {
2079
2161
  type === 'month' ? onNextMonth() : onNextYear();
2080
- }
2081
- 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 })] }));
2082
2164
  }
2083
2165
 
2084
- function RlsPickerYear({ date, disabled: _disabled, formControl, maxDate, minDate, onValue, rlsTheme }) {
2085
- const currentDate = date || new Date();
2086
- const [value, setValue] = useState(formControl?.value || currentDate.getFullYear());
2087
- 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]);
2088
2192
  const [template, setTemplate] = useState(createYearPicker(createPickerOptions()));
2089
2193
  useEffect(() => {
2090
2194
  const options = createPickerOptions(); // YearPickerProps
2091
2195
  const year = verifyYearPicker(options);
2092
- year
2093
- ? setYearValue(year)
2094
- : setTemplate(createYearPicker(createPickerOptions()));
2196
+ year ? setYearValue(year) : setTemplate(createYearPicker(options));
2095
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]);
2096
2201
  useEffect(() => {
2097
2202
  const year = verifyYearPicker(createPickerOptions());
2098
2203
  itIsDefined(year)
2099
2204
  ? formControl?.setValue(year)
2100
- : setValue(formControl?.value || currentDate.getFullYear());
2205
+ : setValue(formControl?.value ?? date.getFullYear());
2101
2206
  }, [formControl?.value]);
2102
- function createPickerOptions() {
2103
- return {
2104
- date: currentDate,
2105
- year,
2106
- minDate,
2107
- maxDate
2108
- };
2109
- }
2110
- function setYearValue(value) {
2207
+ const setYearValue = useCallback((value) => {
2111
2208
  formControl ? formControl.setValue(value) : setValue(value);
2112
2209
  setYear(value);
2113
- }
2114
- function onClickPrev() {
2115
- setYear(year - 8);
2116
- }
2117
- function onClickNext() {
2118
- setYear(year + 8);
2119
- }
2120
- 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) => {
2121
2218
  setYearValue(value);
2122
2219
  onValue && onValue(value);
2123
- }
2124
- 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: template.years.map(({ value, disabled, focused, selected }, index) => (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-picker-year__year', {
2125
- disabled: disabled || _disabled,
2126
- focused,
2127
- selected
2128
- }), onClick: value && !_disabled
2129
- ? () => {
2130
- onChange(value);
2131
- }
2132
- : 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 })] }));
2133
2222
  }
2134
2223
 
2135
2224
  function RlsToolbar({ actions, children, subtitle }) {
@@ -2322,10 +2411,6 @@ function useListController(props) {
2322
2411
  if (listIsOpen.current && !state.modalIsVisible) {
2323
2412
  formControl?.touch();
2324
2413
  }
2325
- refreshState((state) => ({
2326
- ...state,
2327
- higher: locationListCanTop(contentRef.current, listRef.current)
2328
- }));
2329
2414
  }, [state.modalIsVisible]);
2330
2415
  useEffect(() => {
2331
2416
  setCollection(new ListCollection(suggestions, reference));
@@ -2355,7 +2440,13 @@ function useListController(props) {
2355
2440
  changeValueInternal.current = false;
2356
2441
  }, [collection, formControl?.value]);
2357
2442
  const setState = useCallback((state) => {
2358
- refreshState((_state) => ({ ..._state, ...state }));
2443
+ const _state = state.modalIsVisible
2444
+ ? {
2445
+ ...state,
2446
+ higher: locationListCanTop(contentRef.current, listRef.current)
2447
+ }
2448
+ : state;
2449
+ refreshState((state) => ({ ...state, ..._state }));
2359
2450
  }, []);
2360
2451
  const setFormValue = useCallback((element, initialValue = false) => {
2361
2452
  refreshState((state) => ({
@@ -2398,14 +2489,6 @@ function useListController(props) {
2398
2489
  };
2399
2490
  }
2400
2491
 
2401
- function useRenderClassStatus(base, status = {}, additionals) {
2402
- const [className, setClassName] = useState('');
2403
- useEffect(() => {
2404
- setClassName(renderClassStatus(base, status, additionals));
2405
- }, [base, Object.values(status), additionals]);
2406
- return className;
2407
- }
2408
-
2409
2492
  const DURATION_ANIMATION$1 = 240;
2410
2493
  const MAX_ELEMENTS = 6;
2411
2494
  function useFieldAutocomplete(props) {
@@ -2417,19 +2500,29 @@ function useFieldAutocomplete(props) {
2417
2500
  pattern: '',
2418
2501
  previous: null
2419
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
+ }, []);
2420
2513
  useEffect(() => {
2421
- refreshCoincidences(pattern, true);
2514
+ refreshCoincidences(props.suggestions, pattern, true);
2422
2515
  }, [props.suggestions]);
2423
2516
  useEffect(() => {
2424
- refreshCoincidences(pattern);
2517
+ refreshCoincidences(props.suggestions, pattern);
2425
2518
  }, [pattern]);
2426
- function onFocusInput() {
2519
+ const onFocusInput = useCallback(() => {
2427
2520
  controller.setState({ focused: true });
2428
- }
2429
- function onBlurInput() {
2521
+ }, [controller.setState]);
2522
+ const onBlurInput = useCallback(() => {
2430
2523
  controller.setState({ focused: false });
2431
- }
2432
- function onKeydownInput(event) {
2524
+ }, [controller.setState]);
2525
+ const onKeydownInput = useCallback((event) => {
2433
2526
  switch (event.code) {
2434
2527
  case 'Escape':
2435
2528
  case 'Tab':
@@ -2439,14 +2532,14 @@ function useFieldAutocomplete(props) {
2439
2532
  controller.navigationInput(event);
2440
2533
  break;
2441
2534
  }
2442
- }
2443
- function onClickControl() {
2535
+ }, [controller.setState, controller.navigationInput]);
2536
+ const onClickControl = useCallback(() => {
2444
2537
  controller.setState({ modalIsVisible: true });
2445
2538
  setTimeout(() => {
2446
2539
  controller.inputRef?.current?.focus();
2447
2540
  }, DURATION_ANIMATION$1);
2448
- }
2449
- function onClickAction() {
2541
+ }, [controller.setState]);
2542
+ const onClickAction = useCallback(() => {
2450
2543
  if (controller.value) {
2451
2544
  controller.setState({ modalIsVisible: false });
2452
2545
  controller.setFormValue(undefined);
@@ -2455,44 +2548,43 @@ function useFieldAutocomplete(props) {
2455
2548
  else {
2456
2549
  onClickControl();
2457
2550
  }
2458
- }
2459
- function onClickBackdrop() {
2551
+ }, [
2552
+ controller.value,
2553
+ controller.setState,
2554
+ controller.setFormValue,
2555
+ props.onValue
2556
+ ]);
2557
+ const onClickBackdrop = useCallback(() => {
2460
2558
  controller.setState({ modalIsVisible: false });
2461
- }
2462
- 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) => {
2463
2577
  return () => {
2464
2578
  onChange(element);
2465
2579
  };
2466
- }
2467
- function onKeydownElement(element) {
2580
+ }, []);
2581
+ const onKeydownElement = useCallback((element) => {
2468
2582
  return (event) => {
2469
2583
  event.code === 'Enter'
2470
2584
  ? onChange(element)
2471
2585
  : controller.navigationElement(event);
2472
2586
  };
2473
- }
2474
- function onChange(element) {
2475
- const { onSelect, onValue } = props;
2476
- if (onSelect) {
2477
- controller.setState({ modalIsVisible: false });
2478
- element.value && onSelect(element.value);
2479
- }
2480
- else {
2481
- controller.setState({ modalIsVisible: false });
2482
- controller.setFormValue(element);
2483
- }
2484
- onValue && onValue(element.value);
2485
- }
2486
- function refreshCoincidences(pattern, reboot = false) {
2487
- const { collection, store } = createAutocompleteStore({
2488
- pattern,
2489
- suggestions: props.suggestions,
2490
- reboot,
2491
- store: currentStore.current
2492
- });
2493
- currentStore.current = store;
2494
- setCoincidences(collection.slice(0, MAX_ELEMENTS));
2495
- }
2587
+ }, [controller.navigationElement]);
2496
2588
  return {
2497
2589
  ...controller,
2498
2590
  coincidences,
@@ -2512,7 +2604,23 @@ function useFieldAutocomplete(props) {
2512
2604
  function RlsFieldAutocompleteTemplate(props) {
2513
2605
  const autocomplete = useFieldAutocomplete(props);
2514
2606
  const { render, children, formControl, msgErrorDisabled, onSearch, placeholder, rlsTheme, searching } = props;
2515
- const _disabled = formControl?.disabled || props.disabled;
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]);
2516
2624
  const className = useMemo(() => {
2517
2625
  return renderClassStatus('rls-field-box', {
2518
2626
  focused: autocomplete.focused && !_disabled,
@@ -2520,24 +2628,20 @@ function RlsFieldAutocompleteTemplate(props) {
2520
2628
  disabled: _disabled,
2521
2629
  selected: !!autocomplete.value
2522
2630
  }, 'rls-field-list rls-field-autocomplete');
2523
- }, [
2524
- formControl?.wrong,
2525
- formControl?.disabled,
2526
- autocomplete.value,
2527
- autocomplete.focused,
2528
- props.disabled
2529
- ]);
2631
+ }, [formControl?.wrong, autocomplete.value, autocomplete.focused, _disabled]);
2530
2632
  const classNameList = useMemo(() => {
2531
2633
  return renderClassStatus('rls-field-list__suggestions', {
2532
2634
  higher: autocomplete.higher,
2533
2635
  visible: autocomplete.modalIsVisible
2534
2636
  });
2535
2637
  }, [autocomplete.higher, autocomplete.modalIsVisible]);
2536
- 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: reactI18n('listInputPlaceholder'), value: autocomplete.pattern, onChange: (event) => {
2537
- autocomplete.setPattern(event.target.value);
2538
- }, disabled: _disabled || searching, onFocus: autocomplete.onFocusInput, onBlur: autocomplete.onBlurInput, onKeyDown: autocomplete.onKeydownInput }), onSearch && (jsxRuntimeExports.jsx("button", { disabled: _disabled || searching, onClick: () => {
2539
- onSearch(autocomplete.pattern);
2540
- }, 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 })] })) })] }));
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 })] })) })] }));
2541
2645
  }
2542
2646
  function RlsFieldAutocomplete(props) {
2543
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 }) })) }));
@@ -2550,91 +2654,120 @@ function RlsModal({ children, overflow, visible, rlsTheme }) {
2550
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);
2551
2655
  }
2552
2656
 
2553
- const FORMAT_TITLE = '{dw}, {mx} {dd} de {aa}';
2657
+ const formatTitle = '{dw}, {mx} {dd} de {aa}';
2554
2658
  function RlsPickerDate({ automatic, date, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
2555
- const today = new Date(); // Initial current date in component
2556
- const dateInitial = formControl?.value || date || today;
2557
- const yearControl = useReactControl(dateInitial.getFullYear());
2558
- const dayControl = useReactControl(dateInitial.getDate());
2559
- const monthControl = useReactControl(dateInitial.getMonth());
2560
- 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);
2561
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]);
2562
2688
  useEffect(() => {
2563
- const dateRange = verifyDateRange({
2564
- date: formControl?.value || date || today,
2565
- minDate,
2566
- 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
+ });
2567
2698
  });
2568
- setValue(dateRange);
2569
- formControl?.setValue(dateRange);
2570
2699
  }, []);
2571
2700
  useEffect(() => {
2572
- itIsDefined(yearControl.value) &&
2573
- setValue(assignYearInDate(value, yearControl.value));
2574
- }, [yearControl.value]);
2575
- useEffect(() => {
2576
- itIsDefined(monthControl.value) &&
2577
- setValue(assignMonthInDate(value, monthControl.value));
2578
- }, [monthControl.value]);
2579
- useEffect(() => {
2580
- itIsDefined(dayControl.value) &&
2581
- setValue(assignDayInDate(value, dayControl.value));
2582
- }, [dayControl.value]);
2583
- function onVisibilityDay() {
2701
+ setValue(new Date(yearControl.value, monthControl.value, dayControl.value));
2702
+ }, [yearControl.value, monthControl.value, dayControl.value]);
2703
+ const onVisibilityDay = useCallback(() => {
2584
2704
  setVisibility('DAY');
2585
- }
2586
- function onVisibilityMonth() {
2705
+ }, []);
2706
+ const onVisibilityMonth = useCallback(() => {
2587
2707
  setVisibility('MONTH');
2588
- }
2589
- function onVisibilityYear() {
2708
+ }, []);
2709
+ const onVisibilityYear = useCallback(() => {
2590
2710
  setVisibility('YEAR');
2591
- }
2592
- function onCancel() {
2711
+ }, []);
2712
+ const onCancel = useCallback(() => {
2593
2713
  onListener && onListener({ event: PickerListenerEvent.Cancel });
2594
- }
2595
- function onToday() {
2596
- yearControl.setValue(today.getFullYear());
2597
- dayControl.setValue(today.getDate());
2598
- monthControl.setValue(today.getMonth());
2599
- formControl?.setValue(today);
2600
- onListener && onListener({ event: PickerListenerEvent.Now, value: today });
2601
- }
2602
- 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(() => {
2603
2727
  formControl?.setValue(value);
2604
- onListener && onListener({ event: PickerListenerEvent.Select, value });
2605
- }
2606
- const classNameComponent = useMemo(() => {
2607
- return renderClassStatus('rls-picker-date__component', {
2608
- day: visibility === 'DAY',
2609
- month: visibility === 'MONTH',
2610
- year: visibility === 'YEAR'
2611
- });
2612
- }, [visibility]);
2613
- 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: classNameComponent, 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 }) })] }) }))] }));
2614
2735
  }
2615
2736
 
2616
- const FORMAT_DATE = '{dd}/{mx}/{aa}';
2737
+ const formatDate = '{dd}/{mx}/{aa}';
2617
2738
  function RlsFieldDate({ children, date, disabled, formControl, format, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, rlsTheme, value: _value }) {
2618
- const today = new Date(); // Initial current date in component
2619
- const [value, setValue] = useState(formControl?.value || _value);
2739
+ const today = useRef(new Date()); // Initial current date in component
2740
+ const [value, setValue] = useState(formControl?.value ?? _value);
2620
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]);
2621
2754
  useEffect(() => {
2622
- const dateRange = verifyDateRange({
2623
- date: formControl?.value || date || today,
2755
+ const _date = verifyDateRange({
2756
+ date: formControl?.value ?? date ?? today.current,
2624
2757
  minDate,
2625
2758
  maxDate
2626
2759
  });
2627
- setValue(dateRange);
2628
- formControl?.setValue(dateRange);
2760
+ setValue(_date);
2761
+ formControl?.setValue(_date);
2629
2762
  }, []);
2630
- function onChange(value) {
2763
+ const onClickInput = useCallback(() => {
2764
+ setModalIsVisible(true);
2765
+ }, []);
2766
+ const onChange = useCallback((value) => {
2631
2767
  setValue(value);
2632
2768
  onValue && onValue(value);
2633
- }
2634
- function onClickInput() {
2635
- setModalIsVisible(true);
2636
- }
2637
- function onClickAction() {
2769
+ }, [onValue]);
2770
+ const onClickAction = useCallback(() => {
2638
2771
  if (value) {
2639
2772
  formControl?.setValue(_value);
2640
2773
  formControl?.touch();
@@ -2643,123 +2776,137 @@ function RlsFieldDate({ children, date, disabled, formControl, format, identifie
2643
2776
  else {
2644
2777
  setModalIsVisible(true);
2645
2778
  }
2646
- }
2647
- const valueInput = value
2648
- ? dateFormatTemplate(value, format || FORMAT_DATE)
2649
- : '';
2650
- const _disabled = formControl?.disabled || disabled;
2651
- const className = useMemo(() => {
2652
- return renderClassStatus('rls-field-box', { disabled: _disabled });
2653
- }, [formControl?.disabled, disabled]);
2654
- 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: 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 }) => {
2655
- event !== PickerListenerEvent.Cancel && onChange(value);
2656
- formControl?.touch();
2657
- setModalIsVisible(false);
2658
- } }) })] }));
2659
- }
2660
-
2661
- function RlsPickerDateRange({ automatic, date: datePicker, disabled, formControl, maxDate, minDate, onListener, rlsTheme }) {
2662
- const dateInitial = normalizeMinTime(datePicker || new Date());
2663
- const rangeInitial = formControl?.value || DateRange.now();
2664
- const yearControl = useReactControl(dateInitial.getFullYear());
2665
- const monthControl = useReactControl(dateInitial.getMonth());
2666
- const dayControl = useReactControl(rangeInitial);
2667
- const [value, setValue] = useState(rangeInitial);
2668
- 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);
2669
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]);
2812
+ useEffect(() => {
2813
+ return i18nSubscribe(() => {
2814
+ setLabels({
2815
+ dateActionCancel: reactI18n('dateActionCancel'),
2816
+ dateActionSelect: reactI18n('dateActionSelect')
2817
+ });
2818
+ });
2819
+ }, []);
2670
2820
  useEffect(() => {
2671
- setDate((prevValue) => {
2672
- return typeof yearControl.value === 'number'
2673
- ? assignYearInDate(prevValue, yearControl.value)
2674
- : prevValue;
2821
+ setDate((date) => {
2822
+ return itIsDefined(yearControl.value)
2823
+ ? assignYearInDate(date, yearControl.value)
2824
+ : date;
2675
2825
  });
2676
2826
  }, [yearControl.value]);
2677
2827
  useEffect(() => {
2678
- setDate((prevValue) => {
2679
- return typeof monthControl.value === 'number'
2680
- ? assignMonthInDate(prevValue, monthControl.value)
2681
- : prevValue;
2828
+ setDate((date) => {
2829
+ return itIsDefined(monthControl.value)
2830
+ ? assignMonthInDate(date, monthControl.value)
2831
+ : date;
2682
2832
  });
2683
2833
  }, [monthControl.value]);
2684
2834
  useEffect(() => {
2685
- dayControl.value && setValue(dayControl.value);
2835
+ rangeControl.value && setValue(rangeControl.value);
2686
2836
  setVisibility('DAY');
2687
- }, [dayControl.value]);
2688
- function onVisibilityDay() {
2837
+ }, [rangeControl.value]);
2838
+ const onVisibilityDay = useCallback(() => {
2689
2839
  setVisibility('DAY');
2690
- }
2691
- function onVisibilityMonth() {
2840
+ }, []);
2841
+ const onVisibilityMonth = useCallback(() => {
2692
2842
  setVisibility('MONTH');
2693
- }
2694
- function onVisibilityYear() {
2843
+ }, []);
2844
+ const onVisibilityYear = useCallback(() => {
2695
2845
  setVisibility('YEAR');
2696
- }
2697
- function onCancel() {
2846
+ }, []);
2847
+ const onCancel = useCallback(() => {
2698
2848
  onListener && onListener({ event: PickerListenerEvent.Cancel });
2699
- }
2700
- function onSelect() {
2849
+ }, [onListener]);
2850
+ const onSelect = useCallback(() => {
2701
2851
  formControl?.setValue(value);
2702
2852
  onListener && onListener({ event: PickerListenerEvent.Select, value });
2703
- }
2704
- const classNameComponent = useMemo(() => {
2705
- return renderClassStatus('rls-picker-date-range__component', {
2706
- day: visibility === 'DAY',
2707
- month: visibility === 'MONTH',
2708
- year: visibility === 'YEAR'
2709
- });
2710
- }, [visibility]);
2711
- const classNameFooter = useMemo(() => {
2712
- return renderClassStatus('rls-picker-date-range__footer', {
2713
- automatic
2714
- });
2715
- }, [automatic]);
2716
- 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: classNameComponent, 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: 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: 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 }) })] }) })] }));
2717
2855
  }
2718
2856
 
2719
- function RlsFieldDateRange({ children, date: datePicker, disabled, formControl, identifier, maxDate, minDate, msgErrorDisabled, onValue, placeholder, rlsTheme, value: defaultValue }) {
2720
- const currentDate = datePicker || new Date();
2721
- 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);
2722
2860
  const [modalIsVisible, setModalIsVisible] = useState(false);
2723
- 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(() => {
2724
2874
  setModalIsVisible(true);
2725
- }
2726
- function onClickAction() {
2875
+ }, []);
2876
+ const onChange = useCallback((value) => {
2877
+ setValue(value);
2878
+ onValue && onValue(value);
2879
+ }, [onValue]);
2880
+ const onClickAction = useCallback(() => {
2727
2881
  if (value) {
2728
- formControl?.setValue(defaultValue);
2882
+ formControl?.setValue(_value);
2729
2883
  formControl?.touch();
2730
- onChange(defaultValue);
2884
+ onChange(_value);
2731
2885
  }
2732
2886
  else {
2733
2887
  setModalIsVisible(true);
2734
2888
  }
2735
- }
2736
- function onChange(value) {
2737
- setValue(value);
2738
- onValue && onValue(value);
2739
- }
2740
- const _disabled = formControl?.disabled || disabled;
2741
- const className = useMemo(() => {
2742
- return renderClassStatus('rls-field-box', { disabled: _disabled });
2743
- }, [formControl?.disabled, disabled]);
2744
- 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: 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 }) => {
2745
- event !== PickerListenerEvent.Cancel && onChange(value);
2746
- formControl?.touch();
2747
- setModalIsVisible(false);
2748
- } }) })] }));
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 }) })] }));
2749
2896
  }
2750
2897
 
2751
2898
  function useFieldSelect(props) {
2752
2899
  const controller = useListController(props);
2753
- function onFocusInput() {
2900
+ const onFocusInput = useCallback(() => {
2754
2901
  controller.setState({ focused: true });
2755
- }
2756
- function onBlurInput() {
2902
+ }, [controller.setState]);
2903
+ const onBlurInput = useCallback(() => {
2757
2904
  controller.setState({ focused: false });
2758
- }
2759
- function onClickInput() {
2905
+ }, [controller.setState]);
2906
+ const onClickInput = useCallback(() => {
2760
2907
  controller.setState({ modalIsVisible: true });
2761
- }
2762
- function onKeydownInput(event) {
2908
+ }, [controller.setState]);
2909
+ const onKeydownInput = useCallback((event) => {
2763
2910
  switch (event.code) {
2764
2911
  case 'Space':
2765
2912
  case 'Enter':
@@ -2773,8 +2920,8 @@ function useFieldSelect(props) {
2773
2920
  controller.navigationInput(event);
2774
2921
  break;
2775
2922
  }
2776
- }
2777
- function onClickAction() {
2923
+ }, [controller.setState, controller.navigationInput]);
2924
+ const onClickAction = useCallback(() => {
2778
2925
  const removable = !props.unremovable && !!controller.value;
2779
2926
  if (removable) {
2780
2927
  controller.setState({ modalIsVisible: false });
@@ -2786,35 +2933,46 @@ function useFieldSelect(props) {
2786
2933
  controller.setState({ modalIsVisible });
2787
2934
  modalIsVisible && controller.inputRef?.current?.focus();
2788
2935
  }
2789
- }
2790
- 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(() => {
2791
2945
  controller.setState({ modalIsVisible: false });
2792
- }
2793
- 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) => {
2794
2965
  return () => {
2795
2966
  onChange(element);
2796
2967
  };
2797
- }
2798
- function onKeydownElement(element) {
2968
+ }, []);
2969
+ const onKeydownElement = useCallback((element) => {
2799
2970
  return (event) => {
2800
2971
  event.code === 'Enter'
2801
2972
  ? onChange(element)
2802
2973
  : controller.navigationElement(event);
2803
2974
  };
2804
- }
2805
- function onChange(element) {
2806
- const { onSelect, onValue } = props;
2807
- controller.inputRef?.current?.focus();
2808
- if (onSelect) {
2809
- controller.setState({ modalIsVisible: false });
2810
- element.value && onSelect(element.value);
2811
- }
2812
- else {
2813
- controller.setFormValue(element);
2814
- controller.setState({ modalIsVisible: false });
2815
- }
2816
- onValue && onValue(element.value);
2817
- }
2975
+ }, [controller.navigationElement]);
2818
2976
  return {
2819
2977
  ...controller,
2820
2978
  onBlurInput,
@@ -2831,16 +2989,35 @@ function useFieldSelect(props) {
2831
2989
  function RlsFieldSelectTemplate(props) {
2832
2990
  const select = useFieldSelect(props);
2833
2991
  const { render, suggestions, children, formControl, msgErrorDisabled, placeholder, rlsTheme, unremovable } = props;
2834
- const _disabled = formControl?.disabled || props.disabled;
2835
- const className = useRenderClassStatus('rls-field-box', {
2836
- disabled: _disabled,
2837
- error: formControl?.wrong,
2838
- focused: select.focused && !_disabled
2839
- }, 'rls-field-list rls-field-select');
2840
- 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', {
2841
- higher: select.higher,
2842
- visible: select.modalIsVisible
2843
- }), 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 })] })) })] }));
2844
3021
  }
2845
3022
  function RlsFieldSelect(props) {
2846
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 }) })) }));
@@ -2875,29 +3052,36 @@ function RlsSnackbar({ content, icon, title, visible, rlsTheme }) {
2875
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 })] })] }));
2876
3053
  }
2877
3054
  function useSnackbar() {
2878
- const [config, setConfig] = useState({});
2879
- const [duration, setDuration] = useState(4000);
2880
- const [timeoutId, setTimeoutId] = useState();
2881
- const [visible, setVisible] = useState(false);
2882
- 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 });
2883
3062
  useEffect(() => {
2884
- if (visible) {
3063
+ if (state.visible) {
2885
3064
  const timeoutId = setTimeout(() => {
2886
- setVisible(false);
2887
- setTimeoutId(undefined);
2888
- }, duration);
2889
- setTimeoutId(timeoutId);
3065
+ setState((state) => ({
3066
+ ...state,
3067
+ visible: false,
3068
+ timeoutId: undefined
3069
+ }));
3070
+ }, state.duration);
3071
+ setState((state) => ({ ...state, timeoutId }));
2890
3072
  }
2891
- else if (timeoutId) {
2892
- clearTimeout(timeoutId);
2893
- setTimeout(() => snackbar(config), DURATION_ANIMATION);
3073
+ else if (state.timeoutId) {
3074
+ clearTimeout(state.timeoutId);
3075
+ setTimeout(() => snackbar(state.config), DURATION_ANIMATION);
2894
3076
  }
2895
- }, [visible]);
3077
+ }, [state.visible]);
2896
3078
  const snackbar = useCallback((config) => {
2897
- const { content } = config;
2898
- setConfig(config);
2899
- setDuration(calculateDuration(String(content)));
2900
- setVisible((visible) => !visible);
3079
+ setState((state) => ({
3080
+ ...state,
3081
+ config,
3082
+ duration: calculateDuration(String(config.content)),
3083
+ visible: !state.visible
3084
+ }));
2901
3085
  }, []);
2902
3086
  return {
2903
3087
  RlsSnackbar: rlsSnackbar,
@@ -2922,5 +3106,5 @@ function RlsApplication({ children }) {
2922
3106
  return (jsxRuntimeExports.jsxs(RlsContext.Provider, { value: { confirmation, snackbar, withNavbar }, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsConfirmation] }));
2923
3107
  }
2924
3108
 
2925
- 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, setErrorsI18n, 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 };
2926
3110
  //# sourceMappingURL=index.js.map