@sanity/ui 3.0.0-static.0 → 3.0.0-static.1
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/_chunks-cjs/buildCommand.js +1387 -681
- package/dist/_chunks-cjs/buildCommand.js.map +1 -1
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/css.d.mts +131 -12
- package/dist/css.d.ts +131 -12
- package/dist/css.esm.js +1450 -791
- package/dist/css.esm.js.map +1 -1
- package/dist/css.js +1449 -790
- package/dist/css.js.map +1 -1
- package/dist/css.mjs +1450 -791
- package/dist/css.mjs.map +1 -1
- package/dist/index.d.mts +84 -76
- package/dist/index.d.ts +84 -76
- package/dist/index.esm.js +2734 -3146
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2733 -3145
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2734 -3146
- package/dist/index.mjs.map +1 -1
- package/dist/sanity-theme.css +1 -1
- package/dist/system.css +1590 -1158
- package/dist/theme.esm.js +1565 -452
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +1599 -484
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +1565 -452
- package/dist/theme.mjs.map +1 -1
- package/package.json +22 -22
- package/src/core/__workshop__/constants.ts +14 -5
- package/src/core/__workshop__/fontsPlugin.tsx +1 -1
- package/src/core/_compat/index.ts +2 -0
- package/src/core/{styles → _compat/styles}/box/boxStyle.ts +1 -1
- package/src/core/{styles → _compat/styles}/box/types.ts +1 -1
- package/src/core/{styles → _compat/styles}/card/_cardColorStyle.ts +2 -2
- package/src/core/{styles → _compat/styles}/flex/flexItemStyle.ts +1 -1
- package/src/core/{styles → _compat/styles}/font/types.ts +1 -1
- package/src/core/{styles → _compat/styles}/grid/types.ts +1 -1
- package/src/core/{styles → _compat/styles}/helpers.ts +1 -1
- package/src/core/{styles → _compat/styles}/input/textInputStyle.ts +2 -2
- package/src/core/{styles → _compat/styles}/radius/types.ts +1 -1
- package/src/core/{styles → _compat/styles}/shadow/shadowStyle.ts +1 -1
- package/src/core/components/autocomplete/__workshop__/custom.tsx +5 -4
- package/src/core/components/autocomplete/__workshop__/example.tsx +3 -2
- package/src/core/components/autocomplete/autocomplete.tsx +5 -5
- package/src/core/components/dialog/__workshop__/panes.tsx +1 -1
- package/src/core/components/dialog/__workshop__/props.tsx +2 -0
- package/src/core/components/dialog/dialog.tsx +1 -5
- package/src/core/components/hotkeys/hotkeys.tsx +1 -1
- package/src/core/components/menu/menu.tsx +8 -10
- package/src/core/components/menu/menuDivider.tsx +16 -0
- package/src/core/components/menu/menuGroup.tsx +2 -8
- package/src/core/components/menu/menuItem.tsx +1 -1
- package/src/core/components/skeleton/skeleton.tsx +14 -20
- package/src/core/components/skeleton/textSkeleton.tsx +72 -48
- package/src/core/components/tab/tab.tsx +0 -1
- package/src/core/components/tab/tabList.tsx +4 -21
- package/src/core/components/tab/tabPanel.tsx +1 -0
- package/src/core/components/toast/toast.tsx +27 -14
- package/src/core/components/toast/toastProvider.tsx +4 -13
- package/src/core/components/tree/tree.tsx +1 -2
- package/src/core/components/tree/treeGroup.tsx +4 -1
- package/src/core/components/tree/treeItem.tsx +11 -15
- package/src/core/hooks/useArrayProp.ts +1 -1
- package/src/core/index.ts +0 -1
- package/src/core/lib/styled/members.ts +2 -2
- package/src/core/primitives/avatar/avatar.tsx +0 -21
- package/src/core/primitives/avatar/avatarCounter.tsx +1 -1
- package/src/core/primitives/avatar/avatarStack.tsx +1 -1
- package/src/core/primitives/avatar/styles.ts +2 -2
- package/src/core/primitives/box/box.tsx +4 -1
- package/src/core/primitives/button/__workshop__/props.tsx +2 -1
- package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +1 -1
- package/src/core/primitives/button/__workshop__/stacked.tsx +2 -1
- package/src/core/primitives/button/__workshop__/styled1.tsx +1 -1
- package/src/core/primitives/button/__workshop__/styled2.tsx +1 -1
- package/src/core/primitives/button/styles.ts +3 -3
- package/src/core/primitives/card/__workshop__/props.tsx +2 -2
- package/src/core/primitives/card/__workshop__/selected.tsx +1 -1
- package/src/core/primitives/card/__workshop__/styled.tsx +1 -1
- package/src/core/primitives/card/card.tsx +7 -10
- package/src/core/primitives/code/code.tsx +2 -4
- package/src/core/primitives/container/styles.ts +1 -1
- package/src/core/primitives/flex/__workshop__/example.tsx +1 -1
- package/src/core/primitives/flex/flex.tsx +1 -13
- package/src/core/primitives/grid/grid.tsx +5 -19
- package/src/core/primitives/heading/heading.tsx +8 -25
- package/src/core/primitives/heading/styles.ts +1 -1
- package/src/core/primitives/inline/inline.tsx +3 -12
- package/src/core/primitives/inline/styles.ts +1 -1
- package/src/core/primitives/label/label.tsx +4 -9
- package/src/core/primitives/label/styles.ts +1 -1
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +2 -2
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +2 -1
- package/src/core/primitives/popover/popover.tsx +1 -1
- package/src/core/primitives/popover/popoverCard.tsx +1 -1
- package/src/core/primitives/radio/radio.tsx +1 -1
- package/src/core/primitives/radio/styles.ts +2 -2
- package/src/core/primitives/select/select.tsx +1 -1
- package/src/core/primitives/select/styles.ts +3 -3
- package/src/core/primitives/spinner/__workshop__/Props.tsx +2 -1
- package/src/core/primitives/spinner/animatedSpinnerIcon.tsx +16 -0
- package/src/core/primitives/spinner/spinner.tsx +2 -2
- package/src/core/primitives/stack/styles.ts +1 -1
- package/src/core/primitives/switch/styles.ts +2 -2
- package/src/core/primitives/text/__workshop__/colored.tsx +1 -1
- package/src/core/primitives/text/styles.ts +1 -1
- package/src/core/primitives/text/text.tsx +1 -4
- package/src/core/primitives/textArea/__workshop__/plain.tsx +2 -2
- package/src/core/primitives/textArea/textArea.tsx +3 -3
- package/src/core/primitives/textInput/__workshop__/plain.tsx +3 -2
- package/src/core/primitives/textInput/textInput.tsx +16 -83
- package/src/core/primitives/tooltip/tooltipCard.tsx +5 -5
- package/src/core/primitives/types.ts +1 -0
- package/src/core/theme/__workshop__/build/Root.tsx +1 -1
- package/src/core/theme/__workshop__/build/story.tsx +2 -4
- package/src/core/theme/themeProvider.tsx +1 -1
- package/src/core/types/box.ts +22 -16
- package/src/core/types/grid.ts +17 -12
- package/src/core/types/text.ts +7 -4
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +1 -1
- package/src/core/utils/layer/layer.tsx +2 -2
- package/src/core/utils/virtualList/virtualList.tsx +1 -1
- package/src/css/compile/{comileRules.ts → compileRules.ts} +2 -5
- package/src/css/compile/compileSystem.ts +1 -1
- package/src/css/compile/compileTheme.ts +4 -1
- package/src/css/components/breadcrumbs/rules.ts +18 -0
- package/src/css/components/menu/index.ts +1 -0
- package/src/css/components/menu/menu.ts +5 -0
- package/src/css/components/menu/rules.ts +10 -0
- package/src/css/components/skeleton/index.ts +2 -0
- package/src/css/components/skeleton/rules.ts +106 -0
- package/src/css/components/skeleton/skeleton.ts +31 -0
- package/src/css/components/skeleton/types.ts +24 -0
- package/src/css/components/toast/rules.ts +68 -0
- package/src/css/components/tree/rules.ts +115 -0
- package/src/css/index.ts +4 -0
- package/src/css/primitives/box/box.ts +5 -1
- package/src/css/primitives/box/types.ts +7 -8
- package/src/css/primitives/card/rules.ts +161 -13
- package/src/css/primitives/checkbox/__styles.ts +115 -113
- package/src/css/primitives/selectable/__style.ts +117 -115
- package/src/css/primitives/spinner/rules.ts +5 -7
- package/src/css/primitives/spinner/spinner.ts +4 -0
- package/src/css/primitives/textInput/index.ts +1 -0
- package/src/css/primitives/textInput/rules.ts +159 -64
- package/src/css/primitives/textInput/textInput.ts +11 -3
- package/src/css/primitives/textInput/types.ts +8 -0
- package/src/css/rules.ts +16 -38
- package/src/css/styles/font/font.ts +7 -2
- package/src/css/styles/font/rules.ts +23 -0
- package/src/css/styles/font/types.ts +6 -0
- package/src/css/styles/gap/rules.ts +6 -6
- package/src/css/styles/grid/grid.ts +13 -0
- package/src/css/styles/grid/index.ts +2 -0
- package/src/css/styles/grid/rules.ts +112 -1
- package/src/css/styles/grid/types.ts +29 -0
- package/src/css/styles/margin/rules.ts +58 -54
- package/src/css/styles/outline/rules.ts +7 -0
- package/src/css/styles/overflow/index.ts +2 -0
- package/src/css/styles/overflow/overflow.ts +11 -0
- package/src/css/styles/overflow/types.ts +11 -0
- package/src/css/styles/padding/rules.ts +50 -48
- package/src/css/types.ts +36 -1
- package/src/css/varNames.ts +1 -1
- package/src/css/vars.ts +86 -0
- package/dist/_chunks-cjs/getTheme_v2.js +0 -316
- package/dist/_chunks-cjs/getTheme_v2.js.map +0 -1
- package/dist/_chunks-es/getTheme_v2.mjs +0 -317
- package/dist/_chunks-es/getTheme_v2.mjs.map +0 -1
- package/dist/_legacy/getTheme_v2.esm.js +0 -317
- package/dist/_legacy/getTheme_v2.esm.js.map +0 -1
- package/src/core/components/autocomplete/autocomplete.styles.tsx +0 -38
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +0 -17
- package/src/core/components/menu/menuDivider.ts +0 -13
- package/src/core/components/skeleton/styles.ts +0 -50
- package/src/core/components/toast/styles.ts +0 -61
- package/src/core/components/tree/style.ts +0 -104
- package/src/core/primitives/card/styles.ts +0 -146
- /package/src/core/{styles → _compat/styles}/border/borderStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/border/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/border/types.ts +0 -0
- /package/src/core/{styles → _compat/styles}/box/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/card/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/flex/flexStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/flex/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/flex/types.ts +0 -0
- /package/src/core/{styles → _compat/styles}/focusRing/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/codeFontStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/headingFontStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/labelFontStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/responsiveFont.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/textAlignStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/font/textFontStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/grid/gridItemStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/grid/gridStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/grid/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/input/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/input/responsiveInputPaddingStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/internal.ts +0 -0
- /package/src/core/{styles → _compat/styles}/margin/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/margin/marginStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/margin/marginsStyle.test.ts +0 -0
- /package/src/core/{styles → _compat/styles}/margin/types.ts +0 -0
- /package/src/core/{styles → _compat/styles}/padding/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/padding/paddingStyle.test.ts +0 -0
- /package/src/core/{styles → _compat/styles}/padding/paddingStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/padding/types.ts +0 -0
- /package/src/core/{styles → _compat/styles}/radius/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/radius/radiusStyle.ts +0 -0
- /package/src/core/{styles → _compat/styles}/shadow/index.ts +0 -0
- /package/src/core/{styles → _compat/styles}/shadow/types.ts +0 -0
- /package/src/core/{styles → _compat/styles}/types.ts +0 -0
- /package/src/core/{_compat.ts → _compat/types.ts} +0 -0
|
@@ -1,36 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
codeSkeleton,
|
|
3
|
+
composeClassNames,
|
|
4
|
+
headingSkeleton,
|
|
5
|
+
labelSkeleton,
|
|
6
|
+
ResponsiveProp,
|
|
7
|
+
textSkeleton,
|
|
8
|
+
} from '@sanity/ui/css'
|
|
9
|
+
import {FontCodeSize, FontHeadingSize, FontLabelSize, FontTextSize} from '@sanity/ui/theme'
|
|
2
10
|
import {forwardRef} from 'react'
|
|
3
|
-
import {styled} from '../../lib/styled'
|
|
4
|
-
import {useArrayProp} from '../../hooks'
|
|
5
|
-
import {ThemeProps, _responsive} from '../../styles'
|
|
6
11
|
import {Skeleton, SkeletonProps} from './skeleton'
|
|
7
12
|
|
|
8
|
-
const Root = styled(Skeleton)<{$size: number[]; $style: ThemeFontKey}>((
|
|
9
|
-
props: {
|
|
10
|
-
$size: number[]
|
|
11
|
-
$style: ThemeFontKey
|
|
12
|
-
} & ThemeProps,
|
|
13
|
-
) => {
|
|
14
|
-
const {$size, $style} = props
|
|
15
|
-
const {font, media} = getTheme_v2(props.theme)
|
|
16
|
-
const fontStyle = font[$style]
|
|
17
|
-
|
|
18
|
-
const styles = _responsive(media, $size, (sizeIndex) => {
|
|
19
|
-
const fontSize = fontStyle.sizes[sizeIndex]
|
|
20
|
-
const capHeight = fontSize.lineHeight - fontSize.ascenderHeight - fontSize.descenderHeight
|
|
21
|
-
|
|
22
|
-
return {height: capHeight}
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
return styles
|
|
26
|
-
})
|
|
27
|
-
|
|
28
13
|
/**
|
|
29
14
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
30
15
|
* @beta
|
|
31
16
|
*/
|
|
32
17
|
export interface TextSkeletonProps extends SkeletonProps {
|
|
33
|
-
size?:
|
|
18
|
+
size?: ResponsiveProp<FontTextSize>
|
|
34
19
|
}
|
|
35
20
|
|
|
36
21
|
/**
|
|
@@ -38,7 +23,7 @@ export interface TextSkeletonProps extends SkeletonProps {
|
|
|
38
23
|
* @beta
|
|
39
24
|
*/
|
|
40
25
|
export interface LabelSkeletonProps extends SkeletonProps {
|
|
41
|
-
size?:
|
|
26
|
+
size?: ResponsiveProp<FontLabelSize>
|
|
42
27
|
}
|
|
43
28
|
|
|
44
29
|
/**
|
|
@@ -46,7 +31,7 @@ export interface LabelSkeletonProps extends SkeletonProps {
|
|
|
46
31
|
* @beta
|
|
47
32
|
*/
|
|
48
33
|
export interface HeadingSkeletonProps extends SkeletonProps {
|
|
49
|
-
size?:
|
|
34
|
+
size?: ResponsiveProp<FontHeadingSize>
|
|
50
35
|
}
|
|
51
36
|
|
|
52
37
|
/**
|
|
@@ -54,7 +39,7 @@ export interface HeadingSkeletonProps extends SkeletonProps {
|
|
|
54
39
|
* @beta
|
|
55
40
|
*/
|
|
56
41
|
export interface CodeSkeletonProps extends SkeletonProps {
|
|
57
|
-
size?:
|
|
42
|
+
size?: ResponsiveProp<FontCodeSize>
|
|
58
43
|
}
|
|
59
44
|
|
|
60
45
|
/**
|
|
@@ -63,14 +48,24 @@ export interface CodeSkeletonProps extends SkeletonProps {
|
|
|
63
48
|
*/
|
|
64
49
|
export const TextSkeleton = forwardRef(function TextSkeleton(
|
|
65
50
|
props: TextSkeletonProps &
|
|
66
|
-
Omit<
|
|
51
|
+
Omit<
|
|
52
|
+
React.HTMLProps<HTMLDivElement>,
|
|
53
|
+
'as' | 'children' | 'height' | 'rows' | 'size' | 'width' | 'wrap'
|
|
54
|
+
>,
|
|
67
55
|
ref: React.Ref<HTMLDivElement>,
|
|
68
56
|
) {
|
|
69
|
-
const {size = 2, ...restProps} = props
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
57
|
+
const {className, size = 2, ...restProps} = props
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Skeleton
|
|
61
|
+
data-ui="TextSkeleton"
|
|
62
|
+
{...restProps}
|
|
63
|
+
className={composeClassNames(className, textSkeleton({size}))}
|
|
64
|
+
ref={ref}
|
|
65
|
+
/>
|
|
66
|
+
)
|
|
73
67
|
})
|
|
68
|
+
|
|
74
69
|
TextSkeleton.displayName = 'ForwardRef(TextSkeleton)'
|
|
75
70
|
|
|
76
71
|
/**
|
|
@@ -79,14 +74,24 @@ TextSkeleton.displayName = 'ForwardRef(TextSkeleton)'
|
|
|
79
74
|
*/
|
|
80
75
|
export const LabelSkeleton = forwardRef(function TextSkeleton(
|
|
81
76
|
props: LabelSkeletonProps &
|
|
82
|
-
Omit<
|
|
77
|
+
Omit<
|
|
78
|
+
React.HTMLProps<HTMLDivElement>,
|
|
79
|
+
'as' | 'children' | 'height' | 'rows' | 'size' | 'width' | 'wrap'
|
|
80
|
+
>,
|
|
83
81
|
ref: React.Ref<HTMLDivElement>,
|
|
84
82
|
) {
|
|
85
|
-
const {size = 2, ...restProps} = props
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
const {className, size = 2, ...restProps} = props
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Skeleton
|
|
87
|
+
data-ui="LabelSkeleton"
|
|
88
|
+
{...restProps}
|
|
89
|
+
className={composeClassNames(className, labelSkeleton({size}))}
|
|
90
|
+
ref={ref}
|
|
91
|
+
/>
|
|
92
|
+
)
|
|
89
93
|
})
|
|
94
|
+
|
|
90
95
|
LabelSkeleton.displayName = 'ForwardRef(LabelSkeleton)'
|
|
91
96
|
|
|
92
97
|
/**
|
|
@@ -95,14 +100,23 @@ LabelSkeleton.displayName = 'ForwardRef(LabelSkeleton)'
|
|
|
95
100
|
*/
|
|
96
101
|
export const HeadingSkeleton = forwardRef(function TextSkeleton(
|
|
97
102
|
props: HeadingSkeletonProps &
|
|
98
|
-
Omit<
|
|
103
|
+
Omit<
|
|
104
|
+
React.HTMLProps<HTMLDivElement>,
|
|
105
|
+
'as' | 'children' | 'height' | 'rows' | 'size' | 'width' | 'wrap'
|
|
106
|
+
>,
|
|
99
107
|
ref: React.Ref<HTMLDivElement>,
|
|
100
108
|
) {
|
|
101
|
-
const {size = 2, ...restProps} = props
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
109
|
+
const {className, size = 2, ...restProps} = props
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<Skeleton
|
|
113
|
+
{...restProps}
|
|
114
|
+
className={composeClassNames(className, headingSkeleton({size}))}
|
|
115
|
+
ref={ref}
|
|
116
|
+
/>
|
|
117
|
+
)
|
|
105
118
|
})
|
|
119
|
+
|
|
106
120
|
HeadingSkeleton.displayName = 'ForwardRef(HeadingSkeleton)'
|
|
107
121
|
|
|
108
122
|
/**
|
|
@@ -111,12 +125,22 @@ HeadingSkeleton.displayName = 'ForwardRef(HeadingSkeleton)'
|
|
|
111
125
|
*/
|
|
112
126
|
export const CodeSkeleton = forwardRef(function TextSkeleton(
|
|
113
127
|
props: CodeSkeletonProps &
|
|
114
|
-
Omit<
|
|
128
|
+
Omit<
|
|
129
|
+
React.HTMLProps<HTMLDivElement>,
|
|
130
|
+
'as' | 'children' | 'height' | 'rows' | 'size' | 'width' | 'wrap'
|
|
131
|
+
>,
|
|
115
132
|
ref: React.Ref<HTMLDivElement>,
|
|
116
133
|
) {
|
|
117
|
-
const {size = 2, ...restProps} = props
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
134
|
+
const {className, size = 2, ...restProps} = props
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<Skeleton
|
|
138
|
+
// root
|
|
139
|
+
{...restProps}
|
|
140
|
+
className={composeClassNames(className, codeSkeleton({size}))}
|
|
141
|
+
ref={ref}
|
|
142
|
+
/>
|
|
143
|
+
)
|
|
121
144
|
})
|
|
145
|
+
|
|
122
146
|
CodeSkeleton.displayName = 'ForwardRef(CodeSkeleton)'
|
|
@@ -16,7 +16,6 @@ export interface TabProps {
|
|
|
16
16
|
'icon'?: React.ElementType | React.ReactNode
|
|
17
17
|
'focused'?: boolean
|
|
18
18
|
'fontSize'?: ResponsiveProp<FontTextSize>
|
|
19
|
-
// 'fontSize'?: number | number[]
|
|
20
19
|
'label'?: React.ReactNode
|
|
21
20
|
'padding'?: number | number[]
|
|
22
21
|
'selected'?: boolean
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {cloneElement, forwardRef, useCallback, useMemo, useState} from 'react'
|
|
2
|
-
import {styled} from '../../lib/styled'
|
|
1
|
+
import {cloneElement, ForwardedRef, forwardRef, useCallback, useMemo, useState} from 'react'
|
|
3
2
|
import {Inline, InlineProps} from '../../primitives'
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -13,22 +12,12 @@ function _isReactElement(node: unknown): node is React.ReactElement {
|
|
|
13
12
|
return Boolean(node)
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
// Limits the width of tabs in tablist
|
|
17
|
-
const CustomInline = styled(Inline)`
|
|
18
|
-
& > div {
|
|
19
|
-
display: inline-block;
|
|
20
|
-
vertical-align: middle;
|
|
21
|
-
max-width: 100%;
|
|
22
|
-
box-sizing: border-box;
|
|
23
|
-
}
|
|
24
|
-
`
|
|
25
|
-
|
|
26
15
|
/**
|
|
27
16
|
* @public
|
|
28
17
|
*/
|
|
29
18
|
export const TabList = forwardRef(function TabList(
|
|
30
19
|
props: TabListProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height'>,
|
|
31
|
-
ref
|
|
20
|
+
ref: ForwardedRef<HTMLDivElement>,
|
|
32
21
|
) {
|
|
33
22
|
const {children: childrenProp, ...restProps} = props
|
|
34
23
|
const [focusedIndex, setFocusedIndex] = useState(-1)
|
|
@@ -63,15 +52,9 @@ export const TabList = forwardRef(function TabList(
|
|
|
63
52
|
)
|
|
64
53
|
|
|
65
54
|
return (
|
|
66
|
-
<
|
|
67
|
-
data-ui="TabList"
|
|
68
|
-
{...restProps}
|
|
69
|
-
onKeyDown={handleKeyDown}
|
|
70
|
-
ref={ref}
|
|
71
|
-
role="tablist"
|
|
72
|
-
>
|
|
55
|
+
<Inline data-ui="TabList" {...restProps} onKeyDown={handleKeyDown} ref={ref} role="tablist">
|
|
73
56
|
{tabs}
|
|
74
|
-
</
|
|
57
|
+
</Inline>
|
|
75
58
|
)
|
|
76
59
|
})
|
|
77
60
|
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import {CloseIcon} from '@sanity/icons'
|
|
2
2
|
import {RadiusStyleProps} from '@sanity/ui/css'
|
|
3
3
|
import {ThemeColorStateToneKey} from '@sanity/ui/theme'
|
|
4
|
-
import {styled} from '../../lib/styled'
|
|
5
4
|
import {Box, Button, Flex, Stack, Text, Card} from '../../primitives'
|
|
6
|
-
import {ThemeProps} from '../../styles'
|
|
7
5
|
import type {ButtonTone} from '../../types'
|
|
8
|
-
import {rootStyles, TextBox} from './styles'
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* @public
|
|
@@ -40,10 +37,6 @@ const ROLES = {
|
|
|
40
37
|
info: 'alert',
|
|
41
38
|
} as const
|
|
42
39
|
|
|
43
|
-
const Root = styled(Card)<{$duration?: number; tone: ThemeColorStateToneKey} & ThemeProps>(
|
|
44
|
-
rootStyles,
|
|
45
|
-
)
|
|
46
|
-
|
|
47
40
|
/**
|
|
48
41
|
* The `Toast` component gives feedback to users when an action has taken place.
|
|
49
42
|
*
|
|
@@ -53,15 +46,29 @@ const Root = styled(Card)<{$duration?: number; tone: ThemeColorStateToneKey} & T
|
|
|
53
46
|
*/
|
|
54
47
|
export function Toast(
|
|
55
48
|
props: ToastProps &
|
|
56
|
-
Omit<
|
|
49
|
+
Omit<
|
|
50
|
+
React.HTMLProps<HTMLDivElement>,
|
|
51
|
+
'as' | 'height' | 'ref' | 'rows' | 'title' | 'width' | 'wrap'
|
|
52
|
+
>,
|
|
57
53
|
): React.ReactElement {
|
|
58
|
-
const {
|
|
54
|
+
const {
|
|
55
|
+
closable,
|
|
56
|
+
description,
|
|
57
|
+
duration, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
58
|
+
onClose,
|
|
59
|
+
radius = 3,
|
|
60
|
+
title,
|
|
61
|
+
status,
|
|
62
|
+
...restProps
|
|
63
|
+
} = props
|
|
64
|
+
|
|
59
65
|
const cardTone = status ? STATUS_CARD_TONE[status] : 'default'
|
|
60
66
|
const buttonTone = status ? BUTTON_TONE[status] : 'default'
|
|
61
67
|
const role = status ? ROLES[status] : 'status'
|
|
62
68
|
|
|
63
69
|
return (
|
|
64
|
-
<
|
|
70
|
+
<Card
|
|
71
|
+
// root
|
|
65
72
|
data-ui="Toast"
|
|
66
73
|
role={role}
|
|
67
74
|
{...restProps}
|
|
@@ -70,10 +77,16 @@ export function Toast(
|
|
|
70
77
|
radius={radius}
|
|
71
78
|
shadow={2}
|
|
72
79
|
tone={cardTone}
|
|
73
|
-
|
|
80
|
+
// todo
|
|
81
|
+
// $duration={duration}
|
|
74
82
|
>
|
|
75
83
|
<Flex align="flex-start">
|
|
76
|
-
<
|
|
84
|
+
<Box
|
|
85
|
+
// text-box
|
|
86
|
+
flex={1}
|
|
87
|
+
overflowX="auto"
|
|
88
|
+
padding={3}
|
|
89
|
+
>
|
|
77
90
|
<Stack space={3}>
|
|
78
91
|
{title && (
|
|
79
92
|
<Text size={1} weight="medium">
|
|
@@ -86,7 +99,7 @@ export function Toast(
|
|
|
86
99
|
</Text>
|
|
87
100
|
)}
|
|
88
101
|
</Stack>
|
|
89
|
-
</
|
|
102
|
+
</Box>
|
|
90
103
|
|
|
91
104
|
{closable && (
|
|
92
105
|
<Box padding={1}>
|
|
@@ -102,7 +115,7 @@ export function Toast(
|
|
|
102
115
|
</Box>
|
|
103
116
|
)}
|
|
104
117
|
</Flex>
|
|
105
|
-
</
|
|
118
|
+
</Card>
|
|
106
119
|
)
|
|
107
120
|
}
|
|
108
121
|
|
|
@@ -3,7 +3,6 @@ import {useMemo, useRef, useState, startTransition, useEffect} from 'react'
|
|
|
3
3
|
import {POPOVER_MOTION_CONTENT_OPACITY_PROPERTY} from '../../constants'
|
|
4
4
|
import {useMounted} from '../../hooks/useMounted'
|
|
5
5
|
import {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'
|
|
6
|
-
// import {styled} from '../../lib/styled'
|
|
7
6
|
import {Box} from '../../primitives'
|
|
8
7
|
import {Layer} from '../../utils'
|
|
9
8
|
import {Toast} from './toast'
|
|
@@ -27,15 +26,6 @@ export interface ToastProviderProps {
|
|
|
27
26
|
zOffset?: number | number[]
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
// const ToastContainer = styled.div`
|
|
31
|
-
// box-sizing: border-box;
|
|
32
|
-
// position: absolute;
|
|
33
|
-
// right: 0;
|
|
34
|
-
// bottom: 0;
|
|
35
|
-
// max-width: 420px;
|
|
36
|
-
// width: 100%;
|
|
37
|
-
// `
|
|
38
|
-
|
|
39
29
|
let toastId = 0
|
|
40
30
|
|
|
41
31
|
/**
|
|
@@ -145,7 +135,7 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
145
135
|
{children}
|
|
146
136
|
{mounted && (
|
|
147
137
|
<Layer
|
|
148
|
-
|
|
138
|
+
// root
|
|
149
139
|
data-ui="ToastProvider"
|
|
150
140
|
inset={0}
|
|
151
141
|
pointerEvents="none"
|
|
@@ -154,15 +144,16 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
154
144
|
width="fill"
|
|
155
145
|
>
|
|
156
146
|
<Box
|
|
157
|
-
|
|
147
|
+
// container
|
|
158
148
|
position="absolute"
|
|
159
149
|
sizing="border"
|
|
160
150
|
style={{
|
|
161
|
-
// todo: move to css
|
|
151
|
+
// todo: move to css?
|
|
162
152
|
right: 0,
|
|
163
153
|
bottom: 0,
|
|
164
154
|
maxWidth: 420,
|
|
165
155
|
}}
|
|
156
|
+
width="fill"
|
|
166
157
|
>
|
|
167
158
|
<Box padding={padding} paddingX={paddingX} paddingY={paddingY}>
|
|
168
159
|
<AnimatePresence initial={false}>
|
|
@@ -20,7 +20,6 @@ import {TreeContextValue, TreeState} from './types'
|
|
|
20
20
|
* @beta
|
|
21
21
|
*/
|
|
22
22
|
export interface TreeProps {
|
|
23
|
-
// space?: number | number[]
|
|
24
23
|
space?: ResponsiveProp<Space>
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -33,7 +32,7 @@ export const Tree = memo(
|
|
|
33
32
|
props: TreeProps &
|
|
34
33
|
Omit<
|
|
35
34
|
React.HTMLProps<HTMLDivElement>,
|
|
36
|
-
'align' | 'as' | 'height' | 'ref' | 'role' | 'width' | 'wrap'
|
|
35
|
+
'align' | 'as' | 'height' | 'ref' | 'rows' | 'role' | 'width' | 'wrap'
|
|
37
36
|
>,
|
|
38
37
|
forwardedRef: React.ForwardedRef<HTMLDivElement>,
|
|
39
38
|
): React.ReactElement {
|
|
@@ -8,7 +8,10 @@ export interface TreeGroupProps {
|
|
|
8
8
|
|
|
9
9
|
export const TreeGroup = memo(function TreeGroup(
|
|
10
10
|
props: TreeGroupProps &
|
|
11
|
-
Omit<
|
|
11
|
+
Omit<
|
|
12
|
+
React.HTMLProps<HTMLDivElement>,
|
|
13
|
+
'as' | 'height' | 'ref' | 'role' | 'rows' | 'width' | 'wrap'
|
|
14
|
+
>,
|
|
12
15
|
): React.ReactElement {
|
|
13
16
|
const {children, expanded = false, ...restProps} = props
|
|
14
17
|
const tree = useTree()
|
|
@@ -2,7 +2,6 @@ import {ToggleArrowRightIcon} from '@sanity/icons'
|
|
|
2
2
|
import {composeClassNames, ResponsiveProp, treeItem} from '@sanity/ui/css'
|
|
3
3
|
import {Space, ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
4
4
|
import {memo, useCallback, useEffect, useId, useMemo, useRef} from 'react'
|
|
5
|
-
import {styled} from '../../lib/styled'
|
|
6
5
|
import {Box, BoxProps, Flex, Text} from '../../primitives'
|
|
7
6
|
import {TreeContext} from './treeContext'
|
|
8
7
|
import {TreeGroup} from './treeGroup'
|
|
@@ -21,28 +20,20 @@ export interface TreeItemProps {
|
|
|
21
20
|
linkAs?: BoxProps['as']
|
|
22
21
|
padding?: number | number[]
|
|
23
22
|
space?: ResponsiveProp<Space>
|
|
24
|
-
// space?: number | number[]
|
|
25
23
|
text?: React.ReactNode
|
|
26
24
|
weight?: ThemeFontWeightKey
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
// const Root = memo(styled.li(treeItemRootStyle, treeItemRootColorStyle))
|
|
30
|
-
|
|
31
|
-
// const TreeItemBox = styled(Box).attrs({forwardedAs: 'a'})<TreeItemBoxStyleProps>(treeItemBoxStyle)
|
|
32
|
-
|
|
33
|
-
const ToggleArrowText = styled(Text)`
|
|
34
|
-
& > svg {
|
|
35
|
-
transition: transform 100ms;
|
|
36
|
-
}
|
|
37
|
-
`
|
|
38
|
-
|
|
39
27
|
/**
|
|
40
28
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
41
29
|
* @beta
|
|
42
30
|
*/
|
|
43
31
|
export const TreeItem = memo(function TreeItem(
|
|
44
32
|
props: TreeItemProps &
|
|
45
|
-
Omit<
|
|
33
|
+
Omit<
|
|
34
|
+
React.HTMLProps<HTMLDivElement>,
|
|
35
|
+
'as' | 'height' | 'ref' | 'role' | 'rows' | 'width' | 'wrap'
|
|
36
|
+
>,
|
|
46
37
|
): React.ReactElement {
|
|
47
38
|
const {
|
|
48
39
|
children,
|
|
@@ -130,9 +121,14 @@ export const TreeItem = memo(function TreeItem(
|
|
|
130
121
|
</Text>
|
|
131
122
|
)}
|
|
132
123
|
{!IconComponent && (
|
|
133
|
-
<
|
|
124
|
+
<Text
|
|
125
|
+
// ToggleArrowText
|
|
126
|
+
muted={muted}
|
|
127
|
+
size={fontSize}
|
|
128
|
+
weight={weight}
|
|
129
|
+
>
|
|
134
130
|
<ToggleArrowRightIcon style={{transform: expanded ? 'rotate(90deg)' : undefined}} />
|
|
135
|
-
</
|
|
131
|
+
</Text>
|
|
136
132
|
)}
|
|
137
133
|
</Box>
|
|
138
134
|
<Box flex={1}>
|
package/src/core/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createGlobalStyle as _createGlobalStyle,
|
|
4
4
|
type ExecutionContext as _ExecutionContext,
|
|
5
5
|
keyframes as _keyframes,
|
|
6
|
-
ThemeProvider as _ThemeProvider,
|
|
6
|
+
// ThemeProvider as _ThemeProvider,
|
|
7
7
|
useTheme as _useTheme,
|
|
8
8
|
} from 'styled-components'
|
|
9
9
|
|
|
@@ -11,5 +11,5 @@ export const createGlobalStyle = _createGlobalStyle
|
|
|
11
11
|
export const css = _css
|
|
12
12
|
export type ExecutionContext = _ExecutionContext
|
|
13
13
|
export const keyframes = _keyframes
|
|
14
|
-
export const ThemeProvider = _ThemeProvider
|
|
14
|
+
// export const ThemeProvider = _ThemeProvider
|
|
15
15
|
export const useTheme = _useTheme
|
|
@@ -11,11 +11,9 @@ import {ThemeColorAvatarColorKey} from '@sanity/ui/theme'
|
|
|
11
11
|
import {forwardRef, useCallback, useEffect, useId, useMemo, useState} from 'react'
|
|
12
12
|
import ReactIs from 'react-is'
|
|
13
13
|
import {useArrayProp} from '../../hooks'
|
|
14
|
-
// import {styled} from '../../lib/styled'
|
|
15
14
|
import {useTheme_v2} from '../../theme'
|
|
16
15
|
import {AvatarPosition, AvatarSize, AvatarStatus} from '../../types'
|
|
17
16
|
import {Label} from '../label'
|
|
18
|
-
// import {avatarStyle, responsiveAvatarSizeStyle} from './styles'
|
|
19
17
|
|
|
20
18
|
/**
|
|
21
19
|
* @public
|
|
@@ -39,25 +37,6 @@ export interface AvatarProps {
|
|
|
39
37
|
title?: string
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
// const Root = styled.div<{$color: ThemeColorAvatarColorKey; $size: AvatarSize[]}>(
|
|
43
|
-
// responsiveAvatarSizeStyle,
|
|
44
|
-
// avatarStyle.root,
|
|
45
|
-
// )
|
|
46
|
-
|
|
47
|
-
// const Arrow = styled.div(avatarStyle.arrow)
|
|
48
|
-
|
|
49
|
-
// const BgStroke = styled.ellipse(avatarStyle.bgStroke)
|
|
50
|
-
|
|
51
|
-
// const Stroke = styled.ellipse(avatarStyle.stroke)
|
|
52
|
-
|
|
53
|
-
// const Initials = styled.div(avatarStyle.initials)
|
|
54
|
-
|
|
55
|
-
// const InitialsLabel = styled(Label)({
|
|
56
|
-
// color: 'inherit',
|
|
57
|
-
// })
|
|
58
|
-
|
|
59
|
-
// const Image = styled.svg(avatarStyle.image)
|
|
60
|
-
|
|
61
40
|
/**
|
|
62
41
|
* Avatars are used to represent people and other agents (e.g. bots).
|
|
63
42
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {forwardRef, useMemo} from 'react'
|
|
3
|
+
import {rem, _responsive, ThemeProps} from '../../_compat'
|
|
3
4
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
5
|
import {useArrayProp} from '../../hooks'
|
|
5
6
|
import {styled, css} from '../../lib/styled'
|
|
6
|
-
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
7
7
|
import {AvatarSize} from '../../types'
|
|
8
8
|
import {Label} from '../label'
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {getTheme_v2} from '@sanity/ui/theme'
|
|
2
2
|
import {Children, cloneElement, forwardRef, isValidElement, useMemo} from 'react'
|
|
3
|
+
import {rem, _responsive, ThemeProps} from '../../_compat'
|
|
3
4
|
import {EMPTY_RECORD} from '../../constants'
|
|
4
5
|
import {useArrayProp} from '../../hooks'
|
|
5
6
|
import {styled, css} from '../../lib/styled'
|
|
6
|
-
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
7
7
|
import {AvatarSize} from '../../types'
|
|
8
8
|
import {AvatarCounter} from './avatarCounter'
|
|
9
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {CSSObject, getTheme_v2} from '@sanity/ui/theme'
|
|
2
|
-
import {rem, _responsive, ThemeProps} from '../../
|
|
3
|
-
import {focusRingStyle} from '../../styles/internal'
|
|
2
|
+
import {rem, _responsive, ThemeProps} from '../../_compat'
|
|
3
|
+
import {focusRingStyle} from '../../_compat/styles/internal'
|
|
4
4
|
import {AvatarRootStyleProps, ResponsiveAvatarSizeStyleProps} from './types'
|
|
5
5
|
|
|
6
6
|
export const avatarStyle = {
|
|
@@ -17,7 +17,8 @@ export interface BoxProps extends BoxStyleProps, GapStyleProps, PositionStylePro
|
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
19
|
export const Box = forwardRef(function Box(
|
|
20
|
-
props: BoxProps &
|
|
20
|
+
props: BoxProps &
|
|
21
|
+
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'rows' | 'wrap' | 'width'>,
|
|
21
22
|
ref: React.ForwardedRef<HTMLDivElement>,
|
|
22
23
|
) {
|
|
23
24
|
const {
|
|
@@ -43,6 +44,7 @@ export const Box = forwardRef(function Box(
|
|
|
43
44
|
marginRight,
|
|
44
45
|
marginBottom,
|
|
45
46
|
marginLeft,
|
|
47
|
+
maxWidth,
|
|
46
48
|
overflow,
|
|
47
49
|
padding = 0,
|
|
48
50
|
paddingX,
|
|
@@ -91,6 +93,7 @@ export const Box = forwardRef(function Box(
|
|
|
91
93
|
marginRight,
|
|
92
94
|
marginBottom,
|
|
93
95
|
marginLeft,
|
|
96
|
+
maxWidth,
|
|
94
97
|
padding,
|
|
95
98
|
paddingX,
|
|
96
99
|
paddingY,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {icons} from '@sanity/icons'
|
|
2
2
|
import {Button, Flex} from '@sanity/ui'
|
|
3
|
+
import {FontTextSize} from '@sanity/ui/theme'
|
|
3
4
|
import {useAction, useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
4
5
|
import {
|
|
5
6
|
WORKSHOP_BUTTON_MODE_OPTIONS,
|
|
@@ -32,7 +33,7 @@ export default function ButtonStory() {
|
|
|
32
33
|
<Flex align="center" height="fill" justify="center">
|
|
33
34
|
<Button
|
|
34
35
|
disabled={disabled}
|
|
35
|
-
fontSize={fontSize}
|
|
36
|
+
fontSize={fontSize as FontTextSize}
|
|
36
37
|
icon={icon && icons[icon]}
|
|
37
38
|
iconRight={iconRight && icons[iconRight]}
|
|
38
39
|
justify={justify}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {icons} from '@sanity/icons'
|
|
2
2
|
import {Box, Button, Card, Container, Flex, Stack} from '@sanity/ui'
|
|
3
|
+
import {FontTextSize} from '@sanity/ui/theme'
|
|
3
4
|
import {useAction, useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
4
5
|
import {
|
|
5
6
|
WORKSHOP_BUTTON_MODE_OPTIONS,
|
|
@@ -33,7 +34,7 @@ export default function StackedStory() {
|
|
|
33
34
|
{tones.map(([title, tone]) => (
|
|
34
35
|
<Button
|
|
35
36
|
disabled={disabled}
|
|
36
|
-
fontSize={fontSize}
|
|
37
|
+
fontSize={fontSize as FontTextSize}
|
|
37
38
|
icon={icon && icons[icon]}
|
|
38
39
|
iconRight={iconRight && icons[iconRight]}
|
|
39
40
|
justify={justify}
|