@rolster/react-components 19.7.5 → 19.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/cjs/index.cjs +90 -34
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/es/index.mjs +90 -34
  4. package/dist/es/index.mjs.map +1 -1
  5. package/dist/esm/components/organisms/Confirmation/Confirmation.d.ts +2 -1
  6. package/dist/esm/components/organisms/Confirmation/Confirmation.js +13 -4
  7. package/dist/esm/components/organisms/Confirmation/Confirmation.js.map +1 -1
  8. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js +16 -3
  9. package/dist/esm/components/organisms/FieldAutocomplete/FieldAutocompleteController.js.map +1 -1
  10. package/dist/esm/components/organisms/FieldList/FieldListController.js +13 -3
  11. package/dist/esm/components/organisms/FieldList/FieldListController.js.map +1 -1
  12. package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js +13 -3
  13. package/dist/esm/components/organisms/FieldSelect/FieldSelectController.js.map +1 -1
  14. package/dist/esm/components/organisms/Notifications/Notifications.d.ts +2 -1
  15. package/dist/esm/components/organisms/Notifications/Notifications.js +11 -5
  16. package/dist/esm/components/organisms/Notifications/Notifications.js.map +1 -1
  17. package/dist/esm/components/organisms/Snackbar/Snackbar.d.ts +2 -1
  18. package/dist/esm/components/organisms/Snackbar/Snackbar.js +12 -6
  19. package/dist/esm/components/organisms/Snackbar/Snackbar.js.map +1 -1
  20. package/dist/esm/context.js +3 -3
  21. package/dist/esm/context.js.map +1 -1
  22. package/dist/esm/controllers/DropdownController.js +2 -8
  23. package/dist/esm/controllers/DropdownController.js.map +1 -1
  24. package/dist/esm/controllers/ListController.js +3 -3
  25. package/dist/esm/controllers/ListController.js.map +1 -1
  26. package/dist/esm/controllers/PortalController.js +2 -2
  27. package/dist/esm/controllers/PortalController.js.map +1 -1
  28. package/dist/esm/controllers/TabsController.d.ts +5 -1
  29. package/dist/esm/controllers/TabsController.js +12 -4
  30. package/dist/esm/controllers/TabsController.js.map +1 -1
  31. package/package.json +1 -1
@@ -2380,10 +2380,19 @@ function RlsConfirmationComponent({ approved, className, content, reject, rlsThe
2380
2380
  return (jsxRuntimeExports.jsxs("div", { className: classConfirmation, "rls-theme": rlsTheme, children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__component", children: [jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__header", children: [title && jsxRuntimeExports.jsx("div", { className: "rls-confirmation__title", children: title }), subtitle && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__subtitle", children: subtitle }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__body", children: content && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__content", children: content })) }), (approved || reject) && (jsxRuntimeExports.jsx("div", { className: "rls-confirmation__footer", children: jsxRuntimeExports.jsxs("div", { className: "rls-confirmation__actions", children: [approved && (jsxRuntimeExports.jsx(RlsButton, { identifier: approved.identifier, type: approved.type, onClick: approved.onClick, disabled: approved.disabled, rlsTheme: approved.rlsTheme, children: approved.label })), reject && (jsxRuntimeExports.jsx(RlsButton, { identifier: reject.identifier, type: reject.type, onClick: reject.onClick, disabled: reject.disabled, rlsTheme: reject.rlsTheme, children: reject.label }))] }) }))] }), jsxRuntimeExports.jsx("div", { className: "rls-confirmation__backdrop" })] }));
2381
2381
  }
2382
2382
  const RlsConfirmation = require$$0.memo(RlsConfirmationComponent);
2383
+ const RlsConfirmationBase = RlsConfirmation;
2383
2384
  function useConfirmation() {
2384
2385
  const [config, setConfig] = require$$0.useState({});
2385
2386
  const [visible, setVisible] = require$$0.useState(false);
2386
- const component = ReactDOM.createPortal(jsxRuntimeExports.jsx(RlsConfirmation, { ...config, visible: visible }), document.body);
2387
+ const configRef = require$$0.useRef(config);
2388
+ configRef.current = config;
2389
+ const visibleRef = require$$0.useRef(visible);
2390
+ visibleRef.current = visible;
2391
+ const RlsConfirmation = require$$0.useMemo(() => {
2392
+ return function RlsConfirmation(props) {
2393
+ return ReactDOM.createPortal(jsxRuntimeExports.jsx(RlsConfirmationBase, { ...props, ...configRef.current, visible: visibleRef.current }), document.body);
2394
+ };
2395
+ }, []);
2387
2396
  const confirmation = require$$0.useCallback((options) => {
2388
2397
  return new Promise((resolve) => {
2389
2398
  setConfig({
@@ -2417,8 +2426,8 @@ function useConfirmation() {
2417
2426
  });
2418
2427
  }, []);
2419
2428
  return {
2420
- RlsConfirmation: component,
2421
- confirmation
2429
+ confirmation,
2430
+ RlsConfirmation
2422
2431
  };
2423
2432
  }
2424
2433
 
@@ -2556,7 +2565,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
2556
2565
  const refInput = require$$0.useRef(null);
2557
2566
  const listIsOpen = require$$0.useRef(false);
2558
2567
  const stableSuggestions = useStableSuggestions(suggestions);
2559
- const collection = require$$0.useMemo(() => new components.ListCollection(stableSuggestions, reference), [stableSuggestions]);
2568
+ const collection = require$$0.useMemo(() => new components.ListCollection(stableSuggestions, reference), [stableSuggestions, reference]);
2560
2569
  const [state, refreshState] = require$$0.useState({
2561
2570
  focused: false,
2562
2571
  higher: false,
@@ -2665,7 +2674,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
2665
2674
  position: position.current
2666
2675
  });
2667
2676
  }, [state.higher]);
2668
- return {
2677
+ return require$$0.useMemo(() => ({
2669
2678
  ...state,
2670
2679
  navigationElement,
2671
2680
  navigationInput,
@@ -2674,7 +2683,7 @@ function useListController({ suggestions, automatic, formControl, reference }) {
2674
2683
  refList,
2675
2684
  setFormValue,
2676
2685
  setState
2677
- };
2686
+ }), [state, navigationElement, navigationInput, setFormValue, setState]);
2678
2687
  }
2679
2688
 
2680
2689
  const DURATION_ANIMATION$2 = 240;
@@ -2804,7 +2813,7 @@ function useFieldAutocomplete(props) {
2804
2813
  }
2805
2814
  };
2806
2815
  }, [onChange, controller.navigationElement]);
2807
- return {
2816
+ return require$$0.useMemo(() => ({
2808
2817
  ...controller,
2809
2818
  coincidences,
2810
2819
  onBlurInput,
@@ -2817,7 +2826,20 @@ function useFieldAutocomplete(props) {
2817
2826
  onKeydownInput,
2818
2827
  pattern,
2819
2828
  setPattern
2820
- };
2829
+ }), [
2830
+ controller,
2831
+ coincidences,
2832
+ onBlurInput,
2833
+ onClickAction,
2834
+ onClickBackdrop,
2835
+ onClickControl,
2836
+ onClickElement,
2837
+ onFocusInput,
2838
+ onKeydownElement,
2839
+ onKeydownInput,
2840
+ pattern,
2841
+ setPattern
2842
+ ]);
2821
2843
  }
2822
2844
 
2823
2845
  function RlsFieldAutocompleteTemplateComponent(props) {
@@ -3827,7 +3849,7 @@ function useFieldList(props) {
3827
3849
  }
3828
3850
  };
3829
3851
  }, [toggleElement]);
3830
- return {
3852
+ return require$$0.useMemo(() => ({
3831
3853
  ...state,
3832
3854
  selected,
3833
3855
  refContent,
@@ -3839,7 +3861,17 @@ function useFieldList(props) {
3839
3861
  onClickInput,
3840
3862
  onKeydownElement,
3841
3863
  onRemoveElement
3842
- };
3864
+ }), [
3865
+ state,
3866
+ selected,
3867
+ isSelected,
3868
+ onClickAction,
3869
+ onClickBackdrop,
3870
+ onClickElement,
3871
+ onClickInput,
3872
+ onKeydownElement,
3873
+ onRemoveElement
3874
+ ]);
3843
3875
  }
3844
3876
 
3845
3877
  function RlsFieldListInner({ render, suggestions, action, children, formControl, fieldList, msgErrorDisabled, placeholder, rlsTheme, ...props }) {
@@ -3962,7 +3994,7 @@ function useFieldSelect(props) {
3962
3994
  }
3963
3995
  };
3964
3996
  }, [onChange, controller.navigationElement]);
3965
- return {
3997
+ return require$$0.useMemo(() => ({
3966
3998
  ...controller,
3967
3999
  onBlurInput,
3968
4000
  onClickAction,
@@ -3972,7 +4004,17 @@ function useFieldSelect(props) {
3972
4004
  onFocusInput,
3973
4005
  onKeydownElement,
3974
4006
  onKeydownInput
3975
- };
4007
+ }), [
4008
+ controller,
4009
+ onBlurInput,
4010
+ onClickAction,
4011
+ onClickBackdrop,
4012
+ onClickInput,
4013
+ onClickElement,
4014
+ onFocusInput,
4015
+ onKeydownElement,
4016
+ onKeydownInput
4017
+ ]);
3976
4018
  }
3977
4019
 
3978
4020
  function RlsFieldSelectTemplateComponent(props) {
@@ -4469,6 +4511,8 @@ function RlsNotification({ content, icon, onClose, rlsTheme, title, visible }) {
4469
4511
  function useNotifications() {
4470
4512
  const [notifications, setNotifications] = require$$0.useState([]);
4471
4513
  const timersRef = require$$0.useRef(new Map());
4514
+ const notificationsRef = require$$0.useRef(notifications);
4515
+ notificationsRef.current = notifications;
4472
4516
  require$$0.useEffect(() => {
4473
4517
  const timers = timersRef.current;
4474
4518
  return () => {
@@ -4489,6 +4533,14 @@ function useNotifications() {
4489
4533
  setNotifications((notifications) => notifications.filter((notification) => notification.id !== id));
4490
4534
  }, DURATION_ANIMATION$1);
4491
4535
  }, []);
4536
+ const RlsNotifications = require$$0.useMemo(() => {
4537
+ return function RlsNotifications(props) {
4538
+ const className = renderClassStatus('rls-notifications', {
4539
+ visible: notificationsRef.current.length > 0
4540
+ });
4541
+ return ReactDOM.createPortal(jsxRuntimeExports.jsx("div", { className: className, ...props, children: notificationsRef.current.map((notification) => (jsxRuntimeExports.jsx(RlsNotification, { ...notification.config, visible: notification.visible, onClose: () => remove(notification.id) }, notification.id))) }), document.body);
4542
+ };
4543
+ }, [remove]);
4492
4544
  const notify = require$$0.useCallback((config) => {
4493
4545
  const id = generateId();
4494
4546
  const duration = config.duration ?? DURATION_DEFAULT;
@@ -4508,10 +4560,6 @@ function useNotifications() {
4508
4560
  }, duration);
4509
4561
  timersRef.current.set(id, timer);
4510
4562
  }, [remove]);
4511
- const className = renderClassStatus('rls-notifications', {
4512
- visible: notifications.length > 0
4513
- });
4514
- const RlsNotifications = ReactDOM.createPortal(jsxRuntimeExports.jsx("div", { className: className, children: notifications.map((notification) => (jsxRuntimeExports.jsx(RlsNotification, { ...notification.config, visible: notification.visible, onClose: () => remove(notification.id) }, notification.id))) }), document.body);
4515
4563
  return {
4516
4564
  RlsNotifications,
4517
4565
  notify
@@ -4538,6 +4586,7 @@ function RlsSnackbarComponent({ content, onClose, icon, rlsTheme, title, visible
4538
4586
  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: [jsxRuntimeExports.jsxs("div", { className: "rls-snackbar__header", children: [jsxRuntimeExports.jsx("div", { className: "rls-snackbar__title", children: title }), jsxRuntimeExports.jsx("button", { onClick: onClose, children: jsxRuntimeExports.jsx(RlsIcon, { value: "close" }) })] }), jsxRuntimeExports.jsx("div", { className: "rls-snackbar__content", children: content })] })] }));
4539
4587
  }
4540
4588
  const RlsSnackbar = require$$0.memo(RlsSnackbarComponent);
4589
+ const RlsSnackbarNode = RlsSnackbar;
4541
4590
  function useSnackbar() {
4542
4591
  const timeoutId = require$$0.useRef(undefined);
4543
4592
  const duration = require$$0.useRef(4000);
@@ -4545,6 +4594,8 @@ function useSnackbar() {
4545
4594
  config: {},
4546
4595
  visible: false
4547
4596
  });
4597
+ const stateRef = require$$0.useRef(state);
4598
+ stateRef.current = state;
4548
4599
  const onClose = require$$0.useCallback(() => {
4549
4600
  if (timeoutId.current) {
4550
4601
  clearTimeout(timeoutId.current);
@@ -4552,7 +4603,13 @@ function useSnackbar() {
4552
4603
  timeoutId.current = undefined;
4553
4604
  setState((state) => ({ ...state, visible: false }));
4554
4605
  }, []);
4555
- const rlsSnackbar = (jsxRuntimeExports.jsx(RlsSnackbar, { ...state.config, visible: state.visible, onClose: onClose }));
4606
+ const onCloseRef = require$$0.useRef(onClose);
4607
+ onCloseRef.current = onClose;
4608
+ const RlsSnackbar = require$$0.useMemo(() => {
4609
+ return function RlsSnackbar(props) {
4610
+ return (jsxRuntimeExports.jsx(RlsSnackbarNode, { ...props, ...stateRef.current.config, visible: stateRef.current.visible, onClose: onCloseRef.current }));
4611
+ };
4612
+ }, []);
4556
4613
  require$$0.useEffect(() => {
4557
4614
  if (state.visible) {
4558
4615
  timeoutId.current = setTimeout(() => {
@@ -4576,10 +4633,7 @@ function useSnackbar() {
4576
4633
  visible: !state.visible
4577
4634
  }));
4578
4635
  }, []);
4579
- return {
4580
- RlsSnackbar: rlsSnackbar,
4581
- snackbar
4582
- };
4636
+ return { RlsSnackbar, snackbar };
4583
4637
  }
4584
4638
 
4585
4639
  const RlsContext = require$$0.createContext(null);
@@ -4592,8 +4646,8 @@ function useRlsContext() {
4592
4646
  }
4593
4647
  function RlsApplication({ children }) {
4594
4648
  const { RlsConfirmation, confirmation } = useConfirmation();
4595
- const { RlsNotifications, notify } = useNotifications();
4596
4649
  const { RlsSnackbar, snackbar } = useSnackbar();
4650
+ const { RlsNotifications, notify } = useNotifications();
4597
4651
  const [navbarInApp, setNavbarInApp] = require$$0.useState(false);
4598
4652
  const [navbarIsCondense, setNavbarIsCondense] = require$$0.useState(false);
4599
4653
  const [appIsMobile, setIsMobile] = require$$0.useState(false);
@@ -4610,7 +4664,7 @@ function RlsApplication({ children }) {
4610
4664
  setNavbarIsCondense,
4611
4665
  snackbar
4612
4666
  }), [confirmation, notify, snackbar]);
4613
- return (jsxRuntimeExports.jsxs(RlsContext, { value: state, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, RlsSnackbar] }), RlsNotifications, RlsConfirmation] }));
4667
+ return (jsxRuntimeExports.jsxs(RlsContext, { value: state, children: [jsxRuntimeExports.jsxs("div", { className: className, children: [children, jsxRuntimeExports.jsx(RlsSnackbar, {})] }), jsxRuntimeExports.jsx(RlsConfirmation, {}), jsxRuntimeExports.jsx(RlsNotifications, {})] }));
4614
4668
  }
4615
4669
 
4616
4670
  const DEFAULT_DESIGN_SYSTEM = 'bordered';
@@ -4716,13 +4770,7 @@ function useDropdownController(effect = '0% 0%') {
4716
4770
  const close = require$$0.useCallback(() => {
4717
4771
  setVisible(false);
4718
4772
  }, []);
4719
- return {
4720
- close,
4721
- component,
4722
- open,
4723
- openWithEvent,
4724
- visible
4725
- };
4773
+ return require$$0.useMemo(() => ({ close, component, open, openWithEvent, visible }), [close, open, openWithEvent, visible]);
4726
4774
  }
4727
4775
 
4728
4776
  function usePortalController() {
@@ -4733,15 +4781,23 @@ function usePortalController() {
4733
4781
  const close = require$$0.useCallback(() => {
4734
4782
  setVisible(false);
4735
4783
  }, []);
4736
- return { close, open, visible };
4784
+ return require$$0.useMemo(() => ({ close, open, visible }), [close, open, visible]);
4737
4785
  }
4738
4786
 
4739
4787
  function useTabsController(options) {
4740
4788
  const formControl = reactForms.useFormControl(options.value);
4789
+ const tabsRef = require$$0.useRef(options.tabs);
4790
+ tabsRef.current = options.tabs;
4791
+ const onValueRef = require$$0.useRef(options.onValue);
4792
+ onValueRef.current = options.onValue;
4793
+ const formControlRef = require$$0.useRef(formControl);
4794
+ formControlRef.current = formControl;
4741
4795
  const Tabs = require$$0.useMemo(() => {
4742
- return (jsxRuntimeExports.jsx(RlsTabs, { tabs: options.tabs, formControl: formControl, onValue: options.onValue }));
4743
- }, [options.tabs, options.onValue, formControl]);
4744
- return { Tabs, formControl };
4796
+ return function Tabs(props) {
4797
+ return (jsxRuntimeExports.jsx(RlsTabs, { ...props, tabs: tabsRef.current, formControl: formControlRef.current, onValue: onValueRef.current }));
4798
+ };
4799
+ }, []);
4800
+ return require$$0.useMemo(() => ({ Tabs, formControl }), [Tabs, formControl]);
4745
4801
  }
4746
4802
 
4747
4803
  const APP_THEME_ATTRIBUTE = 'app-theme';