@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/ui",
3
- "version": "2.9.0-canary.2",
3
+ "version": "2.9.0-canary.3",
4
4
  "keywords": [
5
5
  "sanity",
6
6
  "ui",
@@ -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 = useMemo(() => Children.toArray(children).filter(isValidElement), [children])
33
+ const rawItems = Children.toArray(children).filter(isValidElement)
43
34
 
44
- const items = useMemo(() => {
45
- const len = rawItems.length
35
+ let items = rawItems
36
+ const len = rawItems.length
46
37
 
47
- if (maxLength && len > maxLength) {
48
- const beforeLength = Math.ceil(maxLength / 2)
49
- const afterLength = Math.floor(maxLength / 2)
38
+ if (maxLength && rawItems.length > maxLength) {
39
+ const beforeLength = Math.ceil(maxLength / 2)
40
+ const afterLength = Math.floor(maxLength / 2)
50
41
 
51
- return [
52
- ...rawItems.slice(0, beforeLength - 1),
53
- <Popover
54
- constrainSize
55
- content={
56
- <Stack as="ol" overflow="auto" padding={space} space={space}>
57
- {rawItems.slice(beforeLength - 1, len - afterLength)}
58
- </Stack>
59
- }
60
- key="button"
61
- open={open}
62
- placement="top"
63
- portal
64
- ref={popoverElementRef}
65
- >
66
- <ExpandButton
67
- fontSize={1}
68
- mode="bleed"
69
- onClick={open ? collapse : expand}
70
- padding={1}
71
- ref={expandElementRef}
72
- selected={open}
73
- text="…"
74
- />
75
- </Popover>,
76
- ...rawItems.slice(len - afterLength),
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}>
@@ -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.