@sanity/ui 1.8.0 → 1.8.2

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 CHANGED
@@ -5860,6 +5860,20 @@ const DEFAULT_POPOVER_PADDING = 4;
5860
5860
  const DEFAULT_POPOVER_ARROW_WIDTH = 27;
5861
5861
  const DEFAULT_POPOVER_ARROW_HEIGHT = 11;
5862
5862
  const DEFAULT_POPOVER_MARGINS = [0, 0, 0, 0];
5863
+ const DEFAULT_FALLBACK_PLACEMENTS$1 = {
5864
+ top: ["bottom", "left", "right"],
5865
+ "top-start": ["bottom-start", "left-start", "right-start"],
5866
+ "top-end": ["bottom-end", "left-end", "right-end"],
5867
+ bottom: ["top", "left", "right"],
5868
+ "bottom-start": ["top-start", "left-start", "right-start"],
5869
+ "bottom-end": ["top-end", "left-end", "right-end"],
5870
+ left: ["right", "top", "bottom"],
5871
+ "left-start": ["right-start", "top-start", "bottom-start"],
5872
+ "left-end": ["right-end", "top-end", "bottom-end"],
5873
+ right: ["left", "top", "bottom"],
5874
+ "right-start": ["left-start", "top-start", "bottom-start"],
5875
+ "right-end": ["left-end", "top-end", "bottom-end"]
5876
+ };
5863
5877
  function size(options) {
5864
5878
  const {
5865
5879
  apply,
@@ -6059,7 +6073,7 @@ const PopoverCard = memo(forwardRef(function PopoverCard2(props, ref) {
6059
6073
  }));
6060
6074
  PopoverCard.displayName = "PopoverCard";
6061
6075
  const Popover = memo(forwardRef(function Popover2(props, ref) {
6062
- var _a, _b, _c, _d, _e, _f, _g;
6076
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
6063
6077
  const theme = useTheme();
6064
6078
  const boundaryElementContext = useBoundaryElement();
6065
6079
  const {
@@ -6070,9 +6084,9 @@ const Popover = memo(forwardRef(function Popover2(props, ref) {
6070
6084
  constrainSize = false,
6071
6085
  content,
6072
6086
  disabled,
6073
- fallbackPlacements,
6087
+ fallbackPlacements = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS$1[(_a = props.placement) != null ? _a : "bottom"],
6074
6088
  matchReferenceWidth,
6075
- floatingBoundary = (_a = props.boundaryElement) != null ? _a : boundaryElementContext.element,
6089
+ floatingBoundary = (_c = props.boundaryElement) != null ? _c : boundaryElementContext.element,
6076
6090
  open,
6077
6091
  overflow = "hidden",
6078
6092
  padding: paddingProp,
@@ -6080,17 +6094,17 @@ const Popover = memo(forwardRef(function Popover2(props, ref) {
6080
6094
  portal,
6081
6095
  preventOverflow = true,
6082
6096
  radius: radiusProp = 3,
6083
- referenceBoundary = (_b = props.boundaryElement) != null ? _b : boundaryElementContext.element,
6097
+ referenceBoundary = (_d = props.boundaryElement) != null ? _d : boundaryElementContext.element,
6084
6098
  referenceElement,
6085
6099
  scheme,
6086
6100
  shadow: shadowProp = 3,
6087
6101
  tone = "inherit",
6088
6102
  width: widthProp = "auto",
6089
- zOffset: zOffsetProp = (_c = theme.sanity.layer) == null ? void 0 : _c.popover.zOffset,
6103
+ zOffset: zOffsetProp = (_e = theme.sanity.layer) == null ? void 0 : _e.popover.zOffset,
6090
6104
  updateRef,
6091
6105
  ...restProps
6092
6106
  } = props;
6093
- const boundarySize = (_d = useElementSize(boundaryElement)) == null ? void 0 : _d.border;
6107
+ const boundarySize = (_f = useElementSize(boundaryElement)) == null ? void 0 : _f.border;
6094
6108
  const padding = useArrayProp(paddingProp);
6095
6109
  const radius = useArrayProp(radiusProp);
6096
6110
  const shadow = useArrayProp(shadowProp);
@@ -6209,9 +6223,9 @@ const Popover = memo(forwardRef(function Popover2(props, ref) {
6209
6223
  placement: placementProp,
6210
6224
  whileElementsMounted: autoUpdate
6211
6225
  });
6212
- const referenceHidden = (_e = middlewareData.hide) == null ? void 0 : _e.referenceHidden;
6213
- const arrowX = (_f = middlewareData.arrow) == null ? void 0 : _f.x;
6214
- const arrowY = (_g = middlewareData.arrow) == null ? void 0 : _g.y;
6226
+ const referenceHidden = (_g = middlewareData.hide) == null ? void 0 : _g.referenceHidden;
6227
+ const arrowX = (_h = middlewareData.arrow) == null ? void 0 : _h.x;
6228
+ const arrowY = (_i = middlewareData.arrow) == null ? void 0 : _i.y;
6215
6229
  const setArrow = useCallback(arrowEl => {
6216
6230
  arrowRef.current = arrowEl;
6217
6231
  }, []);
@@ -6668,6 +6682,11 @@ const Presentation = styled.span(responsiveRadiusStyle, textInputRepresentationS
6668
6682
  const LeftBox = styled(Box)(_d$3 || (_d$3 = __template$g(["\n position: absolute;\n top: 0;\n left: 0;\n"])));
6669
6683
  const RightBox = styled(Box)(_e$1 || (_e$1 = __template$g(["\n position: absolute;\n top: 0;\n right: 0;\n"])));
6670
6684
  const RightCard = styled(Card)(_f$1 || (_f$1 = __template$g(["\n background-color: transparent;\n position: absolute;\n top: 0;\n right: 0;\n"])));
6685
+ const TextInputClearButton = styled(Button)({
6686
+ "&:not([hidden])": {
6687
+ display: "block"
6688
+ }
6689
+ });
6671
6690
  const TextInput = forwardRef(function TextInput2(props, forwardedRef) {
6672
6691
  const {
6673
6692
  border = true,
@@ -6763,7 +6782,7 @@ const TextInput = forwardRef(function TextInput2(props, forwardedRef) {
6763
6782
  padding: clearButtonBoxPadding,
6764
6783
  style: CLEAR_BUTTON_BOX_STYLE,
6765
6784
  tone: customValidity ? "critical" : "inherit",
6766
- children: /* @__PURE__ */jsx(Button, {
6785
+ children: /* @__PURE__ */jsx(TextInputClearButton, {
6767
6786
  "aria-label": "Clear",
6768
6787
  "data-qa": "clear-button",
6769
6788
  fontSize,
@@ -6828,6 +6847,20 @@ function useDelayedState(initialState) {
6828
6847
  }, []);
6829
6848
  return [state, onStateChange];
6830
6849
  }
6850
+ const DEFAULT_FALLBACK_PLACEMENTS = {
6851
+ top: ["bottom", "left", "right"],
6852
+ "top-start": ["bottom-start", "left-start", "right-start"],
6853
+ "top-end": ["bottom-end", "left-end", "right-end"],
6854
+ bottom: ["top", "left", "right"],
6855
+ "bottom-start": ["top-start", "left-start", "right-start"],
6856
+ "bottom-end": ["top-end", "left-end", "right-end"],
6857
+ left: ["right", "top", "bottom"],
6858
+ "left-start": ["right-start", "top-start", "bottom-start"],
6859
+ "left-end": ["right-end", "top-end", "bottom-end"],
6860
+ right: ["left", "top", "bottom"],
6861
+ "right-start": ["left-start", "top-start", "bottom-start"],
6862
+ "right-end": ["left-end", "top-end", "bottom-end"]
6863
+ };
6831
6864
  var __freeze$f = Object.freeze;
6832
6865
  var __defProp$f = Object.defineProperty;
6833
6866
  var __template$f = (cooked, raw) => __freeze$f(__defProp$f(cooked, "raw", {
@@ -6899,7 +6932,7 @@ var __template$e = (cooked, raw) => __freeze$e(__defProp$e(cooked, "raw", {
6899
6932
  var _a$e;
6900
6933
  const Root$a = styled(Layer)(_a$e || (_a$e = __template$e(["\n pointer-events: none;\n"])));
6901
6934
  const Tooltip = forwardRef(function Tooltip2(props, ref) {
6902
- var _a2, _b, _c;
6935
+ var _a2, _b, _c, _d, _e;
6903
6936
  const boundaryElementContext = useBoundaryElement();
6904
6937
  const theme = useTheme();
6905
6938
  const {
@@ -6907,13 +6940,13 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
6907
6940
  children: childProp,
6908
6941
  content,
6909
6942
  disabled,
6910
- fallbackPlacements: fallbackPlacementsProp,
6943
+ fallbackPlacements: fallbackPlacementsProp = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS[(_a2 = props.placement) != null ? _a2 : "bottom"],
6911
6944
  padding,
6912
6945
  placement: placementProp = "bottom",
6913
6946
  portal,
6914
6947
  scheme,
6915
6948
  shadow = 2,
6916
- zOffset = (_a2 = theme.sanity.layer) == null ? void 0 : _a2.tooltip.zOffset,
6949
+ zOffset = (_c = theme.sanity.layer) == null ? void 0 : _c.tooltip.zOffset,
6917
6950
  delay,
6918
6951
  ...restProps
6919
6952
  } = props;
@@ -6973,8 +7006,8 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
6973
7006
  whileElementsMounted: autoUpdate
6974
7007
  });
6975
7008
  const staticSide = placement && FLOATING_STATIC_SIDES[placement.split("-")[0]];
6976
- const arrowX = (_b = middlewareData.arrow) == null ? void 0 : _b.x;
6977
- const arrowY = (_c = middlewareData.arrow) == null ? void 0 : _c.y;
7009
+ const arrowX = (_d = middlewareData.arrow) == null ? void 0 : _d.x;
7010
+ const arrowY = (_e = middlewareData.arrow) == null ? void 0 : _e.y;
6978
7011
  const arrowStyle = useMemo(() => {
6979
7012
  const style = {
6980
7013
  left: arrowX !== null ? arrowX : void 0,