@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/es/index.js CHANGED
@@ -3824,37 +3824,36 @@ function RlsSnackbar({ content, onClose, icon, rlsTheme, title, visible }) {
3824
3824
  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 })] })] }));
3825
3825
  }
3826
3826
  function useSnackbar() {
3827
+ const timeoutId = useRef();
3828
+ const duration = useRef(4000);
3827
3829
  const [state, setState] = useState({
3828
3830
  config: {},
3829
- duration: 4000,
3830
- timeoutId: undefined,
3831
3831
  visible: false
3832
3832
  });
3833
3833
  const onClose = useCallback(() => {
3834
- setState((state) => ({ ...state, timeoutId: undefined, visible: false }));
3834
+ setState((state) => ({ ...state, visible: false }));
3835
3835
  }, []);
3836
3836
  const rlsSnackbar = (jsxRuntimeExports.jsx(RlsSnackbar, { ...state.config, visible: state.visible, onClose: onClose }));
3837
3837
  useEffect(() => {
3838
3838
  if (state.visible) {
3839
- const timeoutId = setTimeout(() => {
3840
- setState((state) => ({
3841
- ...state,
3842
- timeoutId: undefined,
3843
- visible: false
3844
- }));
3845
- }, state.duration);
3846
- setState((state) => ({ ...state, timeoutId }));
3839
+ timeoutId.current = setTimeout(() => {
3840
+ setState((state) => ({ ...state, visible: false }));
3841
+ timeoutId.current = undefined;
3842
+ }, duration.current);
3847
3843
  }
3848
- else if (state.timeoutId) {
3849
- clearTimeout(state.timeoutId);
3850
- setTimeout(() => snackbar(state.config), DURATION_ANIMATION);
3844
+ else if (timeoutId.current) {
3845
+ clearTimeout(timeoutId.current);
3846
+ timeoutId.current = undefined;
3847
+ setTimeout(() => {
3848
+ snackbar(state.config);
3849
+ }, DURATION_ANIMATION);
3851
3850
  }
3852
3851
  }, [state.visible]);
3853
3852
  const snackbar = useCallback((config) => {
3853
+ duration.current = calculateDuration(String(config.content));
3854
3854
  setState((state) => ({
3855
3855
  ...state,
3856
3856
  config,
3857
- duration: calculateDuration(String(config.content)),
3858
3857
  visible: !state.visible
3859
3858
  }));
3860
3859
  }, []);