@sanity/ui 0.37.5 → 0.37.6
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/lib/dts/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/lib/dts/components/autocomplete/autocomplete.styles.d.ts.map +1 -1
- package/lib/dts/components/menu/useMenuController.d.ts.map +1 -1
- package/lib/dts/components/tab/tab.d.ts +1 -1
- package/lib/dts/components/tab/tab.d.ts.map +1 -1
- package/lib/dts/components/tree/tree.d.ts +1 -1
- package/lib/dts/components/tree/tree.d.ts.map +1 -1
- package/lib/dts/components/tree/treeGroup.d.ts +1 -1
- package/lib/dts/components/tree/treeGroup.d.ts.map +1 -1
- package/lib/dts/components/tree/treeItem.d.ts +1 -1
- package/lib/dts/components/tree/treeItem.d.ts.map +1 -1
- package/lib/dts/hooks/usePrefersDark.d.ts.map +1 -1
- package/lib/dts/primitives/textInput/textInput.d.ts.map +1 -1
- package/lib/dts/styles/input/textInputStyle.d.ts.map +1 -1
- package/lib/dts/utils/errorBoundary.d.ts.map +1 -1
- package/lib/sanity-ui.js +64 -37
- package/lib/sanity-ui.js.map +1 -1
- package/lib/sanity-ui.modern.js +76 -38
- package/lib/sanity-ui.modern.js.map +1 -1
- package/lib/sanity-ui.module.js +65 -38
- package/lib/sanity-ui.module.js.map +1 -1
- package/package.json +10 -10
- package/src/components/autocomplete/__workshop__/custom.tsx +10 -4
- package/src/components/autocomplete/__workshop__/example.tsx +38 -15
- package/src/components/autocomplete/__workshop__/fullscreen.tsx +31 -30
- package/src/components/autocomplete/autocomplete.styles.tsx +1 -0
- package/src/components/autocomplete/autocomplete.tsx +24 -3
- package/src/components/menu/useMenuController.ts +4 -8
- package/src/components/tab/tab.tsx +1 -1
- package/src/components/tree/__workshop__/basic.perf.ts +32 -0
- package/src/components/tree/__workshop__/basic.tsx +92 -56
- package/src/components/tree/__workshop__/index.ts +6 -1
- package/src/components/tree/tree.tsx +168 -144
- package/src/components/tree/treeGroup.tsx +3 -3
- package/src/components/tree/treeItem.tsx +4 -4
- package/src/hooks/usePrefersDark.ts +10 -4
- package/src/primitives/textInput/__workshop__/plain.tsx +49 -18
- package/src/primitives/textInput/textInput.tsx +23 -3
- package/src/styles/input/textInputStyle.ts +2 -0
- package/src/theme/{themeContext.ts → ThemeContext.ts} +0 -0
- package/src/utils/errorBoundary.tsx +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.6",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -29,24 +29,24 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@juggle/resize-observer": "^3.3.1",
|
|
32
|
-
"@popperjs/core": "^2.11.
|
|
32
|
+
"@popperjs/core": "^2.11.4",
|
|
33
33
|
"@reach/auto-id": "^0.16.0",
|
|
34
34
|
"@sanity/color": "^2.1.8",
|
|
35
|
-
"@sanity/icons": "^1.2.
|
|
36
|
-
"framer-motion": "6.2.
|
|
35
|
+
"@sanity/icons": "^1.2.6",
|
|
36
|
+
"framer-motion": "6.2.8",
|
|
37
37
|
"popper-max-size-modifier": "^0.2.0",
|
|
38
38
|
"react-is": "^17.0.2",
|
|
39
39
|
"react-popper": "^2.2.5",
|
|
40
|
-
"react-refractor": "^2.1.
|
|
40
|
+
"react-refractor": "^2.1.6"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@testing-library/dom": "^8.
|
|
44
|
-
"@testing-library/jest-dom": "^5.16.
|
|
45
|
-
"@testing-library/react": "^12.1.
|
|
43
|
+
"@testing-library/dom": "^8.12.0",
|
|
44
|
+
"@testing-library/jest-dom": "^5.16.3",
|
|
45
|
+
"@testing-library/react": "^12.1.3",
|
|
46
46
|
"@types/refractor": "^3.0.2",
|
|
47
47
|
"react": "^17.0.2",
|
|
48
48
|
"react-dom": "^17.0.2",
|
|
49
|
-
"styled-components": "^5.3.
|
|
49
|
+
"styled-components": "^5.3.5"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": "^16.9 || ^17",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "d537879301eb41b50e56045bf4d7772720bf58d3"
|
|
74
74
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {Autocomplete, Box, Button, Card, Code, Stack, Text} from '@sanity/ui'
|
|
2
2
|
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
3
3
|
import React, {useCallback, useState} from 'react'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
WORKSHOP_RADIUS_OPTIONS,
|
|
6
|
+
WORKSHOP_SPACE_OPTIONS,
|
|
7
|
+
WORKSHOP_TEXT_SIZE_OPTIONS,
|
|
8
|
+
} from '../../../__workshop__/constants'
|
|
5
9
|
import countries from '../__fixtures__/countries'
|
|
6
10
|
import {ExampleOption} from './types'
|
|
7
11
|
|
|
@@ -11,6 +15,7 @@ export default function CustomStory() {
|
|
|
11
15
|
const disabled = useBoolean('Disabled', false, 'Props')
|
|
12
16
|
const fontSize = Number(useSelect('Font size', WORKSHOP_TEXT_SIZE_OPTIONS, 2, 'Props'))
|
|
13
17
|
const openButton = useBoolean('Open button', true, 'Props')
|
|
18
|
+
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
14
19
|
const radius = Number(useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2, 'Props'))
|
|
15
20
|
const readOnly = useBoolean('Read only', false, 'Props')
|
|
16
21
|
const [value, setValue] = useState('')
|
|
@@ -23,13 +28,13 @@ export default function CustomStory() {
|
|
|
23
28
|
href="#"
|
|
24
29
|
key={option.value}
|
|
25
30
|
onClick={(event) => event.preventDefault()}
|
|
26
|
-
padding={
|
|
31
|
+
padding={padding}
|
|
27
32
|
radius={radius - 1}
|
|
28
33
|
>
|
|
29
|
-
<Text>{option.title}</Text>
|
|
34
|
+
<Text size={fontSize}>{option.title}</Text>
|
|
30
35
|
</Card>
|
|
31
36
|
),
|
|
32
|
-
[radius]
|
|
37
|
+
[fontSize, padding, radius]
|
|
33
38
|
)
|
|
34
39
|
|
|
35
40
|
const renderValue = useCallback((currentValue: string, option?: ExampleOption) => {
|
|
@@ -58,6 +63,7 @@ export default function CustomStory() {
|
|
|
58
63
|
onChange={setValue}
|
|
59
64
|
openButton={openButton}
|
|
60
65
|
options={options}
|
|
66
|
+
padding={padding}
|
|
61
67
|
placeholder="Search"
|
|
62
68
|
radius={radius}
|
|
63
69
|
readOnly={readOnly}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {Autocomplete, Box, Card, Container, Stack, Text} from '@sanity/ui'
|
|
2
2
|
import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
3
|
+
import {PerfTestProps, usePerfTest} from '@sanity/ui-workshop'
|
|
4
|
+
import {fireEvent} from '@testing-library/dom'
|
|
3
5
|
import React, {useCallback, useMemo, useState} from 'react'
|
|
4
6
|
import {
|
|
5
7
|
WORKSHOP_CARD_TONE_OPTIONS,
|
|
@@ -9,7 +11,25 @@ import {
|
|
|
9
11
|
} from '../../../__workshop__/constants'
|
|
10
12
|
import countries from '../__fixtures__/countries'
|
|
11
13
|
|
|
14
|
+
const typingPerfTest: PerfTestProps<HTMLInputElement> = {
|
|
15
|
+
name: 'typing',
|
|
16
|
+
title: 'Typing',
|
|
17
|
+
description: 'This test types one character at a time',
|
|
18
|
+
run({target}) {
|
|
19
|
+
const text = 'Hello, world & Hello, world & Hello, world'
|
|
20
|
+
const len = text.length
|
|
21
|
+
|
|
22
|
+
for (let i = 0; i < len; i += 1) {
|
|
23
|
+
const value = text.slice(0, i + 1)
|
|
24
|
+
|
|
25
|
+
fireEvent.change(target, {target: {value}})
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
12
30
|
export default function ExampleStory() {
|
|
31
|
+
const {ref, Wrapper} = usePerfTest(typingPerfTest)
|
|
32
|
+
|
|
13
33
|
const layoutTone = useSelect('Layout tone', WORKSHOP_CARD_TONE_OPTIONS, 'default', 'Layout')
|
|
14
34
|
const options = useMemo(() => countries.map((country) => ({value: country.code})), [])
|
|
15
35
|
const border = useBoolean('Border', true, 'Props')
|
|
@@ -32,21 +52,24 @@ export default function ExampleStory() {
|
|
|
32
52
|
<Text as="label" htmlFor="default" size={1} weight="semibold">
|
|
33
53
|
Country code
|
|
34
54
|
</Text>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
<Wrapper>
|
|
56
|
+
<Autocomplete
|
|
57
|
+
border={border}
|
|
58
|
+
customValidity={customValidity}
|
|
59
|
+
disabled={disabled}
|
|
60
|
+
fontSize={fontSize}
|
|
61
|
+
onChange={handleChange}
|
|
62
|
+
id="default"
|
|
63
|
+
openButton={openButton}
|
|
64
|
+
options={options}
|
|
65
|
+
padding={padding}
|
|
66
|
+
placeholder="Search"
|
|
67
|
+
radius={radius}
|
|
68
|
+
readOnly={readOnly}
|
|
69
|
+
ref={ref}
|
|
70
|
+
value={value}
|
|
71
|
+
/>
|
|
72
|
+
</Wrapper>
|
|
50
73
|
</Stack>
|
|
51
74
|
</Box>
|
|
52
75
|
</Container>
|
|
@@ -183,7 +183,7 @@ export default function Fullscreen() {
|
|
|
183
183
|
<Button
|
|
184
184
|
aria-label="Open search"
|
|
185
185
|
icon={SearchIcon}
|
|
186
|
-
mode="
|
|
186
|
+
mode="ghost"
|
|
187
187
|
onClick={handleOpen}
|
|
188
188
|
ref={openSearchButtonElementRef}
|
|
189
189
|
/>
|
|
@@ -191,35 +191,36 @@ export default function Fullscreen() {
|
|
|
191
191
|
</Card>
|
|
192
192
|
<Layer hidden={!open} style={{position: 'sticky', top: 0}}>
|
|
193
193
|
<Card padding={2} shadow={1}>
|
|
194
|
-
<
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
194
|
+
<Autocomplete
|
|
195
|
+
filterOption={filterOption}
|
|
196
|
+
icon={SearchIcon}
|
|
197
|
+
id="fullsceen-example"
|
|
198
|
+
listBox={{padding: 2}}
|
|
199
|
+
loading={loading}
|
|
200
|
+
onQueryChange={handleQueryChange}
|
|
201
|
+
onSelect={handleSelect}
|
|
202
|
+
options={options}
|
|
203
|
+
placeholder="Search"
|
|
204
|
+
radius={2}
|
|
205
|
+
ref={inputRef}
|
|
206
|
+
relatedElements={relatedElements}
|
|
207
|
+
renderOption={renderOption}
|
|
208
|
+
renderPopover={renderPopover}
|
|
209
|
+
renderValue={renderValue}
|
|
210
|
+
suffix={
|
|
211
|
+
<Box padding={1}>
|
|
212
|
+
<Button
|
|
213
|
+
aria-label="Close search"
|
|
214
|
+
icon={CloseIcon}
|
|
215
|
+
onClick={handleClose}
|
|
216
|
+
padding={2}
|
|
217
|
+
mode="bleed"
|
|
218
|
+
ref={setCloseSearchButtonElement}
|
|
219
|
+
/>
|
|
220
|
+
</Box>
|
|
221
|
+
}
|
|
222
|
+
value={value}
|
|
223
|
+
/>
|
|
223
224
|
</Card>
|
|
224
225
|
</Layer>
|
|
225
226
|
<Card flex={1} hidden={!open} ref={setPortalElement} style={{position: 'relative'}} />
|
|
@@ -134,6 +134,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
134
134
|
renderOption: renderOptionProp,
|
|
135
135
|
renderPopover,
|
|
136
136
|
renderValue = defaultRenderValue,
|
|
137
|
+
suffix,
|
|
137
138
|
value: valueProp,
|
|
138
139
|
...restProps
|
|
139
140
|
} = props
|
|
@@ -429,8 +430,28 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
429
430
|
return undefined
|
|
430
431
|
}, [disabled, handleClearButtonFocus, loading, value])
|
|
431
432
|
|
|
432
|
-
const openButtonBoxPadding = useMemo(
|
|
433
|
-
|
|
433
|
+
const openButtonBoxPadding = useMemo(
|
|
434
|
+
() =>
|
|
435
|
+
padding.map((v) => {
|
|
436
|
+
if (v === 0) return 0
|
|
437
|
+
if (v === 1) return 1
|
|
438
|
+
if (v === 2) return 1
|
|
439
|
+
|
|
440
|
+
return v - 2
|
|
441
|
+
}),
|
|
442
|
+
[padding]
|
|
443
|
+
)
|
|
444
|
+
const openButtonPadding = useMemo(
|
|
445
|
+
() =>
|
|
446
|
+
padding.map((v) => {
|
|
447
|
+
if (v === 0) return 0
|
|
448
|
+
if (v === 1) return 0
|
|
449
|
+
if (v === 2) return 1
|
|
450
|
+
|
|
451
|
+
return v - 1
|
|
452
|
+
}),
|
|
453
|
+
[padding]
|
|
454
|
+
)
|
|
434
455
|
const openButtonProps: AutocompleteOpenButtonProps = useMemo(
|
|
435
456
|
() => (typeof openButton === 'object' ? openButton : EMPTY_RECORD),
|
|
436
457
|
[openButton]
|
|
@@ -520,7 +541,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
520
541
|
ref={setRef}
|
|
521
542
|
role="combobox"
|
|
522
543
|
spellCheck={false}
|
|
523
|
-
suffix={openButtonNode}
|
|
544
|
+
suffix={suffix || openButtonNode}
|
|
524
545
|
value={inputValue}
|
|
525
546
|
/>
|
|
526
547
|
)
|
|
@@ -26,15 +26,11 @@ export function useMenuController(props: {
|
|
|
26
26
|
shouldFocus: 'first' | 'last' | null
|
|
27
27
|
}): MenuController {
|
|
28
28
|
const {onKeyDown, originElement, shouldFocus} = props
|
|
29
|
-
|
|
30
29
|
const elementsRef = useRef<HTMLElement[]>([])
|
|
31
|
-
|
|
32
30
|
const [rootElement, setRootElement] = useState<HTMLDivElement | null>(null)
|
|
33
31
|
const [activeIndex, _setActiveIndex] = useState(-1)
|
|
34
|
-
|
|
35
|
-
const activeElement = elementsRef.current[activeIndex] || null
|
|
36
32
|
const activeIndexRef = useRef(activeIndex)
|
|
37
|
-
|
|
33
|
+
const activeElement = elementsRef.current[activeIndex] || null
|
|
38
34
|
const mounted = Boolean(rootElement)
|
|
39
35
|
|
|
40
36
|
const setActiveIndex = useCallback((nextActiveIndex) => {
|
|
@@ -122,7 +118,7 @@ export function useMenuController(props: {
|
|
|
122
118
|
|
|
123
119
|
if (focusableLen === 0) return
|
|
124
120
|
|
|
125
|
-
const focusedElement = elementsRef.current[
|
|
121
|
+
const focusedElement = elementsRef.current[activeIndexRef.current]
|
|
126
122
|
|
|
127
123
|
let focusedIndex = focusableElements.indexOf(focusedElement)
|
|
128
124
|
|
|
@@ -145,7 +141,7 @@ export function useMenuController(props: {
|
|
|
145
141
|
|
|
146
142
|
if (focusableLen === 0) return
|
|
147
143
|
|
|
148
|
-
const focusedElement = elementsRef.current[
|
|
144
|
+
const focusedElement = elementsRef.current[activeIndexRef.current]
|
|
149
145
|
|
|
150
146
|
let focusedIndex = focusableElements.indexOf(focusedElement)
|
|
151
147
|
|
|
@@ -163,7 +159,7 @@ export function useMenuController(props: {
|
|
|
163
159
|
onKeyDown(event)
|
|
164
160
|
}
|
|
165
161
|
},
|
|
166
|
-
[
|
|
162
|
+
[onKeyDown, originElement, setActiveIndex]
|
|
167
163
|
)
|
|
168
164
|
|
|
169
165
|
const handleItemMouseEnter = useCallback(
|
|
@@ -26,7 +26,7 @@ export interface TabProps {
|
|
|
26
26
|
*/
|
|
27
27
|
export const Tab = forwardRef(function Tab(
|
|
28
28
|
props: TabProps &
|
|
29
|
-
Omit<React.HTMLProps<HTMLButtonElement>, 'aria-controls' | 'as' | 'id' | 'type'>,
|
|
29
|
+
Omit<React.HTMLProps<HTMLButtonElement>, 'aria-controls' | 'as' | 'id' | 'label' | 'type'>,
|
|
30
30
|
forwardedRef: React.ForwardedRef<HTMLButtonElement>
|
|
31
31
|
) {
|
|
32
32
|
const {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {PerfTestProps, PerfTestRunFn} from '@sanity/ui-workshop'
|
|
2
|
+
import {findByTestId, fireEvent} from '@testing-library/dom'
|
|
3
|
+
|
|
4
|
+
// // function delay(ms: number) {
|
|
5
|
+
// // return new Promise((resolve) => setTimeout(resolve, ms))
|
|
6
|
+
// // }
|
|
7
|
+
|
|
8
|
+
function test<ElementType = unknown>(
|
|
9
|
+
title: string,
|
|
10
|
+
run: PerfTestRunFn<ElementType>
|
|
11
|
+
): PerfTestProps<ElementType> {
|
|
12
|
+
return {name: title, run}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// export const toggleTreeGroupsTest = perfTest(
|
|
16
|
+
// 'Toggle tree groups',
|
|
17
|
+
// async ({target}: {target: HTMLDivElement}) => {
|
|
18
|
+
|
|
19
|
+
// }
|
|
20
|
+
// )
|
|
21
|
+
|
|
22
|
+
export const perfTests = [
|
|
23
|
+
test('Toggle tree groups', async ({target}: {target: HTMLDivElement}) => {
|
|
24
|
+
// await delay(50)
|
|
25
|
+
|
|
26
|
+
const apples = await findByTestId(target, 'apples')
|
|
27
|
+
const oranges = await findByTestId(target, 'oranges')
|
|
28
|
+
|
|
29
|
+
fireEvent.click(apples)
|
|
30
|
+
fireEvent.click(oranges)
|
|
31
|
+
}),
|
|
32
|
+
]
|
|
@@ -1,68 +1,104 @@
|
|
|
1
1
|
import {LinkIcon} from '@sanity/icons'
|
|
2
2
|
import {Box, Tree, TreeItem} from '@sanity/ui'
|
|
3
|
-
import
|
|
3
|
+
import {usePerfTest} from '@sanity/ui-workshop'
|
|
4
|
+
import React, {useCallback, useState} from 'react'
|
|
5
|
+
import {perfTests} from './basic.perf'
|
|
4
6
|
|
|
5
7
|
export default function BasicStory() {
|
|
8
|
+
const {ref, Wrapper} = usePerfTest(perfTests[0])
|
|
9
|
+
|
|
10
|
+
const [id, setId] = useState('')
|
|
11
|
+
|
|
12
|
+
const handleClick = useCallback((event: React.MouseEvent) => {
|
|
13
|
+
event.preventDefault()
|
|
14
|
+
|
|
15
|
+
const testid = event.currentTarget.getAttribute('data-testid')
|
|
16
|
+
|
|
17
|
+
if (testid) setId(testid)
|
|
18
|
+
}, [])
|
|
19
|
+
|
|
6
20
|
return (
|
|
7
21
|
<Box padding={[4, 5, 6]}>
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
<TreeItem text="
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<TreeItem text="
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<TreeItem text="Cereal grains">
|
|
48
|
-
<TreeItem text="Barley" />
|
|
49
|
-
<TreeItem text="Oats" />
|
|
50
|
-
<TreeItem text="Rice" />
|
|
22
|
+
<Wrapper>
|
|
23
|
+
<Tree ref={ref} space={1}>
|
|
24
|
+
<TreeItem onClick={handleClick} expanded text="Fruit">
|
|
25
|
+
<TreeItem
|
|
26
|
+
data-testid="oranges"
|
|
27
|
+
onClick={handleClick}
|
|
28
|
+
selected={id === 'oranges'}
|
|
29
|
+
text="Oranges"
|
|
30
|
+
/>
|
|
31
|
+
<TreeItem
|
|
32
|
+
data-testid="pineapples"
|
|
33
|
+
onClick={handleClick}
|
|
34
|
+
text="Pineapples"
|
|
35
|
+
selected={id === 'pineapples'}
|
|
36
|
+
/>
|
|
37
|
+
<TreeItem data-testid="apples" onClick={handleClick} text="Apples">
|
|
38
|
+
<TreeItem
|
|
39
|
+
data-testid="apples/macintosh"
|
|
40
|
+
onClick={handleClick}
|
|
41
|
+
href="/apples/macintosh"
|
|
42
|
+
icon={LinkIcon}
|
|
43
|
+
text="Macintosh"
|
|
44
|
+
/>
|
|
45
|
+
<TreeItem
|
|
46
|
+
data-testid="apples/granny-smith"
|
|
47
|
+
onClick={handleClick}
|
|
48
|
+
text="Granny Smith"
|
|
49
|
+
/>
|
|
50
|
+
<TreeItem data-testid="apples/fuji" onClick={handleClick} text="Fuji" />
|
|
51
|
+
</TreeItem>
|
|
52
|
+
<TreeItem onClick={handleClick} text="Bananas" />
|
|
53
|
+
<TreeItem onClick={handleClick} text="Pears">
|
|
54
|
+
<TreeItem onClick={handleClick} text="Anjou" />
|
|
55
|
+
<TreeItem onClick={handleClick} text="Bartlett" />
|
|
56
|
+
<TreeItem onClick={handleClick} text="Bosc" />
|
|
57
|
+
<TreeItem onClick={handleClick} text="Concorde" />
|
|
58
|
+
<TreeItem onClick={handleClick} text="Seckel" />
|
|
59
|
+
<TreeItem onClick={handleClick} text="Starkrimson" />
|
|
60
|
+
</TreeItem>
|
|
51
61
|
</TreeItem>
|
|
52
|
-
<TreeItem text="
|
|
53
|
-
<TreeItem text="
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
<TreeItem onClick={handleClick} text="Vegetables">
|
|
63
|
+
<TreeItem onClick={handleClick} text="Podded vegetables">
|
|
64
|
+
<TreeItem onClick={handleClick} text="Lentil" />
|
|
65
|
+
<TreeItem onClick={handleClick} text="Pea" />
|
|
66
|
+
<TreeItem onClick={handleClick} text="Peanut" />
|
|
67
|
+
</TreeItem>
|
|
68
|
+
<TreeItem onClick={handleClick} text="Bulb and stem vegetables">
|
|
69
|
+
<TreeItem onClick={handleClick} text="Asparagus" />
|
|
70
|
+
<TreeItem onClick={handleClick} text="Celery" />
|
|
71
|
+
<TreeItem onClick={handleClick} text="Leek" />
|
|
72
|
+
<TreeItem onClick={handleClick} text="Onion" />
|
|
73
|
+
</TreeItem>
|
|
74
|
+
<TreeItem onClick={handleClick} text="Root and tuberous vegetables">
|
|
75
|
+
<TreeItem onClick={handleClick} text="Carrot" />
|
|
76
|
+
<TreeItem onClick={handleClick} text="Ginger" />
|
|
77
|
+
<TreeItem onClick={handleClick} text="Parsnip" />
|
|
78
|
+
<TreeItem onClick={handleClick} text="Potato" />
|
|
79
|
+
</TreeItem>
|
|
57
80
|
</TreeItem>
|
|
58
|
-
<TreeItem text="
|
|
59
|
-
<TreeItem text="
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
81
|
+
<TreeItem onClick={handleClick} text="Grains">
|
|
82
|
+
<TreeItem onClick={handleClick} text="Cereal grains">
|
|
83
|
+
<TreeItem onClick={handleClick} text="Barley" />
|
|
84
|
+
<TreeItem onClick={handleClick} text="Oats" />
|
|
85
|
+
<TreeItem onClick={handleClick} text="Rice" />
|
|
86
|
+
</TreeItem>
|
|
87
|
+
<TreeItem onClick={handleClick} text="Pseudocereal grains">
|
|
88
|
+
<TreeItem onClick={handleClick} text="Amaranth" />
|
|
89
|
+
<TreeItem onClick={handleClick} text="Buckwheat" />
|
|
90
|
+
<TreeItem onClick={handleClick} text="Chia" />
|
|
91
|
+
<TreeItem onClick={handleClick} text="Quinoa" />
|
|
92
|
+
</TreeItem>
|
|
93
|
+
<TreeItem onClick={handleClick} text="Oilseeds">
|
|
94
|
+
<TreeItem onClick={handleClick} text="India mustard" />
|
|
95
|
+
<TreeItem onClick={handleClick} text="Safflower" />
|
|
96
|
+
<TreeItem onClick={handleClick} text="Flax seed" />
|
|
97
|
+
<TreeItem onClick={handleClick} text="Poppy seed" />
|
|
98
|
+
</TreeItem>
|
|
63
99
|
</TreeItem>
|
|
64
|
-
</
|
|
65
|
-
</
|
|
100
|
+
</Tree>
|
|
101
|
+
</Wrapper>
|
|
66
102
|
</Box>
|
|
67
103
|
)
|
|
68
104
|
}
|
|
@@ -2,5 +2,10 @@ import {defineScope} from '@sanity/ui-workshop'
|
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
4
|
export default defineScope('components/tree', 'Tree', [
|
|
5
|
-
{
|
|
5
|
+
{
|
|
6
|
+
name: 'basic',
|
|
7
|
+
title: 'Basic',
|
|
8
|
+
component: lazy(() => import('./basic')),
|
|
9
|
+
// options: {perfTests: () => import('./basic.perf')},
|
|
10
|
+
},
|
|
6
11
|
])
|