@sanity/ui 2.0.0-alpha.21 → 2.0.0-alpha.22
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.ts +2 -0
- package/dist/index.esm.js +18 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +18 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/autocomplete/autocomplete.tsx +1 -1
- package/src/components/toast/toast.tsx +8 -3
- package/src/primitives/badge/styles.ts +3 -1
- package/src/primitives/tooltip/constants.ts +1 -0
- package/src/primitives/tooltip/tooltip.tsx +13 -5
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ export interface ToastProps {
|
|
|
10
10
|
closable?: boolean
|
|
11
11
|
description?: React.ReactNode
|
|
12
12
|
onClose?: () => void
|
|
13
|
+
radius?: number | number[]
|
|
13
14
|
title?: React.ReactNode
|
|
14
15
|
status?: 'error' | 'warning' | 'success' | 'info'
|
|
15
16
|
}
|
|
@@ -46,7 +47,7 @@ const TextBox = styled(Flex)`
|
|
|
46
47
|
export function Toast(
|
|
47
48
|
props: ToastProps & Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'height' | 'ref' | 'title'>,
|
|
48
49
|
): React.ReactElement {
|
|
49
|
-
const {closable, description, onClose, title, status, ...restProps} = props
|
|
50
|
+
const {closable, description, onClose, radius = 3, title, status, ...restProps} = props
|
|
50
51
|
const cardTone = status ? STATUS_CARD_TONE[status] : 'default'
|
|
51
52
|
const role = status ? ROLES[status] : 'status'
|
|
52
53
|
|
|
@@ -56,14 +57,18 @@ export function Toast(
|
|
|
56
57
|
role={role}
|
|
57
58
|
{...restProps}
|
|
58
59
|
marginTop={3}
|
|
59
|
-
radius={
|
|
60
|
+
radius={radius}
|
|
60
61
|
shadow={2}
|
|
61
62
|
tone={cardTone}
|
|
62
63
|
>
|
|
63
64
|
<Flex align="flex-start">
|
|
64
65
|
<TextBox flex={1} padding={3}>
|
|
65
66
|
<Stack space={3}>
|
|
66
|
-
{title &&
|
|
67
|
+
{title && (
|
|
68
|
+
<Text size={1} weight="medium">
|
|
69
|
+
{title}
|
|
70
|
+
</Text>
|
|
71
|
+
)}
|
|
67
72
|
{description && (
|
|
68
73
|
<Text muted size={1}>
|
|
69
74
|
{description}
|
|
@@ -8,7 +8,9 @@ export function badgeStyle(props: BadgeStyleProps & ThemeProps): CSSObject {
|
|
|
8
8
|
const color = palette[$tone] || palette.default
|
|
9
9
|
|
|
10
10
|
return {
|
|
11
|
-
|
|
11
|
+
'--card-fg-color': color.enabled.fg,
|
|
12
|
+
|
|
13
|
+
backgroundColor: color.enabled.bg2,
|
|
12
14
|
color: color.enabled.fg,
|
|
13
15
|
boxShadow: `inset 0 0 0 1px ${color.enabled.border}`,
|
|
14
16
|
cursor: 'default',
|
|
@@ -30,7 +30,11 @@ import {Placement} from '../../types'
|
|
|
30
30
|
import {Layer, LayerProps, Portal, useBoundaryElement, usePortal} from '../../utils'
|
|
31
31
|
import {Card} from '../card'
|
|
32
32
|
import {Delay} from '../types'
|
|
33
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
DEFAULT_FALLBACK_PLACEMENTS,
|
|
35
|
+
DEFAULT_TOOLTIP_DISTANCE,
|
|
36
|
+
DEFAULT_TOOLTIP_PADDING,
|
|
37
|
+
} from './constants'
|
|
34
38
|
import {TooltipArrow} from './tooltipArrow'
|
|
35
39
|
import {useTooltipDelayGroup} from './tooltipDelayGroup'
|
|
36
40
|
|
|
@@ -40,6 +44,7 @@ import {useTooltipDelayGroup} from './tooltipDelayGroup'
|
|
|
40
44
|
export interface TooltipProps extends Omit<LayerProps, 'as'> {
|
|
41
45
|
/** @deprecated Use `fallbackPlacements` instead. */
|
|
42
46
|
allowedAutoPlacements?: Placement[]
|
|
47
|
+
arrow?: boolean
|
|
43
48
|
boundaryElement?: HTMLElement | null
|
|
44
49
|
children?: React.ReactElement
|
|
45
50
|
content?: React.ReactNode
|
|
@@ -78,6 +83,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
78
83
|
const boundaryElementContext = useBoundaryElement()
|
|
79
84
|
const theme = useTheme()
|
|
80
85
|
const {
|
|
86
|
+
arrow: arrowProp = true,
|
|
81
87
|
boundaryElement = boundaryElementContext?.element,
|
|
82
88
|
children: childProp,
|
|
83
89
|
content,
|
|
@@ -129,7 +135,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
129
135
|
)
|
|
130
136
|
|
|
131
137
|
// Define distance between reference and floating element
|
|
132
|
-
ret.push(offset({mainAxis:
|
|
138
|
+
ret.push(offset({mainAxis: DEFAULT_TOOLTIP_DISTANCE}))
|
|
133
139
|
|
|
134
140
|
// Shift the tooltip so its sits with the boundary element
|
|
135
141
|
ret.push(
|
|
@@ -141,10 +147,12 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
141
147
|
)
|
|
142
148
|
|
|
143
149
|
// Place arrow
|
|
144
|
-
|
|
150
|
+
if (arrowProp) {
|
|
151
|
+
ret.push(arrow({element: arrowRef, padding: 2}))
|
|
152
|
+
}
|
|
145
153
|
|
|
146
154
|
return ret
|
|
147
|
-
}, [boundaryElement, fallbackPlacements])
|
|
155
|
+
}, [arrowProp, boundaryElement, fallbackPlacements])
|
|
148
156
|
|
|
149
157
|
const {floatingStyles, placement, middlewareData, refs, update} = useFloating({
|
|
150
158
|
middleware,
|
|
@@ -384,7 +392,7 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
384
392
|
shadow={shadow}
|
|
385
393
|
>
|
|
386
394
|
{content}
|
|
387
|
-
<TooltipArrow ref={setArrow} style={arrowStyle} />
|
|
395
|
+
{arrowProp && <TooltipArrow ref={setArrow} style={arrowStyle} />}
|
|
388
396
|
</Card>
|
|
389
397
|
</Root>
|
|
390
398
|
)
|