@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,12 +1,12 @@
|
|
|
1
1
|
import {Strategy} from '@floating-ui/react-dom'
|
|
2
2
|
import {popoverCard} from '@sanity/ui/css'
|
|
3
|
-
import {motion
|
|
4
|
-
import {CSSProperties, ForwardedRef,
|
|
3
|
+
import {motion} from 'framer-motion'
|
|
4
|
+
import {CSSProperties, ForwardedRef, useMemo} from 'react'
|
|
5
5
|
|
|
6
6
|
import {POPOVER_MOTION_PROPS} from '../../constants'
|
|
7
7
|
import {Placement, PopoverMargins, Props} from '../../types'
|
|
8
8
|
import {Arrow, useLayer} from '../../utils'
|
|
9
|
-
import {Card,
|
|
9
|
+
import {Card, CardElementType, CardOwnProps} from '../card'
|
|
10
10
|
import {Flex} from '../flex'
|
|
11
11
|
import {
|
|
12
12
|
DEFAULT_POPOVER_ARROW_HEIGHT,
|
|
@@ -16,7 +16,10 @@ import {
|
|
|
16
16
|
} from './constants'
|
|
17
17
|
|
|
18
18
|
/** @internal */
|
|
19
|
-
export
|
|
19
|
+
export const DEFAULT_POPOVER_CARD_ELEMENT = 'div'
|
|
20
|
+
|
|
21
|
+
/** @internal */
|
|
22
|
+
export type PopoverCardOwnProps = CardOwnProps & {
|
|
20
23
|
/** @beta*/
|
|
21
24
|
__unstable_margins?: PopoverMargins
|
|
22
25
|
animate?: boolean
|
|
@@ -33,130 +36,128 @@ export interface PopoverCardProps extends CardProps {
|
|
|
33
36
|
y: number | null
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
/** @internal */
|
|
40
|
+
export type PopoverCardElementType = CardElementType
|
|
37
41
|
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
props: Props<PopoverCardProps, 'div'>,
|
|
44
|
-
ref: ForwardedRef<HTMLDivElement>,
|
|
45
|
-
) {
|
|
46
|
-
const {
|
|
47
|
-
__unstable_margins: marginsProp,
|
|
48
|
-
animate,
|
|
49
|
-
arrow,
|
|
50
|
-
arrowRef,
|
|
51
|
-
arrowX,
|
|
52
|
-
arrowY,
|
|
53
|
-
children,
|
|
54
|
-
maxWidth,
|
|
55
|
-
padding,
|
|
56
|
-
placement,
|
|
57
|
-
originX,
|
|
58
|
-
originY,
|
|
59
|
-
overflow,
|
|
60
|
-
radius,
|
|
61
|
-
referenceWidth,
|
|
62
|
-
// scheme: schemeProp,
|
|
63
|
-
shadow,
|
|
64
|
-
strategy,
|
|
65
|
-
style,
|
|
66
|
-
tone = 'inherit',
|
|
67
|
-
// width,
|
|
68
|
-
x: xProp,
|
|
69
|
-
y: yProp,
|
|
70
|
-
...restProps
|
|
71
|
-
} = props
|
|
42
|
+
/** @internal */
|
|
43
|
+
export type PopoverCardProps<E extends PopoverCardElementType = PopoverCardElementType> = Props<
|
|
44
|
+
PopoverCardOwnProps,
|
|
45
|
+
E
|
|
46
|
+
>
|
|
72
47
|
|
|
73
|
-
|
|
48
|
+
const MotionCard = motion.create(Card)
|
|
74
49
|
|
|
75
|
-
|
|
76
|
-
|
|
50
|
+
/** @internal */
|
|
51
|
+
export function PopoverCard<E extends PopoverCardElementType = typeof DEFAULT_POPOVER_CARD_ELEMENT>(
|
|
52
|
+
props: PopoverCardProps<E>,
|
|
53
|
+
) {
|
|
54
|
+
const {
|
|
55
|
+
__unstable_margins: marginsProp,
|
|
56
|
+
animate,
|
|
57
|
+
arrow,
|
|
58
|
+
arrowRef,
|
|
59
|
+
arrowX,
|
|
60
|
+
arrowY,
|
|
61
|
+
as = DEFAULT_POPOVER_CARD_ELEMENT,
|
|
62
|
+
children,
|
|
63
|
+
maxWidth,
|
|
64
|
+
padding,
|
|
65
|
+
placement,
|
|
66
|
+
originX,
|
|
67
|
+
originY,
|
|
68
|
+
overflow,
|
|
69
|
+
radius,
|
|
70
|
+
referenceWidth,
|
|
71
|
+
shadow,
|
|
72
|
+
strategy,
|
|
73
|
+
style,
|
|
74
|
+
tone = 'inherit',
|
|
75
|
+
x: xProp,
|
|
76
|
+
y: yProp,
|
|
77
|
+
...rest
|
|
78
|
+
} = props as PopoverCardProps<typeof DEFAULT_POPOVER_CARD_ELEMENT>
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
const layer = useLayer()
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
// Get margins: [top, right, bottom, left]
|
|
83
|
+
const margins: PopoverMargins = useMemo(
|
|
84
|
+
() => marginsProp || DEFAULT_POPOVER_MARGINS,
|
|
85
|
+
[marginsProp],
|
|
86
|
+
)
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
// Translate according to margins
|
|
89
|
+
const x = (xProp ?? 0) + margins[3]
|
|
90
|
+
const y = (yProp ?? 0) + margins[0]
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
const rootStyle: CSSProperties = useMemo(
|
|
93
|
+
() => ({
|
|
94
|
+
left: x,
|
|
95
|
+
originX,
|
|
96
|
+
originY,
|
|
97
|
+
position: strategy,
|
|
98
|
+
top: y,
|
|
99
|
+
width: referenceWidth,
|
|
100
|
+
zIndex: layer.zIndex ?? 100,
|
|
101
|
+
willChange: animate ? 'transform' : undefined,
|
|
102
|
+
...style,
|
|
103
|
+
}),
|
|
104
|
+
[animate, layer.zIndex, originX, originY, referenceWidth, strategy, style, x, y],
|
|
105
|
+
)
|
|
104
106
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
const arrowStyle: CSSProperties = useMemo(
|
|
108
|
+
() => ({
|
|
109
|
+
left: arrowX !== null ? arrowX : undefined,
|
|
110
|
+
top: arrowY !== null ? arrowY : undefined,
|
|
111
|
+
right: undefined,
|
|
112
|
+
bottom: undefined,
|
|
113
|
+
}),
|
|
114
|
+
[arrowX, arrowY],
|
|
115
|
+
)
|
|
114
116
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
return (
|
|
118
|
+
<MotionCard
|
|
119
|
+
className={popoverCard()}
|
|
120
|
+
data-ui="Popover"
|
|
121
|
+
{...rest}
|
|
122
|
+
as={as}
|
|
123
|
+
data-context-tone={tone}
|
|
124
|
+
data-placement={placement}
|
|
125
|
+
direction="column"
|
|
126
|
+
display="flex"
|
|
127
|
+
radius={radius}
|
|
128
|
+
shadow={shadow}
|
|
129
|
+
sizing="border"
|
|
130
|
+
style={rootStyle}
|
|
131
|
+
tone={tone}
|
|
132
|
+
variants={POPOVER_MOTION_PROPS.card}
|
|
133
|
+
transition={POPOVER_MOTION_PROPS.transition}
|
|
134
|
+
initial={animate ? ['hidden', 'initial'] : undefined}
|
|
135
|
+
animate={animate ? ['visible', 'scaleIn'] : undefined}
|
|
136
|
+
exit={animate ? ['hidden', 'scaleOut'] : undefined}
|
|
137
|
+
>
|
|
138
|
+
<Flex
|
|
139
|
+
data-ui="Popover__wrapper"
|
|
122
140
|
direction="column"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// scheme={scheme}
|
|
127
|
-
shadow={shadow}
|
|
128
|
-
sizing="border"
|
|
129
|
-
style={rootStyle}
|
|
130
|
-
tone={tone}
|
|
131
|
-
variants={POPOVER_MOTION_PROPS.card}
|
|
132
|
-
transition={POPOVER_MOTION_PROPS.transition}
|
|
133
|
-
initial={animate ? ['hidden', 'initial'] : undefined}
|
|
134
|
-
animate={animate ? ['visible', 'scaleIn'] : undefined}
|
|
135
|
-
exit={animate ? ['hidden', 'scaleOut'] : undefined}
|
|
141
|
+
flex={1}
|
|
142
|
+
maxWidth={maxWidth}
|
|
143
|
+
overflow={overflow}
|
|
136
144
|
>
|
|
137
|
-
<Flex
|
|
138
|
-
|
|
139
|
-
direction="column"
|
|
140
|
-
flex={1}
|
|
141
|
-
maxWidth={maxWidth}
|
|
142
|
-
overflow={overflow}
|
|
143
|
-
>
|
|
144
|
-
<Flex direction="column" flex={1} padding={padding}>
|
|
145
|
-
{children}
|
|
146
|
-
</Flex>
|
|
145
|
+
<Flex direction="column" flex={1} padding={padding}>
|
|
146
|
+
{children}
|
|
147
147
|
</Flex>
|
|
148
|
+
</Flex>
|
|
149
|
+
|
|
150
|
+
{arrow && (
|
|
151
|
+
<Arrow
|
|
152
|
+
ref={arrowRef}
|
|
153
|
+
style={arrowStyle}
|
|
154
|
+
width={DEFAULT_POPOVER_ARROW_WIDTH}
|
|
155
|
+
height={DEFAULT_POPOVER_ARROW_HEIGHT}
|
|
156
|
+
radius={DEFAULT_POPOVER_ARROW_RADIUS}
|
|
157
|
+
/>
|
|
158
|
+
)}
|
|
159
|
+
</MotionCard>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
148
162
|
|
|
149
|
-
|
|
150
|
-
<Arrow
|
|
151
|
-
ref={arrowRef}
|
|
152
|
-
style={arrowStyle}
|
|
153
|
-
width={DEFAULT_POPOVER_ARROW_WIDTH}
|
|
154
|
-
height={DEFAULT_POPOVER_ARROW_HEIGHT}
|
|
155
|
-
radius={DEFAULT_POPOVER_ARROW_RADIUS}
|
|
156
|
-
/>
|
|
157
|
-
)}
|
|
158
|
-
</MotionCard>
|
|
159
|
-
)
|
|
160
|
-
}),
|
|
161
|
-
)
|
|
162
|
-
PopoverCard.displayName = 'Memo(ForwardRef(PopoverCard))'
|
|
163
|
+
PopoverCard.displayName = 'PopoverCard'
|
|
@@ -1,26 +1,42 @@
|
|
|
1
1
|
import {composeClassNames, radio} from '@sanity/ui/css'
|
|
2
|
-
import {
|
|
2
|
+
import {useImperativeHandle, useRef} from 'react'
|
|
3
3
|
|
|
4
4
|
import {useCustomValidity} from '../../hooks'
|
|
5
|
-
import {Props} from '../../types'
|
|
5
|
+
import {ComponentType, Props} from '../../types'
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
/** @public */
|
|
8
|
+
export const DEFAULT_RADIO_ELEMENT = 'input'
|
|
9
|
+
|
|
10
|
+
/** @public */
|
|
11
|
+
export type RadioOwnProps = {
|
|
11
12
|
customValidity?: string
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
/** @public */
|
|
16
|
+
export type RadioElementType = 'input' | ComponentType
|
|
17
|
+
|
|
18
|
+
/** @public */
|
|
19
|
+
export type RadioProps<E extends RadioElementType = RadioElementType> = Props<RadioOwnProps, E>
|
|
20
|
+
|
|
14
21
|
/**
|
|
15
22
|
* The `Radio` component allows the user to select one option from a set.
|
|
16
23
|
*
|
|
17
24
|
* @public
|
|
18
25
|
*/
|
|
19
|
-
export
|
|
20
|
-
props:
|
|
21
|
-
forwardedRef: ForwardedRef<HTMLInputElement>,
|
|
26
|
+
export function Radio<E extends RadioElementType = typeof DEFAULT_RADIO_ELEMENT>(
|
|
27
|
+
props: RadioProps<E>,
|
|
22
28
|
) {
|
|
23
|
-
const {
|
|
29
|
+
const {
|
|
30
|
+
as: Element = DEFAULT_RADIO_ELEMENT,
|
|
31
|
+
className,
|
|
32
|
+
disabled,
|
|
33
|
+
style,
|
|
34
|
+
customValidity,
|
|
35
|
+
readOnly,
|
|
36
|
+
ref: forwardedRef,
|
|
37
|
+
...rest
|
|
38
|
+
} = props as RadioProps<typeof DEFAULT_RADIO_ELEMENT>
|
|
39
|
+
|
|
24
40
|
const ref = useRef<HTMLInputElement | null>(null)
|
|
25
41
|
|
|
26
42
|
useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(
|
|
@@ -32,10 +48,10 @@ export const Radio = forwardRef(function Radio(
|
|
|
32
48
|
|
|
33
49
|
return (
|
|
34
50
|
<div className={composeClassNames(className, radio())} data-ui="Radio" style={style}>
|
|
35
|
-
<
|
|
51
|
+
<Element
|
|
36
52
|
data-read-only={!disabled && readOnly ? '' : undefined}
|
|
37
53
|
data-error={customValidity ? '' : undefined}
|
|
38
|
-
{...
|
|
54
|
+
{...rest}
|
|
39
55
|
disabled={disabled || readOnly}
|
|
40
56
|
readOnly={readOnly}
|
|
41
57
|
ref={ref}
|
|
@@ -44,6 +60,6 @@ export const Radio = forwardRef(function Radio(
|
|
|
44
60
|
<span />
|
|
45
61
|
</div>
|
|
46
62
|
)
|
|
47
|
-
}
|
|
63
|
+
}
|
|
48
64
|
|
|
49
|
-
Radio.displayName = '
|
|
65
|
+
Radio.displayName = 'Radio'
|
|
@@ -7,33 +7,40 @@ import {
|
|
|
7
7
|
SelectStyleProps,
|
|
8
8
|
} from '@sanity/ui/css'
|
|
9
9
|
import {Space} from '@sanity/ui/theme'
|
|
10
|
-
import {
|
|
10
|
+
import {useImperativeHandle, useRef} from 'react'
|
|
11
11
|
|
|
12
12
|
import {useCustomValidity} from '../../hooks'
|
|
13
|
-
import {Props} from '../../types'
|
|
13
|
+
import type {ComponentType, Props} from '../../types'
|
|
14
14
|
import {Box} from '../box'
|
|
15
15
|
import {Text} from '../text'
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/** @public */
|
|
18
|
+
export const DEFAULT_SELECT_ELEMENT = 'select'
|
|
19
|
+
|
|
20
|
+
/** @public */
|
|
21
|
+
export type SelectOwnProps = SelectStyleProps & {
|
|
21
22
|
customValidity?: string
|
|
22
23
|
readOnly?: boolean
|
|
23
24
|
/** @deprecated Use `gap` instead. */
|
|
24
25
|
space?: ResponsiveProp<Space>
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
/** @public */
|
|
29
|
+
export type SelectElementType = 'select' | ComponentType
|
|
30
|
+
|
|
31
|
+
/** @public */
|
|
32
|
+
export type SelectProps<E extends SelectElementType = SelectElementType> = Props<SelectOwnProps, E>
|
|
33
|
+
|
|
27
34
|
/**
|
|
28
35
|
* The `Select` component provides control of options.
|
|
29
36
|
*
|
|
30
37
|
* @public
|
|
31
38
|
*/
|
|
32
|
-
export
|
|
33
|
-
props:
|
|
34
|
-
forwardedRef: ForwardedRef<HTMLSelectElement>,
|
|
39
|
+
export function Select<E extends SelectElementType = typeof DEFAULT_SELECT_ELEMENT>(
|
|
40
|
+
props: SelectProps<E>,
|
|
35
41
|
) {
|
|
36
42
|
const {
|
|
43
|
+
as: Element = DEFAULT_SELECT_ELEMENT,
|
|
37
44
|
border = true,
|
|
38
45
|
children,
|
|
39
46
|
customValidity,
|
|
@@ -43,9 +50,10 @@ export const Select = forwardRef(function Select(
|
|
|
43
50
|
padding = 3,
|
|
44
51
|
radius = 1,
|
|
45
52
|
readOnly,
|
|
53
|
+
ref: forwardedRef,
|
|
46
54
|
space = 2,
|
|
47
|
-
...
|
|
48
|
-
} = props
|
|
55
|
+
...rest
|
|
56
|
+
} = props as SelectProps<typeof DEFAULT_SELECT_ELEMENT>
|
|
49
57
|
|
|
50
58
|
const ref = useRef<HTMLSelectElement | null>(null)
|
|
51
59
|
|
|
@@ -62,15 +70,15 @@ export const Select = forwardRef(function Select(
|
|
|
62
70
|
className={select({border, fontSize, padding, radius, gap: gap ?? space})}
|
|
63
71
|
data-icon-right=""
|
|
64
72
|
>
|
|
65
|
-
<
|
|
73
|
+
<Element
|
|
66
74
|
data-read-only={!disabled && readOnly ? '' : undefined}
|
|
67
|
-
{...
|
|
75
|
+
{...rest}
|
|
68
76
|
className={_inputElement()}
|
|
69
77
|
disabled={disabled || readOnly}
|
|
70
78
|
ref={ref}
|
|
71
79
|
>
|
|
72
80
|
{children}
|
|
73
|
-
</
|
|
81
|
+
</Element>
|
|
74
82
|
<span className={selectPresentation()}>
|
|
75
83
|
<Box as="span" display="inline-block" padding={padding}>
|
|
76
84
|
<Text size={fontSize}>
|
|
@@ -80,6 +88,6 @@ export const Select = forwardRef(function Select(
|
|
|
80
88
|
</span>
|
|
81
89
|
</div>
|
|
82
90
|
)
|
|
83
|
-
}
|
|
91
|
+
}
|
|
84
92
|
|
|
85
|
-
Select.displayName = '
|
|
93
|
+
Select.displayName = 'Select'
|
|
@@ -4,13 +4,15 @@ import {ReactElement, SVGProps} from 'react'
|
|
|
4
4
|
|
|
5
5
|
/** @internal */
|
|
6
6
|
export function AnimatedSpinnerIcon(props: SVGProps<SVGSVGElement>): ReactElement {
|
|
7
|
-
const {className, ...
|
|
7
|
+
const {className, ...rest} = props
|
|
8
8
|
|
|
9
9
|
return (
|
|
10
10
|
<SpinnerIcon
|
|
11
|
-
{...
|
|
11
|
+
{...rest}
|
|
12
12
|
data-sanity-icon="animated-spinner"
|
|
13
13
|
className={composeClassNames(className, animatedSpinnerIcon())}
|
|
14
14
|
/>
|
|
15
15
|
)
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
AnimatedSpinnerIcon.displayName = 'AnimatedSpinnerIcon'
|
|
@@ -1,33 +1,45 @@
|
|
|
1
1
|
import {ResponsiveProp, spinner} from '@sanity/ui/css'
|
|
2
2
|
import {FontTextSize} from '@sanity/ui/theme'
|
|
3
|
-
import {ForwardedRef, forwardRef} from 'react'
|
|
4
3
|
|
|
5
|
-
import {Props} from '../../types'
|
|
4
|
+
import {ComponentType, Props} from '../../types'
|
|
6
5
|
import {Text} from '../text'
|
|
7
6
|
import {AnimatedSpinnerIcon} from './animatedSpinnerIcon'
|
|
8
7
|
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
/** @public */
|
|
9
|
+
export const DEFAULT_SPINNER_ELEMENT = 'div'
|
|
10
|
+
|
|
11
|
+
/** @public */
|
|
12
|
+
export type SpinnerOwnProps = {
|
|
13
13
|
muted?: boolean
|
|
14
14
|
size?: ResponsiveProp<FontTextSize>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/** @public */
|
|
18
|
+
export type SpinnerElementType = 'div' | 'span' | ComponentType
|
|
19
|
+
|
|
20
|
+
/** @public */
|
|
21
|
+
export type SpinnerProps<E extends SpinnerElementType = SpinnerElementType> = Props<
|
|
22
|
+
SpinnerOwnProps,
|
|
23
|
+
E
|
|
24
|
+
>
|
|
25
|
+
|
|
17
26
|
/**
|
|
18
27
|
* Indicate that something is loading for an indeterminate amount of time.
|
|
19
28
|
*
|
|
20
29
|
* @public
|
|
21
30
|
*/
|
|
22
|
-
export
|
|
23
|
-
props:
|
|
24
|
-
ref: ForwardedRef<HTMLDivElement>,
|
|
31
|
+
export function Spinner<E extends SpinnerElementType = typeof DEFAULT_SPINNER_ELEMENT>(
|
|
32
|
+
props: SpinnerProps<E>,
|
|
25
33
|
) {
|
|
34
|
+
const {as = DEFAULT_SPINNER_ELEMENT, ...rest} = props as SpinnerProps<
|
|
35
|
+
typeof DEFAULT_SPINNER_ELEMENT
|
|
36
|
+
>
|
|
37
|
+
|
|
26
38
|
return (
|
|
27
|
-
<Text data-ui="Spinner" {...
|
|
39
|
+
<Text as={as} data-ui="Spinner" {...rest} className={spinner()}>
|
|
28
40
|
<AnimatedSpinnerIcon />
|
|
29
41
|
</Text>
|
|
30
42
|
)
|
|
31
|
-
}
|
|
43
|
+
}
|
|
32
44
|
|
|
33
|
-
Spinner.displayName = '
|
|
45
|
+
Spinner.displayName = 'Spinner'
|
|
@@ -1,45 +1,54 @@
|
|
|
1
1
|
import {composeClassNames, ResponsiveProp, stack} from '@sanity/ui/css'
|
|
2
2
|
import {Space} from '@sanity/ui/theme'
|
|
3
|
-
import {ForwardedRef, forwardRef} from 'react'
|
|
4
3
|
|
|
5
4
|
import {Props} from '../../types'
|
|
6
|
-
import {Box,
|
|
5
|
+
import {Box, BoxElementType, BoxOwnProps} from '../box'
|
|
7
6
|
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
/** @public */
|
|
8
|
+
export const DEFAULT_STACK_ELEMENT = 'div'
|
|
9
|
+
|
|
10
|
+
/** @public */
|
|
11
|
+
export type StackOwnProps = Omit<
|
|
12
|
+
BoxOwnProps,
|
|
13
|
+
'align' | 'columns' | 'direction' | 'display' | 'gapX' | 'gapY' | 'justify'
|
|
14
|
+
> & {
|
|
16
15
|
/** @deprecated Use `gap` instead. */
|
|
17
16
|
space?: ResponsiveProp<Space>
|
|
18
17
|
}
|
|
19
18
|
|
|
19
|
+
/** @public */
|
|
20
|
+
export type StackElementType = BoxElementType
|
|
21
|
+
|
|
22
|
+
/** @public */
|
|
23
|
+
export type StackProps<E extends StackElementType = StackElementType> = Props<StackOwnProps, E>
|
|
24
|
+
|
|
20
25
|
/**
|
|
21
26
|
* The `Stack` component is used to place elements on top of each other.
|
|
22
27
|
*
|
|
23
28
|
* @public
|
|
24
29
|
*/
|
|
25
|
-
export
|
|
26
|
-
props:
|
|
27
|
-
ref: ForwardedRef<HTMLDivElement>,
|
|
30
|
+
export function Stack<E extends StackElementType = typeof DEFAULT_STACK_ELEMENT>(
|
|
31
|
+
props: StackProps<E>,
|
|
28
32
|
) {
|
|
29
|
-
const {
|
|
33
|
+
const {
|
|
34
|
+
as = DEFAULT_STACK_ELEMENT,
|
|
35
|
+
className,
|
|
36
|
+
gap,
|
|
37
|
+
space,
|
|
38
|
+
...rest
|
|
39
|
+
} = props as StackProps<typeof DEFAULT_STACK_ELEMENT>
|
|
30
40
|
|
|
31
41
|
return (
|
|
32
42
|
<Box
|
|
33
43
|
data-ui="Stack"
|
|
34
|
-
{...
|
|
44
|
+
{...rest}
|
|
35
45
|
as={as}
|
|
36
46
|
autoRows="min"
|
|
37
47
|
className={composeClassNames(className, stack())}
|
|
38
48
|
display="grid"
|
|
39
49
|
gap={gap ?? space}
|
|
40
|
-
ref={ref}
|
|
41
50
|
/>
|
|
42
51
|
)
|
|
43
|
-
}
|
|
52
|
+
}
|
|
44
53
|
|
|
45
|
-
Stack.displayName = '
|
|
54
|
+
Stack.displayName = 'Stack'
|
|
@@ -6,18 +6,25 @@ import {
|
|
|
6
6
|
_switchTrack,
|
|
7
7
|
composeClassNames,
|
|
8
8
|
} from '@sanity/ui/css'
|
|
9
|
-
import {
|
|
9
|
+
import {useEffect, useImperativeHandle, useRef} from 'react'
|
|
10
10
|
|
|
11
|
-
import {Props} from '../../types'
|
|
11
|
+
import {ComponentType, Props} from '../../types'
|
|
12
12
|
import {Box} from '../box'
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
/** @public */
|
|
15
|
+
export const DEFAULT_SWITCH_ELEMENT = 'input'
|
|
16
|
+
|
|
17
|
+
/** @public */
|
|
18
|
+
export type SwitchOwnProps = {
|
|
18
19
|
indeterminate?: boolean
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
/** @public */
|
|
23
|
+
export type SwitchElementType = 'input' | ComponentType
|
|
24
|
+
|
|
25
|
+
/** @public */
|
|
26
|
+
export type SwitchProps<E extends SwitchElementType = SwitchElementType> = Props<SwitchOwnProps, E>
|
|
27
|
+
|
|
21
28
|
/**
|
|
22
29
|
* The `Switch` component allows the user to toggle a setting on and off.
|
|
23
30
|
*
|
|
@@ -25,11 +32,21 @@ export interface SwitchProps {
|
|
|
25
32
|
*
|
|
26
33
|
* @public
|
|
27
34
|
*/
|
|
28
|
-
export
|
|
29
|
-
props:
|
|
30
|
-
forwardedRef: ForwardedRef<HTMLInputElement>,
|
|
35
|
+
export function Switch<E extends SwitchElementType = typeof DEFAULT_SWITCH_ELEMENT>(
|
|
36
|
+
props: SwitchProps<E>,
|
|
31
37
|
) {
|
|
32
|
-
const {
|
|
38
|
+
const {
|
|
39
|
+
as: Element = DEFAULT_SWITCH_ELEMENT,
|
|
40
|
+
checked,
|
|
41
|
+
className,
|
|
42
|
+
disabled,
|
|
43
|
+
indeterminate,
|
|
44
|
+
readOnly,
|
|
45
|
+
ref: forwardedRef,
|
|
46
|
+
style,
|
|
47
|
+
...rest
|
|
48
|
+
} = props as SwitchProps<typeof DEFAULT_SWITCH_ELEMENT>
|
|
49
|
+
|
|
33
50
|
const ref = useRef<HTMLInputElement | null>(null)
|
|
34
51
|
|
|
35
52
|
useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(
|
|
@@ -54,8 +71,8 @@ export const Switch = forwardRef(function Switch(
|
|
|
54
71
|
position="relative"
|
|
55
72
|
style={style}
|
|
56
73
|
>
|
|
57
|
-
<
|
|
58
|
-
{...
|
|
74
|
+
<Element
|
|
75
|
+
{...rest}
|
|
59
76
|
checked={indeterminate !== true && checked}
|
|
60
77
|
className={_switchElement()}
|
|
61
78
|
data-disabled={disabled ? '' : undefined}
|
|
@@ -70,6 +87,6 @@ export const Switch = forwardRef(function Switch(
|
|
|
70
87
|
</span>
|
|
71
88
|
</Box>
|
|
72
89
|
)
|
|
73
|
-
}
|
|
90
|
+
}
|
|
74
91
|
|
|
75
|
-
Switch.displayName = '
|
|
92
|
+
Switch.displayName = 'Switch'
|