@sanity/ui 2.8.2 → 2.8.3
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.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +16 -7
package/package.json
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
forwardRef,
|
|
4
|
+
Fragment,
|
|
5
|
+
isValidElement,
|
|
6
|
+
useCallback,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from 'react'
|
|
11
|
+
import {useArrayProp, useClickOutsideEvent} from '../../hooks'
|
|
3
12
|
import {Box, Popover, Stack, Text} from '../../primitives'
|
|
4
13
|
import {ExpandButton, Root} from './breadcrumbs.styles'
|
|
5
14
|
|
|
@@ -22,13 +31,13 @@ export const Breadcrumbs = forwardRef(function Breadcrumbs(
|
|
|
22
31
|
const {children, maxLength, separator, space: spaceRaw = 2, ...restProps} = props
|
|
23
32
|
const space = useArrayProp(spaceRaw)
|
|
24
33
|
const [open, setOpen] = useState(false)
|
|
25
|
-
const
|
|
26
|
-
const
|
|
34
|
+
const expandElementRef = useRef<HTMLButtonElement | null>(null)
|
|
35
|
+
const popoverElementRef = useRef<HTMLDivElement | null>(null)
|
|
27
36
|
|
|
28
37
|
const collapse = useCallback(() => setOpen(false), [])
|
|
29
38
|
const expand = useCallback(() => setOpen(true), [])
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
useClickOutsideEvent(collapse, () => [expandElementRef.current, popoverElementRef.current])
|
|
32
41
|
|
|
33
42
|
const rawItems = useMemo(() => Children.toArray(children).filter(isValidElement), [children])
|
|
34
43
|
|
|
@@ -52,14 +61,14 @@ export const Breadcrumbs = forwardRef(function Breadcrumbs(
|
|
|
52
61
|
open={open}
|
|
53
62
|
placement="top"
|
|
54
63
|
portal
|
|
55
|
-
ref={
|
|
64
|
+
ref={popoverElementRef}
|
|
56
65
|
>
|
|
57
66
|
<ExpandButton
|
|
58
67
|
fontSize={1}
|
|
59
68
|
mode="bleed"
|
|
60
69
|
onClick={open ? collapse : expand}
|
|
61
70
|
padding={1}
|
|
62
|
-
ref={
|
|
71
|
+
ref={expandElementRef}
|
|
63
72
|
selected={open}
|
|
64
73
|
text="…"
|
|
65
74
|
/>
|