@sanity/ui 3.1.0 → 3.1.1-canary.1
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 +185 -175
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +186 -176
- package/dist/index.mjs.map +1 -1
- package/package.json +27 -41
- package/src/core/components/autocomplete/autocomplete.tsx +11 -1
- package/src/core/components/tree/treeItem.tsx +12 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1-canary.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"sanity",
|
|
6
6
|
"ui",
|
|
@@ -60,32 +60,6 @@
|
|
|
60
60
|
"exports",
|
|
61
61
|
"src"
|
|
62
62
|
],
|
|
63
|
-
"scripts": {
|
|
64
|
-
"build": "run-s clean pkg:build pkg:check figma:pkg:build",
|
|
65
|
-
"clean": "rimraf .workshop dist",
|
|
66
|
-
"commit": "cz",
|
|
67
|
-
"cypress:dev": "run-p dev cypress:open",
|
|
68
|
-
"cypress:open": "cypress open",
|
|
69
|
-
"cypress:run": "cypress run",
|
|
70
|
-
"dev": "run-p storybook:dev workshop:dev",
|
|
71
|
-
"figma:pkg:build": "cd figma && pnpm build",
|
|
72
|
-
"format": "prettier --write --cache --ignore-unknown .",
|
|
73
|
-
"lint": "eslint .",
|
|
74
|
-
"prepack": "pnpm build",
|
|
75
|
-
"pkg:build": "pkg build --strict",
|
|
76
|
-
"pkg:check": "pkg --strict",
|
|
77
|
-
"prepare": "husky install",
|
|
78
|
-
"release": "semantic-release",
|
|
79
|
-
"storybook:build": "storybook build",
|
|
80
|
-
"storybook:dev": "storybook dev -p 6006",
|
|
81
|
-
"test": "jest",
|
|
82
|
-
"test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
|
|
83
|
-
"ts:check": "tsc",
|
|
84
|
-
"watch": "pkg watch --strict",
|
|
85
|
-
"workshop:build": "workshop build",
|
|
86
|
-
"workshop:dev": "workshop dev",
|
|
87
|
-
"workshop:start": "http-server -a localhost -c-0 -p 1337 -s -P http://localhost:1337/index.html? dist"
|
|
88
|
-
},
|
|
89
63
|
"commitlint": {
|
|
90
64
|
"extends": [
|
|
91
65
|
"@commitlint/config-conventional"
|
|
@@ -132,7 +106,7 @@
|
|
|
132
106
|
"@commitlint/cli": "^19.8.1",
|
|
133
107
|
"@commitlint/config-conventional": "^19.8.1",
|
|
134
108
|
"@eslint/js": "^9.34.0",
|
|
135
|
-
"@sanity/pkg-utils": "^8.1.
|
|
109
|
+
"@sanity/pkg-utils": "^8.1.12",
|
|
136
110
|
"@sanity/prettier-config": "^2.0.1",
|
|
137
111
|
"@sanity/semantic-release-preset": "^5.0.0",
|
|
138
112
|
"@sanity/ui-workshop": "^3.3.2",
|
|
@@ -210,25 +184,37 @@
|
|
|
210
184
|
"react-is": "^18 || >=19.0.0-0",
|
|
211
185
|
"styled-components": "^5.2 || ^6"
|
|
212
186
|
},
|
|
213
|
-
"packageManager": "pnpm@9.15.9",
|
|
214
187
|
"engines": {
|
|
215
188
|
"node": ">=20.19 <22 || >=22.12"
|
|
216
189
|
},
|
|
217
190
|
"publishConfig": {
|
|
218
191
|
"access": "public"
|
|
219
192
|
},
|
|
220
|
-
"pnpm": {
|
|
221
|
-
"overrides": {
|
|
222
|
-
"@types/react": "$@types/react",
|
|
223
|
-
"@types/react-dom": "$@types/react-dom",
|
|
224
|
-
"@types/react-is": "$@types/react-is",
|
|
225
|
-
"conventional-changelog-conventionalcommits": ">= 8.0.0",
|
|
226
|
-
"react": "$react",
|
|
227
|
-
"react-dom": "$react-dom",
|
|
228
|
-
"react-is": "$react-is"
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
193
|
"esm.sh": {
|
|
232
194
|
"bundle": false
|
|
195
|
+
},
|
|
196
|
+
"scripts": {
|
|
197
|
+
"build": "run-s clean pkg:build pkg:check figma:pkg:build",
|
|
198
|
+
"clean": "rimraf .workshop dist",
|
|
199
|
+
"commit": "cz",
|
|
200
|
+
"cypress:dev": "run-p dev cypress:open",
|
|
201
|
+
"cypress:open": "cypress open",
|
|
202
|
+
"cypress:run": "cypress run",
|
|
203
|
+
"dev": "run-p storybook:dev workshop:dev",
|
|
204
|
+
"figma:pkg:build": "cd figma && pnpm build",
|
|
205
|
+
"format": "prettier --write --cache --ignore-unknown .",
|
|
206
|
+
"lint": "eslint .",
|
|
207
|
+
"pkg:build": "pkg build --strict",
|
|
208
|
+
"pkg:check": "pkg --strict",
|
|
209
|
+
"release": "semantic-release",
|
|
210
|
+
"storybook:build": "storybook build",
|
|
211
|
+
"storybook:dev": "storybook dev -p 6006",
|
|
212
|
+
"test": "jest",
|
|
213
|
+
"test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
|
|
214
|
+
"ts:check": "tsc",
|
|
215
|
+
"watch": "pkg watch --strict",
|
|
216
|
+
"workshop:build": "workshop build",
|
|
217
|
+
"workshop:dev": "workshop dev",
|
|
218
|
+
"workshop:start": "http-server -a localhost -c-0 -p 1337 -s -P http://localhost:1337/index.html? dist"
|
|
233
219
|
}
|
|
234
|
-
}
|
|
220
|
+
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
MouseEvent,
|
|
11
11
|
ReactNode,
|
|
12
12
|
Ref,
|
|
13
|
+
startTransition,
|
|
13
14
|
useCallback,
|
|
14
15
|
useEffect,
|
|
15
16
|
useImperativeHandle,
|
|
@@ -191,7 +192,16 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
191
192
|
const inputElementRef = useRef<HTMLInputElement | null>(null)
|
|
192
193
|
const listBoxElementRef = useRef<HTMLDivElement | null>(null)
|
|
193
194
|
// Element refs that need to be accessed during render
|
|
194
|
-
const [inputElement,
|
|
195
|
+
const [inputElement, _setInputElement] = useState<HTMLInputElement | null>(null)
|
|
196
|
+
/**
|
|
197
|
+
* The startTransition wrapper here is to avoid an issue when on React 18 where this error can happen:
|
|
198
|
+
* >Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
|
|
199
|
+
* This doesn't happen on React 19 due to automatic batching of all state updates, the startTransition wrapper here gives a type of batching for 18 users in a way that still works with 19.
|
|
200
|
+
* NOTE: The startTransition wrapper is not needed in UI v4, since the baseline there is React 19.
|
|
201
|
+
*/
|
|
202
|
+
const setInputElement = useCallback((node: HTMLInputElement | null) => {
|
|
203
|
+
startTransition(() => _setInputElement(node))
|
|
204
|
+
}, [])
|
|
195
205
|
|
|
196
206
|
// Value refs
|
|
197
207
|
const listFocusedRef = useRef(false)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {ToggleArrowRightIcon} from '@sanity/icons'
|
|
2
2
|
import {ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
3
|
-
import {useCallback, useEffect, useId, useMemo, useRef, useState} from 'react'
|
|
3
|
+
import {startTransition, useCallback, useEffect, useId, useMemo, useRef, useState} from 'react'
|
|
4
4
|
import {styled} from 'styled-components'
|
|
5
5
|
|
|
6
6
|
import {Box, BoxProps, Flex, Text} from '../../primitives'
|
|
@@ -65,7 +65,17 @@ export function TreeItem(
|
|
|
65
65
|
weight,
|
|
66
66
|
...restProps
|
|
67
67
|
} = props
|
|
68
|
-
const [rootElement,
|
|
68
|
+
const [rootElement, _setRootElement] = useState<HTMLLIElement | null>(null)
|
|
69
|
+
/**
|
|
70
|
+
* The startTransition wrapper here is to avoid an issue when on React 18 where this error can happen:
|
|
71
|
+
* >Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
|
|
72
|
+
* This doesn't happen on React 19 due to automatic batching of all state updates, the startTransition wrapper here gives a type of batching for 18 users in a way that still works with 19.
|
|
73
|
+
* NOTE: The startTransition wrapper is not needed in UI v4, since the baseline there is React 19.
|
|
74
|
+
*/
|
|
75
|
+
const setRootElement = useCallback((node: HTMLLIElement | null) => {
|
|
76
|
+
startTransition(() => _setRootElement(node))
|
|
77
|
+
}, [])
|
|
78
|
+
|
|
69
79
|
const treeitemRef = useRef<HTMLDivElement | null>(null)
|
|
70
80
|
const tree = useTree()
|
|
71
81
|
const {path, registerItem, setExpanded, setFocusedElement} = tree
|