@sanity/ui 2.8.24-canary.1 → 2.8.24

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.24-canary.1",
3
+ "version": "2.8.24",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -51,6 +51,32 @@
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
+ },
54
80
  "commitlint": {
55
81
  "extends": [
56
82
  "@commitlint/config-conventional"
@@ -84,7 +110,7 @@
84
110
  "@sanity/icons": "^3.4.0",
85
111
  "csstype": "^3.1.3",
86
112
  "framer-motion": "11.0.8",
87
- "react-compiler-runtime": "19.0.0-beta-a7bf2bd-20241110",
113
+ "react-compiler-runtime": "19.0.0-beta-0dec889-20241115",
88
114
  "react-refractor": "^2.2.0",
89
115
  "use-effect-event": "^1.0.2"
90
116
  },
@@ -96,7 +122,7 @@
96
122
  "@commitlint/cli": "^19.4.0",
97
123
  "@commitlint/config-conventional": "^19.2.2",
98
124
  "@juggle/resize-observer": "^3.4.0",
99
- "@sanity/pkg-utils": "^6.11.10",
125
+ "@sanity/pkg-utils": "^6.11.11",
100
126
  "@sanity/prettier-config": "^1.0.3",
101
127
  "@sanity/semantic-release-preset": "^5.0.0",
102
128
  "@sanity/ui-workshop": "^2.0.16",
@@ -128,7 +154,7 @@
128
154
  "@typescript-eslint/eslint-plugin": "^7.18.0",
129
155
  "@typescript-eslint/parser": "^7.18.0",
130
156
  "@vitejs/plugin-react": "^4.3.3",
131
- "babel-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
157
+ "babel-plugin-react-compiler": "19.0.0-beta-0dec889-20241115",
132
158
  "commitizen": "^4.3.0",
133
159
  "cypress": "^13.13.2",
134
160
  "cypress-real-events": "^1.13.0",
@@ -140,7 +166,7 @@
140
166
  "eslint-plugin-jsx-a11y": "^6.10.2",
141
167
  "eslint-plugin-prettier": "^5.2.1",
142
168
  "eslint-plugin-react": "^7.37.2",
143
- "eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
169
+ "eslint-plugin-react-compiler": "19.0.0-beta-0dec889-20241115",
144
170
  "eslint-plugin-react-hooks": "^5.0.0",
145
171
  "eslint-plugin-storybook": "^0.11.0",
146
172
  "http-server": "^14.1.1",
@@ -163,7 +189,7 @@
163
189
  "styled-components": "^6.1.13",
164
190
  "tsconfig-paths": "^4.2.0",
165
191
  "typescript": "5.6.3",
166
- "vite": "^5.4.10",
192
+ "vite": "^5.4.11",
167
193
  "vite-tsconfig-paths": "^5.0.1"
168
194
  },
169
195
  "peerDependencies": {
@@ -172,37 +198,19 @@
172
198
  "react-is": "^18 || >=19.0.0-0",
173
199
  "styled-components": "^5.2 || ^6"
174
200
  },
201
+ "packageManager": "pnpm@9.12.3",
175
202
  "engines": {
176
203
  "node": ">=14.0.0"
177
204
  },
178
205
  "publishConfig": {
179
206
  "access": "public"
180
207
  },
208
+ "pnpm": {
209
+ "overrides": {
210
+ "conventional-changelog-conventionalcommits": ">= 8.0.0"
211
+ }
212
+ },
181
213
  "esm.sh": {
182
214
  "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"
207
215
  }
208
- }
216
+ }
@@ -10,23 +10,21 @@ export type ArrayPropPrimitive = string | number | boolean | undefined | null
10
10
  */
11
11
  export function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
12
12
  val: T | T[] | undefined,
13
+ defaultVal?: T[],
13
14
  ): T[] {
14
15
  const [[cachedVal, cachedHash], setCache] = useState<[T[], string]>(() => [
15
- _getArrayProp(val),
16
- JSON.stringify(val),
16
+ _getArrayProp(val, defaultVal),
17
+ JSON.stringify(val ?? defaultVal),
17
18
  ])
18
- let result = cachedVal
19
19
 
20
- const hash = JSON.stringify(val)
20
+ const hash = JSON.stringify(val ?? defaultVal)
21
21
 
22
22
  if (hash !== cachedHash) {
23
- const current = _getArrayProp(val)
24
23
  // If the cached hash has changed, update the cache right away.
25
24
  // Calling setState during render is fine in this case, and preferred over a useEffect loop
26
25
  // https://19.react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
27
- setCache([current, hash])
28
- result = current
26
+ setCache([_getArrayProp(val, defaultVal), hash])
29
27
  }
30
28
 
31
- return result
29
+ return cachedVal
32
30
  }
@@ -42,8 +42,8 @@ export function _responsive<T>(
42
42
  /**
43
43
  * @internal
44
44
  */
45
- export function _getArrayProp<T = number>(val: T | T[] | undefined): T[] {
46
- if (val === undefined) return EMPTY_ARRAY
45
+ export function _getArrayProp<T = number>(val: T | T[] | undefined, defaultVal?: T[]): T[] {
46
+ if (val === undefined) return defaultVal || EMPTY_ARRAY
47
47
 
48
48
  return Array.isArray(val) ? val : [val]
49
49
  }
@@ -1,4 +1,4 @@
1
- import {useMemo, useState, useSyncExternalStore} from 'react'
1
+ import {useMemo, useRef, useSyncExternalStore} from 'react'
2
2
  import {PortalContext} from './portalContext'
3
3
  import {PortalContextValue} from './types'
4
4
 
@@ -22,8 +22,8 @@ export interface PortalProviderProps {
22
22
  * @public
23
23
  */
24
24
  export function PortalProvider(props: PortalProviderProps): React.ReactElement {
25
- const {boundaryElement, children, element} = props
26
- const elements = useUnique(props.__unstable_elements)
25
+ const {boundaryElement, children, element, __unstable_elements: elementsProp} = props
26
+ const elements = useUnique(elementsProp)
27
27
  const fallbackElement = useSyncExternalStore(
28
28
  emptySubscribe,
29
29
  () => document.body,
@@ -51,18 +51,16 @@ 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 [cachedValue, setCachedValue] = useState(value)
55
- let result = cachedValue
54
+ const valueRef = useRef<ValueType>(value)
56
55
 
57
- if (!isEqual(cachedValue, value)) {
58
- setCachedValue(value)
59
- result = value
56
+ if (!_isEqual(valueRef.current, value)) {
57
+ valueRef.current = value
60
58
  }
61
59
 
62
- return result
60
+ return valueRef.current
63
61
  }
64
62
 
65
- function isEqual(objA: Comparable, objB: Comparable): boolean {
63
+ function _isEqual(objA: Comparable, objB: Comparable): boolean {
66
64
  if (!objA || !objB) {
67
65
  return objA === objB
68
66
  }