@sanity/ui 2.0.0-beta.13 → 2.0.0-beta.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023–2024 Sanity.io
3
+ Copyright (c) 2024–2024 Sanity.io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.esm.js CHANGED
@@ -20,17 +20,23 @@ const screen = screen$1;
20
20
  const studioTheme = buildTheme();
21
21
  const EMPTY_ARRAY = [];
22
22
  const EMPTY_RECORD = {};
23
+ const POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = "--motion-content-opacity";
23
24
  const POPOVER_MOTION_PROPS = {
24
25
  initial: {
25
26
  opacity: 0.5,
26
- scale: 0.97
27
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 0,
28
+ scale: 0.97,
29
+ willChange: "transform"
27
30
  },
28
31
  animate: {
29
- opacity: 1,
32
+ opacity: [null, 1, 1],
33
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [null, null, 1],
30
34
  scale: 1
31
35
  },
32
36
  exit: {
33
- opacity: 0,
37
+ // @ts-expect-error -- passing null a second time is valid: https://github.com/framer/motion/blob/b9ce4c42914c3916ea523609c5b032dfc72718bb/packages/framer-motion/src/animation/utils/keyframes.ts#L34C22-L34C22
38
+ opacity: [null, null, 0],
39
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [null, 0, 0],
34
40
  scale: 0.97
35
41
  },
36
42
  transition: {
@@ -3942,7 +3948,7 @@ var __template$m = (cooked, raw) => __freeze$m(__defProp$m(cooked, "raw", {
3942
3948
  value: __freeze$m(raw || cooked.slice())
3943
3949
  }));
3944
3950
  var _a$m;
3945
- const MotionCard$1 = styled(motion(Card))(_a$m || (_a$m = __template$m(["\n &:not([hidden]) {\n display: flex;\n }\n flex-direction: column;\n width: max-content;\n min-width: min-content;\n"])));
3951
+ const MotionCard$1 = styled(motion(Card))(_a$m || (_a$m = __template$m(["\n &:not([hidden]) {\n display: flex;\n }\n flex-direction: column;\n width: max-content;\n min-width: min-content;\n & > * {\n opacity: var(", ", 1);\n will-change: opacity;\n }\n"])), POPOVER_MOTION_CONTENT_OPACITY_PROPERTY);
3946
3952
  const PopoverCard = memo(forwardRef(function PopoverCard2(props, ref) {
3947
3953
  const {
3948
3954
  __unstable_margins: marginsProp,
@@ -3982,8 +3988,9 @@ const PopoverCard = memo(forwardRef(function PopoverCard2(props, ref) {
3982
3988
  top: y,
3983
3989
  width,
3984
3990
  zIndex,
3991
+ willChange: animate ? "transform" : void 0,
3985
3992
  ...style
3986
- }), [originX, originY, strategy, style, width, x, y, zIndex]);
3993
+ }), [animate, originX, originY, strategy, style, width, x, y, zIndex]);
3987
3994
  const arrowStyle = useMemo(() => ({
3988
3995
  left: arrowX !== null ? arrowX : void 0,
3989
3996
  top: arrowY !== null ? arrowY : void 0,
@@ -4830,7 +4837,7 @@ var __template$g = (cooked, raw) => __freeze$g(__defProp$g(cooked, "raw", {
4830
4837
  value: __freeze$g(raw || cooked.slice())
4831
4838
  }));
4832
4839
  var _a$g;
4833
- const MotionCard = styled(motion(Card))(_a$g || (_a$g = __template$g([""])));
4840
+ const MotionCard = styled(motion(Card))(_a$g || (_a$g = __template$g(["\n & > * {\n opacity: var(", ", 1);\n will-change: opacity;\n }\n"])), POPOVER_MOTION_CONTENT_OPACITY_PROPERTY);
4834
4841
  const TooltipCard = memo(forwardRef(function TooltipCard2(props, ref) {
4835
4842
  const {
4836
4843
  animate,
@@ -4852,8 +4859,9 @@ const TooltipCard = memo(forwardRef(function TooltipCard2(props, ref) {
4852
4859
  const rootStyle = useMemo(() => ({
4853
4860
  originX,
4854
4861
  originY,
4862
+ willChange: animate ? "transform" : void 0,
4855
4863
  ...style
4856
- }), [originX, originY, style]);
4864
+ }), [animate, originX, originY, style]);
4857
4865
  const arrowStyle = useMemo(() => ({
4858
4866
  left: arrowX !== null ? arrowX : void 0,
4859
4867
  top: arrowY !== null ? arrowY : void 0,
@@ -7096,13 +7104,19 @@ const STATUS_CARD_TONE = {
7096
7104
  success: "positive",
7097
7105
  info: "primary"
7098
7106
  };
7107
+ const BUTTON_TONE = {
7108
+ error: "critical",
7109
+ warning: "caution",
7110
+ success: "positive",
7111
+ info: "primary"
7112
+ };
7099
7113
  const ROLES = {
7100
7114
  error: "alert",
7101
7115
  warning: "alert",
7102
7116
  success: "alert",
7103
7117
  info: "alert"
7104
7118
  };
7105
- const Root$2 = styled(Card)(_a$3 || (_a$3 = __template$3(["\n pointer-events: all;\n"])));
7119
+ const Root$2 = styled(Card)(_a$3 || (_a$3 = __template$3(["\n pointer-events: all;\n & > * {\n opacity: var(", ", 1);\n will-change: opacity;\n }\n"])), POPOVER_MOTION_CONTENT_OPACITY_PROPERTY);
7106
7120
  const TextBox = styled(Flex)(_b$2 || (_b$2 = __template$3(["\n overflow-x: auto;\n"])));
7107
7121
  function Toast(props) {
7108
7122
  const {
@@ -7115,6 +7129,7 @@ function Toast(props) {
7115
7129
  ...restProps
7116
7130
  } = props;
7117
7131
  const cardTone = status ? STATUS_CARD_TONE[status] : "default";
7132
+ const buttonTone = status ? BUTTON_TONE[status] : "default";
7118
7133
  const role = status ? ROLES[status] : "status";
7119
7134
  return /* @__PURE__ */jsx(Root$2, {
7120
7135
  "data-ui": "Toast",
@@ -7148,6 +7163,7 @@ function Toast(props) {
7148
7163
  icon: CloseIcon,
7149
7164
  mode: "bleed",
7150
7165
  padding: 2,
7166
+ tone: buttonTone,
7151
7167
  onClick: onClose,
7152
7168
  style: {
7153
7169
  verticalAlign: "top"
@@ -7257,12 +7273,14 @@ function ToastProvider(props) {
7257
7273
  } = _ref12;
7258
7274
  return /* @__PURE__ */jsx(motion.div, {
7259
7275
  animate: {
7260
- opacity: 1,
7276
+ opacity: [0, 1, 1],
7277
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [0, 0, 1],
7261
7278
  y: 0,
7262
7279
  scale: 1
7263
7280
  },
7264
7281
  exit: {
7265
- opacity: 0,
7282
+ opacity: [1, 1, 0],
7283
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: [1, 0, 0],
7266
7284
  scale: 0.5,
7267
7285
  transition: {
7268
7286
  duration: 0.2
@@ -7270,8 +7288,10 @@ function ToastProvider(props) {
7270
7288
  },
7271
7289
  initial: {
7272
7290
  opacity: 0,
7291
+ [POPOVER_MOTION_CONTENT_OPACITY_PROPERTY]: 0,
7273
7292
  y: 32,
7274
- scale: 0.25
7293
+ scale: 0.25,
7294
+ willChange: "transform"
7275
7295
  },
7276
7296
  layout: "position",
7277
7297
  transition: {