@sanity/ui 2.3.4-canary.0 → 2.3.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 +21 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +20 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +33 -25
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +1 -7
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +38 -0
- package/src/core/components/menu/__workshop__/index.ts +5 -0
- package/src/core/components/menu/menuButton.tsx +1 -1
- package/src/core/components/tree/tree.tsx +1 -1
- package/src/core/primitives/avatar/avatarStack.tsx +5 -4
- package/src/core/primitives/inline/inline.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.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",
|
|
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"
|
|
@@ -167,6 +193,7 @@
|
|
|
167
193
|
"react-is": "^18",
|
|
168
194
|
"styled-components": "^5.2 || ^6"
|
|
169
195
|
},
|
|
196
|
+
"packageManager": "pnpm@9.2.0",
|
|
170
197
|
"engines": {
|
|
171
198
|
"node": ">=14.0.0"
|
|
172
199
|
},
|
|
@@ -176,28 +203,9 @@
|
|
|
176
203
|
"esm.sh": {
|
|
177
204
|
"bundle": false
|
|
178
205
|
},
|
|
179
|
-
"
|
|
180
|
-
"
|
|
181
|
-
|
|
182
|
-
|
|
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",
|
|
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"
|
|
206
|
+
"pnpm": {
|
|
207
|
+
"overrides": {
|
|
208
|
+
"conventional-changelog-conventionalcommits": ">= 8.0.0"
|
|
209
|
+
}
|
|
202
210
|
}
|
|
203
|
-
}
|
|
211
|
+
}
|
|
@@ -30,13 +30,7 @@ export const Breadcrumbs = forwardRef(function Breadcrumbs(
|
|
|
30
30
|
|
|
31
31
|
useClickOutside(collapse, [expandElement, popoverElement])
|
|
32
32
|
|
|
33
|
-
const rawItems = useMemo(
|
|
34
|
-
() =>
|
|
35
|
-
Children.toArray(children).filter((child) => {
|
|
36
|
-
return isValidElement(child)
|
|
37
|
-
}),
|
|
38
|
-
[children],
|
|
39
|
-
)
|
|
33
|
+
const rawItems = useMemo(() => Children.toArray(children).filter(isValidElement), [children])
|
|
40
34
|
|
|
41
35
|
const items = useMemo(() => {
|
|
42
36
|
const len = rawItems.length
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {ChevronDownIcon} from '@sanity/icons'
|
|
2
|
+
import {useSelect} from '@sanity/ui-workshop'
|
|
3
|
+
import {Box, Button} from '../../../primitives'
|
|
4
|
+
import {Menu} from '../menu'
|
|
5
|
+
import {MenuButton} from '../menuButton'
|
|
6
|
+
import {MenuItem} from '../menuItem'
|
|
7
|
+
|
|
8
|
+
const selectedOptions = {
|
|
9
|
+
undefined: 'undefined',
|
|
10
|
+
true: true,
|
|
11
|
+
false: false,
|
|
12
|
+
} as const
|
|
13
|
+
|
|
14
|
+
export default function CustomSelectedStateStory() {
|
|
15
|
+
const selected = useSelect('Selected', selectedOptions, false)
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Box padding={4}>
|
|
19
|
+
<MenuButton
|
|
20
|
+
button={
|
|
21
|
+
<Button
|
|
22
|
+
icon={ChevronDownIcon}
|
|
23
|
+
mode="bleed"
|
|
24
|
+
selected={selected === 'undefined' ? undefined : selected}
|
|
25
|
+
text="Menu"
|
|
26
|
+
/>
|
|
27
|
+
}
|
|
28
|
+
id="test-menu"
|
|
29
|
+
menu={
|
|
30
|
+
<Menu>
|
|
31
|
+
<MenuItem text="Item 1" />
|
|
32
|
+
<MenuItem text="Item 2" />
|
|
33
|
+
</Menu>
|
|
34
|
+
}
|
|
35
|
+
/>
|
|
36
|
+
</Box>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -80,5 +80,10 @@ export default defineScope({
|
|
|
80
80
|
title: 'Avatar menu',
|
|
81
81
|
component: lazy(() => import('./avatarMenu')),
|
|
82
82
|
},
|
|
83
|
+
{
|
|
84
|
+
name: 'custom-selected-state',
|
|
85
|
+
title: 'Custom selected state',
|
|
86
|
+
component: lazy(() => import('./customSelectedState')),
|
|
87
|
+
},
|
|
83
88
|
],
|
|
84
89
|
})
|
|
@@ -241,7 +241,7 @@ export const MenuButton = forwardRef(function MenuButton(
|
|
|
241
241
|
'aria-haspopup': true,
|
|
242
242
|
'aria-expanded': open,
|
|
243
243
|
ref: ref,
|
|
244
|
-
selected: open,
|
|
244
|
+
selected: buttonProp.props.selected ?? open,
|
|
245
245
|
}),
|
|
246
246
|
[buttonProp, handleButtonClick, handleButtonKeyDown, handleMouseDown, id, open],
|
|
247
247
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {getTheme_v2} from '@sanity/ui/theme'
|
|
2
|
-
import {Children, cloneElement, forwardRef} from 'react'
|
|
2
|
+
import {Children, cloneElement, forwardRef, isValidElement, useMemo} from 'react'
|
|
3
3
|
import {styled, css} from 'styled-components'
|
|
4
4
|
import {EMPTY_RECORD} from '../../constants'
|
|
5
5
|
import {useArrayProp} from '../../hooks'
|
|
@@ -65,9 +65,10 @@ export const AvatarStack = forwardRef(function AvatarStack(
|
|
|
65
65
|
size: sizeProp = 1,
|
|
66
66
|
...restProps
|
|
67
67
|
} = props
|
|
68
|
-
const children =
|
|
69
|
-
(
|
|
70
|
-
|
|
68
|
+
const children = useMemo<React.ReactElement[]>(
|
|
69
|
+
() => Children.toArray(childrenProp).filter(isValidElement),
|
|
70
|
+
[childrenProp],
|
|
71
|
+
)
|
|
71
72
|
const maxLength = Math.max(maxLengthProp, 0)
|
|
72
73
|
const size = useArrayProp(sizeProp)
|
|
73
74
|
|
|
@@ -27,7 +27,7 @@ export const Inline = forwardRef(function Inline(
|
|
|
27
27
|
const {as, children: childrenProp, space, ...restProps} = props
|
|
28
28
|
|
|
29
29
|
const children = useMemo(
|
|
30
|
-
() => Children.map(childrenProp, (child) => <div>{child}</div>),
|
|
30
|
+
() => Children.map(childrenProp, (child) => child && <div>{child}</div>),
|
|
31
31
|
[childrenProp],
|
|
32
32
|
)
|
|
33
33
|
|