@sanity/ui 2.11.6 → 2.11.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.11.6",
3
+ "version": "2.11.7",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -109,7 +109,7 @@
109
109
  "@sanity/color": "^3.0.6",
110
110
  "@sanity/icons": "^3.5.7",
111
111
  "csstype": "^3.1.3",
112
- "framer-motion": "^11.18.2",
112
+ "framer-motion": "^12.0.6",
113
113
  "react-compiler-runtime": "19.0.0-beta-27714ef-20250124",
114
114
  "react-refractor": "^2.2.0",
115
115
  "use-effect-event": "^1.0.2"
@@ -122,28 +122,28 @@
122
122
  "@commitlint/cli": "^19.6.1",
123
123
  "@commitlint/config-conventional": "^19.6.0",
124
124
  "@juggle/resize-observer": "^3.4.0",
125
- "@sanity/pkg-utils": "^6.13.1",
125
+ "@sanity/pkg-utils": "^6.13.4",
126
126
  "@sanity/prettier-config": "^1.0.3",
127
127
  "@sanity/semantic-release-preset": "^5.0.0",
128
128
  "@sanity/ui-workshop": "^2.0.25",
129
- "@storybook/addon-a11y": "^8.4.7",
130
- "@storybook/addon-docs": "^8.4.7",
131
- "@storybook/addon-essentials": "^8.4.7",
132
- "@storybook/addon-interactions": "^8.4.7",
133
- "@storybook/addon-links": "^8.4.7",
134
- "@storybook/addon-mdx-gfm": "^8.4.7",
135
- "@storybook/addon-storysource": "^8.4.7",
136
- "@storybook/addon-themes": "^8.4.7",
137
- "@storybook/blocks": "^8.4.7",
138
- "@storybook/manager-api": "^8.4.7",
139
- "@storybook/react": "^8.4.7",
140
- "@storybook/react-vite": "^8.4.7",
141
- "@storybook/test": "^8.4.7",
142
- "@storybook/theming": "^8.4.7",
129
+ "@storybook/addon-a11y": "^8.5.2",
130
+ "@storybook/addon-docs": "^8.5.2",
131
+ "@storybook/addon-essentials": "^8.5.2",
132
+ "@storybook/addon-interactions": "^8.5.2",
133
+ "@storybook/addon-links": "^8.5.2",
134
+ "@storybook/addon-mdx-gfm": "^8.5.2",
135
+ "@storybook/addon-storysource": "^8.5.2",
136
+ "@storybook/addon-themes": "^8.5.2",
137
+ "@storybook/blocks": "^8.5.2",
138
+ "@storybook/manager-api": "^8.5.2",
139
+ "@storybook/react": "^8.5.2",
140
+ "@storybook/react-vite": "^8.5.2",
141
+ "@storybook/test": "^8.5.2",
142
+ "@storybook/theming": "^8.5.2",
143
143
  "@testing-library/dom": "^10.4.0",
144
144
  "@testing-library/jest-dom": "^6.6.3",
145
- "@testing-library/react": "^16.1.0",
146
- "@testing-library/user-event": "^14.5.2",
145
+ "@testing-library/react": "^16.2.0",
146
+ "@testing-library/user-event": "^14.6.1",
147
147
  "@types/jest": "^29.5.14",
148
148
  "@types/jest-axe": "^3.5.9",
149
149
  "@types/node": "^20.12.7",
@@ -185,7 +185,7 @@
185
185
  "rimraf": "^5.0.5",
186
186
  "semantic-release": "^24.2.1",
187
187
  "start-server-and-test": "^2.0.10",
188
- "storybook": "^8.4.7",
188
+ "storybook": "^8.5.2",
189
189
  "styled-components": "^6.1.14",
190
190
  "tsconfig-paths": "^4.2.0",
191
191
  "typescript": "5.7.3",
@@ -28,6 +28,7 @@ import {origin} from '../../middleware/origin'
28
28
  import {useTheme_v2} from '../../theme'
29
29
  import {BoxOverflow, CardTone, Placement, PopoverMargins} from '../../types'
30
30
  import {LayerProps, LayerProvider, Portal, useBoundaryElement} from '../../utils'
31
+ import {getElementRef} from '../../utils/getElementRef'
31
32
  import {ResponsiveRadiusProps, ResponsiveShadowProps} from '../types'
32
33
  import {
33
34
  DEFAULT_POPOVER_DISTANCE,
@@ -443,29 +444,3 @@ export const Popover = memo(
443
444
  }),
444
445
  )
445
446
  Popover.displayName = 'Memo(ForwardRef(Popover))'
446
-
447
- // Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`
448
- // After React 19 accessing `element.ref` does the opposite.
449
- // https://github.com/facebook/react/pull/28348
450
- //
451
- // Access the ref using the method that doesn't yield a warning.
452
- function getElementRef(element: React.JSX.Element) {
453
- // React <=18 in DEV
454
- let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get
455
- let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning
456
-
457
- if (mayWarn) {
458
- return (element as any).ref
459
- }
460
-
461
- // React 19 in DEV
462
- getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get
463
- mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning
464
-
465
- if (mayWarn) {
466
- return element.props.ref
467
- }
468
-
469
- // Not DEV
470
- return element.props.ref || (element as any).ref
471
- }
@@ -30,6 +30,7 @@ import {origin} from '../../middleware/origin'
30
30
  import {useTheme_v2} from '../../theme'
31
31
  import type {Placement} from '../../types'
32
32
  import {Layer, type LayerProps, Portal, useBoundaryElement, usePortal} from '../../utils'
33
+ import {getElementRef} from '../../utils/getElementRef'
33
34
  import type {Delay} from '../types'
34
35
  import {
35
36
  DEFAULT_FALLBACK_PLACEMENTS,
@@ -320,11 +321,6 @@ export const Tooltip = forwardRef(function Tooltip(
320
321
  [refs],
321
322
  )
322
323
 
323
- const childRef = useRef<HTMLElement | null>(null)
324
-
325
- // Merge refs so that any ref we are overriding is called as well
326
- useImperativeHandle((childProp as any)?.ref, () => childRef.current)
327
-
328
324
  const child = useMemo(() => {
329
325
  if (!childProp) return null
330
326
 
@@ -335,7 +331,7 @@ export const Tooltip = forwardRef(function Tooltip(
335
331
  onMouseLeave: handleMouseLeave,
336
332
  onClick: handleClick,
337
333
  onContextMenu: handleContextMenu,
338
- ref: childRef,
334
+ ref: setReferenceElement,
339
335
  })
340
336
  }, [
341
337
  childProp,
@@ -349,13 +345,9 @@ export const Tooltip = forwardRef(function Tooltip(
349
345
 
350
346
  // If there's a child then we need to set the reference element to the cloned child ref
351
347
  // and if child changes we make sure to update or remove the reference element.
352
- useEffect(() => {
353
- if (!child) return undefined
354
-
355
- setReferenceElement(childRef.current)
356
-
357
- return () => setReferenceElement(null)
358
- }, [child])
348
+ useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [
349
+ referenceElement,
350
+ ])
359
351
 
360
352
  if (!child) return <></>
361
353
 
@@ -0,0 +1,26 @@
1
+ // Based on https://github.com/radix-ui/primitives/blob/0bade6a704e5821b90a6da0f3d8cfa8a7711127d/packages/react/slot/src/Slot.tsx#L128-L150
2
+ // Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`
3
+ // After React 19 accessing `element.ref` does the opposite.
4
+ // https://github.com/facebook/react/pull/28348
5
+ //
6
+ // Access the ref using the method that doesn't yield a warning.
7
+ export function getElementRef(element: React.ReactElement) {
8
+ // React <=18 in DEV
9
+ let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get
10
+ let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning
11
+
12
+ if (mayWarn) {
13
+ return (element as any).ref
14
+ }
15
+
16
+ // React 19 in DEV
17
+ getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get
18
+ mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning
19
+
20
+ if (mayWarn) {
21
+ return (element.props as {ref?: React.Ref<unknown>}).ref
22
+ }
23
+
24
+ // Not DEV
25
+ return (element.props as {ref?: React.Ref<unknown>}).ref || (element as any).ref
26
+ }