@sanity/ui 1.7.9 → 1.7.11

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 (55) hide show
  1. package/dist/index.d.ts +351 -15
  2. package/dist/index.esm.js +44 -47
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +43 -46
  5. package/dist/index.js.map +1 -1
  6. package/package.json +20 -19
  7. package/src/components/dialog/styles.ts +1 -1
  8. package/src/components/menu/__workshop__/shouldFocus.tsx +1 -1
  9. package/src/components/menu/menuDivider.ts +2 -3
  10. package/src/components/menu/menuGroup.tsx +1 -1
  11. package/src/components/tree/style.ts +4 -4
  12. package/src/primitives/_selectable/style.ts +3 -3
  13. package/src/primitives/avatar/styles.ts +6 -3
  14. package/src/primitives/badge/styles.ts +1 -1
  15. package/src/primitives/box/box.tsx +1 -0
  16. package/src/primitives/button/styles.ts +3 -2
  17. package/src/primitives/card/styles.ts +4 -4
  18. package/src/primitives/checkbox/styles.ts +3 -3
  19. package/src/primitives/code/styles.ts +3 -5
  20. package/src/primitives/container/styles.ts +1 -1
  21. package/src/primitives/flex/flex.tsx +1 -0
  22. package/src/primitives/heading/styles.ts +2 -4
  23. package/src/primitives/inline/inline.tsx +8 -1
  24. package/src/primitives/inline/styles.ts +1 -1
  25. package/src/primitives/label/styles.ts +2 -2
  26. package/src/primitives/popover/popover.tsx +2 -0
  27. package/src/primitives/radio/styles.ts +3 -3
  28. package/src/primitives/select/styles.ts +6 -5
  29. package/src/primitives/stack/styles.ts +1 -1
  30. package/src/primitives/switch/styles.ts +6 -6
  31. package/src/primitives/text/styles.ts +2 -2
  32. package/src/primitives/tooltip/tooltip.tsx +11 -22
  33. package/src/styles/border/borderStyle.ts +1 -1
  34. package/src/styles/box/boxStyle.ts +1 -1
  35. package/src/styles/colorVars/colorVarsStyle.ts +1 -1
  36. package/src/styles/flex/flexItemStyle.ts +1 -1
  37. package/src/styles/flex/flexStyle.ts +1 -1
  38. package/src/styles/font/codeFontStyle.ts +1 -1
  39. package/src/styles/font/headingFontStyle.ts +1 -1
  40. package/src/styles/font/labelFontStyle.ts +1 -1
  41. package/src/styles/font/responsiveFont.ts +1 -1
  42. package/src/styles/font/textAlignStyle.ts +1 -1
  43. package/src/styles/font/textFontStyle.ts +1 -1
  44. package/src/styles/grid/gridItemStyle.ts +1 -1
  45. package/src/styles/grid/gridStyle.ts +1 -1
  46. package/src/styles/helpers.ts +1 -1
  47. package/src/styles/input/responsiveInputPaddingStyle.ts +1 -1
  48. package/src/styles/input/textInputStyle.ts +5 -4
  49. package/src/styles/margin/marginStyle.ts +1 -1
  50. package/src/styles/padding/paddingStyle.ts +1 -1
  51. package/src/styles/radius/radiusStyle.ts +1 -1
  52. package/src/styles/shadow/shadowStyle.ts +1 -1
  53. package/src/theme/types.ts +1 -1
  54. package/src/types/index.ts +1 -0
  55. package/src/types/styled.ts +9 -0
package/dist/index.esm.js CHANGED
@@ -5,7 +5,7 @@ import styled, { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css,
5
5
  import { white as white$1, black as black$1, hues } from '@sanity/color';
6
6
  import { SpinnerIcon, CheckmarkIcon, RemoveIcon, SelectIcon, CloseIcon, ChevronDownIcon, ChevronRightIcon, ToggleArrowRightIcon } from '@sanity/icons';
7
7
  import Refractor from 'react-refractor';
8
- import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate, size as size$2 } from '@floating-ui/react-dom';
8
+ import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from '@floating-ui/react-dom';
9
9
  import { createPortal } from 'react-dom';
10
10
  import { AnimatePresence, motion } from 'framer-motion';
11
11
  const EMPTY_ARRAY = [];
@@ -3983,6 +3983,7 @@ function avatarArrowStyle() {
3983
3983
  top: "-5px",
3984
3984
  left: "50%",
3985
3985
  transform: "translateX(-6px)",
3986
+ // @ts-expect-error -- TODO wait for CSSObject types to be fixed in `styled-components` itself
3986
3987
  "&:not([hidden])": {
3987
3988
  display: "block"
3988
3989
  }
@@ -4019,13 +4020,14 @@ function avatarRootStyle(props) {
4019
4020
  opacity: 0.5
4020
4021
  },
4021
4022
  "&>svg": {
4023
+ // @ts-expect-error -- TODO wait for CSSObject types to be fixed in `styled-components` itself
4022
4024
  "&:not([hidden])": {
4023
4025
  display: "block"
4024
4026
  }
4025
4027
  },
4026
4028
  /* &:is(button) */
4027
4029
  '&[data-as="button"]': {
4028
- "-webkit-font-smoothing": "inherit",
4030
+ WebkitFontSmoothing: "inherit",
4029
4031
  appearance: "none",
4030
4032
  margin: 0,
4031
4033
  padding: 0,
@@ -4033,6 +4035,7 @@ function avatarRootStyle(props) {
4033
4035
  font: "inherit",
4034
4036
  color: "inherit",
4035
4037
  outline: "none",
4038
+ // @ts-expect-error -- TODO wait for CSSObject types to be fixed in `styled-components` itself
4036
4039
  "&:focus": {
4037
4040
  boxShadow: focusRingStyle({
4038
4041
  focusRing
@@ -4097,7 +4100,7 @@ function avatarStrokeStyle() {
4097
4100
  return {
4098
4101
  strokeWidth: "3px",
4099
4102
  '[data-status="editing"] &': {
4100
- strokeSasharray: "2 4",
4103
+ strokeDasharray: "2 4",
4101
4104
  strokeLinecap: "round"
4102
4105
  }
4103
4106
  };
@@ -4514,17 +4517,21 @@ const Flex = forwardRef(function Flex2(props, ref) {
4514
4517
  wrap,
4515
4518
  ...restProps
4516
4519
  } = props;
4517
- return /* @__PURE__ */jsx(Root$x, {
4518
- "data-ui": "Flex",
4519
- ...restProps,
4520
- $align: useArrayProp(align),
4521
- $direction: useArrayProp(direction),
4522
- $gap: useArrayProp(gap),
4523
- $justify: useArrayProp(justify),
4524
- $wrap: useArrayProp(wrap),
4525
- forwardedAs: as,
4526
- ref
4527
- });
4520
+ return (
4521
+ // @ts-expect-error -- some dollar prefixed typings aren't inferred correctly https://github.com/styled-components/styled-components/issues/4062
4522
+ /* @__PURE__ */
4523
+ jsx(Root$x, {
4524
+ "data-ui": "Flex",
4525
+ ...restProps,
4526
+ $align: useArrayProp(align),
4527
+ $direction: useArrayProp(direction),
4528
+ $gap: useArrayProp(gap),
4529
+ $justify: useArrayProp(justify),
4530
+ $wrap: useArrayProp(wrap),
4531
+ forwardedAs: as,
4532
+ ref
4533
+ })
4534
+ );
4528
4535
  });
4529
4536
  var __freeze$w = Object.freeze;
4530
4537
  var __defProp$x = Object.defineProperty;
@@ -6870,28 +6877,11 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
6870
6877
  boundary: boundaryElement || void 0,
6871
6878
  fallbackPlacements,
6872
6879
  padding: 4,
6873
- rootBoundary,
6874
- mainAxis: false
6880
+ rootBoundary
6875
6881
  }));
6876
6882
  ret.push(offset({
6877
6883
  mainAxis: 3
6878
6884
  }));
6879
- ret.push(size$2({
6880
- apply(_ref22) {
6881
- let {
6882
- availableWidth,
6883
- availableHeight,
6884
- elements
6885
- } = _ref22;
6886
- Object.assign(elements.floating.style, {
6887
- maxWidth: "".concat(availableWidth - 4 * 2, "px"),
6888
- // the padding is `4px`
6889
- maxHeight: "".concat(availableHeight - 4 * 2, "px")
6890
- // the padding is `4px`
6891
- });
6892
- }
6893
- }));
6894
-
6895
6885
  ret.push(shift({
6896
6886
  boundary: boundaryElement || void 0,
6897
6887
  rootBoundary,
@@ -6904,16 +6894,23 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
6904
6894
  return ret;
6905
6895
  }, [boundaryElement, fallbackPlacements]);
6906
6896
  const {
6907
- floatingStyles,
6897
+ x,
6898
+ y,
6908
6899
  placement,
6909
6900
  middlewareData,
6910
6901
  refs,
6911
- update
6902
+ update,
6903
+ strategy
6912
6904
  } = useFloating({
6913
6905
  middleware,
6914
6906
  placement: placementProp,
6915
6907
  whileElementsMounted: autoUpdate
6916
6908
  });
6909
+ const rootStyle = useMemo(() => ({
6910
+ position: strategy,
6911
+ top: y != null ? y : 0,
6912
+ left: x != null ? x : 0
6913
+ }), [strategy, x, y]);
6917
6914
  const staticSide = placement && FLOATING_STATIC_SIDES[placement.split("-")[0]];
6918
6915
  const arrowX = (_b = middlewareData.arrow) == null ? void 0 : _b.x;
6919
6916
  const arrowY = (_c = middlewareData.arrow) == null ? void 0 : _c.y;
@@ -6987,7 +6984,7 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
6987
6984
  "data-ui": "Tooltip",
6988
6985
  ...restProps,
6989
6986
  ref: setFloating,
6990
- style: floatingStyles,
6987
+ style: rootStyle,
6991
6988
  zOffset,
6992
6989
  children: /* @__PURE__ */jsxs(Card, {
6993
6990
  "data-ui": "Tooltip__card",
@@ -7165,10 +7162,10 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete2(props, ref) {
7165
7162
  query,
7166
7163
  value
7167
7164
  } = state;
7168
- const defaultRenderOption = useCallback(_ref23 => {
7165
+ const defaultRenderOption = useCallback(_ref22 => {
7169
7166
  let {
7170
7167
  value: value2
7171
- } = _ref23;
7168
+ } = _ref22;
7172
7169
  return /* @__PURE__ */jsx(Card, {
7173
7170
  "data-as": "button",
7174
7171
  padding: paddingProp,
@@ -7621,10 +7618,10 @@ const Breadcrumbs = forwardRef(function Breadcrumbs2(props, ref) {
7621
7618
  }, itemIndex))
7622
7619
  });
7623
7620
  });
7624
- function dialogStyle(_ref24) {
7621
+ function dialogStyle(_ref23) {
7625
7622
  let {
7626
7623
  theme
7627
- } = _ref24;
7624
+ } = _ref23;
7628
7625
  const color = theme.sanity.color.base;
7629
7626
  return {
7630
7627
  "&:not([hidden])": {
@@ -8686,15 +8683,15 @@ var __template$6 = (cooked, raw) => __freeze$6(__defProp$6(cooked, "raw", {
8686
8683
  var _a$6, _b$3, _c$1, _d;
8687
8684
  const keyframe = keyframes(_a$6 || (_a$6 = __template$6(["\n 0% {\n background-position: 100%;\n }\n 100% {\n background-position: -100%;\n }\n"])));
8688
8685
  const animation = css(_b$3 || (_b$3 = __template$6(["\n background-image: linear-gradient(\n to right,\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-to),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from)\n );\n background-position: 100%;\n background-size: 200% 100%;\n background-attachment: fixed;\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n animation-iteration-count: infinite;\n animation-duration: 2000ms;\n"])), keyframe);
8689
- const skeletonStyle = css(_d || (_d = __template$6(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])), _ref25 => {
8686
+ const skeletonStyle = css(_d || (_d = __template$6(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])), _ref24 => {
8690
8687
  let {
8691
8688
  $visible
8692
- } = _ref25;
8689
+ } = _ref24;
8693
8690
  return $visible ? 1 : 0;
8694
- }, _ref26 => {
8691
+ }, _ref25 => {
8695
8692
  let {
8696
8693
  $animated
8697
- } = _ref26;
8694
+ } = _ref25;
8698
8695
  return $animated ? animation : css(_c$1 || (_c$1 = __template$6(["\n background-color: var(--card-skeleton-color-from);\n "])));
8699
8696
  });
8700
8697
  const Root$4 = styled(Box)(responsiveRadiusStyle, skeletonStyle);
@@ -8725,12 +8722,12 @@ const Skeleton = forwardRef(function Skeleton2(props, ref) {
8725
8722
  ref
8726
8723
  });
8727
8724
  });
8728
- const Root$3 = styled(Skeleton)(_ref27 => {
8725
+ const Root$3 = styled(Skeleton)(_ref26 => {
8729
8726
  let {
8730
8727
  $size,
8731
8728
  $style,
8732
8729
  theme
8733
- } = _ref27;
8730
+ } = _ref26;
8734
8731
  const {
8735
8732
  media
8736
8733
  } = theme.sanity;
@@ -9077,12 +9074,12 @@ function ToastProvider(props) {
9077
9074
  paddingY,
9078
9075
  children: /* @__PURE__ */jsx(AnimatePresence, {
9079
9076
  initial: false,
9080
- children: state.map(_ref28 => {
9077
+ children: state.map(_ref27 => {
9081
9078
  let {
9082
9079
  dismiss,
9083
9080
  id,
9084
9081
  params
9085
- } = _ref28;
9082
+ } = _ref27;
9086
9083
  return /* @__PURE__ */jsx(motion.div, {
9087
9084
  animate: {
9088
9085
  opacity: 1,