@sanity/ui 2.3.4 → 2.3.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/dist/index.esm.js +9 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +7 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +1 -7
- package/src/core/components/tree/tree.tsx +1 -1
- package/src/core/primitives/avatar/avatarStack.tsx +5 -5
- package/src/core/primitives/inline/inline.tsx +2 -6
- package/src/core/primitives/helpers.ts +0 -11
package/package.json
CHANGED
|
@@ -30,13 +30,7 @@ export const Breadcrumbs = forwardRef(function Breadcrumbs(
|
|
|
30
30
|
|
|
31
31
|
useClickOutside(collapse, [expandElement, popoverElement])
|
|
32
32
|
|
|
33
|
-
const rawItems = useMemo(
|
|
34
|
-
() =>
|
|
35
|
-
Children.toArray(children).filter((child) => {
|
|
36
|
-
return isValidElement(child)
|
|
37
|
-
}),
|
|
38
|
-
[children],
|
|
39
|
-
)
|
|
33
|
+
const rawItems = useMemo(() => Children.toArray(children).filter(isValidElement), [children])
|
|
40
34
|
|
|
41
35
|
const items = useMemo(() => {
|
|
42
36
|
const len = rawItems.length
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import {getTheme_v2} from '@sanity/ui/theme'
|
|
2
|
-
import {cloneElement, forwardRef} from 'react'
|
|
2
|
+
import {Children, cloneElement, forwardRef, isValidElement, useMemo} from 'react'
|
|
3
3
|
import {styled, css} from 'styled-components'
|
|
4
4
|
import {EMPTY_RECORD} from '../../constants'
|
|
5
5
|
import {useArrayProp} from '../../hooks'
|
|
6
6
|
import {rem, _responsive, ThemeProps} from '../../styles'
|
|
7
7
|
import {AvatarSize} from '../../types'
|
|
8
|
-
import {childrenToElementArray} from '../helpers'
|
|
9
8
|
import {AvatarCounter} from './avatarCounter'
|
|
10
9
|
|
|
11
10
|
const BASE_STYLES = css`
|
|
@@ -66,9 +65,10 @@ export const AvatarStack = forwardRef(function AvatarStack(
|
|
|
66
65
|
size: sizeProp = 1,
|
|
67
66
|
...restProps
|
|
68
67
|
} = props
|
|
69
|
-
const children =
|
|
70
|
-
(
|
|
71
|
-
|
|
68
|
+
const children = useMemo<React.ReactElement[]>(
|
|
69
|
+
() => Children.toArray(childrenProp).filter(isValidElement),
|
|
70
|
+
[childrenProp],
|
|
71
|
+
)
|
|
72
72
|
const maxLength = Math.max(maxLengthProp, 0)
|
|
73
73
|
const size = useArrayProp(sizeProp)
|
|
74
74
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {forwardRef, useMemo} from 'react'
|
|
1
|
+
import {forwardRef, useMemo, Children} from 'react'
|
|
2
2
|
import {styled} from 'styled-components'
|
|
3
3
|
import {useArrayProp} from '../../hooks'
|
|
4
4
|
import {Box, BoxProps} from '../box'
|
|
5
|
-
import {childrenToElementArray} from '../helpers'
|
|
6
5
|
import {inlineBaseStyle, inlineSpaceStyle} from './styles'
|
|
7
6
|
import {ResponsiveInlineSpaceStyleProps} from './types'
|
|
8
7
|
|
|
@@ -28,10 +27,7 @@ export const Inline = forwardRef(function Inline(
|
|
|
28
27
|
const {as, children: childrenProp, space, ...restProps} = props
|
|
29
28
|
|
|
30
29
|
const children = useMemo(
|
|
31
|
-
() =>
|
|
32
|
-
childrenToElementArray(childrenProp)
|
|
33
|
-
.filter(Boolean)
|
|
34
|
-
.map((child, idx) => <div key={idx}>{child}</div>),
|
|
30
|
+
() => Children.map(childrenProp, (child) => child && <div>{child}</div>),
|
|
35
31
|
[childrenProp],
|
|
36
32
|
)
|
|
37
33
|
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {isElement, isFragment} from 'react-is'
|
|
2
|
-
|
|
3
|
-
export function childrenToElementArray(
|
|
4
|
-
children: React.ReactNode,
|
|
5
|
-
): Array<React.ReactElement | string> {
|
|
6
|
-
const childrenArray = Array.isArray(children) ? children : [children]
|
|
7
|
-
|
|
8
|
-
return childrenArray.filter(
|
|
9
|
-
(node) => isElement(node) || isFragment(node) || typeof node === 'string',
|
|
10
|
-
) as Array<React.ReactElement | string>
|
|
11
|
-
}
|