@sanity/ui 2.3.6-canary.5 → 2.3.6-canary.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.compiled.mjs +36 -25
- package/dist/index.compiled.mjs.map +1 -1
- package/dist/index.esm.js +12 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/primitives/popover/popover.tsx +18 -16
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ import {AnimatePresence} from 'framer-motion'
|
|
|
14
14
|
import {
|
|
15
15
|
MutableRefObject,
|
|
16
16
|
RefCallback,
|
|
17
|
+
cloneElement,
|
|
17
18
|
forwardRef,
|
|
18
19
|
memo,
|
|
19
20
|
useCallback,
|
|
@@ -133,7 +134,7 @@ export const Popover = memo(
|
|
|
133
134
|
animate: _animate = false,
|
|
134
135
|
arrow: arrowProp = false,
|
|
135
136
|
boundaryElement: _boundaryElement,
|
|
136
|
-
children,
|
|
137
|
+
children: _children,
|
|
137
138
|
constrainSize = false,
|
|
138
139
|
content,
|
|
139
140
|
disabled,
|
|
@@ -366,12 +367,23 @@ export const Popover = memo(
|
|
|
366
367
|
useImperativeHandle(updateRef, () => update, [update])
|
|
367
368
|
|
|
368
369
|
useEffect(() => {
|
|
369
|
-
if (
|
|
370
|
+
if (_children) return
|
|
370
371
|
refs.setReference(referenceElement || null)
|
|
371
|
-
}, [
|
|
372
|
+
}, [_children, referenceElement, refs])
|
|
373
|
+
|
|
374
|
+
const children = useMemo(() => {
|
|
375
|
+
if (!_children || referenceElement) return null
|
|
376
|
+
|
|
377
|
+
return cloneElement(_children, {
|
|
378
|
+
ref: (node: HTMLDivElement | null): void => {
|
|
379
|
+
logDeprecatedWarning()
|
|
380
|
+
refs.setReference(node)
|
|
381
|
+
},
|
|
382
|
+
})
|
|
383
|
+
}, [_children, referenceElement, refs])
|
|
372
384
|
|
|
373
385
|
if (disabled) {
|
|
374
|
-
return
|
|
386
|
+
return _children || <></>
|
|
375
387
|
}
|
|
376
388
|
|
|
377
389
|
const popover = (
|
|
@@ -426,18 +438,8 @@ export const Popover = memo(
|
|
|
426
438
|
)}
|
|
427
439
|
</ConditionalWrapper>
|
|
428
440
|
|
|
429
|
-
{/* the referred element */}
|
|
430
|
-
{children
|
|
431
|
-
<div
|
|
432
|
-
ref={(node) => {
|
|
433
|
-
logDeprecatedWarning()
|
|
434
|
-
refs.setReference(node)
|
|
435
|
-
}}
|
|
436
|
-
style={{display: 'contents'}}
|
|
437
|
-
>
|
|
438
|
-
{children}
|
|
439
|
-
</div>
|
|
440
|
-
)}
|
|
441
|
+
{/* the referred element (legacy, use referenceElement instead) */}
|
|
442
|
+
{children}
|
|
441
443
|
</>
|
|
442
444
|
)
|
|
443
445
|
}),
|