@sanity/ui 0.37.13 → 0.37.14-next.5
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/lib/dts/src/components/autocomplete/autocomplete.styles.d.ts +1 -1
- package/lib/dts/src/components/autocomplete/autocomplete.styles.d.ts.map +1 -1
- package/lib/dts/src/components/autocomplete/constants.d.ts.map +1 -1
- package/lib/dts/src/constants.d.ts +10 -0
- package/lib/dts/src/constants.d.ts.map +1 -1
- package/lib/dts/src/primitives/popover/popover.d.ts +6 -5
- package/lib/dts/src/primitives/popover/popover.d.ts.map +1 -1
- package/lib/dts/src/primitives/popover/{arrow.d.ts → popoverArrow.d.ts} +1 -1
- package/lib/dts/src/primitives/popover/popoverArrow.d.ts.map +1 -0
- package/lib/dts/src/primitives/popover/popoverCard.d.ts +33 -0
- package/lib/dts/src/primitives/popover/popoverCard.d.ts.map +1 -0
- package/lib/dts/src/primitives/tooltip/tooltip.d.ts +2 -0
- package/lib/dts/src/primitives/tooltip/tooltip.d.ts.map +1 -1
- package/lib/dts/src/primitives/tooltip/tooltipArrow.d.ts.map +1 -1
- package/lib/sanity-ui.js +488 -439
- package/lib/sanity-ui.js.map +1 -1
- package/lib/sanity-ui.modern.mjs +561 -555
- package/lib/sanity-ui.modern.mjs.map +1 -1
- package/lib/sanity-ui.module.js +489 -439
- package/lib/sanity-ui.module.js.map +1 -1
- package/package.json +5 -6
- package/src/components/autocomplete/autocomplete.styles.tsx +0 -5
- package/src/components/autocomplete/constants.ts +3 -3
- package/src/constants.ts +17 -0
- package/src/primitives/popover/__workshop__/PlainStory.tsx +1 -0
- package/src/primitives/popover/__workshop__/RightAlignedStory.tsx +1 -0
- package/src/primitives/popover/__workshop__/TestStory.tsx +1 -0
- package/src/primitives/popover/popover.tsx +245 -195
- package/src/primitives/popover/{arrow.tsx → popoverArrow.tsx} +5 -5
- package/src/primitives/popover/popoverCard.tsx +160 -0
- package/src/primitives/tooltip/__workshop__/props.tsx +3 -1
- package/src/primitives/tooltip/tooltip.tsx +159 -83
- package/src/primitives/tooltip/tooltipArrow.tsx +25 -10
- package/lib/dts/src/primitives/popover/arrow.d.ts.map +0 -1
- package/lib/dts/src/primitives/popover/modifiers/getPopoverModifiers.d.ts +0 -4
- package/lib/dts/src/primitives/popover/modifiers/getPopoverModifiers.d.ts.map +0 -1
- package/lib/dts/src/primitives/popover/modifiers/index.d.ts +0 -2
- package/lib/dts/src/primitives/popover/modifiers/index.d.ts.map +0 -1
- package/lib/dts/src/primitives/popover/modifiers/types.d.ts +0 -18
- package/lib/dts/src/primitives/popover/modifiers/types.d.ts.map +0 -1
- package/lib/dts/src/primitives/popover/modifiers/usePopoverModifiers.d.ts +0 -4
- package/lib/dts/src/primitives/popover/modifiers/usePopoverModifiers.d.ts.map +0 -1
- package/src/primitives/popover/modifiers/getPopoverModifiers.ts +0 -137
- package/src/primitives/popover/modifiers/index.ts +0 -1
- package/src/primitives/popover/modifiers/types.ts +0 -18
- package/src/primitives/popover/modifiers/usePopoverModifiers.ts +0 -58
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.14-next.5+9c21947f",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -30,15 +30,14 @@
|
|
|
30
30
|
"watch:es": "tsc --preserveWatchOutput -w --module ES6 --outDir lib/esm --project tsconfig.lib.json --rootDir src --target ES6"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@floating-ui/react-dom": "^1.0.0",
|
|
33
34
|
"@juggle/resize-observer": "^3.4.0",
|
|
34
|
-
"@popperjs/core": "^2.11.6",
|
|
35
35
|
"@reach/auto-id": "^0.17.0",
|
|
36
|
-
"@sanity/color": "
|
|
37
|
-
"@sanity/icons": "
|
|
36
|
+
"@sanity/color": "2.1.13-next.5+9c21947f",
|
|
37
|
+
"@sanity/icons": "1.3.3-next.5+9c21947f",
|
|
38
38
|
"framer-motion": "6.3.0",
|
|
39
39
|
"popper-max-size-modifier": "^0.2.0",
|
|
40
40
|
"react-is": "^17.0.2",
|
|
41
|
-
"react-popper": "^2.3.0",
|
|
42
41
|
"react-refractor": "^2.1.7"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
@@ -72,5 +71,5 @@
|
|
|
72
71
|
"publishConfig": {
|
|
73
72
|
"access": "public"
|
|
74
73
|
},
|
|
75
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "9c21947f552622d210cce5225718985570fcdb25"
|
|
76
75
|
}
|
|
@@ -20,14 +20,14 @@ export const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [
|
|
|
20
20
|
/**
|
|
21
21
|
* @internal
|
|
22
22
|
*/
|
|
23
|
-
export const AUTOCOMPLETE_POPOVER_MARGINS: PopoverMargins = [0, 1,
|
|
23
|
+
export const AUTOCOMPLETE_POPOVER_MARGINS: PopoverMargins = [0, 1, 0, 0]
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @internal
|
|
27
27
|
*/
|
|
28
|
-
export const AUTOCOMPLETE_POPOVER_PLACEMENT: Placement = 'bottom
|
|
28
|
+
export const AUTOCOMPLETE_POPOVER_PLACEMENT: Placement = 'bottom'
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
|
-
export const AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS: Placement[] = ['top
|
|
33
|
+
export const AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS: Placement[] = ['bottom', 'top']
|
package/src/constants.ts
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/
|
|
1
4
|
export const EMPTY_ARRAY: any[] = []
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
2
9
|
export const EMPTY_RECORD: Record<string, any> = {}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export const FLOATING_STATIC_SIDES: Record<string, 'bottom' | 'left' | 'top' | 'right'> = {
|
|
15
|
+
top: 'bottom',
|
|
16
|
+
right: 'left',
|
|
17
|
+
bottom: 'top',
|
|
18
|
+
left: 'right',
|
|
19
|
+
}
|
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
Middleware,
|
|
3
|
+
arrow,
|
|
4
|
+
autoUpdate,
|
|
5
|
+
flip,
|
|
6
|
+
offset,
|
|
7
|
+
shift,
|
|
8
|
+
useFloating,
|
|
9
|
+
size as sizeMiddleware,
|
|
10
|
+
RootBoundary,
|
|
11
|
+
} from '@floating-ui/react-dom'
|
|
12
|
+
import React, {
|
|
13
|
+
cloneElement,
|
|
14
|
+
forwardRef,
|
|
15
|
+
memo,
|
|
16
|
+
useCallback,
|
|
17
|
+
useEffect,
|
|
18
|
+
useMemo,
|
|
19
|
+
useRef,
|
|
20
|
+
useState,
|
|
21
|
+
} from 'react'
|
|
22
|
+
import {useForwardedRef, useArrayProp, useElementSize} from '../../hooks'
|
|
6
23
|
import {ThemeColorSchemeKey, useTheme} from '../../theme'
|
|
7
|
-
import {CardTone, Placement, PopoverMargins} from '../../types'
|
|
8
|
-
import {
|
|
9
|
-
import {Card} from '../card'
|
|
10
|
-
import {ResponsiveWidthStyleProps} from '../container'
|
|
11
|
-
import {responsiveContainerWidthStyle} from '../container/styles'
|
|
24
|
+
import {BoxOverflow, CardTone, Placement, PopoverMargins} from '../../types'
|
|
25
|
+
import {LayerProps, LayerProvider, Portal, useBoundaryElement} from '../../utils'
|
|
12
26
|
import {ResponsiveRadiusProps, ResponsiveShadowProps, ResponsiveWidthProps} from '../types'
|
|
13
|
-
import {
|
|
14
|
-
import {usePopoverModifiers} from './modifiers'
|
|
27
|
+
import {PopoverCard} from './popoverCard'
|
|
15
28
|
|
|
16
29
|
/**
|
|
17
30
|
* @public
|
|
@@ -25,6 +38,7 @@ export interface PopoverProps
|
|
|
25
38
|
* @beta
|
|
26
39
|
*/
|
|
27
40
|
__unstable_margins?: PopoverMargins
|
|
41
|
+
/** @deprecated Use `fallbackPlacements` instead. */
|
|
28
42
|
allowedAutoPlacements?: Placement[]
|
|
29
43
|
arrow?: boolean
|
|
30
44
|
boundaryElement?: HTMLElement | null
|
|
@@ -34,6 +48,7 @@ export interface PopoverProps
|
|
|
34
48
|
disabled?: boolean
|
|
35
49
|
fallbackPlacements?: Placement[]
|
|
36
50
|
open?: boolean
|
|
51
|
+
overflow?: BoxOverflow
|
|
37
52
|
padding?: number | number[]
|
|
38
53
|
placement?: Placement
|
|
39
54
|
portal?: boolean | string
|
|
@@ -41,208 +56,243 @@ export interface PopoverProps
|
|
|
41
56
|
referenceElement?: HTMLElement | null
|
|
42
57
|
matchReferenceWidth?: boolean
|
|
43
58
|
scheme?: ThemeColorSchemeKey
|
|
59
|
+
/** @deprecated No longer supported. */
|
|
44
60
|
tether?: boolean
|
|
61
|
+
/** @deprecated No longer supported. */
|
|
45
62
|
tetherOffset?: number | ((...args: any[]) => number)
|
|
46
63
|
tone?: CardTone
|
|
47
64
|
}
|
|
48
65
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
function size(scope: {
|
|
67
|
+
boundaryElement: HTMLElement | null
|
|
68
|
+
constrainSize: boolean
|
|
69
|
+
matchReferenceWidth: boolean | undefined
|
|
70
|
+
setAvailableWidth: (v: number) => void
|
|
71
|
+
setAvailableHeight: (v: number) => void
|
|
72
|
+
setReferenceWidth: (v: number) => void
|
|
73
|
+
}) {
|
|
74
|
+
return sizeMiddleware({
|
|
75
|
+
apply(args) {
|
|
76
|
+
if (scope.constrainSize) {
|
|
77
|
+
scope.setAvailableWidth(args.availableWidth)
|
|
78
|
+
scope.setAvailableHeight(args.availableHeight)
|
|
79
|
+
}
|
|
55
80
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
if (scope.matchReferenceWidth) {
|
|
82
|
+
scope.setReferenceWidth(args.rects.reference.width)
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
boundary: scope.boundaryElement || undefined,
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const Popover = memo(
|
|
90
|
+
forwardRef(function Popover(
|
|
91
|
+
props: PopoverProps &
|
|
92
|
+
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'width'>,
|
|
93
|
+
ref: React.ForwardedRef<HTMLDivElement>
|
|
94
|
+
): React.ReactElement {
|
|
95
|
+
const theme = useTheme()
|
|
96
|
+
const boundaryElementContext = useBoundaryElement()
|
|
97
|
+
|
|
98
|
+
const {
|
|
99
|
+
__unstable_margins: margins,
|
|
100
|
+
allowedAutoPlacements,
|
|
101
|
+
arrow: arrowProp = true,
|
|
102
|
+
boundaryElement = boundaryElementContext.element,
|
|
103
|
+
children: childProp,
|
|
104
|
+
constrainSize = false,
|
|
105
|
+
content,
|
|
106
|
+
disabled,
|
|
107
|
+
fallbackPlacements,
|
|
108
|
+
matchReferenceWidth: matchReferenceWidthProp,
|
|
109
|
+
open,
|
|
110
|
+
overflow = props.constrainSize ? 'auto' : undefined,
|
|
111
|
+
padding: paddingProp,
|
|
112
|
+
placement: placementProp = 'bottom',
|
|
113
|
+
portal,
|
|
114
|
+
preventOverflow = true,
|
|
115
|
+
radius: radiusProp = 3,
|
|
116
|
+
referenceElement,
|
|
117
|
+
scheme,
|
|
118
|
+
shadow: shadowProp = 3,
|
|
119
|
+
tether,
|
|
120
|
+
tetherOffset,
|
|
121
|
+
tone = 'inherit',
|
|
122
|
+
width: widthProp = undefined,
|
|
123
|
+
zOffset: zOffsetProp = theme.sanity.layer?.popover.zOffset,
|
|
124
|
+
...restProps
|
|
125
|
+
} = props
|
|
126
|
+
const boundarySize = useElementSize(boundaryElement)?.border
|
|
127
|
+
const padding = useArrayProp(paddingProp)
|
|
128
|
+
const radius = useArrayProp(radiusProp)
|
|
129
|
+
const shadow = useArrayProp(shadowProp)
|
|
130
|
+
const width = useArrayProp(widthProp)
|
|
131
|
+
const zOffset = useArrayProp(zOffsetProp)
|
|
132
|
+
const [availableWidth, setAvailableWidth] = useState<number | undefined>(undefined)
|
|
133
|
+
const [availableHeight, setAvailableHeight] = useState<number | undefined>(undefined)
|
|
134
|
+
const [referenceWidth, setReferenceWidth] = useState<number | undefined>(undefined)
|
|
135
|
+
const forwardedRef = useForwardedRef(ref)
|
|
136
|
+
const arrowRef = useRef<HTMLDivElement | null>(null)
|
|
137
|
+
const rootBoundary: RootBoundary = 'viewport'
|
|
138
|
+
|
|
139
|
+
const middleware = useMemo(() => {
|
|
140
|
+
const ret: Middleware[] = []
|
|
59
141
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
142
|
+
// Flip the floating element when leaving the boundary box
|
|
143
|
+
if (constrainSize || preventOverflow) {
|
|
144
|
+
ret.push(
|
|
145
|
+
flip({
|
|
146
|
+
boundary: boundaryElement || undefined,
|
|
147
|
+
fallbackPlacements,
|
|
148
|
+
padding: 8,
|
|
149
|
+
rootBoundary,
|
|
150
|
+
})
|
|
151
|
+
)
|
|
65
152
|
}
|
|
66
|
-
`}
|
|
67
|
-
`
|
|
68
|
-
)
|
|
69
153
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
&& {
|
|
83
|
-
display: flex;
|
|
84
|
-
}
|
|
154
|
+
// Track sizes
|
|
155
|
+
ret.push(
|
|
156
|
+
size({
|
|
157
|
+
boundaryElement,
|
|
158
|
+
constrainSize,
|
|
159
|
+
matchReferenceWidth: matchReferenceWidthProp,
|
|
160
|
+
setAvailableHeight,
|
|
161
|
+
setAvailableWidth,
|
|
162
|
+
setReferenceWidth,
|
|
163
|
+
})
|
|
164
|
+
)
|
|
85
165
|
|
|
86
|
-
|
|
166
|
+
// Define distance between reference and floating element
|
|
167
|
+
ret.push(offset({mainAxis: arrowProp ? 4 : 0}))
|
|
87
168
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
169
|
+
// Shift the popover so its sits with the boundary eleement
|
|
170
|
+
if (preventOverflow) {
|
|
171
|
+
ret.push(
|
|
172
|
+
shift({
|
|
173
|
+
boundary: boundaryElement || undefined,
|
|
174
|
+
rootBoundary,
|
|
175
|
+
padding: 8,
|
|
176
|
+
})
|
|
177
|
+
)
|
|
178
|
+
}
|
|
91
179
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
)
|
|
180
|
+
// Place arrow
|
|
181
|
+
if (arrowProp) {
|
|
182
|
+
ret.push(arrow({element: arrowRef, padding: 4}))
|
|
183
|
+
}
|
|
95
184
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const theme = useTheme()
|
|
106
|
-
const {
|
|
107
|
-
__unstable_margins: margins,
|
|
108
|
-
allowedAutoPlacements,
|
|
109
|
-
arrow = true,
|
|
110
|
-
boundaryElement: boundaryElementProp = boundaryElementContext.element,
|
|
111
|
-
children: child,
|
|
112
|
-
content,
|
|
113
|
-
constrainSize,
|
|
114
|
-
disabled,
|
|
115
|
-
fallbackPlacements,
|
|
116
|
-
open = false,
|
|
117
|
-
padding,
|
|
118
|
-
placement = 'bottom',
|
|
119
|
-
portal: portalProp = false,
|
|
120
|
-
preventOverflow,
|
|
121
|
-
radius = 3,
|
|
122
|
-
referenceElement: referenceElementProp,
|
|
123
|
-
matchReferenceWidth,
|
|
124
|
-
shadow = 3,
|
|
125
|
-
scheme,
|
|
126
|
-
style = EMPTY_RECORD,
|
|
127
|
-
tether,
|
|
128
|
-
tetherOffset,
|
|
129
|
-
tone = 'inherit',
|
|
130
|
-
width: widthProp = 0,
|
|
131
|
-
zOffset = theme.sanity.layer?.popover.zOffset,
|
|
132
|
-
...restProps
|
|
133
|
-
} = props
|
|
134
|
-
const forwardedRef = useForwardedRef(ref)
|
|
135
|
-
const portal = usePortal()
|
|
136
|
-
const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null)
|
|
137
|
-
const [popperElement, setPopperElement] = useState<HTMLElement | null>(null)
|
|
138
|
-
const [arrowElement, setArrowElement] = useState<HTMLElement | null>(null)
|
|
139
|
-
const popperReferenceElement = referenceElementProp || referenceElement
|
|
140
|
-
const width = useArrayProp(widthProp)
|
|
141
|
-
|
|
142
|
-
const modifiers = usePopoverModifiers({
|
|
143
|
-
allowedAutoPlacements,
|
|
144
|
-
arrow,
|
|
145
|
-
arrowElement,
|
|
146
|
-
boundaryElement: boundaryElementProp || portal.boundaryElement,
|
|
147
|
-
constrainSize,
|
|
148
|
-
distance: arrow ? 4 : 0,
|
|
149
|
-
fallbackPlacements,
|
|
150
|
-
margins,
|
|
151
|
-
matchReferenceWidth,
|
|
152
|
-
open,
|
|
153
|
-
preventOverflow,
|
|
154
|
-
skidding: 0,
|
|
155
|
-
tether,
|
|
156
|
-
tetherOffset,
|
|
157
|
-
})
|
|
185
|
+
return ret
|
|
186
|
+
}, [
|
|
187
|
+
arrowProp,
|
|
188
|
+
boundaryElement,
|
|
189
|
+
constrainSize,
|
|
190
|
+
fallbackPlacements,
|
|
191
|
+
matchReferenceWidthProp,
|
|
192
|
+
preventOverflow,
|
|
193
|
+
])
|
|
158
194
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
195
|
+
const {x, y, placement, reference, floating, middlewareData, strategy} = useFloating({
|
|
196
|
+
middleware,
|
|
197
|
+
placement: placementProp,
|
|
198
|
+
whileElementsMounted: autoUpdate,
|
|
199
|
+
})
|
|
163
200
|
|
|
164
|
-
|
|
201
|
+
const arrowX = middlewareData.arrow?.x
|
|
202
|
+
const arrowY = middlewareData.arrow?.y
|
|
165
203
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
204
|
+
const setArrow = useCallback((arrowEl: HTMLDivElement | null) => {
|
|
205
|
+
arrowRef.current = arrowEl
|
|
206
|
+
}, [])
|
|
169
207
|
|
|
170
|
-
|
|
208
|
+
const setFloating = useCallback(
|
|
209
|
+
(node: HTMLDivElement | null) => {
|
|
210
|
+
forwardedRef.current = node
|
|
211
|
+
floating(node)
|
|
212
|
+
},
|
|
213
|
+
[floating, forwardedRef]
|
|
214
|
+
)
|
|
171
215
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
childRef.current = el
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
[child]
|
|
179
|
-
)
|
|
216
|
+
const setReference = useCallback(
|
|
217
|
+
(node: HTMLElement | null) => {
|
|
218
|
+
reference(node)
|
|
180
219
|
|
|
181
|
-
|
|
182
|
-
(el: HTMLDivElement | null) => {
|
|
183
|
-
setPopperElement(el)
|
|
184
|
-
forwardedRef.current = el
|
|
185
|
-
},
|
|
186
|
-
[forwardedRef]
|
|
187
|
-
)
|
|
220
|
+
const childRef = (childProp as any)?.ref
|
|
188
221
|
|
|
189
|
-
|
|
222
|
+
if (typeof childRef === 'function') {
|
|
223
|
+
childRef(node)
|
|
224
|
+
} else if (childRef) {
|
|
225
|
+
childRef.current = node
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
[childProp, reference]
|
|
229
|
+
)
|
|
190
230
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
231
|
+
const child = useMemo(() => {
|
|
232
|
+
if (!childProp || referenceElement) return null
|
|
233
|
+
|
|
234
|
+
return cloneElement(childProp, {ref: setReference})
|
|
235
|
+
}, [childProp, referenceElement, setReference])
|
|
236
|
+
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
if (referenceElement) reference(referenceElement)
|
|
239
|
+
}, [reference, referenceElement])
|
|
240
|
+
|
|
241
|
+
if (disabled) {
|
|
242
|
+
return childProp || <></>
|
|
198
243
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
|
|
245
|
+
const popover = (
|
|
246
|
+
<LayerProvider zOffset={zOffset}>
|
|
247
|
+
<PopoverCard
|
|
248
|
+
{...restProps}
|
|
249
|
+
__unstable_margins={margins}
|
|
250
|
+
arrow={arrowProp}
|
|
251
|
+
arrowRef={setArrow}
|
|
252
|
+
arrowX={arrowX}
|
|
253
|
+
arrowY={arrowY}
|
|
254
|
+
availableWidth={constrainSize ? availableWidth : undefined}
|
|
255
|
+
availableHeight={constrainSize ? availableHeight : undefined}
|
|
256
|
+
boundaryWidth={boundarySize?.width}
|
|
257
|
+
overflow={overflow}
|
|
258
|
+
padding={padding}
|
|
259
|
+
placement={placement}
|
|
260
|
+
radius={radius}
|
|
261
|
+
ref={setFloating}
|
|
262
|
+
referenceWidth={matchReferenceWidthProp ? referenceWidth : undefined}
|
|
263
|
+
scheme={scheme}
|
|
264
|
+
shadow={shadow}
|
|
265
|
+
strategy={strategy}
|
|
266
|
+
tone={tone}
|
|
267
|
+
x={x}
|
|
268
|
+
y={y}
|
|
269
|
+
width={width}
|
|
270
|
+
>
|
|
271
|
+
{content}
|
|
272
|
+
</PopoverCard>
|
|
273
|
+
</LayerProvider>
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
return (
|
|
277
|
+
<>
|
|
278
|
+
{/* the popover */}
|
|
279
|
+
{open && (
|
|
280
|
+
<>
|
|
281
|
+
{portal ? (
|
|
282
|
+
<Portal __unstable_name={typeof portal === 'string' ? portal : undefined}>
|
|
283
|
+
{popover}
|
|
284
|
+
</Portal>
|
|
285
|
+
) : (
|
|
286
|
+
popover
|
|
287
|
+
)}
|
|
288
|
+
</>
|
|
289
|
+
)}
|
|
290
|
+
|
|
291
|
+
{/* the referred element */}
|
|
292
|
+
{child}
|
|
293
|
+
</>
|
|
294
|
+
)
|
|
295
|
+
})
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
Popover.displayName = 'Popover'
|
|
@@ -17,11 +17,11 @@ const Root = styled.div`
|
|
|
17
17
|
transform-origin: 13.5px 13.5px;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
[data-
|
|
20
|
+
[data-placement^='top'] > & {
|
|
21
21
|
bottom: -27px;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
[data-
|
|
24
|
+
[data-placement^='right'] > & {
|
|
25
25
|
left: -27px;
|
|
26
26
|
|
|
27
27
|
& > svg {
|
|
@@ -29,7 +29,7 @@ const Root = styled.div`
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
[data-
|
|
32
|
+
[data-placement^='left'] > & {
|
|
33
33
|
right: -27px;
|
|
34
34
|
|
|
35
35
|
& > svg {
|
|
@@ -37,7 +37,7 @@ const Root = styled.div`
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
[data-
|
|
40
|
+
[data-placement^='bottom'] > & {
|
|
41
41
|
top: -27px;
|
|
42
42
|
|
|
43
43
|
& > svg {
|
|
@@ -59,7 +59,7 @@ export const PopoverArrow = forwardRef(function PopoverArrow(
|
|
|
59
59
|
ref: React.ForwardedRef<HTMLDivElement>
|
|
60
60
|
) {
|
|
61
61
|
return (
|
|
62
|
-
<Root data-ui="
|
|
62
|
+
<Root data-ui="Popover__arrow" {...props} ref={ref}>
|
|
63
63
|
<svg
|
|
64
64
|
width="27"
|
|
65
65
|
height="11"
|