@sanity/ui 5.0.0-alpha.4 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- import type { ComponentProps } from "react";
1
+ import { ComponentProps } from "react";
2
2
  import { ComponentPropsWithRef } from "react";
3
3
  import { ElementType } from "react";
4
4
  import { JSX } from "react";
@@ -641,6 +641,47 @@ export declare type MarginProps = {
641
641
  marginLeft?: Responsive<SpaceAutoNegative>;
642
642
  };
643
643
 
644
+ /**
645
+ * @beta
646
+ *
647
+ * Renders a modal dialog element — should not be used for nonmodal dialogs.
648
+ * Modal dialogs make their containing documents inert, and render on the topmost
649
+ * layer within that containing document; they must be dimissed before the containing
650
+ * document and its contents become unblocked. They also trap focus within the bounds
651
+ * of the modal element and its descendants.
652
+ *
653
+ * For more on dialogs and modality, refer to the HTML specification for the dialog element:
654
+ * https://html.spec.whatwg.org/dev/interactive-elements.html#the-dialog-element
655
+ */
656
+ export declare const Modal: typeof ModalRoot;
657
+
658
+ declare function ModalContent(props: ComponentProps<"div">): JSX.Element;
659
+
660
+ declare function ModalFooter(props: ComponentProps<"div">): JSX.Element;
661
+
662
+ /** @beta */
663
+ export declare interface ModalProps extends Omit<
664
+ React.ComponentProps<"dialog">,
665
+ "open"
666
+ > {
667
+ /** Text to be displayed as the modal's heading; optional but recommended for optimal accessibility and presentation */
668
+ header?: string;
669
+ /** Used to set the value of open to false. Fires whenever the modal is closed, either programmatically or by the user (via Esc key, clicking background, clicking the modal's close button, or any other means.) */
670
+ onClose: React.ReactEventHandler<HTMLDialogElement>;
671
+ /** Whether the modal is open; defaults to false. */
672
+ open?: boolean;
673
+ /** Max width of the modal */
674
+ size?: Responsive<ContainerSize>;
675
+ }
676
+
677
+ declare function ModalRoot({ open, size, ...props }: ModalProps): JSX.Element;
678
+
679
+ declare namespace ModalRoot {
680
+ var displayName: string;
681
+ var Content: typeof ModalContent;
682
+ var Footer: typeof ModalFooter;
683
+ }
684
+
644
685
  declare const OVERFLOW: readonly [
645
686
  "visible",
646
687
  "hidden",
@@ -703,6 +744,33 @@ export declare type PlacementProps = {
703
744
  placement?: Placement;
704
745
  };
705
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
+
706
774
  declare const POSITION: readonly [
707
775
  "absolute",
708
776
  "fixed",
@@ -913,8 +981,8 @@ declare type ToneProps = {
913
981
  tone?: Tone;
914
982
  };
915
983
 
916
- /** @public */
917
- export declare function Tooltip({ placement, ...props }: TooltipProps): any;
984
+ /** @beta */
985
+ export declare const Tooltip: typeof TooltipRoot;
918
986
 
919
987
  /** @public */
920
988
  export declare function TooltipGroup<T extends ElementType = "div">(
@@ -930,15 +998,28 @@ export declare interface TooltipGroupProps<
930
998
  as?: T;
931
999
  }
932
1000
 
933
- /** @public */
1001
+ /** @beta */
934
1002
  export declare interface TooltipProps
935
- extends React.ComponentProps<"div">, PlacementProps {
936
- /** Tooltip text */
937
- text?: React.ReactNode;
938
- /** Disabled state */
939
- disabled?: boolean;
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;
940
1014
  }
941
1015
 
1016
+ declare function TooltipRoot({
1017
+ placement,
1018
+ ...props
1019
+ }: TooltipProps & {
1020
+ triggerProps?: Record<string, unknown>;
1021
+ }): JSX.Element;
1022
+
942
1023
  /** @public */
943
1024
  export declare interface TypographyProps extends MarginProps, ToneProps {
944
1025
  /** CSS **text-align** property */
@@ -953,6 +1034,9 @@ export declare interface TypographyProps extends MarginProps, ToneProps {
953
1034
  weight?: FontWeight;
954
1035
  }
955
1036
 
1037
+ /** @public */
1038
+ export declare function useIsClient(): boolean;
1039
+
956
1040
  /** @public */
957
1041
  export declare function VisuallyHidden<T extends ElementType = "span">(
958
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";
6
- import { SpinnerIcon, RemoveIcon, CheckmarkIcon } from "@sanity/icons";
5
+ import { isValidElement, useRef, useEffect, lazy, Suspense, Children, useId, useSyncExternalStore, useState, cloneElement, Activity } from "react";
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 = "fc8b40";
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;
@@ -1647,7 +1648,205 @@ ListRoot.Item = ListItem;
1647
1648
  ListRoot.ButtonItem = ListButtonItem;
1648
1649
  ListRoot.ItemText = ListItemText;
1649
1650
  ListRoot.ItemImage = ListItemImage;
1650
- const radioProps = {
1651
+ const modalProps = {
1652
+ header: {
1653
+ type: "string"
1654
+ },
1655
+ open: {
1656
+ type: "boolean"
1657
+ },
1658
+ size: {
1659
+ type: "union",
1660
+ className: "container",
1661
+ values: CONTAINER_SIZE
1662
+ }
1663
+ }, modalClassName = suffixClassName("sui-Modal"), modalContentClassName = suffixClassName("sui-ModalContent"), modalFooterClassName = suffixClassName("sui-ModalFooter");
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, {
1670
+ children,
1671
+ className,
1672
+ style,
1673
+ header,
1674
+ onClose,
1675
+ ...rest
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 = () => {
1682
+ const dialogElement = modalRef.current;
1683
+ if (dialogElement)
1684
+ return open ? dialogElement.open || dialogElement.showModal() : dialogElement.open && dialogElement.close(), () => {
1685
+ dialogElement.close();
1686
+ };
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,
1701
+ children
1702
+ ] }), $[9] = children, $[10] = onClose, $[11] = rest, $[12] = style, $[13] = t10, $[14] = t6, $[15] = t7, $[16] = t11) : t11 = $[16], t11;
1703
+ }
1704
+ function ModalContent(props) {
1705
+ const $ = c(12);
1706
+ let T0, children, style, t0, t1;
1707
+ if ($[0] !== props) {
1708
+ const {
1709
+ children: t22,
1710
+ className,
1711
+ style: t3,
1712
+ ...rest
1713
+ } = getProps(props, {});
1714
+ children = t22, style = t3, T0 = Box, t0 = rest, t1 = clsx(modalContentClassName, className), $[0] = props, $[1] = T0, $[2] = children, $[3] = style, $[4] = t0, $[5] = t1;
1715
+ } else
1716
+ T0 = $[1], children = $[2], style = $[3], t0 = $[4], t1 = $[5];
1717
+ let t2;
1718
+ return $[6] !== T0 || $[7] !== children || $[8] !== style || $[9] !== t0 || $[10] !== t1 ? (t2 = /* @__PURE__ */ jsx(T0, { ...t0, className: t1, style, "data-ui": "ModalContent", flexGrow: 1, overflowY: "auto", children }), $[6] = T0, $[7] = children, $[8] = style, $[9] = t0, $[10] = t1, $[11] = t2) : t2 = $[11], t2;
1719
+ }
1720
+ function ModalFooter(props) {
1721
+ const $ = c(12);
1722
+ let T0, children, style, t0, t1;
1723
+ if ($[0] !== props) {
1724
+ const {
1725
+ children: t22,
1726
+ className,
1727
+ style: t3,
1728
+ ...rest
1729
+ } = getProps(props, {});
1730
+ children = t22, style = t3, T0 = Box, t0 = rest, t1 = clsx(modalFooterClassName, className), $[0] = props, $[1] = T0, $[2] = children, $[3] = style, $[4] = t0, $[5] = t1;
1731
+ } else
1732
+ T0 = $[1], children = $[2], style = $[3], t0 = $[4], t1 = $[5];
1733
+ let t2;
1734
+ return $[6] !== T0 || $[7] !== children || $[8] !== style || $[9] !== t0 || $[10] !== t1 ? (t2 = /* @__PURE__ */ jsx(T0, { ...t0, className: t1, style, "data-ui": "ModalFooter", flexShrink: 0, children }), $[6] = T0, $[7] = children, $[8] = style, $[9] = t0, $[10] = t1, $[11] = t2) : t2 = $[11], t2;
1735
+ }
1736
+ ModalRoot.displayName = "Modal";
1737
+ const Modal = ModalRoot;
1738
+ ModalRoot.Content = ModalContent;
1739
+ ModalRoot.Footer = ModalFooter;
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 = {
1651
1850
  error: {
1652
1851
  type: "boolean"
1653
1852
  },
@@ -1668,7 +1867,7 @@ function Radio(props) {
1668
1867
  error,
1669
1868
  ...rest
1670
1869
  } = getProps(props, radioProps);
1671
- 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;
1672
1871
  } else
1673
1872
  T0 = $[1], T1 = $[2], label = $[3], t0 = $[4], t1 = $[5], t2 = $[6], t3 = $[7], t4 = $[8], t5 = $[9], t6 = $[10], t7 = $[11];
1674
1873
  let t8;
@@ -1724,7 +1923,7 @@ function Switch(props) {
1724
1923
  label: t82,
1725
1924
  ...rest
1726
1925
  } = getProps(props, switchProps);
1727
- 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;
1728
1927
  } else
1729
1928
  T0 = $[1], T1 = $[2], label = $[3], t0 = $[4], t1 = $[5], t2 = $[6], t3 = $[7], t4 = $[8], t5 = $[9], t6 = $[10], t7 = $[11];
1730
1929
  let t8;
@@ -1736,79 +1935,73 @@ function Switch(props) {
1736
1935
  label
1737
1936
  ] }), $[16] = T1, $[17] = label, $[18] = t2, $[19] = t3, $[20] = t4, $[21] = t5, $[22] = t6, $[23] = t7, $[24] = t8, $[25] = t9) : t9 = $[25], t9;
1738
1937
  }
1739
- const PLACEMENT = ["top", "top-start", "top-end", "right", "right-start", "right-end", "bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end"], placementProps = {
1740
- placement: {
1741
- type: "union",
1742
- className: "placement",
1743
- values: PLACEMENT
1744
- }
1745
- }, tooltipProps = {
1746
- text: {
1938
+ const tooltipProps = {
1939
+ anchorName: {
1747
1940
  type: "string"
1748
1941
  },
1749
- disabled: {
1942
+ content: {
1943
+ type: "string"
1944
+ },
1945
+ portal: {
1750
1946
  type: "boolean"
1751
1947
  },
1752
1948
  ...placementProps
1753
- }, tooltipClassName = suffixClassName("sui-Tooltip"), tooltipDismissedClassName = suffixClassName("sui-Tooltip-Dismissed");
1754
- function Tooltip(t0) {
1755
- const $ = c(16), {
1949
+ }, tooltipClassName = suffixClassName("sui-Tooltip");
1950
+ function TooltipRoot(t0) {
1951
+ const $ = c(7), {
1756
1952
  placement: t1,
1757
1953
  ...props
1758
1954
  } = t0, placement = t1 === void 0 ? "bottom" : t1, {
1759
1955
  children,
1760
1956
  className,
1761
1957
  style,
1762
- disabled,
1763
1958
  id: idProp,
1764
- text,
1959
+ anchorName,
1960
+ content,
1961
+ portal,
1962
+ triggerProps: forwardedTriggerProps,
1765
1963
  ...rest
1766
1964
  } = getProps({
1767
1965
  placement,
1768
1966
  ...props
1769
- }, tooltipProps), reactId = useId(), id = idProp || reactId, [dismissed, setDismissed] = useState(!1);
1967
+ }, tooltipProps), reactId = useId(), id = idProp || reactId, [dismissed, setDismissed] = useState(!1), isClient = useIsClient();
1770
1968
  let t2, t3;
1771
- $[0] !== dismissed ? (t2 = () => {
1772
- if (dismissed)
1773
- return;
1774
- const handleKeyDown = (e) => {
1775
- e.key === "Escape" && setDismissed(!0);
1776
- };
1777
- return window.addEventListener("keydown", handleKeyDown), () => window.removeEventListener("keydown", handleKeyDown);
1778
- }, t3 = [dismissed], $[0] = dismissed, $[1] = t2, $[2] = t3) : (t2 = $[1], t3 = $[2]), useEffect(t2, t3);
1779
- 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 = {
1780
1975
  "aria-describedby": id,
1781
- onMouseEnter: (e_0) => {
1782
- setDismissed(!1), children.props.onMouseEnter?.(e_0);
1783
- },
1784
- onFocus: (e_1) => {
1785
- setDismissed(!1), children.props.onFocus?.(e_1);
1786
- },
1787
- onClick: (e_2) => {
1788
- setDismissed(!0), children.props.onClick?.(e_2);
1789
- },
1976
+ interestfor: id,
1790
1977
  style: {
1791
- ...children.props.style,
1792
- anchorName: `--tooltip-anchor-${id}`
1978
+ anchorName: `--anchor-${anchorName || id}`
1979
+ },
1980
+ onMouseLeave: t2,
1981
+ onBlur: t3,
1982
+ onClick: () => {
1983
+ setDismissed(!0), document.getElementById(id)?.hidePopover();
1793
1984
  }
1794
- });
1795
- if (disabled)
1796
- return children;
1797
- const T0 = Box, t4 = clsx(tooltipClassName, dismissed ? tooltipDismissedClassName : "", className), t5 = `--tooltip-anchor-${id}`;
1798
- let t6;
1799
- $[3] !== style || $[4] !== t5 ? (t6 = {
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: {
1800
1993
  ...style,
1801
- positionAnchor: t5
1802
- }, $[3] = style, $[4] = t5, $[5] = t6) : t6 = $[5];
1803
- let t7;
1804
- $[6] !== T0 || $[7] !== id || $[8] !== rest || $[9] !== t4 || $[10] !== t6 || $[11] !== text ? (t7 = /* @__PURE__ */ jsx(T0, { className: t4, role: "tooltip", style: t6, "data-ui": "Tooltip", id, paddingX: 2, paddingY: 1, radius: 2, position: "fixed", zIndex: 9999, shadow: 2, ...rest, children: text }), $[6] = T0, $[7] = id, $[8] = rest, $[9] = t4, $[10] = t6, $[11] = text, $[12] = t7) : t7 = $[12];
1805
- let t8;
1806
- 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: [
1807
1998
  trigger,
1808
- t7
1809
- ] }), $[13] = t7, $[14] = trigger, $[15] = t8) : t8 = $[15], t8;
1999
+ t5
2000
+ ] }), $[4] = t5, $[5] = trigger, $[6] = t6) : t6 = $[6], t6;
1810
2001
  }
1811
- const tooltipGroupProps = {
2002
+ const Tooltip = Object.assign(TooltipRoot, {
2003
+ forwardsTriggerProps: !0
2004
+ }), tooltipGroupProps = {
1812
2005
  as: {
1813
2006
  type: "string"
1814
2007
  }
@@ -1824,7 +2017,7 @@ function TooltipGroup(props) {
1824
2017
  let t0;
1825
2018
  $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = (e) => {
1826
2019
  const tooltip = e.target.closest('[data-ui="Tooltip"]');
1827
- tooltip && e.propertyName === "visibility" && window.getComputedStyle(tooltip).visibility !== "hidden" && setIsActive(!0);
2020
+ tooltip && e.propertyName === "opacity" && window.getComputedStyle(tooltip).opacity !== "0" && setIsActive(!0);
1828
2021
  }, $[0] = t0) : t0 = $[0];
1829
2022
  const handleTransitionEnd = t0;
1830
2023
  let t1;
@@ -1839,7 +2032,7 @@ function TooltipGroup(props) {
1839
2032
  const handleBlur = t2, t3 = clsx(tooltipGroupClassName, className);
1840
2033
  let t4;
1841
2034
  $[3] !== isActive ? (t4 = isActive && {
1842
- "--tooltip-delay-group": 0
2035
+ "--tooltip-delay-group": "0ms"
1843
2036
  }, $[3] = isActive, $[4] = t4) : t4 = $[4];
1844
2037
  let t5;
1845
2038
  $[5] !== style || $[6] !== t4 ? (t5 = {
@@ -1870,6 +2063,8 @@ export {
1870
2063
  Label,
1871
2064
  Link,
1872
2065
  List,
2066
+ Modal,
2067
+ Popover,
1873
2068
  PressArea,
1874
2069
  Radio,
1875
2070
  SkipToContent,
@@ -1879,6 +2074,7 @@ export {
1879
2074
  Tooltip,
1880
2075
  TooltipGroup,
1881
2076
  VStack,
1882
- VisuallyHidden
2077
+ VisuallyHidden,
2078
+ useIsClient
1883
2079
  };
1884
2080
  //# sourceMappingURL=index.js.map