@sanity/ui 1.0.0-next.3 → 1.0.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/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/{types/src/index.d.ts → index.d.ts} +4450 -4398
- package/dist/{sanity-ui.esm.js → index.esm.js} +888 -2678
- package/dist/index.esm.js.map +1 -0
- package/dist/{sanity-ui.js → index.js} +882 -2688
- package/dist/index.js.map +1 -0
- package/package.json +112 -23
- package/src/components/autocomplete/__workshop__/example.tsx +1 -1
- package/src/components/autocomplete/__workshop__/index.ts +36 -32
- package/src/components/autocomplete/autocomplete.styles.tsx +22 -28
- package/src/components/autocomplete/autocomplete.tsx +1 -2
- package/src/components/autocomplete/constants.ts +3 -8
- package/src/components/breadcrumbs/__workshop__/index.ts +11 -7
- package/src/components/breadcrumbs/breadcrumbs.styles.ts +13 -18
- package/src/components/dialog/__workshop__/index.ts +13 -9
- package/src/components/dialog/dialog.tsx +53 -67
- package/src/components/hotkeys/__workshop__/index.ts +11 -3
- package/src/components/hotkeys/hotkeys.tsx +12 -16
- package/src/components/menu/__workshop__/index.ts +71 -67
- package/src/components/menu/menu.tsx +5 -7
- package/src/components/menu/menuButton.tsx +16 -14
- package/src/components/menu/menuDivider.ts +8 -10
- package/src/components/skeleton/__workshop__/index.ts +8 -4
- package/src/components/skeleton/skeleton.tsx +4 -6
- package/src/components/skeleton/styles.ts +13 -9
- package/src/components/skeleton/textSkeleton.tsx +12 -14
- package/src/components/tab/__workshop__/index.ts +11 -3
- package/src/components/toast/__workshop__/index.ts +16 -4
- package/src/components/toast/toast.tsx +6 -11
- package/src/components/toast/toastProvider.tsx +18 -22
- package/src/components/tree/__workshop__/basic.perf.ts +1 -14
- package/src/components/tree/__workshop__/basic.tsx +1 -1
- package/src/components/tree/__workshop__/index.ts +12 -8
- package/src/components/tree/style.ts +78 -76
- package/src/components/tree/treeItem.tsx +7 -12
- package/src/hooks/useElementRect/__workshop__/index.ts +11 -3
- package/src/hooks/useMediaIndex/__workshop__/index.ts +11 -3
- package/src/primitives/_selectable/selectable.tsx +4 -7
- package/src/primitives/_selectable/style.ts +85 -82
- package/src/primitives/avatar/__workshop__/index.ts +16 -12
- package/src/primitives/avatar/avatar.tsx +9 -12
- package/src/primitives/avatar/avatarCounter.tsx +22 -24
- package/src/primitives/avatar/avatarStack.tsx +16 -14
- package/src/primitives/avatar/styles.ts +1 -1
- package/src/primitives/badge/__workshop__/index.ts +16 -12
- package/src/primitives/badge/__workshop__/tones.tsx +1 -1
- package/src/primitives/badge/badge.tsx +6 -5
- package/src/primitives/box/__workshop__/index.ts +16 -4
- package/src/primitives/box/box.tsx +21 -49
- package/src/primitives/button/__workshop__/index.ts +51 -47
- package/src/primitives/button/__workshop__/sanityUploadButton.tsx +19 -20
- package/src/primitives/button/__workshop__/styled1.tsx +6 -6
- package/src/primitives/button/button.tsx +20 -26
- package/src/primitives/button/styles.ts +30 -29
- package/src/primitives/card/__workshop__/index.ts +15 -11
- package/src/primitives/card/card.tsx +9 -25
- package/src/primitives/card/styles.ts +119 -114
- package/src/primitives/checkbox/__workshop__/index.ts +10 -6
- package/src/primitives/checkbox/checkbox.tsx +4 -4
- package/src/primitives/checkbox/styles.ts +71 -69
- package/src/primitives/code/__workshop__/index.ts +16 -12
- package/src/primitives/code/code.tsx +3 -5
- package/src/primitives/code/styles.ts +20 -18
- package/src/primitives/container/__workshop__/index.ts +5 -3
- package/src/primitives/container/container.tsx +5 -4
- package/src/primitives/flex/__workshop__/index.ts +8 -4
- package/src/primitives/flex/flex.tsx +7 -23
- package/src/primitives/grid/__workshop__/index.ts +7 -3
- package/src/primitives/grid/grid.tsx +4 -27
- package/src/primitives/heading/__workshop__/index.ts +16 -12
- package/src/primitives/heading/heading.tsx +10 -17
- package/src/primitives/heading/styles.ts +45 -36
- package/src/primitives/inline/__workshop__/index.ts +5 -3
- package/src/primitives/inline/inline.tsx +3 -5
- package/src/primitives/kbd/__workshop__/index.ts +5 -3
- package/src/primitives/kbd/kbd.tsx +12 -13
- package/src/primitives/label/__workshop__/index.ts +16 -12
- package/src/primitives/label/label.tsx +13 -18
- package/src/primitives/label/styles.ts +24 -18
- package/src/primitives/popover/__workshop__/PlainStory.tsx +0 -1
- package/src/primitives/popover/__workshop__/TestStory.tsx +0 -1
- package/src/primitives/popover/__workshop__/index.ts +36 -32
- package/src/primitives/popover/constants.ts +0 -3
- package/src/primitives/popover/floating-ui/size.ts +40 -25
- package/src/primitives/popover/popover.tsx +220 -196
- package/src/primitives/popover/popoverArrow.tsx +42 -48
- package/src/primitives/popover/popoverCard.tsx +12 -22
- package/src/primitives/radio/__workshop__/index.ts +8 -4
- package/src/primitives/radio/radio.tsx +3 -3
- package/src/primitives/radio/styles.ts +73 -73
- package/src/primitives/select/__workshop__/index.ts +8 -4
- package/src/primitives/select/select.tsx +9 -11
- package/src/primitives/select/styles.ts +77 -77
- package/src/primitives/spinner/__workshop__/index.ts +11 -7
- package/src/primitives/spinner/spinner.tsx +2 -5
- package/src/primitives/stack/__workshop__/index.ts +11 -7
- package/src/primitives/stack/stack.tsx +3 -5
- package/src/primitives/switch/__workshop__/index.ts +8 -4
- package/src/primitives/switch/styles.ts +119 -112
- package/src/primitives/switch/switch.tsx +6 -6
- package/src/primitives/text/__workshop__/index.ts +21 -17
- package/src/primitives/text/styles.ts +51 -45
- package/src/primitives/text/text.tsx +11 -16
- package/src/primitives/textArea/__workshop__/index.ts +11 -7
- package/src/primitives/textArea/textArea.tsx +15 -22
- package/src/primitives/textInput/__workshop__/index.ts +46 -42
- package/src/primitives/textInput/__workshop__/plain.tsx +2 -1
- package/src/primitives/textInput/textInput.tsx +49 -69
- package/src/primitives/tooltip/__workshop__/index.ts +11 -7
- package/src/primitives/tooltip/tooltip.tsx +3 -6
- package/src/primitives/tooltip/tooltipArrow.tsx +69 -59
- package/src/styles/border/borderStyle.ts +10 -18
- package/src/styles/box/boxStyle.ts +14 -18
- package/src/styles/flex/flexItemStyle.ts +7 -1
- package/src/styles/flex/flexStyle.ts +14 -9
- package/src/styles/grid/gridItemStyle.ts +18 -30
- package/src/styles/grid/gridStyle.ts +25 -33
- package/src/styles/helpers.ts +2 -2
- package/src/styles/index.ts +0 -1
- package/src/styles/input/textInputStyle.ts +127 -123
- package/src/styles/margin/marginStyle.ts +11 -10
- package/src/styles/margin/marginsStyle.test.ts +12 -10
- package/src/styles/padding/paddingStyle.test.ts +12 -10
- package/src/styles/padding/paddingStyle.ts +9 -10
- package/src/theme/__workshop__/index.ts +26 -22
- package/src/theme/{ThemeContext.ts → themeContext.ts} +0 -0
- package/src/utils/boundaryElement/__workshop__/index.ts +11 -7
- package/src/utils/elementQuery/__workshop__/index.ts +11 -7
- package/src/utils/layer/__workshop__/index.ts +21 -17
- package/src/utils/layer/layer.tsx +4 -6
- package/src/utils/portal/__workshop__/index.ts +11 -7
- package/src/utils/srOnly/srOnly.tsx +8 -10
- package/src/utils/virtualList/__workshop__/index.ts +26 -22
- package/src/utils/virtualList/virtualList.tsx +10 -14
- package/dist/sanity-ui.esm.js.map +0 -1
- package/dist/sanity-ui.js.map +0 -1
- package/src/__workshop__/color/overview.tsx +0 -101
- package/src/__workshop__/index.ts +0 -10
- package/src/icons/__workshop__/.eslintrc +0 -5
- package/src/icons/__workshop__/index.tsx +0 -6
- package/src/icons/__workshop__/overview.tsx +0 -76
- package/src/styles/compose.ts +0 -35
- package/src/utils/srOnly/__workshop__/.eslintrc +0 -5
|
@@ -1,70 +1,74 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'components/menu',
|
|
6
|
+
title: 'Menu',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'menu-button',
|
|
10
|
+
title: 'MenuButton',
|
|
11
|
+
component: lazy(() => import('./menuButton')),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'nested-menu-items',
|
|
15
|
+
title: 'Nested MenuItems',
|
|
16
|
+
component: lazy(() => import('./nestedMenu')),
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'custom-menu-item',
|
|
20
|
+
title: 'Custom MenuItem',
|
|
21
|
+
component: lazy(() => import('./customMenuItem')),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'groups',
|
|
25
|
+
title: 'Groups',
|
|
26
|
+
component: lazy(() => import('./groups')),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'menu-group-right',
|
|
30
|
+
title: 'Menu group (right)',
|
|
31
|
+
component: lazy(() => import('./menuGroupRight')),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'tones',
|
|
35
|
+
title: 'Tones',
|
|
36
|
+
component: lazy(() => import('./tones')),
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'selected-item',
|
|
40
|
+
title: 'Selected item',
|
|
41
|
+
component: lazy(() => import('./selectedItem')),
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'closable',
|
|
45
|
+
title: 'Closeable',
|
|
46
|
+
component: lazy(() => import('./closableMenuButton')),
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'without-arrow',
|
|
50
|
+
title: 'Without arrow',
|
|
51
|
+
component: lazy(() => import('./withoutArrow')),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'constrained-in-boundary',
|
|
55
|
+
title: 'Constrained in boundary',
|
|
56
|
+
component: lazy(() => import('./constrainedInBoundary')),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'as-component',
|
|
60
|
+
title: 'As component',
|
|
61
|
+
component: lazy(() => import('./asComponent')),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'disable-focus-on-close',
|
|
65
|
+
title: 'Disable focus on close',
|
|
66
|
+
component: lazy(() => import('./disableFocusOnClose')),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'menu-button-with-on-close',
|
|
70
|
+
title: 'MenuButton with on close',
|
|
71
|
+
component: lazy(() => import('./onCloseMenuButton')),
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {forwardRef,
|
|
1
|
+
import {forwardRef, useCallback, useEffect, useMemo} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
import {useClickOutside, useForwardedRef, useGlobalKeyDown} from '../../hooks'
|
|
4
4
|
import {Box, Stack} from '../../primitives'
|
|
@@ -29,12 +29,10 @@ export interface MenuProps extends ResponsivePaddingProps {
|
|
|
29
29
|
space?: number | number[]
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const Root =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
)
|
|
32
|
+
const Root = styled(Box)`
|
|
33
|
+
outline: none;
|
|
34
|
+
overflow: auto;
|
|
35
|
+
`
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
38
|
* @public
|
|
@@ -228,28 +228,30 @@ export const MenuButton = forwardRef(function MenuButton(
|
|
|
228
228
|
[buttonProp, handleButtonClick, handleButtonKeyDown, id, open, setButtonRef]
|
|
229
229
|
)
|
|
230
230
|
|
|
231
|
-
const popoverProps:
|
|
232
|
-
|
|
231
|
+
const popoverProps: MenuButtonProps['popover'] = useMemo(
|
|
232
|
+
() => ({
|
|
233
233
|
boundaryElement: deprecated_boundaryElement,
|
|
234
|
+
overflow: 'auto',
|
|
234
235
|
placement: deprecated_placement,
|
|
235
236
|
portal: deprecated_portal,
|
|
236
|
-
radius: deprecated_popoverRadius,
|
|
237
237
|
preventOverflow: deprecated_preventOverflow,
|
|
238
|
+
radius: deprecated_popoverRadius,
|
|
238
239
|
scheme: deprecated_popoverScheme,
|
|
239
240
|
...(popover || {}),
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
241
|
+
}),
|
|
242
|
+
[
|
|
243
|
+
deprecated_boundaryElement,
|
|
244
|
+
deprecated_placement,
|
|
245
|
+
deprecated_popoverRadius,
|
|
246
|
+
deprecated_popoverScheme,
|
|
247
|
+
deprecated_portal,
|
|
248
|
+
deprecated_preventOverflow,
|
|
249
|
+
popover,
|
|
250
|
+
]
|
|
251
|
+
)
|
|
250
252
|
|
|
251
253
|
return (
|
|
252
|
-
<Popover {...popoverProps} content={menu}
|
|
254
|
+
<Popover data-ui="MenuButton__popover" {...popoverProps} content={menu} open={open}>
|
|
253
255
|
{button || <></>}
|
|
254
256
|
</Popover>
|
|
255
257
|
)
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import styled, {StyledComponent} from 'styled-components'
|
|
2
|
+
import {Theme} from '../../theme'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export const MenuDivider =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})
|
|
14
|
-
)
|
|
7
|
+
export const MenuDivider: StyledComponent<'hr', Theme> = styled.hr`
|
|
8
|
+
height: 1px;
|
|
9
|
+
border: 0;
|
|
10
|
+
background: var(--card-hairline-soft-color);
|
|
11
|
+
margin: 0;
|
|
12
|
+
`
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'components/skeleton',
|
|
6
|
+
title: 'Skeleton',
|
|
7
|
+
stories: [
|
|
8
|
+
{name: 'skeleton', title: 'Skeleton', component: lazy(() => import('./skeleton'))},
|
|
9
|
+
{name: 'skeleton-delay', title: 'Skeleton delay', component: lazy(() => import('./delay'))},
|
|
10
|
+
],
|
|
11
|
+
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {forwardRef,
|
|
1
|
+
import {forwardRef, useEffect, useState} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {Box} from '../../primitives'
|
|
@@ -6,11 +6,9 @@ import {BoxProps, ResponsiveRadiusProps} from '../../primitives'
|
|
|
6
6
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
7
7
|
import {skeletonStyle} from './styles'
|
|
8
8
|
|
|
9
|
-
const Root =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
skeletonStyle
|
|
13
|
-
)
|
|
9
|
+
const Root = styled(Box)<{$animated: boolean; $visible: boolean} & ResponsiveRadiusStyleProps>(
|
|
10
|
+
responsiveRadiusStyle,
|
|
11
|
+
skeletonStyle
|
|
14
12
|
)
|
|
15
13
|
|
|
16
14
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {css, keyframes} from 'styled-components'
|
|
2
2
|
|
|
3
|
-
const keyframe = keyframes
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
3
|
+
const keyframe = keyframes`
|
|
4
|
+
0% {
|
|
5
|
+
background-position: 100%;
|
|
6
|
+
}
|
|
7
|
+
100% {
|
|
8
|
+
background-position: -100%;
|
|
9
|
+
}
|
|
10
|
+
`
|
|
11
11
|
|
|
12
12
|
const animation = css`
|
|
13
13
|
background-image: linear-gradient(
|
|
@@ -37,7 +37,11 @@ export const skeletonStyle = css<{$animated: boolean; $visible: boolean}>`
|
|
|
37
37
|
|
|
38
38
|
@media screen and (prefers-reduced-motion: no-preference) {
|
|
39
39
|
${({$animated}) =>
|
|
40
|
-
$animated
|
|
40
|
+
$animated
|
|
41
|
+
? animation
|
|
42
|
+
: css`
|
|
43
|
+
background-color: var(--card-skeleton-color-from);
|
|
44
|
+
`}
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
@media screen and (prefers-reduced-motion: reduce) {
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {_responsive} from '../../styles'
|
|
5
5
|
import {Theme, ThemeFontKey} from '../../theme'
|
|
6
6
|
import {Skeleton, SkeletonProps} from './skeleton'
|
|
7
7
|
|
|
8
|
-
const Root =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const font = theme.sanity.fonts[$style]
|
|
8
|
+
const Root = styled(Skeleton)<{$size: number[]; $style: ThemeFontKey}>(
|
|
9
|
+
({$size, $style, theme}: {$size: number[]; $style: ThemeFontKey; theme: Theme}) => {
|
|
10
|
+
const {media} = theme.sanity
|
|
11
|
+
const font = theme.sanity.fonts[$style]
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const styles = _responsive(media, $size, (sizeIndex) => {
|
|
14
|
+
const fontSize = font.sizes[sizeIndex]
|
|
15
|
+
const capHeight = fontSize.lineHeight - fontSize.ascenderHeight - fontSize.descenderHeight
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
return {height: capHeight}
|
|
18
|
+
})
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
20
|
+
return styles
|
|
21
|
+
}
|
|
24
22
|
)
|
|
25
23
|
|
|
26
24
|
/**
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'components/tab',
|
|
6
|
+
title: 'Tab',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'example',
|
|
10
|
+
title: 'Example',
|
|
11
|
+
component: lazy(() => import('./example')),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
})
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'components/toast',
|
|
6
|
+
title: 'Toast',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'toast',
|
|
10
|
+
title: 'Toast',
|
|
11
|
+
component: lazy(() => import('./toast')),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'hook',
|
|
15
|
+
title: 'Hook',
|
|
16
|
+
component: lazy(() => import('./hook')),
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {CloseIcon} from '@sanity/icons'
|
|
2
|
-
import {memo} from 'react'
|
|
3
2
|
import styled from 'styled-components'
|
|
4
3
|
import {Box, Button, Card, Flex, Stack, Text} from '../../primitives'
|
|
5
4
|
import {ThemeColorToneKey} from '../../theme'
|
|
@@ -29,17 +28,13 @@ const ROLES = {
|
|
|
29
28
|
info: 'alert',
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
const Root =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
36
|
-
)
|
|
31
|
+
const Root = styled(Card)`
|
|
32
|
+
pointer-events: all;
|
|
33
|
+
`
|
|
37
34
|
|
|
38
|
-
const TextBox =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
)
|
|
35
|
+
const TextBox = styled(Flex)`
|
|
36
|
+
overflow-x: auto;
|
|
37
|
+
`
|
|
43
38
|
|
|
44
39
|
/**
|
|
45
40
|
* @public
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {AnimatePresence, motion} from 'framer-motion'
|
|
2
|
-
import {
|
|
2
|
+
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
|
3
3
|
import styled from 'styled-components'
|
|
4
4
|
import {Box} from '../../primitives'
|
|
5
5
|
import {Layer} from '../../utils'
|
|
@@ -26,27 +26,23 @@ export interface ToastProviderProps {
|
|
|
26
26
|
zOffset?: number | number[]
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const Root =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
maxWidth: '420px',
|
|
47
|
-
width: '100%',
|
|
48
|
-
})
|
|
49
|
-
)
|
|
29
|
+
const Root = styled(Layer)`
|
|
30
|
+
position: fixed;
|
|
31
|
+
top: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
right: 0;
|
|
34
|
+
bottom: 0;
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
`
|
|
37
|
+
|
|
38
|
+
const ToastContainer = styled.div`
|
|
39
|
+
box-sizing: border-box;
|
|
40
|
+
position: absolute;
|
|
41
|
+
right: 0;
|
|
42
|
+
bottom: 0;
|
|
43
|
+
max-width: 420px;
|
|
44
|
+
width: 100%;
|
|
45
|
+
`
|
|
50
46
|
|
|
51
47
|
let toastId = 0
|
|
52
48
|
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {PerfTestProps, PerfTestRunFn} from '@sanity/ui-workshop'
|
|
1
|
+
import {PerfTestProps, PerfTestRunFn} from '@sanity/ui-workshop/plugin-perf'
|
|
2
2
|
import {findByTestId, fireEvent} from '@testing-library/dom'
|
|
3
3
|
|
|
4
|
-
// // function delay(ms: number) {
|
|
5
|
-
// // return new Promise((resolve) => setTimeout(resolve, ms))
|
|
6
|
-
// // }
|
|
7
|
-
|
|
8
4
|
function test<ElementType = unknown>(
|
|
9
5
|
title: string,
|
|
10
6
|
run: PerfTestRunFn<ElementType>
|
|
@@ -12,17 +8,8 @@ function test<ElementType = unknown>(
|
|
|
12
8
|
return {name: title, run}
|
|
13
9
|
}
|
|
14
10
|
|
|
15
|
-
// export const toggleTreeGroupsTest = perfTest(
|
|
16
|
-
// 'Toggle tree groups',
|
|
17
|
-
// async ({target}: {target: HTMLDivElement}) => {
|
|
18
|
-
|
|
19
|
-
// }
|
|
20
|
-
// )
|
|
21
|
-
|
|
22
11
|
export const perfTests = [
|
|
23
12
|
test('Toggle tree groups', async ({target}: {target: HTMLDivElement}) => {
|
|
24
|
-
// await delay(50)
|
|
25
|
-
|
|
26
13
|
const apples = await findByTestId(target, 'apples')
|
|
27
14
|
const oranges = await findByTestId(target, 'oranges')
|
|
28
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {LinkIcon} from '@sanity/icons'
|
|
2
2
|
import {Box, Tree, TreeItem} from '@sanity/ui'
|
|
3
|
-
import {usePerfTest} from '@sanity/ui-workshop'
|
|
3
|
+
import {usePerfTest} from '@sanity/ui-workshop/plugin-perf'
|
|
4
4
|
import {useCallback, useState} from 'react'
|
|
5
5
|
import {perfTests} from './basic.perf'
|
|
6
6
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import {defineScope} from '@sanity/ui-workshop'
|
|
2
2
|
import {lazy} from 'react'
|
|
3
3
|
|
|
4
|
-
export default defineScope(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
export default defineScope({
|
|
5
|
+
name: 'components/tree',
|
|
6
|
+
title: 'Tree',
|
|
7
|
+
stories: [
|
|
8
|
+
{
|
|
9
|
+
name: 'basic',
|
|
10
|
+
title: 'Basic',
|
|
11
|
+
component: lazy(() => import('./basic')),
|
|
12
|
+
// options: {perfTests: () => import('./basic.perf')},
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
})
|