@sanity/ui 2.0.0-alpha.16 → 2.0.0-alpha.18

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.
Files changed (46) hide show
  1. package/dist/index.d.ts +83 -1
  2. package/dist/index.esm.js +35 -22
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +35 -22
  5. package/dist/index.js.map +1 -1
  6. package/package.json +5 -7
  7. package/src/components/autocomplete/autocomplete.tsx +6 -0
  8. package/src/components/dialog/dialog.tsx +2 -0
  9. package/src/components/hotkeys/hotkeys.tsx +2 -0
  10. package/src/components/menu/menu.tsx +2 -0
  11. package/src/components/menu/menuButton.tsx +2 -0
  12. package/src/components/toast/toast.tsx +4 -0
  13. package/src/primitives/_selectable/style.ts +2 -0
  14. package/src/primitives/avatar/avatar.tsx +16 -9
  15. package/src/primitives/avatar/avatarCounter.tsx +3 -3
  16. package/src/primitives/avatar/styles.ts +1 -1
  17. package/src/primitives/badge/badge.tsx +2 -0
  18. package/src/primitives/box/box.tsx +3 -0
  19. package/src/primitives/button/__workshop__/sanityUploadButton.tsx +2 -1
  20. package/src/primitives/button/styles.ts +1 -0
  21. package/src/primitives/card/card.tsx +3 -0
  22. package/src/primitives/card/styles.ts +2 -0
  23. package/src/primitives/checkbox/checkbox.tsx +2 -0
  24. package/src/primitives/code/code.tsx +1 -0
  25. package/src/primitives/container/container.tsx +2 -0
  26. package/src/primitives/flex/flex.tsx +2 -0
  27. package/src/primitives/grid/grid.tsx +2 -0
  28. package/src/primitives/heading/heading.tsx +2 -0
  29. package/src/primitives/inline/inline.tsx +3 -0
  30. package/src/primitives/kbd/kbd.tsx +2 -0
  31. package/src/primitives/label/label.tsx +2 -0
  32. package/src/primitives/popover/popover.tsx +6 -1
  33. package/src/primitives/radio/radio.tsx +2 -0
  34. package/src/primitives/select/select.tsx +2 -0
  35. package/src/primitives/select/styles.ts +2 -0
  36. package/src/primitives/spinner/spinner.tsx +2 -0
  37. package/src/primitives/stack/stack.tsx +2 -0
  38. package/src/primitives/switch/switch.tsx +4 -0
  39. package/src/primitives/text/text.tsx +3 -0
  40. package/src/primitives/textArea/textArea.tsx +3 -0
  41. package/src/primitives/textInput/textInput.tsx +2 -0
  42. package/src/primitives/tooltip/tooltip.test.tsx +67 -0
  43. package/src/primitives/tooltip/tooltip.tsx +28 -5
  44. package/src/primitives/types.ts +4 -0
  45. package/src/theme/lib/theme/avatar.ts +2 -0
  46. package/src/theme/studioTheme/theme.ts +4 -4
package/dist/index.js CHANGED
@@ -3836,16 +3836,16 @@ const studioTheme = {
3836
3836
  avatar: {
3837
3837
  sizes: [{
3838
3838
  distance: -3,
3839
- size: 25
3839
+ size: 23
3840
3840
  }, {
3841
3841
  distance: -6,
3842
- size: 35
3842
+ size: 33
3843
3843
  }, {
3844
3844
  distance: -9,
3845
- size: 55
3845
+ size: 53
3846
3846
  }],
3847
3847
  focusRing: {
3848
- offset: 1,
3848
+ offset: 0,
3849
3849
  width: 1
3850
3850
  }
3851
3851
  },
@@ -5017,7 +5017,7 @@ function avatarBgStrokeStyle() {
5017
5017
  }
5018
5018
  function avatarStrokeStyle() {
5019
5019
  return {
5020
- strokeWidth: "3px",
5020
+ strokeWidth: "2px",
5021
5021
  '[data-status="editing"] &': {
5022
5022
  strokeDasharray: "2 4",
5023
5023
  strokeLinecap: "round"
@@ -5039,6 +5039,7 @@ const Avatar = react.forwardRef(function Avatar2(props, ref) {
5039
5039
  onImageLoadError,
5040
5040
  arrowPosition: arrowPositionProp,
5041
5041
  animateArrowFrom,
5042
+ hideInnerStroke,
5042
5043
  status = "online",
5043
5044
  size: sizeProp = 0,
5044
5045
  ...restProps
@@ -5113,7 +5114,7 @@ const Avatar = react.forwardRef(function Avatar2(props, ref) {
5113
5114
  cy: _radius,
5114
5115
  r: _radius,
5115
5116
  fill: "url(#".concat(imageId, ")")
5116
- }), /* @__PURE__ */jsxRuntime.jsx(BgStroke, {
5117
+ }), !hideInnerStroke && /* @__PURE__ */jsxRuntime.jsx(BgStroke, {
5117
5118
  cx: _radius,
5118
5119
  cy: _radius,
5119
5120
  rx: _radius,
@@ -5132,9 +5133,8 @@ const Avatar = react.forwardRef(function Avatar2(props, ref) {
5132
5133
  children: /* @__PURE__ */jsxRuntime.jsx(Text, {
5133
5134
  as: "span",
5134
5135
  size: initialsSize,
5135
- children: /* @__PURE__ */jsxRuntime.jsx("strong", {
5136
- children: initials
5137
- })
5136
+ weight: "medium",
5137
+ children: initials
5138
5138
  })
5139
5139
  })
5140
5140
  })]
@@ -5168,7 +5168,7 @@ function _avatarCounterBaseStyle(props) {
5168
5168
  const {
5169
5169
  theme
5170
5170
  } = props;
5171
- return styled.css(_a$A || (_a$A = __template$A(["\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n user-select: none;\n color: inherit;\n color: var(--card-fg-color);\n background: var(--card-bg-color);\n box-shadow:\n 0 0 0 1px var(--card-bg-color),\n inset 0 0 0 1.5px var(--card-hairline-hard-color);\n padding: 0 ", ";\n\n &:not([hidden]) {\n display: flex;\n }\n "])), rem(theme.sanity.space[2]));
5171
+ return styled.css(_a$A || (_a$A = __template$A(["\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n user-select: none;\n color: inherit;\n color: var(--card-fg-color);\n background: var(--card-bg-color);\n box-shadow:\n 0 0 0 1px var(--card-bg-color),\n inset 0 0 0 1px var(--card-hairline-hard-color);\n padding: 0 ", ";\n\n &:not([hidden]) {\n display: flex;\n }\n "])), rem(theme.sanity.space[2]));
5172
5172
  }
5173
5173
  const Root$C = styled__default.default.div(_responsiveAvatarCounterSizeStyle, _avatarCounterBaseStyle);
5174
5174
  const AvatarCounter = react.forwardRef(function AvatarCounter2(props, ref) {
@@ -5185,9 +5185,8 @@ const AvatarCounter = react.forwardRef(function AvatarCounter2(props, ref) {
5185
5185
  children: /* @__PURE__ */jsxRuntime.jsx(Text, {
5186
5186
  as: "span",
5187
5187
  size: counterSize,
5188
- children: /* @__PURE__ */jsxRuntime.jsx("strong", {
5189
- children: count
5190
- })
5188
+ weight: "medium",
5189
+ children: count
5191
5190
  })
5192
5191
  });
5193
5192
  });
@@ -5452,7 +5451,7 @@ function buttonBaseStyles(_ref24) {
5452
5451
  let {
5453
5452
  $width
5454
5453
  } = _ref24;
5455
- return styled.css(_b$k || (_b$k = __template$x(["\n -webkit-font-smoothing: inherit;\n appearance: none;\n display: inline-flex;\n align-items: center;\n font: inherit;\n border: 0;\n outline: none;\n user-select: none;\n text-decoration: none;\n border: 0;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n white-space: nowrap;\n text-align: left;\n position: relative;\n\n ", "\n\n & > span {\n display: block;\n flex: 1;\n min-width: 0;\n border-radius: inherit;\n }\n\n &::-moz-focus-inner {\n border: 0;\n padding: 0;\n }\n "])), $width === "fill" && styled.css(_a$x || (_a$x = __template$x(["\n width: -webkit-fill-available;\n width: stretch;\n "]))));
5454
+ return styled.css(_b$k || (_b$k = __template$x(["\n -webkit-font-smoothing: inherit;\n appearance: none;\n display: inline-flex;\n align-items: center;\n font: inherit;\n border: 0;\n outline: none;\n user-select: none;\n text-decoration: none;\n border: 0;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n white-space: nowrap;\n text-align: left;\n position: relative;\n\n ", "\n\n & > span {\n display: block;\n flex: 1;\n min-width: 0;\n border-radius: inherit;\n }\n\n &::-moz-focus-inner {\n border: 0;\n padding: 0;\n }\n "])), $width === "fill" && styled.css(_a$x || (_a$x = __template$x(["\n width: -moz-available;\n width: -webkit-fill-available;\n width: stretch;\n "]))));
5456
5455
  }
5457
5456
  const buttonTheme = {
5458
5457
  border: {
@@ -5630,7 +5629,7 @@ function cardBaseStyle(props) {
5630
5629
  theme
5631
5630
  } = props;
5632
5631
  const space = theme.sanity.space;
5633
- return styled.css(_b$j || (_b$j = __template$v(["\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$v || (_a$v = __template$v(["\n background-size: ", "px ", "px;\n background-position: 50% 50%;\n background-image: var(--card-bg-image);\n "])), space[3], space[3]));
5632
+ return styled.css(_b$j || (_b$j = __template$v(["\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: -moz-available;\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$v || (_a$v = __template$v(["\n background-size: ", "px ", "px;\n background-position: 50% 50%;\n background-image: var(--card-bg-image);\n "])), space[3], space[3]));
5634
5633
  }
5635
5634
  function cardColorStyle(props) {
5636
5635
  var _a2, _b2;
@@ -7328,7 +7327,7 @@ var __template$j = (cooked, raw) => __freeze$j(__defProp$j(cooked, "raw", {
7328
7327
  }));
7329
7328
  var _a$j, _b$c, _c$7, _d$5;
7330
7329
  function rootStyle() {
7331
- 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 "])));
7330
+ return styled.css(_a$j || (_a$j = __template$j(["\n position: relative;\n width: -moz-available;\n width: -webkit-fill-available;\n width: stretch;\n\n &:not([hidden]) {\n display: inline-block;\n }\n "])));
7332
7331
  }
7333
7332
  function inputBaseStyle(props) {
7334
7333
  const {
@@ -7994,19 +7993,21 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
7994
7993
  const closeDelayProp = typeof delay === "number" ? delay : (delay == null ? void 0 : delay.close) || 0;
7995
7994
  const openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp;
7996
7995
  const closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp;
7997
- const handleIsOpenChange = react.useCallback(open => {
7996
+ const handleIsOpenChange = react.useCallback((open, immediate) => {
7998
7997
  if (isInsideGroup) {
7999
7998
  if (open) {
8000
- delayGroupContext.setIsGroupActive(open, openDelay);
8001
- delayGroupContext.setOpenTooltipId(tooltipId, openDelay);
7999
+ const groupedOpenDelay = immediate ? 0 : openDelay;
8000
+ delayGroupContext.setIsGroupActive(open, groupedOpenDelay);
8001
+ delayGroupContext.setOpenTooltipId(tooltipId, groupedOpenDelay);
8002
8002
  } else {
8003
8003
  const minimumGroupDeactivateDelay = 200;
8004
8004
  const groupDeactivateDelay = closeDelay > minimumGroupDeactivateDelay ? closeDelay : minimumGroupDeactivateDelay;
8005
8005
  delayGroupContext.setIsGroupActive(open, groupDeactivateDelay);
8006
- delayGroupContext.setOpenTooltipId(null, closeDelay);
8006
+ delayGroupContext.setOpenTooltipId(null, immediate ? 0 : closeDelay);
8007
8007
  }
8008
8008
  } else {
8009
- setIsOpen(open, open ? openDelay : closeDelay);
8009
+ const standaloneDelay = immediate ? 0 : open ? openDelay : closeDelay;
8010
+ setIsOpen(open, standaloneDelay);
8010
8011
  }
8011
8012
  }, [isInsideGroup, delayGroupContext, openDelay, tooltipId, closeDelay, setIsOpen]);
8012
8013
  const handleBlur = react.useCallback(() => handleIsOpenChange(false), [handleIsOpenChange]);
@@ -8035,6 +8036,18 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
8035
8036
  if (!content) handleIsOpenChange(false);
8036
8037
  }, [content, handleIsOpenChange]);
8037
8038
  react.useEffect(() => refs.setReference(referenceElement), [referenceElement, refs]);
8039
+ react.useEffect(() => {
8040
+ if (!showTooltip) return;
8041
+ function handleWindowKeyDown(event) {
8042
+ if (event.key === "Escape") {
8043
+ handleIsOpenChange(false, true);
8044
+ }
8045
+ }
8046
+ window.addEventListener("keydown", handleWindowKeyDown);
8047
+ return () => {
8048
+ window.removeEventListener("keydown", handleWindowKeyDown);
8049
+ };
8050
+ }, [handleIsOpenChange, showTooltip]);
8038
8051
  const setArrow = react.useCallback(arrowEl => {
8039
8052
  arrowRef.current = arrowEl;
8040
8053
  update();
@@ -9510,7 +9523,7 @@ var __template$7 = (cooked, raw) => __freeze$7(__defProp$7(cooked, "raw", {
9510
9523
  }));
9511
9524
  var _a$7, _b$4;
9512
9525
  function selectableBaseStyle() {
9513
- 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 "])));
9526
+ 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: -moz-available;\n width: -webkit-fill-available;\n width: stretch;\n }\n\n /* &:is(a) */\n &[data-as='a'] {\n text-decoration: none;\n }\n "])));
9514
9527
  }
9515
9528
  function selectableColorStyle(props) {
9516
9529
  var _a2, _b2;