@rolster/react-components 18.26.14 → 18.26.16

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.
@@ -3181,21 +3181,21 @@
3181
3181
  .rls-snackbar {
3182
3182
  position: fixed;
3183
3183
  display: flex;
3184
- column-gap: var(--rls-sizing-x6);
3185
- bottom: 0rem;
3186
3184
  left: var(--rlc-snackbar-left, 50%);
3187
- z-index: 32;
3188
3185
  width: auto;
3189
- height: auto;
3190
3186
  max-width: 240rem;
3187
+ height: auto;
3188
+ bottom: 0rem;
3189
+ column-gap: var(--rls-sizing-x6);
3191
3190
  padding: var(--rls-sizing-x6);
3192
3191
  box-sizing: border-box;
3193
3192
  border-radius: var(--rls-sizing-x6);
3194
3193
  background: var(--rls-app-color-050);
3195
3194
  border-left: var(--rls-theme-border-4-400);
3196
- transform: translate(-50%, 100%);
3195
+ transform: translate(-50%, calc(100% + var(--rls-sizing-x4)));
3197
3196
  transition: all 160ms 0ms var(--rls-standard-curve);
3198
3197
  box-shadow: var(--rls-app-shadow-center-8);
3198
+ z-index: var(--rls-z-index-32);
3199
3199
  }
3200
3200
  .rls-snackbar--visible {
3201
3201
  transform: translate(-50%, calc(0% - var(--rls-sizing-x8)));
package/dist/cjs/index.js CHANGED
@@ -3826,37 +3826,38 @@ function RlsSnackbar({ content, onClose, icon, rlsTheme, title, visible }) {
3826
3826
  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 })] })] }));
3827
3827
  }
3828
3828
  function useSnackbar() {
3829
+ const timeoutId = require$$0.useRef();
3830
+ const duration = require$$0.useRef(4000);
3829
3831
  const [state, setState] = require$$0.useState({
3830
3832
  config: {},
3831
- duration: 4000,
3832
- timeoutId: undefined,
3833
3833
  visible: false
3834
3834
  });
3835
3835
  const onClose = require$$0.useCallback(() => {
3836
- setState((state) => ({ ...state, timeoutId: undefined, visible: false }));
3836
+ timeoutId.current && clearTimeout(timeoutId.current);
3837
+ timeoutId.current = undefined;
3838
+ setState((state) => ({ ...state, visible: false }));
3837
3839
  }, []);
3838
3840
  const rlsSnackbar = (jsxRuntimeExports.jsx(RlsSnackbar, { ...state.config, visible: state.visible, onClose: onClose }));
3839
3841
  require$$0.useEffect(() => {
3840
3842
  if (state.visible) {
3841
- const timeoutId = setTimeout(() => {
3842
- setState((state) => ({
3843
- ...state,
3844
- timeoutId: undefined,
3845
- visible: false
3846
- }));
3847
- }, state.duration);
3848
- setState((state) => ({ ...state, timeoutId }));
3843
+ timeoutId.current = setTimeout(() => {
3844
+ timeoutId.current = undefined;
3845
+ setState((state) => ({ ...state, visible: false }));
3846
+ }, duration.current);
3849
3847
  }
3850
- else if (state.timeoutId) {
3851
- clearTimeout(state.timeoutId);
3852
- setTimeout(() => snackbar(state.config), DURATION_ANIMATION);
3848
+ else if (timeoutId.current) {
3849
+ clearTimeout(timeoutId.current);
3850
+ timeoutId.current = undefined;
3851
+ setTimeout(() => {
3852
+ snackbar(state.config);
3853
+ }, DURATION_ANIMATION);
3853
3854
  }
3854
3855
  }, [state.visible]);
3855
3856
  const snackbar = require$$0.useCallback((config) => {
3857
+ duration.current = calculateDuration(String(config.content));
3856
3858
  setState((state) => ({
3857
3859
  ...state,
3858
3860
  config,
3859
- duration: calculateDuration(String(config.content)),
3860
3861
  visible: !state.visible
3861
3862
  }));
3862
3863
  }, []);