@sanity/ui 2.14.4-canary.2 → 2.14.4-canary.3
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.esm.js +9 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/toast/styles.ts +0 -1
- package/src/core/components/toast/toast.tsx +10 -5
- package/src/core/components/toast/toastProvider.tsx +5 -0
package/dist/index.esm.js
CHANGED
|
@@ -982,7 +982,7 @@ const LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
|
|
|
982
982
|
})`overflow-x:auto;`, StyledToast = styled(Card).withConfig({
|
|
983
983
|
displayName: "StyledToast",
|
|
984
984
|
componentId: "sc-1rr7rxo-1"
|
|
985
|
-
})`pointer-events:all;width:100%;position:relative;overflow:hidden;overflow:clip
|
|
985
|
+
})`pointer-events:all;width:100%;position:relative;overflow:hidden;overflow:clip;&[data-has-duration]{padding-bottom:calc(${LOADING_BAR_HEIGHT}px / 2);}`, LoadingBar = styled.div.withConfig({
|
|
986
986
|
displayName: "LoadingBar",
|
|
987
987
|
componentId: "sc-1rr7rxo-2"
|
|
988
988
|
})`display:flex;position:absolute;bottom:0px;top:0px;left:0px;right:0px;pointer-events:none;z-index:-1;overflow:hidden;overflow:clip;background:transparent;align-items:flex-end;will-change:opacity;`, LoadingBarProgress = styled(Card).withConfig({
|
|
@@ -998,7 +998,7 @@ const LOADING_BAR_HEIGHT = 2, STATUS_CARD_TONE = {
|
|
|
998
998
|
warning: "alert",
|
|
999
999
|
success: "alert",
|
|
1000
1000
|
info: "alert"
|
|
1001
|
-
};
|
|
1001
|
+
}, LONG_ENOUGH_BUT_NOT_TOO_LONG = 1e3 * 60 * 60 * 24 * 24;
|
|
1002
1002
|
function Toast(props) {
|
|
1003
1003
|
const {
|
|
1004
1004
|
closable,
|
|
@@ -1010,15 +1010,13 @@ function Toast(props) {
|
|
|
1010
1010
|
status,
|
|
1011
1011
|
updatedAt,
|
|
1012
1012
|
...restProps
|
|
1013
|
-
} = props, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status"
|
|
1014
|
-
let visualDuration = usePrefersReducedMotion() ? 0 : 0.26;
|
|
1015
|
-
const transition = visualDuration ? {
|
|
1013
|
+
} = props, cardTone = status ? STATUS_CARD_TONE[status] : "default", buttonTone = status ? BUTTON_TONE[status] : "default", role = status ? ROLES[status] : "status", visualDuration = usePrefersReducedMotion() ? 0 : 0.26, transition = visualDuration ? {
|
|
1016
1014
|
type: "spring",
|
|
1017
1015
|
visualDuration,
|
|
1018
1016
|
bounce: 0.25
|
|
1019
1017
|
} : {
|
|
1020
1018
|
duration: 0
|
|
1021
|
-
}, hasDuration = duration && isFinite(duration);
|
|
1019
|
+
}, hasDuration = duration && isFinite(duration) && duration < LONG_ENOUGH_BUT_NOT_TOO_LONG;
|
|
1022
1020
|
return /* @__PURE__ */ jsxs(MotionToast, { "data-ui": "Toast", role, ...restProps, "data-has-duration": hasDuration ? "" : void 0, custom: visualDuration, radius, shadow: 2, tone: cardTone, forwardedAs: "li", layout: "position", variants: container, initial: ["hidden", "initial"], animate: ["visible", "slideIn"], exit: ["hidden", "slideOut"], transition, children: [
|
|
1023
1021
|
/* @__PURE__ */ jsxs(MotionFlex, { align: "flex-start", variants: content, transition, children: [
|
|
1024
1022
|
/* @__PURE__ */ jsx(TextBox, { flex: 1, padding: 3, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
@@ -1046,7 +1044,7 @@ function Toast(props) {
|
|
|
1046
1044
|
delay: visualDuration,
|
|
1047
1045
|
duration: duration / 1e3,
|
|
1048
1046
|
ease: "linear"
|
|
1049
|
-
}, onAnimationComplete: onClose },
|
|
1047
|
+
}, onAnimationComplete: onClose }, `progress-${updatedAt}`)
|
|
1050
1048
|
] })
|
|
1051
1049
|
] });
|
|
1052
1050
|
}
|
|
@@ -1079,6 +1077,9 @@ const container = {
|
|
|
1079
1077
|
scale: 0.75
|
|
1080
1078
|
}
|
|
1081
1079
|
}, content = {
|
|
1080
|
+
initial: {
|
|
1081
|
+
willChange: "transform"
|
|
1082
|
+
},
|
|
1082
1083
|
hidden: {
|
|
1083
1084
|
opacity: 0
|
|
1084
1085
|
},
|
|
@@ -1154,7 +1155,7 @@ function ToastProvider(props) {
|
|
|
1154
1155
|
});
|
|
1155
1156
|
});
|
|
1156
1157
|
};
|
|
1157
|
-
return prevState.filter((t_0) => t_0.id !== id).concat([{
|
|
1158
|
+
return duration === 0.01 ? prevState.filter((t_0) => t_0.id !== id) : prevState.filter((t_1) => t_1.id !== id).concat([{
|
|
1158
1159
|
dismiss,
|
|
1159
1160
|
id,
|
|
1160
1161
|
updatedAt: Date.now(),
|