@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.
@@ -1884,18 +1884,20 @@ const color = createColorTheme({
1884
1884
  name
1885
1885
  }) => {
1886
1886
  if (name === 'default') {
1887
- const _skeletonFrom = dark ? hues.gray[900].hex : hues.gray[100].hex;
1887
+ const _tints = hues.gray;
1888
+
1889
+ const _skeletonFrom = dark ? _tints[900].hex : _tints[100].hex;
1888
1890
 
1889
1891
  return {
1890
1892
  fg: dark ? white$1.hex : black$1.hex,
1891
1893
  bg: dark ? black$1.hex : white$1.hex,
1892
- border: hues.gray[dark ? 800 : 200].hex,
1894
+ border: _tints[dark ? 800 : 200].hex,
1893
1895
  focusRing: hues.blue[dark ? 500 : 500].hex,
1894
1896
  shadow: {
1895
- outline: rgba(hues.gray[500].hex, 0.4),
1896
- umbra: rgba(dark ? black$1.hex : hues.gray[500].hex, 0.2),
1897
- penumbra: rgba(dark ? black$1.hex : hues.gray[500].hex, 0.14),
1898
- ambient: rgba(dark ? black$1.hex : hues.gray[500].hex, 0.12)
1897
+ outline: rgba(_tints[500].hex, 0.4),
1898
+ umbra: dark ? rgba(_tints[950].hex, 0.4) : rgba(_tints[500].hex, 0.2),
1899
+ penumbra: dark ? rgba(_tints[950].hex, 0.28) : rgba(_tints[500].hex, 0.14),
1900
+ ambient: dark ? rgba(_tints[950].hex, 0.24) : rgba(_tints[500].hex, 0.12)
1899
1901
  },
1900
1902
  skeleton: {
1901
1903
  from: _skeletonFrom,
@@ -1905,18 +1907,18 @@ const color = createColorTheme({
1905
1907
  }
1906
1908
 
1907
1909
  if (name === 'transparent') {
1908
- const _tints = tones.default;
1909
- const _skeletonFrom2 = _tints[dark ? 800 : 200].hex;
1910
+ const _tints2 = tones.default;
1911
+ const _skeletonFrom2 = _tints2[dark ? 800 : 200].hex;
1910
1912
  return {
1911
- fg: _tints[dark ? 100 : 900].hex,
1912
- bg: _tints[dark ? 950 : 50].hex,
1913
- border: _tints[dark ? 800 : 300].hex,
1913
+ fg: _tints2[dark ? 100 : 900].hex,
1914
+ bg: _tints2[dark ? 950 : 50].hex,
1915
+ border: _tints2[dark ? 800 : 300].hex,
1914
1916
  focusRing: hues.blue[500].hex,
1915
1917
  shadow: {
1916
- outline: rgba(_tints[500].hex, dark ? 0.2 : 0.4),
1917
- umbra: rgba(dark ? black$1.hex : _tints[500].hex, 0.2),
1918
- penumbra: rgba(dark ? black$1.hex : _tints[500].hex, 0.14),
1919
- ambient: rgba(dark ? black$1.hex : _tints[500].hex, 0.12)
1918
+ outline: rgba(_tints2[500].hex, 0.4),
1919
+ umbra: dark ? rgba(_tints2[900].hex, 0.4) : rgba(_tints2[500].hex, 0.2),
1920
+ penumbra: dark ? rgba(_tints2[900].hex, 0.28) : rgba(_tints2[500].hex, 0.14),
1921
+ ambient: dark ? rgba(_tints2[900].hex, 0.24) : rgba(_tints2[500].hex, 0.12)
1920
1922
  },
1921
1923
  skeleton: {
1922
1924
  from: _skeletonFrom2,
@@ -1933,10 +1935,10 @@ const color = createColorTheme({
1933
1935
  border: tints[dark ? 800 : 200].hex,
1934
1936
  focusRing: tints[500].hex,
1935
1937
  shadow: {
1936
- outline: rgba(tints[500].hex, dark ? 0.2 : 0.4),
1937
- umbra: rgba(dark ? black$1.hex : tints[500].hex, 0.2),
1938
- penumbra: rgba(dark ? black$1.hex : tints[500].hex, 0.14),
1939
- ambient: rgba(dark ? black$1.hex : tints[500].hex, 0.12)
1938
+ outline: rgba(tints[500].hex, 0.4),
1939
+ umbra: dark ? rgba(tints[900].hex, 0.4) : rgba(tints[500].hex, 0.2),
1940
+ penumbra: dark ? rgba(tints[900].hex, 0.28) : rgba(tints[500].hex, 0.14),
1941
+ ambient: dark ? rgba(tints[900].hex, 0.24) : rgba(tints[500].hex, 0.12)
1940
1942
  },
1941
1943
  skeleton: {
1942
1944
  from: skeletonFrom,
@@ -3668,6 +3670,7 @@ function textInputRootStyle() {
3668
3670
  function textInputBaseStyle(props) {
3669
3671
  const {
3670
3672
  theme,
3673
+ $scheme,
3671
3674
  $tone,
3672
3675
  $weight
3673
3676
  } = props;
@@ -3709,7 +3712,7 @@ function textInputBaseStyle(props) {
3709
3712
  color: var(--input-placeholder-color);
3710
3713
  }
3711
3714
 
3712
- &[data-tone='${0}'] {
3715
+ &[data-scheme='${0}'][data-tone='${0}'] {
3713
3716
  --input-fg-color: ${0};
3714
3717
  --input-placeholder-color: ${0};
3715
3718
 
@@ -3737,7 +3740,7 @@ function textInputBaseStyle(props) {
3737
3740
  --input-placeholder-color: ${0};
3738
3741
  }
3739
3742
  }
3740
- `), 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);
3743
+ `), 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);
3741
3744
  }
3742
3745
  function textInputFontSizeStyle(props) {
3743
3746
  const {
@@ -3760,6 +3763,7 @@ function textInputRepresentationStyle(props) {
3760
3763
  $border,
3761
3764
  $hasPrefix,
3762
3765
  $hasSuffix,
3766
+ $scheme,
3763
3767
  $tone,
3764
3768
  theme
3765
3769
  } = props;
@@ -3788,7 +3792,7 @@ function textInputRepresentationStyle(props) {
3788
3792
  border-top-right-radius: ${0};
3789
3793
  border-bottom-right-radius: ${0};
3790
3794
 
3791
- &[data-tone='${0}'] {
3795
+ &[data-scheme='${0}'][data-tone='${0}'] {
3792
3796
  --card-bg-color: ${0};
3793
3797
  --card-fg-color: ${0};
3794
3798
 
@@ -3834,7 +3838,7 @@ function textInputRepresentationStyle(props) {
3834
3838
  }
3835
3839
  }
3836
3840
  }
3837
- `), $hasPrefix ? 0 : undefined, $hasPrefix ? 0 : undefined, $hasSuffix ? 0 : undefined, $hasSuffix ? 0 : undefined, $tone, color.default.enabled.bg, color.default.enabled.fg, $border ? focusRingBorderStyle({
3841
+ `), $hasPrefix ? 0 : undefined, $hasPrefix ? 0 : undefined, $hasSuffix ? 0 : undefined, $hasSuffix ? 0 : undefined, $scheme, $tone, color.default.enabled.bg, color.default.enabled.fg, $border ? focusRingBorderStyle({
3838
3842
  color: color.default.enabled.border,
3839
3843
  width: input.border.width
3840
3844
  }) : undefined, color.invalid.enabled.bg, color.invalid.enabled.fg, $border ? focusRingBorderStyle({
@@ -6774,7 +6778,7 @@ const Popover = /*#__PURE__*/forwardRef(function Popover(props, ref) {
6774
6778
  const [popperElement, setPopperElement] = useState(null);
6775
6779
  const [arrowElement, setArrowElement] = useState(null);
6776
6780
  const popperReferenceElement = referenceElementProp || referenceElement;
6777
- const width = useArrayProp(widthProp);
6781
+ const width = useArrayProp(matchReferenceWidth ? 'auto' : widthProp);
6778
6782
  const modifiers = usePopoverModifiers({
6779
6783
  allowedAutoPlacements,
6780
6784
  arrow,
@@ -6815,13 +6819,21 @@ const Popover = /*#__PURE__*/forwardRef(function Popover(props, ref) {
6815
6819
  forwardedRef.current = el;
6816
6820
  }, [forwardedRef]);
6817
6821
  const popoverStyle = useMemo(() => _extends({}, style, styles.popper), [style, styles]);
6822
+ const updateTimeoutRef = useRef(null);
6818
6823
  useEffect(() => {
6819
- if (forceUpdate) {
6820
- try {
6821
- forceUpdate();
6822
- } catch (_) {// ignore caught error
6823
- }
6824
+ if (updateTimeoutRef.current) {
6825
+ clearTimeout(updateTimeoutRef.current);
6826
+ updateTimeoutRef.current = null;
6824
6827
  }
6828
+
6829
+ updateTimeoutRef.current = setTimeout(() => {
6830
+ if (forceUpdate) {
6831
+ try {
6832
+ forceUpdate();
6833
+ } catch (_) {// ignore caught error
6834
+ }
6835
+ }
6836
+ }, 0);
6825
6837
  }, [content, forceUpdate, open, popperReferenceElement]);
6826
6838
 
6827
6839
  if (disabled) {
@@ -7518,6 +7530,7 @@ const TextArea = /*#__PURE__*/forwardRef(function TextArea(props, forwardedRef)
7518
7530
  }, restProps, {
7519
7531
  "$fontSize": useArrayProp(fontSize),
7520
7532
  "$padding": useArrayProp(padding),
7533
+ "$scheme": rootTheme.scheme,
7521
7534
  "$space": useArrayProp(0),
7522
7535
  "$tone": rootTheme.tone,
7523
7536
  "$weight": weight,
@@ -7526,6 +7539,7 @@ const TextArea = /*#__PURE__*/forwardRef(function TextArea(props, forwardedRef)
7526
7539
  })), /*#__PURE__*/React.createElement(Presentation$1, {
7527
7540
  "$border": border,
7528
7541
  "$radius": useArrayProp(radius),
7542
+ "$scheme": rootTheme.scheme,
7529
7543
  "$tone": rootTheme.tone,
7530
7544
  "data-tone": rootTheme.tone
7531
7545
  })));
@@ -7659,7 +7673,9 @@ const TextInput = /*#__PURE__*/forwardRef(function TextInput(props, forwardedRef
7659
7673
  "$hasPrefix": $hasPrefix,
7660
7674
  "$hasSuffix": $hasSuffix,
7661
7675
  "$radius": radius,
7676
+ "$scheme": rootTheme.scheme,
7662
7677
  "$tone": rootTheme.tone,
7678
+ "data-scheme": rootTheme.scheme,
7663
7679
  "data-tone": rootTheme.tone
7664
7680
  }, icon && /*#__PURE__*/React.createElement(LeftBox, {
7665
7681
  padding: padding
@@ -7669,7 +7685,7 @@ const TextInput = /*#__PURE__*/forwardRef(function TextInput(props, forwardedRef
7669
7685
  padding: padding
7670
7686
  }, /*#__PURE__*/React.createElement(Text, {
7671
7687
  size: fontSize
7672
- }, /*#__PURE__*/isValidElement(iconRight) && iconRight, isValidElementType(iconRight) && /*#__PURE__*/createElement(iconRight)))), [border, fontSize, icon, iconRight, padding, radius, rootTheme.tone, $hasClearButton, $hasPrefix, $hasSuffix]); // Render clear button (memoized)
7688
+ }, /*#__PURE__*/isValidElement(iconRight) && iconRight, isValidElementType(iconRight) && /*#__PURE__*/createElement(iconRight)))), [border, fontSize, icon, iconRight, padding, radius, rootTheme, $hasClearButton, $hasPrefix, $hasSuffix]); // Render clear button (memoized)
7673
7689
 
7674
7690
  const clearButtonBoxPadding = useMemo(() => padding.map(v => {
7675
7691
  if (v === 0) return 0;
@@ -7714,12 +7730,14 @@ const TextInput = /*#__PURE__*/forwardRef(function TextInput(props, forwardedRef
7714
7730
  tone: rootTheme.tone
7715
7731
  }, prefixNode, /*#__PURE__*/React.createElement(InputRoot, null, /*#__PURE__*/React.createElement(Input, _extends({
7716
7732
  "data-as": "input",
7733
+ "data-scheme": rootTheme.scheme,
7717
7734
  "data-tone": rootTheme.tone
7718
7735
  }, restProps, {
7719
7736
  "$fontSize": fontSize,
7720
7737
  "$iconLeft": $hasIcon,
7721
7738
  "$iconRight": $hasIconRight || $hasClearButton,
7722
7739
  "$padding": padding,
7740
+ "$scheme": rootTheme.scheme,
7723
7741
  "$space": space,
7724
7742
  "$tone": rootTheme.tone,
7725
7743
  "$weight": weight,
@@ -7894,13 +7912,21 @@ const Tooltip = /*#__PURE__*/forwardRef(function Tooltip(props, ref) {
7894
7912
  window.removeEventListener('mousemove', handleWindowMouseMove);
7895
7913
  };
7896
7914
  }, [isOpen, referenceElement]);
7915
+ const updateTimeoutRef = useRef(null);
7897
7916
  useEffect(() => {
7898
- if (forceUpdate) {
7899
- try {
7900
- forceUpdate();
7901
- } catch (_) {// ignore caught error
7902
- }
7917
+ if (updateTimeoutRef.current) {
7918
+ clearTimeout(updateTimeoutRef.current);
7919
+ updateTimeoutRef.current = null;
7903
7920
  }
7921
+
7922
+ updateTimeoutRef.current = setTimeout(() => {
7923
+ if (forceUpdate) {
7924
+ try {
7925
+ forceUpdate();
7926
+ } catch (_) {// ignore caught error
7927
+ }
7928
+ }
7929
+ }, 0);
7904
7930
  }, [forceUpdate, content]); // Close when `disabled` changes to `true`
7905
7931
 
7906
7932
  useEffect(() => {
@@ -8694,7 +8720,7 @@ function dialogStyle({
8694
8720
  alignItems: 'center',
8695
8721
  justifyContent: 'center',
8696
8722
  outline: 'none',
8697
- background: color.shadow.penumbra
8723
+ background: color.shadow.umbra
8698
8724
  };
8699
8725
  }
8700
8726
  function responsiveDialogPositionStyle(props) {