@sanity/ui 2.8.22 → 2.8.24-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/dist/index.esm.js +266 -256
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +266 -256
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +266 -256
- package/dist/index.mjs.map +1 -1
- package/package.json +31 -39
- package/src/core/hooks/useArrayProp.ts +5 -2
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +2 -2
- package/src/core/theme/__workshop__/debug/story.tsx +8 -11
- package/src/core/utils/portal/portalProvider.tsx +8 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.24-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,7 +84,7 @@
|
|
|
110
84
|
"@sanity/icons": "^3.4.0",
|
|
111
85
|
"csstype": "^3.1.3",
|
|
112
86
|
"framer-motion": "11.0.8",
|
|
113
|
-
"react-compiler-runtime": "19.0.0-beta-
|
|
87
|
+
"react-compiler-runtime": "19.0.0-beta-a7bf2bd-20241110",
|
|
114
88
|
"react-refractor": "^2.2.0",
|
|
115
89
|
"use-effect-event": "^1.0.2"
|
|
116
90
|
},
|
|
@@ -122,8 +96,8 @@
|
|
|
122
96
|
"@commitlint/cli": "^19.4.0",
|
|
123
97
|
"@commitlint/config-conventional": "^19.2.2",
|
|
124
98
|
"@juggle/resize-observer": "^3.4.0",
|
|
125
|
-
"@sanity/pkg-utils": "^6.11.
|
|
126
|
-
"@sanity/prettier-config": "^1.0.
|
|
99
|
+
"@sanity/pkg-utils": "^6.11.10",
|
|
100
|
+
"@sanity/prettier-config": "^1.0.3",
|
|
127
101
|
"@sanity/semantic-release-preset": "^5.0.0",
|
|
128
102
|
"@sanity/ui-workshop": "^2.0.16",
|
|
129
103
|
"@storybook/addon-a11y": "^8.4.2",
|
|
@@ -154,7 +128,7 @@
|
|
|
154
128
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
155
129
|
"@typescript-eslint/parser": "^7.18.0",
|
|
156
130
|
"@vitejs/plugin-react": "^4.3.3",
|
|
157
|
-
"babel-plugin-react-compiler": "19.0.0-beta-
|
|
131
|
+
"babel-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
|
|
158
132
|
"commitizen": "^4.3.0",
|
|
159
133
|
"cypress": "^13.13.2",
|
|
160
134
|
"cypress-real-events": "^1.13.0",
|
|
@@ -166,7 +140,7 @@
|
|
|
166
140
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
167
141
|
"eslint-plugin-prettier": "^5.2.1",
|
|
168
142
|
"eslint-plugin-react": "^7.37.2",
|
|
169
|
-
"eslint-plugin-react-compiler": "19.0.0-beta-
|
|
143
|
+
"eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
|
|
170
144
|
"eslint-plugin-react-hooks": "^5.0.0",
|
|
171
145
|
"eslint-plugin-storybook": "^0.11.0",
|
|
172
146
|
"http-server": "^14.1.1",
|
|
@@ -198,19 +172,37 @@
|
|
|
198
172
|
"react-is": "^18 || >=19.0.0-0",
|
|
199
173
|
"styled-components": "^5.2 || ^6"
|
|
200
174
|
},
|
|
201
|
-
"packageManager": "pnpm@9.12.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
|
-
"conventional-changelog-conventionalcommits": ">= 8.0.0"
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
181
|
"esm.sh": {
|
|
214
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"
|
|
215
207
|
}
|
|
216
|
-
}
|
|
208
|
+
}
|
|
@@ -16,15 +16,18 @@ export function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
|
|
|
16
16
|
_getArrayProp(val, defaultVal),
|
|
17
17
|
JSON.stringify(val ?? defaultVal),
|
|
18
18
|
])
|
|
19
|
+
let result = cachedVal
|
|
19
20
|
|
|
20
21
|
const hash = JSON.stringify(val ?? defaultVal)
|
|
21
22
|
|
|
22
23
|
if (hash !== cachedHash) {
|
|
24
|
+
const current = _getArrayProp(val, defaultVal)
|
|
23
25
|
// If the cached hash has changed, update the cache right away.
|
|
24
26
|
// Calling setState during render is fine in this case, and preferred over a useEffect loop
|
|
25
27
|
// https://19.react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
|
|
26
|
-
setCache([
|
|
28
|
+
setCache([current, hash])
|
|
29
|
+
result = current
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
return
|
|
32
|
+
return result
|
|
30
33
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {Box, Card, Code, Container, Stack, Text, useElementRect} from '@sanity/ui'
|
|
2
|
-
import {
|
|
2
|
+
import {useState} from 'react'
|
|
3
3
|
import {Grid} from '../../../primitives'
|
|
4
4
|
|
|
5
5
|
export default function ExampleStory() {
|
|
6
6
|
const [element, setElement] = useState<HTMLElement | null>(null)
|
|
7
7
|
const rect = useElementRect(element)
|
|
8
|
-
const size =
|
|
8
|
+
const size = {width: rect?.width || 0, height: rect?.height || 0}
|
|
9
9
|
|
|
10
10
|
return (
|
|
11
11
|
<Box padding={[3, 4, 5]}>
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
ThemeColorState_v2,
|
|
13
13
|
} from '@sanity/ui/theme'
|
|
14
14
|
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
15
|
-
import {CSSProperties
|
|
15
|
+
import {CSSProperties} from 'react'
|
|
16
16
|
import {Badge, Box, Flex, KBD, Stack, Text} from '../../../primitives'
|
|
17
17
|
import {useRootTheme} from '../../useRootTheme'
|
|
18
18
|
|
|
@@ -50,16 +50,13 @@ export default function DebugStory() {
|
|
|
50
50
|
const button = useBoolean('Button', false, 'Props') || false
|
|
51
51
|
const selectable = useBoolean('Selectable', false, 'Props') || false
|
|
52
52
|
|
|
53
|
-
const features: Features =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}),
|
|
61
|
-
[base, button, scheme, selectable, tone],
|
|
62
|
-
)
|
|
53
|
+
const features: Features = {
|
|
54
|
+
base,
|
|
55
|
+
button,
|
|
56
|
+
schemes: scheme == 'all' ? ['light', 'dark'] : [scheme],
|
|
57
|
+
selectable,
|
|
58
|
+
tones: tone == 'all' ? ['transparent', 'default'] : [tone],
|
|
59
|
+
}
|
|
63
60
|
|
|
64
61
|
return (
|
|
65
62
|
<Flex>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useMemo,
|
|
1
|
+
import {useMemo, useState, useSyncExternalStore} from 'react'
|
|
2
2
|
import {PortalContext} from './portalContext'
|
|
3
3
|
import {PortalContextValue} from './types'
|
|
4
4
|
|
|
@@ -51,16 +51,18 @@ const emptySubscribe = () => () => {}
|
|
|
51
51
|
* equality comparison (eg by identity), and only goes one level deep.
|
|
52
52
|
*/
|
|
53
53
|
function useUnique<ValueType extends Comparable = Comparable>(value: ValueType): ValueType {
|
|
54
|
-
const
|
|
54
|
+
const [cachedValue, setCachedValue] = useState(value)
|
|
55
|
+
let result = cachedValue
|
|
55
56
|
|
|
56
|
-
if (!
|
|
57
|
-
|
|
57
|
+
if (!isEqual(cachedValue, value)) {
|
|
58
|
+
setCachedValue(value)
|
|
59
|
+
result = value
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
return
|
|
62
|
+
return result
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
function
|
|
65
|
+
function isEqual(objA: Comparable, objB: Comparable): boolean {
|
|
64
66
|
if (!objA || !objB) {
|
|
65
67
|
return objA === objB
|
|
66
68
|
}
|