@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.js CHANGED
@@ -5873,6 +5873,20 @@ const DEFAULT_POPOVER_PADDING = 4;
5873
5873
  const DEFAULT_POPOVER_ARROW_WIDTH = 27;
5874
5874
  const DEFAULT_POPOVER_ARROW_HEIGHT = 11;
5875
5875
  const DEFAULT_POPOVER_MARGINS = [0, 0, 0, 0];
5876
+ const DEFAULT_FALLBACK_PLACEMENTS$1 = {
5877
+ top: ["bottom", "left", "right"],
5878
+ "top-start": ["bottom-start", "left-start", "right-start"],
5879
+ "top-end": ["bottom-end", "left-end", "right-end"],
5880
+ bottom: ["top", "left", "right"],
5881
+ "bottom-start": ["top-start", "left-start", "right-start"],
5882
+ "bottom-end": ["top-end", "left-end", "right-end"],
5883
+ left: ["right", "top", "bottom"],
5884
+ "left-start": ["right-start", "top-start", "bottom-start"],
5885
+ "left-end": ["right-end", "top-end", "bottom-end"],
5886
+ right: ["left", "top", "bottom"],
5887
+ "right-start": ["left-start", "top-start", "bottom-start"],
5888
+ "right-end": ["left-end", "top-end", "bottom-end"]
5889
+ };
5876
5890
  function size(options) {
5877
5891
  const {
5878
5892
  apply,
@@ -6072,7 +6086,7 @@ const PopoverCard = react.memo(react.forwardRef(function PopoverCard2(props, ref
6072
6086
  }));
6073
6087
  PopoverCard.displayName = "PopoverCard";
6074
6088
  const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
6075
- var _a, _b, _c, _d, _e, _f, _g;
6089
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
6076
6090
  const theme = useTheme();
6077
6091
  const boundaryElementContext = useBoundaryElement();
6078
6092
  const {
@@ -6083,9 +6097,9 @@ const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
6083
6097
  constrainSize = false,
6084
6098
  content,
6085
6099
  disabled,
6086
- fallbackPlacements,
6100
+ fallbackPlacements = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS$1[(_a = props.placement) != null ? _a : "bottom"],
6087
6101
  matchReferenceWidth,
6088
- floatingBoundary = (_a = props.boundaryElement) != null ? _a : boundaryElementContext.element,
6102
+ floatingBoundary = (_c = props.boundaryElement) != null ? _c : boundaryElementContext.element,
6089
6103
  open,
6090
6104
  overflow = "hidden",
6091
6105
  padding: paddingProp,
@@ -6093,17 +6107,17 @@ const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
6093
6107
  portal,
6094
6108
  preventOverflow = true,
6095
6109
  radius: radiusProp = 3,
6096
- referenceBoundary = (_b = props.boundaryElement) != null ? _b : boundaryElementContext.element,
6110
+ referenceBoundary = (_d = props.boundaryElement) != null ? _d : boundaryElementContext.element,
6097
6111
  referenceElement,
6098
6112
  scheme,
6099
6113
  shadow: shadowProp = 3,
6100
6114
  tone = "inherit",
6101
6115
  width: widthProp = "auto",
6102
- zOffset: zOffsetProp = (_c = theme.sanity.layer) == null ? void 0 : _c.popover.zOffset,
6116
+ zOffset: zOffsetProp = (_e = theme.sanity.layer) == null ? void 0 : _e.popover.zOffset,
6103
6117
  updateRef,
6104
6118
  ...restProps
6105
6119
  } = props;
6106
- const boundarySize = (_d = useElementSize(boundaryElement)) == null ? void 0 : _d.border;
6120
+ const boundarySize = (_f = useElementSize(boundaryElement)) == null ? void 0 : _f.border;
6107
6121
  const padding = useArrayProp(paddingProp);
6108
6122
  const radius = useArrayProp(radiusProp);
6109
6123
  const shadow = useArrayProp(shadowProp);
@@ -6222,9 +6236,9 @@ const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
6222
6236
  placement: placementProp,
6223
6237
  whileElementsMounted: reactDom$1.autoUpdate
6224
6238
  });
6225
- const referenceHidden = (_e = middlewareData.hide) == null ? void 0 : _e.referenceHidden;
6226
- const arrowX = (_f = middlewareData.arrow) == null ? void 0 : _f.x;
6227
- const arrowY = (_g = middlewareData.arrow) == null ? void 0 : _g.y;
6239
+ const referenceHidden = (_g = middlewareData.hide) == null ? void 0 : _g.referenceHidden;
6240
+ const arrowX = (_h = middlewareData.arrow) == null ? void 0 : _h.x;
6241
+ const arrowY = (_i = middlewareData.arrow) == null ? void 0 : _i.y;
6228
6242
  const setArrow = react.useCallback(arrowEl => {
6229
6243
  arrowRef.current = arrowEl;
6230
6244
  }, []);
@@ -6681,6 +6695,11 @@ const Presentation = styled__default.default.span(responsiveRadiusStyle, textInp
6681
6695
  const LeftBox = styled__default.default(Box)(_d$3 || (_d$3 = __template$g(["\n position: absolute;\n top: 0;\n left: 0;\n"])));
6682
6696
  const RightBox = styled__default.default(Box)(_e$1 || (_e$1 = __template$g(["\n position: absolute;\n top: 0;\n right: 0;\n"])));
6683
6697
  const RightCard = styled__default.default(Card)(_f$1 || (_f$1 = __template$g(["\n background-color: transparent;\n position: absolute;\n top: 0;\n right: 0;\n"])));
6698
+ const TextInputClearButton = styled__default.default(Button)({
6699
+ "&:not([hidden])": {
6700
+ display: "block"
6701
+ }
6702
+ });
6684
6703
  const TextInput = react.forwardRef(function TextInput2(props, forwardedRef) {
6685
6704
  const {
6686
6705
  border = true,
@@ -6776,7 +6795,7 @@ const TextInput = react.forwardRef(function TextInput2(props, forwardedRef) {
6776
6795
  padding: clearButtonBoxPadding,
6777
6796
  style: CLEAR_BUTTON_BOX_STYLE,
6778
6797
  tone: customValidity ? "critical" : "inherit",
6779
- children: /* @__PURE__ */jsxRuntime.jsx(Button, {
6798
+ children: /* @__PURE__ */jsxRuntime.jsx(TextInputClearButton, {
6780
6799
  "aria-label": "Clear",
6781
6800
  "data-qa": "clear-button",
6782
6801
  fontSize,
@@ -6841,6 +6860,20 @@ function useDelayedState(initialState) {
6841
6860
  }, []);
6842
6861
  return [state, onStateChange];
6843
6862
  }
6863
+ const DEFAULT_FALLBACK_PLACEMENTS = {
6864
+ top: ["bottom", "left", "right"],
6865
+ "top-start": ["bottom-start", "left-start", "right-start"],
6866
+ "top-end": ["bottom-end", "left-end", "right-end"],
6867
+ bottom: ["top", "left", "right"],
6868
+ "bottom-start": ["top-start", "left-start", "right-start"],
6869
+ "bottom-end": ["top-end", "left-end", "right-end"],
6870
+ left: ["right", "top", "bottom"],
6871
+ "left-start": ["right-start", "top-start", "bottom-start"],
6872
+ "left-end": ["right-end", "top-end", "bottom-end"],
6873
+ right: ["left", "top", "bottom"],
6874
+ "right-start": ["left-start", "top-start", "bottom-start"],
6875
+ "right-end": ["left-end", "top-end", "bottom-end"]
6876
+ };
6844
6877
  var __freeze$f = Object.freeze;
6845
6878
  var __defProp$f = Object.defineProperty;
6846
6879
  var __template$f = (cooked, raw) => __freeze$f(__defProp$f(cooked, "raw", {
@@ -6912,7 +6945,7 @@ var __template$e = (cooked, raw) => __freeze$e(__defProp$e(cooked, "raw", {
6912
6945
  var _a$e;
6913
6946
  const Root$a = styled__default.default(Layer)(_a$e || (_a$e = __template$e(["\n pointer-events: none;\n"])));
6914
6947
  const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
6915
- var _a2, _b, _c;
6948
+ var _a2, _b, _c, _d, _e;
6916
6949
  const boundaryElementContext = useBoundaryElement();
6917
6950
  const theme = useTheme();
6918
6951
  const {
@@ -6920,13 +6953,13 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
6920
6953
  children: childProp,
6921
6954
  content,
6922
6955
  disabled,
6923
- fallbackPlacements: fallbackPlacementsProp,
6956
+ fallbackPlacements: fallbackPlacementsProp = (_b = props.fallbackPlacements) != null ? _b : DEFAULT_FALLBACK_PLACEMENTS[(_a2 = props.placement) != null ? _a2 : "bottom"],
6924
6957
  padding,
6925
6958
  placement: placementProp = "bottom",
6926
6959
  portal,
6927
6960
  scheme,
6928
6961
  shadow = 2,
6929
- zOffset = (_a2 = theme.sanity.layer) == null ? void 0 : _a2.tooltip.zOffset,
6962
+ zOffset = (_c = theme.sanity.layer) == null ? void 0 : _c.tooltip.zOffset,
6930
6963
  delay,
6931
6964
  ...restProps
6932
6965
  } = props;
@@ -6986,8 +7019,8 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
6986
7019
  whileElementsMounted: reactDom$1.autoUpdate
6987
7020
  });
6988
7021
  const staticSide = placement && FLOATING_STATIC_SIDES[placement.split("-")[0]];
6989
- const arrowX = (_b = middlewareData.arrow) == null ? void 0 : _b.x;
6990
- const arrowY = (_c = middlewareData.arrow) == null ? void 0 : _c.y;
7022
+ const arrowX = (_d = middlewareData.arrow) == null ? void 0 : _d.x;
7023
+ const arrowY = (_e = middlewareData.arrow) == null ? void 0 : _e.y;
6991
7024
  const arrowStyle = react.useMemo(() => {
6992
7025
  const style = {
6993
7026
  left: arrowX !== null ? arrowX : void 0,