@sanity/ui 2.1.4-canary.0 → 2.1.5
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 +2 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -4
- package/dist/index.mjs.map +1 -1
- package/dist/theme.esm.js +72 -10
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +72 -10
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +72 -10
- package/dist/theme.mjs.map +1 -1
- package/package.json +45 -43
- package/src/core/components/dialog/dialog.tsx +2 -2
- package/src/core/components/toast/toastProvider.tsx +2 -4
- package/src/core/hooks/useDelayedState.ts +2 -2
- package/src/core/primitives/avatar/__workshop__/index.ts +10 -0
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +62 -0
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +69 -0
- package/src/core/theme/__workshop__/debug/story.tsx +256 -51
- package/src/theme/build/renderColorTheme.ts +1 -1
- package/src/theme/defaults/colorTokens.ts +70 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
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 --quiet",
|
|
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"
|
|
@@ -90,10 +116,10 @@
|
|
|
90
116
|
"@babel/preset-env": "^7.24.4",
|
|
91
117
|
"@babel/preset-react": "^7.24.1",
|
|
92
118
|
"@babel/preset-typescript": "^7.24.1",
|
|
93
|
-
"@commitlint/cli": "^19.
|
|
94
|
-
"@commitlint/config-conventional": "^19.
|
|
119
|
+
"@commitlint/cli": "^19.3.0",
|
|
120
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
95
121
|
"@juggle/resize-observer": "^3.4.0",
|
|
96
|
-
"@sanity/pkg-utils": "^6.
|
|
122
|
+
"@sanity/pkg-utils": "^6.8.10",
|
|
97
123
|
"@sanity/semantic-release-preset": "^4.1.7",
|
|
98
124
|
"@sanity/ui-workshop": "^2.0.12",
|
|
99
125
|
"@storybook/addon-a11y": "^8.0.8",
|
|
@@ -115,16 +141,16 @@
|
|
|
115
141
|
"@testing-library/react": "^14.3.1",
|
|
116
142
|
"@types/jest": "^29.5.12",
|
|
117
143
|
"@types/jest-axe": "^3.5.9",
|
|
118
|
-
"@types/node": "^20.
|
|
119
|
-
"@types/react": "^18.
|
|
120
|
-
"@types/react-dom": "^18.
|
|
121
|
-
"@types/react-is": "^18.
|
|
144
|
+
"@types/node": "^20.12.7",
|
|
145
|
+
"@types/react": "^18.3.1",
|
|
146
|
+
"@types/react-dom": "^18.3.0",
|
|
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.
|
|
125
|
-
"@typescript-eslint/parser": "^7.
|
|
150
|
+
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
151
|
+
"@typescript-eslint/parser": "^7.8.0",
|
|
126
152
|
"commitizen": "^4.3.0",
|
|
127
|
-
"cypress": "^13.
|
|
153
|
+
"cypress": "^13.8.1",
|
|
128
154
|
"cypress-real-events": "^1.12.0",
|
|
129
155
|
"cz-conventional-changelog": "^3.3.0",
|
|
130
156
|
"eslint": "^8.57.0",
|
|
@@ -134,7 +160,7 @@
|
|
|
134
160
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
135
161
|
"eslint-plugin-prettier": "^5.1.3",
|
|
136
162
|
"eslint-plugin-react": "^7.34.1",
|
|
137
|
-
"eslint-plugin-react-hooks": "^4.6.
|
|
163
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
138
164
|
"eslint-plugin-storybook": "^0.8.0",
|
|
139
165
|
"http-server": "^14.1.1",
|
|
140
166
|
"husky": "^8.0.3",
|
|
@@ -146,18 +172,18 @@
|
|
|
146
172
|
"npm-run-all2": "^5.0.2",
|
|
147
173
|
"prettier": "^3.2.5",
|
|
148
174
|
"prettier-plugin-packagejson": "^2.5.0",
|
|
149
|
-
"react": "^18.
|
|
150
|
-
"react-dom": "^18.
|
|
151
|
-
"react-is": "^18.
|
|
175
|
+
"react": "^18.3.1",
|
|
176
|
+
"react-dom": "^18.3.1",
|
|
177
|
+
"react-is": "^18.3.1",
|
|
152
178
|
"refractor": "^4.8.1",
|
|
153
|
-
"rimraf": "^5.0.
|
|
179
|
+
"rimraf": "^5.0.5",
|
|
154
180
|
"semantic-release": "^23.0.8",
|
|
155
181
|
"start-server-and-test": "^2.0.3",
|
|
156
182
|
"storybook": "^8.0.8",
|
|
157
183
|
"styled-components": "^6.1.8",
|
|
158
184
|
"tsconfig-paths": "^4.2.0",
|
|
159
185
|
"typescript": "5.4.5",
|
|
160
|
-
"vite": "^5.2.
|
|
186
|
+
"vite": "^5.2.11",
|
|
161
187
|
"vite-tsconfig-paths": "^4.3.2"
|
|
162
188
|
},
|
|
163
189
|
"peerDependencies": {
|
|
@@ -166,7 +192,7 @@
|
|
|
166
192
|
"react-is": "^18",
|
|
167
193
|
"styled-components": "^5.2 || ^6"
|
|
168
194
|
},
|
|
169
|
-
"packageManager": "pnpm@
|
|
195
|
+
"packageManager": "pnpm@9.0.6",
|
|
170
196
|
"engines": {
|
|
171
197
|
"node": ">=14.0.0"
|
|
172
198
|
},
|
|
@@ -175,29 +201,5 @@
|
|
|
175
201
|
},
|
|
176
202
|
"esm.sh": {
|
|
177
203
|
"bundle": false
|
|
178
|
-
},
|
|
179
|
-
"scripts": {
|
|
180
|
-
"build": "run-s clean pkg:build pkg:check figma:pkg:build",
|
|
181
|
-
"clean": "rimraf .workshop dist",
|
|
182
|
-
"commit": "cz",
|
|
183
|
-
"cypress:dev": "run-p dev cypress:open",
|
|
184
|
-
"cypress:open": "cypress open",
|
|
185
|
-
"cypress:run": "cypress run",
|
|
186
|
-
"dev": "run-p storybook:dev workshop:dev",
|
|
187
|
-
"figma:pkg:build": "cd figma && pnpm build",
|
|
188
|
-
"format": "prettier --write --cache --ignore-unknown .",
|
|
189
|
-
"lint": "eslint . --ext .cjs,.js,.jsx,.mjs,.ts,.tsx --quiet",
|
|
190
|
-
"pkg:build": "pkg build --strict",
|
|
191
|
-
"pkg:check": "pkg --strict",
|
|
192
|
-
"release": "semantic-release",
|
|
193
|
-
"storybook:build": "storybook build",
|
|
194
|
-
"storybook:dev": "storybook dev -p 6006",
|
|
195
|
-
"test": "jest",
|
|
196
|
-
"test:browser": "start-server-and-test 'run-s workshop:build workshop:start' http://localhost:1337 'run-s cypress:run'",
|
|
197
|
-
"ts:check": "tsc",
|
|
198
|
-
"watch": "pkg watch --strict",
|
|
199
|
-
"workshop:build": "workshop build",
|
|
200
|
-
"workshop:dev": "workshop dev",
|
|
201
|
-
"workshop:start": "http-server -a localhost -c-0 -p 1337 -s -P http://localhost:1337/index.html? dist"
|
|
202
204
|
}
|
|
203
|
-
}
|
|
205
|
+
}
|
|
@@ -369,7 +369,7 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
369
369
|
|
|
370
370
|
const labelId = `${id}_label`
|
|
371
371
|
|
|
372
|
-
const rootClickTimeoutRef = useRef<
|
|
372
|
+
const rootClickTimeoutRef = useRef<NodeJS.Timeout>()
|
|
373
373
|
|
|
374
374
|
// If the resulting active element (a.k.a. focused element) is not withing scope when clicking
|
|
375
375
|
// within the dialog, then we want to focus the previously interactive element in the dialog instead.
|
|
@@ -379,7 +379,7 @@ export const Dialog = forwardRef(function Dialog(
|
|
|
379
379
|
clearTimeout(rootClickTimeoutRef.current)
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
rootClickTimeoutRef.current =
|
|
382
|
+
rootClickTimeoutRef.current = setTimeout(() => {
|
|
383
383
|
const activeElement = document.activeElement
|
|
384
384
|
|
|
385
385
|
if (activeElement && !isTargetWithinScope(boundaryElement, portalElement, activeElement)) {
|
|
@@ -53,7 +53,7 @@ let toastId = 0
|
|
|
53
53
|
export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
54
54
|
const {children, padding = 4, paddingX, paddingY, zOffset} = props
|
|
55
55
|
const [state, _setState] = useState<ToastState>([])
|
|
56
|
-
const toastsRef = useRef<{[key: string]: {timeoutId:
|
|
56
|
+
const toastsRef = useRef<{[key: string]: {timeoutId: NodeJS.Timeout}}>({})
|
|
57
57
|
const mounted = useMounted()
|
|
58
58
|
const prefersReducedMotion = usePrefersReducedMotion()
|
|
59
59
|
const variants = useMemo<Variants>(
|
|
@@ -129,9 +129,7 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
129
129
|
delete toastsRef.current[id]
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
toastsRef.current[id] = {
|
|
133
|
-
timeoutId: (setTimeout as typeof window.setTimeout)(dismiss, duration),
|
|
134
|
-
}
|
|
132
|
+
toastsRef.current[id] = {timeoutId: setTimeout(dismiss, duration)}
|
|
135
133
|
|
|
136
134
|
return id
|
|
137
135
|
}
|
|
@@ -8,7 +8,7 @@ export function useDelayedState<S>(
|
|
|
8
8
|
initialState: S | (() => S),
|
|
9
9
|
): [S, (nextState: SetStateAction<S>, delay?: number) => void] {
|
|
10
10
|
const [state, setState] = useState(initialState)
|
|
11
|
-
const delayedAction = useRef<
|
|
11
|
+
const delayedAction = useRef<NodeJS.Timeout | undefined>()
|
|
12
12
|
|
|
13
13
|
const onStateChange = useCallback((nextState: SetStateAction<S>, delay?: number) => {
|
|
14
14
|
const action = () => {
|
|
@@ -22,7 +22,7 @@ export function useDelayedState<S>(
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (!delay) return action()
|
|
25
|
-
delayedAction.current =
|
|
25
|
+
delayedAction.current = setTimeout(action, delay)
|
|
26
26
|
}, [])
|
|
27
27
|
|
|
28
28
|
return [state, onStateChange]
|
|
@@ -15,5 +15,15 @@ export default defineScope({
|
|
|
15
15
|
title: 'Avatar stack',
|
|
16
16
|
component: lazy(() => import('./stack')),
|
|
17
17
|
},
|
|
18
|
+
{
|
|
19
|
+
name: 'within-button',
|
|
20
|
+
title: 'Within button',
|
|
21
|
+
component: lazy(() => import('./withinButton')),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'within-menu-item',
|
|
25
|
+
title: 'Within menu item',
|
|
26
|
+
component: lazy(() => import('./withinMenuItem')),
|
|
27
|
+
},
|
|
18
28
|
],
|
|
19
29
|
})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {useBoolean} from '@sanity/ui-workshop'
|
|
2
|
+
import {Box} from '../../box'
|
|
3
|
+
import {Button} from '../../button'
|
|
4
|
+
import {Container} from '../../container'
|
|
5
|
+
import {Flex} from '../../flex'
|
|
6
|
+
import {Stack} from '../../stack'
|
|
7
|
+
import {Text} from '../../text'
|
|
8
|
+
import {Avatar} from '../avatar'
|
|
9
|
+
import {AvatarStack} from '../avatarStack'
|
|
10
|
+
|
|
11
|
+
export default function WithinButtonStory() {
|
|
12
|
+
const disabled = useBoolean('Disabled', false, 'Props')
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<Container width={1}>
|
|
16
|
+
<Stack paddingX={4} paddingY={[5, 6, 7]} space={1}>
|
|
17
|
+
<Button disabled={disabled} padding={1}>
|
|
18
|
+
<Flex align="center" gap={3} padding={2}>
|
|
19
|
+
<Box flex={1}>
|
|
20
|
+
<Text size={1}>Default button</Text>
|
|
21
|
+
</Box>
|
|
22
|
+
<Box flex="none">
|
|
23
|
+
<AvatarStack>
|
|
24
|
+
<Avatar color="blue" initials="AB" />
|
|
25
|
+
<Avatar color="magenta" initials="CD" />
|
|
26
|
+
<Avatar color="purple" initials="EF" />
|
|
27
|
+
</AvatarStack>
|
|
28
|
+
</Box>
|
|
29
|
+
</Flex>
|
|
30
|
+
</Button>
|
|
31
|
+
<Button disabled={disabled} mode="ghost" padding={1}>
|
|
32
|
+
<Flex align="center" gap={3} padding={2}>
|
|
33
|
+
<Box flex={1}>
|
|
34
|
+
<Text size={1}>Ghost button</Text>
|
|
35
|
+
</Box>
|
|
36
|
+
<Box flex="none">
|
|
37
|
+
<AvatarStack>
|
|
38
|
+
<Avatar color="blue" initials="AB" />
|
|
39
|
+
<Avatar color="magenta" initials="CD" />
|
|
40
|
+
<Avatar color="purple" initials="EF" />
|
|
41
|
+
</AvatarStack>
|
|
42
|
+
</Box>
|
|
43
|
+
</Flex>
|
|
44
|
+
</Button>
|
|
45
|
+
<Button disabled={disabled} mode="bleed" padding={1}>
|
|
46
|
+
<Flex align="center" gap={3} padding={2}>
|
|
47
|
+
<Box flex={1}>
|
|
48
|
+
<Text size={1}>Bleed button</Text>
|
|
49
|
+
</Box>
|
|
50
|
+
<Box flex="none">
|
|
51
|
+
<AvatarStack>
|
|
52
|
+
<Avatar color="blue" initials="AB" />
|
|
53
|
+
<Avatar color="magenta" initials="CD" />
|
|
54
|
+
<Avatar color="purple" initials="EF" />
|
|
55
|
+
</AvatarStack>
|
|
56
|
+
</Box>
|
|
57
|
+
</Flex>
|
|
58
|
+
</Button>
|
|
59
|
+
</Stack>
|
|
60
|
+
</Container>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {useBoolean} from '@sanity/ui-workshop'
|
|
2
|
+
import {Menu, MenuItem} from '../../../components'
|
|
3
|
+
import {Layer} from '../../../utils'
|
|
4
|
+
import {Box} from '../../box'
|
|
5
|
+
import {Card} from '../../card'
|
|
6
|
+
import {Container} from '../../container'
|
|
7
|
+
import {Flex} from '../../flex'
|
|
8
|
+
import {Text} from '../../text'
|
|
9
|
+
import {Avatar} from '../avatar'
|
|
10
|
+
import {AvatarStack} from '../avatarStack'
|
|
11
|
+
|
|
12
|
+
export default function WithinMenuItemStory() {
|
|
13
|
+
const disabled = useBoolean('Disabled', false, 'Props')
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Container width={1}>
|
|
17
|
+
<Layer>
|
|
18
|
+
<Box paddingX={4} paddingY={[5, 6, 7]}>
|
|
19
|
+
<Card radius={3} shadow={3}>
|
|
20
|
+
<Menu space={1}>
|
|
21
|
+
<MenuItem disabled={disabled} padding={0}>
|
|
22
|
+
<Flex align="center" gap={2} padding={2}>
|
|
23
|
+
<Box flex={1}>
|
|
24
|
+
<Text size={1}>Menu item 1</Text>
|
|
25
|
+
</Box>
|
|
26
|
+
<Box flex="none">
|
|
27
|
+
<AvatarStack>
|
|
28
|
+
<Avatar color="blue" initials="AB" />
|
|
29
|
+
<Avatar color="magenta" initials="CD" />
|
|
30
|
+
<Avatar color="purple" initials="EF" />
|
|
31
|
+
</AvatarStack>
|
|
32
|
+
</Box>
|
|
33
|
+
</Flex>
|
|
34
|
+
</MenuItem>
|
|
35
|
+
<MenuItem disabled={disabled} padding={0}>
|
|
36
|
+
<Flex align="center" gap={2} padding={2}>
|
|
37
|
+
<Box flex={1}>
|
|
38
|
+
<Text size={1}>Menu item 1</Text>
|
|
39
|
+
</Box>
|
|
40
|
+
<Box flex="none">
|
|
41
|
+
<AvatarStack>
|
|
42
|
+
<Avatar color="blue" initials="AB" />
|
|
43
|
+
<Avatar color="magenta" initials="CD" />
|
|
44
|
+
<Avatar color="purple" initials="EF" />
|
|
45
|
+
</AvatarStack>
|
|
46
|
+
</Box>
|
|
47
|
+
</Flex>
|
|
48
|
+
</MenuItem>
|
|
49
|
+
<MenuItem disabled={disabled} padding={0}>
|
|
50
|
+
<Flex align="center" gap={2} padding={2}>
|
|
51
|
+
<Box flex={1}>
|
|
52
|
+
<Text size={1}>Menu item 1</Text>
|
|
53
|
+
</Box>
|
|
54
|
+
<Box flex="none">
|
|
55
|
+
<AvatarStack>
|
|
56
|
+
<Avatar color="blue" initials="AB" />
|
|
57
|
+
<Avatar color="magenta" initials="CD" />
|
|
58
|
+
<Avatar color="purple" initials="EF" />
|
|
59
|
+
</AvatarStack>
|
|
60
|
+
</Box>
|
|
61
|
+
</Flex>
|
|
62
|
+
</MenuItem>
|
|
63
|
+
</Menu>
|
|
64
|
+
</Card>
|
|
65
|
+
</Box>
|
|
66
|
+
</Layer>
|
|
67
|
+
</Container>
|
|
68
|
+
)
|
|
69
|
+
}
|