@sanity/ui 3.0.11 → 3.0.12-canary.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/_visual-editing.js +1124 -628
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +1127 -631
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +3 -7
- package/dist/_visual-editing.d.ts +3 -7
- package/dist/index.d.mts +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +252 -295
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +254 -297
- package/dist/index.mjs.map +1 -1
- package/package.json +26 -40
- package/src/core/components/autocomplete/autocomplete.tsx +2 -2
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +70 -40
- package/src/core/components/dialog/dialog.tsx +10 -14
- package/src/core/components/hotkeys/hotkeys.tsx +2 -2
- package/src/core/components/menu/menuGroup.tsx +2 -2
- package/src/core/components/menu/menuItem.tsx +4 -4
- package/src/core/components/skeleton/skeleton.tsx +2 -2
- package/src/core/components/skeleton/textSkeleton.tsx +5 -5
- package/src/core/components/tree/tree.tsx +176 -182
- package/src/core/components/tree/treeGroup.tsx +2 -4
- package/src/core/components/tree/treeItem.tsx +5 -5
- package/src/core/hooks/index.ts +1 -1
- package/src/core/hooks/useArrayProp.ts +5 -17
- package/src/core/primitives/avatar/avatar.tsx +14 -16
- package/src/core/primitives/avatar/avatarCounter.tsx +14 -16
- package/src/core/primitives/avatar/avatarStack.tsx +2 -2
- package/src/core/primitives/badge/badge.tsx +3 -3
- package/src/core/primitives/box/box.tsx +26 -26
- package/src/core/primitives/button/button.tsx +11 -11
- package/src/core/primitives/card/card.tsx +8 -8
- package/src/core/primitives/code/code.tsx +2 -2
- package/src/core/primitives/container/container.tsx +2 -2
- package/src/core/primitives/flex/flex.tsx +6 -6
- package/src/core/primitives/grid/grid.tsx +9 -9
- package/src/core/primitives/heading/heading.tsx +3 -3
- package/src/core/primitives/inline/inline.tsx +2 -2
- package/src/core/primitives/kbd/kbd.tsx +2 -2
- package/src/core/primitives/label/label.tsx +3 -3
- package/src/core/primitives/popover/floating-ui/size.ts +32 -16
- package/src/core/primitives/popover/popover.tsx +355 -328
- package/src/core/primitives/popover/popoverCard.tsx +123 -125
- package/src/core/primitives/select/select.tsx +6 -5
- package/src/core/primitives/stack/stack.tsx +2 -2
- package/src/core/primitives/text/text.tsx +3 -3
- package/src/core/primitives/textArea/textArea.tsx +6 -5
- package/src/core/primitives/textInput/textInput.tsx +6 -5
- package/src/core/primitives/tooltip/tooltip.tsx +73 -44
- package/src/core/primitives/tooltip/tooltipCard.tsx +83 -85
- package/src/core/utils/layer/layerProvider.tsx +3 -2
- package/src/core/utils/virtualList/virtualList.tsx +48 -23
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
5
5
|
import {
|
|
6
6
|
boxStyle,
|
|
7
7
|
flexItemStyle,
|
|
@@ -96,31 +96,31 @@ export const Box = forwardRef(function Box(
|
|
|
96
96
|
data-as={typeof asProp === 'string' ? asProp : undefined}
|
|
97
97
|
data-ui="Box"
|
|
98
98
|
{...restProps}
|
|
99
|
-
$column={
|
|
100
|
-
$columnStart={
|
|
101
|
-
$columnEnd={
|
|
102
|
-
$display={
|
|
103
|
-
$flex={
|
|
104
|
-
$height={
|
|
105
|
-
$margin={
|
|
106
|
-
$marginX={
|
|
107
|
-
$marginY={
|
|
108
|
-
$marginTop={
|
|
109
|
-
$marginRight={
|
|
110
|
-
$marginBottom={
|
|
111
|
-
$marginLeft={
|
|
112
|
-
$overflow={
|
|
113
|
-
$padding={
|
|
114
|
-
$paddingX={
|
|
115
|
-
$paddingY={
|
|
116
|
-
$paddingTop={
|
|
117
|
-
$paddingRight={
|
|
118
|
-
$paddingBottom={
|
|
119
|
-
$paddingLeft={
|
|
120
|
-
$row={
|
|
121
|
-
$rowStart={
|
|
122
|
-
$rowEnd={
|
|
123
|
-
$sizing={
|
|
99
|
+
$column={getArrayProp(column)}
|
|
100
|
+
$columnStart={getArrayProp(columnStart)}
|
|
101
|
+
$columnEnd={getArrayProp(columnEnd)}
|
|
102
|
+
$display={getArrayProp(display)}
|
|
103
|
+
$flex={getArrayProp(flex)}
|
|
104
|
+
$height={getArrayProp(height)}
|
|
105
|
+
$margin={getArrayProp(margin)}
|
|
106
|
+
$marginX={getArrayProp(marginX)}
|
|
107
|
+
$marginY={getArrayProp(marginY)}
|
|
108
|
+
$marginTop={getArrayProp(marginTop)}
|
|
109
|
+
$marginRight={getArrayProp(marginRight)}
|
|
110
|
+
$marginBottom={getArrayProp(marginBottom)}
|
|
111
|
+
$marginLeft={getArrayProp(marginLeft)}
|
|
112
|
+
$overflow={getArrayProp(overflow)}
|
|
113
|
+
$padding={getArrayProp(padding)}
|
|
114
|
+
$paddingX={getArrayProp(paddingX)}
|
|
115
|
+
$paddingY={getArrayProp(paddingY)}
|
|
116
|
+
$paddingTop={getArrayProp(paddingTop)}
|
|
117
|
+
$paddingRight={getArrayProp(paddingRight)}
|
|
118
|
+
$paddingBottom={getArrayProp(paddingBottom)}
|
|
119
|
+
$paddingLeft={getArrayProp(paddingLeft)}
|
|
120
|
+
$row={getArrayProp(row)}
|
|
121
|
+
$rowStart={getArrayProp(rowStart)}
|
|
122
|
+
$rowEnd={getArrayProp(rowEnd)}
|
|
123
|
+
$sizing={getArrayProp(sizing)}
|
|
124
124
|
as={asProp}
|
|
125
125
|
ref={ref}
|
|
126
126
|
>
|
|
@@ -3,7 +3,7 @@ import {forwardRef, isValidElement, useMemo} from 'react'
|
|
|
3
3
|
import {isValidElementType} from 'react-is'
|
|
4
4
|
import {styled} from 'styled-components'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
7
7
|
import {ThemeProps} from '../../styles'
|
|
8
8
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
9
9
|
import {useTheme_v2} from '../../theme'
|
|
@@ -97,16 +97,16 @@ export const Button = forwardRef(function Button(
|
|
|
97
97
|
} = props
|
|
98
98
|
const {button} = useTheme_v2()
|
|
99
99
|
|
|
100
|
-
const justify =
|
|
101
|
-
const padding =
|
|
102
|
-
const paddingX =
|
|
103
|
-
const paddingY =
|
|
104
|
-
const paddingTop =
|
|
105
|
-
const paddingBottom =
|
|
106
|
-
const paddingLeft =
|
|
107
|
-
const paddingRight =
|
|
108
|
-
const radius =
|
|
109
|
-
const space =
|
|
100
|
+
const justify = getArrayProp(justifyProp)
|
|
101
|
+
const padding = getArrayProp(paddingProp)
|
|
102
|
+
const paddingX = getArrayProp(paddingXProp)
|
|
103
|
+
const paddingY = getArrayProp(paddingYProp)
|
|
104
|
+
const paddingTop = getArrayProp(paddingTopProp)
|
|
105
|
+
const paddingBottom = getArrayProp(paddingBottomProp)
|
|
106
|
+
const paddingLeft = getArrayProp(paddingLeftProp)
|
|
107
|
+
const paddingRight = getArrayProp(paddingRightProp)
|
|
108
|
+
const radius = getArrayProp(radiusProp)
|
|
109
|
+
const space = getArrayProp(spaceProp)
|
|
110
110
|
|
|
111
111
|
const boxProps = useMemo(
|
|
112
112
|
() => ({
|
|
@@ -3,7 +3,7 @@ import {forwardRef} from 'react'
|
|
|
3
3
|
import {isValidElementType} from 'react-is'
|
|
4
4
|
import {styled} from 'styled-components'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
7
7
|
import {
|
|
8
8
|
responsiveBorderStyle,
|
|
9
9
|
ResponsiveBorderStyleProps,
|
|
@@ -93,16 +93,16 @@ export const Card = forwardRef(function Card(
|
|
|
93
93
|
data-ui="Card"
|
|
94
94
|
data-tone={tone}
|
|
95
95
|
{...restProps}
|
|
96
|
-
$border={
|
|
97
|
-
$borderTop={
|
|
98
|
-
$borderRight={
|
|
99
|
-
$borderBottom={
|
|
100
|
-
$borderLeft={
|
|
96
|
+
$border={getArrayProp(border)}
|
|
97
|
+
$borderTop={getArrayProp(borderTop)}
|
|
98
|
+
$borderRight={getArrayProp(borderRight)}
|
|
99
|
+
$borderBottom={getArrayProp(borderBottom)}
|
|
100
|
+
$borderLeft={getArrayProp(borderLeft)}
|
|
101
101
|
$checkered={checkered}
|
|
102
102
|
$focusRing={focusRing}
|
|
103
103
|
$muted={muted}
|
|
104
|
-
$radius={
|
|
105
|
-
$shadow={
|
|
104
|
+
$radius={getArrayProp(radius)}
|
|
105
|
+
$shadow={getArrayProp(shadow)}
|
|
106
106
|
$tone={tone}
|
|
107
107
|
data-checkered={checkered ? '' : undefined}
|
|
108
108
|
data-pressed={pressed ? '' : undefined}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {forwardRef, lazy, Suspense} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
5
5
|
import {responsiveCodeFontStyle, ResponsiveFontStyleProps} from '../../styles/internal'
|
|
6
6
|
import {codeBaseStyle} from './styles'
|
|
7
7
|
|
|
@@ -30,7 +30,7 @@ export const Code = forwardRef(function Code(
|
|
|
30
30
|
const {children, language, size = 2, weight, ...restProps} = props
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
|
-
<StyledCode data-ui="Code" {...restProps} $size={
|
|
33
|
+
<StyledCode data-ui="Code" {...restProps} $size={getArrayProp(size)} $weight={weight} ref={ref}>
|
|
34
34
|
<Suspense fallback={<code>{children}</code>}>
|
|
35
35
|
<LazyRefractor language={language} value={children} />
|
|
36
36
|
</Suspense>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
5
5
|
import {Box, BoxProps} from '../box'
|
|
6
6
|
import {ResponsiveWidthProps} from '../types'
|
|
7
7
|
import {containerBaseStyle, responsiveContainerWidthStyle} from './styles'
|
|
@@ -32,7 +32,7 @@ export const Container = forwardRef(function Container(
|
|
|
32
32
|
<StyledContainer
|
|
33
33
|
data-ui="Container"
|
|
34
34
|
{...restProps}
|
|
35
|
-
$width={
|
|
35
|
+
$width={getArrayProp(width)}
|
|
36
36
|
forwardedAs={as}
|
|
37
37
|
ref={ref}
|
|
38
38
|
/>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
5
5
|
import {
|
|
6
6
|
flexItemStyle,
|
|
7
7
|
FlexItemStyleProps,
|
|
@@ -41,11 +41,11 @@ export const Flex = forwardRef(function Flex(
|
|
|
41
41
|
<StyledFlex
|
|
42
42
|
data-ui="Flex"
|
|
43
43
|
{...restProps}
|
|
44
|
-
$align={
|
|
45
|
-
$direction={
|
|
46
|
-
$gap={
|
|
47
|
-
$justify={
|
|
48
|
-
$wrap={
|
|
44
|
+
$align={getArrayProp(align)}
|
|
45
|
+
$direction={getArrayProp(direction)}
|
|
46
|
+
$gap={getArrayProp(gap)}
|
|
47
|
+
$justify={getArrayProp(justify)}
|
|
48
|
+
$wrap={getArrayProp(wrap)}
|
|
49
49
|
forwardedAs={as}
|
|
50
50
|
ref={ref}
|
|
51
51
|
/>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
5
5
|
import {responsiveGridStyle, ResponsiveGridStyleProps} from '../../styles/internal'
|
|
6
6
|
import {Box, BoxProps} from '../box'
|
|
7
7
|
import {ResponsiveGridProps} from '../types'
|
|
@@ -30,14 +30,14 @@ export const Grid = forwardRef(function Grid(
|
|
|
30
30
|
data-as={typeof as === 'string' ? as : undefined}
|
|
31
31
|
data-ui="Grid"
|
|
32
32
|
{...restProps}
|
|
33
|
-
$autoRows={
|
|
34
|
-
$autoCols={
|
|
35
|
-
$autoFlow={
|
|
36
|
-
$columns={
|
|
37
|
-
$gap={
|
|
38
|
-
$gapX={
|
|
39
|
-
$gapY={
|
|
40
|
-
$rows={
|
|
33
|
+
$autoRows={getArrayProp(autoRows)}
|
|
34
|
+
$autoCols={getArrayProp(autoCols)}
|
|
35
|
+
$autoFlow={getArrayProp(autoFlow)}
|
|
36
|
+
$columns={getArrayProp(columns)}
|
|
37
|
+
$gap={getArrayProp(gap)}
|
|
38
|
+
$gapX={getArrayProp(gapX)}
|
|
39
|
+
$gapY={getArrayProp(gapY)}
|
|
40
|
+
$rows={getArrayProp(rows)}
|
|
41
41
|
forwardedAs={as}
|
|
42
42
|
ref={ref}
|
|
43
43
|
>
|
|
@@ -2,7 +2,7 @@ import {ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
|
2
2
|
import {forwardRef} from 'react'
|
|
3
3
|
import {styled} from 'styled-components'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
6
6
|
import {
|
|
7
7
|
ResponsiveFontStyleProps,
|
|
8
8
|
responsiveHeadingFont,
|
|
@@ -67,9 +67,9 @@ export const Heading = forwardRef(function Heading(
|
|
|
67
67
|
data-ui="Heading"
|
|
68
68
|
{...restProps}
|
|
69
69
|
$accent={accent}
|
|
70
|
-
$align={
|
|
70
|
+
$align={getArrayProp(align)}
|
|
71
71
|
$muted={muted}
|
|
72
|
-
$size={
|
|
72
|
+
$size={getArrayProp(size)}
|
|
73
73
|
$weight={weight}
|
|
74
74
|
ref={ref}
|
|
75
75
|
>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Children, forwardRef, useMemo} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
5
5
|
import {Box, BoxProps} from '../box'
|
|
6
6
|
import {inlineBaseStyle, inlineSpaceStyle} from './styles'
|
|
7
7
|
import {ResponsiveInlineSpaceStyleProps} from './types'
|
|
@@ -36,7 +36,7 @@ export const Inline = forwardRef(function Inline(
|
|
|
36
36
|
<StyledInline
|
|
37
37
|
data-ui="Inline"
|
|
38
38
|
{...restProps}
|
|
39
|
-
$space={
|
|
39
|
+
$space={getArrayProp(space)}
|
|
40
40
|
forwardedAs={as}
|
|
41
41
|
ref={ref as any}
|
|
42
42
|
>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {forwardRef} from 'react'
|
|
2
2
|
import {css, styled} from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
5
5
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
6
6
|
import {Radius} from '../../types'
|
|
7
7
|
import {Box} from '../box'
|
|
@@ -49,7 +49,7 @@ export const KBD = forwardRef(function KBD(
|
|
|
49
49
|
const {children, fontSize = 0, padding = 1, radius = 2, ...restProps} = props
|
|
50
50
|
|
|
51
51
|
return (
|
|
52
|
-
<StyledKBD data-ui="KBD" {...restProps} $radius={
|
|
52
|
+
<StyledKBD data-ui="KBD" {...restProps} $radius={getArrayProp(radius)} ref={ref}>
|
|
53
53
|
<Box as="span" padding={padding}>
|
|
54
54
|
<Text as="span" size={fontSize} weight="semibold">
|
|
55
55
|
{children}
|
|
@@ -2,7 +2,7 @@ import {ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
|
2
2
|
import {forwardRef} from 'react'
|
|
3
3
|
import {styled} from 'styled-components'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {getArrayProp} from '../../hooks/useArrayProp'
|
|
6
6
|
import {responsiveLabelFont, responsiveTextAlignStyle} from '../../styles/internal'
|
|
7
7
|
import {TextAlign} from '../../types'
|
|
8
8
|
import {SpanWithTextOverflow} from '../../utils/spanWithTextOverflow'
|
|
@@ -66,9 +66,9 @@ export const Label = forwardRef(function Label(
|
|
|
66
66
|
data-ui="Label"
|
|
67
67
|
{...restProps}
|
|
68
68
|
$accent={accent}
|
|
69
|
-
$align={
|
|
69
|
+
$align={getArrayProp(align)}
|
|
70
70
|
$muted={muted}
|
|
71
|
-
$size={
|
|
71
|
+
$size={getArrayProp(size)}
|
|
72
72
|
$weight={weight}
|
|
73
73
|
ref={ref}
|
|
74
74
|
>
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import {detectOverflow,
|
|
1
|
+
import {detectOverflow, Middleware} from '@floating-ui/react-dom'
|
|
2
2
|
|
|
3
3
|
import {PopoverMargins} from '../../../types'
|
|
4
4
|
|
|
5
|
-
export interface SizeMiddlewareApplyOptions {
|
|
6
|
-
availableWidth: number
|
|
7
|
-
availableHeight: number
|
|
8
|
-
elements: Elements
|
|
9
|
-
referenceWidth: number
|
|
10
|
-
}
|
|
11
|
-
|
|
12
5
|
export function size(options: {
|
|
13
|
-
apply: (args: SizeMiddlewareApplyOptions) => void
|
|
14
6
|
boundaryElement?: HTMLElement | null
|
|
15
7
|
constrainSize: boolean
|
|
16
8
|
margins: PopoverMargins
|
|
17
9
|
matchReferenceWidth?: boolean
|
|
10
|
+
maxWidthRef: React.RefObject<number | undefined>
|
|
18
11
|
padding?: number
|
|
12
|
+
referenceWidthRef: React.RefObject<number | undefined>
|
|
13
|
+
setReferenceWidth: (referenceWidth: number) => void
|
|
14
|
+
widthRef: React.RefObject<number | undefined>
|
|
19
15
|
}): Middleware {
|
|
20
|
-
const {
|
|
16
|
+
const {
|
|
17
|
+
constrainSize,
|
|
18
|
+
margins,
|
|
19
|
+
matchReferenceWidth,
|
|
20
|
+
maxWidthRef,
|
|
21
|
+
padding = 0,
|
|
22
|
+
referenceWidthRef,
|
|
23
|
+
setReferenceWidth,
|
|
24
|
+
widthRef,
|
|
25
|
+
} = options
|
|
21
26
|
|
|
22
27
|
return {
|
|
23
28
|
name: '@sanity/ui/size',
|
|
@@ -61,12 +66,23 @@ export function size(options: {
|
|
|
61
66
|
|
|
62
67
|
// IMPORTANT – APPLY ELEMENT STYLES HERE
|
|
63
68
|
// Elements need to be resized BEFORE the `platform.getDimensions` call below
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
const availableWidth = maxWidth - margins[1] - margins[3]
|
|
70
|
+
const availableHeight = maxHeight - margins[0] - margins[2]
|
|
71
|
+
const referenceWidth = reference.width - margins[1] - margins[3]
|
|
72
|
+
referenceWidthRef.current = referenceWidth
|
|
73
|
+
setReferenceWidth(referenceWidth)
|
|
74
|
+
|
|
75
|
+
if (matchReferenceWidth) {
|
|
76
|
+
elements.floating.style.width = `${referenceWidth}px`
|
|
77
|
+
} else if (widthRef.current !== undefined) {
|
|
78
|
+
elements.floating.style.width = `${widthRef.current}px`
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (constrainSize) {
|
|
82
|
+
elements.floating.style.maxWidth = `${Math.min(availableWidth, maxWidthRef.current ?? Infinity)}px`
|
|
83
|
+
|
|
84
|
+
elements.floating.style.maxHeight = `${availableHeight}px`
|
|
85
|
+
}
|
|
70
86
|
|
|
71
87
|
const nextDimensions = await platform.getDimensions(elements.floating)
|
|
72
88
|
|