@sanity/ui 2.8.23 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.8.23",
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"
@@ -122,7 +96,7 @@
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.9",
99
+ "@sanity/pkg-utils": "^6.11.10",
126
100
  "@sanity/prettier-config": "^1.0.3",
127
101
  "@sanity/semantic-release-preset": "^5.0.0",
128
102
  "@sanity/ui-workshop": "^2.0.16",
@@ -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([_getArrayProp(val, defaultVal), hash])
28
+ setCache([current, hash])
29
+ result = current
27
30
  }
28
31
 
29
- return cachedVal
32
+ return result
30
33
  }
@@ -1,4 +1,4 @@
1
- import {useMemo, useRef, useSyncExternalStore} from 'react'
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 valueRef = useRef<ValueType>(value)
54
+ const [cachedValue, setCachedValue] = useState(value)
55
+ let result = cachedValue
55
56
 
56
- if (!_isEqual(valueRef.current, value)) {
57
- valueRef.current = value
57
+ if (!isEqual(cachedValue, value)) {
58
+ setCachedValue(value)
59
+ result = value
58
60
  }
59
61
 
60
- return valueRef.current
62
+ return result
61
63
  }
62
64
 
63
- function _isEqual(objA: Comparable, objB: Comparable): boolean {
65
+ function isEqual(objA: Comparable, objB: Comparable): boolean {
64
66
  if (!objA || !objB) {
65
67
  return objA === objB
66
68
  }