@sanity/ui 5.0.0-alpha.5 → 5.0.0-alpha.7

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.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, useId, Children, 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 = "024922";
99
+ const HASH = "47d232";
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;
@@ -970,6 +971,176 @@ function Container(t0) {
970
971
  let t2;
971
972
  return $[6] !== T0 || $[7] !== children || $[8] !== rest || $[9] !== style || $[10] !== t1 ? (t2 = /* @__PURE__ */ jsx(T0, { className: t1, style, "data-ui": "Container", ...rest, children }), $[6] = T0, $[7] = children, $[8] = rest, $[9] = style, $[10] = t1, $[11] = t2) : t2 = $[11], t2;
972
973
  }
974
+ const HEADING_TAG = ["h1", "h2", "h3", "h4", "h5", "h6"], HEADING_SIZE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], headingProps = {
975
+ as: {
976
+ type: "union",
977
+ values: HEADING_TAG
978
+ },
979
+ size: {
980
+ type: "union",
981
+ className: "text-heading",
982
+ values: HEADING_SIZE
983
+ },
984
+ ...typographyProps
985
+ }, headingClassName = suffixClassName("sui-Heading");
986
+ function Heading(t0) {
987
+ const $ = c(15);
988
+ let T0, children, rest, style, t1, t2;
989
+ if ($[0] !== t0) {
990
+ t2 = /* @__PURE__ */ Symbol.for("react.early_return_sentinel");
991
+ bb0: {
992
+ const {
993
+ size: t32,
994
+ weight: t4,
995
+ ...props
996
+ } = t0, size = t32 === void 0 ? 2 : t32, weight = t4 === void 0 ? "bold" : t4, {
997
+ as,
998
+ children: t5,
999
+ className,
1000
+ style: t6,
1001
+ ...t7
1002
+ } = getProps({
1003
+ size,
1004
+ weight,
1005
+ ...props
1006
+ }, headingProps);
1007
+ children = t5, style = t6, rest = t7;
1008
+ const Component = as || "h2";
1009
+ if (props.truncate && props.trim) {
1010
+ const t8 = clsx(headingClassName, className?.replace("sui-line-clamp", "").replace("sui-text-overflow", "")), t9 = props.truncate === 1 ? "sui-text-overflow" : "sui-line-clamp";
1011
+ let t10;
1012
+ $[7] !== t9 ? (t10 = clsx("sui-overflow-hidden", t9), $[7] = t9, $[8] = t10) : t10 = $[8], t2 = /* @__PURE__ */ jsx(Component, { className: t8, style, "data-ui": "Heading", ...rest, children: /* @__PURE__ */ jsx("span", { className: t10, children }) });
1013
+ break bb0;
1014
+ }
1015
+ T0 = Component, t1 = clsx(headingClassName, props.truncate && "sui-overflow-hidden", className);
1016
+ }
1017
+ $[0] = t0, $[1] = T0, $[2] = children, $[3] = rest, $[4] = style, $[5] = t1, $[6] = t2;
1018
+ } else
1019
+ T0 = $[1], children = $[2], rest = $[3], style = $[4], t1 = $[5], t2 = $[6];
1020
+ if (t2 !== /* @__PURE__ */ Symbol.for("react.early_return_sentinel"))
1021
+ return t2;
1022
+ let t3;
1023
+ return $[9] !== T0 || $[10] !== children || $[11] !== rest || $[12] !== style || $[13] !== t1 ? (t3 = /* @__PURE__ */ jsx(T0, { className: t1, style, "data-ui": "Heading", ...rest, children }), $[9] = T0, $[10] = children, $[11] = rest, $[12] = style, $[13] = t1, $[14] = t3) : t3 = $[14], t3;
1024
+ }
1025
+ const iconButtonProps = {
1026
+ "aria-label": {
1027
+ type: "string"
1028
+ },
1029
+ as: buttonProps.as,
1030
+ icon: {
1031
+ type: "string"
1032
+ }
1033
+ }, iconButtonClassName = suffixClassName("sui-IconButton");
1034
+ function IconButton(props) {
1035
+ const $ = c(16);
1036
+ let IconProp, T0, rest, style, t0, t1;
1037
+ if ($[0] !== props) {
1038
+ const {
1039
+ as,
1040
+ className,
1041
+ style: t22,
1042
+ icon: t32,
1043
+ ...t4
1044
+ } = getProps(props, iconButtonProps);
1045
+ style = t22, IconProp = t32, rest = t4;
1046
+ const Component = as || "button";
1047
+ T0 = Button, t0 = Component, t1 = clsx(iconButtonClassName, className), $[0] = props, $[1] = IconProp, $[2] = T0, $[3] = rest, $[4] = style, $[5] = t0, $[6] = t1;
1048
+ } else
1049
+ IconProp = $[1], T0 = $[2], rest = $[3], style = $[4], t0 = $[5], t1 = $[6];
1050
+ let t2;
1051
+ $[7] !== IconProp ? (t2 = /* @__PURE__ */ jsx(Icon, { icon: IconProp, margin: -2, size: 1 }), $[7] = IconProp, $[8] = t2) : t2 = $[8];
1052
+ let t3;
1053
+ return $[9] !== T0 || $[10] !== rest || $[11] !== style || $[12] !== t0 || $[13] !== t1 || $[14] !== t2 ? (t3 = /* @__PURE__ */ jsx(T0, { as: t0, className: t1, style, "data-ui": "IconButton", ...rest, children: t2 }), $[9] = T0, $[10] = rest, $[11] = style, $[12] = t0, $[13] = t1, $[14] = t2, $[15] = t3) : t3 = $[15], t3;
1054
+ }
1055
+ const dialogProps = {
1056
+ header: {
1057
+ type: "string"
1058
+ },
1059
+ open: {
1060
+ type: "boolean"
1061
+ },
1062
+ size: {
1063
+ type: "union",
1064
+ className: "container",
1065
+ values: CONTAINER_SIZE
1066
+ }
1067
+ }, dialogClassName = suffixClassName("sui-Dialog"), dialogContentClassName = suffixClassName("sui-DialogContent"), dialogFooterClassName = suffixClassName("sui-DialogFooter");
1068
+ function DialogRoot(t0) {
1069
+ const $ = c(17), {
1070
+ open: t1,
1071
+ size: t2,
1072
+ ...props
1073
+ } = t0, open = t1 === void 0 ? !1 : t1, size = t2 === void 0 ? 0 : t2, {
1074
+ children,
1075
+ className,
1076
+ style,
1077
+ header,
1078
+ onClose,
1079
+ ...rest
1080
+ } = getProps({
1081
+ size,
1082
+ ...props
1083
+ }, dialogProps), dialogRef = useRef(null), headerId = useId(), dialogClasses = clsx(dialogClassName, "sui-inset0 sui-m-auto sui-radius5 sui-shadow3 sui-p4 sui-flex-direction-column sui-gap4 sui-overflow-y-auto");
1084
+ let t3, t4;
1085
+ $[0] !== open ? (t3 = () => {
1086
+ const dialogElement = dialogRef.current;
1087
+ if (dialogElement)
1088
+ return open ? dialogElement.open || dialogElement.showModal() : dialogElement.open && dialogElement.close(), () => {
1089
+ dialogElement.close();
1090
+ };
1091
+ }, t4 = [open], $[0] = open, $[1] = t3, $[2] = t4) : (t3 = $[1], t4 = $[2]), useEffect(t3, t4);
1092
+ const t5 = "any", t6 = header ? headerId : void 0, t7 = clsx(dialogClasses, className);
1093
+ let t8;
1094
+ $[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];
1095
+ let t9;
1096
+ $[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx(IconButton, { "aria-label": "Close", level: "tertiary", icon: CloseIcon, onClick: () => dialogRef.current?.close() }), $[6] = t9) : t9 = $[6];
1097
+ let t10;
1098
+ $[7] !== t8 ? (t10 = /* @__PURE__ */ jsxs(Flex, { flexShrink: 0, justifyContent: "space-between", alignItems: "center", children: [
1099
+ t8,
1100
+ t9
1101
+ ] }), $[7] = t8, $[8] = t10) : t10 = $[8];
1102
+ let t11;
1103
+ return $[9] !== children || $[10] !== onClose || $[11] !== rest || $[12] !== style || $[13] !== t10 || $[14] !== t6 || $[15] !== t7 ? (t11 = /* @__PURE__ */ jsxs("dialog", { ...rest, ref: dialogRef, closedby: t5, "aria-labelledby": t6, onClose, className: t7, style, "data-ui": "Dialog", children: [
1104
+ t10,
1105
+ children
1106
+ ] }), $[9] = children, $[10] = onClose, $[11] = rest, $[12] = style, $[13] = t10, $[14] = t6, $[15] = t7, $[16] = t11) : t11 = $[16], t11;
1107
+ }
1108
+ function DialogContent(props) {
1109
+ const $ = c(12);
1110
+ let T0, children, style, t0, t1;
1111
+ if ($[0] !== props) {
1112
+ const {
1113
+ children: t22,
1114
+ className,
1115
+ style: t3,
1116
+ ...rest
1117
+ } = getProps(props, {});
1118
+ children = t22, style = t3, T0 = Box, t0 = rest, t1 = clsx(dialogContentClassName, className), $[0] = props, $[1] = T0, $[2] = children, $[3] = style, $[4] = t0, $[5] = t1;
1119
+ } else
1120
+ T0 = $[1], children = $[2], style = $[3], t0 = $[4], t1 = $[5];
1121
+ let t2;
1122
+ return $[6] !== T0 || $[7] !== children || $[8] !== style || $[9] !== t0 || $[10] !== t1 ? (t2 = /* @__PURE__ */ jsx(T0, { ...t0, className: t1, style, "data-ui": "DialogContent", flexGrow: 1, overflowY: "auto", children }), $[6] = T0, $[7] = children, $[8] = style, $[9] = t0, $[10] = t1, $[11] = t2) : t2 = $[11], t2;
1123
+ }
1124
+ function DialogFooter(props) {
1125
+ const $ = c(12);
1126
+ let T0, children, style, t0, t1;
1127
+ if ($[0] !== props) {
1128
+ const {
1129
+ children: t22,
1130
+ className,
1131
+ style: t3,
1132
+ ...rest
1133
+ } = getProps(props, {});
1134
+ children = t22, style = t3, T0 = Box, t0 = rest, t1 = clsx(dialogFooterClassName, className), $[0] = props, $[1] = T0, $[2] = children, $[3] = style, $[4] = t0, $[5] = t1;
1135
+ } else
1136
+ T0 = $[1], children = $[2], style = $[3], t0 = $[4], t1 = $[5];
1137
+ let t2;
1138
+ return $[6] !== T0 || $[7] !== children || $[8] !== style || $[9] !== t0 || $[10] !== t1 ? (t2 = /* @__PURE__ */ jsx(T0, { ...t0, className: t1, style, "data-ui": "DialogFooter", flexShrink: 0, children }), $[6] = T0, $[7] = children, $[8] = style, $[9] = t0, $[10] = t1, $[11] = t2) : t2 = $[11], t2;
1139
+ }
1140
+ DialogRoot.displayName = "Dialog";
1141
+ const Dialog = DialogRoot;
1142
+ DialogRoot.Content = DialogContent;
1143
+ DialogRoot.Footer = DialogFooter;
973
1144
  const dividerProps = {
974
1145
  ...marginProps
975
1146
  }, dividerClassName = suffixClassName("sui-Divider");
@@ -1129,87 +1300,6 @@ function HStack(props) {
1129
1300
  let t2;
1130
1301
  return $[7] !== T0 || $[8] !== children || $[9] !== rest || $[10] !== style || $[11] !== t0 || $[12] !== t1 ? (t2 = /* @__PURE__ */ jsx(T0, { as: t0, className: t1, style, "data-ui": "HStack", display: "inline-flex", alignItems: "center", flexWrap: "wrap", ...rest, children }), $[7] = T0, $[8] = children, $[9] = rest, $[10] = style, $[11] = t0, $[12] = t1, $[13] = t2) : t2 = $[13], t2;
1131
1302
  }
1132
- const HEADING_TAG = ["h1", "h2", "h3", "h4", "h5", "h6"], HEADING_SIZE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], headingProps = {
1133
- as: {
1134
- type: "union",
1135
- values: HEADING_TAG
1136
- },
1137
- size: {
1138
- type: "union",
1139
- className: "text-heading",
1140
- values: HEADING_SIZE
1141
- },
1142
- ...typographyProps
1143
- }, headingClassName = suffixClassName("sui-Heading");
1144
- function Heading(t0) {
1145
- const $ = c(15);
1146
- let T0, children, rest, style, t1, t2;
1147
- if ($[0] !== t0) {
1148
- t2 = /* @__PURE__ */ Symbol.for("react.early_return_sentinel");
1149
- bb0: {
1150
- const {
1151
- size: t32,
1152
- weight: t4,
1153
- ...props
1154
- } = t0, size = t32 === void 0 ? 2 : t32, weight = t4 === void 0 ? "bold" : t4, {
1155
- as,
1156
- children: t5,
1157
- className,
1158
- style: t6,
1159
- ...t7
1160
- } = getProps({
1161
- size,
1162
- weight,
1163
- ...props
1164
- }, headingProps);
1165
- children = t5, style = t6, rest = t7;
1166
- const Component = as || "h2";
1167
- if (props.truncate && props.trim) {
1168
- const t8 = clsx(headingClassName, className?.replace("sui-line-clamp", "").replace("sui-text-overflow", "")), t9 = props.truncate === 1 ? "sui-text-overflow" : "sui-line-clamp";
1169
- let t10;
1170
- $[7] !== t9 ? (t10 = clsx("sui-overflow-hidden", t9), $[7] = t9, $[8] = t10) : t10 = $[8], t2 = /* @__PURE__ */ jsx(Component, { className: t8, style, "data-ui": "Heading", ...rest, children: /* @__PURE__ */ jsx("span", { className: t10, children }) });
1171
- break bb0;
1172
- }
1173
- T0 = Component, t1 = clsx(headingClassName, props.truncate && "sui-overflow-hidden", className);
1174
- }
1175
- $[0] = t0, $[1] = T0, $[2] = children, $[3] = rest, $[4] = style, $[5] = t1, $[6] = t2;
1176
- } else
1177
- T0 = $[1], children = $[2], rest = $[3], style = $[4], t1 = $[5], t2 = $[6];
1178
- if (t2 !== /* @__PURE__ */ Symbol.for("react.early_return_sentinel"))
1179
- return t2;
1180
- let t3;
1181
- return $[9] !== T0 || $[10] !== children || $[11] !== rest || $[12] !== style || $[13] !== t1 ? (t3 = /* @__PURE__ */ jsx(T0, { className: t1, style, "data-ui": "Heading", ...rest, children }), $[9] = T0, $[10] = children, $[11] = rest, $[12] = style, $[13] = t1, $[14] = t3) : t3 = $[14], t3;
1182
- }
1183
- const iconButtonProps = {
1184
- "aria-label": {
1185
- type: "string"
1186
- },
1187
- as: buttonProps.as,
1188
- icon: {
1189
- type: "string"
1190
- }
1191
- }, iconButtonClassName = suffixClassName("sui-IconButton");
1192
- function IconButton(props) {
1193
- const $ = c(16);
1194
- let IconProp, T0, rest, style, t0, t1;
1195
- if ($[0] !== props) {
1196
- const {
1197
- as,
1198
- className,
1199
- style: t22,
1200
- icon: t32,
1201
- ...t4
1202
- } = getProps(props, iconButtonProps);
1203
- style = t22, IconProp = t32, rest = t4;
1204
- const Component = as || "button";
1205
- T0 = Button, t0 = Component, t1 = clsx(iconButtonClassName, className), $[0] = props, $[1] = IconProp, $[2] = T0, $[3] = rest, $[4] = style, $[5] = t0, $[6] = t1;
1206
- } else
1207
- IconProp = $[1], T0 = $[2], rest = $[3], style = $[4], t0 = $[5], t1 = $[6];
1208
- let t2;
1209
- $[7] !== IconProp ? (t2 = /* @__PURE__ */ jsx(Icon, { icon: IconProp, margin: -2, size: 1 }), $[7] = IconProp, $[8] = t2) : t2 = $[8];
1210
- let t3;
1211
- return $[9] !== T0 || $[10] !== rest || $[11] !== style || $[12] !== t0 || $[13] !== t1 || $[14] !== t2 ? (t3 = /* @__PURE__ */ jsx(T0, { as: t0, className: t1, style, "data-ui": "IconButton", ...rest, children: t2 }), $[9] = T0, $[10] = rest, $[11] = style, $[12] = t0, $[13] = t1, $[14] = t2, $[15] = t3) : t3 = $[15], t3;
1212
- }
1213
1303
  const indicatorProps = {
1214
1304
  as: {
1215
1305
  type: "string"
@@ -1647,84 +1737,116 @@ ListRoot.Item = ListItem;
1647
1737
  ListRoot.ButtonItem = ListButtonItem;
1648
1738
  ListRoot.ItemText = ListItemText;
1649
1739
  ListRoot.ItemImage = ListItemImage;
1650
- const modalProps = {
1651
- header: {
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: {
1652
1798
  type: "string"
1653
1799
  },
1654
- open: {
1800
+ content: {
1801
+ type: "string"
1802
+ },
1803
+ portal: {
1655
1804
  type: "boolean"
1656
- }
1657
- }, modalClassName = suffixClassName("sui-Modal"), modalContentClassName = suffixClassName("sui-ModalContent"), modalFooterClassName = suffixClassName("sui-ModalFooter");
1658
- function ModalRoot(props) {
1659
- const $ = c(14), {
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, {
1660
1813
  children,
1661
1814
  className,
1662
1815
  style,
1663
- header,
1664
- open: t0,
1665
- onClose,
1816
+ id: idProp,
1817
+ anchorName,
1818
+ content,
1819
+ portal,
1820
+ triggerProps: forwardedTriggerProps,
1666
1821
  ...rest
1667
- } = getProps(props, modalProps), open = t0 === void 0 ? !1 : t0, 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");
1668
- useEffect(() => {
1669
- const dialogElement = modalRef.current;
1670
- if (dialogElement)
1671
- return open ? dialogElement.open || dialogElement.showModal() : dialogElement.open && dialogElement.close(), () => {
1672
- dialogElement.close();
1673
- };
1674
- }, [open]);
1675
- const t1 = "any", t2 = header ? headerId : void 0, t3 = clsx(modalClasses, className);
1676
- let t4;
1677
- $[0] !== header || $[1] !== headerId ? (t4 = header ? /* @__PURE__ */ jsx(Heading, { trim: !0, size: 1, id: headerId, children: header }) : /* @__PURE__ */ jsx("div", {}), $[0] = header, $[1] = headerId, $[2] = t4) : t4 = $[2];
1678
- let t5;
1679
- $[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = /* @__PURE__ */ jsx(IconButton, { "aria-label": "Close", level: "tertiary", icon: CloseIcon, onClick: () => modalRef.current?.close() }), $[3] = t5) : t5 = $[3];
1680
- let t6;
1681
- $[4] !== t4 ? (t6 = /* @__PURE__ */ jsxs(Flex, { flexShrink: 0, justifyContent: "space-between", alignItems: "center", children: [
1682
- t4,
1683
- t5
1684
- ] }), $[4] = t4, $[5] = t6) : t6 = $[5];
1685
- let t7;
1686
- return $[6] !== children || $[7] !== onClose || $[8] !== rest || $[9] !== style || $[10] !== t2 || $[11] !== t3 || $[12] !== t6 ? (t7 = /* @__PURE__ */ jsxs("dialog", { ...rest, ref: modalRef, closedby: t1, "aria-labelledby": t2, onClose, className: t3, style, "data-ui": "Modal", children: [
1687
- t6,
1688
- children
1689
- ] }), $[6] = children, $[7] = onClose, $[8] = rest, $[9] = style, $[10] = t2, $[11] = t3, $[12] = t6, $[13] = t7) : t7 = $[13], t7;
1690
- }
1691
- function ModalContent(props) {
1692
- const $ = c(12);
1693
- let T0, children, style, t0, t1;
1694
- if ($[0] !== props) {
1695
- const {
1696
- children: t22,
1697
- className,
1698
- style: t3,
1699
- ...rest
1700
- } = getProps(props, {});
1701
- children = t22, style = t3, T0 = Box, t0 = rest, t1 = clsx(modalContentClassName, className), $[0] = props, $[1] = T0, $[2] = children, $[3] = style, $[4] = t0, $[5] = t1;
1702
- } else
1703
- T0 = $[1], children = $[2], style = $[3], t0 = $[4], t1 = $[5];
1704
- let t2;
1705
- 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;
1706
- }
1707
- function ModalFooter(props) {
1708
- const $ = c(12);
1709
- let T0, children, style, t0, t1;
1710
- if ($[0] !== props) {
1711
- const {
1712
- children: t22,
1713
- className,
1714
- style: t3,
1715
- ...rest
1716
- } = getProps(props, {});
1717
- children = t22, style = t3, T0 = Box, t0 = rest, t1 = clsx(modalFooterClassName, className), $[0] = props, $[1] = T0, $[2] = children, $[3] = style, $[4] = t0, $[5] = t1;
1718
- } else
1719
- T0 = $[1], children = $[2], style = $[3], t0 = $[4], t1 = $[5];
1822
+ } = getProps({
1823
+ placement,
1824
+ ...props
1825
+ }, popoverProps), reactId = useId(), id = idProp || reactId, [open, setOpen] = useState(!1), isClient = useIsClient();
1720
1826
  let t2;
1721
- 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;
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;
1722
1846
  }
1723
- ModalRoot.displayName = "Modal";
1724
- const Modal = ModalRoot;
1725
- ModalRoot.Content = ModalContent;
1726
- ModalRoot.Footer = ModalFooter;
1727
- const radioProps = {
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 PLACEMENT = ["top", "top-start", "top-end", "right", "right-start", "right-end", "bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end"], placementProps = {
1817
- placement: {
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
- disabled: {
1942
+ content: {
1943
+ type: "string"
1944
+ },
1945
+ portal: {
1827
1946
  type: "boolean"
1828
1947
  },
1829
1948
  ...placementProps
1830
- }, tooltipClassName = suffixClassName("sui-Tooltip"), tooltipDismissedClassName = suffixClassName("sui-Tooltip-Dismissed");
1831
- function Tooltip(t0) {
1832
- const $ = c(16), {
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
- text,
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] !== dismissed ? (t2 = () => {
1849
- if (dismissed)
1850
- return;
1851
- const handleKeyDown = (e) => {
1852
- e.key === "Escape" && setDismissed(!0);
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
- onMouseEnter: (e_0) => {
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
- ...children.props.style,
1869
- 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();
1870
1984
  }
1871
- });
1872
- if (disabled)
1873
- return children;
1874
- const T0 = Box, t4 = clsx(tooltipClassName, dismissed ? tooltipDismissedClassName : "", className), t5 = `--tooltip-anchor-${id}`;
1875
- let t6;
1876
- $[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: {
1877
1993
  ...style,
1878
- positionAnchor: t5
1879
- }, $[3] = style, $[4] = t5, $[5] = t6) : t6 = $[5];
1880
- let t7;
1881
- $[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];
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
- t7
1886
- ] }), $[13] = t7, $[14] = trigger, $[15] = t8) : t8 = $[15], t8;
1999
+ t5
2000
+ ] }), $[4] = t5, $[5] = trigger, $[6] = t6) : t6 = $[6], t6;
1887
2001
  }
1888
- const tooltipGroupProps = {
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 === "visibility" && window.getComputedStyle(tooltip).visibility !== "hidden" && setIsActive(!0);
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": 0
2035
+ "--tooltip-delay-group": "0ms"
1920
2036
  }, $[3] = isActive, $[4] = t4) : t4 = $[4];
1921
2037
  let t5;
1922
2038
  $[5] !== style || $[6] !== t4 ? (t5 = {
@@ -1933,6 +2049,7 @@ export {
1933
2049
  Checkbox,
1934
2050
  Code,
1935
2051
  Container,
2052
+ Dialog,
1936
2053
  Divider,
1937
2054
  Eyebrow,
1938
2055
  Flex,
@@ -1947,7 +2064,7 @@ export {
1947
2064
  Label,
1948
2065
  Link,
1949
2066
  List,
1950
- 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