@sanity/ui 1.8.2 → 1.9.0

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
@@ -4761,7 +4761,7 @@ function cardBaseStyle(props) {
4761
4761
  theme
4762
4762
  } = props;
4763
4763
  const space = theme.sanity.space;
4764
- return styled.css(_b$i || (_b$i = __template$t(["\n ", "\n\n &[data-as='button'] {\n -webkit-font-smoothing: inherit;\n appearance: none;\n outline: none;\n font: inherit;\n text-align: inherit;\n border: 0;\n width: stretch;\n }\n\n /* &:is(a) */\n &[data-as='a'] {\n outline: none;\n text-decoration: none;\n }\n\n /* &:is(pre) */\n &[data-as='pre'] {\n font: inherit;\n }\n "])), $checkered && styled.css(_a$t || (_a$t = __template$t(["\n background-size: ", "px ", "px;\n background-position: 50% 50%;\n background-image: var(--card-bg-image);\n "])), space[3], space[3]));
4764
+ return styled.css(_b$i || (_b$i = __template$t(["\n ", "\n\n &[data-as='button'] {\n -webkit-font-smoothing: inherit;\n appearance: none;\n outline: none;\n font: inherit;\n text-align: inherit;\n border: 0;\n width: -webkit-fill-available;\n width: stretch;\n }\n\n /* &:is(a) */\n &[data-as='a'] {\n outline: none;\n text-decoration: none;\n }\n\n /* &:is(pre) */\n &[data-as='pre'] {\n font: inherit;\n }\n "])), $checkered && styled.css(_a$t || (_a$t = __template$t(["\n background-size: ", "px ", "px;\n background-position: 50% 50%;\n background-image: var(--card-bg-image);\n "])), space[3], space[3]));
4765
4765
  }
4766
4766
  function cardColorStyle(props) {
4767
4767
  var _a2, _b2;
@@ -6378,7 +6378,7 @@ var __template$j = (cooked, raw) => __freeze$j(__defProp$j(cooked, "raw", {
6378
6378
  }));
6379
6379
  var _a$j, _b$c, _c$7, _d$5;
6380
6380
  function rootStyle() {
6381
- return styled.css(_a$j || (_a$j = __template$j(["\n position: relative;\n width: stretch;\n\n &:not([hidden]) {\n display: inline-block;\n }\n "])));
6381
+ return styled.css(_a$j || (_a$j = __template$j(["\n position: relative;\n width: -webkit-fill-available;\n width: stretch;\n\n &:not([hidden]) {\n display: inline-block;\n }\n "])));
6382
6382
  }
6383
6383
  function inputBaseStyle(props) {
6384
6384
  const {
@@ -7040,19 +7040,21 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
7040
7040
  const closeDelayProp = typeof delay === "number" ? delay : (delay == null ? void 0 : delay.close) || 0;
7041
7041
  const openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp;
7042
7042
  const closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp;
7043
- const handleIsOpenChange = react.useCallback(open => {
7043
+ const handleIsOpenChange = react.useCallback((open, immediate) => {
7044
7044
  if (isInsideGroup) {
7045
7045
  if (open) {
7046
- delayGroupContext.setIsGroupActive(open, openDelay);
7047
- delayGroupContext.setOpenTooltipId(tooltipId, openDelay);
7046
+ const groupedOpenDelay = immediate ? 0 : openDelay;
7047
+ delayGroupContext.setIsGroupActive(open, groupedOpenDelay);
7048
+ delayGroupContext.setOpenTooltipId(tooltipId, groupedOpenDelay);
7048
7049
  } else {
7049
7050
  const minimumGroupDeactivateDelay = 200;
7050
7051
  const groupDeactivateDelay = closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay;
7051
7052
  delayGroupContext.setIsGroupActive(open, groupDeactivateDelay);
7052
- delayGroupContext.setOpenTooltipId(null, closeDelay);
7053
+ delayGroupContext.setOpenTooltipId(null, immediate ? 0 : closeDelay);
7053
7054
  }
7054
7055
  } else {
7055
- setIsOpen(open, open ? openDelay : closeDelay);
7056
+ const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay;
7057
+ setIsOpen(open, standaloneDelay);
7056
7058
  }
7057
7059
  }, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]);
7058
7060
  const handleBlur = react.useCallback(() => handleIsOpenChange(false), [handleIsOpenChange]);
@@ -7081,6 +7083,18 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
7081
7083
  if (!content) handleIsOpenChange(false);
7082
7084
  }, [content, handleIsOpenChange]);
7083
7085
  react.useEffect(() => refs.setReference(referenceElement), [referenceElement, refs]);
7086
+ react.useEffect(() => {
7087
+ if (!showTooltip) return;
7088
+ function handleWindowKeyDown(event) {
7089
+ if (event.key === "Escape") {
7090
+ handleIsOpenChange(false, true);
7091
+ }
7092
+ }
7093
+ window.addEventListener("keydown", handleWindowKeyDown);
7094
+ return () => {
7095
+ window.removeEventListener("keydown", handleWindowKeyDown);
7096
+ };
7097
+ }, [handleIsOpenChange, showTooltip]);
7084
7098
  const setArrow = react.useCallback(arrowEl => {
7085
7099
  arrowRef.current = arrowEl;
7086
7100
  update();
@@ -8529,7 +8543,7 @@ var __template$7 = (cooked, raw) => __freeze$7(__defProp$7(cooked, "raw", {
8529
8543
  }));
8530
8544
  var _a$7, _b$4;
8531
8545
  function selectableBaseStyle() {
8532
- return styled.css(_a$7 || (_a$7 = __template$7(["\n background-color: inherit;\n color: inherit;\n\n &[data-as='button'] {\n -webkit-font-smoothing: inherit;\n appearance: none;\n outline: none;\n font: inherit;\n text-align: inherit;\n border: 0;\n width: stretch;\n }\n\n /* &:is(a) */\n &[data-as='a'] {\n text-decoration: none;\n }\n "])));
8546
+ return styled.css(_a$7 || (_a$7 = __template$7(["\n background-color: inherit;\n color: inherit;\n\n &[data-as='button'] {\n -webkit-font-smoothing: inherit;\n appearance: none;\n outline: none;\n font: inherit;\n text-align: inherit;\n border: 0;\n width: -webkit-fill-available;\n width: stretch;\n }\n\n /* &:is(a) */\n &[data-as='a'] {\n text-decoration: none;\n }\n "])));
8533
8547
  }
8534
8548
  function selectableColorStyle(props) {
8535
8549
  var _a2, _b2;