@sanity/ui 3.0.0-static.11 → 3.0.0-static.13
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/_visual-editing.js +1293 -1215
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-cjs/buildCommand.js +28 -10
- package/dist/_chunks-cjs/buildCommand.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +1284 -1202
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +528 -358
- package/dist/_visual-editing.d.ts +528 -358
- package/dist/cli.js +1 -1
- package/dist/css.d.mts +143 -73
- package/dist/css.d.ts +143 -73
- package/dist/css.js +329 -472
- package/dist/css.js.map +1 -1
- package/dist/css.mjs +330 -473
- package/dist/css.mjs.map +1 -1
- package/dist/index.d.mts +1362 -869
- package/dist/index.d.ts +1362 -869
- package/dist/index.js +383 -308
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +387 -312
- package/dist/index.mjs.map +1 -1
- package/dist/sanity-palette.css +105 -1
- package/dist/sanity-palette.min.css +1 -0
- package/dist/sanity-theme.css +4571 -1
- package/dist/sanity-theme.min.css +1 -0
- package/dist/system.css +22053 -21946
- package/dist/system.min.css +1 -0
- package/dist/theme.d.mts +51 -106
- package/dist/theme.d.ts +51 -106
- package/dist/theme.js +9 -9
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +9 -9
- package/dist/theme.mjs.map +1 -1
- package/package.json +10 -5
- package/src/cli/buildCommand.ts +46 -19
- package/src/css/_comp.ts +2 -2
- package/src/css/{compile/compileStyle.ts → _compileStyle.ts} +7 -7
- package/src/css/{system.style.ts → _system.style.ts} +3 -2
- package/src/css/aspects/display/display.ts +1 -0
- package/src/css/aspects/display/types.ts +2 -3
- package/src/css/aspects/flex/types.ts +4 -12
- package/src/css/aspects/flexItem/types.ts +1 -3
- package/src/css/aspects/font/types.ts +1 -3
- package/src/css/aspects/grid/grid.ts +1 -0
- package/src/css/aspects/grid/types.ts +5 -9
- package/src/css/aspects/gridItem/gridItem.ts +1 -1
- package/src/css/aspects/gridItem/types.ts +7 -18
- package/src/css/aspects/height/height.ts +3 -4
- package/src/css/aspects/inset/inset.ts +1 -0
- package/src/css/aspects/margin/margin.ts +1 -0
- package/src/css/aspects/margin/types.ts +1 -0
- package/src/css/aspects/maxWidth/maxWidth.ts +1 -0
- package/src/css/aspects/maxWidth/types.ts +1 -0
- package/src/css/aspects/minWidth/minWidth.ts +1 -0
- package/src/css/aspects/minWidth/types.ts +2 -0
- package/src/css/aspects/overflow/overflow.ts +1 -0
- package/src/css/aspects/padding/padding.ts +1 -0
- package/src/css/aspects/pointerEvents/pointerEvents.ts +1 -0
- package/src/css/aspects/position/position.ts +1 -0
- package/src/css/aspects/shadow/shadow.ts +1 -0
- package/src/css/aspects/textOverflow/textOverflow.ts +1 -0
- package/src/css/aspects/textOverflow/types.ts +1 -0
- package/src/css/aspects/width/types.ts +2 -0
- package/src/css/aspects/width/width.ts +1 -0
- package/src/css/{compile/compilePalette.ts → compilePalette.ts} +14 -10
- package/src/css/compileSystem.ts +7 -0
- package/src/css/{compile/compileTheme.ts → compileTheme.ts} +1 -0
- package/src/css/{compile/compileTheme_v3.ts → compileTheme_v3.ts} +123 -104
- package/src/css/components/breadcrumbs/breadcrumbs.ts +1 -0
- package/src/css/components/dialog/dialog.ts +7 -0
- package/src/css/components/menu/menu.ts +2 -0
- package/src/css/components/skeleton/skeleton.ts +4 -0
- package/src/css/components/skeleton/types.ts +4 -0
- package/src/css/components/toast/toast.ts +5 -0
- package/src/css/components/tree/tree.ts +1 -0
- package/src/css/composeClassNames.ts +4 -2
- package/src/css/constants.ts +2 -0
- package/src/css/index.ts +3 -3
- package/src/css/primitives/_arrow/_arrow.ts +3 -0
- package/src/css/primitives/_input/input.ts +2 -0
- package/src/css/primitives/_selectable/_selectable.style.ts +1 -2
- package/src/css/primitives/_selectable/selectable.ts +1 -2
- package/src/css/primitives/avatar/avatar.style.ts +5 -8
- package/src/css/primitives/avatar/avatar.ts +6 -0
- package/src/css/primitives/avatar/types.ts +1 -0
- package/src/css/primitives/box/types.ts +1 -3
- package/src/css/primitives/button/button.ts +4 -21
- package/src/css/primitives/button/index.ts +1 -0
- package/src/css/primitives/button/types.ts +18 -0
- package/src/css/primitives/card/card.style.ts +3 -6
- package/src/css/primitives/card/card.ts +2 -2
- package/src/css/primitives/card/types.ts +2 -2
- package/src/css/primitives/checkbox/checkbox.ts +2 -0
- package/src/css/primitives/container/container.ts +1 -0
- package/src/css/primitives/container/types.ts +1 -0
- package/src/css/primitives/kbd/kbd.ts +1 -0
- package/src/css/primitives/label/types.ts +7 -2
- package/src/css/primitives/popover/popover.ts +2 -0
- package/src/css/primitives/radio/radio.ts +1 -0
- package/src/css/primitives/select/select.ts +2 -0
- package/src/css/primitives/spinner/spinner.ts +2 -0
- package/src/css/primitives/switch/switch.ts +5 -0
- package/src/css/primitives/text/types.ts +4 -0
- package/src/css/primitives/textArea/textArea.ts +1 -0
- package/src/css/primitives/textInput/textInput.ts +1 -0
- package/src/css/primitives/tooltip/tooltip.ts +2 -0
- package/src/css/scopeClassName.ts +1 -0
- package/src/css/types.ts +9 -12
- package/src/css/util.ts +5 -0
- package/src/css/utils/srOnly/srOnly.ts +3 -1
- package/src/css/varNames.ts +131 -141
- package/src/css/vars.ts +1 -6
- package/src/theme/palette/constants.ts +2 -0
- package/src/theme/palette/types.ts +3 -0
- package/src/theme/types.ts +2 -6
- package/src/theme/v0/focusRing.ts +1 -3
- package/src/theme/v0/font.ts +6 -18
- package/src/theme/v0/layer.ts +1 -3
- package/src/theme/v0/shadow.ts +2 -6
- package/src/theme/v2/avatar.ts +1 -3
- package/src/theme/v2/color/_system.ts +1 -3
- package/src/theme/v2/color/avatar.ts +2 -6
- package/src/theme/v2/color/badge.ts +2 -6
- package/src/theme/v2/color/button.ts +3 -9
- package/src/theme/v2/color/color.ts +3 -9
- package/src/theme/v2/color/input.ts +3 -9
- package/src/theme/v2/color/kbd.ts +1 -3
- package/src/theme/v2/color/selectable.ts +2 -6
- package/src/theme/v2/color/state.ts +1 -3
- package/src/theme/v2/color/syntax.ts +1 -3
- package/src/theme/v2/input.ts +1 -3
- package/src/theme/v2/theme.ts +2 -6
- package/src/theme/v3/buildTheme_v3.ts +1 -0
- package/src/theme/v3/color/color.ts +6 -4
- package/src/theme/v3/color/renderColor.ts +4 -1
- package/src/theme/v3/defaultTokens.ts +1 -0
- package/src/theme/v3/resolveTokens.ts +9 -9
- package/src/ui/RootClassNames.tsx +3 -0
- package/src/ui/StyleTags.tsx +3 -1
- package/src/ui/_compat/theme/themeColorProvider.tsx +2 -6
- package/src/ui/_compat/theme/themeProvider.tsx +2 -6
- package/src/ui/_compat/theme/types.ts +1 -3
- package/src/ui/_compat/theme/useRootTheme.ts +1 -3
- package/src/ui/_compat/theme/useTheme.ts +2 -6
- package/src/ui/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
- package/src/ui/components/autocomplete/autocomplete.tsx +86 -114
- package/src/ui/components/autocomplete/autocompleteOption.tsx +2 -0
- package/src/ui/components/autocomplete/types.ts +3 -8
- package/src/ui/components/breadcrumbs/breadcrumbs.tsx +27 -21
- package/src/ui/components/dialog/dialog.tsx +89 -291
- package/src/ui/components/dialog/dialogCard.tsx +183 -0
- package/src/ui/components/dialog/isTargetWithinScope.ts +14 -0
- package/src/ui/components/hotkeys/hotkeys.tsx +33 -15
- package/src/ui/components/menu/__workshop__/asComponent.tsx +6 -6
- package/src/ui/components/menu/menu.tsx +27 -33
- package/src/ui/components/menu/menuButton.tsx +10 -14
- package/src/ui/components/menu/menuDivider.tsx +25 -13
- package/src/ui/components/menu/menuGroup.tsx +34 -26
- package/src/ui/components/menu/menuItem.tsx +51 -40
- package/src/ui/components/skeleton/codeSkeleton.tsx +53 -0
- package/src/ui/components/skeleton/headingSkeleton.tsx +52 -0
- package/src/ui/components/skeleton/index.ts +3 -0
- package/src/ui/components/skeleton/labelSkeleton.tsx +51 -0
- package/src/ui/components/skeleton/skeleton.tsx +39 -16
- package/src/ui/components/skeleton/textSkeleton.tsx +31 -110
- package/src/ui/components/tab/tab.tsx +23 -19
- package/src/ui/components/tab/tabList.tsx +34 -33
- package/src/ui/components/tab/tabPanel.tsx +25 -19
- package/src/ui/components/toast/toast.tsx +21 -16
- package/src/ui/components/toast/toastLayer.tsx +28 -10
- package/src/ui/components/toast/toastProvider.tsx +2 -6
- package/src/ui/components/toast/types.ts +2 -6
- package/src/ui/components/toast/useToast.ts +1 -3
- package/src/ui/components/tree/tree.tsx +194 -187
- package/src/ui/components/tree/treeGroup.tsx +25 -5
- package/src/ui/components/tree/treeItem.tsx +35 -23
- package/src/ui/hooks/useClickOutside.ts +2 -6
- package/src/ui/hooks/useClickOutsideEvent.ts +3 -9
- package/src/ui/primitives/_selectable/selectable.tsx +33 -20
- package/src/ui/primitives/avatar/avatar.tsx +28 -31
- package/src/ui/primitives/avatar/avatarCounter.tsx +33 -25
- package/src/ui/primitives/avatar/avatarStack.tsx +31 -24
- package/src/ui/primitives/avatar/types.ts +2 -0
- package/src/ui/primitives/badge/__workshop__/props.tsx +1 -9
- package/src/ui/primitives/badge/__workshop__/tones.tsx +1 -6
- package/src/ui/primitives/badge/badge.tsx +33 -32
- package/src/ui/primitives/badge/types.ts +2 -1
- package/src/ui/primitives/box/box.tsx +59 -29
- package/src/ui/primitives/button/__workshop__/sanityUploadButton.tsx +3 -3
- package/src/ui/primitives/button/__workshop__/uploadButton.tsx +2 -1
- package/src/ui/primitives/button/button.test.tsx +1 -15
- package/src/ui/primitives/button/button.tsx +64 -70
- package/src/ui/primitives/card/__workshop__/asComponent.tsx +3 -3
- package/src/ui/primitives/card/card.tsx +22 -22
- package/src/ui/primitives/card/cardProvider.tsx +2 -0
- package/src/ui/primitives/checkbox/checkbox.tsx +26 -15
- package/src/ui/primitives/code/code.tsx +24 -22
- package/src/ui/primitives/container/container.tsx +26 -15
- package/src/ui/primitives/flex/flex.tsx +21 -19
- package/src/ui/primitives/grid/grid.tsx +21 -16
- package/src/ui/primitives/heading/heading.tsx +42 -19
- package/src/ui/primitives/inline/inline.tsx +26 -23
- package/src/ui/primitives/kbd/kbd.tsx +25 -23
- package/src/ui/primitives/label/label.tsx +41 -26
- package/src/ui/primitives/popover/popover.tsx +281 -277
- package/src/ui/primitives/popover/popoverCard.tsx +119 -118
- package/src/ui/primitives/radio/radio.tsx +30 -14
- package/src/ui/primitives/select/select.tsx +24 -16
- package/src/ui/primitives/spinner/animatedSpinnerIcon.tsx +4 -2
- package/src/ui/primitives/spinner/spinner.tsx +24 -12
- package/src/ui/primitives/stack/stack.tsx +27 -18
- package/src/ui/primitives/switch/switch.tsx +31 -14
- package/src/ui/primitives/text/text.tsx +42 -24
- package/src/ui/primitives/textArea/textArea.tsx +33 -18
- package/src/ui/primitives/textInput/textInput.tsx +28 -40
- package/src/ui/primitives/tooltip/constants.ts +1 -1
- package/src/ui/primitives/tooltip/tooltip.tsx +76 -59
- package/src/ui/primitives/tooltip/tooltipCard.tsx +89 -82
- package/src/ui/primitives/types.ts +1 -3
- package/src/ui/types/avatar.ts +3 -6
- package/src/ui/types/badge.ts +1 -3
- package/src/ui/types/button.ts +1 -3
- package/src/ui/types/card.ts +1 -3
- package/src/ui/types/dialog.ts +1 -3
- package/src/ui/types/props.ts +20 -10
- package/src/ui/utils/arrow/arrow.tsx +40 -14
- package/src/ui/utils/boundaryElement/boundaryElementProvider.tsx +2 -6
- package/src/ui/utils/boundaryElement/types.ts +1 -3
- package/src/ui/utils/boundaryElement/useBoundaryElement.ts +1 -3
- package/src/ui/utils/elementQuery/elementQuery.tsx +36 -14
- package/src/ui/utils/errorBoundary.tsx +2 -0
- package/src/ui/utils/index.ts +0 -1
- package/src/ui/utils/layer/layer.tsx +23 -93
- package/src/ui/utils/layer/layerCard.tsx +92 -0
- package/src/ui/utils/layer/layerProvider.tsx +2 -6
- package/src/ui/utils/layer/useLayer.ts +1 -3
- package/src/ui/utils/portal/portal.ts +2 -6
- package/src/ui/utils/portal/portalProvider.tsx +2 -6
- package/src/ui/utils/portal/types.ts +1 -3
- package/src/ui/utils/portal/usePortal.ts +1 -3
- package/src/ui/utils/srOnly/srOnly.tsx +25 -20
- package/src/ui/utils/virtualList/virtualList.tsx +36 -24
- package/src/css/compile/compileRule.ts +0 -97
- package/src/css/compile/compileRules.test.ts +0 -36
- package/src/css/compile/compileRules.ts +0 -43
- package/src/css/compile/compileSystem.ts +0 -7
- package/src/css/compile/types.ts +0 -6
- package/src/css/primitives/_selectable/_contants.ts +0 -11
- package/src/css/primitives/card/_constants.ts +0 -13
- package/src/ui/utils/conditionalWrapper/conditionalWrapper.tsx +0 -23
- package/src/ui/utils/conditionalWrapper/index.ts +0 -1
|
@@ -1,132 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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'
|
|
10
|
-
import {ForwardedRef, forwardRef} from 'react'
|
|
1
|
+
import {composeClassNames, ResponsiveProp, textSkeleton} from '@sanity/ui/css'
|
|
2
|
+
import {FontTextSize} from '@sanity/ui/theme'
|
|
11
3
|
|
|
12
4
|
import {Props} from '../../types'
|
|
13
|
-
import {Skeleton,
|
|
5
|
+
import {Skeleton, SkeletonElementType, SkeletonOwnProps} from './skeleton'
|
|
14
6
|
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
* @beta
|
|
18
|
-
*/
|
|
19
|
-
export interface TextSkeletonProps extends SkeletonProps {
|
|
20
|
-
size?: ResponsiveProp<FontTextSize>
|
|
21
|
-
}
|
|
7
|
+
/** @public */
|
|
8
|
+
export const DEFAULT_TEXT_SKELETON_ELEMENT = 'div'
|
|
22
9
|
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*/
|
|
27
|
-
export interface LabelSkeletonProps extends SkeletonProps {
|
|
28
|
-
size?: ResponsiveProp<FontLabelSize>
|
|
10
|
+
/** @beta */
|
|
11
|
+
export type TextSkeletonOwnProps = SkeletonOwnProps & {
|
|
12
|
+
size?: ResponsiveProp<FontTextSize>
|
|
29
13
|
}
|
|
30
14
|
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
* @beta
|
|
34
|
-
*/
|
|
35
|
-
export interface HeadingSkeletonProps extends SkeletonProps {
|
|
36
|
-
size?: ResponsiveProp<FontHeadingSize>
|
|
37
|
-
}
|
|
15
|
+
/** @public */
|
|
16
|
+
export type TextSkeletonElementType = SkeletonElementType
|
|
38
17
|
|
|
39
18
|
/**
|
|
40
19
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
41
20
|
* @beta
|
|
42
21
|
*/
|
|
43
|
-
export
|
|
44
|
-
|
|
45
|
-
|
|
22
|
+
export type TextSkeletonProps<E extends TextSkeletonElementType = TextSkeletonElementType> = Props<
|
|
23
|
+
TextSkeletonOwnProps,
|
|
24
|
+
E
|
|
25
|
+
>
|
|
46
26
|
|
|
47
27
|
/**
|
|
48
28
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
49
29
|
* @beta
|
|
50
30
|
*/
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
31
|
+
export function TextSkeleton<
|
|
32
|
+
E extends TextSkeletonElementType = typeof DEFAULT_TEXT_SKELETON_ELEMENT,
|
|
33
|
+
>(props: TextSkeletonProps<E>) {
|
|
34
|
+
const {
|
|
35
|
+
className,
|
|
36
|
+
size = 2,
|
|
37
|
+
...rest
|
|
38
|
+
} = props as TextSkeletonProps<typeof DEFAULT_TEXT_SKELETON_ELEMENT>
|
|
56
39
|
|
|
57
40
|
return (
|
|
58
41
|
<Skeleton
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
42
|
+
{...rest}
|
|
43
|
+
className={composeClassNames(
|
|
44
|
+
className,
|
|
45
|
+
textSkeleton({
|
|
46
|
+
size,
|
|
47
|
+
}),
|
|
48
|
+
)}
|
|
63
49
|
/>
|
|
64
50
|
)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
TextSkeleton.displayName = 'ForwardRef(TextSkeleton)'
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
71
|
-
* @beta
|
|
72
|
-
*/
|
|
73
|
-
export const LabelSkeleton = forwardRef(function TextSkeleton(
|
|
74
|
-
props: Props<LabelSkeletonProps, 'div'>,
|
|
75
|
-
ref: ForwardedRef<HTMLDivElement>,
|
|
76
|
-
) {
|
|
77
|
-
const {className, size = 2, ...restProps} = props
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<Skeleton
|
|
81
|
-
data-ui="LabelSkeleton"
|
|
82
|
-
{...restProps}
|
|
83
|
-
className={composeClassNames(className, labelSkeleton({size}))}
|
|
84
|
-
ref={ref}
|
|
85
|
-
/>
|
|
86
|
-
)
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
LabelSkeleton.displayName = 'ForwardRef(LabelSkeleton)'
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
93
|
-
* @beta
|
|
94
|
-
*/
|
|
95
|
-
export const HeadingSkeleton = forwardRef(function TextSkeleton(
|
|
96
|
-
props: Props<HeadingSkeletonProps, 'div'>,
|
|
97
|
-
ref: ForwardedRef<HTMLDivElement>,
|
|
98
|
-
) {
|
|
99
|
-
const {className, size = 2, ...restProps} = props
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<Skeleton
|
|
103
|
-
{...restProps}
|
|
104
|
-
className={composeClassNames(className, headingSkeleton({size}))}
|
|
105
|
-
ref={ref}
|
|
106
|
-
/>
|
|
107
|
-
)
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
HeadingSkeleton.displayName = 'ForwardRef(HeadingSkeleton)'
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* This API might change. DO NOT USE IN PRODUCTION.
|
|
114
|
-
* @beta
|
|
115
|
-
*/
|
|
116
|
-
export const CodeSkeleton = forwardRef(function TextSkeleton(
|
|
117
|
-
props: Props<CodeSkeletonProps, 'div'>,
|
|
118
|
-
ref: ForwardedRef<HTMLDivElement>,
|
|
119
|
-
) {
|
|
120
|
-
const {className, size = 2, ...restProps} = props
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<Skeleton
|
|
124
|
-
// root
|
|
125
|
-
{...restProps}
|
|
126
|
-
className={composeClassNames(className, codeSkeleton({size}))}
|
|
127
|
-
ref={ref}
|
|
128
|
-
/>
|
|
129
|
-
)
|
|
130
|
-
})
|
|
51
|
+
}
|
|
131
52
|
|
|
132
|
-
|
|
53
|
+
TextSkeleton.displayName = 'TextSkeleton'
|
|
@@ -3,8 +3,6 @@ import {FontTextSize, Space} from '@sanity/ui/theme'
|
|
|
3
3
|
import {
|
|
4
4
|
ElementType,
|
|
5
5
|
FocusEvent,
|
|
6
|
-
ForwardedRef,
|
|
7
|
-
forwardRef,
|
|
8
6
|
ReactNode,
|
|
9
7
|
useCallback,
|
|
10
8
|
useEffect,
|
|
@@ -13,12 +11,13 @@ import {
|
|
|
13
11
|
} from 'react'
|
|
14
12
|
|
|
15
13
|
import {Button} from '../../primitives'
|
|
16
|
-
import {ButtonTone, Props} from '../../types'
|
|
14
|
+
import {ButtonTone, ComponentType, Props} from '../../types'
|
|
17
15
|
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
/** @public */
|
|
17
|
+
export const DEFAULT_TAB_ELEMENT = 'button'
|
|
18
|
+
|
|
19
|
+
/** @public */
|
|
20
|
+
export type TabOwnProps = {
|
|
22
21
|
/**
|
|
23
22
|
* The `id` of the corresponding `TabPanel` component.
|
|
24
23
|
*/
|
|
@@ -33,14 +32,16 @@ export interface TabProps {
|
|
|
33
32
|
'tone'?: ButtonTone
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
/** @public */
|
|
36
|
+
export type TabElementType = 'button' | ComponentType
|
|
37
|
+
|
|
38
|
+
/** @public */
|
|
39
|
+
export type TabProps<E extends TabElementType = TabElementType> = Props<TabOwnProps, E>
|
|
40
|
+
|
|
41
|
+
/** @public */
|
|
42
|
+
export function Tab<E extends TabElementType = typeof DEFAULT_TAB_ELEMENT>(props: TabProps<E>) {
|
|
43
43
|
const {
|
|
44
|
+
as = DEFAULT_TAB_ELEMENT,
|
|
44
45
|
icon,
|
|
45
46
|
id,
|
|
46
47
|
focused,
|
|
@@ -49,9 +50,11 @@ export const Tab = forwardRef(function Tab(
|
|
|
49
50
|
onClick,
|
|
50
51
|
onFocus,
|
|
51
52
|
padding = 2,
|
|
53
|
+
ref: forwardedRef,
|
|
52
54
|
selected,
|
|
53
|
-
...
|
|
54
|
-
} = props
|
|
55
|
+
...rest
|
|
56
|
+
} = props as TabProps<typeof DEFAULT_TAB_ELEMENT>
|
|
57
|
+
|
|
55
58
|
const ref = useRef<HTMLButtonElement | null>(null)
|
|
56
59
|
const focusedRef = useRef(false)
|
|
57
60
|
|
|
@@ -82,8 +85,9 @@ export const Tab = forwardRef(function Tab(
|
|
|
82
85
|
return (
|
|
83
86
|
<Button
|
|
84
87
|
data-ui="Tab"
|
|
85
|
-
{...
|
|
88
|
+
{...rest}
|
|
86
89
|
aria-selected={selected ? 'true' : 'false'}
|
|
90
|
+
as={as}
|
|
87
91
|
fontSize={fontSize}
|
|
88
92
|
icon={icon}
|
|
89
93
|
id={id}
|
|
@@ -100,6 +104,6 @@ export const Tab = forwardRef(function Tab(
|
|
|
100
104
|
type="button"
|
|
101
105
|
/>
|
|
102
106
|
)
|
|
103
|
-
}
|
|
107
|
+
}
|
|
104
108
|
|
|
105
|
-
Tab.displayName = '
|
|
109
|
+
Tab.displayName = 'Tab'
|
|
@@ -1,42 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
forwardRef,
|
|
6
|
-
KeyboardEvent,
|
|
7
|
-
ReactElement,
|
|
8
|
-
useCallback,
|
|
9
|
-
useState,
|
|
10
|
-
} from 'react'
|
|
11
|
-
|
|
12
|
-
import {Inline, InlineProps} from '../../primitives'
|
|
13
|
-
import {Props} from '../../types'
|
|
1
|
+
import {Children, cloneElement, KeyboardEvent, ReactElement, useCallback, useState} from 'react'
|
|
2
|
+
|
|
3
|
+
import {Inline, InlineOwnProps} from '../../primitives'
|
|
4
|
+
import {ComponentType, Props} from '../../types'
|
|
14
5
|
import {TabProps} from './tab'
|
|
15
6
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
/** @public */
|
|
8
|
+
export const DEFAULT_TAB_LIST_ELEMENT = 'div'
|
|
9
|
+
|
|
10
|
+
/** @public */
|
|
19
11
|
export type TabListChild = ReactElement<Props<TabProps, 'button'>> | null | undefined | false
|
|
20
12
|
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
export interface TabListProps extends Omit<InlineProps, 'as' | 'height'> {
|
|
13
|
+
/** @public */
|
|
14
|
+
export type TabListOwnProps = Omit<InlineOwnProps, 'as' | 'height'> & {
|
|
25
15
|
children: TabListChild[]
|
|
26
16
|
}
|
|
27
17
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
/** @public */
|
|
19
|
+
export type TabListElementType = 'div' | 'span' | ComponentType
|
|
20
|
+
|
|
21
|
+
/** @public */
|
|
22
|
+
export type TabListProps<E extends TabListElementType = TabListElementType> = Props<
|
|
23
|
+
TabListOwnProps,
|
|
24
|
+
E
|
|
25
|
+
>
|
|
31
26
|
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export const TabList = forwardRef(function TabList(
|
|
36
|
-
props: Props<TabListProps, 'div'>,
|
|
37
|
-
ref: ForwardedRef<HTMLDivElement>,
|
|
27
|
+
/** @public */
|
|
28
|
+
export function TabList<E extends TabListElementType = typeof DEFAULT_TAB_LIST_ELEMENT>(
|
|
29
|
+
props: TabListProps<E>,
|
|
38
30
|
) {
|
|
39
|
-
const {
|
|
31
|
+
const {
|
|
32
|
+
as = DEFAULT_TAB_LIST_ELEMENT,
|
|
33
|
+
children: childrenProp,
|
|
34
|
+
...rest
|
|
35
|
+
} = props as TabListProps<typeof DEFAULT_TAB_LIST_ELEMENT>
|
|
36
|
+
|
|
40
37
|
const [focusedIndex, setFocusedIndex] = useState(-1)
|
|
41
38
|
|
|
42
39
|
const children = Children.toArray(childrenProp).filter(_isReactElement)
|
|
@@ -65,10 +62,14 @@ export const TabList = forwardRef(function TabList(
|
|
|
65
62
|
)
|
|
66
63
|
|
|
67
64
|
return (
|
|
68
|
-
<Inline data-ui="TabList" {...
|
|
65
|
+
<Inline data-ui="TabList" {...rest} as={as} onKeyDown={handleKeyDown} role="tablist">
|
|
69
66
|
{tabs}
|
|
70
67
|
</Inline>
|
|
71
68
|
)
|
|
72
|
-
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
TabList.displayName = 'TabList'
|
|
73
72
|
|
|
74
|
-
|
|
73
|
+
function _isReactElement(node: unknown): node is ReactElement<Props<TabProps, 'button'>> {
|
|
74
|
+
return Boolean(node)
|
|
75
|
+
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Box, BoxOwnProps} from '../../primitives'
|
|
2
|
+
import {ComponentType, Props} from '../../types'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
/** @public */
|
|
5
|
+
export const DEFAULT_TAB_PANEL_ELEMENT = 'div'
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
export interface TabPanelProps extends BoxProps {
|
|
7
|
+
/** @public */
|
|
8
|
+
export type TabPanelOwnProps = BoxOwnProps & {
|
|
10
9
|
/**
|
|
11
10
|
* The `id` of the correlating `Tab` component.
|
|
12
11
|
*/
|
|
@@ -14,27 +13,34 @@ export interface TabPanelProps extends BoxProps {
|
|
|
14
13
|
'id': string
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
/** @public */
|
|
17
|
+
export type TabPanelElementType = 'div' | 'span' | ComponentType
|
|
18
|
+
|
|
19
|
+
/** @public */
|
|
20
|
+
export type TabPanelProps<E extends TabPanelElementType = TabPanelElementType> = Props<
|
|
21
|
+
TabPanelOwnProps,
|
|
22
|
+
E
|
|
23
|
+
>
|
|
24
|
+
|
|
25
|
+
/** @public */
|
|
26
|
+
export function TabPanel<E extends TabPanelElementType = typeof DEFAULT_TAB_PANEL_ELEMENT>(
|
|
27
|
+
props: TabPanelProps<E>,
|
|
23
28
|
) {
|
|
24
|
-
const {
|
|
29
|
+
const {as = DEFAULT_TAB_PANEL_ELEMENT, ...rest} = props as TabPanelProps<
|
|
30
|
+
typeof DEFAULT_TAB_PANEL_ELEMENT
|
|
31
|
+
>
|
|
25
32
|
|
|
26
33
|
return (
|
|
27
34
|
<Box
|
|
28
35
|
data-ui="TabPanel"
|
|
29
|
-
{...
|
|
30
|
-
|
|
31
|
-
ref={ref}
|
|
36
|
+
{...rest}
|
|
37
|
+
as={as}
|
|
32
38
|
role="tabpanel"
|
|
33
39
|
tabIndex={props.tabIndex === undefined ? 0 : props.tabIndex}
|
|
34
40
|
>
|
|
35
41
|
{props.children}
|
|
36
42
|
</Box>
|
|
37
43
|
)
|
|
38
|
-
}
|
|
44
|
+
}
|
|
39
45
|
|
|
40
|
-
TabPanel.displayName = '
|
|
46
|
+
TabPanel.displayName = 'TabPanel'
|
|
@@ -8,16 +8,17 @@ import {
|
|
|
8
8
|
} from '@sanity/ui/css'
|
|
9
9
|
import {ThemeColorStateToneKey} from '@sanity/ui/theme'
|
|
10
10
|
import {motion, type Variant, type Variants} from 'framer-motion'
|
|
11
|
-
import {
|
|
11
|
+
import {ReactNode} from 'react'
|
|
12
12
|
|
|
13
13
|
import {usePrefersReducedMotion} from '../../hooks/usePrefersReducedMotion'
|
|
14
14
|
import {Box, Button, Card, Flex, Stack, Text} from '../../primitives'
|
|
15
|
-
import {ButtonTone, Props} from '../../types'
|
|
15
|
+
import {ButtonTone, ComponentType, Props} from '../../types'
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/** @public */
|
|
18
|
+
export const DEFAULT_TOAST_ELEMENT = 'li'
|
|
19
|
+
|
|
20
|
+
/** @public */
|
|
21
|
+
export type ToastOwnProps = RadiusStyleProps & {
|
|
21
22
|
closable?: boolean
|
|
22
23
|
description?: ReactNode
|
|
23
24
|
onClose?: () => void
|
|
@@ -27,6 +28,12 @@ export interface ToastProps extends RadiusStyleProps {
|
|
|
27
28
|
updatedAt?: number
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
/** @public */
|
|
32
|
+
export type ToastElementType = 'li' | ComponentType
|
|
33
|
+
|
|
34
|
+
/** @public */
|
|
35
|
+
export type ToastProps<E extends ToastElementType = ToastElementType> = Props<ToastOwnProps, E>
|
|
36
|
+
|
|
30
37
|
const ROLES = {
|
|
31
38
|
error: 'alert',
|
|
32
39
|
warning: 'alert',
|
|
@@ -59,13 +66,11 @@ const LONG_ENOUGH_BUT_NOT_TOO_LONG = 1000 * 60 * 60 * 24 * 24
|
|
|
59
66
|
*
|
|
60
67
|
* @public
|
|
61
68
|
*/
|
|
62
|
-
export function Toast(
|
|
63
|
-
props:
|
|
64
|
-
|
|
65
|
-
'onDrag' | 'onDragEnd' | 'onDragStart' | 'onAnimationStart'
|
|
66
|
-
>,
|
|
67
|
-
): ReactElement {
|
|
69
|
+
export function Toast<E extends ToastElementType = typeof DEFAULT_TOAST_ELEMENT>(
|
|
70
|
+
props: ToastProps<E>,
|
|
71
|
+
) {
|
|
68
72
|
const {
|
|
73
|
+
as = DEFAULT_TOAST_ELEMENT,
|
|
69
74
|
closable,
|
|
70
75
|
description,
|
|
71
76
|
duration,
|
|
@@ -74,8 +79,8 @@ export function Toast(
|
|
|
74
79
|
title,
|
|
75
80
|
status,
|
|
76
81
|
updatedAt,
|
|
77
|
-
...
|
|
78
|
-
} = props
|
|
82
|
+
...rest
|
|
83
|
+
} = props as ToastProps<typeof DEFAULT_TOAST_ELEMENT>
|
|
79
84
|
|
|
80
85
|
const cardTone = status ? STATUS_CARD_TONE[status] : 'default'
|
|
81
86
|
const buttonTone = status ? BUTTON_TONE[status] : 'default'
|
|
@@ -93,11 +98,11 @@ export function Toast(
|
|
|
93
98
|
|
|
94
99
|
return (
|
|
95
100
|
<MotionCard
|
|
96
|
-
as=
|
|
101
|
+
as={as}
|
|
97
102
|
className={toast()}
|
|
98
103
|
data-ui="Toast"
|
|
99
104
|
role={role}
|
|
100
|
-
{...
|
|
105
|
+
{...rest}
|
|
101
106
|
data-has-duration={hasDuration ? '' : undefined}
|
|
102
107
|
custom={visualDuration}
|
|
103
108
|
radius={radius}
|
|
@@ -1,26 +1,44 @@
|
|
|
1
1
|
import {GapStyleProps, PaddingStyleProps, toastLayer} from '@sanity/ui/css'
|
|
2
|
-
import {ReactNode} from 'react'
|
|
3
2
|
|
|
4
3
|
import {Grid} from '../../primitives/grid'
|
|
4
|
+
import {ComponentType, Props} from '../../types'
|
|
5
5
|
import {useLayer} from '../../utils'
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
/** @internal */
|
|
8
|
+
export const DEFAULT_TOAST_LAYER_ELEMENT = 'ul'
|
|
9
|
+
|
|
10
|
+
/** @internal */
|
|
11
|
+
export type ToastLayerOwnProps = GapStyleProps & PaddingStyleProps
|
|
12
|
+
|
|
13
|
+
/** @internal */
|
|
14
|
+
export type ToastLayerElementType = 'ul' | ComponentType
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export type ToastLayerProps<E extends ToastLayerElementType = ToastLayerElementType> = Props<
|
|
18
|
+
ToastLayerOwnProps,
|
|
19
|
+
E
|
|
20
|
+
>
|
|
13
21
|
|
|
14
22
|
/**
|
|
15
23
|
* @internal
|
|
16
24
|
*/
|
|
17
|
-
export function ToastLayer
|
|
18
|
-
|
|
25
|
+
export function ToastLayer<E extends ToastLayerElementType = typeof DEFAULT_TOAST_LAYER_ELEMENT>(
|
|
26
|
+
props: ToastLayerProps<E>,
|
|
27
|
+
) {
|
|
28
|
+
const {
|
|
29
|
+
as = DEFAULT_TOAST_LAYER_ELEMENT,
|
|
30
|
+
children,
|
|
31
|
+
padding = 4,
|
|
32
|
+
paddingX,
|
|
33
|
+
paddingY,
|
|
34
|
+
gap = 3,
|
|
35
|
+
} = props as ToastLayerProps<typeof DEFAULT_TOAST_LAYER_ELEMENT>
|
|
36
|
+
|
|
19
37
|
const {zIndex} = useLayer()
|
|
20
38
|
|
|
21
39
|
return (
|
|
22
40
|
<Grid
|
|
23
|
-
as=
|
|
41
|
+
as={as}
|
|
24
42
|
className={toastLayer()}
|
|
25
43
|
data-ui="ToastProvider"
|
|
26
44
|
padding={padding}
|
|
@@ -16,17 +16,13 @@ type ToastState = {
|
|
|
16
16
|
params: ToastParams
|
|
17
17
|
}[]
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
19
|
+
/** @public */
|
|
22
20
|
export interface ToastProviderProps extends Omit<ToastLayerProps, 'children'> {
|
|
23
21
|
children?: React.ReactNode
|
|
24
22
|
zOffset?: number | number[]
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
/**
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
25
|
+
/** @public */
|
|
30
26
|
export function ToastProvider(props: ToastProviderProps): React.JSX.Element {
|
|
31
27
|
const {children, padding, paddingX, paddingY, gap, zOffset = 1} = props
|
|
32
28
|
const [state, setState] = useState<ToastState>([])
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {ReactNode} from 'react'
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @public
|
|
5
|
-
*/
|
|
3
|
+
/** @public */
|
|
6
4
|
export interface ToastParams {
|
|
7
5
|
closable?: boolean
|
|
8
6
|
description?: ReactNode
|
|
@@ -13,9 +11,7 @@ export interface ToastParams {
|
|
|
13
11
|
status?: 'error' | 'warning' | 'success' | 'info'
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
/**
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
14
|
+
/** @public */
|
|
19
15
|
export interface ToastContextValue {
|
|
20
16
|
version: 0.0
|
|
21
17
|
/**
|
|
@@ -4,9 +4,7 @@ import {isRecord} from '../../lib/isRecord'
|
|
|
4
4
|
import {ToastContext} from './toastContext'
|
|
5
5
|
import {ToastContextValue} from './types'
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
7
|
+
/** @public */
|
|
10
8
|
export function useToast(): ToastContextValue {
|
|
11
9
|
const value = useContext(ToastContext)
|
|
12
10
|
|