@rolster/react-components 18.26.14 → 18.26.15

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,36 @@ 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
+ setState((state) => ({ ...state, visible: false }));
3837
3837
  }, []);
3838
3838
  const rlsSnackbar = (jsxRuntimeExports.jsx(RlsSnackbar, { ...state.config, visible: state.visible, onClose: onClose }));
3839
3839
  require$$0.useEffect(() => {
3840
3840
  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 }));
3841
+ timeoutId.current = setTimeout(() => {
3842
+ setState((state) => ({ ...state, visible: false }));
3843
+ timeoutId.current = undefined;
3844
+ }, duration.current);
3849
3845
  }
3850
- else if (state.timeoutId) {
3851
- clearTimeout(state.timeoutId);
3852
- setTimeout(() => snackbar(state.config), DURATION_ANIMATION);
3846
+ else if (timeoutId.current) {
3847
+ clearTimeout(timeoutId.current);
3848
+ timeoutId.current = undefined;
3849
+ setTimeout(() => {
3850
+ snackbar(state.config);
3851
+ }, DURATION_ANIMATION);
3853
3852
  }
3854
3853
  }, [state.visible]);
3855
3854
  const snackbar = require$$0.useCallback((config) => {
3855
+ duration.current = calculateDuration(String(config.content));
3856
3856
  setState((state) => ({
3857
3857
  ...state,
3858
3858
  config,
3859
- duration: calculateDuration(String(config.content)),
3860
3859
  visible: !state.visible
3861
3860
  }));
3862
3861
  }, []);