@sanity/ui 5.0.0-alpha.5 → 5.0.0-alpha.6
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.d.ts +54 -9
- package/dist/index.js +197 -79
- package/dist/index.js.map +1 -1
- package/dist/polyfills.d.ts +1 -0
- package/dist/polyfills.js +5 -0
- package/dist/polyfills.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +8 -2
- package/src/components/checkbox/Checkbox.tsx +1 -1
- package/src/components/index.css +1 -0
- package/src/components/modal/Modal.tsx +5 -10
- package/src/components/modal/modal.css +3 -3
- package/src/components/modal/modal.props.ts +9 -0
- package/src/components/popover/Popover.tsx +85 -0
- package/src/components/popover/popover.css +21 -0
- package/src/components/popover/popover.props.ts +28 -0
- package/src/components/radio/Radio.tsx +1 -1
- package/src/components/switch/Switch.tsx +1 -1
- package/src/components/tooltip/Tooltip.tsx +59 -55
- package/src/components/tooltip/tooltip.css +19 -40
- package/src/components/tooltip/tooltip.props.ts +16 -8
- package/src/components/tooltip-group/TooltipGroup.tsx +2 -5
- package/src/css/classes/generic/placement.css +31 -0
- package/src/css/tokens/semantic.css +4 -0
- package/src/hooks/useIsClient.ts +10 -0
- package/src/index.ts +3 -0
- package/src/polyfills.ts +15 -0
- package/src/utils/mergeTriggerProps.ts +66 -0
- package/src/utils/renderPortal.tsx +14 -0
- package/src/version.ts +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -670,9 +670,11 @@ export declare interface ModalProps extends Omit<
|
|
|
670
670
|
onClose: React.ReactEventHandler<HTMLDialogElement>;
|
|
671
671
|
/** Whether the modal is open; defaults to false. */
|
|
672
672
|
open?: boolean;
|
|
673
|
+
/** Max width of the modal */
|
|
674
|
+
size?: Responsive<ContainerSize>;
|
|
673
675
|
}
|
|
674
676
|
|
|
675
|
-
declare function ModalRoot(props: ModalProps): JSX.Element;
|
|
677
|
+
declare function ModalRoot({ open, size, ...props }: ModalProps): JSX.Element;
|
|
676
678
|
|
|
677
679
|
declare namespace ModalRoot {
|
|
678
680
|
var displayName: string;
|
|
@@ -742,6 +744,33 @@ export declare type PlacementProps = {
|
|
|
742
744
|
placement?: Placement;
|
|
743
745
|
};
|
|
744
746
|
|
|
747
|
+
/** @beta */
|
|
748
|
+
export declare const Popover: typeof PopoverRoot & {
|
|
749
|
+
forwardsTriggerProps: boolean;
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
/** @beta */
|
|
753
|
+
export declare interface PopoverProps
|
|
754
|
+
extends
|
|
755
|
+
Omit<React.ComponentProps<"div">, "children" | "content">,
|
|
756
|
+
PlacementProps {
|
|
757
|
+
/** Anchor name for positioning */
|
|
758
|
+
anchorName?: React.ReactNode;
|
|
759
|
+
/** Focusable trigger element */
|
|
760
|
+
children: React.ReactElement<Record<string, unknown>>;
|
|
761
|
+
/** Popover content */
|
|
762
|
+
content?: React.ReactNode;
|
|
763
|
+
/** Render tooltip in portal */
|
|
764
|
+
portal?: boolean;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
declare function PopoverRoot({
|
|
768
|
+
placement,
|
|
769
|
+
...props
|
|
770
|
+
}: PopoverProps & {
|
|
771
|
+
triggerProps?: Record<string, unknown>;
|
|
772
|
+
}): JSX.Element;
|
|
773
|
+
|
|
745
774
|
declare const POSITION: readonly [
|
|
746
775
|
"absolute",
|
|
747
776
|
"fixed",
|
|
@@ -952,8 +981,8 @@ declare type ToneProps = {
|
|
|
952
981
|
tone?: Tone;
|
|
953
982
|
};
|
|
954
983
|
|
|
955
|
-
/** @
|
|
956
|
-
export declare
|
|
984
|
+
/** @beta */
|
|
985
|
+
export declare const Tooltip: typeof TooltipRoot;
|
|
957
986
|
|
|
958
987
|
/** @public */
|
|
959
988
|
export declare function TooltipGroup<T extends ElementType = "div">(
|
|
@@ -969,15 +998,28 @@ export declare interface TooltipGroupProps<
|
|
|
969
998
|
as?: T;
|
|
970
999
|
}
|
|
971
1000
|
|
|
972
|
-
/** @
|
|
1001
|
+
/** @beta */
|
|
973
1002
|
export declare interface TooltipProps
|
|
974
|
-
extends
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
/**
|
|
978
|
-
|
|
1003
|
+
extends
|
|
1004
|
+
Omit<React.ComponentProps<"div">, "children" | "content">,
|
|
1005
|
+
PlacementProps {
|
|
1006
|
+
/** Anchor name for positioning */
|
|
1007
|
+
anchorName?: React.ReactNode;
|
|
1008
|
+
/** Focusable trigger element */
|
|
1009
|
+
children: React.ReactElement<Record<string, unknown>>;
|
|
1010
|
+
/** Tooltip content */
|
|
1011
|
+
content?: React.ReactNode;
|
|
1012
|
+
/** Render tooltip in portal */
|
|
1013
|
+
portal?: boolean;
|
|
979
1014
|
}
|
|
980
1015
|
|
|
1016
|
+
declare function TooltipRoot({
|
|
1017
|
+
placement,
|
|
1018
|
+
...props
|
|
1019
|
+
}: TooltipProps & {
|
|
1020
|
+
triggerProps?: Record<string, unknown>;
|
|
1021
|
+
}): JSX.Element;
|
|
1022
|
+
|
|
981
1023
|
/** @public */
|
|
982
1024
|
export declare interface TypographyProps extends MarginProps, ToneProps {
|
|
983
1025
|
/** CSS **text-align** property */
|
|
@@ -992,6 +1034,9 @@ export declare interface TypographyProps extends MarginProps, ToneProps {
|
|
|
992
1034
|
weight?: FontWeight;
|
|
993
1035
|
}
|
|
994
1036
|
|
|
1037
|
+
/** @public */
|
|
1038
|
+
export declare function useIsClient(): boolean;
|
|
1039
|
+
|
|
995
1040
|
/** @public */
|
|
996
1041
|
export declare function VisuallyHidden<T extends ElementType = "span">(
|
|
997
1042
|
props: VisuallyHiddenProps<T> &
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import clsx from "clsx";
|
|
5
|
-
import { isValidElement, useRef, useEffect, lazy, Suspense, Children, useId, useState, cloneElement } from "react";
|
|
5
|
+
import { isValidElement, useRef, useEffect, lazy, Suspense, Children, useId, useSyncExternalStore, useState, cloneElement, Activity } from "react";
|
|
6
6
|
import { SpinnerIcon, RemoveIcon, CheckmarkIcon, CloseIcon } from "@sanity/icons";
|
|
7
|
+
import { createPortal } from "react-dom";
|
|
7
8
|
const PREFIX = "sui", BREAKPOINTS_LENGTH = 6;
|
|
8
9
|
function getProps(componentProps, propDefs) {
|
|
9
10
|
const {
|
|
@@ -95,7 +96,7 @@ function getCompositeValue(propValue, propDef, key) {
|
|
|
95
96
|
compositeValue = mapping?.[propValue];
|
|
96
97
|
return compositeValue;
|
|
97
98
|
}
|
|
98
|
-
const HASH = "
|
|
99
|
+
const HASH = "71d7e5";
|
|
99
100
|
function suffixClassName(className) {
|
|
100
101
|
return `${className}-${HASH}`;
|
|
101
102
|
}
|
|
@@ -866,7 +867,7 @@ function Checkbox(props) {
|
|
|
866
867
|
useEffect(() => {
|
|
867
868
|
inputRef.current && (inputRef.current.indeterminate = indeterminate);
|
|
868
869
|
}, [indeterminate]);
|
|
869
|
-
const t0 = clsx(checkboxClassName, className), T0 = Box, t1 = "span", t2 = clsx(checkboxMarkClassName, error && "sui-error");
|
|
870
|
+
const t0 = clsx(checkboxClassName, "sui-position-relative", className), T0 = Box, t1 = "span", t2 = clsx(checkboxMarkClassName, error && "sui-error");
|
|
870
871
|
let t3;
|
|
871
872
|
$[0] !== indeterminate ? (t3 = indeterminate ? /* @__PURE__ */ jsx(RemoveIcon, {}) : /* @__PURE__ */ jsx(CheckmarkIcon, {}), $[0] = indeterminate, $[1] = t3) : t3 = $[1];
|
|
872
873
|
let t4;
|
|
@@ -1653,40 +1654,52 @@ const modalProps = {
|
|
|
1653
1654
|
},
|
|
1654
1655
|
open: {
|
|
1655
1656
|
type: "boolean"
|
|
1657
|
+
},
|
|
1658
|
+
size: {
|
|
1659
|
+
type: "union",
|
|
1660
|
+
className: "container",
|
|
1661
|
+
values: CONTAINER_SIZE
|
|
1656
1662
|
}
|
|
1657
1663
|
}, modalClassName = suffixClassName("sui-Modal"), modalContentClassName = suffixClassName("sui-ModalContent"), modalFooterClassName = suffixClassName("sui-ModalFooter");
|
|
1658
|
-
function ModalRoot(
|
|
1659
|
-
const $ = c(
|
|
1664
|
+
function ModalRoot(t0) {
|
|
1665
|
+
const $ = c(17), {
|
|
1666
|
+
open: t1,
|
|
1667
|
+
size: t2,
|
|
1668
|
+
...props
|
|
1669
|
+
} = t0, open = t1 === void 0 ? !1 : t1, size = t2 === void 0 ? 0 : t2, {
|
|
1660
1670
|
children,
|
|
1661
1671
|
className,
|
|
1662
1672
|
style,
|
|
1663
1673
|
header,
|
|
1664
|
-
open: t0,
|
|
1665
1674
|
onClose,
|
|
1666
1675
|
...rest
|
|
1667
|
-
} = getProps(
|
|
1668
|
-
|
|
1676
|
+
} = getProps({
|
|
1677
|
+
size,
|
|
1678
|
+
...props
|
|
1679
|
+
}, modalProps), modalRef = useRef(null), headerId = useId(), modalClasses = clsx(modalClassName, "sui-inset0 sui-m-auto sui-radius5 sui-shadow3 sui-p4 sui-flex-direction-column sui-gap4 sui-overflow-y-auto");
|
|
1680
|
+
let t3, t4;
|
|
1681
|
+
$[0] !== open ? (t3 = () => {
|
|
1669
1682
|
const dialogElement = modalRef.current;
|
|
1670
1683
|
if (dialogElement)
|
|
1671
1684
|
return open ? dialogElement.open || dialogElement.showModal() : dialogElement.open && dialogElement.close(), () => {
|
|
1672
1685
|
dialogElement.close();
|
|
1673
1686
|
};
|
|
1674
|
-
}, [open]);
|
|
1675
|
-
const
|
|
1676
|
-
let
|
|
1677
|
-
$[
|
|
1678
|
-
let
|
|
1679
|
-
$[
|
|
1680
|
-
let
|
|
1681
|
-
$[
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
] }), $[
|
|
1685
|
-
let
|
|
1686
|
-
return $[
|
|
1687
|
-
|
|
1687
|
+
}, t4 = [open], $[0] = open, $[1] = t3, $[2] = t4) : (t3 = $[1], t4 = $[2]), useEffect(t3, t4);
|
|
1688
|
+
const t5 = "any", t6 = header ? headerId : void 0, t7 = clsx(modalClasses, className);
|
|
1689
|
+
let t8;
|
|
1690
|
+
$[3] !== header || $[4] !== headerId ? (t8 = header ? /* @__PURE__ */ jsx(Heading, { trim: !0, size: 1, id: headerId, children: header }) : /* @__PURE__ */ jsx("div", {}), $[3] = header, $[4] = headerId, $[5] = t8) : t8 = $[5];
|
|
1691
|
+
let t9;
|
|
1692
|
+
$[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx(IconButton, { "aria-label": "Close", level: "tertiary", icon: CloseIcon, onClick: () => modalRef.current?.close() }), $[6] = t9) : t9 = $[6];
|
|
1693
|
+
let t10;
|
|
1694
|
+
$[7] !== t8 ? (t10 = /* @__PURE__ */ jsxs(Flex, { flexShrink: 0, justifyContent: "space-between", alignItems: "center", children: [
|
|
1695
|
+
t8,
|
|
1696
|
+
t9
|
|
1697
|
+
] }), $[7] = t8, $[8] = t10) : t10 = $[8];
|
|
1698
|
+
let t11;
|
|
1699
|
+
return $[9] !== children || $[10] !== onClose || $[11] !== rest || $[12] !== style || $[13] !== t10 || $[14] !== t6 || $[15] !== t7 ? (t11 = /* @__PURE__ */ jsxs("dialog", { ...rest, ref: modalRef, closedby: t5, "aria-labelledby": t6, onClose, className: t7, style, "data-ui": "Modal", children: [
|
|
1700
|
+
t10,
|
|
1688
1701
|
children
|
|
1689
|
-
] }), $[
|
|
1702
|
+
] }), $[9] = children, $[10] = onClose, $[11] = rest, $[12] = style, $[13] = t10, $[14] = t6, $[15] = t7, $[16] = t11) : t11 = $[16], t11;
|
|
1690
1703
|
}
|
|
1691
1704
|
function ModalContent(props) {
|
|
1692
1705
|
const $ = c(12);
|
|
@@ -1724,7 +1737,116 @@ ModalRoot.displayName = "Modal";
|
|
|
1724
1737
|
const Modal = ModalRoot;
|
|
1725
1738
|
ModalRoot.Content = ModalContent;
|
|
1726
1739
|
ModalRoot.Footer = ModalFooter;
|
|
1727
|
-
|
|
1740
|
+
function useIsClient() {
|
|
1741
|
+
return useSyncExternalStore(_temp2, _temp3, _temp4);
|
|
1742
|
+
}
|
|
1743
|
+
function _temp4() {
|
|
1744
|
+
return !1;
|
|
1745
|
+
}
|
|
1746
|
+
function _temp3() {
|
|
1747
|
+
return !0;
|
|
1748
|
+
}
|
|
1749
|
+
function _temp2() {
|
|
1750
|
+
return _temp;
|
|
1751
|
+
}
|
|
1752
|
+
function _temp() {
|
|
1753
|
+
}
|
|
1754
|
+
function isReactEventHandler(key, value) {
|
|
1755
|
+
return /^on[A-Z]/.test(key) && typeof value == "function";
|
|
1756
|
+
}
|
|
1757
|
+
function chainEventHandlers(...handlers) {
|
|
1758
|
+
const defined = handlers.filter(Boolean);
|
|
1759
|
+
if (defined.length !== 0)
|
|
1760
|
+
return defined.length === 1 ? defined[0] : (e) => {
|
|
1761
|
+
for (const handler of defined)
|
|
1762
|
+
handler(e);
|
|
1763
|
+
};
|
|
1764
|
+
}
|
|
1765
|
+
function mergeTriggerProps(childProps, forwardedProps, ownProps) {
|
|
1766
|
+
const result = {};
|
|
1767
|
+
for (const source of [forwardedProps, ownProps])
|
|
1768
|
+
if (source) {
|
|
1769
|
+
for (const [key, value] of Object.entries(source))
|
|
1770
|
+
if (key !== "style") {
|
|
1771
|
+
if (isReactEventHandler(key, value)) {
|
|
1772
|
+
result[key] = chainEventHandlers(result[key], value);
|
|
1773
|
+
continue;
|
|
1774
|
+
}
|
|
1775
|
+
value !== void 0 && (result[key] = value);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
result.style = {
|
|
1779
|
+
...childProps.style,
|
|
1780
|
+
...forwardedProps?.style,
|
|
1781
|
+
...ownProps?.style
|
|
1782
|
+
};
|
|
1783
|
+
for (const [key, value] of Object.entries(childProps))
|
|
1784
|
+
isReactEventHandler(key, value) && (result[key] = chainEventHandlers(result[key], value));
|
|
1785
|
+
return result;
|
|
1786
|
+
}
|
|
1787
|
+
function renderPortal(node, mounted, portal) {
|
|
1788
|
+
return portal ? mounted ? createPortal(node, document.body) : null : node;
|
|
1789
|
+
}
|
|
1790
|
+
const PLACEMENT = ["top", "top-start", "top-end", "right", "right-start", "right-end", "bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end"], placementProps = {
|
|
1791
|
+
placement: {
|
|
1792
|
+
type: "union",
|
|
1793
|
+
className: "placement",
|
|
1794
|
+
values: PLACEMENT
|
|
1795
|
+
}
|
|
1796
|
+
}, popoverProps = {
|
|
1797
|
+
anchorName: {
|
|
1798
|
+
type: "string"
|
|
1799
|
+
},
|
|
1800
|
+
content: {
|
|
1801
|
+
type: "string"
|
|
1802
|
+
},
|
|
1803
|
+
portal: {
|
|
1804
|
+
type: "boolean"
|
|
1805
|
+
},
|
|
1806
|
+
...placementProps
|
|
1807
|
+
}, popoverClassName = suffixClassName("sui-PopoverContent");
|
|
1808
|
+
function PopoverRoot(t0) {
|
|
1809
|
+
const $ = c(4), {
|
|
1810
|
+
placement: t1,
|
|
1811
|
+
...props
|
|
1812
|
+
} = t0, placement = t1 === void 0 ? "bottom" : t1, {
|
|
1813
|
+
children,
|
|
1814
|
+
className,
|
|
1815
|
+
style,
|
|
1816
|
+
id: idProp,
|
|
1817
|
+
anchorName,
|
|
1818
|
+
content,
|
|
1819
|
+
portal,
|
|
1820
|
+
triggerProps: forwardedTriggerProps,
|
|
1821
|
+
...rest
|
|
1822
|
+
} = getProps({
|
|
1823
|
+
placement,
|
|
1824
|
+
...props
|
|
1825
|
+
}, popoverProps), reactId = useId(), id = idProp || reactId, [open, setOpen] = useState(!1), isClient = useIsClient();
|
|
1826
|
+
let t2;
|
|
1827
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = (e) => {
|
|
1828
|
+
setOpen(e.newState === "open");
|
|
1829
|
+
}, $[0] = t2) : t2 = $[0];
|
|
1830
|
+
const handleToggle = t2, triggerProps = {
|
|
1831
|
+
popoverTarget: id,
|
|
1832
|
+
style: {
|
|
1833
|
+
anchorName: `--anchor-${anchorName || id}`
|
|
1834
|
+
}
|
|
1835
|
+
}, trigger = children.type.forwardsTriggerProps ? cloneElement(children, {
|
|
1836
|
+
triggerProps
|
|
1837
|
+
}) : cloneElement(children, mergeTriggerProps(children.props, forwardedTriggerProps, triggerProps)), t3 = renderPortal(/* @__PURE__ */ jsx(Activity, { mode: open ? "visible" : "hidden", children: /* @__PURE__ */ jsx("div", { className: clsx(popoverClassName, "sui-px2 sui-py1 sui-radius2 sui-position-fixed sui-shadow2", className), style: {
|
|
1838
|
+
...style,
|
|
1839
|
+
positionAnchor: `--anchor-${anchorName || id}`
|
|
1840
|
+
}, "data-ui": "Popover", popover: "auto", id, onToggle: handleToggle, ...rest, children: content }) }), isClient, portal);
|
|
1841
|
+
let t4;
|
|
1842
|
+
return $[1] !== t3 || $[2] !== trigger ? (t4 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1843
|
+
trigger,
|
|
1844
|
+
t3
|
|
1845
|
+
] }), $[1] = t3, $[2] = trigger, $[3] = t4) : t4 = $[3], t4;
|
|
1846
|
+
}
|
|
1847
|
+
const Popover = Object.assign(PopoverRoot, {
|
|
1848
|
+
forwardsTriggerProps: !0
|
|
1849
|
+
}), radioProps = {
|
|
1728
1850
|
error: {
|
|
1729
1851
|
type: "boolean"
|
|
1730
1852
|
},
|
|
@@ -1745,7 +1867,7 @@ function Radio(props) {
|
|
|
1745
1867
|
error,
|
|
1746
1868
|
...rest
|
|
1747
1869
|
} = getProps(props, radioProps);
|
|
1748
|
-
label = t82, T1 = Label, t2 = clsx(radioClassName, className), t3 = style, t4 = "Radio", t5 = disabled, t6 = error, t7 = /* @__PURE__ */ jsx(VisuallyHidden, { as: "input", type: "radio", className: radioInputClassName, disabled, ...rest }), T0 = Box, t0 = "span", t1 = clsx(radioMarkClassName, error && "sui-error"), $[0] = props, $[1] = T0, $[2] = T1, $[3] = label, $[4] = t0, $[5] = t1, $[6] = t2, $[7] = t3, $[8] = t4, $[9] = t5, $[10] = t6, $[11] = t7;
|
|
1870
|
+
label = t82, T1 = Label, t2 = clsx(radioClassName, "sui-position-relative", className), t3 = style, t4 = "Radio", t5 = disabled, t6 = error, t7 = /* @__PURE__ */ jsx(VisuallyHidden, { as: "input", type: "radio", className: radioInputClassName, disabled, ...rest }), T0 = Box, t0 = "span", t1 = clsx(radioMarkClassName, error && "sui-error"), $[0] = props, $[1] = T0, $[2] = T1, $[3] = label, $[4] = t0, $[5] = t1, $[6] = t2, $[7] = t3, $[8] = t4, $[9] = t5, $[10] = t6, $[11] = t7;
|
|
1749
1871
|
} else
|
|
1750
1872
|
T0 = $[1], T1 = $[2], label = $[3], t0 = $[4], t1 = $[5], t2 = $[6], t3 = $[7], t4 = $[8], t5 = $[9], t6 = $[10], t7 = $[11];
|
|
1751
1873
|
let t8;
|
|
@@ -1801,7 +1923,7 @@ function Switch(props) {
|
|
|
1801
1923
|
label: t82,
|
|
1802
1924
|
...rest
|
|
1803
1925
|
} = getProps(props, switchProps);
|
|
1804
|
-
label = t82, T1 = Label, t2 = clsx(switchClassName, className), t3 = style, t4 = "Switch", t5 = props.disabled, t6 = error, t7 = /* @__PURE__ */ jsx(VisuallyHidden, { as: "input", type: "checkbox", role: "switch", className: switchInputClassName, disabled, ...rest }), T0 = Flex, t0 = "span", t1 = clsx(switchMarkClassName, error && "sui-error"), $[0] = props, $[1] = T0, $[2] = T1, $[3] = label, $[4] = t0, $[5] = t1, $[6] = t2, $[7] = t3, $[8] = t4, $[9] = t5, $[10] = t6, $[11] = t7;
|
|
1926
|
+
label = t82, T1 = Label, t2 = clsx(switchClassName, "sui-position-relative", className), t3 = style, t4 = "Switch", t5 = props.disabled, t6 = error, t7 = /* @__PURE__ */ jsx(VisuallyHidden, { as: "input", type: "checkbox", role: "switch", className: switchInputClassName, disabled, ...rest }), T0 = Flex, t0 = "span", t1 = clsx(switchMarkClassName, error && "sui-error"), $[0] = props, $[1] = T0, $[2] = T1, $[3] = label, $[4] = t0, $[5] = t1, $[6] = t2, $[7] = t3, $[8] = t4, $[9] = t5, $[10] = t6, $[11] = t7;
|
|
1805
1927
|
} else
|
|
1806
1928
|
T0 = $[1], T1 = $[2], label = $[3], t0 = $[4], t1 = $[5], t2 = $[6], t3 = $[7], t4 = $[8], t5 = $[9], t6 = $[10], t7 = $[11];
|
|
1807
1929
|
let t8;
|
|
@@ -1813,79 +1935,73 @@ function Switch(props) {
|
|
|
1813
1935
|
label
|
|
1814
1936
|
] }), $[16] = T1, $[17] = label, $[18] = t2, $[19] = t3, $[20] = t4, $[21] = t5, $[22] = t6, $[23] = t7, $[24] = t8, $[25] = t9) : t9 = $[25], t9;
|
|
1815
1937
|
}
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1818
|
-
type: "union",
|
|
1819
|
-
className: "placement",
|
|
1820
|
-
values: PLACEMENT
|
|
1821
|
-
}
|
|
1822
|
-
}, tooltipProps = {
|
|
1823
|
-
text: {
|
|
1938
|
+
const tooltipProps = {
|
|
1939
|
+
anchorName: {
|
|
1824
1940
|
type: "string"
|
|
1825
1941
|
},
|
|
1826
|
-
|
|
1942
|
+
content: {
|
|
1943
|
+
type: "string"
|
|
1944
|
+
},
|
|
1945
|
+
portal: {
|
|
1827
1946
|
type: "boolean"
|
|
1828
1947
|
},
|
|
1829
1948
|
...placementProps
|
|
1830
|
-
}, tooltipClassName = suffixClassName("sui-Tooltip")
|
|
1831
|
-
function
|
|
1832
|
-
const $ = c(
|
|
1949
|
+
}, tooltipClassName = suffixClassName("sui-Tooltip");
|
|
1950
|
+
function TooltipRoot(t0) {
|
|
1951
|
+
const $ = c(7), {
|
|
1833
1952
|
placement: t1,
|
|
1834
1953
|
...props
|
|
1835
1954
|
} = t0, placement = t1 === void 0 ? "bottom" : t1, {
|
|
1836
1955
|
children,
|
|
1837
1956
|
className,
|
|
1838
1957
|
style,
|
|
1839
|
-
disabled,
|
|
1840
1958
|
id: idProp,
|
|
1841
|
-
|
|
1959
|
+
anchorName,
|
|
1960
|
+
content,
|
|
1961
|
+
portal,
|
|
1962
|
+
triggerProps: forwardedTriggerProps,
|
|
1842
1963
|
...rest
|
|
1843
1964
|
} = getProps({
|
|
1844
1965
|
placement,
|
|
1845
1966
|
...props
|
|
1846
|
-
}, tooltipProps), reactId = useId(), id = idProp || reactId, [dismissed, setDismissed] = useState(!1);
|
|
1967
|
+
}, tooltipProps), reactId = useId(), id = idProp || reactId, [dismissed, setDismissed] = useState(!1), isClient = useIsClient();
|
|
1847
1968
|
let t2, t3;
|
|
1848
|
-
$[0]
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
return window.addEventListener("keydown", handleKeyDown), () => window.removeEventListener("keydown", handleKeyDown);
|
|
1855
|
-
}, t3 = [dismissed], $[0] = dismissed, $[1] = t2, $[2] = t3) : (t2 = $[1], t3 = $[2]), useEffect(t2, t3);
|
|
1856
|
-
const trigger = cloneElement(children, {
|
|
1969
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = () => {
|
|
1970
|
+
setDismissed(!1);
|
|
1971
|
+
}, t3 = () => {
|
|
1972
|
+
setDismissed(!1);
|
|
1973
|
+
}, $[0] = t2, $[1] = t3) : (t2 = $[0], t3 = $[1]);
|
|
1974
|
+
const triggerProps = {
|
|
1857
1975
|
"aria-describedby": id,
|
|
1858
|
-
|
|
1859
|
-
setDismissed(!1), children.props.onMouseEnter?.(e_0);
|
|
1860
|
-
},
|
|
1861
|
-
onFocus: (e_1) => {
|
|
1862
|
-
setDismissed(!1), children.props.onFocus?.(e_1);
|
|
1863
|
-
},
|
|
1864
|
-
onClick: (e_2) => {
|
|
1865
|
-
setDismissed(!0), children.props.onClick?.(e_2);
|
|
1866
|
-
},
|
|
1976
|
+
interestfor: id,
|
|
1867
1977
|
style: {
|
|
1868
|
-
|
|
1869
|
-
|
|
1978
|
+
anchorName: `--anchor-${anchorName || id}`
|
|
1979
|
+
},
|
|
1980
|
+
onMouseLeave: t2,
|
|
1981
|
+
onBlur: t3,
|
|
1982
|
+
onClick: () => {
|
|
1983
|
+
setDismissed(!0), document.getElementById(id)?.hidePopover();
|
|
1870
1984
|
}
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1985
|
+
}, trigger = children.type.forwardsTriggerProps ? cloneElement(children, {
|
|
1986
|
+
triggerProps
|
|
1987
|
+
}) : cloneElement(children, mergeTriggerProps(children.props, forwardedTriggerProps, triggerProps));
|
|
1988
|
+
let t4;
|
|
1989
|
+
$[2] !== dismissed ? (t4 = (e) => {
|
|
1990
|
+
e.newState === "open" && dismissed && e.preventDefault();
|
|
1991
|
+
}, $[2] = dismissed, $[3] = t4) : t4 = $[3];
|
|
1992
|
+
const handleBeforeToggle = t4, t5 = renderPortal(/* @__PURE__ */ jsx("div", { className: clsx(tooltipClassName, "sui-px2 sui-py1 sui-radius2 sui-position-fixed sui-shadow2", className), style: {
|
|
1877
1993
|
...style,
|
|
1878
|
-
positionAnchor:
|
|
1879
|
-
},
|
|
1880
|
-
let
|
|
1881
|
-
|
|
1882
|
-
let t8;
|
|
1883
|
-
return $[13] !== t7 || $[14] !== trigger ? (t8 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1994
|
+
positionAnchor: `--anchor-${anchorName || id}`
|
|
1995
|
+
}, "data-ui": "Tooltip", role: "tooltip", popover: "hint", id, onBeforeToggle: handleBeforeToggle, ...rest, children: content }), isClient, portal);
|
|
1996
|
+
let t6;
|
|
1997
|
+
return $[4] !== t5 || $[5] !== trigger ? (t6 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1884
1998
|
trigger,
|
|
1885
|
-
|
|
1886
|
-
] }), $[
|
|
1999
|
+
t5
|
|
2000
|
+
] }), $[4] = t5, $[5] = trigger, $[6] = t6) : t6 = $[6], t6;
|
|
1887
2001
|
}
|
|
1888
|
-
const
|
|
2002
|
+
const Tooltip = Object.assign(TooltipRoot, {
|
|
2003
|
+
forwardsTriggerProps: !0
|
|
2004
|
+
}), tooltipGroupProps = {
|
|
1889
2005
|
as: {
|
|
1890
2006
|
type: "string"
|
|
1891
2007
|
}
|
|
@@ -1901,7 +2017,7 @@ function TooltipGroup(props) {
|
|
|
1901
2017
|
let t0;
|
|
1902
2018
|
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = (e) => {
|
|
1903
2019
|
const tooltip = e.target.closest('[data-ui="Tooltip"]');
|
|
1904
|
-
tooltip && e.propertyName === "
|
|
2020
|
+
tooltip && e.propertyName === "opacity" && window.getComputedStyle(tooltip).opacity !== "0" && setIsActive(!0);
|
|
1905
2021
|
}, $[0] = t0) : t0 = $[0];
|
|
1906
2022
|
const handleTransitionEnd = t0;
|
|
1907
2023
|
let t1;
|
|
@@ -1916,7 +2032,7 @@ function TooltipGroup(props) {
|
|
|
1916
2032
|
const handleBlur = t2, t3 = clsx(tooltipGroupClassName, className);
|
|
1917
2033
|
let t4;
|
|
1918
2034
|
$[3] !== isActive ? (t4 = isActive && {
|
|
1919
|
-
"--tooltip-delay-group":
|
|
2035
|
+
"--tooltip-delay-group": "0ms"
|
|
1920
2036
|
}, $[3] = isActive, $[4] = t4) : t4 = $[4];
|
|
1921
2037
|
let t5;
|
|
1922
2038
|
$[5] !== style || $[6] !== t4 ? (t5 = {
|
|
@@ -1948,6 +2064,7 @@ export {
|
|
|
1948
2064
|
Link,
|
|
1949
2065
|
List,
|
|
1950
2066
|
Modal,
|
|
2067
|
+
Popover,
|
|
1951
2068
|
PressArea,
|
|
1952
2069
|
Radio,
|
|
1953
2070
|
SkipToContent,
|
|
@@ -1957,6 +2074,7 @@ export {
|
|
|
1957
2074
|
Tooltip,
|
|
1958
2075
|
TooltipGroup,
|
|
1959
2076
|
VStack,
|
|
1960
|
-
VisuallyHidden
|
|
2077
|
+
VisuallyHidden,
|
|
2078
|
+
useIsClient
|
|
1961
2079
|
};
|
|
1962
2080
|
//# sourceMappingURL=index.js.map
|