@sanity/ui 3.0.0-static.26 → 3.0.0-static.28

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.
Files changed (248) hide show
  1. package/README.md +1 -1
  2. package/dist/_chunks-cjs/_visual-editing.cjs +674 -804
  3. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
  4. package/dist/_chunks-cjs/refractor.cjs +2 -2
  5. package/dist/_chunks-cjs/refractor.cjs.map +1 -1
  6. package/dist/_chunks-es/_visual-editing.js +652 -781
  7. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  8. package/dist/_chunks-es/refractor.js +1 -1
  9. package/dist/_visual-editing.d.cts +1 -0
  10. package/dist/_visual-editing.d.ts +1 -0
  11. package/dist/css/layers.css +4 -0
  12. package/dist/css/primitives/popover/popover.css +4 -0
  13. package/dist/css.cjs +59 -50
  14. package/dist/css.cjs.map +1 -1
  15. package/dist/css.d.cts +14 -6
  16. package/dist/css.d.ts +14 -6
  17. package/dist/css.js +59 -50
  18. package/dist/css.js.map +1 -1
  19. package/dist/index.cjs +1995 -1813
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.css +1 -0
  22. package/dist/index.d.cts +35 -17
  23. package/dist/index.d.ts +35 -17
  24. package/dist/index.js +2013 -1832
  25. package/dist/index.js.map +1 -1
  26. package/dist/theme.cjs +2605 -1075
  27. package/dist/theme.cjs.map +1 -1
  28. package/dist/theme.d.cts +1 -1
  29. package/dist/theme.d.ts +1 -1
  30. package/dist/theme.js +2689 -1159
  31. package/dist/theme.js.map +1 -1
  32. package/exports/_visual-editing.ts +2 -2
  33. package/package.json +20 -38
  34. package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
  35. package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
  36. package/src/core/components/autocomplete/autocomplete.tsx +13 -17
  37. package/src/core/components/autocomplete/autocompleteOption.tsx +1 -1
  38. package/src/core/components/autocomplete/constants.ts +3 -1
  39. package/src/core/components/autocomplete/types.ts +1 -1
  40. package/src/core/components/breadcrumbs/breadcrumbs.tsx +8 -3
  41. package/src/core/components/dialog/__workshop__/activate.tsx +11 -3
  42. package/src/core/components/dialog/__workshop__/panes.tsx +12 -5
  43. package/src/core/components/dialog/dialog.tsx +12 -13
  44. package/src/core/components/dialog/dialogCard.tsx +89 -53
  45. package/src/core/components/dialog/dialogContext.ts +1 -1
  46. package/src/core/components/dialog/dialogProvider.tsx +1 -1
  47. package/src/core/components/dialog/index.ts +1 -0
  48. package/src/core/components/dialog/isTargetWithinScope.ts +1 -1
  49. package/src/core/components/hotkeys/hotkeys.tsx +3 -2
  50. package/src/core/components/menu/__workshop__/avatarMenu.tsx +12 -6
  51. package/src/core/components/menu/__workshop__/customSelectedState.tsx +1 -5
  52. package/src/core/components/menu/__workshop__/shouldFocus.tsx +1 -2
  53. package/src/core/components/menu/helpers.ts +1 -1
  54. package/src/core/components/menu/menu.tsx +6 -4
  55. package/src/core/components/menu/menuButton.tsx +5 -3
  56. package/src/core/components/menu/menuDivider.tsx +1 -1
  57. package/src/core/components/menu/menuGroup.tsx +8 -4
  58. package/src/core/components/menu/menuItem.tsx +4 -2
  59. package/src/core/components/tab/tab.tsx +2 -2
  60. package/src/core/components/tab/tabList.tsx +2 -2
  61. package/src/core/components/tab/tabPanel.tsx +2 -2
  62. package/src/core/components/toast/toast.tsx +7 -2
  63. package/src/core/components/toast/toastLayer.tsx +2 -2
  64. package/src/core/components/toast/toastProvider.tsx +1 -1
  65. package/src/core/components/tree/tree.tsx +2 -2
  66. package/src/core/components/tree/treeGroup.tsx +2 -2
  67. package/src/core/components/tree/treeItem.tsx +13 -6
  68. package/src/core/components/tree/types.ts +0 -1
  69. package/src/core/{utils → components}/virtualList/__workshop__/index.ts +1 -1
  70. package/src/core/{utils → components}/virtualList/virtualList.tsx +10 -5
  71. package/src/core/helpers/focus.ts +0 -8
  72. package/src/core/hooks/useArrayProp.ts +1 -1
  73. package/src/core/hooks/useElementRect/__workshop__/example.tsx +1 -3
  74. package/src/core/hooks/useElementSize.ts +1 -1
  75. package/src/core/hooks/useResponsiveProp.ts +1 -1
  76. package/src/core/index.ts +83 -7
  77. package/src/core/observers/{elementSizeObserver.ts → elementSize.ts} +1 -1
  78. package/src/core/primitives/_selectable/index.ts +1 -0
  79. package/src/core/primitives/_selectable/selectable.tsx +13 -3
  80. package/src/core/{types/selectable.ts → primitives/_selectable/types.ts} +1 -1
  81. package/src/core/{utils → primitives}/arrow/arrow.tsx +1 -1
  82. package/src/core/primitives/avatar/avatar.tsx +4 -3
  83. package/src/core/primitives/avatar/avatarCounter.tsx +3 -3
  84. package/src/core/primitives/avatar/avatarStack.tsx +4 -4
  85. package/src/core/primitives/avatar/types.ts +17 -0
  86. package/src/core/primitives/badge/badge.tsx +4 -2
  87. package/src/core/primitives/badge/types.ts +11 -2
  88. package/src/core/primitives/box/__workshop__/responsive.tsx +0 -1
  89. package/src/core/primitives/box/box.tsx +1 -1
  90. package/src/core/primitives/box/index.ts +1 -0
  91. package/src/core/primitives/button/__workshop__/disabled.tsx +37 -51
  92. package/src/core/primitives/button/__workshop__/index.ts +5 -0
  93. package/src/core/primitives/button/__workshop__/textOverflow.tsx +13 -0
  94. package/src/core/primitives/button/button.tsx +15 -14
  95. package/src/core/primitives/button/index.ts +1 -0
  96. package/src/core/primitives/card/__workshop__/listNavigation.tsx +2 -2
  97. package/src/core/primitives/card/card.tsx +1 -1
  98. package/src/core/primitives/card/types.ts +3 -0
  99. package/src/core/primitives/checkbox/__workshop__/tones.tsx +9 -1
  100. package/src/core/primitives/checkbox/checkbox.tsx +3 -4
  101. package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +17 -42
  102. package/src/core/primitives/code/code.tsx +1 -1
  103. package/src/core/primitives/container/container.tsx +1 -1
  104. package/src/core/primitives/flex/flex.tsx +1 -1
  105. package/src/core/primitives/flex/index.ts +1 -0
  106. package/src/core/primitives/grid/grid.tsx +1 -1
  107. package/src/core/primitives/grid/index.ts +1 -0
  108. package/src/core/primitives/heading/heading.tsx +1 -1
  109. package/src/core/primitives/inline/inline.tsx +1 -1
  110. package/src/core/primitives/kbd/kbd.tsx +1 -1
  111. package/src/core/primitives/label/label.tsx +1 -1
  112. package/src/core/{utils → primitives}/layer/__workshop__/index.ts +1 -1
  113. package/src/core/{utils → primitives}/layer/layer.test.tsx +1 -1
  114. package/src/core/{utils → primitives}/layer/layer.tsx +2 -2
  115. package/src/core/{utils → primitives}/layer/layerCard.tsx +3 -3
  116. package/src/core/{utils → primitives}/layer/layerProvider.tsx +2 -1
  117. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +12 -9
  118. package/src/core/primitives/popover/__workshop__/TestStory.tsx +9 -8
  119. package/src/core/primitives/popover/constants.ts +1 -1
  120. package/src/core/primitives/popover/floating-ui/size.ts +1 -1
  121. package/src/core/primitives/popover/popover.tsx +8 -4
  122. package/src/core/primitives/popover/popoverLayer.tsx +4 -2
  123. package/src/core/primitives/popover/types.ts +5 -0
  124. package/src/core/primitives/radio/radio.tsx +2 -2
  125. package/src/core/primitives/select/select.tsx +2 -2
  126. package/src/core/{components → primitives}/skeleton/__workshop__/index.ts +1 -1
  127. package/src/core/{components → primitives}/skeleton/codeSkeleton.tsx +1 -1
  128. package/src/core/{components → primitives}/skeleton/headingSkeleton.tsx +1 -1
  129. package/src/core/{components → primitives}/skeleton/labelSkeleton.tsx +1 -1
  130. package/src/core/{components → primitives}/skeleton/skeleton.tsx +7 -8
  131. package/src/core/{components → primitives}/skeleton/textSkeleton.tsx +1 -1
  132. package/src/core/primitives/spinner/spinner.tsx +1 -1
  133. package/src/core/{utils → primitives}/srOnly/srOnly.tsx +1 -1
  134. package/src/core/primitives/stack/stack.tsx +2 -1
  135. package/src/core/primitives/switch/switch.tsx +2 -7
  136. package/src/core/primitives/text/__workshop__/colored.tsx +2 -2
  137. package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +17 -42
  138. package/src/core/primitives/text/text.tsx +3 -1
  139. package/src/core/primitives/textArea/__workshop__/plain.tsx +2 -2
  140. package/src/core/primitives/textArea/textArea.tsx +2 -2
  141. package/src/core/primitives/textInput/textInput.tsx +3 -2
  142. package/src/core/primitives/tooltip/constants.ts +1 -1
  143. package/src/core/primitives/tooltip/tooltip.tsx +6 -3
  144. package/src/core/primitives/tooltip/tooltipLayer.tsx +3 -2
  145. package/src/core/primitives/types.ts +8 -10
  146. package/src/core/types/radius.ts +1 -1
  147. package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +9 -5
  148. package/src/core/utils/elementQuery/elementQuery.tsx +2 -2
  149. package/src/core/utils/getElementRef.ts +1 -0
  150. package/src/core/utils/portal/portal.tsx +1 -1
  151. package/src/css/components/dialog/dialog.css.ts +26 -1
  152. package/src/css/components/dialog/dialog.ts +27 -7
  153. package/src/css/components/skeleton/skeleton.ts +3 -1
  154. package/src/css/components/skeleton/types.ts +3 -1
  155. package/src/css/index.ts +75 -5
  156. package/src/css/primitives/_input/input.ts +2 -1
  157. package/src/css/primitives/_input/types.ts +2 -1
  158. package/src/css/primitives/_selectable/_selectable.css.ts +32 -24
  159. package/src/css/primitives/_selectable/selectable.ts +1 -1
  160. package/src/css/primitives/_selectable/types.ts +1 -1
  161. package/src/css/primitives/avatar/avatar.css.ts +11 -2
  162. package/src/css/primitives/avatar/avatar.ts +1 -1
  163. package/src/css/primitives/badge/badge.css.ts +2 -1
  164. package/src/css/primitives/badge/types.ts +0 -2
  165. package/src/css/primitives/box/box.ts +35 -37
  166. package/src/css/primitives/box/types.ts +34 -36
  167. package/src/css/primitives/button/button.css.ts +4 -0
  168. package/src/css/primitives/button/button.ts +5 -2
  169. package/src/css/primitives/button/types.ts +4 -11
  170. package/src/css/primitives/card/__workshop__/color.tsx +70 -0
  171. package/src/css/primitives/card/__workshop__/index.ts +14 -0
  172. package/src/css/primitives/card/card.css.ts +4 -0
  173. package/src/css/primitives/code/code.ts +3 -1
  174. package/src/css/primitives/code/types.ts +2 -1
  175. package/src/css/primitives/container/container.ts +3 -1
  176. package/src/css/primitives/heading/heading.ts +4 -1
  177. package/src/css/primitives/heading/types.ts +3 -1
  178. package/src/css/primitives/kbd/kbd.ts +1 -1
  179. package/src/css/primitives/kbd/types.ts +1 -1
  180. package/src/css/primitives/label/label.css.ts +1 -0
  181. package/src/css/primitives/label/label.ts +4 -1
  182. package/src/css/primitives/label/types.ts +3 -1
  183. package/src/css/primitives/switch/switch.css.ts +1 -1
  184. package/src/css/primitives/text/text.ts +6 -1
  185. package/src/css/primitives/text/types.ts +5 -2
  186. package/src/css/props/width/types.ts +1 -1
  187. package/src/css/props/width/width.css.ts +3 -0
  188. package/src/theme/v2/build/buildTheme.test.ts +8 -8
  189. package/src/theme/v2/build/buildTheme.ts +32 -7
  190. package/src/theme/v3/defaultFonts.ts +6 -6
  191. package/src/theme/v3/defaultTokens.ts +1 -1
  192. package/bin/sanity-ui.cjs +0 -5
  193. package/dist/ui.css +0 -1
  194. package/src/cli/buildCommand.ts +0 -10
  195. package/src/cli/index.ts +0 -26
  196. package/src/core/components/autocomplete/index.ts +0 -2
  197. package/src/core/components/index.ts +0 -9
  198. package/src/core/helpers/index.ts +0 -5
  199. package/src/core/hooks/index.ts +0 -13
  200. package/src/core/observers/index.ts +0 -2
  201. package/src/core/primitives/index.ts +0 -27
  202. package/src/core/types/avatar.ts +0 -16
  203. package/src/core/types/card.ts +0 -4
  204. package/src/core/types/index.ts +0 -15
  205. package/src/core/types/popover.ts +0 -4
  206. package/src/core/utils/index.ts +0 -8
  207. package/src/css/__theme/index.ts +0 -16
  208. package/src/css/__theme/lib/contract/buildVarContract.ts +0 -78
  209. package/src/css/__theme/lib/contract/index.ts +0 -4
  210. package/src/css/__theme/lib/contract/types.ts +0 -17
  211. package/src/css/__theme/resolveTheme.ts +0 -865
  212. package/src/css/components/index.ts +0 -6
  213. package/src/css/primitives/index.ts +0 -24
  214. package/src/css/props/index.ts +0 -37
  215. package/src/css/utils/srOnly/index.ts +0 -1
  216. /package/src/core/{global.ts → __DEV__.ts} +0 -0
  217. /package/src/core/{types/dialog.ts → components/dialog/types.ts} +0 -0
  218. /package/src/core/{utils → components}/virtualList/__workshop__/changingProps.tsx +0 -0
  219. /package/src/core/{utils → components}/virtualList/__workshop__/elementScroll.tsx +0 -0
  220. /package/src/core/{utils → components}/virtualList/__workshop__/infiniteList.tsx +0 -0
  221. /package/src/core/{utils → components}/virtualList/__workshop__/windowScrolll.tsx +0 -0
  222. /package/src/core/{utils → components}/virtualList/index.ts +0 -0
  223. /package/src/core/observers/{resizeObserver.ts → resize.ts} +0 -0
  224. /package/src/core/{utils → primitives}/arrow/cmds.ts +0 -0
  225. /package/src/core/{utils → primitives}/arrow/index.ts +0 -0
  226. /package/src/core/{types/badge.ts → primitives/badge/types2.ts} +0 -0
  227. /package/src/core/{types/box.ts → primitives/box/types.ts} +0 -0
  228. /package/src/core/{types/button.ts → primitives/button/types.ts} +0 -0
  229. /package/src/core/{types/flex.ts → primitives/flex/types.ts} +0 -0
  230. /package/src/core/{types/grid.ts → primitives/grid/types.ts} +0 -0
  231. /package/src/core/{utils → primitives}/layer/__workshop__/_debug.tsx +0 -0
  232. /package/src/core/{utils → primitives}/layer/__workshop__/multipleRoots.tsx +0 -0
  233. /package/src/core/{utils → primitives}/layer/__workshop__/nested.tsx +0 -0
  234. /package/src/core/{utils → primitives}/layer/__workshop__/responsiveZOffset.tsx +0 -0
  235. /package/src/core/{utils → primitives}/layer/getLayerContext.test.ts +0 -0
  236. /package/src/core/{utils → primitives}/layer/getLayerContext.ts +0 -0
  237. /package/src/core/{utils → primitives}/layer/index.ts +0 -0
  238. /package/src/core/{utils → primitives}/layer/layerContext.ts +0 -0
  239. /package/src/core/{utils → primitives}/layer/types.ts +0 -0
  240. /package/src/core/{utils → primitives}/layer/useLayer.ts +0 -0
  241. /package/src/core/{components → primitives}/skeleton/__workshop__/delay.tsx +0 -0
  242. /package/src/core/{components → primitives}/skeleton/__workshop__/skeleton.tsx +0 -0
  243. /package/src/core/{components → primitives}/skeleton/index.ts +0 -0
  244. /package/src/core/{utils → primitives}/srOnly/index.ts +0 -0
  245. /package/src/core/types/{text.ts → textAlign.ts} +0 -0
  246. /package/src/css/{utils → primitives/srOnly}/index.ts +0 -0
  247. /package/src/css/{utils → primitives}/srOnly/srOnly.css.ts +0 -0
  248. /package/src/css/{utils → primitives}/srOnly/srOnly.ts +0 -0
@@ -1,17 +1,16 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { c } from "react-compiler-runtime";
2
+ import { c } from "react/compiler-runtime";
3
3
  import { getScopedTheme, getTheme_v2 } from "@sanity/ui/theme";
4
- import { createContext, useContext, useEffect, useDebugValue, useState, useSyncExternalStore, isValidElement, lazy, Suspense, useImperativeHandle, useRef, useMemo, useCallback, cloneElement, useId, useLayoutEffect, Children } from "react";
4
+ import { createContext, useContext, useState, isValidElement, useDebugValue, useSyncExternalStore, useRef, useImperativeHandle, useEffect, useMemo, useCallback, cloneElement, Children, useId, useLayoutEffect } from "react";
5
5
  import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1 } from "styled-components";
6
- import { BREAKPOINTS, box, text, textOverflow, animatedSpinnerIcon, spinner, button, buttonLoadingBox, card, code, kbd, _arrow, vars, _arrowSvg, _arrowStrokeMask, _arrowStroke, _arrowShape, popoverCard, popover, stack, textInput, textInputPrefix, textInputElement, _inputElement, _inputPresentation, textInputSuffix, tooltip, menu, menuDivider, _selectable } from "@sanity/ui/css";
7
- import { ResizeObserver } from "@juggle/resize-observer";
6
+ import { box, text, textOverflow, animatedSpinnerIcon, spinner, button, buttonLoadingBox, card, BREAKPOINTS, _arrow, vars, _arrowSvg, _arrowStrokeMask, _arrowStroke, _arrowShape, popoverCard, popover, stack, textInput, textInputPrefix, textInputElement, _inputElement, _inputPresentation, textInputSuffix, kbd, menu, menuDivider, _selectable, tooltip } from "@sanity/ui/css";
8
7
  import { useEffectEvent } from "use-effect-event";
9
8
  import { SpinnerIcon, CloseIcon, ChevronRightIcon } from "@sanity/icons";
10
9
  import { isValidElementType } from "react-is";
11
10
  import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from "@floating-ui/react-dom";
12
11
  import { motion, AnimatePresence } from "framer-motion";
13
- import { assignInlineVars } from "@vanilla-extract/dynamic";
14
12
  import { createPortal } from "react-dom";
13
+ import { assignInlineVars } from "@vanilla-extract/dynamic";
15
14
  function getGlobalScope() {
16
15
  if (typeof globalThis < "u") return globalThis;
17
16
  if (typeof window < "u") return window;
@@ -174,188 +173,6 @@ function _getArrayProp(val, defaultVal) {
174
173
  function _getResponsiveProp(val, defaultVal) {
175
174
  return val === void 0 ? defaultVal || EMPTY_ARRAY : isArray(val) || isRecord(val) ? val : [val];
176
175
  }
177
- function useClickOutsideEvent(listener, t0, boundaryElement) {
178
- const $ = c(9), elementsArg = t0 === void 0 ? _temp$5 : t0;
179
- let t1;
180
- $[0] !== boundaryElement || $[1] !== elementsArg || $[2] !== listener ? (t1 = (evt) => {
181
- if (!listener)
182
- return;
183
- const target = evt.target;
184
- if (!(target instanceof Node))
185
- return;
186
- const resolvedBoundaryElement = boundaryElement?.();
187
- if (resolvedBoundaryElement && !resolvedBoundaryElement.contains(target))
188
- return;
189
- const elements = elementsArg().flat();
190
- for (const el of elements)
191
- if (el && (target === el || el.contains(target)))
192
- return;
193
- listener(evt);
194
- }, $[0] = boundaryElement, $[1] = elementsArg, $[2] = listener, $[3] = t1) : t1 = $[3];
195
- const onEvent = useEffectEvent(t1), hasListener = !!listener;
196
- let t2;
197
- $[4] !== hasListener || $[5] !== onEvent ? (t2 = () => {
198
- if (!hasListener)
199
- return;
200
- const handleEvent = (evt_0) => onEvent(evt_0);
201
- return document.addEventListener("mousedown", handleEvent), () => {
202
- document.removeEventListener("mousedown", handleEvent);
203
- };
204
- }, $[4] = hasListener, $[5] = onEvent, $[6] = t2) : t2 = $[6];
205
- let t3;
206
- $[7] !== hasListener ? (t3 = [hasListener], $[7] = hasListener, $[8] = t3) : t3 = $[8], useEffect(t2, t3), useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
207
- }
208
- function _temp$5() {
209
- return EMPTY_ARRAY;
210
- }
211
- function useCustomValidity(ref, customValidity) {
212
- const $ = c(6);
213
- let t0;
214
- $[0] !== customValidity || $[1] !== ref.current ? (t0 = () => {
215
- ref.current?.setCustomValidity(customValidity || "");
216
- }, $[0] = customValidity, $[1] = ref.current, $[2] = t0) : t0 = $[2];
217
- let t1;
218
- $[3] !== customValidity || $[4] !== ref ? (t1 = [customValidity, ref], $[3] = customValidity, $[4] = ref, $[5] = t1) : t1 = $[5], useEffect(t0, t1);
219
- }
220
- const _ResizeObserver = typeof document < "u" && typeof window < "u" && window.ResizeObserver ? window.ResizeObserver : ResizeObserver, _elementSizeObserver = _createElementSizeObserver();
221
- function _createElementRectValueListener() {
222
- return {
223
- subscribe(element, subscriber) {
224
- const resizeObserver = new _ResizeObserver(([entry]) => {
225
- subscriber({
226
- _contentRect: entry.contentRect,
227
- border: {
228
- width: entry.borderBoxSize[0].inlineSize,
229
- height: entry.borderBoxSize[0].blockSize
230
- },
231
- content: {
232
- width: entry.contentRect.width,
233
- height: entry.contentRect.height
234
- }
235
- });
236
- });
237
- return resizeObserver.observe(element), () => {
238
- resizeObserver.unobserve(element), resizeObserver.disconnect();
239
- };
240
- }
241
- };
242
- }
243
- function _createElementSizeObserver() {
244
- const disposeCache = /* @__PURE__ */ new WeakMap(), subscribersCache = /* @__PURE__ */ new WeakMap();
245
- return {
246
- subscribe(element, subscriber) {
247
- const subscribers = subscribersCache.get(element) || [];
248
- let dispose = disposeCache.get(element);
249
- return subscribersCache.has(element) || (subscribersCache.set(element, subscribers), dispose = _createElementRectValueListener().subscribe(element, (elementRect) => {
250
- for (const sub of subscribers)
251
- sub(elementRect);
252
- })), subscribers.push(subscriber), () => {
253
- const idx = subscribers.indexOf(subscriber);
254
- idx > -1 && subscribers.splice(idx, 1), subscribers.length === 0 && dispose && dispose();
255
- };
256
- }
257
- };
258
- }
259
- function useElementSize(element) {
260
- const $ = c(3), [size2, setSize] = useState(null);
261
- let t0, t1;
262
- return $[0] !== element ? (t0 = () => {
263
- if (element)
264
- return _elementSizeObserver.subscribe(element, setSize);
265
- }, t1 = [element], $[0] = element, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), useEffect(t0, t1), size2;
266
- }
267
- function useGlobalKeyDown(onKeyDown) {
268
- const $ = c(5);
269
- let t0;
270
- $[0] !== onKeyDown ? (t0 = (event) => onKeyDown(event), $[0] = onKeyDown, $[1] = t0) : t0 = $[1];
271
- const handleKeyDown = useEffectEvent(t0);
272
- let t1;
273
- $[2] !== handleKeyDown ? (t1 = () => {
274
- const handler = (event_0) => handleKeyDown(event_0);
275
- return window.addEventListener("keydown", handler), () => window.removeEventListener("keydown", handler);
276
- }, $[2] = handleKeyDown, $[3] = t1) : t1 = $[3];
277
- let t2;
278
- $[4] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[4] = t2) : t2 = $[4], useEffect(t1, t2);
279
- }
280
- function useMatchMedia(mediaQueryString, getServerSnapshot2) {
281
- const $ = c(4);
282
- useDebugValue(mediaQueryString);
283
- let t0;
284
- $[0] !== mediaQueryString ? (t0 = (onStoreChange) => {
285
- const media2 = window.matchMedia(mediaQueryString);
286
- return media2.addEventListener("change", onStoreChange), () => media2.removeEventListener("change", onStoreChange);
287
- }, $[0] = mediaQueryString, $[1] = t0) : t0 = $[1];
288
- let t1;
289
- return $[2] !== mediaQueryString ? (t1 = () => window.matchMedia(mediaQueryString).matches, $[2] = mediaQueryString, $[3] = t1) : t1 = $[3], useSyncExternalStore(t0, t1, getServerSnapshot2);
290
- }
291
- const media = Object.values(BREAKPOINTS);
292
- function _getMediaQuery(media2, index) {
293
- return index === 0 ? `screen and (max-width: ${media2[index + 1] - 1}px)` : index === media2.length - 1 ? `screen and (min-width: ${media2[index]}px)` : `screen and (min-width: ${media2[index]}px) and (max-width: ${media2[index + 1] - 1}px)`;
294
- }
295
- function _createMediaStore() {
296
- const mediaLen = media.length;
297
- let sizes;
298
- const getSizes = () => {
299
- if (!sizes) {
300
- sizes = [];
301
- for (let index = mediaLen; index > -1; index -= 1) {
302
- const mediaQuery = _getMediaQuery(media, index);
303
- sizes.push({
304
- index,
305
- mq: window.matchMedia(mediaQuery)
306
- });
307
- }
308
- }
309
- return sizes;
310
- };
311
- return {
312
- getSnapshot: () => {
313
- for (const {
314
- index,
315
- mq
316
- } of getSizes())
317
- if (mq.matches) return index;
318
- return 0;
319
- },
320
- subscribe: (onStoreChange) => {
321
- const disposeFns = [];
322
- for (const {
323
- mq
324
- } of getSizes()) {
325
- const handleChange = () => {
326
- mq.matches && onStoreChange();
327
- };
328
- mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
329
- }
330
- return () => {
331
- for (const disposeFn of disposeFns)
332
- disposeFn();
333
- };
334
- }
335
- };
336
- }
337
- function getServerSnapshot() {
338
- return 0;
339
- }
340
- function useMediaIndex() {
341
- const $ = c(1);
342
- let t0, t1;
343
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = _createMediaStore(), $[0] = t1) : t1 = $[0], t0 = t1;
344
- const store = t0;
345
- return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
346
- }
347
- function usePrefersDark(t0) {
348
- return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp$4 : t0);
349
- }
350
- function _temp$4() {
351
- return !1;
352
- }
353
- function usePrefersReducedMotion(t0) {
354
- return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$3 : t0);
355
- }
356
- function _temp$3() {
357
- return !1;
358
- }
359
176
  function useResponsiveProp(val, defaultVal) {
360
177
  const $ = c(3);
361
178
  let t0;
@@ -525,8 +342,8 @@ function Box(props) {
525
342
  }
526
343
  const DEFAULT_TEXT_ELEMENT = "div";
527
344
  function Text(props) {
528
- const $ = c(30), t0 = props;
529
- let accent, align, children, className, flex, muted, rest, t1, t2, t3, textOverflowProp;
345
+ const $ = c(32), t0 = props;
346
+ let accent, align, children, className, flex, muted, rest, t1, t2, t3, t4, textOverflowProp;
530
347
  $[0] !== t0 ? ({
531
348
  accent,
532
349
  align,
@@ -534,31 +351,33 @@ function Text(props) {
534
351
  children,
535
352
  className,
536
353
  flex,
354
+ maxWidth: t2,
537
355
  muted,
538
- size: t2,
356
+ size: t3,
539
357
  textOverflow: textOverflowProp,
540
- weight: t3,
358
+ weight: t4,
541
359
  ...rest
542
- } = t0, $[0] = t0, $[1] = accent, $[2] = align, $[3] = children, $[4] = className, $[5] = flex, $[6] = muted, $[7] = rest, $[8] = t1, $[9] = t2, $[10] = t3, $[11] = textOverflowProp) : (accent = $[1], align = $[2], children = $[3], className = $[4], flex = $[5], muted = $[6], rest = $[7], t1 = $[8], t2 = $[9], t3 = $[10], textOverflowProp = $[11]);
543
- const Element = t1 === void 0 ? DEFAULT_TEXT_ELEMENT : t1, size2 = t2 === void 0 ? 2 : t2, weight = t3 === void 0 ? "regular" : t3;
544
- let t4;
545
- $[12] !== accent || $[13] !== align || $[14] !== className || $[15] !== flex || $[16] !== muted || $[17] !== size2 || $[18] !== weight ? (t4 = text({
360
+ } = t0, $[0] = t0, $[1] = accent, $[2] = align, $[3] = children, $[4] = className, $[5] = flex, $[6] = muted, $[7] = rest, $[8] = t1, $[9] = t2, $[10] = t3, $[11] = t4, $[12] = textOverflowProp) : (accent = $[1], align = $[2], children = $[3], className = $[4], flex = $[5], muted = $[6], rest = $[7], t1 = $[8], t2 = $[9], t3 = $[10], t4 = $[11], textOverflowProp = $[12]);
361
+ const Element = t1 === void 0 ? DEFAULT_TEXT_ELEMENT : t1, maxWidth = t2 === void 0 ? "fill" : t2, size2 = t3 === void 0 ? 2 : t3, weight = t4 === void 0 ? "regular" : t4;
362
+ let t5;
363
+ $[13] !== accent || $[14] !== align || $[15] !== className || $[16] !== flex || $[17] !== maxWidth || $[18] !== muted || $[19] !== size2 || $[20] !== weight ? (t5 = text({
546
364
  className,
547
365
  accent,
548
366
  align,
549
367
  flex,
368
+ maxWidth,
550
369
  muted,
551
370
  size: size2,
552
371
  weight
553
- }), $[12] = accent, $[13] = align, $[14] = className, $[15] = flex, $[16] = muted, $[17] = size2, $[18] = weight, $[19] = t4) : t4 = $[19];
554
- let t5;
555
- $[20] !== textOverflowProp ? (t5 = textOverflow({
556
- textOverflow: textOverflowProp
557
- }), $[20] = textOverflowProp, $[21] = t5) : t5 = $[21];
372
+ }), $[13] = accent, $[14] = align, $[15] = className, $[16] = flex, $[17] = maxWidth, $[18] = muted, $[19] = size2, $[20] = weight, $[21] = t5) : t5 = $[21];
558
373
  let t6;
559
- $[22] !== children || $[23] !== t5 ? (t6 = /* @__PURE__ */ jsx("span", { className: t5, children }), $[22] = children, $[23] = t5, $[24] = t6) : t6 = $[24];
374
+ $[22] !== textOverflowProp ? (t6 = textOverflow({
375
+ textOverflow: textOverflowProp
376
+ }), $[22] = textOverflowProp, $[23] = t6) : t6 = $[23];
560
377
  let t7;
561
- return $[25] !== Element || $[26] !== rest || $[27] !== t4 || $[28] !== t6 ? (t7 = /* @__PURE__ */ jsx(Element, { "data-ui": "Text", ...rest, className: t4, children: t6 }), $[25] = Element, $[26] = rest, $[27] = t4, $[28] = t6, $[29] = t7) : t7 = $[29], t7;
378
+ $[24] !== children || $[25] !== t6 ? (t7 = /* @__PURE__ */ jsx("span", { className: t6, children }), $[24] = children, $[25] = t6, $[26] = t7) : t7 = $[26];
379
+ let t8;
380
+ return $[27] !== Element || $[28] !== rest || $[29] !== t5 || $[30] !== t7 ? (t8 = /* @__PURE__ */ jsx(Element, { "data-ui": "Text", ...rest, className: t5, children: t7 }), $[27] = Element, $[28] = rest, $[29] = t5, $[30] = t7, $[31] = t8) : t8 = $[31], t8;
562
381
  }
563
382
  function AnimatedSpinnerIcon(props) {
564
383
  const $ = c(5);
@@ -598,7 +417,6 @@ function Button(props) {
598
417
  children,
599
418
  className,
600
419
  disabled,
601
- display = "inline-flex",
602
420
  flex,
603
421
  fontSize = 1,
604
422
  gap = props.space ?? props.padding ?? 3,
@@ -638,7 +456,6 @@ function Button(props) {
638
456
  ...rest,
639
457
  className: button({
640
458
  className,
641
- display,
642
459
  flex,
643
460
  mode,
644
461
  radius,
@@ -657,7 +474,7 @@ function Button(props) {
657
474
  isValidElement(IconComponent) && IconComponent,
658
475
  isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})
659
476
  ] }),
660
- text2 && /* @__PURE__ */ jsx(Text, { align: textAlign, as: "span", flex: "none", muted, size: fontSize, textOverflow: textOverflow2, weight: textWeight, children: text2 }),
477
+ text2 && /* @__PURE__ */ jsx(Box, { as: "span", maxWidth: "auto", children: /* @__PURE__ */ jsx(Text, { align: textAlign, as: "span", muted, size: fontSize, textOverflow: textOverflow2, weight: textWeight, children: text2 }) }),
661
478
  IconRightComponent && /* @__PURE__ */ jsxs(Text, { as: "span", flex: "none", muted: !0, size: fontSize, children: [
662
479
  isValidElement(IconRightComponent) && IconRightComponent,
663
480
  isValidElementType(IconRightComponent) && /* @__PURE__ */ jsx(IconRightComponent, {})
@@ -711,88 +528,22 @@ function Card(props) {
711
528
  }
712
529
  return node;
713
530
  }
714
- const LazyRefractor = lazy(() => import("./refractor.js")), DEFAULT_CODE_ELEMENT = "pre";
715
- function Code(props) {
716
- const $ = c(25), t0 = props;
717
- let children, className, languageProp, rest, t1, t2, t3;
718
- $[0] !== t0 ? ({
719
- as: t1,
720
- children,
721
- className,
722
- language: languageProp,
723
- size: t2,
724
- weight: t3,
725
- ...rest
726
- } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = languageProp, $[4] = rest, $[5] = t1, $[6] = t2, $[7] = t3) : (children = $[1], className = $[2], languageProp = $[3], rest = $[4], t1 = $[5], t2 = $[6], t3 = $[7]);
727
- const Element = t1 === void 0 ? DEFAULT_CODE_ELEMENT : t1, size2 = t2 === void 0 ? 2 : t2, weight = t3 === void 0 ? "regular" : t3, language = typeof languageProp == "string" ? languageProp : void 0;
728
- let t4;
729
- $[8] !== className || $[9] !== size2 || $[10] !== weight ? (t4 = code({
730
- className,
731
- size: size2,
732
- weight
733
- }), $[8] = className, $[9] = size2, $[10] = weight, $[11] = t4) : t4 = $[11];
734
- let t5;
735
- $[12] !== children ? (t5 = /* @__PURE__ */ jsx("code", { children }), $[12] = children, $[13] = t5) : t5 = $[13];
736
- let t6;
737
- $[14] !== children || $[15] !== language ? (t6 = /* @__PURE__ */ jsx(LazyRefractor, { language, value: children }), $[14] = children, $[15] = language, $[16] = t6) : t6 = $[16];
738
- let t7;
739
- $[17] !== t5 || $[18] !== t6 ? (t7 = /* @__PURE__ */ jsx(Suspense, { fallback: t5, children: t6 }), $[17] = t5, $[18] = t6, $[19] = t7) : t7 = $[19];
740
- let t8;
741
- return $[20] !== Element || $[21] !== rest || $[22] !== t4 || $[23] !== t7 ? (t8 = /* @__PURE__ */ jsx(Element, { "data-ui": "Code", ...rest, className: t4, children: t7 }), $[20] = Element, $[21] = rest, $[22] = t4, $[23] = t7, $[24] = t8) : t8 = $[24], t8;
742
- }
743
- const DEFAULT_FLEX_ELEMENT = "div";
744
- function Flex(props) {
745
- const $ = c(14), t0 = props;
746
- let align, justify, rest, t1, t2, wrap;
747
- $[0] !== t0 ? ({
748
- align,
749
- as: t1,
750
- direction: t2,
751
- justify,
752
- wrap,
753
- ...rest
754
- } = t0, $[0] = t0, $[1] = align, $[2] = justify, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = wrap) : (align = $[1], justify = $[2], rest = $[3], t1 = $[4], t2 = $[5], wrap = $[6]);
755
- const as = t1 === void 0 ? DEFAULT_FLEX_ELEMENT : t1, direction = t2 === void 0 ? "row" : t2;
756
- let t3;
757
- return $[7] !== align || $[8] !== as || $[9] !== direction || $[10] !== justify || $[11] !== rest || $[12] !== wrap ? (t3 = /* @__PURE__ */ jsx(Box, { "data-ui": "Flex", ...rest, alignItems: align, as, display: "flex", flexDirection: direction, flexWrap: wrap, justifyContent: justify }), $[7] = align, $[8] = as, $[9] = direction, $[10] = justify, $[11] = rest, $[12] = wrap, $[13] = t3) : t3 = $[13], t3;
531
+ function useMatchMedia(mediaQueryString, getServerSnapshot2) {
532
+ const $ = c(4);
533
+ useDebugValue(mediaQueryString);
534
+ let t0;
535
+ $[0] !== mediaQueryString ? (t0 = (onStoreChange) => {
536
+ const media2 = window.matchMedia(mediaQueryString);
537
+ return media2.addEventListener("change", onStoreChange), () => media2.removeEventListener("change", onStoreChange);
538
+ }, $[0] = mediaQueryString, $[1] = t0) : t0 = $[1];
539
+ let t1;
540
+ return $[2] !== mediaQueryString ? (t1 = () => window.matchMedia(mediaQueryString).matches, $[2] = mediaQueryString, $[3] = t1) : t1 = $[3], useSyncExternalStore(t0, t1, getServerSnapshot2);
758
541
  }
759
- const DEFAULT_GRID_ELEMENT = "div";
760
- function Grid(props) {
761
- const $ = c(8), t0 = props;
762
- let children, rest, t1;
763
- $[0] !== t0 ? ({
764
- as: t1,
765
- children,
766
- ...rest
767
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1) : (children = $[1], rest = $[2], t1 = $[3]);
768
- const as = t1 === void 0 ? DEFAULT_GRID_ELEMENT : t1;
769
- let t2;
770
- return $[4] !== as || $[5] !== children || $[6] !== rest ? (t2 = /* @__PURE__ */ jsx(Box, { "data-ui": "Grid", ...rest, as, display: "grid", children }), $[4] = as, $[5] = children, $[6] = rest, $[7] = t2) : t2 = $[7], t2;
542
+ function usePrefersReducedMotion(t0) {
543
+ return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$5 : t0);
771
544
  }
772
- const DEFAULT_KBD_ELEMENT = "kbd";
773
- function KBD(props) {
774
- const $ = c(22), t0 = props;
775
- let children, className, rest, t1, t2, t3, t4, t5;
776
- $[0] !== t0 ? ({
777
- as: t1,
778
- children,
779
- className,
780
- display: t2,
781
- fontSize: t3,
782
- padding: t4,
783
- radius: t5,
784
- ...rest
785
- } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = t3, $[7] = t4, $[8] = t5) : (children = $[1], className = $[2], rest = $[3], t1 = $[4], t2 = $[5], t3 = $[6], t4 = $[7], t5 = $[8]);
786
- const as = t1 === void 0 ? DEFAULT_KBD_ELEMENT : t1, display = t2 === void 0 ? "inline-block" : t2, fontSize = t3 === void 0 ? 0 : t3, padding = t4 === void 0 ? 1 : t4, radius = t5 === void 0 ? 2 : t5, t6 = as;
787
- let t7;
788
- $[9] !== className || $[10] !== radius ? (t7 = kbd({
789
- className,
790
- radius
791
- }), $[9] = className, $[10] = radius, $[11] = t7) : t7 = $[11];
792
- let t8;
793
- $[12] !== children || $[13] !== fontSize ? (t8 = /* @__PURE__ */ jsx(Text, { as: "span", muted: !0, size: fontSize, weight: "semibold", children }), $[12] = children, $[13] = fontSize, $[14] = t8) : t8 = $[14];
794
- let t9;
795
- return $[15] !== display || $[16] !== padding || $[17] !== rest || $[18] !== t6 || $[19] !== t7 || $[20] !== t8 ? (t9 = /* @__PURE__ */ jsx(Box, { "data-ui": "KBD", ...rest, as: t6, className: t7, display, muted: !0, padding, children: t8 }), $[15] = display, $[16] = padding, $[17] = rest, $[18] = t6, $[19] = t7, $[20] = t8, $[21] = t9) : t9 = $[21], t9;
545
+ function _temp$5() {
546
+ return !1;
796
547
  }
797
548
  const origin = {
798
549
  name: "@sanity/ui/origin",
@@ -825,170 +576,83 @@ const origin = {
825
576
  function clamp(num, min, max) {
826
577
  return Math.min(Math.max(num, min), max);
827
578
  }
828
- function moveTowardsLength(movingPoint, targetPoint, amount) {
829
- const width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
830
- return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
831
- }
832
- function moveTowardsFractional(movingPoint, targetPoint, fraction) {
833
- return {
834
- x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
835
- y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
836
- };
579
+ const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null), DEFAULT_VALUE = {
580
+ version: 0,
581
+ element: null
582
+ };
583
+ function useBoundaryElement() {
584
+ const value = useContext(BoundaryElementContext);
585
+ if (value && (!isRecord(value) || value.version !== 0))
586
+ throw new Error("useBoundaryElement(): the context value is not compatible");
587
+ return value || DEFAULT_VALUE;
837
588
  }
838
- function getRoundedCommands(points) {
839
- const len = points.length, cmds = [];
840
- for (let i = 0; i < len; i += 1) {
841
- const point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
842
- if (prevPoint && point.radius) {
843
- const curveStart = moveTowardsLength(point, prevPoint, point.radius), curveEnd = moveTowardsLength(point, nextPoint, point.radius), startControl = moveTowardsFractional(curveStart, point, 0.5), endControl = moveTowardsFractional(point, curveEnd, 0.5);
844
- cmds.push({
845
- type: "point",
846
- ...curveStart
847
- }), cmds.push({
848
- type: "curve",
849
- curveEnd,
850
- startControl,
851
- endControl
852
- });
853
- } else
854
- cmds.push({
855
- type: "point",
856
- ...point
857
- });
589
+ const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
590
+ globalScope[elementKey] = null;
591
+ const defaultContextValue = {
592
+ version: 0,
593
+ boundaryElement: null,
594
+ get element() {
595
+ return typeof document > "u" ? null : (globalScope[elementKey] || (globalScope[elementKey] = document.createElement("div"), globalScope[elementKey].setAttribute("data-portal", ""), document.body.appendChild(globalScope[elementKey])), globalScope[elementKey]);
858
596
  }
859
- return cmds;
597
+ }, PortalContext = createGlobalScopedContext(key, defaultContextValue);
598
+ function usePortal() {
599
+ const value = useContext(PortalContext);
600
+ if (!value)
601
+ throw new Error("usePortal(): missing context value");
602
+ if (!isRecord(value) || value.version !== 0)
603
+ throw new Error("usePortal(): the context value is not compatible");
604
+ return value;
860
605
  }
861
- function compileCommands(cmds) {
862
- return cmds.map((n, idx) => n.type === "point" ? `${idx === 0 ? "M" : "L"} ${n.x} ${n.y}` : n.type === "curve" ? `C ${n.startControl.x} ${n.startControl.y} ${n.endControl.x} ${n.endControl.y} ${n.curveEnd.x} ${n.curveEnd.y}` : "").join(" ");
606
+ function Portal(props) {
607
+ const $ = c(6), {
608
+ children,
609
+ __unstable_name: name
610
+ } = props, card2 = useCard(), portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
611
+ if (!portalElement)
612
+ return null;
613
+ const t0 = card2?.scheme || "light";
614
+ let t1;
615
+ $[0] !== children || $[1] !== t0 ? (t1 = /* @__PURE__ */ jsx(CardProvider, { tone: "transparent", scheme: t0, children }), $[0] = children, $[1] = t0, $[2] = t1) : t1 = $[2];
616
+ let t2;
617
+ return $[3] !== portalElement || $[4] !== t1 ? (t2 = createPortal(t1, portalElement), $[3] = portalElement, $[4] = t1, $[5] = t2) : t2 = $[5], t2;
863
618
  }
864
- const DEFAULT_ARROW_ELEMENT = "div";
865
- function Arrow(props) {
866
- const $ = c(34), t0 = props;
867
- let h, rest, style, t1, t2, w;
868
- $[0] !== t0 ? ({
869
- as: t1,
870
- width: w,
871
- height: h,
872
- radius: t2,
873
- style,
874
- ...rest
875
- } = t0, $[0] = t0, $[1] = h, $[2] = rest, $[3] = style, $[4] = t1, $[5] = t2, $[6] = w) : (h = $[1], rest = $[2], style = $[3], t1 = $[4], t2 = $[5], w = $[6]);
876
- const Element = t1 === void 0 ? DEFAULT_ARROW_ELEMENT : t1, radius = t2 === void 0 ? 0 : t2, center = w / 2;
619
+ function PortalProvider(props) {
620
+ const $ = c(7), {
621
+ boundaryElement,
622
+ children,
623
+ element,
624
+ __unstable_elements: elementsProp
625
+ } = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(emptySubscribe, _temp$4, _temp2$2);
626
+ let t0;
627
+ const t1 = boundaryElement || null, t2 = element || fallbackElement;
877
628
  let t3;
878
- const points = [{
879
- x: 0,
880
- y: 0
881
- }, {
882
- x: radius,
883
- y: 0,
884
- radius
885
- }, {
886
- x: center,
887
- y: h - 1,
888
- radius
889
- }, {
890
- x: w - radius,
891
- y: 0,
892
- radius
893
- }, {
894
- x: w,
895
- y: 0
896
- }], cmds = getRoundedCommands(points);
897
- t3 = compileCommands(cmds);
898
- const path = t3, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`;
629
+ $[0] !== elements || $[1] !== t1 || $[2] !== t2 ? (t3 = {
630
+ version: 0,
631
+ boundaryElement: t1,
632
+ element: t2,
633
+ elements
634
+ }, $[0] = elements, $[1] = t1, $[2] = t2, $[3] = t3) : t3 = $[3], t0 = t3;
635
+ const value = t0;
899
636
  let t4;
900
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = _arrow(), $[7] = t4) : t4 = $[7];
901
- const t5 = `${w}px`;
902
- let t6;
903
- $[8] !== t5 ? (t6 = assignInlineVars({
904
- [vars.arrow.size]: t5
905
- }), $[8] = t5, $[9] = t6) : t6 = $[9];
906
- let t7;
907
- $[10] !== style || $[11] !== t6 ? (t7 = {
908
- ...style,
909
- ...t6
910
- }, $[10] = style, $[11] = t6, $[12] = t7) : t7 = $[12];
911
- let t8;
912
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = _arrowSvg(), $[13] = t8) : t8 = $[13];
913
- const t9 = `0 0 ${w} ${w}`;
914
- let t10;
915
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t10 = _arrowStrokeMask(), $[14] = t10) : t10 = $[14];
916
- let t11;
917
- $[15] !== w ? (t11 = /* @__PURE__ */ jsx("mask", { id: "stroke-mask", children: /* @__PURE__ */ jsx("rect", { className: t10, x: 0, width: w, height: w, fill: "white" }) }), $[15] = w, $[16] = t11) : t11 = $[16];
918
- let t12;
919
- $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = _arrowStroke(), $[17] = t12) : t12 = $[17];
920
- let t13;
921
- $[18] !== strokePath ? (t13 = /* @__PURE__ */ jsx("path", { className: t12, d: strokePath, mask: "url(#stroke-mask)" }), $[18] = strokePath, $[19] = t13) : t13 = $[19];
922
- let t14;
923
- $[20] === Symbol.for("react.memo_cache_sentinel") ? (t14 = _arrowShape(), $[20] = t14) : t14 = $[20];
924
- let t15;
925
- $[21] !== fillPath ? (t15 = /* @__PURE__ */ jsx("path", { className: t14, d: fillPath }), $[21] = fillPath, $[22] = t15) : t15 = $[22];
926
- let t16;
927
- $[23] !== t11 || $[24] !== t13 || $[25] !== t15 || $[26] !== t9 || $[27] !== w ? (t16 = /* @__PURE__ */ jsxs("svg", { className: t8, width: w, height: w, viewBox: t9, children: [
928
- t11,
929
- t13,
930
- t15
931
- ] }), $[23] = t11, $[24] = t13, $[25] = t15, $[26] = t9, $[27] = w, $[28] = t16) : t16 = $[28];
932
- let t17;
933
- return $[29] !== Element || $[30] !== rest || $[31] !== t16 || $[32] !== t7 ? (t17 = /* @__PURE__ */ jsx(Element, { ...rest, className: t4, style: t7, children: t16 }), $[29] = Element, $[30] = rest, $[31] = t16, $[32] = t7, $[33] = t17) : t17 = $[33], t17;
637
+ return $[4] !== children || $[5] !== value ? (t4 = /* @__PURE__ */ jsx(PortalContext.Provider, { value, children }), $[4] = children, $[5] = value, $[6] = t4) : t4 = $[6], t4;
934
638
  }
935
- const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null), DEFAULT_VALUE = {
936
- version: 0,
937
- element: null
938
- };
939
- function useBoundaryElement() {
940
- const value = useContext(BoundaryElementContext);
941
- if (value && (!isRecord(value) || value.version !== 0))
942
- throw new Error("useBoundaryElement(): the context value is not compatible");
943
- return value || DEFAULT_VALUE;
639
+ function _temp2$2() {
640
+ return null;
944
641
  }
945
- function findMaxBreakpoints(media2, width) {
946
- const ret = [];
947
- for (let i = 0; i < media2.length; i += 1)
948
- media2[i] > width && ret.push(i);
949
- return ret;
642
+ function _temp$4() {
643
+ return document.body;
950
644
  }
951
- function findMinBreakpoints(media2, width) {
952
- const ret = [];
953
- for (let i = 0; i < media2.length; i += 1)
954
- media2[i] <= width && ret.push(i);
955
- return ret;
645
+ const emptySubscribe = () => () => {
646
+ };
647
+ function useUnique(value) {
648
+ const valueRef = useRef(value);
649
+ return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
956
650
  }
957
- const DEFAULT_ELEMENT_QUERY_ELEMENT = "div", DEFAULT_BREAKPOINTS = Object.values(BREAKPOINTS);
958
- function ElementQuery(props) {
959
- const $ = c(21), t0 = props;
960
- let children, forwardedRef, mediaProp, rest, t1;
961
- $[0] !== t0 ? ({
962
- as: t1,
963
- children,
964
- media: mediaProp,
965
- ref: forwardedRef,
966
- ...rest
967
- } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = mediaProp, $[4] = rest, $[5] = t1) : (children = $[1], forwardedRef = $[2], mediaProp = $[3], rest = $[4], t1 = $[5]);
968
- const Element = t1 === void 0 ? DEFAULT_ELEMENT_QUERY_ELEMENT : t1, breakpoints = mediaProp ?? DEFAULT_BREAKPOINTS, [element, setElement] = useState(null), elementSize = useElementSize(element);
969
- let t2;
970
- t2 = elementSize?.border.width ?? window.innerWidth;
971
- const width = t2;
972
- let t3, t4;
973
- if ($[6] !== breakpoints || $[7] !== width) {
974
- const eq = findMaxBreakpoints(breakpoints, width);
975
- t4 = eq.length ? eq.join(" ") : void 0, $[6] = breakpoints, $[7] = width, $[8] = t4;
976
- } else
977
- t4 = $[8];
978
- t3 = t4;
979
- const max = t3;
980
- let t5, t6;
981
- if ($[9] !== breakpoints || $[10] !== width) {
982
- const eq_0 = findMinBreakpoints(breakpoints, width);
983
- t6 = eq_0.length ? eq_0.join(" ") : void 0, $[9] = breakpoints, $[10] = width, $[11] = t6;
984
- } else
985
- t6 = $[11];
986
- t5 = t6;
987
- const min = t5;
988
- let t7, t8;
989
- $[12] !== element ? (t7 = () => element, t8 = [element], $[12] = element, $[13] = t7, $[14] = t8) : (t7 = $[13], t8 = $[14]), useImperativeHandle(forwardedRef, t7, t8);
990
- let t9;
991
- return $[15] !== Element || $[16] !== children || $[17] !== max || $[18] !== min || $[19] !== rest ? (t9 = /* @__PURE__ */ jsx(Element, { "data-ui": "ElementQuery", ...rest, "data-eq-max": max, "data-eq-min": min, ref: setElement, children }), $[15] = Element, $[16] = children, $[17] = max, $[18] = min, $[19] = rest, $[20] = t9) : t9 = $[20], t9;
651
+ function _isEqual(objA, objB) {
652
+ if (!objA || !objB)
653
+ return objA === objB;
654
+ const keysA = Object.keys(objA), keysB = Object.keys(objB);
655
+ return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
992
656
  }
993
657
  function getLayerContext(contextValue) {
994
658
  if (!isRecord(contextValue) || contextValue.version !== 0)
@@ -1053,6 +717,62 @@ function LayerCard(props) {
1053
717
  let t10;
1054
718
  return $[20] !== children || $[21] !== handleFocus || $[22] !== position || $[23] !== rest || $[24] !== t8 || $[25] !== t9 ? (t10 = /* @__PURE__ */ jsx(Card, { "data-ui": "Layer", ...rest, as: t8, onFocus: handleFocus, position, ref, style: t9, children }), $[20] = children, $[21] = handleFocus, $[22] = position, $[23] = rest, $[24] = t8, $[25] = t9, $[26] = t10) : t10 = $[26], t10;
1055
719
  }
720
+ const media = Object.values(BREAKPOINTS);
721
+ function _getMediaQuery(media2, index) {
722
+ return index === 0 ? `screen and (max-width: ${media2[index + 1] - 1}px)` : index === media2.length - 1 ? `screen and (min-width: ${media2[index]}px)` : `screen and (min-width: ${media2[index]}px) and (max-width: ${media2[index + 1] - 1}px)`;
723
+ }
724
+ function _createMediaStore() {
725
+ const mediaLen = media.length;
726
+ let sizes;
727
+ const getSizes = () => {
728
+ if (!sizes) {
729
+ sizes = [];
730
+ for (let index = mediaLen; index > -1; index -= 1) {
731
+ const mediaQuery = _getMediaQuery(media, index);
732
+ sizes.push({
733
+ index,
734
+ mq: window.matchMedia(mediaQuery)
735
+ });
736
+ }
737
+ }
738
+ return sizes;
739
+ };
740
+ return {
741
+ getSnapshot: () => {
742
+ for (const {
743
+ index,
744
+ mq
745
+ } of getSizes())
746
+ if (mq.matches) return index;
747
+ return 0;
748
+ },
749
+ subscribe: (onStoreChange) => {
750
+ const disposeFns = [];
751
+ for (const {
752
+ mq
753
+ } of getSizes()) {
754
+ const handleChange = () => {
755
+ mq.matches && onStoreChange();
756
+ };
757
+ mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
758
+ }
759
+ return () => {
760
+ for (const disposeFn of disposeFns)
761
+ disposeFn();
762
+ };
763
+ }
764
+ };
765
+ }
766
+ function getServerSnapshot() {
767
+ return 0;
768
+ }
769
+ function useMediaIndex() {
770
+ const $ = c(1);
771
+ let t0, t1;
772
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = _createMediaStore(), $[0] = t1) : t1 = $[0], t0 = t1;
773
+ const store = t0;
774
+ return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
775
+ }
1056
776
  function LayerProvider(props) {
1057
777
  const $ = c(19), {
1058
778
  children,
@@ -1073,13 +793,13 @@ function LayerProvider(props) {
1073
793
  [childLevel]: prevLen + 1
1074
794
  };
1075
795
  return setSize(Object.keys(nextState).length), nextState;
1076
- }) : setSize(_temp$2), () => {
796
+ }) : setSize(_temp$3), () => {
1077
797
  childLevel !== void 0 ? setChildLayers((state_0) => {
1078
798
  const nextState_0 = {
1079
799
  ...state_0
1080
800
  };
1081
801
  return nextState_0[childLevel] === 1 ? (delete nextState_0[childLevel], setSize(Object.keys(nextState_0).length)) : nextState_0[childLevel] = nextState_0[childLevel] - 1, nextState_0;
1082
- }) : setSize(_temp2$2), parentDispose?.();
802
+ }) : setSize(_temp2$1), parentDispose?.();
1083
803
  };
1084
804
  }, $[3] = parentRegisterChild, $[4] = setChildLayers, $[5] = t3) : t3 = $[5];
1085
805
  const registerChild = t3;
@@ -1098,10 +818,10 @@ function LayerProvider(props) {
1098
818
  let t8;
1099
819
  return $[16] !== children || $[17] !== value ? (t8 = /* @__PURE__ */ jsx(LayerContext.Provider, { value, children }), $[16] = children, $[17] = value, $[18] = t8) : t8 = $[18], t8;
1100
820
  }
1101
- function _temp2$2(v_0) {
821
+ function _temp2$1(v_0) {
1102
822
  return v_0 - 1;
1103
823
  }
1104
- function _temp$2(v) {
824
+ function _temp$3(v) {
1105
825
  return v + 1;
1106
826
  }
1107
827
  const DEFAULT_LAYER_ELEMENT = "div";
@@ -1120,74 +840,6 @@ function Layer(props) {
1120
840
  let t4;
1121
841
  return $[9] !== t3 || $[10] !== zOffset ? (t4 = /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: t3 }), $[9] = t3, $[10] = zOffset, $[11] = t4) : t4 = $[11], t4;
1122
842
  }
1123
- const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
1124
- globalScope[elementKey] = null;
1125
- const defaultContextValue = {
1126
- version: 0,
1127
- boundaryElement: null,
1128
- get element() {
1129
- return typeof document > "u" ? null : (globalScope[elementKey] || (globalScope[elementKey] = document.createElement("div"), globalScope[elementKey].setAttribute("data-portal", ""), document.body.appendChild(globalScope[elementKey])), globalScope[elementKey]);
1130
- }
1131
- }, PortalContext = createGlobalScopedContext(key, defaultContextValue);
1132
- function usePortal() {
1133
- const value = useContext(PortalContext);
1134
- if (!value)
1135
- throw new Error("usePortal(): missing context value");
1136
- if (!isRecord(value) || value.version !== 0)
1137
- throw new Error("usePortal(): the context value is not compatible");
1138
- return value;
1139
- }
1140
- function Portal(props) {
1141
- const $ = c(6), {
1142
- children,
1143
- __unstable_name: name
1144
- } = props, card2 = useCard(), portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
1145
- if (!portalElement)
1146
- return null;
1147
- const t0 = card2?.scheme || "light";
1148
- let t1;
1149
- $[0] !== children || $[1] !== t0 ? (t1 = /* @__PURE__ */ jsx(CardProvider, { tone: "transparent", scheme: t0, children }), $[0] = children, $[1] = t0, $[2] = t1) : t1 = $[2];
1150
- let t2;
1151
- return $[3] !== portalElement || $[4] !== t1 ? (t2 = createPortal(t1, portalElement), $[3] = portalElement, $[4] = t1, $[5] = t2) : t2 = $[5], t2;
1152
- }
1153
- function PortalProvider(props) {
1154
- const $ = c(7), {
1155
- boundaryElement,
1156
- children,
1157
- element,
1158
- __unstable_elements: elementsProp
1159
- } = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(emptySubscribe, _temp$1, _temp2$1);
1160
- let t0;
1161
- const t1 = boundaryElement || null, t2 = element || fallbackElement;
1162
- let t3;
1163
- $[0] !== elements || $[1] !== t1 || $[2] !== t2 ? (t3 = {
1164
- version: 0,
1165
- boundaryElement: t1,
1166
- element: t2,
1167
- elements
1168
- }, $[0] = elements, $[1] = t1, $[2] = t2, $[3] = t3) : t3 = $[3], t0 = t3;
1169
- const value = t0;
1170
- let t4;
1171
- return $[4] !== children || $[5] !== value ? (t4 = /* @__PURE__ */ jsx(PortalContext.Provider, { value, children }), $[4] = children, $[5] = value, $[6] = t4) : t4 = $[6], t4;
1172
- }
1173
- function _temp2$1() {
1174
- return null;
1175
- }
1176
- function _temp$1() {
1177
- return document.body;
1178
- }
1179
- const emptySubscribe = () => () => {
1180
- };
1181
- function useUnique(value) {
1182
- const valueRef = useRef(value);
1183
- return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
1184
- }
1185
- function _isEqual(objA, objB) {
1186
- if (!objA || !objB)
1187
- return objA === objB;
1188
- const keysA = Object.keys(objA), keysB = Object.keys(objB);
1189
- return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
1190
- }
1191
843
  const DEFAULT_POPOVER_DISTANCE = 4, DEFAULT_POPOVER_PADDING = 4, DEFAULT_POPOVER_ARROW_WIDTH = 19, DEFAULT_POPOVER_ARROW_HEIGHT = 8, DEFAULT_POPOVER_ARROW_RADIUS = 2, DEFAULT_POPOVER_MARGINS = [0, 0, 0, 0], DEFAULT_FALLBACK_PLACEMENTS$1 = {
1192
844
  top: ["bottom", "left", "right"],
1193
845
  "top-start": ["bottom-start", "left-start", "right-start"],
@@ -1243,6 +895,129 @@ function size(options) {
1243
895
  }
1244
896
  };
1245
897
  }
898
+ function moveTowardsLength(movingPoint, targetPoint, amount) {
899
+ const width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
900
+ return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
901
+ }
902
+ function moveTowardsFractional(movingPoint, targetPoint, fraction) {
903
+ return {
904
+ x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
905
+ y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
906
+ };
907
+ }
908
+ function getRoundedCommands(points) {
909
+ const len = points.length, cmds = [];
910
+ for (let i = 0; i < len; i += 1) {
911
+ const point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
912
+ if (prevPoint && point.radius) {
913
+ const curveStart = moveTowardsLength(point, prevPoint, point.radius), curveEnd = moveTowardsLength(point, nextPoint, point.radius), startControl = moveTowardsFractional(curveStart, point, 0.5), endControl = moveTowardsFractional(point, curveEnd, 0.5);
914
+ cmds.push({
915
+ type: "point",
916
+ ...curveStart
917
+ }), cmds.push({
918
+ type: "curve",
919
+ curveEnd,
920
+ startControl,
921
+ endControl
922
+ });
923
+ } else
924
+ cmds.push({
925
+ type: "point",
926
+ ...point
927
+ });
928
+ }
929
+ return cmds;
930
+ }
931
+ function compileCommands(cmds) {
932
+ return cmds.map((n, idx) => n.type === "point" ? `${idx === 0 ? "M" : "L"} ${n.x} ${n.y}` : n.type === "curve" ? `C ${n.startControl.x} ${n.startControl.y} ${n.endControl.x} ${n.endControl.y} ${n.curveEnd.x} ${n.curveEnd.y}` : "").join(" ");
933
+ }
934
+ const DEFAULT_ARROW_ELEMENT = "div";
935
+ function Arrow(props) {
936
+ const $ = c(34), t0 = props;
937
+ let h, rest, style, t1, t2, w;
938
+ $[0] !== t0 ? ({
939
+ as: t1,
940
+ width: w,
941
+ height: h,
942
+ radius: t2,
943
+ style,
944
+ ...rest
945
+ } = t0, $[0] = t0, $[1] = h, $[2] = rest, $[3] = style, $[4] = t1, $[5] = t2, $[6] = w) : (h = $[1], rest = $[2], style = $[3], t1 = $[4], t2 = $[5], w = $[6]);
946
+ const Element = t1 === void 0 ? DEFAULT_ARROW_ELEMENT : t1, radius = t2 === void 0 ? 0 : t2, center = w / 2;
947
+ let t3;
948
+ const points = [{
949
+ x: 0,
950
+ y: 0
951
+ }, {
952
+ x: radius,
953
+ y: 0,
954
+ radius
955
+ }, {
956
+ x: center,
957
+ y: h - 1,
958
+ radius
959
+ }, {
960
+ x: w - radius,
961
+ y: 0,
962
+ radius
963
+ }, {
964
+ x: w,
965
+ y: 0
966
+ }], cmds = getRoundedCommands(points);
967
+ t3 = compileCommands(cmds);
968
+ const path = t3, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`;
969
+ let t4;
970
+ $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = _arrow(), $[7] = t4) : t4 = $[7];
971
+ const t5 = `${w}px`;
972
+ let t6;
973
+ $[8] !== t5 ? (t6 = assignInlineVars({
974
+ [vars.arrow.size]: t5
975
+ }), $[8] = t5, $[9] = t6) : t6 = $[9];
976
+ let t7;
977
+ $[10] !== style || $[11] !== t6 ? (t7 = {
978
+ ...style,
979
+ ...t6
980
+ }, $[10] = style, $[11] = t6, $[12] = t7) : t7 = $[12];
981
+ let t8;
982
+ $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = _arrowSvg(), $[13] = t8) : t8 = $[13];
983
+ const t9 = `0 0 ${w} ${w}`;
984
+ let t10;
985
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t10 = _arrowStrokeMask(), $[14] = t10) : t10 = $[14];
986
+ let t11;
987
+ $[15] !== w ? (t11 = /* @__PURE__ */ jsx("mask", { id: "stroke-mask", children: /* @__PURE__ */ jsx("rect", { className: t10, x: 0, width: w, height: w, fill: "white" }) }), $[15] = w, $[16] = t11) : t11 = $[16];
988
+ let t12;
989
+ $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = _arrowStroke(), $[17] = t12) : t12 = $[17];
990
+ let t13;
991
+ $[18] !== strokePath ? (t13 = /* @__PURE__ */ jsx("path", { className: t12, d: strokePath, mask: "url(#stroke-mask)" }), $[18] = strokePath, $[19] = t13) : t13 = $[19];
992
+ let t14;
993
+ $[20] === Symbol.for("react.memo_cache_sentinel") ? (t14 = _arrowShape(), $[20] = t14) : t14 = $[20];
994
+ let t15;
995
+ $[21] !== fillPath ? (t15 = /* @__PURE__ */ jsx("path", { className: t14, d: fillPath }), $[21] = fillPath, $[22] = t15) : t15 = $[22];
996
+ let t16;
997
+ $[23] !== t11 || $[24] !== t13 || $[25] !== t15 || $[26] !== t9 || $[27] !== w ? (t16 = /* @__PURE__ */ jsxs("svg", { className: t8, width: w, height: w, viewBox: t9, children: [
998
+ t11,
999
+ t13,
1000
+ t15
1001
+ ] }), $[23] = t11, $[24] = t13, $[25] = t15, $[26] = t9, $[27] = w, $[28] = t16) : t16 = $[28];
1002
+ let t17;
1003
+ return $[29] !== Element || $[30] !== rest || $[31] !== t16 || $[32] !== t7 ? (t17 = /* @__PURE__ */ jsx(Element, { ...rest, className: t4, style: t7, children: t16 }), $[29] = Element, $[30] = rest, $[31] = t16, $[32] = t7, $[33] = t17) : t17 = $[33], t17;
1004
+ }
1005
+ const DEFAULT_FLEX_ELEMENT = "div";
1006
+ function Flex(props) {
1007
+ const $ = c(14), t0 = props;
1008
+ let align, justify, rest, t1, t2, wrap;
1009
+ $[0] !== t0 ? ({
1010
+ align,
1011
+ as: t1,
1012
+ direction: t2,
1013
+ justify,
1014
+ wrap,
1015
+ ...rest
1016
+ } = t0, $[0] = t0, $[1] = align, $[2] = justify, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = wrap) : (align = $[1], justify = $[2], rest = $[3], t1 = $[4], t2 = $[5], wrap = $[6]);
1017
+ const as = t1 === void 0 ? DEFAULT_FLEX_ELEMENT : t1, direction = t2 === void 0 ? "row" : t2;
1018
+ let t3;
1019
+ return $[7] !== align || $[8] !== as || $[9] !== direction || $[10] !== justify || $[11] !== rest || $[12] !== wrap ? (t3 = /* @__PURE__ */ jsx(Box, { "data-ui": "Flex", ...rest, alignItems: align, as, display: "flex", flexDirection: direction, flexWrap: wrap, justifyContent: justify }), $[7] = align, $[8] = as, $[9] = direction, $[10] = justify, $[11] = rest, $[12] = wrap, $[13] = t3) : t3 = $[13], t3;
1020
+ }
1246
1021
  function PopoverLayer(props) {
1247
1022
  const $ = c(65);
1248
1023
  let animate, arrow2, arrowRef, arrowX, arrowY, children, marginsProp, maxWidth, originX, originY, overflow, padding, placement, radius, referenceWidth, rest, shadow, strategy, style, t0, xProp, yProp;
@@ -1467,6 +1242,15 @@ function Stack(props) {
1467
1242
  let t4;
1468
1243
  return $[8] !== as || $[9] !== rest || $[10] !== t2 || $[11] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, { "data-ui": "Stack", ...rest, as, gridAutoRows: "min", className: t2, display: "grid", gap: t3 }), $[8] = as, $[9] = rest, $[10] = t2, $[11] = t3, $[12] = t4) : t4 = $[12], t4;
1469
1244
  }
1245
+ function useCustomValidity(ref, customValidity) {
1246
+ const $ = c(6);
1247
+ let t0;
1248
+ $[0] !== customValidity || $[1] !== ref.current ? (t0 = () => {
1249
+ ref.current?.setCustomValidity(customValidity || "");
1250
+ }, $[0] = customValidity, $[1] = ref.current, $[2] = t0) : t0 = $[2];
1251
+ let t1;
1252
+ $[3] !== customValidity || $[4] !== ref ? (t1 = [customValidity, ref], $[3] = customValidity, $[4] = ref, $[5] = t1) : t1 = $[5], useEffect(t0, t1);
1253
+ }
1470
1254
  const DEFAULT_TEXT_INPUT_ELEMENT = "input";
1471
1255
  function TextInput(props) {
1472
1256
  const $ = c(89), t0 = props;
@@ -1503,7 +1287,7 @@ function TextInput(props) {
1503
1287
  const Element = t1 === void 0 ? DEFAULT_TEXT_INPUT_ELEMENT : t1, border = t2 === void 0 ? !0 : t2, disabled = t3 === void 0 ? !1 : t3, fontSize = t4 === void 0 ? 2 : t4, padding = t5 === void 0 ? 3 : t5, radius = t6 === void 0 ? 2 : t6, space = t7 === void 0 ? 3 : t7, type = t8 === void 0 ? "text" : t8, ref = useRef(null), responsivePadding = useResponsiveProp(padding), withClearButton = !!clearButton;
1504
1288
  let t9;
1505
1289
  $[23] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => ref.current, $[23] = t9) : t9 = $[23], useImperativeHandle(forwardedRef, t9), useCustomValidity(ref, customValidity);
1506
- const handleClearMouseDown = _temp;
1290
+ const handleClearMouseDown = _temp$2;
1507
1291
  let t10;
1508
1292
  $[24] !== onClear ? (t10 = (event_0) => {
1509
1293
  event_0.preventDefault(), event_0.stopPropagation(), onClear && onClear(), ref.current?.focus();
@@ -1582,254 +1366,80 @@ function _temp2(t0) {
1582
1366
  const [key2, value] = t0;
1583
1367
  return value === 0 ? [key2, 0] : value === 1 ? [key2, 1] : value === 2 ? [key2, 1] : [key2, typeof value == "number" ? value - 2 : 0];
1584
1368
  }
1585
- function _temp(event) {
1369
+ function _temp$2(event) {
1586
1370
  event.preventDefault(), event.stopPropagation();
1587
1371
  }
1588
- function useDelayedState(initialState) {
1589
- const $ = c(3), [state, setState] = useState(initialState), delayedAction = useRef(void 0);
1590
- let t0;
1591
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (nextState, delay) => {
1592
- const action = () => {
1593
- setState(nextState);
1594
- };
1595
- if (delayedAction.current && (clearTimeout(delayedAction.current), delayedAction.current = void 0), !delay)
1596
- return action();
1597
- delayedAction.current = setTimeout(action, delay);
1598
- }, $[0] = t0) : t0 = $[0];
1599
- const onStateChange = t0;
1372
+ function useClickOutsideEvent(listener, t0, boundaryElement) {
1373
+ const $ = c(9), elementsArg = t0 === void 0 ? _temp$1 : t0;
1600
1374
  let t1;
1601
- return $[1] !== state ? (t1 = [state, onStateChange], $[1] = state, $[2] = t1) : t1 = $[2], t1;
1375
+ $[0] !== boundaryElement || $[1] !== elementsArg || $[2] !== listener ? (t1 = (evt) => {
1376
+ if (!listener)
1377
+ return;
1378
+ const target = evt.target;
1379
+ if (!(target instanceof Node))
1380
+ return;
1381
+ const resolvedBoundaryElement = boundaryElement?.();
1382
+ if (resolvedBoundaryElement && !resolvedBoundaryElement.contains(target))
1383
+ return;
1384
+ const elements = elementsArg().flat();
1385
+ for (const el of elements)
1386
+ if (el && (target === el || el.contains(target)))
1387
+ return;
1388
+ listener(evt);
1389
+ }, $[0] = boundaryElement, $[1] = elementsArg, $[2] = listener, $[3] = t1) : t1 = $[3];
1390
+ const onEvent = useEffectEvent(t1), hasListener = !!listener;
1391
+ let t2;
1392
+ $[4] !== hasListener || $[5] !== onEvent ? (t2 = () => {
1393
+ if (!hasListener)
1394
+ return;
1395
+ const handleEvent = (evt_0) => onEvent(evt_0);
1396
+ return document.addEventListener("mousedown", handleEvent), () => {
1397
+ document.removeEventListener("mousedown", handleEvent);
1398
+ };
1399
+ }, $[4] = hasListener, $[5] = onEvent, $[6] = t2) : t2 = $[6];
1400
+ let t3;
1401
+ $[7] !== hasListener ? (t3 = [hasListener], $[7] = hasListener, $[8] = t3) : t3 = $[8], useEffect(t2, t3), useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
1602
1402
  }
1603
- function getElementRef(element) {
1604
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
1605
- return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
1403
+ function _temp$1() {
1404
+ return EMPTY_ARRAY;
1606
1405
  }
1607
- const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAULT_TOOLTIP_ARROW_RADIUS = 2, DEFAULT_TOOLTIP_DISTANCE = 4, DEFAULT_TOOLTIP_PADDING = 4, DEFAULT_FALLBACK_PLACEMENTS = {
1608
- top: ["top-end", "top-start", "bottom", "left", "right"],
1609
- "top-start": ["top", "top-end", "bottom-start", "left-start", "right-start"],
1610
- "top-end": ["top", "top-start", "bottom-end", "left-end", "right-end"],
1611
- bottom: ["bottom-end", "bottom-start", "top", "left", "right"],
1612
- "bottom-start": ["bottom", "bottom-end", "top-start", "left-start", "right-start"],
1613
- "bottom-end": ["bottom", "bottom-start", "top-end", "left-end", "right-end"],
1614
- left: ["left-end", "left-start", "right", "top", "bottom"],
1615
- "left-start": ["left", "left-end", "right-start", "top-start", "bottom-start"],
1616
- "left-end": ["left", "left-start", "right-end", "top-end", "bottom-end"],
1617
- right: ["right-end", "right-start", "left", "top", "bottom"],
1618
- "right-start": ["right", "right-end", "left-start", "top-start", "bottom-start"],
1619
- "right-end": ["right", "right-start", "left-end", "top-end", "bottom-end"]
1620
- }, TooltipDelayGroupContext = createGlobalScopedContext("@sanity/ui/context/tooltipDelayGroup", null);
1621
- function useTooltipDelayGroup() {
1622
- return useContext(TooltipDelayGroupContext);
1406
+ function useGlobalKeyDown(onKeyDown) {
1407
+ const $ = c(5);
1408
+ let t0;
1409
+ $[0] !== onKeyDown ? (t0 = (event) => onKeyDown(event), $[0] = onKeyDown, $[1] = t0) : t0 = $[1];
1410
+ const handleKeyDown = useEffectEvent(t0);
1411
+ let t1;
1412
+ $[2] !== handleKeyDown ? (t1 = () => {
1413
+ const handler = (event_0) => handleKeyDown(event_0);
1414
+ return window.addEventListener("keydown", handler), () => window.removeEventListener("keydown", handler);
1415
+ }, $[2] = handleKeyDown, $[3] = t1) : t1 = $[3];
1416
+ let t2;
1417
+ $[4] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[4] = t2) : t2 = $[4], useEffect(t1, t2);
1623
1418
  }
1624
- function TooltipLayer(props) {
1625
- const $ = c(50);
1626
- let animate, arrow2, arrowRef, arrowX, arrowY, children, originX, originY, padding, placement, radius, rest, scheme, shadow, style, t0;
1627
- $[0] !== props ? ({
1628
- animate,
1629
- arrow: arrow2,
1630
- arrowRef,
1631
- arrowX,
1632
- arrowY,
1419
+ const DEFAULT_KBD_ELEMENT = "kbd";
1420
+ function KBD(props) {
1421
+ const $ = c(22), t0 = props;
1422
+ let children, className, rest, t1, t2, t3, t4, t5;
1423
+ $[0] !== t0 ? ({
1424
+ as: t1,
1633
1425
  children,
1634
- originX,
1635
- originY,
1636
- padding,
1637
- placement,
1638
- radius,
1639
- scheme,
1640
- shadow,
1641
- style,
1642
- tone: t0,
1426
+ className,
1427
+ display: t2,
1428
+ fontSize: t3,
1429
+ padding: t4,
1430
+ radius: t5,
1643
1431
  ...rest
1644
- } = props, $[0] = props, $[1] = animate, $[2] = arrow2, $[3] = arrowRef, $[4] = arrowX, $[5] = arrowY, $[6] = children, $[7] = originX, $[8] = originY, $[9] = padding, $[10] = placement, $[11] = radius, $[12] = rest, $[13] = scheme, $[14] = shadow, $[15] = style, $[16] = t0) : (animate = $[1], arrow2 = $[2], arrowRef = $[3], arrowX = $[4], arrowY = $[5], children = $[6], originX = $[7], originY = $[8], padding = $[9], placement = $[10], radius = $[11], rest = $[12], scheme = $[13], shadow = $[14], style = $[15], t0 = $[16]);
1645
- const tone = t0 === void 0 ? "inherit" : t0;
1646
- let t1;
1647
- const t2 = animate ? "transform" : void 0;
1648
- let t3;
1649
- $[17] !== originX || $[18] !== originY || $[19] !== style || $[20] !== t2 ? (t3 = {
1650
- originX,
1651
- originY,
1652
- willChange: t2,
1653
- ...style
1654
- }, $[17] = originX, $[18] = originY, $[19] = style, $[20] = t2, $[21] = t3) : t3 = $[21], t1 = t3;
1655
- const rootStyle = t1;
1656
- let t4;
1657
- const t5 = arrowX !== null ? arrowX : void 0, t6 = arrowY !== null ? arrowY : void 0;
1432
+ } = t0, $[0] = t0, $[1] = children, $[2] = className, $[3] = rest, $[4] = t1, $[5] = t2, $[6] = t3, $[7] = t4, $[8] = t5) : (children = $[1], className = $[2], rest = $[3], t1 = $[4], t2 = $[5], t3 = $[6], t4 = $[7], t5 = $[8]);
1433
+ const as = t1 === void 0 ? DEFAULT_KBD_ELEMENT : t1, display = t2 === void 0 ? "inline-block" : t2, fontSize = t3 === void 0 ? 0 : t3, padding = t4 === void 0 ? 1 : t4, radius = t5 === void 0 ? 2 : t5, t6 = as;
1658
1434
  let t7;
1659
- $[22] !== t5 || $[23] !== t6 ? (t7 = {
1660
- left: t5,
1661
- top: t6,
1662
- right: void 0,
1663
- bottom: void 0
1664
- }, $[22] = t5, $[23] = t6, $[24] = t7) : t7 = $[24], t4 = t7;
1665
- const arrowStyle = t4, t8 = animate ? "" : void 0;
1666
- let t9;
1667
- $[25] !== animate ? (t9 = animate ? ["hidden", "initial"] : void 0, $[25] = animate, $[26] = t9) : t9 = $[26];
1668
- let t10;
1669
- $[27] !== animate ? (t10 = animate ? ["visible", "scaleIn"] : void 0, $[27] = animate, $[28] = t10) : t10 = $[28];
1670
- let t11;
1671
- $[29] !== animate ? (t11 = animate ? ["hidden", "scaleOut"] : void 0, $[29] = animate, $[30] = t11) : t11 = $[30];
1672
- let t12;
1673
- $[31] !== arrow2 || $[32] !== arrowRef || $[33] !== arrowStyle ? (t12 = arrow2 && /* @__PURE__ */ jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_TOOLTIP_ARROW_WIDTH, height: DEFAULT_TOOLTIP_ARROW_HEIGHT, radius: DEFAULT_TOOLTIP_ARROW_RADIUS }), $[31] = arrow2, $[32] = arrowRef, $[33] = arrowStyle, $[34] = t12) : t12 = $[34];
1674
- let t13;
1675
- return $[35] !== children || $[36] !== padding || $[37] !== placement || $[38] !== radius || $[39] !== rest || $[40] !== rootStyle || $[41] !== scheme || $[42] !== shadow || $[43] !== t10 || $[44] !== t11 || $[45] !== t12 || $[46] !== t8 || $[47] !== t9 || $[48] !== tone ? (t13 = /* @__PURE__ */ jsxs(Layer, { "data-ui": "Tooltip__layer", ...rest, as: motion.div, "data-animate": t8, "data-placement": placement, padding, radius, scheme, shadow, style: rootStyle, variants: POPOVER_MOTION_PROPS.card, transition: POPOVER_MOTION_PROPS.transition, initial: t9, animate: t10, exit: t11, tone, children: [
1676
- children,
1677
- t12
1678
- ] }), $[35] = children, $[36] = padding, $[37] = placement, $[38] = radius, $[39] = rest, $[40] = rootStyle, $[41] = scheme, $[42] = shadow, $[43] = t10, $[44] = t11, $[45] = t12, $[46] = t8, $[47] = t9, $[48] = tone, $[49] = t13) : t13 = $[49], t13;
1679
- }
1680
- const DEFAULT_TOOLTIP_ELEMENT = "div";
1681
- function Tooltip(props) {
1682
- const boundaryElementContext = useBoundaryElement(), {
1683
- animate: _animate = !1,
1684
- arrow: arrowProp = !1,
1685
- as = DEFAULT_TOOLTIP_ELEMENT,
1686
- boundaryElement = boundaryElementContext?.element,
1687
- children: childProp,
1435
+ $[9] !== className || $[10] !== radius ? (t7 = kbd({
1688
1436
  className,
1689
- content,
1690
- delay,
1691
- disabled,
1692
- fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"],
1693
- padding = 2,
1694
- placement: placementProp = "bottom",
1695
- portal: portalProp,
1696
- radius = 3,
1697
- ref: forwardedRef,
1698
- scheme,
1699
- shadow = 2,
1700
- zOffset = Z_OFFSETS.tooltip,
1701
- tone = "inherit",
1702
- ...rest
1703
- } = props, card2 = useCard(), animate = usePrefersReducedMotion() ? !1 : _animate, ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), rootBoundary = "viewport", [tooltipMaxWidth, setTooltipMaxWidth] = useState(0);
1704
- useImperativeHandle(forwardedRef, () => ref.current);
1705
- const portal = usePortal(), portalElement = typeof portalProp == "string" ? portal.elements?.[portalProp] || null : portal.element, middleware = useMemo(() => {
1706
- const ret = [];
1707
- return ret.push(flip({
1708
- boundary: boundaryElement || void 0,
1709
- fallbackPlacements,
1710
- padding: DEFAULT_TOOLTIP_PADDING,
1711
- rootBoundary
1712
- })), ret.push(offset({
1713
- mainAxis: DEFAULT_TOOLTIP_DISTANCE
1714
- })), ret.push(shift({
1715
- boundary: boundaryElement || void 0,
1716
- rootBoundary,
1717
- padding: DEFAULT_TOOLTIP_PADDING
1718
- })), arrowProp && ret.push(arrow({
1719
- element: arrowRef,
1720
- padding: DEFAULT_TOOLTIP_PADDING
1721
- })), animate && ret.push(origin), ret;
1722
- }, [animate, arrowProp, boundaryElement, fallbackPlacements]), {
1723
- floatingStyles,
1724
- placement,
1725
- middlewareData,
1726
- refs,
1727
- update
1728
- } = useFloating({
1729
- middleware,
1730
- placement: placementProp,
1731
- whileElementsMounted: autoUpdate,
1732
- elements: {
1733
- reference: referenceElement
1734
- },
1735
- transform: !1
1736
- }), arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, tooltipId = useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), {
1737
- setIsGroupActive,
1738
- setOpenTooltipId
1739
- } = delayGroupContext || {}, showTooltip = isOpen || delayGroupContext?.openTooltipId === tooltipId, isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : delay?.open || 0, closeDelayProp = typeof delay == "number" ? delay : delay?.close || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, handleIsOpenChange = useCallback((open, immediate) => {
1740
- if (isInsideGroup)
1741
- if (open) {
1742
- const groupedOpenDelay = immediate ? 0 : openDelay;
1743
- setIsGroupActive?.(open, groupedOpenDelay), setOpenTooltipId?.(tooltipId, groupedOpenDelay);
1744
- } else {
1745
- const groupDeactivateDelay = closeDelay > 200 ? closeDelay : 200;
1746
- setIsGroupActive?.(open, groupDeactivateDelay), setOpenTooltipId?.(null, immediate ? 0 : closeDelay);
1747
- }
1748
- else
1749
- setIsOpen(open, immediate ? 0 : open ? openDelay : closeDelay);
1750
- }, [isInsideGroup, openDelay, setIsGroupActive, setOpenTooltipId, tooltipId, closeDelay, setIsOpen]), handleBlur = useCallback((e) => {
1751
- handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
1752
- }, [childProp?.props, handleIsOpenChange]), handleClick = useCallback((e_0) => {
1753
- handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e_0);
1754
- }, [childProp?.props, handleIsOpenChange]), handleContextMenu = useCallback((e_1) => {
1755
- handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e_1);
1756
- }, [childProp?.props, handleIsOpenChange]), handleFocus = useCallback((e_2) => {
1757
- handleIsOpenChange(!0), childProp?.props?.onFocus?.(e_2);
1758
- }, [childProp?.props, handleIsOpenChange]), handleMouseEnter = useCallback((e_3) => {
1759
- handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e_3);
1760
- }, [childProp?.props, handleIsOpenChange]), handleMouseLeave = useCallback((e_4) => {
1761
- handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e_4);
1762
- }, [childProp?.props, handleIsOpenChange]);
1763
- useCloseOnMouseLeave({
1764
- handleIsOpenChange,
1765
- referenceElement,
1766
- showTooltip,
1767
- isInsideGroup
1768
- }), useEffect(() => {
1769
- disabled && showTooltip && handleIsOpenChange(!1);
1770
- }, [disabled, handleIsOpenChange, showTooltip]), useEffect(() => {
1771
- !content && showTooltip && handleIsOpenChange(!1);
1772
- }, [content, handleIsOpenChange, showTooltip]), useEffect(() => {
1773
- if (!showTooltip) return;
1774
- function handleWindowKeyDown(event) {
1775
- event.key === "Escape" && handleIsOpenChange(!1, !0);
1776
- }
1777
- return window.addEventListener("keydown", handleWindowKeyDown), () => {
1778
- window.removeEventListener("keydown", handleWindowKeyDown);
1779
- };
1780
- }, [handleIsOpenChange, showTooltip]), useLayoutEffect(() => {
1781
- const availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
1782
- setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
1783
- }, [boundaryElement, portalElement]);
1784
- const setArrow = useCallback((arrowEl) => {
1785
- arrowRef.current = arrowEl, update();
1786
- }, [update]), setFloating = useCallback((node) => {
1787
- ref.current = node, refs.setFloating(node);
1788
- }, [refs]), child = useMemo(() => childProp ? cloneElement(childProp, {
1789
- onBlur: handleBlur,
1790
- onFocus: handleFocus,
1791
- onMouseEnter: handleMouseEnter,
1792
- onMouseLeave: handleMouseLeave,
1793
- onClick: handleClick,
1794
- onContextMenu: handleContextMenu,
1795
- ref: setReferenceElement
1796
- }) : null, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave]);
1797
- if (useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsx(Fragment, {});
1798
- if (disabled) return child;
1799
- const node_0 = /* @__PURE__ */ jsx(TooltipLayer, { "data-ui": "Tooltip", ...rest, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: tooltip({
1800
- className
1801
- }), originX, originY, padding, placement, radius, ref: setFloating, scheme, shadow, style: {
1802
- ...floatingStyles,
1803
- maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
1804
- }, tone, zOffset, children: content }), children = showTooltip && (portalProp ? /* @__PURE__ */ jsx(Portal, { __unstable_name: typeof portalProp == "string" ? portalProp : void 0, children: /* @__PURE__ */ jsx(CardProvider, { tone: tone === "inherit" ? card2?.tone ?? "default" : tone, scheme: scheme ?? "light", children: node_0 }) }) : node_0);
1805
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1806
- animate ? /* @__PURE__ */ jsx(AnimatePresence, { children }) : children,
1807
- child
1808
- ] });
1809
- }
1810
- function useCloseOnMouseLeave(t0) {
1811
- const $ = c(10), {
1812
- handleIsOpenChange,
1813
- referenceElement,
1814
- showTooltip,
1815
- isInsideGroup
1816
- } = t0;
1817
- let t1;
1818
- $[0] !== handleIsOpenChange || $[1] !== referenceElement ? (t1 = (target, teardown) => {
1819
- referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
1820
- }, $[0] = handleIsOpenChange, $[1] = referenceElement, $[2] = t1) : t1 = $[2];
1821
- const onMouseMove = useEffectEvent(t1);
1822
- let t2;
1823
- $[3] !== isInsideGroup || $[4] !== onMouseMove || $[5] !== showTooltip ? (t2 = () => {
1824
- if (!showTooltip || isInsideGroup)
1825
- return;
1826
- const handleMouseMove = (event) => {
1827
- onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
1828
- };
1829
- return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
1830
- }, $[3] = isInsideGroup, $[4] = onMouseMove, $[5] = showTooltip, $[6] = t2) : t2 = $[6];
1831
- let t3;
1832
- $[7] !== isInsideGroup || $[8] !== showTooltip ? (t3 = [isInsideGroup, showTooltip], $[7] = isInsideGroup, $[8] = showTooltip, $[9] = t3) : t3 = $[9], useEffect(t2, t3);
1437
+ radius
1438
+ }), $[9] = className, $[10] = radius, $[11] = t7) : t7 = $[11];
1439
+ let t8;
1440
+ $[12] !== children || $[13] !== fontSize ? (t8 = /* @__PURE__ */ jsx(Text, { as: "span", muted: !0, size: fontSize, weight: "semibold", children }), $[12] = children, $[13] = fontSize, $[14] = t8) : t8 = $[14];
1441
+ let t9;
1442
+ return $[15] !== display || $[16] !== padding || $[17] !== rest || $[18] !== t6 || $[19] !== t7 || $[20] !== t8 ? (t9 = /* @__PURE__ */ jsx(Box, { "data-ui": "KBD", ...rest, as: t6, className: t7, display, muted: !0, padding, children: t8 }), $[15] = display, $[16] = padding, $[17] = rest, $[18] = t6, $[19] = t7, $[20] = t8, $[21] = t9) : t9 = $[21], t9;
1833
1443
  }
1834
1444
  const DEFAULT_HOTKEYS_ELEMENT = "kbd";
1835
1445
  function Hotkeys(props) {
@@ -2109,24 +1719,26 @@ function MenuDivider(props) {
2109
1719
  }
2110
1720
  const DEFAULT_SELECTABLE_ELEMENT = "button";
2111
1721
  function Selectable(props) {
2112
- const $ = c(14), t0 = props;
2113
- let className, radius, rest, t1, tone;
1722
+ const $ = c(16), t0 = props;
1723
+ let className, radius, rest, selected, t1, tone;
2114
1724
  $[0] !== t0 ? ({
2115
1725
  as: t1,
2116
1726
  className,
2117
1727
  radius,
1728
+ selected,
2118
1729
  tone,
2119
1730
  ...rest
2120
- } = t0, $[0] = t0, $[1] = className, $[2] = radius, $[3] = rest, $[4] = t1, $[5] = tone) : (className = $[1], radius = $[2], rest = $[3], t1 = $[4], tone = $[5]);
1731
+ } = t0, $[0] = t0, $[1] = className, $[2] = radius, $[3] = rest, $[4] = selected, $[5] = t1, $[6] = tone) : (className = $[1], radius = $[2], rest = $[3], selected = $[4], t1 = $[5], tone = $[6]);
2121
1732
  const as = t1 === void 0 ? DEFAULT_SELECTABLE_ELEMENT : t1;
2122
1733
  let t2;
2123
- $[6] !== className || $[7] !== radius || $[8] !== tone ? (t2 = _selectable({
1734
+ $[7] !== className || $[8] !== radius || $[9] !== tone ? (t2 = _selectable({
2124
1735
  className,
2125
1736
  radius,
2126
1737
  tone
2127
- }), $[6] = className, $[7] = radius, $[8] = tone, $[9] = t2) : t2 = $[9];
2128
- let t3;
2129
- return $[10] !== as || $[11] !== rest || $[12] !== t2 ? (t3 = /* @__PURE__ */ jsx(Box, { ...rest, as, className: t2 }), $[10] = as, $[11] = rest, $[12] = t2, $[13] = t3) : t3 = $[13], t3;
1738
+ }), $[7] = className, $[8] = radius, $[9] = tone, $[10] = t2) : t2 = $[10];
1739
+ const t3 = selected ? "" : void 0;
1740
+ let t4;
1741
+ return $[11] !== as || $[12] !== rest || $[13] !== t2 || $[14] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, { ...rest, as, className: t2, "data-selected": t3 }), $[11] = as, $[12] = rest, $[13] = t2, $[14] = t3, $[15] = t4) : t4 = $[15], t4;
2130
1742
  }
2131
1743
  function useMenu() {
2132
1744
  const value = useContext(MenuContext);
@@ -2138,7 +1750,7 @@ function useMenu() {
2138
1750
  }
2139
1751
  const DEFAULT_MENU_GROUP_ELEMENT = "button";
2140
1752
  function MenuGroup(props) {
2141
- const $ = c(79), t0 = props;
1753
+ const $ = c(78), t0 = props;
2142
1754
  let IconComponent, children, gap, menuProps, onClick, popover2, rest, t1, t2, t3, t4, t5, t6, text2;
2143
1755
  $[0] !== t0 ? ({
2144
1756
  as: t1,
@@ -2218,28 +1830,28 @@ function MenuGroup(props) {
2218
1830
  return;
2219
1831
  }
2220
1832
  }, $[46] = t21) : t21 = $[46];
2221
- const handleKeyDown = t21, t22 = as === "button" ? withinMenu : void 0, t23 = as !== "button" ? withinMenu : void 0, t24 = !withinMenu && active ? "" : void 0, t25 = as === "button" ? "button" : void 0, t26 = gap ?? space;
2222
- let t27;
2223
- $[47] !== IconComponent || $[48] !== fontSize ? (t27 = IconComponent && /* @__PURE__ */ jsxs(Text, { size: fontSize, children: [
1833
+ const handleKeyDown = t21, t22 = as === "button" ? withinMenu : void 0, t23 = as === "button" ? "button" : void 0, t24 = gap ?? space;
1834
+ let t25;
1835
+ $[47] !== IconComponent || $[48] !== fontSize ? (t25 = IconComponent && /* @__PURE__ */ jsxs(Text, { size: fontSize, children: [
2224
1836
  isValidElement(IconComponent) && IconComponent,
2225
1837
  isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})
2226
- ] }), $[47] = IconComponent, $[48] = fontSize, $[49] = t27) : t27 = $[49];
1838
+ ] }), $[47] = IconComponent, $[48] = fontSize, $[49] = t25) : t25 = $[49];
1839
+ let t26;
1840
+ $[50] !== fontSize || $[51] !== text2 ? (t26 = /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { size: fontSize, textOverflow: "ellipsis", weight: "medium", children: text2 }) }), $[50] = fontSize, $[51] = text2, $[52] = t26) : t26 = $[52];
1841
+ let t27;
1842
+ $[53] === Symbol.for("react.memo_cache_sentinel") ? (t27 = /* @__PURE__ */ jsx(ChevronRightIcon, {}), $[53] = t27) : t27 = $[53];
2227
1843
  let t28;
2228
- $[50] !== fontSize || $[51] !== text2 ? (t28 = /* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Text, { size: fontSize, textOverflow: "ellipsis", weight: "medium", children: text2 }) }), $[50] = fontSize, $[51] = text2, $[52] = t28) : t28 = $[52];
1844
+ $[54] !== fontSize ? (t28 = /* @__PURE__ */ jsx(Text, { size: fontSize, children: t27 }), $[54] = fontSize, $[55] = t28) : t28 = $[55];
2229
1845
  let t29;
2230
- $[53] === Symbol.for("react.memo_cache_sentinel") ? (t29 = /* @__PURE__ */ jsx(ChevronRightIcon, {}), $[53] = t29) : t29 = $[53];
1846
+ $[56] !== padding || $[57] !== t24 || $[58] !== t25 || $[59] !== t26 || $[60] !== t28 ? (t29 = /* @__PURE__ */ jsxs(Flex, { gap: t24, padding, children: [
1847
+ t25,
1848
+ t26,
1849
+ t28
1850
+ ] }), $[56] = padding, $[57] = t24, $[58] = t25, $[59] = t26, $[60] = t28, $[61] = t29) : t29 = $[61];
2231
1851
  let t30;
2232
- $[54] !== fontSize ? (t30 = /* @__PURE__ */ jsx(Text, { size: fontSize, children: t29 }), $[54] = fontSize, $[55] = t30) : t30 = $[55];
1852
+ $[62] !== as || $[63] !== handleClick || $[64] !== handleMouseEnter || $[65] !== radius || $[66] !== rest || $[67] !== t22 || $[68] !== t23 || $[69] !== t29 || $[70] !== tone || $[71] !== withinMenu ? (t30 = /* @__PURE__ */ jsx(Selectable, { "data-ui": "MenuGroup", ...rest, "aria-pressed": t22, as, onClick: handleClick, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, radius, ref: setRootElement, selected: withinMenu, tabIndex: -1, tone, type: t23, children: t29 }), $[62] = as, $[63] = handleClick, $[64] = handleMouseEnter, $[65] = radius, $[66] = rest, $[67] = t22, $[68] = t23, $[69] = t29, $[70] = tone, $[71] = withinMenu, $[72] = t30) : t30 = $[72];
2233
1853
  let t31;
2234
- $[56] !== padding || $[57] !== t26 || $[58] !== t27 || $[59] !== t28 || $[60] !== t30 ? (t31 = /* @__PURE__ */ jsxs(Flex, { gap: t26, padding, children: [
2235
- t27,
2236
- t28,
2237
- t30
2238
- ] }), $[56] = padding, $[57] = t26, $[58] = t27, $[59] = t28, $[60] = t30, $[61] = t31) : t31 = $[61];
2239
- let t32;
2240
- $[62] !== as || $[63] !== handleClick || $[64] !== handleMouseEnter || $[65] !== radius || $[66] !== rest || $[67] !== t22 || $[68] !== t23 || $[69] !== t24 || $[70] !== t25 || $[71] !== t31 || $[72] !== tone ? (t32 = /* @__PURE__ */ jsx(Selectable, { "data-ui": "MenuGroup", ...rest, "aria-pressed": t22, as, "data-pressed": t23, "data-selected": t24, onClick: handleClick, onKeyDown: handleKeyDown, onMouseEnter: handleMouseEnter, radius, ref: setRootElement, tabIndex: -1, tone, type: t25, children: t31 }), $[62] = as, $[63] = handleClick, $[64] = handleMouseEnter, $[65] = radius, $[66] = rest, $[67] = t22, $[68] = t23, $[69] = t24, $[70] = t25, $[71] = t31, $[72] = tone, $[73] = t32) : t32 = $[73];
2241
- let t33;
2242
- return $[74] !== childMenu || $[75] !== open || $[76] !== popover2 || $[77] !== t32 ? (t33 = /* @__PURE__ */ jsx(Popover, { ...popover2, content: childMenu, "data-ui": "MenuGroup__popover", open, children: t32 }), $[74] = childMenu, $[75] = open, $[76] = popover2, $[77] = t32, $[78] = t33) : t33 = $[78], t33;
1854
+ return $[73] !== childMenu || $[74] !== open || $[75] !== popover2 || $[76] !== t30 ? (t31 = /* @__PURE__ */ jsx(Popover, { ...popover2, content: childMenu, "data-ui": "MenuGroup__popover", open, children: t30 }), $[73] = childMenu, $[74] = open, $[75] = popover2, $[76] = t30, $[77] = t31) : t31 = $[77], t31;
2243
1855
  }
2244
1856
  const DEFAULT_MENU_ITEM_ELEMENT = "button";
2245
1857
  function MenuItem(props) {
@@ -2404,6 +2016,271 @@ function TabList(props) {
2404
2016
  function _isReactElement(node) {
2405
2017
  return !!node;
2406
2018
  }
2019
+ const DEFAULT_GRID_ELEMENT = "div";
2020
+ function Grid(props) {
2021
+ const $ = c(8), t0 = props;
2022
+ let children, rest, t1;
2023
+ $[0] !== t0 ? ({
2024
+ as: t1,
2025
+ children,
2026
+ ...rest
2027
+ } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1) : (children = $[1], rest = $[2], t1 = $[3]);
2028
+ const as = t1 === void 0 ? DEFAULT_GRID_ELEMENT : t1;
2029
+ let t2;
2030
+ return $[4] !== as || $[5] !== children || $[6] !== rest ? (t2 = /* @__PURE__ */ jsx(Box, { "data-ui": "Grid", ...rest, as, display: "grid", children }), $[4] = as, $[5] = children, $[6] = rest, $[7] = t2) : t2 = $[7], t2;
2031
+ }
2032
+ function usePrefersDark(t0) {
2033
+ return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp : t0);
2034
+ }
2035
+ function _temp() {
2036
+ return !1;
2037
+ }
2038
+ function useDelayedState(initialState) {
2039
+ const $ = c(3), [state, setState] = useState(initialState), delayedAction = useRef(void 0);
2040
+ let t0;
2041
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (nextState, delay) => {
2042
+ const action = () => {
2043
+ setState(nextState);
2044
+ };
2045
+ if (delayedAction.current && (clearTimeout(delayedAction.current), delayedAction.current = void 0), !delay)
2046
+ return action();
2047
+ delayedAction.current = setTimeout(action, delay);
2048
+ }, $[0] = t0) : t0 = $[0];
2049
+ const onStateChange = t0;
2050
+ let t1;
2051
+ return $[1] !== state ? (t1 = [state, onStateChange], $[1] = state, $[2] = t1) : t1 = $[2], t1;
2052
+ }
2053
+ function getElementRef(element) {
2054
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
2055
+ return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
2056
+ }
2057
+ const DEFAULT_TOOLTIP_ARROW_WIDTH = 15, DEFAULT_TOOLTIP_ARROW_HEIGHT = 6, DEFAULT_TOOLTIP_ARROW_RADIUS = 2, DEFAULT_TOOLTIP_DISTANCE = 4, DEFAULT_TOOLTIP_PADDING = 4, DEFAULT_FALLBACK_PLACEMENTS = {
2058
+ top: ["top-end", "top-start", "bottom", "left", "right"],
2059
+ "top-start": ["top", "top-end", "bottom-start", "left-start", "right-start"],
2060
+ "top-end": ["top", "top-start", "bottom-end", "left-end", "right-end"],
2061
+ bottom: ["bottom-end", "bottom-start", "top", "left", "right"],
2062
+ "bottom-start": ["bottom", "bottom-end", "top-start", "left-start", "right-start"],
2063
+ "bottom-end": ["bottom", "bottom-start", "top-end", "left-end", "right-end"],
2064
+ left: ["left-end", "left-start", "right", "top", "bottom"],
2065
+ "left-start": ["left", "left-end", "right-start", "top-start", "bottom-start"],
2066
+ "left-end": ["left", "left-start", "right-end", "top-end", "bottom-end"],
2067
+ right: ["right-end", "right-start", "left", "top", "bottom"],
2068
+ "right-start": ["right", "right-end", "left-start", "top-start", "bottom-start"],
2069
+ "right-end": ["right", "right-start", "left-end", "top-end", "bottom-end"]
2070
+ }, TooltipDelayGroupContext = createGlobalScopedContext("@sanity/ui/context/tooltipDelayGroup", null);
2071
+ function useTooltipDelayGroup() {
2072
+ return useContext(TooltipDelayGroupContext);
2073
+ }
2074
+ function TooltipLayer(props) {
2075
+ const $ = c(50);
2076
+ let animate, arrow2, arrowRef, arrowX, arrowY, children, originX, originY, padding, placement, radius, rest, scheme, shadow, style, t0;
2077
+ $[0] !== props ? ({
2078
+ animate,
2079
+ arrow: arrow2,
2080
+ arrowRef,
2081
+ arrowX,
2082
+ arrowY,
2083
+ children,
2084
+ originX,
2085
+ originY,
2086
+ padding,
2087
+ placement,
2088
+ radius,
2089
+ scheme,
2090
+ shadow,
2091
+ style,
2092
+ tone: t0,
2093
+ ...rest
2094
+ } = props, $[0] = props, $[1] = animate, $[2] = arrow2, $[3] = arrowRef, $[4] = arrowX, $[5] = arrowY, $[6] = children, $[7] = originX, $[8] = originY, $[9] = padding, $[10] = placement, $[11] = radius, $[12] = rest, $[13] = scheme, $[14] = shadow, $[15] = style, $[16] = t0) : (animate = $[1], arrow2 = $[2], arrowRef = $[3], arrowX = $[4], arrowY = $[5], children = $[6], originX = $[7], originY = $[8], padding = $[9], placement = $[10], radius = $[11], rest = $[12], scheme = $[13], shadow = $[14], style = $[15], t0 = $[16]);
2095
+ const tone = t0 === void 0 ? "inherit" : t0;
2096
+ let t1;
2097
+ const t2 = animate ? "transform" : void 0;
2098
+ let t3;
2099
+ $[17] !== originX || $[18] !== originY || $[19] !== style || $[20] !== t2 ? (t3 = {
2100
+ originX,
2101
+ originY,
2102
+ willChange: t2,
2103
+ ...style
2104
+ }, $[17] = originX, $[18] = originY, $[19] = style, $[20] = t2, $[21] = t3) : t3 = $[21], t1 = t3;
2105
+ const rootStyle = t1;
2106
+ let t4;
2107
+ const t5 = arrowX !== null ? arrowX : void 0, t6 = arrowY !== null ? arrowY : void 0;
2108
+ let t7;
2109
+ $[22] !== t5 || $[23] !== t6 ? (t7 = {
2110
+ left: t5,
2111
+ top: t6,
2112
+ right: void 0,
2113
+ bottom: void 0
2114
+ }, $[22] = t5, $[23] = t6, $[24] = t7) : t7 = $[24], t4 = t7;
2115
+ const arrowStyle = t4, t8 = animate ? "" : void 0;
2116
+ let t9;
2117
+ $[25] !== animate ? (t9 = animate ? ["hidden", "initial"] : void 0, $[25] = animate, $[26] = t9) : t9 = $[26];
2118
+ let t10;
2119
+ $[27] !== animate ? (t10 = animate ? ["visible", "scaleIn"] : void 0, $[27] = animate, $[28] = t10) : t10 = $[28];
2120
+ let t11;
2121
+ $[29] !== animate ? (t11 = animate ? ["hidden", "scaleOut"] : void 0, $[29] = animate, $[30] = t11) : t11 = $[30];
2122
+ let t12;
2123
+ $[31] !== arrow2 || $[32] !== arrowRef || $[33] !== arrowStyle ? (t12 = arrow2 && /* @__PURE__ */ jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_TOOLTIP_ARROW_WIDTH, height: DEFAULT_TOOLTIP_ARROW_HEIGHT, radius: DEFAULT_TOOLTIP_ARROW_RADIUS }), $[31] = arrow2, $[32] = arrowRef, $[33] = arrowStyle, $[34] = t12) : t12 = $[34];
2124
+ let t13;
2125
+ return $[35] !== children || $[36] !== padding || $[37] !== placement || $[38] !== radius || $[39] !== rest || $[40] !== rootStyle || $[41] !== scheme || $[42] !== shadow || $[43] !== t10 || $[44] !== t11 || $[45] !== t12 || $[46] !== t8 || $[47] !== t9 || $[48] !== tone ? (t13 = /* @__PURE__ */ jsxs(Layer, { "data-ui": "Tooltip__layer", ...rest, as: motion.div, "data-animate": t8, "data-placement": placement, padding, radius, scheme, shadow, style: rootStyle, variants: POPOVER_MOTION_PROPS.card, transition: POPOVER_MOTION_PROPS.transition, initial: t9, animate: t10, exit: t11, tone, children: [
2126
+ children,
2127
+ t12
2128
+ ] }), $[35] = children, $[36] = padding, $[37] = placement, $[38] = radius, $[39] = rest, $[40] = rootStyle, $[41] = scheme, $[42] = shadow, $[43] = t10, $[44] = t11, $[45] = t12, $[46] = t8, $[47] = t9, $[48] = tone, $[49] = t13) : t13 = $[49], t13;
2129
+ }
2130
+ const DEFAULT_TOOLTIP_ELEMENT = "div";
2131
+ function Tooltip(props) {
2132
+ const boundaryElementContext = useBoundaryElement(), {
2133
+ animate: _animate = !1,
2134
+ arrow: arrowProp = !1,
2135
+ as = DEFAULT_TOOLTIP_ELEMENT,
2136
+ boundaryElement = boundaryElementContext?.element,
2137
+ children: childProp,
2138
+ className,
2139
+ content,
2140
+ delay,
2141
+ disabled,
2142
+ fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"],
2143
+ padding = 2,
2144
+ placement: placementProp = "bottom",
2145
+ portal: portalProp,
2146
+ radius = 3,
2147
+ ref: forwardedRef,
2148
+ scheme,
2149
+ shadow = 2,
2150
+ zOffset = Z_OFFSETS.tooltip,
2151
+ tone = "inherit",
2152
+ ...rest
2153
+ } = props, card2 = useCard(), animate = usePrefersReducedMotion() ? !1 : _animate, ref = useRef(null), [referenceElement, setReferenceElement] = useState(null), arrowRef = useRef(null), rootBoundary = "viewport", [tooltipMaxWidth, setTooltipMaxWidth] = useState(0);
2154
+ useImperativeHandle(forwardedRef, () => ref.current);
2155
+ const portal = usePortal(), portalElement = typeof portalProp == "string" ? portal.elements?.[portalProp] || null : portal.element, middleware = useMemo(() => {
2156
+ const ret = [];
2157
+ return ret.push(flip({
2158
+ boundary: boundaryElement || void 0,
2159
+ fallbackPlacements,
2160
+ padding: DEFAULT_TOOLTIP_PADDING,
2161
+ rootBoundary
2162
+ })), ret.push(offset({
2163
+ mainAxis: DEFAULT_TOOLTIP_DISTANCE
2164
+ })), ret.push(shift({
2165
+ boundary: boundaryElement || void 0,
2166
+ rootBoundary,
2167
+ padding: DEFAULT_TOOLTIP_PADDING
2168
+ })), arrowProp && ret.push(arrow({
2169
+ element: arrowRef,
2170
+ padding: DEFAULT_TOOLTIP_PADDING
2171
+ })), animate && ret.push(origin), ret;
2172
+ }, [animate, arrowProp, boundaryElement, fallbackPlacements]), {
2173
+ floatingStyles,
2174
+ placement,
2175
+ middlewareData,
2176
+ refs,
2177
+ update
2178
+ } = useFloating({
2179
+ middleware,
2180
+ placement: placementProp,
2181
+ whileElementsMounted: autoUpdate,
2182
+ elements: {
2183
+ reference: referenceElement
2184
+ },
2185
+ transform: !1
2186
+ }), arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, tooltipId = useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), {
2187
+ setIsGroupActive,
2188
+ setOpenTooltipId
2189
+ } = delayGroupContext || {}, showTooltip = isOpen || delayGroupContext?.openTooltipId === tooltipId, isInsideGroup = delayGroupContext !== null, openDelayProp = typeof delay == "number" ? delay : delay?.open || 0, closeDelayProp = typeof delay == "number" ? delay : delay?.close || 0, openDelay = isInsideGroup ? delayGroupContext.openDelay : openDelayProp, closeDelay = isInsideGroup ? delayGroupContext.closeDelay : closeDelayProp, handleIsOpenChange = useCallback((open, immediate) => {
2190
+ if (isInsideGroup)
2191
+ if (open) {
2192
+ const groupedOpenDelay = immediate ? 0 : openDelay;
2193
+ setIsGroupActive?.(open, groupedOpenDelay), setOpenTooltipId?.(tooltipId, groupedOpenDelay);
2194
+ } else {
2195
+ const groupDeactivateDelay = closeDelay > 200 ? closeDelay : 200;
2196
+ setIsGroupActive?.(open, groupDeactivateDelay), setOpenTooltipId?.(null, immediate ? 0 : closeDelay);
2197
+ }
2198
+ else
2199
+ setIsOpen(open, immediate ? 0 : open ? openDelay : closeDelay);
2200
+ }, [isInsideGroup, openDelay, setIsGroupActive, setOpenTooltipId, tooltipId, closeDelay, setIsOpen]), handleBlur = useCallback((e) => {
2201
+ handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
2202
+ }, [childProp?.props, handleIsOpenChange]), handleClick = useCallback((e_0) => {
2203
+ handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e_0);
2204
+ }, [childProp?.props, handleIsOpenChange]), handleContextMenu = useCallback((e_1) => {
2205
+ handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e_1);
2206
+ }, [childProp?.props, handleIsOpenChange]), handleFocus = useCallback((e_2) => {
2207
+ handleIsOpenChange(!0), childProp?.props?.onFocus?.(e_2);
2208
+ }, [childProp?.props, handleIsOpenChange]), handleMouseEnter = useCallback((e_3) => {
2209
+ handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e_3);
2210
+ }, [childProp?.props, handleIsOpenChange]), handleMouseLeave = useCallback((e_4) => {
2211
+ handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e_4);
2212
+ }, [childProp?.props, handleIsOpenChange]);
2213
+ useCloseOnMouseLeave({
2214
+ handleIsOpenChange,
2215
+ referenceElement,
2216
+ showTooltip,
2217
+ isInsideGroup
2218
+ }), useEffect(() => {
2219
+ disabled && showTooltip && handleIsOpenChange(!1);
2220
+ }, [disabled, handleIsOpenChange, showTooltip]), useEffect(() => {
2221
+ !content && showTooltip && handleIsOpenChange(!1);
2222
+ }, [content, handleIsOpenChange, showTooltip]), useEffect(() => {
2223
+ if (!showTooltip) return;
2224
+ function handleWindowKeyDown(event) {
2225
+ event.key === "Escape" && handleIsOpenChange(!1, !0);
2226
+ }
2227
+ return window.addEventListener("keydown", handleWindowKeyDown), () => {
2228
+ window.removeEventListener("keydown", handleWindowKeyDown);
2229
+ };
2230
+ }, [handleIsOpenChange, showTooltip]), useLayoutEffect(() => {
2231
+ const availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
2232
+ setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
2233
+ }, [boundaryElement, portalElement]);
2234
+ const setArrow = useCallback((arrowEl) => {
2235
+ arrowRef.current = arrowEl, update();
2236
+ }, [update]), setFloating = useCallback((node) => {
2237
+ ref.current = node, refs.setFloating(node);
2238
+ }, [refs]), child = useMemo(() => childProp ? cloneElement(childProp, {
2239
+ onBlur: handleBlur,
2240
+ onFocus: handleFocus,
2241
+ onMouseEnter: handleMouseEnter,
2242
+ onMouseLeave: handleMouseLeave,
2243
+ onClick: handleClick,
2244
+ onContextMenu: handleContextMenu,
2245
+ ref: setReferenceElement
2246
+ }) : null, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave]);
2247
+ if (useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsx(Fragment, {});
2248
+ if (disabled) return child;
2249
+ const node_0 = /* @__PURE__ */ jsx(TooltipLayer, { "data-ui": "Tooltip", ...rest, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: tooltip({
2250
+ className
2251
+ }), originX, originY, padding, placement, radius, ref: setFloating, scheme, shadow, style: {
2252
+ ...floatingStyles,
2253
+ maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
2254
+ }, tone, zOffset, children: content }), children = showTooltip && (portalProp ? /* @__PURE__ */ jsx(Portal, { __unstable_name: typeof portalProp == "string" ? portalProp : void 0, children: /* @__PURE__ */ jsx(CardProvider, { tone: tone === "inherit" ? card2?.tone ?? "default" : tone, scheme: scheme ?? "light", children: node_0 }) }) : node_0);
2255
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2256
+ animate ? /* @__PURE__ */ jsx(AnimatePresence, { children }) : children,
2257
+ child
2258
+ ] });
2259
+ }
2260
+ function useCloseOnMouseLeave(t0) {
2261
+ const $ = c(10), {
2262
+ handleIsOpenChange,
2263
+ referenceElement,
2264
+ showTooltip,
2265
+ isInsideGroup
2266
+ } = t0;
2267
+ let t1;
2268
+ $[0] !== handleIsOpenChange || $[1] !== referenceElement ? (t1 = (target, teardown) => {
2269
+ referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
2270
+ }, $[0] = handleIsOpenChange, $[1] = referenceElement, $[2] = t1) : t1 = $[2];
2271
+ const onMouseMove = useEffectEvent(t1);
2272
+ let t2;
2273
+ $[3] !== isInsideGroup || $[4] !== onMouseMove || $[5] !== showTooltip ? (t2 = () => {
2274
+ if (!showTooltip || isInsideGroup)
2275
+ return;
2276
+ const handleMouseMove = (event) => {
2277
+ onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
2278
+ };
2279
+ return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
2280
+ }, $[3] = isInsideGroup, $[4] = onMouseMove, $[5] = showTooltip, $[6] = t2) : t2 = $[6];
2281
+ let t3;
2282
+ $[7] !== isInsideGroup || $[8] !== showTooltip ? (t3 = [isInsideGroup, showTooltip], $[7] = isInsideGroup, $[8] = showTooltip, $[9] = t3) : t3 = $[9], useEffect(t2, t3);
2283
+ }
2407
2284
  export {
2408
2285
  AnimatedSpinnerIcon,
2409
2286
  Arrow,
@@ -2412,13 +2289,10 @@ export {
2412
2289
  Button,
2413
2290
  Card,
2414
2291
  CardProvider,
2415
- Code,
2416
2292
  DEFAULT_ARROW_ELEMENT,
2417
2293
  DEFAULT_BOX_ELEMENT,
2418
2294
  DEFAULT_BUTTON_ELEMENT,
2419
2295
  DEFAULT_CARD_ELEMENT,
2420
- DEFAULT_CODE_ELEMENT,
2421
- DEFAULT_ELEMENT_QUERY_ELEMENT,
2422
2296
  DEFAULT_FLEX_ELEMENT,
2423
2297
  DEFAULT_GRID_ELEMENT,
2424
2298
  DEFAULT_HOTKEYS_ELEMENT,
@@ -2429,6 +2303,7 @@ export {
2429
2303
  DEFAULT_MENU_GROUP_ELEMENT,
2430
2304
  DEFAULT_MENU_ITEM_ELEMENT,
2431
2305
  DEFAULT_POPOVER_ELEMENT,
2306
+ DEFAULT_SELECTABLE_ELEMENT,
2432
2307
  DEFAULT_SPINNER_ELEMENT,
2433
2308
  DEFAULT_STACK_ELEMENT,
2434
2309
  DEFAULT_TAB_ELEMENT,
@@ -2438,7 +2313,6 @@ export {
2438
2313
  DEFAULT_TOOLTIP_ELEMENT,
2439
2314
  EMPTY_ARRAY,
2440
2315
  EMPTY_RECORD,
2441
- ElementQuery,
2442
2316
  Flex,
2443
2317
  Grid,
2444
2318
  Hotkeys,
@@ -2464,8 +2338,6 @@ export {
2464
2338
  Tooltip,
2465
2339
  TooltipDelayGroupContext,
2466
2340
  Z_OFFSETS,
2467
- _ResizeObserver,
2468
- _elementSizeObserver,
2469
2341
  _getArrayProp,
2470
2342
  _getResponsiveProp,
2471
2343
  _isEnterToClickElement,
@@ -2483,7 +2355,6 @@ export {
2483
2355
  useClickOutsideEvent,
2484
2356
  useCustomValidity,
2485
2357
  useDelayedState,
2486
- useElementSize,
2487
2358
  useGlobalKeyDown,
2488
2359
  useLayer,
2489
2360
  useMatchMedia,