@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/es/index.js CHANGED
@@ -3824,37 +3824,38 @@ 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
+ timeoutId.current && clearTimeout(timeoutId.current);
3835
+ timeoutId.current = undefined;
3836
+ setState((state) => ({ ...state, visible: false }));
3835
3837
  }, []);
3836
3838
  const rlsSnackbar = (jsxRuntimeExports.jsx(RlsSnackbar, { ...state.config, visible: state.visible, onClose: onClose }));
3837
3839
  useEffect(() => {
3838
3840
  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 }));
3841
+ timeoutId.current = setTimeout(() => {
3842
+ timeoutId.current = undefined;
3843
+ setState((state) => ({ ...state, visible: false }));
3844
+ }, duration.current);
3847
3845
  }
3848
- else if (state.timeoutId) {
3849
- clearTimeout(state.timeoutId);
3850
- 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);
3851
3852
  }
3852
3853
  }, [state.visible]);
3853
3854
  const snackbar = useCallback((config) => {
3855
+ duration.current = calculateDuration(String(config.content));
3854
3856
  setState((state) => ({
3855
3857
  ...state,
3856
3858
  config,
3857
- duration: calculateDuration(String(config.content)),
3858
3859
  visible: !state.visible
3859
3860
  }));
3860
3861
  }, []);