@sanity/ui 3.1.2 → 3.1.4
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 +3 -3
- 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.4",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"sanity",
|
|
6
6
|
"ui",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"@sanity/color": "^3.0.6",
|
|
120
120
|
"@sanity/icons": "^3.7.4",
|
|
121
121
|
"csstype": "^3.1.3",
|
|
122
|
-
"framer-motion": "^12.23.
|
|
122
|
+
"framer-motion": "^12.23.16",
|
|
123
123
|
"react-compiler-runtime": "19.1.0-rc.3",
|
|
124
124
|
"react-refractor": "^4.0.0",
|
|
125
125
|
"use-effect-event": "^2.0.3"
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"@commitlint/cli": "^19.8.1",
|
|
133
133
|
"@commitlint/config-conventional": "^19.8.1",
|
|
134
134
|
"@eslint/js": "^9.35.0",
|
|
135
|
-
"@sanity/pkg-utils": "^8.1.
|
|
135
|
+
"@sanity/pkg-utils": "^8.1.13",
|
|
136
136
|
"@sanity/prettier-config": "^2.0.1",
|
|
137
137
|
"@sanity/semantic-release-preset": "^5.0.0",
|
|
138
138
|
"@sanity/ui-workshop": "^3.3.2",
|
|
@@ -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
|