@sanity/ui 0.37.14 → 0.37.17

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.
@@ -1975,18 +1975,20 @@ var color = createColorTheme({
1975
1975
  name = _ref.name;
1976
1976
 
1977
1977
  if (name === 'default') {
1978
- var _skeletonFrom = dark ? hues.gray[900].hex : hues.gray[100].hex;
1978
+ var _tints = hues.gray;
1979
+
1980
+ var _skeletonFrom = dark ? _tints[900].hex : _tints[100].hex;
1979
1981
 
1980
1982
  return {
1981
1983
  fg: dark ? white$1.hex : black$1.hex,
1982
1984
  bg: dark ? black$1.hex : white$1.hex,
1983
- border: hues.gray[dark ? 800 : 200].hex,
1985
+ border: _tints[dark ? 800 : 200].hex,
1984
1986
  focusRing: hues.blue[dark ? 500 : 500].hex,
1985
1987
  shadow: {
1986
- outline: rgba(hues.gray[500].hex, 0.4),
1987
- umbra: rgba(dark ? black$1.hex : hues.gray[500].hex, 0.2),
1988
- penumbra: rgba(dark ? black$1.hex : hues.gray[500].hex, 0.14),
1989
- ambient: rgba(dark ? black$1.hex : hues.gray[500].hex, 0.12)
1988
+ outline: rgba(_tints[500].hex, 0.4),
1989
+ umbra: dark ? rgba(_tints[950].hex, 0.4) : rgba(_tints[500].hex, 0.2),
1990
+ penumbra: dark ? rgba(_tints[950].hex, 0.28) : rgba(_tints[500].hex, 0.14),
1991
+ ambient: dark ? rgba(_tints[950].hex, 0.24) : rgba(_tints[500].hex, 0.12)
1990
1992
  },
1991
1993
  skeleton: {
1992
1994
  from: _skeletonFrom,
@@ -1996,18 +1998,18 @@ var color = createColorTheme({
1996
1998
  }
1997
1999
 
1998
2000
  if (name === 'transparent') {
1999
- var _tints = tones["default"];
2000
- var _skeletonFrom2 = _tints[dark ? 800 : 200].hex;
2001
+ var _tints2 = tones["default"];
2002
+ var _skeletonFrom2 = _tints2[dark ? 800 : 200].hex;
2001
2003
  return {
2002
- fg: _tints[dark ? 100 : 900].hex,
2003
- bg: _tints[dark ? 950 : 50].hex,
2004
- border: _tints[dark ? 800 : 300].hex,
2004
+ fg: _tints2[dark ? 100 : 900].hex,
2005
+ bg: _tints2[dark ? 950 : 50].hex,
2006
+ border: _tints2[dark ? 800 : 300].hex,
2005
2007
  focusRing: hues.blue[500].hex,
2006
2008
  shadow: {
2007
- outline: rgba(_tints[500].hex, dark ? 0.2 : 0.4),
2008
- umbra: rgba(dark ? black$1.hex : _tints[500].hex, 0.2),
2009
- penumbra: rgba(dark ? black$1.hex : _tints[500].hex, 0.14),
2010
- ambient: rgba(dark ? black$1.hex : _tints[500].hex, 0.12)
2009
+ outline: rgba(_tints2[500].hex, 0.4),
2010
+ umbra: dark ? rgba(_tints2[900].hex, 0.4) : rgba(_tints2[500].hex, 0.2),
2011
+ penumbra: dark ? rgba(_tints2[900].hex, 0.28) : rgba(_tints2[500].hex, 0.14),
2012
+ ambient: dark ? rgba(_tints2[900].hex, 0.24) : rgba(_tints2[500].hex, 0.12)
2011
2013
  },
2012
2014
  skeleton: {
2013
2015
  from: _skeletonFrom2,
@@ -2024,10 +2026,10 @@ var color = createColorTheme({
2024
2026
  border: tints[dark ? 800 : 200].hex,
2025
2027
  focusRing: tints[500].hex,
2026
2028
  shadow: {
2027
- outline: rgba(tints[500].hex, dark ? 0.2 : 0.4),
2028
- umbra: rgba(dark ? black$1.hex : tints[500].hex, 0.2),
2029
- penumbra: rgba(dark ? black$1.hex : tints[500].hex, 0.14),
2030
- ambient: rgba(dark ? black$1.hex : tints[500].hex, 0.12)
2029
+ outline: rgba(tints[500].hex, 0.4),
2030
+ umbra: dark ? rgba(tints[900].hex, 0.4) : rgba(tints[500].hex, 0.2),
2031
+ penumbra: dark ? rgba(tints[900].hex, 0.28) : rgba(tints[500].hex, 0.14),
2032
+ ambient: dark ? rgba(tints[900].hex, 0.24) : rgba(tints[500].hex, 0.12)
2031
2033
  },
2032
2034
  skeleton: {
2033
2035
  from: skeletonFrom,
@@ -3692,11 +3694,12 @@ function textInputRootStyle() {
3692
3694
  }
3693
3695
  function textInputBaseStyle(props) {
3694
3696
  var theme = props.theme,
3697
+ $scheme = props.$scheme,
3695
3698
  $tone = props.$tone,
3696
3699
  $weight = props.$weight;
3697
3700
  var font = theme.sanity.fonts.text;
3698
3701
  var color = theme.sanity.color.input;
3699
- return css(_templateObject2$n || (_templateObject2$n = _taggedTemplateLiteralLoose(["\n appearance: none;\n background: none;\n border: 0;\n border-radius: 0;\n outline: none;\n width: 100%;\n box-sizing: border-box;\n font-family: ", ";\n font-weight: ", ";\n margin: 0;\n position: relative;\n z-index: 1;\n display: block;\n\n /* NOTE: This is a hack to disable Chrome\u2019s autofill styles */\n &:-webkit-autofill,\n &:-webkit-autofill:hover,\n &:-webkit-autofill:focus,\n &:-webkit-autofill:active {\n -webkit-text-fill-color: var(--input-fg-color) !important;\n transition: background-color 5000s;\n transition-delay: 86400s /* 24h */;\n }\n\n /* &:is(textarea) */\n &[data-as='textarea'] {\n resize: none;\n }\n\n color: var(--input-fg-color);\n\n &::placeholder {\n color: var(--input-placeholder-color);\n }\n\n &[data-tone='", "'] {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n\n /* enabled */\n &:not(:invalid):not(:disabled):not(:read-only) {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* disabled */\n &:not(:invalid):disabled {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* invalid */\n &:invalid {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* readOnly */\n &:read-only {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n }\n "])), font.family, $weight && font.weights[$weight] || font.weights.regular, $tone, color["default"].enabled.fg, color["default"].enabled.placeholder, color["default"].enabled.fg, color["default"].enabled.placeholder, color["default"].disabled.fg, color["default"].disabled.placeholder, color.invalid.enabled.fg, color.invalid.enabled.placeholder, color["default"].readOnly.fg, color["default"].readOnly.placeholder);
3702
+ return css(_templateObject2$n || (_templateObject2$n = _taggedTemplateLiteralLoose(["\n appearance: none;\n background: none;\n border: 0;\n border-radius: 0;\n outline: none;\n width: 100%;\n box-sizing: border-box;\n font-family: ", ";\n font-weight: ", ";\n margin: 0;\n position: relative;\n z-index: 1;\n display: block;\n\n /* NOTE: This is a hack to disable Chrome\u2019s autofill styles */\n &:-webkit-autofill,\n &:-webkit-autofill:hover,\n &:-webkit-autofill:focus,\n &:-webkit-autofill:active {\n -webkit-text-fill-color: var(--input-fg-color) !important;\n transition: background-color 5000s;\n transition-delay: 86400s /* 24h */;\n }\n\n /* &:is(textarea) */\n &[data-as='textarea'] {\n resize: none;\n }\n\n color: var(--input-fg-color);\n\n &::placeholder {\n color: var(--input-placeholder-color);\n }\n\n &[data-scheme='", "'][data-tone='", "'] {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n\n /* enabled */\n &:not(:invalid):not(:disabled):not(:read-only) {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* disabled */\n &:not(:invalid):disabled {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* invalid */\n &:invalid {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n\n /* readOnly */\n &:read-only {\n --input-fg-color: ", ";\n --input-placeholder-color: ", ";\n }\n }\n "])), font.family, $weight && font.weights[$weight] || font.weights.regular, $scheme, $tone, color["default"].enabled.fg, color["default"].enabled.placeholder, color["default"].enabled.fg, color["default"].enabled.placeholder, color["default"].disabled.fg, color["default"].disabled.placeholder, color.invalid.enabled.fg, color.invalid.enabled.placeholder, color["default"].readOnly.fg, color["default"].readOnly.placeholder);
3700
3703
  }
3701
3704
  function textInputFontSizeStyle(props) {
3702
3705
  var theme = props.theme;
@@ -3715,13 +3718,14 @@ function textInputRepresentationStyle(props) {
3715
3718
  var $border = props.$border,
3716
3719
  $hasPrefix = props.$hasPrefix,
3717
3720
  $hasSuffix = props.$hasSuffix,
3721
+ $scheme = props.$scheme,
3718
3722
  $tone = props.$tone,
3719
3723
  theme = props.theme;
3720
3724
  var _theme$sanity2 = theme.sanity,
3721
3725
  focusRing = _theme$sanity2.focusRing,
3722
3726
  input = _theme$sanity2.input;
3723
3727
  var color = theme.sanity.color.input;
3724
- return css(_templateObject3$e || (_templateObject3$e = _taggedTemplateLiteralLoose(["\n --input-box-shadow: none;\n\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: block;\n pointer-events: none;\n z-index: 0;\n\n background-color: var(--card-bg-color);\n box-shadow: var(--input-box-shadow);\n\n border-top-left-radius: ", ";\n border-bottom-left-radius: ", ";\n border-top-right-radius: ", ";\n border-bottom-right-radius: ", ";\n\n &[data-tone='", "'] {\n --card-bg-color: ", ";\n --card-fg-color: ", ";\n\n /* enabled */\n *:not(:disabled) + & {\n --input-box-shadow: ", ";\n }\n\n /* invalid */\n *:not(:disabled):invalid + & {\n --card-bg-color: ", ";\n --card-fg-color: ", ";\n --input-box-shadow: ", ";\n }\n\n /* focused */\n *:not(:disabled):focus + & {\n --input-box-shadow: ", ";\n }\n\n /* disabled */\n *:disabled + & {\n --card-bg-color: ", " !important;\n --card-fg-color: ", " !important;\n --input-box-shadow: ", ";\n }\n\n /* readOnly */\n *:read-only + & {\n --card-bg-color: ", " !important;\n --card-fg-color: ", " !important;\n }\n\n /* hovered */\n @media (hover: hover) {\n *:not(:disabled):not(:read-only):not(:invalid):hover + & {\n --card-bg-color: ", ";\n --card-fg-color: ", ";\n }\n\n *:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + & {\n --input-box-shadow: ", ";\n }\n }\n }\n "])), $hasPrefix ? 0 : undefined, $hasPrefix ? 0 : undefined, $hasSuffix ? 0 : undefined, $hasSuffix ? 0 : undefined, $tone, color["default"].enabled.bg, color["default"].enabled.fg, $border ? focusRingBorderStyle({
3728
+ return css(_templateObject3$e || (_templateObject3$e = _taggedTemplateLiteralLoose(["\n --input-box-shadow: none;\n\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: block;\n pointer-events: none;\n z-index: 0;\n\n background-color: var(--card-bg-color);\n box-shadow: var(--input-box-shadow);\n\n border-top-left-radius: ", ";\n border-bottom-left-radius: ", ";\n border-top-right-radius: ", ";\n border-bottom-right-radius: ", ";\n\n &[data-scheme='", "'][data-tone='", "'] {\n --card-bg-color: ", ";\n --card-fg-color: ", ";\n\n /* enabled */\n *:not(:disabled) + & {\n --input-box-shadow: ", ";\n }\n\n /* invalid */\n *:not(:disabled):invalid + & {\n --card-bg-color: ", ";\n --card-fg-color: ", ";\n --input-box-shadow: ", ";\n }\n\n /* focused */\n *:not(:disabled):focus + & {\n --input-box-shadow: ", ";\n }\n\n /* disabled */\n *:disabled + & {\n --card-bg-color: ", " !important;\n --card-fg-color: ", " !important;\n --input-box-shadow: ", ";\n }\n\n /* readOnly */\n *:read-only + & {\n --card-bg-color: ", " !important;\n --card-fg-color: ", " !important;\n }\n\n /* hovered */\n @media (hover: hover) {\n *:not(:disabled):not(:read-only):not(:invalid):hover + & {\n --card-bg-color: ", ";\n --card-fg-color: ", ";\n }\n\n *:not(:disabled):not(:read-only):not(:invalid):not(:focus):hover + & {\n --input-box-shadow: ", ";\n }\n }\n }\n "])), $hasPrefix ? 0 : undefined, $hasPrefix ? 0 : undefined, $hasSuffix ? 0 : undefined, $hasSuffix ? 0 : undefined, $scheme, $tone, color["default"].enabled.bg, color["default"].enabled.fg, $border ? focusRingBorderStyle({
3725
3729
  color: color["default"].enabled.border,
3726
3730
  width: input.border.width
3727
3731
  }) : undefined, color.invalid.enabled.bg, color.invalid.enabled.fg, $border ? focusRingBorderStyle({
@@ -6143,7 +6147,7 @@ var Popover = /*#__PURE__*/forwardRef(function Popover(props, ref) {
6143
6147
  setArrowElement = _useState3[1];
6144
6148
 
6145
6149
  var popperReferenceElement = referenceElementProp || referenceElement;
6146
- var width = useArrayProp(widthProp);
6150
+ var width = useArrayProp(matchReferenceWidth ? 'auto' : widthProp);
6147
6151
  var modifiers = usePopoverModifiers({
6148
6152
  allowedAutoPlacements: allowedAutoPlacements,
6149
6153
  arrow: arrow,
@@ -6184,13 +6188,21 @@ var Popover = /*#__PURE__*/forwardRef(function Popover(props, ref) {
6184
6188
  var popoverStyle = useMemo(function () {
6185
6189
  return _extends({}, style, styles.popper);
6186
6190
  }, [style, styles]);
6191
+ var updateTimeoutRef = useRef(null);
6187
6192
  useEffect(function () {
6188
- if (forceUpdate) {
6189
- try {
6190
- forceUpdate();
6191
- } catch (_) {// ignore caught error
6192
- }
6193
+ if (updateTimeoutRef.current) {
6194
+ clearTimeout(updateTimeoutRef.current);
6195
+ updateTimeoutRef.current = null;
6193
6196
  }
6197
+
6198
+ updateTimeoutRef.current = setTimeout(function () {
6199
+ if (forceUpdate) {
6200
+ try {
6201
+ forceUpdate();
6202
+ } catch (_) {// ignore caught error
6203
+ }
6204
+ }
6205
+ }, 0);
6194
6206
  }, [content, forceUpdate, open, popperReferenceElement]);
6195
6207
 
6196
6208
  if (disabled) {
@@ -6572,6 +6584,7 @@ var TextArea = /*#__PURE__*/forwardRef(function TextArea(props, forwardedRef) {
6572
6584
  }, restProps, {
6573
6585
  "$fontSize": useArrayProp(fontSize),
6574
6586
  "$padding": useArrayProp(padding),
6587
+ "$scheme": rootTheme.scheme,
6575
6588
  "$space": useArrayProp(0),
6576
6589
  "$tone": rootTheme.tone,
6577
6590
  "$weight": weight,
@@ -6580,6 +6593,7 @@ var TextArea = /*#__PURE__*/forwardRef(function TextArea(props, forwardedRef) {
6580
6593
  })), /*#__PURE__*/React.createElement(Presentation$1, {
6581
6594
  "$border": border,
6582
6595
  "$radius": useArrayProp(radius),
6596
+ "$scheme": rootTheme.scheme,
6583
6597
  "$tone": rootTheme.tone,
6584
6598
  "data-tone": rootTheme.tone
6585
6599
  })));
@@ -6681,7 +6695,9 @@ var TextInput = /*#__PURE__*/forwardRef(function TextInput(props, forwardedRef)
6681
6695
  "$hasPrefix": $hasPrefix,
6682
6696
  "$hasSuffix": $hasSuffix,
6683
6697
  "$radius": radius,
6698
+ "$scheme": rootTheme.scheme,
6684
6699
  "$tone": rootTheme.tone,
6700
+ "data-scheme": rootTheme.scheme,
6685
6701
  "data-tone": rootTheme.tone
6686
6702
  }, icon && /*#__PURE__*/React.createElement(LeftBox, {
6687
6703
  padding: padding
@@ -6692,7 +6708,7 @@ var TextInput = /*#__PURE__*/forwardRef(function TextInput(props, forwardedRef)
6692
6708
  }, /*#__PURE__*/React.createElement(Text, {
6693
6709
  size: fontSize
6694
6710
  }, /*#__PURE__*/isValidElement(iconRight) && iconRight, isValidElementType(iconRight) && /*#__PURE__*/createElement(iconRight))));
6695
- }, [border, fontSize, icon, iconRight, padding, radius, rootTheme.tone, $hasClearButton, $hasPrefix, $hasSuffix]); // Render clear button (memoized)
6711
+ }, [border, fontSize, icon, iconRight, padding, radius, rootTheme, $hasClearButton, $hasPrefix, $hasSuffix]); // Render clear button (memoized)
6696
6712
 
6697
6713
  var clearButtonBoxPadding = useMemo(function () {
6698
6714
  return padding.map(function (v) {
@@ -6747,12 +6763,14 @@ var TextInput = /*#__PURE__*/forwardRef(function TextInput(props, forwardedRef)
6747
6763
  tone: rootTheme.tone
6748
6764
  }, prefixNode, /*#__PURE__*/React.createElement(InputRoot, null, /*#__PURE__*/React.createElement(Input, _extends({
6749
6765
  "data-as": "input",
6766
+ "data-scheme": rootTheme.scheme,
6750
6767
  "data-tone": rootTheme.tone
6751
6768
  }, restProps, {
6752
6769
  "$fontSize": fontSize,
6753
6770
  "$iconLeft": $hasIcon,
6754
6771
  "$iconRight": $hasIconRight || $hasClearButton,
6755
6772
  "$padding": padding,
6773
+ "$scheme": rootTheme.scheme,
6756
6774
  "$space": space,
6757
6775
  "$tone": rootTheme.tone,
6758
6776
  "$weight": weight,
@@ -6894,13 +6912,21 @@ var Tooltip = /*#__PURE__*/forwardRef(function Tooltip(props, ref) {
6894
6912
  window.removeEventListener('mousemove', handleWindowMouseMove);
6895
6913
  };
6896
6914
  }, [isOpen, referenceElement]);
6915
+ var updateTimeoutRef = useRef(null);
6897
6916
  useEffect(function () {
6898
- if (forceUpdate) {
6899
- try {
6900
- forceUpdate();
6901
- } catch (_) {// ignore caught error
6902
- }
6917
+ if (updateTimeoutRef.current) {
6918
+ clearTimeout(updateTimeoutRef.current);
6919
+ updateTimeoutRef.current = null;
6903
6920
  }
6921
+
6922
+ updateTimeoutRef.current = setTimeout(function () {
6923
+ if (forceUpdate) {
6924
+ try {
6925
+ forceUpdate();
6926
+ } catch (_) {// ignore caught error
6927
+ }
6928
+ }
6929
+ }, 0);
6904
6930
  }, [forceUpdate, content]); // Close when `disabled` changes to `true`
6905
6931
 
6906
6932
  useEffect(function () {
@@ -7708,7 +7734,7 @@ function dialogStyle(_ref) {
7708
7734
  alignItems: 'center',
7709
7735
  justifyContent: 'center',
7710
7736
  outline: 'none',
7711
- background: color.shadow.penumbra
7737
+ background: color.shadow.umbra
7712
7738
  };
7713
7739
  }
7714
7740
  function responsiveDialogPositionStyle(props) {