@rolster/react-components 18.21.5 → 18.21.7

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.
package/dist/cjs/index.js CHANGED
@@ -1863,51 +1863,51 @@ function RlsLabelSwitch({ children, disabled, extended, identifier, formControl,
1863
1863
  }
1864
1864
 
1865
1865
  function RlsPagination({ suggestions, count, filter, onPagination }) {
1866
- const controller = require$$0.useRef(new components.PaginationController({ suggestions, count }));
1867
- const [template, setTemplate] = require$$0.useState(controller.current.template);
1866
+ const [template, setTemplate] = require$$0.useState();
1867
+ const controller = require$$0.useRef();
1868
1868
  const refreshTemplate = require$$0.useCallback((template, suggestions) => {
1869
1869
  const { firstPage, lastPage } = template;
1870
1870
  onPagination && onPagination({ firstPage, lastPage, suggestions });
1871
1871
  setTemplate(template);
1872
1872
  }, [onPagination]);
1873
+ const refreshPagination = require$$0.useCallback((pagination) => {
1874
+ pagination &&
1875
+ refreshTemplate(pagination.template, pagination.page.collection);
1876
+ }, []);
1873
1877
  require$$0.useEffect(() => {
1874
- controller.current = new components.PaginationController({
1878
+ const pagination = new components.PaginationController({
1875
1879
  suggestions,
1876
1880
  count,
1877
- position: template.currentPage.value
1881
+ position: template?.currentPage.value
1878
1882
  });
1879
- refreshTemplate(controller.current.template, controller.current.page.collection);
1883
+ controller.current = pagination;
1884
+ refreshTemplate(pagination.template, pagination.page.collection);
1880
1885
  }, [suggestions, count]);
1881
1886
  require$$0.useEffect(() => {
1882
- refreshPagination(controller.current.filtrable(filter));
1887
+ refreshPagination(controller.current?.filtrable(filter));
1883
1888
  }, [filter]);
1884
- const refreshPagination = require$$0.useCallback((pagination) => {
1885
- if (pagination) {
1886
- refreshTemplate(pagination.template, pagination.page.collection);
1887
- }
1888
- }, []);
1889
1889
  const goToPagination = require$$0.useCallback((page) => {
1890
- refreshPagination(controller.current.goToPage(page));
1890
+ refreshPagination(controller.current?.goToPage(page));
1891
1891
  }, []);
1892
1892
  const goFirstPagination = require$$0.useCallback(() => {
1893
- refreshPagination(controller.current.goFirstPage());
1893
+ refreshPagination(controller.current?.goFirstPage());
1894
1894
  }, []);
1895
1895
  const goPreviousPagination = require$$0.useCallback(() => {
1896
- refreshPagination(controller.current.goPreviousPage());
1896
+ refreshPagination(controller.current?.goPreviousPage());
1897
1897
  }, []);
1898
1898
  const goNextPagination = require$$0.useCallback(() => {
1899
- refreshPagination(controller.current.goNextPage());
1899
+ refreshPagination(controller.current?.goNextPage());
1900
1900
  }, []);
1901
1901
  const goLastPagination = require$$0.useCallback(() => {
1902
- refreshPagination(controller.current.goLastPage());
1902
+ refreshPagination(controller.current?.goLastPage());
1903
1903
  }, []);
1904
- return (jsxRuntimeExports.jsxs("div", { className: "rls-pagination", children: [jsxRuntimeExports.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goFirstPagination, disabled: template.firstPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrowhead-left" }) }), jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: template.firstPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-pagination__pages", children: template.pages.map((page, index) => {
1904
+ return (jsxRuntimeExports.jsxs("div", { className: "rls-pagination", children: [jsxRuntimeExports.jsxs("div", { className: "rls-pagination__actions", children: [jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goFirstPagination, disabled: template?.firstPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrowhead-left" }) }), jsxRuntimeExports.jsx("button", { className: "rls-pagination__action", onClick: goPreviousPagination, disabled: template?.firstPage, children: jsxRuntimeExports.jsx(RlsIcon, { value: "arrow-ios-left" }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-pagination__pages", children: template?.pages.map((page, index) => {
1905
1905
  return (jsxRuntimeExports.jsx("div", { className: renderClassStatus('rls-pagination__page', {
1906
1906
  active: page.active
1907
1907
  }), onClick: () => {
1908
1908
  goToPagination(page);
1909
1909
  }, children: page.label }, index));
1910
- }) }), 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" }) })] })] }));
1910
+ }) }), 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" }) })] })] }));
1911
1911
  }
1912
1912
 
1913
1913
  function RlsPickerDayItem({ day, onSelect, disabled }) {
@@ -2436,7 +2436,9 @@ function useListController(props) {
2436
2436
  element && setFormValue(element);
2437
2437
  }
2438
2438
  else {
2439
- automatic && setFormValue(collection.value[0], true);
2439
+ automatic
2440
+ ? setFormValue(collection.value[0], true)
2441
+ : refreshState({ ...state, value: '' });
2440
2442
  }
2441
2443
  }
2442
2444
  changeValueInternal.current = false;