@sanity/ui 2.3.3 → 2.3.4

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.3.3",
3
+ "version": "2.3.4",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -184,7 +184,7 @@
184
184
  "styled-components": "^6.1.11",
185
185
  "tsconfig-paths": "^4.2.0",
186
186
  "typescript": "5.4.5",
187
- "vite": "^5.2.12",
187
+ "vite": "^5.2.13",
188
188
  "vite-tsconfig-paths": "^4.3.2"
189
189
  },
190
190
  "peerDependencies": {
@@ -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
  )