@sanity/ui 2.9.0-canary.2 → 2.9.0-canary.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 +35 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +35 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +35 -47
- package/src/core/constants.ts +1 -1
package/package.json
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Children,
|
|
3
|
-
forwardRef,
|
|
4
|
-
Fragment,
|
|
5
|
-
isValidElement,
|
|
6
|
-
useCallback,
|
|
7
|
-
useMemo,
|
|
8
|
-
useRef,
|
|
9
|
-
useState,
|
|
10
|
-
} from 'react'
|
|
1
|
+
import {Children, forwardRef, Fragment, isValidElement, useCallback, useRef, useState} from 'react'
|
|
11
2
|
import {useArrayProp, useClickOutsideEvent} from '../../hooks'
|
|
12
3
|
import {Box, Popover, Stack, Text} from '../../primitives'
|
|
13
4
|
import {ExpandButton, Root} from './breadcrumbs.styles'
|
|
@@ -39,46 +30,43 @@ export const Breadcrumbs = forwardRef(function Breadcrumbs(
|
|
|
39
30
|
|
|
40
31
|
useClickOutsideEvent(collapse, () => [expandElementRef.current, popoverElementRef.current])
|
|
41
32
|
|
|
42
|
-
const rawItems =
|
|
33
|
+
const rawItems = Children.toArray(children).filter(isValidElement)
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
let items = rawItems
|
|
36
|
+
const len = rawItems.length
|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
if (maxLength && rawItems.length > maxLength) {
|
|
39
|
+
const beforeLength = Math.ceil(maxLength / 2)
|
|
40
|
+
const afterLength = Math.floor(maxLength / 2)
|
|
50
41
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return rawItems
|
|
81
|
-
}, [collapse, expand, maxLength, open, rawItems, space])
|
|
42
|
+
items = [
|
|
43
|
+
...rawItems.slice(0, beforeLength - 1),
|
|
44
|
+
<Popover
|
|
45
|
+
constrainSize
|
|
46
|
+
content={
|
|
47
|
+
<Stack as="ol" overflow="auto" padding={space} space={space}>
|
|
48
|
+
{rawItems.slice(beforeLength - 1, len - afterLength)}
|
|
49
|
+
</Stack>
|
|
50
|
+
}
|
|
51
|
+
key="button"
|
|
52
|
+
open={open}
|
|
53
|
+
placement="top"
|
|
54
|
+
portal
|
|
55
|
+
ref={popoverElementRef}
|
|
56
|
+
>
|
|
57
|
+
<ExpandButton
|
|
58
|
+
fontSize={1}
|
|
59
|
+
mode="bleed"
|
|
60
|
+
onClick={open ? collapse : expand}
|
|
61
|
+
padding={1}
|
|
62
|
+
ref={expandElementRef}
|
|
63
|
+
selected={open}
|
|
64
|
+
text="…"
|
|
65
|
+
/>
|
|
66
|
+
</Popover>,
|
|
67
|
+
...rawItems.slice(len - afterLength),
|
|
68
|
+
]
|
|
69
|
+
}
|
|
82
70
|
|
|
83
71
|
return (
|
|
84
72
|
<Root data-ui="Breadcrumbs" {...restProps} ref={ref}>
|
package/src/core/constants.ts
CHANGED
|
@@ -13,7 +13,7 @@ export const EMPTY_RECORD: Record<string, never> = {}
|
|
|
13
13
|
/**
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
export const POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = '--motion-content-opacity'
|
|
16
|
+
export const POPOVER_MOTION_CONTENT_OPACITY_PROPERTY = '--motion-content-opacity' as string
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Shared `framer-motion` variants used by `Popover` and `Tooltip` components.
|