@sanity/ui 2.1.15-canary.6 → 2.3.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.1.15-canary.6",
3
+ "version": "2.3.0",
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
+ "prepublishOnly": "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"
@@ -93,9 +119,9 @@
93
119
  "@commitlint/cli": "^19.3.0",
94
120
  "@commitlint/config-conventional": "^19.2.2",
95
121
  "@juggle/resize-observer": "^3.4.0",
96
- "@sanity/pkg-utils": "6.8.20-canary.0",
97
- "@sanity/semantic-release-preset": "^4.1.7",
98
- "@sanity/ui-workshop": "^2.0.13",
122
+ "@sanity/pkg-utils": "^6.8.19",
123
+ "@sanity/semantic-release-preset": "^4.1.8",
124
+ "@sanity/ui-workshop": "^2.0.15",
99
125
  "@storybook/addon-a11y": "^8.0.8",
100
126
  "@storybook/addon-docs": "^8.0.8",
101
127
  "@storybook/addon-essentials": "^8.0.8",
@@ -112,7 +138,7 @@
112
138
  "@storybook/theming": "^8.0.8",
113
139
  "@testing-library/dom": "^10.1.0",
114
140
  "@testing-library/jest-dom": "^5.17.0",
115
- "@testing-library/react": "^15.0.7",
141
+ "@testing-library/react": "^16.0.0",
116
142
  "@types/jest": "^29.5.12",
117
143
  "@types/jest-axe": "^3.5.9",
118
144
  "@types/node": "^20.12.7",
@@ -121,9 +147,8 @@
121
147
  "@types/react-is": "^18.3.0",
122
148
  "@types/refractor": "^3.4.1",
123
149
  "@types/testing-library__jest-dom": "^5.14.9",
124
- "@typescript-eslint/eslint-plugin": "^7.11.0",
125
- "@typescript-eslint/parser": "^7.11.0",
126
- "babel-plugin-react-compiler": "0.0.0-experimental-938cd9a-20240601",
150
+ "@typescript-eslint/eslint-plugin": "^7.12.0",
151
+ "@typescript-eslint/parser": "^7.12.0",
127
152
  "commitizen": "^4.3.0",
128
153
  "cypress": "^13.10.0",
129
154
  "cypress-real-events": "^1.12.0",
@@ -146,14 +171,14 @@
146
171
  "lint-staged": "^14.0.1",
147
172
  "module-alias": "^2.2.3",
148
173
  "npm-run-all2": "^5.0.2",
149
- "prettier": "^3.2.5",
174
+ "prettier": "^3.3.0",
150
175
  "prettier-plugin-packagejson": "^2.5.0",
151
- "react": "19.0.0-rc-6d3110b4d9-20240531",
152
- "react-dom": "19.0.0-rc-6d3110b4d9-20240531",
153
- "react-is": "19.0.0-rc-6d3110b4d9-20240531",
176
+ "react": "^18.3.1",
177
+ "react-dom": "^18.3.1",
178
+ "react-is": "^18.3.1",
154
179
  "refractor": "^4.8.1",
155
180
  "rimraf": "^5.0.5",
156
- "semantic-release": "^23.1.1",
181
+ "semantic-release": "^24.0.0",
157
182
  "start-server-and-test": "^2.0.3",
158
183
  "storybook": "^8.0.8",
159
184
  "styled-components": "^6.1.11",
@@ -163,11 +188,12 @@
163
188
  "vite-tsconfig-paths": "^4.3.2"
164
189
  },
165
190
  "peerDependencies": {
166
- "react": ">=19.0.0-rc",
167
- "react-dom": ">=19.0.0-rc",
168
- "react-is": ">=19.0.0-rc",
169
- "styled-components": "^6.1"
191
+ "react": "^18",
192
+ "react-dom": "^18",
193
+ "react-is": "^18",
194
+ "styled-components": "^5.2 || ^6"
170
195
  },
196
+ "packageManager": "pnpm@9.1.3",
171
197
  "engines": {
172
198
  "node": ">=14.0.0"
173
199
  },
@@ -177,28 +203,9 @@
177
203
  "esm.sh": {
178
204
  "bundle": false
179
205
  },
180
- "scripts": {
181
- "build": "run-s clean pkg:build pkg:check figma:pkg:build",
182
- "clean": "rimraf .workshop dist",
183
- "commit": "cz",
184
- "cypress:dev": "run-p dev cypress:open",
185
- "cypress:open": "cypress open",
186
- "cypress:run": "cypress run",
187
- "dev": "run-p storybook:dev workshop:dev",
188
- "figma:pkg:build": "cd figma && pnpm build",
189
- "format": "prettier --write --cache --ignore-unknown .",
190
- "lint": "eslint . --ext .cjs,.js,.jsx,.mjs,.ts,.tsx",
191
- "pkg:build": "pkg build --strict",
192
- "pkg:check": "pkg --strict",
193
- "release": "semantic-release",
194
- "storybook:build": "storybook build",
195
- "storybook:dev": "storybook dev -p 6006",
196
- "test": "jest",
197
- "test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
198
- "ts:check": "tsc",
199
- "watch": "pkg watch --strict",
200
- "workshop:build": "workshop build",
201
- "workshop:dev": "workshop dev",
202
- "workshop:start": "http-server -a localhost -c-0 -p 1337 -s -P http://localhost:1337/index.html? dist"
206
+ "pnpm": {
207
+ "overrides": {
208
+ "conventional-changelog-conventionalcommits": ">= 8.0.0"
209
+ }
203
210
  }
204
- }
211
+ }
@@ -12,5 +12,14 @@ export function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
12
12
  val: T | T[] | undefined,
13
13
  defaultVal?: T[],
14
14
  ): T[] {
15
- return useMemo(() => _getArrayProp(val, defaultVal), [defaultVal, val])
15
+ // JSON.stringify is fast, but it's not faster than useMemo's referencial equality check
16
+ const __perf_hash__ = useMemo(() => JSON.stringify(val ?? defaultVal), [defaultVal, val])
17
+
18
+ return useMemo(
19
+ () => _getArrayProp(val, defaultVal),
20
+
21
+ // Improve performance: Keep object identify for a given hash of the value
22
+ // eslint-disable-next-line react-hooks/exhaustive-deps
23
+ [__perf_hash__],
24
+ )
16
25
  }
@@ -12,6 +12,7 @@ export default function PropsStory() {
12
12
  const as = useSelect('As', WORKSHOP_CARD_AS_OPTIONS, 'div', 'Props')
13
13
  const border = useBoolean('Border', false, 'Props')
14
14
  const checkered = useBoolean('Checkered', false, 'Props')
15
+ const muted = useBoolean('Muted', false, 'Props')
15
16
  const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 0, 'Props')
16
17
  const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 0, 'Props')
17
18
  const selected = useBoolean('Selected', false, 'Props')
@@ -24,6 +25,7 @@ export default function PropsStory() {
24
25
  __unstable_checkered={checkered}
25
26
  as={as}
26
27
  border={border}
28
+ muted={muted}
27
29
  onClick={useAction('onClick')}
28
30
  padding={padding}
29
31
  radius={radius}
@@ -36,6 +36,7 @@ export interface CardProps
36
36
  * @beta
37
37
  */
38
38
  __unstable_focusRing?: boolean
39
+ muted?: boolean
39
40
  pressed?: boolean
40
41
  scheme?: ThemeColorSchemeKey
41
42
  tone?: CardTone
@@ -67,6 +68,7 @@ export const Card = forwardRef(function Card(
67
68
  borderRight,
68
69
  borderBottom,
69
70
  borderLeft,
71
+ muted,
70
72
  pressed,
71
73
  radius = 0,
72
74
  scheme,
@@ -96,6 +98,7 @@ export const Card = forwardRef(function Card(
96
98
  $borderLeft={useArrayProp(borderLeft)}
97
99
  $checkered={checkered}
98
100
  $focusRing={focusRing}
101
+ $muted={muted}
99
102
  $radius={useArrayProp(radius)}
100
103
  $shadow={useArrayProp(shadow)}
101
104
  $tone={tone}
@@ -49,7 +49,7 @@ export function cardBaseStyle(props: CardStyleProps & ThemeProps): ReturnType<ty
49
49
  }
50
50
 
51
51
  export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<typeof css> {
52
- const {$checkered, $focusRing} = props
52
+ const {$checkered, $focusRing, $muted} = props
53
53
  const {card, color, style} = getTheme_v2(props.theme)
54
54
  const border = {width: card.border.width, color: 'var(--card-border-color)'}
55
55
 
@@ -58,7 +58,7 @@ export function cardColorStyle(props: CardStyleProps & ThemeProps): ReturnType<t
58
58
 
59
59
  ${_cardColorStyle(color, color, $checkered)}
60
60
 
61
- background-color: var(--card-bg-color);
61
+ background-color: ${$muted ? 'var(--card-muted-bg-color)' : 'var(--card-bg-color)'};
62
62
  color: var(--card-fg-color);
63
63
 
64
64
  /* &:is(button) */
@@ -6,5 +6,6 @@ import {ThemeColorToneKey} from '@sanity/ui/theme'
6
6
  export interface CardStyleProps {
7
7
  $checkered: boolean
8
8
  $focusRing: boolean
9
+ $muted: boolean
9
10
  $tone: ThemeColorToneKey
10
11
  }