@sanity/ui 2.11.5 → 2.11.7-canary.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.11.5",
3
+ "version": "2.11.7-canary.0",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -51,32 +51,6 @@
51
51
  "src",
52
52
  "theme.js"
53
53
  ],
54
- "scripts": {
55
- "build": "run-s clean pkg:build pkg:check figma:pkg:build",
56
- "clean": "rimraf .workshop dist",
57
- "commit": "cz",
58
- "cypress:dev": "run-p dev cypress:open",
59
- "cypress:open": "cypress open",
60
- "cypress:run": "cypress run",
61
- "dev": "run-p storybook:dev workshop:dev",
62
- "figma:pkg:build": "cd figma && pnpm build",
63
- "format": "prettier --write --cache --ignore-unknown .",
64
- "lint": "eslint . --ext .cjs,.js,.jsx,.mjs,.ts,.tsx",
65
- "pkg:build": "pkg build --strict",
66
- "pkg:check": "pkg --strict",
67
- "prepare": "husky install",
68
- "prepack": "pnpm build",
69
- "release": "semantic-release",
70
- "storybook:build": "storybook build",
71
- "storybook:dev": "storybook dev -p 6006",
72
- "test": "jest",
73
- "test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
74
- "ts:check": "tsc",
75
- "watch": "pkg watch --strict",
76
- "workshop:build": "workshop build",
77
- "workshop:dev": "workshop dev",
78
- "workshop:start": "http-server -a localhost -c-0 -p 1337 -s -P http://localhost:1337/index.html? dist"
79
- },
80
54
  "commitlint": {
81
55
  "extends": [
82
56
  "@commitlint/config-conventional"
@@ -110,63 +84,63 @@
110
84
  "@sanity/icons": "^3.5.7",
111
85
  "csstype": "^3.1.3",
112
86
  "framer-motion": "^11.18.2",
113
- "react-compiler-runtime": "19.0.0-beta-decd7b8-20250118",
87
+ "react-compiler-runtime": "19.0.0-beta-27714ef-20250124",
114
88
  "react-refractor": "^2.2.0",
115
89
  "use-effect-event": "^1.0.2"
116
90
  },
117
91
  "devDependencies": {
118
- "@babel/core": "^7.26.0",
119
- "@babel/preset-env": "^7.26.0",
92
+ "@babel/core": "^7.26.7",
93
+ "@babel/preset-env": "^7.26.7",
120
94
  "@babel/preset-react": "^7.26.3",
121
95
  "@babel/preset-typescript": "^7.26.0",
122
96
  "@commitlint/cli": "^19.6.1",
123
97
  "@commitlint/config-conventional": "^19.6.0",
124
98
  "@juggle/resize-observer": "^3.4.0",
125
- "@sanity/pkg-utils": "^6.13.1",
99
+ "@sanity/pkg-utils": "^6.13.4",
126
100
  "@sanity/prettier-config": "^1.0.3",
127
101
  "@sanity/semantic-release-preset": "^5.0.0",
128
- "@sanity/ui-workshop": "^2.0.21",
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",
102
+ "@sanity/ui-workshop": "^2.0.25",
103
+ "@storybook/addon-a11y": "^8.5.2",
104
+ "@storybook/addon-docs": "^8.5.2",
105
+ "@storybook/addon-essentials": "^8.5.2",
106
+ "@storybook/addon-interactions": "^8.5.2",
107
+ "@storybook/addon-links": "^8.5.2",
108
+ "@storybook/addon-mdx-gfm": "^8.5.2",
109
+ "@storybook/addon-storysource": "^8.5.2",
110
+ "@storybook/addon-themes": "^8.5.2",
111
+ "@storybook/blocks": "^8.5.2",
112
+ "@storybook/manager-api": "^8.5.2",
113
+ "@storybook/react": "^8.5.2",
114
+ "@storybook/react-vite": "^8.5.2",
115
+ "@storybook/test": "^8.5.2",
116
+ "@storybook/theming": "^8.5.2",
143
117
  "@testing-library/dom": "^10.4.0",
144
118
  "@testing-library/jest-dom": "^6.6.3",
145
- "@testing-library/react": "^16.1.0",
146
- "@testing-library/user-event": "^14.5.2",
119
+ "@testing-library/react": "^16.2.0",
120
+ "@testing-library/user-event": "^14.6.1",
147
121
  "@types/jest": "^29.5.14",
148
122
  "@types/jest-axe": "^3.5.9",
149
123
  "@types/node": "^20.12.7",
150
- "@types/react": "^19.0.3",
151
- "@types/react-dom": "^19.0.2",
124
+ "@types/react": "^19.0.8",
125
+ "@types/react-dom": "^19.0.3",
152
126
  "@types/react-is": "^19.0.0",
153
127
  "@types/refractor": "^3.4.1",
154
128
  "@typescript-eslint/eslint-plugin": "^7.18.0",
155
129
  "@typescript-eslint/parser": "^7.18.0",
156
130
  "@vitejs/plugin-react": "^4.3.4",
157
- "babel-plugin-react-compiler": "19.0.0-beta-decd7b8-20250118",
131
+ "babel-plugin-react-compiler": "19.0.0-beta-27714ef-20250124",
158
132
  "babel-plugin-styled-components": "^2.1.4",
159
133
  "commitizen": "^4.3.1",
160
134
  "cypress": "^13.17.0",
161
- "cypress-real-events": "^1.13.0",
135
+ "cypress-real-events": "^1.14.0",
162
136
  "cz-conventional-changelog": "^3.3.0",
163
137
  "eslint": "^8.57.1",
164
- "eslint-config-prettier": "^9.1.0",
138
+ "eslint-config-prettier": "^10.0.1",
165
139
  "eslint-plugin-boundaries": "^5.0.1",
166
140
  "eslint-plugin-import": "^2.31.0",
167
141
  "eslint-plugin-jsx-a11y": "^6.10.2",
168
- "eslint-plugin-react": "^7.37.3",
169
- "eslint-plugin-react-compiler": "19.0.0-beta-decd7b8-20250118",
142
+ "eslint-plugin-react": "^7.37.4",
143
+ "eslint-plugin-react-compiler": "19.0.0-beta-27714ef-20250124",
170
144
  "eslint-plugin-react-hooks": "^5.1.0",
171
145
  "eslint-plugin-storybook": "^0.11.2",
172
146
  "http-server": "^14.1.1",
@@ -184,12 +158,12 @@
184
158
  "refractor": "^4.8.1",
185
159
  "rimraf": "^5.0.5",
186
160
  "semantic-release": "^24.2.1",
187
- "start-server-and-test": "^2.0.9",
188
- "storybook": "^8.4.7",
161
+ "start-server-and-test": "^2.0.10",
162
+ "storybook": "^8.5.2",
189
163
  "styled-components": "^6.1.14",
190
164
  "tsconfig-paths": "^4.2.0",
191
165
  "typescript": "5.7.3",
192
- "vite": "^5.4.11",
166
+ "vite": "^5.4.14",
193
167
  "vite-tsconfig-paths": "^5.1.4"
194
168
  },
195
169
  "peerDependencies": {
@@ -198,25 +172,37 @@
198
172
  "react-is": "^18 || >=19.0.0-0",
199
173
  "styled-components": "^5.2 || ^6"
200
174
  },
201
- "packageManager": "pnpm@9.15.3",
202
175
  "engines": {
203
176
  "node": ">=14.0.0"
204
177
  },
205
178
  "publishConfig": {
206
179
  "access": "public"
207
180
  },
208
- "pnpm": {
209
- "overrides": {
210
- "@types/react": "$@types/react",
211
- "@types/react-dom": "$@types/react-dom",
212
- "@types/react-is": "$@types/react-is",
213
- "conventional-changelog-conventionalcommits": ">= 8.0.0",
214
- "react": "$react",
215
- "react-dom": "$react-dom",
216
- "react-is": "$react-is"
217
- }
218
- },
219
181
  "esm.sh": {
220
182
  "bundle": false
183
+ },
184
+ "scripts": {
185
+ "build": "run-s clean pkg:build pkg:check figma:pkg:build",
186
+ "clean": "rimraf .workshop dist",
187
+ "commit": "cz",
188
+ "cypress:dev": "run-p dev cypress:open",
189
+ "cypress:open": "cypress open",
190
+ "cypress:run": "cypress run",
191
+ "dev": "run-p storybook:dev workshop:dev",
192
+ "figma:pkg:build": "cd figma && pnpm build",
193
+ "format": "prettier --write --cache --ignore-unknown .",
194
+ "lint": "eslint . --ext .cjs,.js,.jsx,.mjs,.ts,.tsx",
195
+ "pkg:build": "pkg build --strict",
196
+ "pkg:check": "pkg --strict",
197
+ "release": "semantic-release",
198
+ "storybook:build": "storybook build",
199
+ "storybook:dev": "storybook dev -p 6006",
200
+ "test": "jest",
201
+ "test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
202
+ "ts:check": "tsc",
203
+ "watch": "pkg watch --strict",
204
+ "workshop:build": "workshop build",
205
+ "workshop:dev": "workshop dev",
206
+ "workshop:start": "http-server -a localhost -c-0 -p 1337 -s -P http://localhost:1337/index.html? dist"
221
207
  }
222
- }
208
+ }
@@ -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
+ }
@@ -69,18 +69,12 @@ export const VirtualList = forwardRef(function VirtualList(
69
69
  }
70
70
  }, [renderItem])
71
71
 
72
- useEffect(() => {
72
+ useEffect((): (() => void) | undefined => {
73
73
  if (!ref.current) return
74
74
 
75
- let _scrollEl = ref.current.parentNode
76
-
77
- while (_scrollEl && !_isScrollable(_scrollEl)) {
78
- _scrollEl = _scrollEl.parentNode
79
- }
80
-
81
- if (_scrollEl) {
82
- const scrollEl = _scrollEl
75
+ const scrollEl = findScrollable(ref.current.parentNode)
83
76
 
77
+ if (scrollEl) {
84
78
  if (!(scrollEl instanceof HTMLElement)) return
85
79
 
86
80
  const handleScroll = () => {
@@ -167,3 +161,13 @@ export const VirtualList = forwardRef(function VirtualList(
167
161
  )
168
162
  })
169
163
  VirtualList.displayName = 'ForwardRef(VirtualList)'
164
+
165
+ function findScrollable(parentNode: ParentNode | null) {
166
+ let _scrollEl = parentNode
167
+
168
+ while (_scrollEl && !_isScrollable(_scrollEl)) {
169
+ _scrollEl = _scrollEl.parentNode
170
+ }
171
+
172
+ return _scrollEl
173
+ }