@sanity/ui 2.3.6-canary.6 → 2.3.6
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/index.d.mts +1 -13
- package/dist/index.d.ts +1 -13
- package/dist/index.esm.js +2174 -2147
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2181 -2154
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2174 -2147
- package/dist/index.mjs.map +1 -1
- package/package.json +35 -31
- package/src/core/components/autocomplete/autocomplete.tsx +34 -31
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +2 -3
- package/src/core/components/dialog/dialog.tsx +12 -23
- package/src/core/components/hotkeys/hotkeys.tsx +3 -3
- package/src/core/components/menu/menu.tsx +1 -5
- package/src/core/components/menu/menuButton.tsx +32 -17
- package/src/core/components/menu/menuGroup.tsx +5 -7
- package/src/core/components/menu/menuItem.tsx +6 -10
- package/src/core/components/skeleton/skeleton.tsx +11 -5
- package/src/core/components/skeleton/textSkeleton.tsx +7 -6
- package/src/core/components/toast/toastProvider.tsx +24 -26
- package/src/core/components/tree/treeItem.tsx +44 -31
- package/src/core/hooks/useArrayProp.ts +10 -11
- package/src/core/primitives/avatar/avatar.tsx +15 -11
- package/src/core/primitives/avatar/avatarCounter.tsx +17 -11
- package/src/core/primitives/avatar/avatarStack.tsx +7 -3
- package/src/core/primitives/badge/badge.tsx +4 -7
- package/src/core/primitives/box/box.tsx +27 -53
- package/src/core/primitives/button/button.tsx +12 -11
- package/src/core/primitives/card/card.tsx +9 -17
- package/src/core/primitives/code/code.tsx +3 -4
- package/src/core/primitives/container/container.tsx +11 -4
- package/src/core/primitives/flex/flex.tsx +7 -13
- package/src/core/primitives/grid/grid.tsx +10 -19
- package/src/core/primitives/heading/heading.tsx +4 -7
- package/src/core/primitives/inline/inline.tsx +2 -3
- package/src/core/primitives/kbd/kbd.tsx +3 -4
- package/src/core/primitives/label/label.tsx +4 -7
- package/src/core/primitives/popover/popover.tsx +49 -49
- package/src/core/primitives/select/select.tsx +6 -12
- package/src/core/primitives/stack/stack.tsx +3 -4
- package/src/core/primitives/text/text.tsx +4 -7
- package/src/core/primitives/textArea/textArea.tsx +6 -12
- package/src/core/primitives/textInput/textInput.tsx +5 -6
- package/src/core/primitives/tooltip/tooltip.tsx +11 -14
- package/src/core/theme/themeProvider.tsx +6 -4
- package/src/core/utils/elementQuery/elementQuery.tsx +3 -4
- package/src/core/utils/layer/getLayerContext.test.ts +4 -0
- package/src/core/utils/layer/layer.test.tsx +2 -0
- package/src/core/utils/layer/layerProvider.tsx +43 -35
- package/src/core/utils/layer/types.ts +1 -0
- package/dist/index.compiled.mjs +0 -7486
- package/dist/index.compiled.mjs.map +0 -1
- package/src/core/components/tree/treeItem.styles.ts +0 -21
|
@@ -45,6 +45,8 @@ const ToastContainer = styled.div`
|
|
|
45
45
|
width: 100%;
|
|
46
46
|
`
|
|
47
47
|
|
|
48
|
+
let toastId = 0
|
|
49
|
+
|
|
48
50
|
/**
|
|
49
51
|
* @public
|
|
50
52
|
*/
|
|
@@ -55,7 +57,27 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
55
57
|
const mounted = useMounted()
|
|
56
58
|
const prefersReducedMotion = usePrefersReducedMotion()
|
|
57
59
|
const variants = useMemo<Variants>(
|
|
58
|
-
() =>
|
|
60
|
+
() => ({
|
|
61
|
+
initial: {
|
|
62
|
+
opacity: 0,
|
|
63
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: 0,
|
|
64
|
+
y: 32,
|
|
65
|
+
scale: 0.25,
|
|
66
|
+
willChange: 'transform',
|
|
67
|
+
},
|
|
68
|
+
animate: {
|
|
69
|
+
opacity: [0, 1, 1],
|
|
70
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: [0, 0, 1],
|
|
71
|
+
y: 0,
|
|
72
|
+
scale: 1,
|
|
73
|
+
},
|
|
74
|
+
exit: {
|
|
75
|
+
opacity: [1, 1, 0],
|
|
76
|
+
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: [1, 0, 0],
|
|
77
|
+
scale: 0.5,
|
|
78
|
+
transition: prefersReducedMotion ? {duration: 0} : {duration: 0.2},
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
59
81
|
[prefersReducedMotion],
|
|
60
82
|
)
|
|
61
83
|
|
|
@@ -64,7 +86,7 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
64
86
|
// Wrap setState in startTransition to allow React to give input state updates higher priority
|
|
65
87
|
const setState: typeof _setState = (state) => startTransition(() => _setState(state))
|
|
66
88
|
|
|
67
|
-
const id = params.id ||
|
|
89
|
+
const id = params.id || String(toastId++)
|
|
68
90
|
const duration = params.duration || 5000
|
|
69
91
|
|
|
70
92
|
const dismiss = () => {
|
|
@@ -166,27 +188,3 @@ export function ToastProvider(props: ToastProviderProps): React.ReactElement {
|
|
|
166
188
|
</ToastContext.Provider>
|
|
167
189
|
)
|
|
168
190
|
}
|
|
169
|
-
|
|
170
|
-
function getVariants(prefersReducedMotion: boolean) {
|
|
171
|
-
return {
|
|
172
|
-
initial: {
|
|
173
|
-
opacity: 0,
|
|
174
|
-
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: 0,
|
|
175
|
-
y: 32,
|
|
176
|
-
scale: 0.25,
|
|
177
|
-
willChange: 'transform',
|
|
178
|
-
},
|
|
179
|
-
animate: {
|
|
180
|
-
opacity: [0, 1, 1],
|
|
181
|
-
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: [0, 0, 1],
|
|
182
|
-
y: 0,
|
|
183
|
-
scale: 1,
|
|
184
|
-
},
|
|
185
|
-
exit: {
|
|
186
|
-
opacity: [1, 1, 0],
|
|
187
|
-
[POPOVER_MOTION_CONTENT_OPACITY_PROPERTY as string]: [1, 0, 0],
|
|
188
|
-
scale: 0.5,
|
|
189
|
-
transition: {duration: prefersReducedMotion ? 0 : 0.2},
|
|
190
|
-
},
|
|
191
|
-
}
|
|
192
|
-
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import {ToggleArrowRightIcon} from '@sanity/icons'
|
|
2
2
|
import {ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
3
3
|
import {memo, useCallback, useEffect, useId, useMemo, useRef} from 'react'
|
|
4
|
+
import {styled} from 'styled-components'
|
|
4
5
|
import {Box, BoxProps, Flex, Text} from '../../primitives'
|
|
6
|
+
import {
|
|
7
|
+
treeItemRootStyle,
|
|
8
|
+
treeItemRootColorStyle,
|
|
9
|
+
treeItemBoxStyle,
|
|
10
|
+
TreeItemBoxStyleProps,
|
|
11
|
+
} from './style'
|
|
5
12
|
import {TreeContext} from './treeContext'
|
|
6
13
|
import {TreeGroup} from './treeGroup'
|
|
7
|
-
import {Root, ToggleArrowText, TreeItemBox} from './treeItem.styles'
|
|
8
14
|
import {useTree} from './useTree'
|
|
9
15
|
|
|
10
16
|
/**
|
|
@@ -24,6 +30,16 @@ export interface TreeItemProps {
|
|
|
24
30
|
weight?: ThemeFontWeightKey
|
|
25
31
|
}
|
|
26
32
|
|
|
33
|
+
const Root = memo(styled.li(treeItemRootStyle, treeItemRootColorStyle))
|
|
34
|
+
|
|
35
|
+
const TreeItemBox = styled(Box).attrs({forwardedAs: 'a'})<TreeItemBoxStyleProps>(treeItemBoxStyle)
|
|
36
|
+
|
|
37
|
+
const ToggleArrowText = styled(Text)`
|
|
38
|
+
& > svg {
|
|
39
|
+
transition: transform 100ms;
|
|
40
|
+
}
|
|
41
|
+
`
|
|
42
|
+
|
|
27
43
|
/**
|
|
28
44
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
29
45
|
* @beta
|
|
@@ -54,7 +70,7 @@ export const TreeItem = memo(function TreeItem(
|
|
|
54
70
|
const {path, registerItem, setExpanded, setFocusedElement} = tree
|
|
55
71
|
const _id = useId()
|
|
56
72
|
const id = idProp || _id
|
|
57
|
-
const itemPath = useMemo(() => [
|
|
73
|
+
const itemPath = useMemo(() => path.concat([id || '']), [id, path])
|
|
58
74
|
const itemKey = itemPath.join('/')
|
|
59
75
|
const itemState = tree.state[itemKey]
|
|
60
76
|
const focused = tree.focusedElement === rootRef.current
|
|
@@ -67,7 +83,7 @@ export const TreeItem = memo(function TreeItem(
|
|
|
67
83
|
|
|
68
84
|
const handleClick = useCallback(
|
|
69
85
|
(event: React.MouseEvent<HTMLLIElement>) => {
|
|
70
|
-
onClick
|
|
86
|
+
if (onClick) onClick(event)
|
|
71
87
|
|
|
72
88
|
const target = event.target
|
|
73
89
|
|
|
@@ -101,35 +117,32 @@ export const TreeItem = memo(function TreeItem(
|
|
|
101
117
|
return registerItem(rootRef.current, itemPath.join('/'), expanded, selected)
|
|
102
118
|
}, [expanded, itemPath, registerItem, selected])
|
|
103
119
|
|
|
104
|
-
const content =
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{
|
|
115
|
-
<
|
|
116
|
-
<IconComponent />
|
|
117
|
-
</Text>
|
|
118
|
-
)}
|
|
119
|
-
{!IconComponent && (
|
|
120
|
-
<ToggleArrowText muted={muted} size={fontSize} weight={weight}>
|
|
121
|
-
<ToggleArrowRightIcon style={{transform: expanded ? 'rotate(90deg)' : undefined}} />
|
|
122
|
-
</ToggleArrowText>
|
|
123
|
-
)}
|
|
124
|
-
</Box>
|
|
125
|
-
<Box flex={1}>
|
|
126
|
-
<Text muted={muted} size={fontSize} textOverflow="ellipsis" weight={weight}>
|
|
127
|
-
{text}
|
|
120
|
+
const content = (
|
|
121
|
+
<Flex padding={padding}>
|
|
122
|
+
<Box
|
|
123
|
+
marginRight={space}
|
|
124
|
+
style={{
|
|
125
|
+
visibility: IconComponent || children ? 'visible' : 'hidden',
|
|
126
|
+
pointerEvents: 'none',
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
{IconComponent && (
|
|
130
|
+
<Text muted={muted} size={fontSize} weight={weight}>
|
|
131
|
+
<IconComponent />
|
|
128
132
|
</Text>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
)}
|
|
134
|
+
{!IconComponent && (
|
|
135
|
+
<ToggleArrowText muted={muted} size={fontSize} weight={weight}>
|
|
136
|
+
<ToggleArrowRightIcon style={{transform: expanded ? 'rotate(90deg)' : undefined}} />
|
|
137
|
+
</ToggleArrowText>
|
|
138
|
+
)}
|
|
139
|
+
</Box>
|
|
140
|
+
<Box flex={1}>
|
|
141
|
+
<Text muted={muted} size={fontSize} textOverflow="ellipsis" weight={weight}>
|
|
142
|
+
{text}
|
|
143
|
+
</Text>
|
|
144
|
+
</Box>
|
|
145
|
+
</Flex>
|
|
133
146
|
)
|
|
134
147
|
|
|
135
148
|
if (href) {
|
|
@@ -7,20 +7,19 @@ export type ArrayPropPrimitive = string | number | boolean | undefined | null
|
|
|
7
7
|
/**
|
|
8
8
|
* This API might change. DO NOT USE IN PRODUCTION.
|
|
9
9
|
* @beta
|
|
10
|
-
* @deprecated use `_getArrayProp` and `useMemo` directly instead
|
|
11
|
-
* @example
|
|
12
|
-
* ```diff
|
|
13
|
-
* -import {useArrayProp} from '@sanity/ui'
|
|
14
|
-
* +import {_getArrayProp} from '@sanity/ui'
|
|
15
|
-
* +import {useMemo} from 'react'
|
|
16
|
-
*
|
|
17
|
-
* -const width = useArrayProp(props.width)
|
|
18
|
-
* +const width = useMemo(() => _getArrayProp(props.width), [props.width])
|
|
19
|
-
* ```
|
|
20
10
|
*/
|
|
21
11
|
export function useArrayProp<T extends ArrayPropPrimitive = ArrayPropPrimitive>(
|
|
22
12
|
val: T | T[] | undefined,
|
|
23
13
|
defaultVal?: T[],
|
|
24
14
|
): T[] {
|
|
25
|
-
|
|
15
|
+
// JSON.stringify is fast, but it's not faster than useMemo's referencial equality check
|
|
16
|
+
const __perf_hash__ = useMemo(() => JSON.stringify(val ?? defaultVal), [defaultVal, val])
|
|
17
|
+
|
|
18
|
+
return useMemo(
|
|
19
|
+
() => _getArrayProp(val, defaultVal),
|
|
20
|
+
|
|
21
|
+
// Improve performance: Keep object identify for a given hash of the value
|
|
22
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
+
[__perf_hash__],
|
|
24
|
+
)
|
|
26
25
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {ThemeColorAvatarColorKey} from '@sanity/ui/theme'
|
|
2
|
-
import {forwardRef, useCallback, useEffect, useId, useState} from 'react'
|
|
3
|
-
import
|
|
2
|
+
import {forwardRef, useCallback, useEffect, useId, useMemo, useState} from 'react'
|
|
3
|
+
import ReactIs from 'react-is'
|
|
4
4
|
import {styled} from 'styled-components'
|
|
5
|
-
import {
|
|
5
|
+
import {useArrayProp} from '../../hooks'
|
|
6
6
|
import {useTheme_v2} from '../../theme'
|
|
7
7
|
import {AvatarPosition, AvatarSize, AvatarStatus} from '../../types'
|
|
8
8
|
import {Label} from '../label'
|
|
@@ -73,8 +73,8 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
73
73
|
...restProps
|
|
74
74
|
} = props
|
|
75
75
|
const {avatar} = useTheme_v2()
|
|
76
|
-
const as = isValidElementType(asProp) ? asProp : 'div'
|
|
77
|
-
const size =
|
|
76
|
+
const as = ReactIs.isValidElementType(asProp) ? asProp : 'div'
|
|
77
|
+
const size = useArrayProp(sizeProp)
|
|
78
78
|
|
|
79
79
|
// @todo: remove this
|
|
80
80
|
const avatarSize = avatar.sizes[size[0]] || avatar.sizes[0]
|
|
@@ -111,13 +111,17 @@ export const Avatar = forwardRef(function Avatar(
|
|
|
111
111
|
}
|
|
112
112
|
}, [onImageLoadError])
|
|
113
113
|
|
|
114
|
-
const initialsSize =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
const initialsSize = useMemo(
|
|
115
|
+
() =>
|
|
116
|
+
size.map((s) => {
|
|
117
|
+
if (s === 1) return 1
|
|
118
|
+
if (s === 2) return 3
|
|
119
|
+
if (s === 3) return 5
|
|
118
120
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
return 0
|
|
122
|
+
}),
|
|
123
|
+
[size],
|
|
124
|
+
)
|
|
121
125
|
|
|
122
126
|
return (
|
|
123
127
|
<Root
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {getTheme_v2} from '@sanity/ui/theme'
|
|
2
|
-
import {forwardRef} from 'react'
|
|
2
|
+
import {forwardRef, useMemo} from 'react'
|
|
3
3
|
import {styled, css} from 'styled-components'
|
|
4
4
|
import {EMPTY_RECORD} from '../../constants'
|
|
5
|
-
import {
|
|
5
|
+
import {useArrayProp} from '../../hooks'
|
|
6
|
+
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
6
7
|
import {AvatarSize} from '../../types'
|
|
7
8
|
import {Label} from '../label'
|
|
8
9
|
|
|
@@ -66,18 +67,23 @@ export const AvatarCounter = forwardRef(function AvatarCounter(
|
|
|
66
67
|
props: AvatarCounterProps,
|
|
67
68
|
ref: React.Ref<HTMLDivElement>,
|
|
68
69
|
) {
|
|
69
|
-
const {count, size} = props
|
|
70
|
-
const
|
|
71
|
-
const fontSize = $size.map((s) => {
|
|
72
|
-
if (s === 1) return 1
|
|
73
|
-
if (s === 2) return 3
|
|
74
|
-
if (s === 3) return 5
|
|
70
|
+
const {count, size: sizeProp = 1} = props
|
|
71
|
+
const size = useArrayProp(sizeProp)
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
const fontSize = useMemo(
|
|
74
|
+
() =>
|
|
75
|
+
size.map((s) => {
|
|
76
|
+
if (s === 1) return 1
|
|
77
|
+
if (s === 2) return 3
|
|
78
|
+
if (s === 3) return 5
|
|
79
|
+
|
|
80
|
+
return 0
|
|
81
|
+
}),
|
|
82
|
+
[size],
|
|
83
|
+
)
|
|
78
84
|
|
|
79
85
|
return (
|
|
80
|
-
<Root $size={
|
|
86
|
+
<Root $size={size} data-ui="AvatarCounter" ref={ref}>
|
|
81
87
|
<Label as="span" size={fontSize} weight="medium">
|
|
82
88
|
{count}
|
|
83
89
|
</Label>
|
|
@@ -2,7 +2,8 @@ import {getTheme_v2} from '@sanity/ui/theme'
|
|
|
2
2
|
import {Children, cloneElement, forwardRef, isValidElement, useMemo} from 'react'
|
|
3
3
|
import {styled, css} from 'styled-components'
|
|
4
4
|
import {EMPTY_RECORD} from '../../constants'
|
|
5
|
-
import {
|
|
5
|
+
import {useArrayProp} from '../../hooks'
|
|
6
|
+
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
6
7
|
import {AvatarSize} from '../../types'
|
|
7
8
|
import {AvatarCounter} from './avatarCounter'
|
|
8
9
|
|
|
@@ -64,9 +65,12 @@ export const AvatarStack = forwardRef(function AvatarStack(
|
|
|
64
65
|
size: sizeProp = 1,
|
|
65
66
|
...restProps
|
|
66
67
|
} = props
|
|
67
|
-
const children
|
|
68
|
+
const children = useMemo<React.ReactElement[]>(
|
|
69
|
+
() => Children.toArray(childrenProp).filter(isValidElement),
|
|
70
|
+
[childrenProp],
|
|
71
|
+
)
|
|
68
72
|
const maxLength = Math.max(maxLengthProp, 0)
|
|
69
|
-
const size =
|
|
73
|
+
const size = useArrayProp(sizeProp)
|
|
70
74
|
|
|
71
75
|
const len = children.length
|
|
72
76
|
const visibleCount = maxLength - 1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
|
-
import {
|
|
3
|
+
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
5
5
|
import {BadgeMode, BadgeTone} from '../../types'
|
|
6
6
|
import {Box, BoxProps} from '../box'
|
|
@@ -45,16 +45,13 @@ export const Badge = forwardRef(function Badge(
|
|
|
45
45
|
...restProps
|
|
46
46
|
} = props
|
|
47
47
|
|
|
48
|
-
const $radius = useMemo(() => _getArrayProp(radius), [radius])
|
|
49
|
-
const $padding = useMemo(() => _getArrayProp(padding), [padding])
|
|
50
|
-
|
|
51
48
|
return (
|
|
52
49
|
<Root
|
|
53
50
|
data-ui="Badge"
|
|
54
51
|
{...restProps}
|
|
55
52
|
$tone={tone}
|
|
56
|
-
$radius={
|
|
57
|
-
padding={
|
|
53
|
+
$radius={useArrayProp(radius)}
|
|
54
|
+
padding={useArrayProp(padding)}
|
|
58
55
|
ref={ref}
|
|
59
56
|
>
|
|
60
57
|
<Text size={fontSize}>{children}</Text>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
|
-
import {
|
|
3
|
+
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {
|
|
5
5
|
boxStyle,
|
|
6
6
|
flexItemStyle,
|
|
@@ -90,62 +90,36 @@ export const Box = forwardRef(function Box(
|
|
|
90
90
|
...restProps
|
|
91
91
|
} = props
|
|
92
92
|
|
|
93
|
-
const $column = useMemo(() => _getArrayProp(column), [column])
|
|
94
|
-
const $columnStart = useMemo(() => _getArrayProp(columnStart), [columnStart])
|
|
95
|
-
const $columnEnd = useMemo(() => _getArrayProp(columnEnd), [columnEnd])
|
|
96
|
-
const $display = useMemo(() => _getArrayProp(display), [display])
|
|
97
|
-
const $flex = useMemo(() => _getArrayProp(flex), [flex])
|
|
98
|
-
const $height = useMemo(() => _getArrayProp(height), [height])
|
|
99
|
-
const $margin = useMemo(() => _getArrayProp(margin), [margin])
|
|
100
|
-
const $marginX = useMemo(() => _getArrayProp(marginX), [marginX])
|
|
101
|
-
const $marginY = useMemo(() => _getArrayProp(marginY), [marginY])
|
|
102
|
-
const $marginTop = useMemo(() => _getArrayProp(marginTop), [marginTop])
|
|
103
|
-
const $marginRight = useMemo(() => _getArrayProp(marginRight), [marginRight])
|
|
104
|
-
const $marginBottom = useMemo(() => _getArrayProp(marginBottom), [marginBottom])
|
|
105
|
-
const $marginLeft = useMemo(() => _getArrayProp(marginLeft), [marginLeft])
|
|
106
|
-
const $overflow = useMemo(() => _getArrayProp(overflow), [overflow])
|
|
107
|
-
const $padding = useMemo(() => _getArrayProp(padding), [padding])
|
|
108
|
-
const $paddingX = useMemo(() => _getArrayProp(paddingX), [paddingX])
|
|
109
|
-
const $paddingY = useMemo(() => _getArrayProp(paddingY), [paddingY])
|
|
110
|
-
const $paddingTop = useMemo(() => _getArrayProp(paddingTop), [paddingTop])
|
|
111
|
-
const $paddingRight = useMemo(() => _getArrayProp(paddingRight), [paddingRight])
|
|
112
|
-
const $paddingBottom = useMemo(() => _getArrayProp(paddingBottom), [paddingBottom])
|
|
113
|
-
const $paddingLeft = useMemo(() => _getArrayProp(paddingLeft), [paddingLeft])
|
|
114
|
-
const $row = useMemo(() => _getArrayProp(row), [row])
|
|
115
|
-
const $rowStart = useMemo(() => _getArrayProp(rowStart), [rowStart])
|
|
116
|
-
const $rowEnd = useMemo(() => _getArrayProp(rowEnd), [rowEnd])
|
|
117
|
-
const $sizing = useMemo(() => _getArrayProp(sizing), [sizing])
|
|
118
|
-
|
|
119
93
|
return (
|
|
120
94
|
<Root
|
|
121
95
|
data-as={typeof asProp === 'string' ? asProp : undefined}
|
|
122
96
|
data-ui="Box"
|
|
123
97
|
{...restProps}
|
|
124
|
-
$column={
|
|
125
|
-
$columnStart={
|
|
126
|
-
$columnEnd={
|
|
127
|
-
$display={
|
|
128
|
-
$flex={
|
|
129
|
-
$height={
|
|
130
|
-
$margin={
|
|
131
|
-
$marginX={
|
|
132
|
-
$marginY={
|
|
133
|
-
$marginTop={
|
|
134
|
-
$marginRight={
|
|
135
|
-
$marginBottom={
|
|
136
|
-
$marginLeft={
|
|
137
|
-
$overflow={
|
|
138
|
-
$padding={
|
|
139
|
-
$paddingX={
|
|
140
|
-
$paddingY={
|
|
141
|
-
$paddingTop={
|
|
142
|
-
$paddingRight={
|
|
143
|
-
$paddingBottom={
|
|
144
|
-
$paddingLeft={
|
|
145
|
-
$row={
|
|
146
|
-
$rowStart={
|
|
147
|
-
$rowEnd={
|
|
148
|
-
$sizing={
|
|
98
|
+
$column={useArrayProp(column)}
|
|
99
|
+
$columnStart={useArrayProp(columnStart)}
|
|
100
|
+
$columnEnd={useArrayProp(columnEnd)}
|
|
101
|
+
$display={useArrayProp(display)}
|
|
102
|
+
$flex={useArrayProp(flex)}
|
|
103
|
+
$height={useArrayProp(height)}
|
|
104
|
+
$margin={useArrayProp(margin)}
|
|
105
|
+
$marginX={useArrayProp(marginX)}
|
|
106
|
+
$marginY={useArrayProp(marginY)}
|
|
107
|
+
$marginTop={useArrayProp(marginTop)}
|
|
108
|
+
$marginRight={useArrayProp(marginRight)}
|
|
109
|
+
$marginBottom={useArrayProp(marginBottom)}
|
|
110
|
+
$marginLeft={useArrayProp(marginLeft)}
|
|
111
|
+
$overflow={useArrayProp(overflow)}
|
|
112
|
+
$padding={useArrayProp(padding)}
|
|
113
|
+
$paddingX={useArrayProp(paddingX)}
|
|
114
|
+
$paddingY={useArrayProp(paddingY)}
|
|
115
|
+
$paddingTop={useArrayProp(paddingTop)}
|
|
116
|
+
$paddingRight={useArrayProp(paddingRight)}
|
|
117
|
+
$paddingBottom={useArrayProp(paddingBottom)}
|
|
118
|
+
$paddingLeft={useArrayProp(paddingLeft)}
|
|
119
|
+
$row={useArrayProp(row)}
|
|
120
|
+
$rowStart={useArrayProp(rowStart)}
|
|
121
|
+
$rowEnd={useArrayProp(rowEnd)}
|
|
122
|
+
$sizing={useArrayProp(sizing)}
|
|
149
123
|
as={asProp}
|
|
150
124
|
ref={ref}
|
|
151
125
|
>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {forwardRef, isValidElement, useMemo} from 'react'
|
|
2
2
|
import {isValidElementType} from 'react-is'
|
|
3
3
|
import {styled} from 'styled-components'
|
|
4
|
-
import {
|
|
4
|
+
import {useArrayProp} from '../../hooks'
|
|
5
|
+
import {ThemeProps} from '../../styles'
|
|
5
6
|
import {responsiveRadiusStyle, ResponsiveRadiusStyleProps} from '../../styles/internal'
|
|
6
7
|
import {useTheme_v2} from '../../theme'
|
|
7
8
|
import {ButtonMode, ButtonTextAlign, ButtonTone, ButtonWidth, FlexJustify} from '../../types'
|
|
@@ -92,16 +93,16 @@ export const Button = forwardRef(function Button(
|
|
|
92
93
|
} = props
|
|
93
94
|
const {button} = useTheme_v2()
|
|
94
95
|
|
|
95
|
-
const justify =
|
|
96
|
-
const padding =
|
|
97
|
-
const paddingX =
|
|
98
|
-
const paddingY =
|
|
99
|
-
const paddingTop =
|
|
100
|
-
const paddingBottom =
|
|
101
|
-
const paddingLeft =
|
|
102
|
-
const paddingRight =
|
|
103
|
-
const radius =
|
|
104
|
-
const space =
|
|
96
|
+
const justify = useArrayProp(justifyProp)
|
|
97
|
+
const padding = useArrayProp(paddingProp)
|
|
98
|
+
const paddingX = useArrayProp(paddingXProp)
|
|
99
|
+
const paddingY = useArrayProp(paddingYProp)
|
|
100
|
+
const paddingTop = useArrayProp(paddingTopProp)
|
|
101
|
+
const paddingBottom = useArrayProp(paddingBottomProp)
|
|
102
|
+
const paddingLeft = useArrayProp(paddingLeftProp)
|
|
103
|
+
const paddingRight = useArrayProp(paddingRightProp)
|
|
104
|
+
const radius = useArrayProp(radiusProp)
|
|
105
|
+
const space = useArrayProp(spaceProp)
|
|
105
106
|
|
|
106
107
|
const boxProps = useMemo(
|
|
107
108
|
() => ({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {ThemeColorSchemeKey} from '@sanity/ui/theme'
|
|
2
|
-
import {forwardRef
|
|
2
|
+
import {forwardRef} from 'react'
|
|
3
3
|
import {isValidElementType} from 'react-is'
|
|
4
4
|
import {styled} from 'styled-components'
|
|
5
|
-
import {
|
|
5
|
+
import {useArrayProp} from '../../hooks'
|
|
6
6
|
import {
|
|
7
7
|
responsiveBorderStyle,
|
|
8
8
|
ResponsiveBorderStyleProps,
|
|
@@ -82,14 +82,6 @@ export const Card = forwardRef(function Card(
|
|
|
82
82
|
const rootTheme = useRootTheme()
|
|
83
83
|
const tone = toneProp === 'inherit' ? rootTheme.tone : toneProp
|
|
84
84
|
|
|
85
|
-
const $border = useMemo(() => _getArrayProp(border), [border])
|
|
86
|
-
const $borderTop = useMemo(() => _getArrayProp(borderTop), [borderTop])
|
|
87
|
-
const $borderRight = useMemo(() => _getArrayProp(borderRight), [borderRight])
|
|
88
|
-
const $borderBottom = useMemo(() => _getArrayProp(borderBottom), [borderBottom])
|
|
89
|
-
const $borderLeft = useMemo(() => _getArrayProp(borderLeft), [borderLeft])
|
|
90
|
-
const $radius = useMemo(() => _getArrayProp(radius), [radius])
|
|
91
|
-
const $shadow = useMemo(() => _getArrayProp(shadow), [shadow])
|
|
92
|
-
|
|
93
85
|
// todo: Consider adding the wrapper approach for nested cards in which the tones are not changing, avoid unnecessary ThemeColorProvider
|
|
94
86
|
return (
|
|
95
87
|
<ThemeColorProvider scheme={scheme} tone={tone}>
|
|
@@ -99,16 +91,16 @@ export const Card = forwardRef(function Card(
|
|
|
99
91
|
data-ui="Card"
|
|
100
92
|
data-tone={tone}
|
|
101
93
|
{...restProps}
|
|
102
|
-
$border={
|
|
103
|
-
$borderTop={
|
|
104
|
-
$borderRight={
|
|
105
|
-
$borderBottom={
|
|
106
|
-
$borderLeft={
|
|
107
|
-
$radius={$radius}
|
|
108
|
-
$shadow={$shadow}
|
|
94
|
+
$border={useArrayProp(border)}
|
|
95
|
+
$borderTop={useArrayProp(borderTop)}
|
|
96
|
+
$borderRight={useArrayProp(borderRight)}
|
|
97
|
+
$borderBottom={useArrayProp(borderBottom)}
|
|
98
|
+
$borderLeft={useArrayProp(borderLeft)}
|
|
109
99
|
$checkered={checkered}
|
|
110
100
|
$focusRing={focusRing}
|
|
111
101
|
$muted={muted}
|
|
102
|
+
$radius={useArrayProp(radius)}
|
|
103
|
+
$shadow={useArrayProp(shadow)}
|
|
112
104
|
$tone={tone}
|
|
113
105
|
data-checkered={checkered ? '' : undefined}
|
|
114
106
|
data-pressed={pressed ? '' : undefined}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import {forwardRef
|
|
2
|
+
import {forwardRef} from 'react'
|
|
3
3
|
import Refractor from 'react-refractor'
|
|
4
4
|
import {styled} from 'styled-components'
|
|
5
|
-
import {
|
|
5
|
+
import {useArrayProp} from '../../hooks'
|
|
6
6
|
import {responsiveCodeFontStyle, ResponsiveFontStyleProps} from '../../styles/internal'
|
|
7
7
|
import {codeBaseStyle} from './styles'
|
|
8
8
|
|
|
@@ -29,10 +29,9 @@ export const Code = forwardRef(function Code(
|
|
|
29
29
|
const {children, language: languageProp, size = 2, weight, ...restProps} = props
|
|
30
30
|
const language = typeof languageProp === 'string' ? languageProp : undefined
|
|
31
31
|
const registered = language ? Refractor.hasLanguage(language as any) : false
|
|
32
|
-
const $size = useMemo(() => _getArrayProp(size), [size])
|
|
33
32
|
|
|
34
33
|
return (
|
|
35
|
-
<Root data-ui="Code" {...restProps} $size={
|
|
34
|
+
<Root data-ui="Code" {...restProps} $size={useArrayProp(size)} $weight={weight} ref={ref}>
|
|
36
35
|
{!(language && registered) && <code>{children}</code>}
|
|
37
36
|
{language && registered && <Refractor inline language={language} value={String(children)} />}
|
|
38
37
|
</Root>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
|
-
import {
|
|
3
|
+
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {Box, BoxProps} from '../box'
|
|
5
5
|
import {ResponsiveWidthProps} from '../types'
|
|
6
6
|
import {containerBaseStyle, responsiveContainerWidthStyle} from './styles'
|
|
@@ -26,7 +26,14 @@ export const Container = forwardRef(function Container(
|
|
|
26
26
|
ref: React.ForwardedRef<HTMLDivElement>,
|
|
27
27
|
) {
|
|
28
28
|
const {as, width = 2, ...restProps} = props
|
|
29
|
-
const $width = useMemo(() => _getArrayProp(width), [width])
|
|
30
29
|
|
|
31
|
-
return
|
|
30
|
+
return (
|
|
31
|
+
<Root
|
|
32
|
+
data-ui="Container"
|
|
33
|
+
{...restProps}
|
|
34
|
+
$width={useArrayProp(width)}
|
|
35
|
+
forwardedAs={as}
|
|
36
|
+
ref={ref}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
32
39
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {forwardRef
|
|
1
|
+
import {forwardRef} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
|
-
import {
|
|
3
|
+
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {
|
|
5
5
|
flexItemStyle,
|
|
6
6
|
FlexItemStyleProps,
|
|
@@ -36,21 +36,15 @@ export const Flex = forwardRef(function Flex(
|
|
|
36
36
|
) {
|
|
37
37
|
const {align, as, direction = 'row', gap, justify, wrap, ...restProps} = props
|
|
38
38
|
|
|
39
|
-
const $align = useMemo(() => _getArrayProp(align), [align])
|
|
40
|
-
const $direction = useMemo(() => _getArrayProp(direction), [direction])
|
|
41
|
-
const $gap = useMemo(() => _getArrayProp(gap), [gap])
|
|
42
|
-
const $justify = useMemo(() => _getArrayProp(justify), [justify])
|
|
43
|
-
const $wrap = useMemo(() => _getArrayProp(wrap), [wrap])
|
|
44
|
-
|
|
45
39
|
return (
|
|
46
40
|
<Root
|
|
47
41
|
data-ui="Flex"
|
|
48
42
|
{...restProps}
|
|
49
|
-
$align={
|
|
50
|
-
$direction={
|
|
51
|
-
$gap={
|
|
52
|
-
$justify={
|
|
53
|
-
$wrap={
|
|
43
|
+
$align={useArrayProp(align)}
|
|
44
|
+
$direction={useArrayProp(direction)}
|
|
45
|
+
$gap={useArrayProp(gap)}
|
|
46
|
+
$justify={useArrayProp(justify)}
|
|
47
|
+
$wrap={useArrayProp(wrap)}
|
|
54
48
|
forwardedAs={as}
|
|
55
49
|
ref={ref}
|
|
56
50
|
/>
|