@sanity/ui 4.0.0-static.40 → 4.0.0-static.42
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 +18 -15
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/core/components/toast/Toast.tsx +1 -1
- package/src/core/components/toast/ToastProvider.tsx +18 -3
- package/src/core/constants.ts +1 -1
- package/src/core/primitives/popover/Popover.tsx +1 -1
- package/src/core/primitives/popover/PopoverLayer.tsx +1 -1
- package/src/core/primitives/tooltip/Tooltip.tsx +1 -1
- package/src/core/primitives/tooltip/TooltipLayer.tsx +1 -1
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { isValidElement, useDebugValue, useSyncExternalStore, createContext, use
|
|
|
5
5
|
import { box, text, textOverflow, animatedSpinnerIcon, spinner, button, buttonLoadingBox, _arrow, vars, _arrowSvg, _arrowStrokeMask, _arrowStroke, _arrowShape, card, BREAKPOINTS, popoverCard, popover, _selectable, stack, textInput, textInputPrefix, textInputElement, _inputElement, _inputPresentation, textInputSuffix, breadcrumbs, container as container$1, dialogCard, dialogHeader, dialogContent, dialogScrollerShadowTop, dialogScroller, dialogScrollerShadowBottom, dialogFooter, dialog, dialogContainer, kbd, menu, menuDivider, toast, toastLayer, treeItem, label, avatar, avatarArrow, avatarInitials, avatarImage, avatarImageOutline, avatarCounter, avatarStack, badge, checkbox, checkboxInput, checkboxPresentation, code, heading, radio, radioInput, radioPresentation, select, selectPresentation, skeleton, codeSkeleton, headingSkeleton, labelSkeleton, textSkeleton, srOnly, _switch, _switchElement, _switchPresentation, _switchTrack, _switchThumb, textArea, tooltip, root } from "@sanity/ui/css";
|
|
6
6
|
import { isValidElementType } from "react-is";
|
|
7
7
|
import { detectOverflow, useFloating, autoPlacement, flip, offset, shift, arrow, hide, autoUpdate } from "@floating-ui/react-dom";
|
|
8
|
-
import { motion, AnimatePresence } from "
|
|
8
|
+
import { motion, AnimatePresence } from "motion/react";
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
11
11
|
import { useEffectEvent } from "use-effect-event";
|
|
@@ -3138,7 +3138,7 @@ function generateToastId() {
|
|
|
3138
3138
|
return String(toastId++);
|
|
3139
3139
|
}
|
|
3140
3140
|
function ToastProvider(props) {
|
|
3141
|
-
const $ = c(
|
|
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
|
-
}, $[
|
|
3178
|
-
const value =
|
|
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
|
-
|
|
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
|
-
|
|
3185
|
-
] }), $[
|
|
3187
|
+
t4
|
|
3188
|
+
] }), $[11] = children, $[12] = t4, $[13] = t5) : t5 = $[13], t5;
|
|
3186
3189
|
}
|
|
3187
3190
|
function _temp$4(t0) {
|
|
3188
3191
|
const {
|