@sanity/ui 3.0.11 → 3.0.12-canary.0
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/_chunks-cjs/_visual-editing.js +515 -215
- package/dist/_chunks-cjs/_visual-editing.js.map +1 -1
- package/dist/_chunks-es/_visual-editing.mjs +517 -217
- package/dist/_chunks-es/_visual-editing.mjs.map +1 -1
- package/dist/_visual-editing.d.mts +2 -5
- package/dist/_visual-editing.d.ts +2 -5
- package/dist/index.d.mts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +71 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +26 -40
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +67 -38
- package/src/core/primitives/popover/floating-ui/size.ts +32 -16
- package/src/core/primitives/popover/popover.tsx +171 -139
- package/src/core/primitives/tooltip/tooltip.tsx +70 -42
- package/src/core/utils/virtualList/virtualList.tsx +48 -23
|
@@ -5,10 +5,9 @@ import {ForwardRefExoticComponent} from 'react'
|
|
|
5
5
|
import {HTMLAttributes} from 'react'
|
|
6
6
|
import {HTMLProps} from 'react'
|
|
7
7
|
import {IStyledComponentBase} from 'styled-components/dist/types'
|
|
8
|
-
import {MutableRefObject} from 'react'
|
|
9
8
|
import {NamedExoticComponent} from 'react'
|
|
9
|
+
import {Ref} from 'react'
|
|
10
10
|
import {RefAttributes} from 'react'
|
|
11
|
-
import {RefCallback} from 'react'
|
|
12
11
|
import {RootTheme} from '@sanity/ui/theme'
|
|
13
12
|
import {Theme_v2} from '@sanity/ui/theme'
|
|
14
13
|
import {ThemeColorButtonModeKey} from '@sanity/ui/theme'
|
|
@@ -559,9 +558,7 @@ declare interface PopoverProps
|
|
|
559
558
|
scheme?: ThemeColorSchemeKey
|
|
560
559
|
tone?: CardTone
|
|
561
560
|
/** @beta */
|
|
562
|
-
updateRef?:
|
|
563
|
-
| MutableRefObject<PopoverUpdateCallback | undefined>
|
|
564
|
-
| RefCallback<PopoverUpdateCallback | undefined>
|
|
561
|
+
updateRef?: Ref<PopoverUpdateCallback | undefined>
|
|
565
562
|
width?: PopoverWidth | PopoverWidth[]
|
|
566
563
|
}
|
|
567
564
|
|
|
@@ -5,10 +5,9 @@ import {ForwardRefExoticComponent} from 'react'
|
|
|
5
5
|
import {HTMLAttributes} from 'react'
|
|
6
6
|
import {HTMLProps} from 'react'
|
|
7
7
|
import {IStyledComponentBase} from 'styled-components/dist/types'
|
|
8
|
-
import {MutableRefObject} from 'react'
|
|
9
8
|
import {NamedExoticComponent} from 'react'
|
|
9
|
+
import {Ref} from 'react'
|
|
10
10
|
import {RefAttributes} from 'react'
|
|
11
|
-
import {RefCallback} from 'react'
|
|
12
11
|
import {RootTheme} from '@sanity/ui/theme'
|
|
13
12
|
import {Theme_v2} from '@sanity/ui/theme'
|
|
14
13
|
import {ThemeColorButtonModeKey} from '@sanity/ui/theme'
|
|
@@ -559,9 +558,7 @@ declare interface PopoverProps
|
|
|
559
558
|
scheme?: ThemeColorSchemeKey
|
|
560
559
|
tone?: CardTone
|
|
561
560
|
/** @beta */
|
|
562
|
-
updateRef?:
|
|
563
|
-
| MutableRefObject<PopoverUpdateCallback | undefined>
|
|
564
|
-
| RefCallback<PopoverUpdateCallback | undefined>
|
|
561
|
+
updateRef?: Ref<PopoverUpdateCallback | undefined>
|
|
565
562
|
width?: PopoverWidth | PopoverWidth[]
|
|
566
563
|
}
|
|
567
564
|
|
package/dist/index.d.mts
CHANGED
|
@@ -14,7 +14,6 @@ import {HTMLAttributes} from 'react'
|
|
|
14
14
|
import {HTMLProps} from 'react'
|
|
15
15
|
import {IStyledComponentBase} from 'styled-components/dist/types'
|
|
16
16
|
import {multiply as multiply_2} from '@sanity/ui/theme'
|
|
17
|
-
import {MutableRefObject} from 'react'
|
|
18
17
|
import {NamedExoticComponent} from 'react'
|
|
19
18
|
import {parseColor as parseColor_2} from '@sanity/ui/theme'
|
|
20
19
|
import {PartialThemeColorBuilderOpts} from '@sanity/ui/theme'
|
|
@@ -22,7 +21,6 @@ import {PropsWithChildren} from 'react'
|
|
|
22
21
|
import {ReactNode} from 'react'
|
|
23
22
|
import {Ref} from 'react'
|
|
24
23
|
import {RefAttributes} from 'react'
|
|
25
|
-
import {RefCallback} from 'react'
|
|
26
24
|
import {RGB as RGB_2} from '@sanity/ui/theme'
|
|
27
25
|
import {rgba as rgba_2} from '@sanity/ui/theme'
|
|
28
26
|
import {rgbToHex as rgbToHex_2} from '@sanity/ui/theme'
|
|
@@ -1618,9 +1616,7 @@ export declare interface PopoverProps
|
|
|
1618
1616
|
scheme?: ThemeColorSchemeKey_2
|
|
1619
1617
|
tone?: CardTone
|
|
1620
1618
|
/** @beta */
|
|
1621
|
-
updateRef?:
|
|
1622
|
-
| MutableRefObject<PopoverUpdateCallback | undefined>
|
|
1623
|
-
| RefCallback<PopoverUpdateCallback | undefined>
|
|
1619
|
+
updateRef?: Ref<PopoverUpdateCallback | undefined>
|
|
1624
1620
|
width?: PopoverWidth | PopoverWidth[]
|
|
1625
1621
|
}
|
|
1626
1622
|
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ import {HTMLAttributes} from 'react'
|
|
|
14
14
|
import {HTMLProps} from 'react'
|
|
15
15
|
import {IStyledComponentBase} from 'styled-components/dist/types'
|
|
16
16
|
import {multiply as multiply_2} from '@sanity/ui/theme'
|
|
17
|
-
import {MutableRefObject} from 'react'
|
|
18
17
|
import {NamedExoticComponent} from 'react'
|
|
19
18
|
import {parseColor as parseColor_2} from '@sanity/ui/theme'
|
|
20
19
|
import {PartialThemeColorBuilderOpts} from '@sanity/ui/theme'
|
|
@@ -22,7 +21,6 @@ import {PropsWithChildren} from 'react'
|
|
|
22
21
|
import {ReactNode} from 'react'
|
|
23
22
|
import {Ref} from 'react'
|
|
24
23
|
import {RefAttributes} from 'react'
|
|
25
|
-
import {RefCallback} from 'react'
|
|
26
24
|
import {RGB as RGB_2} from '@sanity/ui/theme'
|
|
27
25
|
import {rgba as rgba_2} from '@sanity/ui/theme'
|
|
28
26
|
import {rgbToHex as rgbToHex_2} from '@sanity/ui/theme'
|
|
@@ -1618,9 +1616,7 @@ export declare interface PopoverProps
|
|
|
1618
1616
|
scheme?: ThemeColorSchemeKey_2
|
|
1619
1617
|
tone?: CardTone
|
|
1620
1618
|
/** @beta */
|
|
1621
|
-
updateRef?:
|
|
1622
|
-
| MutableRefObject<PopoverUpdateCallback | undefined>
|
|
1623
|
-
| RefCallback<PopoverUpdateCallback | undefined>
|
|
1619
|
+
updateRef?: Ref<PopoverUpdateCallback | undefined>
|
|
1624
1620
|
width?: PopoverWidth | PopoverWidth[]
|
|
1625
1621
|
}
|
|
1626
1622
|
|
package/dist/index.js
CHANGED
|
@@ -566,28 +566,83 @@ const StyledBreadcrumbs = styledComponents.styled.ol.withConfig({
|
|
|
566
566
|
displayName: "ExpandButton",
|
|
567
567
|
componentId: "sc-1es8h8q-1"
|
|
568
568
|
})`appearance:none;margin:-4px;`, Breadcrumbs = react.forwardRef(function(props, ref) {
|
|
569
|
-
const
|
|
569
|
+
const $ = reactCompilerRuntime.c(27);
|
|
570
|
+
let children, maxLength, restProps, separator, t0;
|
|
571
|
+
$[0] !== props ? ({
|
|
570
572
|
children,
|
|
571
573
|
maxLength,
|
|
572
574
|
separator,
|
|
573
|
-
space:
|
|
575
|
+
space: t0,
|
|
574
576
|
...restProps
|
|
575
|
-
} = props,
|
|
576
|
-
_visualEditing.
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
577
|
+
} = props, $[0] = props, $[1] = children, $[2] = maxLength, $[3] = restProps, $[4] = separator, $[5] = t0) : (children = $[1], maxLength = $[2], restProps = $[3], separator = $[4], t0 = $[5]);
|
|
578
|
+
const space = _visualEditing.useArrayProp(t0 === void 0 ? 2 : t0), [open, setOpen] = react.useState(!1), expandElementRef = react.useRef(null), popoverElementRef = react.useRef(null);
|
|
579
|
+
let t1;
|
|
580
|
+
$[6] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => setOpen(!1), $[6] = t1) : t1 = $[6];
|
|
581
|
+
const collapse = t1;
|
|
582
|
+
let t2;
|
|
583
|
+
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t2 = () => setOpen(!0), $[7] = t2) : t2 = $[7];
|
|
584
|
+
const expand = t2;
|
|
585
|
+
let t3;
|
|
586
|
+
$[8] === Symbol.for("react.memo_cache_sentinel") ? (t3 = () => [expandElementRef.current, popoverElementRef.current], $[8] = t3) : t3 = $[8], _visualEditing.useClickOutsideEvent(collapse, t3);
|
|
587
|
+
let t4;
|
|
588
|
+
$[9] !== children ? (t4 = react.Children.toArray(children).filter(react.isValidElement), $[9] = children, $[10] = t4) : t4 = $[10];
|
|
589
|
+
const rawItems = t4;
|
|
590
|
+
let t5;
|
|
591
|
+
$[11] !== maxLength || $[12] !== open || $[13] !== rawItems || $[14] !== space ? (t5 = {
|
|
592
|
+
collapse,
|
|
593
|
+
expand,
|
|
594
|
+
expandElementRef,
|
|
595
|
+
maxLength,
|
|
596
|
+
open,
|
|
597
|
+
popoverElementRef,
|
|
598
|
+
rawItems,
|
|
599
|
+
space
|
|
600
|
+
}, $[11] = maxLength, $[12] = open, $[13] = rawItems, $[14] = space, $[15] = t5) : t5 = $[15];
|
|
601
|
+
const items = useItems(t5);
|
|
602
|
+
let t6;
|
|
603
|
+
if ($[16] !== items || $[17] !== separator || $[18] !== space) {
|
|
604
|
+
let t72;
|
|
605
|
+
$[20] !== separator || $[21] !== space ? (t72 = (item, itemIndex) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
606
|
+
itemIndex > 0 && /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { "aria-hidden": !0, as: "li", paddingX: space, children: separator || /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Text, { muted: !0, children: "/" }) }),
|
|
607
|
+
/* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Box, { as: "li", children: item })
|
|
608
|
+
] }, itemIndex), $[20] = separator, $[21] = space, $[22] = t72) : t72 = $[22], t6 = items.map(t72), $[16] = items, $[17] = separator, $[18] = space, $[19] = t6;
|
|
609
|
+
} else
|
|
610
|
+
t6 = $[19];
|
|
611
|
+
let t7;
|
|
612
|
+
return $[23] !== ref || $[24] !== restProps || $[25] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(StyledBreadcrumbs, { "data-ui": "Breadcrumbs", ...restProps, ref, children: t6 }), $[23] = ref, $[24] = restProps, $[25] = t6, $[26] = t7) : t7 = $[26], t7;
|
|
589
613
|
});
|
|
590
614
|
Breadcrumbs.displayName = "ForwardRef(Breadcrumbs)";
|
|
615
|
+
function useItems(t0) {
|
|
616
|
+
const $ = reactCompilerRuntime.c(28), {
|
|
617
|
+
collapse,
|
|
618
|
+
expand,
|
|
619
|
+
expandElementRef,
|
|
620
|
+
maxLength,
|
|
621
|
+
open,
|
|
622
|
+
popoverElementRef,
|
|
623
|
+
rawItems,
|
|
624
|
+
space
|
|
625
|
+
} = t0, len = rawItems.length;
|
|
626
|
+
if (maxLength && len > maxLength) {
|
|
627
|
+
const beforeLength = Math.ceil(maxLength / 2), afterLength = Math.floor(maxLength / 2);
|
|
628
|
+
let t1;
|
|
629
|
+
if ($[0] !== afterLength || $[1] !== beforeLength || $[2] !== collapse || $[3] !== expand || $[4] !== expandElementRef || $[5] !== len || $[6] !== open || $[7] !== popoverElementRef || $[8] !== rawItems || $[9] !== space) {
|
|
630
|
+
const t2 = rawItems.slice(0, beforeLength - 1);
|
|
631
|
+
let t3;
|
|
632
|
+
$[11] !== afterLength || $[12] !== beforeLength || $[13] !== len || $[14] !== rawItems ? (t3 = rawItems.slice(beforeLength - 1, len - afterLength), $[11] = afterLength, $[12] = beforeLength, $[13] = len, $[14] = rawItems, $[15] = t3) : t3 = $[15];
|
|
633
|
+
let t4;
|
|
634
|
+
$[16] !== space || $[17] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Stack, { as: "ol", overflow: "auto", padding: space, space, children: t3 }), $[16] = space, $[17] = t3, $[18] = t4) : t4 = $[18];
|
|
635
|
+
const t5 = open ? collapse : expand;
|
|
636
|
+
let t6;
|
|
637
|
+
$[19] !== expandElementRef || $[20] !== open || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(ExpandButton, { fontSize: 1, mode: "bleed", onClick: t5, padding: 1, ref: expandElementRef, selected: open, text: "\u2026" }), $[19] = expandElementRef, $[20] = open, $[21] = t5, $[22] = t6) : t6 = $[22];
|
|
638
|
+
let t7;
|
|
639
|
+
$[23] !== open || $[24] !== popoverElementRef || $[25] !== t4 || $[26] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(_visualEditing.Popover, { constrainSize: !0, content: t4, open, placement: "top", portal: !0, ref: popoverElementRef, children: t6 }, "button"), $[23] = open, $[24] = popoverElementRef, $[25] = t4, $[26] = t6, $[27] = t7) : t7 = $[27], t1 = [...t2, t7, ...rawItems.slice(len - afterLength)], $[0] = afterLength, $[1] = beforeLength, $[2] = collapse, $[3] = expand, $[4] = expandElementRef, $[5] = len, $[6] = open, $[7] = popoverElementRef, $[8] = rawItems, $[9] = space, $[10] = t1;
|
|
640
|
+
} else
|
|
641
|
+
t1 = $[10];
|
|
642
|
+
return t1;
|
|
643
|
+
}
|
|
644
|
+
return rawItems;
|
|
645
|
+
}
|
|
591
646
|
function dialogStyle({
|
|
592
647
|
theme: theme$1
|
|
593
648
|
}) {
|