@sanity/ui 4.0.0-static.40 → 4.0.0-static.41

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.
package/dist/index.js CHANGED
@@ -3138,7 +3138,7 @@ function generateToastId() {
3138
3138
  return String(toastId++);
3139
3139
  }
3140
3140
  function ToastProvider(props) {
3141
- const $ = c(13), {
3141
+ const $ = c(14), {
3142
3142
  children,
3143
3143
  padding,
3144
3144
  paddingX,
@@ -3150,20 +3150,23 @@ function ToastProvider(props) {
3150
3150
  $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[0] = t1) : t1 = $[0];
3151
3151
  const [state, setState] = useState(t1), mounted = useMounted();
3152
3152
  let t2;
3153
- $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
3153
+ $[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[1] = t2) : t2 = $[1];
3154
+ const timeoutIdsRef = useRef(t2);
3155
+ let t3;
3156
+ $[2] === Symbol.for("react.memo_cache_sentinel") ? (t3 = {
3154
3157
  version: 0,
3155
3158
  push: (params) => {
3156
- const id = params.id ?? generateToastId(), duration = params.duration ?? 5e3;
3157
- return startTransition(() => {
3159
+ const id = params.id ?? generateToastId(), duration = params.duration ?? 5e3, existingTimeoutId = timeoutIdsRef.current[id];
3160
+ return existingTimeoutId && (clearTimeout(existingTimeoutId), timeoutIdsRef.current[id] = void 0), startTransition(() => {
3158
3161
  setState((prevState) => {
3159
3162
  if (duration === 0.01)
3160
3163
  return prevState.filter((toast2) => toast2.id !== id);
3161
- const dismiss = () => {
3164
+ const dismiss = function() {
3162
3165
  startTransition(() => {
3163
- timeoutId && clearTimeout(timeoutId), setState((currentState) => currentState.filter((toast_0) => toast_0.id !== id));
3166
+ timeoutId && clearTimeout(timeoutId), setState((currentState) => currentState.filter((toast_0) => toast_0.id !== id)), timeoutIdsRef.current[id] = void 0;
3164
3167
  });
3165
3168
  }, timeoutId = duration === 1 / 0 ? void 0 : setTimeout(dismiss, duration);
3166
- return [...prevState.filter((toast_1) => toast_1.id !== id), {
3169
+ return timeoutIdsRef.current[id] = timeoutId, [...prevState.filter((toast_1) => toast_1.id !== id), {
3167
3170
  dismiss,
3168
3171
  id,
3169
3172
  params: {
@@ -3174,15 +3177,15 @@ function ToastProvider(props) {
3174
3177
  });
3175
3178
  }), id;
3176
3179
  }
3177
- }, $[1] = t2) : t2 = $[1];
3178
- const value = t2;
3179
- let t3;
3180
- $[2] !== gap || $[3] !== mounted || $[4] !== padding || $[5] !== paddingX || $[6] !== paddingY || $[7] !== state || $[8] !== zOffset ? (t3 = mounted && /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(_temp$4) }) }) }), $[2] = gap, $[3] = mounted, $[4] = padding, $[5] = paddingX, $[6] = paddingY, $[7] = state, $[8] = zOffset, $[9] = t3) : t3 = $[9];
3180
+ }, $[2] = t3) : t3 = $[2];
3181
+ const value = t3;
3181
3182
  let t4;
3182
- return $[10] !== children || $[11] !== t3 ? (t4 = /* @__PURE__ */ jsxs(ToastContext, { value, children: [
3183
+ $[3] !== gap || $[4] !== mounted || $[5] !== padding || $[6] !== paddingX || $[7] !== paddingY || $[8] !== state || $[9] !== zOffset ? (t4 = mounted && /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: /* @__PURE__ */ jsx(ToastLayer, { padding, paddingX, paddingY, gap, children: /* @__PURE__ */ jsx(AnimatePresence, { initial: !1, mode: "popLayout", children: state.map(_temp$4) }) }) }), $[3] = gap, $[4] = mounted, $[5] = padding, $[6] = paddingX, $[7] = paddingY, $[8] = state, $[9] = zOffset, $[10] = t4) : t4 = $[10];
3184
+ let t5;
3185
+ return $[11] !== children || $[12] !== t4 ? (t5 = /* @__PURE__ */ jsxs(ToastContext, { value, children: [
3183
3186
  children,
3184
- t3
3185
- ] }), $[10] = children, $[11] = t3, $[12] = t4) : t4 = $[12], t4;
3187
+ t4
3188
+ ] }), $[11] = children, $[12] = t4, $[13] = t5) : t5 = $[13], t5;
3186
3189
  }
3187
3190
  function _temp$4(t0) {
3188
3191
  const {