@sanity/ui 3.0.0-static.27 → 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 (217) hide show
  1. package/README.md +1 -1
  2. package/dist/_chunks-cjs/_visual-editing.cjs +710 -840
  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 +705 -834
  7. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  8. package/dist/_chunks-es/refractor.js +1 -1
  9. package/dist/css/layers.css +4 -0
  10. package/dist/css/primitives/popover/popover.css +4 -0
  11. package/dist/css.cjs +58 -49
  12. package/dist/css.cjs.map +1 -1
  13. package/dist/css.d.cts +13 -5
  14. package/dist/css.d.ts +13 -5
  15. package/dist/css.js +58 -49
  16. package/dist/css.js.map +1 -1
  17. package/dist/index.cjs +2006 -1824
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.css +1 -0
  20. package/dist/index.d.cts +34 -17
  21. package/dist/index.d.ts +34 -17
  22. package/dist/index.js +2002 -1821
  23. package/dist/index.js.map +1 -1
  24. package/dist/theme.cjs +7 -7
  25. package/dist/theme.cjs.map +1 -1
  26. package/dist/theme.js +7 -7
  27. package/dist/theme.js.map +1 -1
  28. package/exports/_visual-editing.ts +1 -1
  29. package/package.json +10 -15
  30. package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
  31. package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
  32. package/src/core/components/autocomplete/autocomplete.tsx +13 -17
  33. package/src/core/components/autocomplete/autocompleteOption.tsx +1 -1
  34. package/src/core/components/autocomplete/constants.ts +3 -1
  35. package/src/core/components/autocomplete/types.ts +1 -1
  36. package/src/core/components/breadcrumbs/breadcrumbs.tsx +8 -3
  37. package/src/core/components/dialog/__workshop__/activate.tsx +11 -3
  38. package/src/core/components/dialog/__workshop__/panes.tsx +12 -5
  39. package/src/core/components/dialog/dialog.tsx +12 -6
  40. package/src/core/components/dialog/dialogCard.tsx +89 -54
  41. package/src/core/components/dialog/dialogContext.ts +1 -1
  42. package/src/core/components/dialog/dialogProvider.tsx +1 -1
  43. package/src/core/components/dialog/index.ts +1 -0
  44. package/src/core/components/dialog/isTargetWithinScope.ts +1 -1
  45. package/src/core/components/hotkeys/hotkeys.tsx +3 -2
  46. package/src/core/components/menu/__workshop__/avatarMenu.tsx +12 -6
  47. package/src/core/components/menu/__workshop__/customSelectedState.tsx +1 -5
  48. package/src/core/components/menu/__workshop__/shouldFocus.tsx +1 -2
  49. package/src/core/components/menu/helpers.ts +1 -1
  50. package/src/core/components/menu/menu.tsx +6 -3
  51. package/src/core/components/menu/menuButton.tsx +5 -3
  52. package/src/core/components/menu/menuDivider.tsx +1 -1
  53. package/src/core/components/menu/menuGroup.tsx +8 -4
  54. package/src/core/components/menu/menuItem.tsx +4 -2
  55. package/src/core/components/tab/tab.tsx +2 -2
  56. package/src/core/components/tab/tabList.tsx +2 -2
  57. package/src/core/components/tab/tabPanel.tsx +2 -2
  58. package/src/core/components/toast/toast.tsx +7 -2
  59. package/src/core/components/toast/toastLayer.tsx +3 -2
  60. package/src/core/components/toast/toastProvider.tsx +1 -1
  61. package/src/core/components/tree/tree.tsx +2 -2
  62. package/src/core/components/tree/treeGroup.tsx +2 -2
  63. package/src/core/components/tree/treeItem.tsx +13 -6
  64. package/src/core/components/tree/types.ts +0 -1
  65. package/src/core/components/virtualList/virtualList.tsx +10 -5
  66. package/src/core/helpers/focus.ts +0 -8
  67. package/src/core/hooks/useArrayProp.ts +1 -1
  68. package/src/core/hooks/useElementRect/__workshop__/example.tsx +1 -3
  69. package/src/core/hooks/useElementSize.ts +1 -1
  70. package/src/core/hooks/useResponsiveProp.ts +1 -1
  71. package/src/core/index.ts +83 -7
  72. package/src/core/observers/{elementSizeObserver.ts → elementSize.ts} +1 -1
  73. package/src/core/primitives/_selectable/index.ts +1 -0
  74. package/src/core/primitives/_selectable/selectable.tsx +13 -3
  75. package/src/core/{types/selectable.ts → primitives/_selectable/types.ts} +1 -1
  76. package/src/core/primitives/arrow/arrow.tsx +1 -1
  77. package/src/core/primitives/avatar/avatar.tsx +4 -3
  78. package/src/core/primitives/avatar/avatarCounter.tsx +3 -3
  79. package/src/core/primitives/avatar/avatarStack.tsx +4 -4
  80. package/src/core/primitives/avatar/types.ts +17 -0
  81. package/src/core/primitives/badge/badge.tsx +2 -1
  82. package/src/core/primitives/badge/types.ts +11 -2
  83. package/src/core/primitives/box/__workshop__/responsive.tsx +0 -1
  84. package/src/core/primitives/box/box.tsx +1 -1
  85. package/src/core/primitives/box/index.ts +1 -0
  86. package/src/core/primitives/button/__workshop__/disabled.tsx +37 -51
  87. package/src/core/primitives/button/__workshop__/index.ts +5 -0
  88. package/src/core/primitives/button/__workshop__/textOverflow.tsx +13 -0
  89. package/src/core/primitives/button/button.tsx +15 -14
  90. package/src/core/primitives/button/index.ts +1 -0
  91. package/src/core/primitives/card/__workshop__/listNavigation.tsx +2 -2
  92. package/src/core/primitives/card/card.tsx +1 -1
  93. package/src/core/primitives/card/types.ts +3 -0
  94. package/src/core/primitives/checkbox/__workshop__/tones.tsx +9 -1
  95. package/src/core/primitives/checkbox/checkbox.tsx +3 -4
  96. package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +17 -42
  97. package/src/core/primitives/code/code.tsx +1 -1
  98. package/src/core/primitives/container/container.tsx +1 -1
  99. package/src/core/primitives/flex/flex.tsx +1 -1
  100. package/src/core/primitives/flex/index.ts +1 -0
  101. package/src/core/primitives/grid/grid.tsx +1 -1
  102. package/src/core/primitives/grid/index.ts +1 -0
  103. package/src/core/primitives/heading/heading.tsx +1 -1
  104. package/src/core/primitives/inline/inline.tsx +1 -1
  105. package/src/core/primitives/kbd/kbd.tsx +1 -1
  106. package/src/core/primitives/label/label.tsx +1 -1
  107. package/src/core/primitives/layer/layer.test.tsx +1 -1
  108. package/src/core/primitives/layer/layer.tsx +2 -2
  109. package/src/core/primitives/layer/layerCard.tsx +3 -3
  110. package/src/core/primitives/layer/layerProvider.tsx +2 -1
  111. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +12 -10
  112. package/src/core/primitives/popover/__workshop__/TestStory.tsx +9 -8
  113. package/src/core/primitives/popover/constants.ts +1 -1
  114. package/src/core/primitives/popover/floating-ui/size.ts +1 -1
  115. package/src/core/primitives/popover/popover.tsx +7 -4
  116. package/src/core/primitives/popover/popoverLayer.tsx +2 -1
  117. package/src/core/primitives/popover/types.ts +5 -0
  118. package/src/core/primitives/radio/radio.tsx +2 -2
  119. package/src/core/primitives/select/select.tsx +2 -2
  120. package/src/core/{components → primitives}/skeleton/__workshop__/index.ts +1 -1
  121. package/src/core/{components → primitives}/skeleton/codeSkeleton.tsx +1 -1
  122. package/src/core/{components → primitives}/skeleton/headingSkeleton.tsx +1 -1
  123. package/src/core/{components → primitives}/skeleton/labelSkeleton.tsx +1 -1
  124. package/src/core/{components → primitives}/skeleton/skeleton.tsx +7 -8
  125. package/src/core/{components → primitives}/skeleton/textSkeleton.tsx +1 -1
  126. package/src/core/primitives/spinner/spinner.tsx +1 -1
  127. package/src/core/primitives/srOnly/srOnly.tsx +1 -1
  128. package/src/core/primitives/stack/stack.tsx +1 -1
  129. package/src/core/primitives/switch/switch.tsx +1 -6
  130. package/src/core/primitives/text/__workshop__/colored.tsx +2 -2
  131. package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +17 -42
  132. package/src/core/primitives/text/text.tsx +3 -1
  133. package/src/core/primitives/textArea/__workshop__/plain.tsx +2 -2
  134. package/src/core/primitives/textArea/textArea.tsx +2 -2
  135. package/src/core/primitives/textInput/textInput.tsx +3 -2
  136. package/src/core/primitives/tooltip/constants.ts +1 -1
  137. package/src/core/primitives/tooltip/tooltip.tsx +5 -3
  138. package/src/core/primitives/tooltip/tooltipLayer.tsx +1 -1
  139. package/src/core/primitives/types.ts +8 -10
  140. package/src/core/types/radius.ts +1 -1
  141. package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +9 -5
  142. package/src/core/utils/elementQuery/elementQuery.tsx +2 -2
  143. package/src/core/utils/portal/portal.tsx +1 -1
  144. package/src/css/components/dialog/dialog.css.ts +26 -1
  145. package/src/css/components/dialog/dialog.ts +27 -7
  146. package/src/css/components/skeleton/skeleton.ts +3 -1
  147. package/src/css/components/skeleton/types.ts +3 -1
  148. package/src/css/index.ts +75 -5
  149. package/src/css/primitives/_input/input.ts +2 -1
  150. package/src/css/primitives/_input/types.ts +2 -1
  151. package/src/css/primitives/_selectable/_selectable.css.ts +32 -24
  152. package/src/css/primitives/_selectable/selectable.ts +1 -1
  153. package/src/css/primitives/_selectable/types.ts +1 -1
  154. package/src/css/primitives/avatar/avatar.css.ts +8 -4
  155. package/src/css/primitives/avatar/avatar.ts +1 -1
  156. package/src/css/primitives/badge/types.ts +0 -2
  157. package/src/css/primitives/box/box.ts +35 -37
  158. package/src/css/primitives/box/types.ts +34 -36
  159. package/src/css/primitives/button/button.css.ts +4 -0
  160. package/src/css/primitives/button/button.ts +5 -2
  161. package/src/css/primitives/button/types.ts +4 -11
  162. package/src/css/primitives/card/__workshop__/color.tsx +70 -0
  163. package/src/css/primitives/card/__workshop__/index.ts +14 -0
  164. package/src/css/primitives/card/card.css.ts +4 -0
  165. package/src/css/primitives/code/code.ts +3 -1
  166. package/src/css/primitives/code/types.ts +2 -1
  167. package/src/css/primitives/container/container.ts +3 -1
  168. package/src/css/primitives/heading/heading.ts +4 -1
  169. package/src/css/primitives/heading/types.ts +3 -1
  170. package/src/css/primitives/kbd/kbd.ts +1 -1
  171. package/src/css/primitives/kbd/types.ts +1 -1
  172. package/src/css/primitives/label/label.ts +4 -1
  173. package/src/css/primitives/label/types.ts +3 -1
  174. package/src/css/primitives/switch/switch.css.ts +1 -1
  175. package/src/css/primitives/text/text.ts +6 -1
  176. package/src/css/primitives/text/types.ts +5 -2
  177. package/src/theme/v3/defaultFonts.ts +6 -6
  178. package/src/theme/v3/defaultTokens.ts +1 -1
  179. package/bin/sanity-ui.cjs +0 -5
  180. package/dist/ui.css +0 -1
  181. package/src/cli/buildCommand.ts +0 -10
  182. package/src/cli/index.ts +0 -26
  183. package/src/core/components/autocomplete/index.ts +0 -2
  184. package/src/core/components/index.ts +0 -10
  185. package/src/core/helpers/index.ts +0 -5
  186. package/src/core/hooks/index.ts +0 -13
  187. package/src/core/observers/index.ts +0 -2
  188. package/src/core/primitives/index.ts +0 -30
  189. package/src/core/types/avatar.ts +0 -16
  190. package/src/core/types/card.ts +0 -4
  191. package/src/core/types/index.ts +0 -15
  192. package/src/core/types/popover.ts +0 -4
  193. package/src/core/utils/index.ts +0 -4
  194. package/src/css/__theme/index.ts +0 -16
  195. package/src/css/__theme/lib/contract/buildVarContract.ts +0 -78
  196. package/src/css/__theme/lib/contract/index.ts +0 -4
  197. package/src/css/__theme/lib/contract/types.ts +0 -17
  198. package/src/css/__theme/resolveTheme.ts +0 -865
  199. package/src/css/components/index.ts +0 -6
  200. package/src/css/primitives/index.ts +0 -24
  201. package/src/css/props/index.ts +0 -37
  202. package/src/css/utils/srOnly/index.ts +0 -1
  203. /package/src/core/{global.ts → __DEV__.ts} +0 -0
  204. /package/src/core/{types/dialog.ts → components/dialog/types.ts} +0 -0
  205. /package/src/core/observers/{resizeObserver.ts → resize.ts} +0 -0
  206. /package/src/core/{types/badge.ts → primitives/badge/types2.ts} +0 -0
  207. /package/src/core/{types/box.ts → primitives/box/types.ts} +0 -0
  208. /package/src/core/{types/button.ts → primitives/button/types.ts} +0 -0
  209. /package/src/core/{types/flex.ts → primitives/flex/types.ts} +0 -0
  210. /package/src/core/{types/grid.ts → primitives/grid/types.ts} +0 -0
  211. /package/src/core/{components → primitives}/skeleton/__workshop__/delay.tsx +0 -0
  212. /package/src/core/{components → primitives}/skeleton/__workshop__/skeleton.tsx +0 -0
  213. /package/src/core/{components → primitives}/skeleton/index.ts +0 -0
  214. /package/src/core/types/{text.ts → textAlign.ts} +0 -0
  215. /package/src/css/{utils → primitives/srOnly}/index.ts +0 -0
  216. /package/src/css/{utils → primitives}/srOnly/srOnly.css.ts +0 -0
  217. /package/src/css/{utils → primitives}/srOnly/srOnly.ts +0 -0
@@ -1,10 +1,9 @@
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, useRef, useImperativeHandle, 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, _arrow, vars, _arrowSvg, _arrowStrokeMask, _arrowStroke, _arrowShape, box, text, textOverflow, animatedSpinnerIcon, spinner, button, buttonLoadingBox, card, code, kbd, 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";
@@ -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;
@@ -363,113 +180,6 @@ function useResponsiveProp(val, defaultVal) {
363
180
  const [t1, setCache] = useState(t0), [cachedVal, cachedHash] = t1, hash = JSON.stringify(val ?? defaultVal);
364
181
  return hash !== cachedHash && setCache([_getResponsiveProp(val, defaultVal), hash]), cachedVal;
365
182
  }
366
- function moveTowardsLength(movingPoint, targetPoint, amount) {
367
- const width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
368
- return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
369
- }
370
- function moveTowardsFractional(movingPoint, targetPoint, fraction) {
371
- return {
372
- x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
373
- y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
374
- };
375
- }
376
- function getRoundedCommands(points) {
377
- const len = points.length, cmds = [];
378
- for (let i = 0; i < len; i += 1) {
379
- const point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
380
- if (prevPoint && point.radius) {
381
- 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);
382
- cmds.push({
383
- type: "point",
384
- ...curveStart
385
- }), cmds.push({
386
- type: "curve",
387
- curveEnd,
388
- startControl,
389
- endControl
390
- });
391
- } else
392
- cmds.push({
393
- type: "point",
394
- ...point
395
- });
396
- }
397
- return cmds;
398
- }
399
- function compileCommands(cmds) {
400
- 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(" ");
401
- }
402
- const DEFAULT_ARROW_ELEMENT = "div";
403
- function Arrow(props) {
404
- const $ = c(34), t0 = props;
405
- let h, rest, style, t1, t2, w;
406
- $[0] !== t0 ? ({
407
- as: t1,
408
- width: w,
409
- height: h,
410
- radius: t2,
411
- style,
412
- ...rest
413
- } = 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]);
414
- const Element = t1 === void 0 ? DEFAULT_ARROW_ELEMENT : t1, radius = t2 === void 0 ? 0 : t2, center = w / 2;
415
- let t3;
416
- const points = [{
417
- x: 0,
418
- y: 0
419
- }, {
420
- x: radius,
421
- y: 0,
422
- radius
423
- }, {
424
- x: center,
425
- y: h - 1,
426
- radius
427
- }, {
428
- x: w - radius,
429
- y: 0,
430
- radius
431
- }, {
432
- x: w,
433
- y: 0
434
- }], cmds = getRoundedCommands(points);
435
- t3 = compileCommands(cmds);
436
- const path = t3, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`;
437
- let t4;
438
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = _arrow(), $[7] = t4) : t4 = $[7];
439
- const t5 = `${w}px`;
440
- let t6;
441
- $[8] !== t5 ? (t6 = assignInlineVars({
442
- [vars.arrow.size]: t5
443
- }), $[8] = t5, $[9] = t6) : t6 = $[9];
444
- let t7;
445
- $[10] !== style || $[11] !== t6 ? (t7 = {
446
- ...style,
447
- ...t6
448
- }, $[10] = style, $[11] = t6, $[12] = t7) : t7 = $[12];
449
- let t8;
450
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = _arrowSvg(), $[13] = t8) : t8 = $[13];
451
- const t9 = `0 0 ${w} ${w}`;
452
- let t10;
453
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t10 = _arrowStrokeMask(), $[14] = t10) : t10 = $[14];
454
- let t11;
455
- $[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];
456
- let t12;
457
- $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = _arrowStroke(), $[17] = t12) : t12 = $[17];
458
- let t13;
459
- $[18] !== strokePath ? (t13 = /* @__PURE__ */ jsx("path", { className: t12, d: strokePath, mask: "url(#stroke-mask)" }), $[18] = strokePath, $[19] = t13) : t13 = $[19];
460
- let t14;
461
- $[20] === Symbol.for("react.memo_cache_sentinel") ? (t14 = _arrowShape(), $[20] = t14) : t14 = $[20];
462
- let t15;
463
- $[21] !== fillPath ? (t15 = /* @__PURE__ */ jsx("path", { className: t14, d: fillPath }), $[21] = fillPath, $[22] = t15) : t15 = $[22];
464
- let t16;
465
- $[23] !== t11 || $[24] !== t13 || $[25] !== t15 || $[26] !== t9 || $[27] !== w ? (t16 = /* @__PURE__ */ jsxs("svg", { className: t8, width: w, height: w, viewBox: t9, children: [
466
- t11,
467
- t13,
468
- t15
469
- ] }), $[23] = t11, $[24] = t13, $[25] = t15, $[26] = t9, $[27] = w, $[28] = t16) : t16 = $[28];
470
- let t17;
471
- 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;
472
- }
473
183
  const DEFAULT_BOX_ELEMENT = "div";
474
184
  function Box(props) {
475
185
  const $ = c(154), t0 = props;
@@ -632,8 +342,8 @@ function Box(props) {
632
342
  }
633
343
  const DEFAULT_TEXT_ELEMENT = "div";
634
344
  function Text(props) {
635
- const $ = c(30), t0 = props;
636
- 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;
637
347
  $[0] !== t0 ? ({
638
348
  accent,
639
349
  align,
@@ -641,31 +351,33 @@ function Text(props) {
641
351
  children,
642
352
  className,
643
353
  flex,
354
+ maxWidth: t2,
644
355
  muted,
645
- size: t2,
356
+ size: t3,
646
357
  textOverflow: textOverflowProp,
647
- weight: t3,
358
+ weight: t4,
648
359
  ...rest
649
- } = 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]);
650
- const Element = t1 === void 0 ? DEFAULT_TEXT_ELEMENT : t1, size2 = t2 === void 0 ? 2 : t2, weight = t3 === void 0 ? "regular" : t3;
651
- let t4;
652
- $[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({
653
364
  className,
654
365
  accent,
655
366
  align,
656
367
  flex,
368
+ maxWidth,
657
369
  muted,
658
370
  size: size2,
659
371
  weight
660
- }), $[12] = accent, $[13] = align, $[14] = className, $[15] = flex, $[16] = muted, $[17] = size2, $[18] = weight, $[19] = t4) : t4 = $[19];
661
- let t5;
662
- $[20] !== textOverflowProp ? (t5 = textOverflow({
663
- textOverflow: textOverflowProp
664
- }), $[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];
665
373
  let t6;
666
- $[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];
667
377
  let t7;
668
- 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;
669
381
  }
670
382
  function AnimatedSpinnerIcon(props) {
671
383
  const $ = c(5);
@@ -705,7 +417,6 @@ function Button(props) {
705
417
  children,
706
418
  className,
707
419
  disabled,
708
- display = "inline-flex",
709
420
  flex,
710
421
  fontSize = 1,
711
422
  gap = props.space ?? props.padding ?? 3,
@@ -745,7 +456,6 @@ function Button(props) {
745
456
  ...rest,
746
457
  className: button({
747
458
  className,
748
- display,
749
459
  flex,
750
460
  mode,
751
461
  radius,
@@ -764,7 +474,7 @@ function Button(props) {
764
474
  isValidElement(IconComponent) && IconComponent,
765
475
  isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})
766
476
  ] }),
767
- 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 }) }),
768
478
  IconRightComponent && /* @__PURE__ */ jsxs(Text, { as: "span", flex: "none", muted: !0, size: fontSize, children: [
769
479
  isValidElement(IconRightComponent) && IconRightComponent,
770
480
  isValidElementType(IconRightComponent) && /* @__PURE__ */ jsx(IconRightComponent, {})
@@ -818,88 +528,131 @@ function Card(props) {
818
528
  }
819
529
  return node;
820
530
  }
821
- const LazyRefractor = lazy(() => import("./refractor.js")), DEFAULT_CODE_ELEMENT = "pre";
822
- function Code(props) {
823
- const $ = c(25), t0 = props;
824
- let children, className, languageProp, rest, t1, t2, t3;
825
- $[0] !== t0 ? ({
826
- as: t1,
827
- children,
828
- className,
829
- language: languageProp,
830
- size: t2,
831
- weight: t3,
832
- ...rest
833
- } = 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]);
834
- 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;
835
- let t4;
836
- $[8] !== className || $[9] !== size2 || $[10] !== weight ? (t4 = code({
837
- className,
838
- size: size2,
839
- weight
840
- }), $[8] = className, $[9] = size2, $[10] = weight, $[11] = t4) : t4 = $[11];
841
- let t5;
842
- $[12] !== children ? (t5 = /* @__PURE__ */ jsx("code", { children }), $[12] = children, $[13] = t5) : t5 = $[13];
843
- let t6;
844
- $[14] !== children || $[15] !== language ? (t6 = /* @__PURE__ */ jsx(LazyRefractor, { language, value: children }), $[14] = children, $[15] = language, $[16] = t6) : t6 = $[16];
845
- let t7;
846
- $[17] !== t5 || $[18] !== t6 ? (t7 = /* @__PURE__ */ jsx(Suspense, { fallback: t5, children: t6 }), $[17] = t5, $[18] = t6, $[19] = t7) : t7 = $[19];
847
- let t8;
848
- 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;
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);
849
541
  }
850
- const DEFAULT_FLEX_ELEMENT = "div";
851
- function Flex(props) {
852
- const $ = c(14), t0 = props;
853
- let align, justify, rest, t1, t2, wrap;
854
- $[0] !== t0 ? ({
855
- align,
856
- as: t1,
857
- direction: t2,
858
- justify,
859
- wrap,
860
- ...rest
861
- } = 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]);
862
- const as = t1 === void 0 ? DEFAULT_FLEX_ELEMENT : t1, direction = t2 === void 0 ? "row" : t2;
863
- let t3;
864
- 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;
542
+ function usePrefersReducedMotion(t0) {
543
+ return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$5 : t0);
865
544
  }
866
- const DEFAULT_GRID_ELEMENT = "div";
867
- function Grid(props) {
868
- const $ = c(8), t0 = props;
869
- let children, rest, t1;
870
- $[0] !== t0 ? ({
871
- as: t1,
545
+ function _temp$5() {
546
+ return !1;
547
+ }
548
+ const origin = {
549
+ name: "@sanity/ui/origin",
550
+ fn({
551
+ middlewareData,
552
+ placement,
553
+ rects
554
+ }) {
555
+ const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
556
+ if (floatingWidth <= 0 || floatingHeight <= 0)
557
+ return {};
558
+ const isVerticalPlacement = ["bottom", "top"].includes(side), {
559
+ originX,
560
+ originY
561
+ } = isVerticalPlacement ? {
562
+ originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),
563
+ originY: side === "bottom" ? 0 : 1
564
+ } : {
565
+ originX: side === "left" ? 1 : 0,
566
+ originY: clamp(0.5 - shiftY / floatingHeight, 0, 1)
567
+ };
568
+ return {
569
+ data: {
570
+ originX,
571
+ originY
572
+ }
573
+ };
574
+ }
575
+ };
576
+ function clamp(num, min, max) {
577
+ return Math.min(Math.max(num, min), max);
578
+ }
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;
588
+ }
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]);
596
+ }
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;
605
+ }
606
+ function Portal(props) {
607
+ const $ = c(6), {
872
608
  children,
873
- ...rest
874
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1) : (children = $[1], rest = $[2], t1 = $[3]);
875
- const as = t1 === void 0 ? DEFAULT_GRID_ELEMENT : t1;
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];
876
616
  let t2;
877
- 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;
617
+ return $[3] !== portalElement || $[4] !== t1 ? (t2 = createPortal(t1, portalElement), $[3] = portalElement, $[4] = t1, $[5] = t2) : t2 = $[5], t2;
878
618
  }
879
- const DEFAULT_KBD_ELEMENT = "kbd";
880
- function KBD(props) {
881
- const $ = c(22), t0 = props;
882
- let children, className, rest, t1, t2, t3, t4, t5;
883
- $[0] !== t0 ? ({
884
- as: t1,
619
+ function PortalProvider(props) {
620
+ const $ = c(7), {
621
+ boundaryElement,
885
622
  children,
886
- className,
887
- display: t2,
888
- fontSize: t3,
889
- padding: t4,
890
- radius: t5,
891
- ...rest
892
- } = 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]);
893
- 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;
894
- let t7;
895
- $[9] !== className || $[10] !== radius ? (t7 = kbd({
896
- className,
897
- radius
898
- }), $[9] = className, $[10] = radius, $[11] = t7) : t7 = $[11];
899
- let t8;
900
- $[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];
901
- let t9;
902
- 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;
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;
628
+ let t3;
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;
636
+ let t4;
637
+ return $[4] !== children || $[5] !== value ? (t4 = /* @__PURE__ */ jsx(PortalContext.Provider, { value, children }), $[4] = children, $[5] = value, $[6] = t4) : t4 = $[6], t4;
638
+ }
639
+ function _temp2$2() {
640
+ return null;
641
+ }
642
+ function _temp$4() {
643
+ return document.body;
644
+ }
645
+ const emptySubscribe = () => () => {
646
+ };
647
+ function useUnique(value) {
648
+ const valueRef = useRef(value);
649
+ return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
650
+ }
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]);
903
656
  }
904
657
  function getLayerContext(contextValue) {
905
658
  if (!isRecord(contextValue) || contextValue.version !== 0)
@@ -964,6 +717,62 @@ function LayerCard(props) {
964
717
  let t10;
965
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;
966
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
+ }
967
776
  function LayerProvider(props) {
968
777
  const $ = c(19), {
969
778
  children,
@@ -984,13 +793,13 @@ function LayerProvider(props) {
984
793
  [childLevel]: prevLen + 1
985
794
  };
986
795
  return setSize(Object.keys(nextState).length), nextState;
987
- }) : setSize(_temp$2), () => {
796
+ }) : setSize(_temp$3), () => {
988
797
  childLevel !== void 0 ? setChildLayers((state_0) => {
989
798
  const nextState_0 = {
990
799
  ...state_0
991
800
  };
992
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;
993
- }) : setSize(_temp2$2), parentDispose?.();
802
+ }) : setSize(_temp2$1), parentDispose?.();
994
803
  };
995
804
  }, $[3] = parentRegisterChild, $[4] = setChildLayers, $[5] = t3) : t3 = $[5];
996
805
  const registerChild = t3;
@@ -1009,10 +818,10 @@ function LayerProvider(props) {
1009
818
  let t8;
1010
819
  return $[16] !== children || $[17] !== value ? (t8 = /* @__PURE__ */ jsx(LayerContext.Provider, { value, children }), $[16] = children, $[17] = value, $[18] = t8) : t8 = $[18], t8;
1011
820
  }
1012
- function _temp2$2(v_0) {
821
+ function _temp2$1(v_0) {
1013
822
  return v_0 - 1;
1014
823
  }
1015
- function _temp$2(v) {
824
+ function _temp$3(v) {
1016
825
  return v + 1;
1017
826
  }
1018
827
  const DEFAULT_LAYER_ELEMENT = "div";
@@ -1031,163 +840,6 @@ function Layer(props) {
1031
840
  let t4;
1032
841
  return $[9] !== t3 || $[10] !== zOffset ? (t4 = /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: t3 }), $[9] = t3, $[10] = zOffset, $[11] = t4) : t4 = $[11], t4;
1033
842
  }
1034
- const origin = {
1035
- name: "@sanity/ui/origin",
1036
- fn({
1037
- middlewareData,
1038
- placement,
1039
- rects
1040
- }) {
1041
- const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
1042
- if (floatingWidth <= 0 || floatingHeight <= 0)
1043
- return {};
1044
- const isVerticalPlacement = ["bottom", "top"].includes(side), {
1045
- originX,
1046
- originY
1047
- } = isVerticalPlacement ? {
1048
- originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),
1049
- originY: side === "bottom" ? 0 : 1
1050
- } : {
1051
- originX: side === "left" ? 1 : 0,
1052
- originY: clamp(0.5 - shiftY / floatingHeight, 0, 1)
1053
- };
1054
- return {
1055
- data: {
1056
- originX,
1057
- originY
1058
- }
1059
- };
1060
- }
1061
- };
1062
- function clamp(num, min, max) {
1063
- return Math.min(Math.max(num, min), max);
1064
- }
1065
- const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null), DEFAULT_VALUE = {
1066
- version: 0,
1067
- element: null
1068
- };
1069
- function useBoundaryElement() {
1070
- const value = useContext(BoundaryElementContext);
1071
- if (value && (!isRecord(value) || value.version !== 0))
1072
- throw new Error("useBoundaryElement(): the context value is not compatible");
1073
- return value || DEFAULT_VALUE;
1074
- }
1075
- function findMaxBreakpoints(media2, width) {
1076
- const ret = [];
1077
- for (let i = 0; i < media2.length; i += 1)
1078
- media2[i] > width && ret.push(i);
1079
- return ret;
1080
- }
1081
- function findMinBreakpoints(media2, width) {
1082
- const ret = [];
1083
- for (let i = 0; i < media2.length; i += 1)
1084
- media2[i] <= width && ret.push(i);
1085
- return ret;
1086
- }
1087
- const DEFAULT_ELEMENT_QUERY_ELEMENT = "div", DEFAULT_BREAKPOINTS = Object.values(BREAKPOINTS);
1088
- function ElementQuery(props) {
1089
- const $ = c(21), t0 = props;
1090
- let children, forwardedRef, mediaProp, rest, t1;
1091
- $[0] !== t0 ? ({
1092
- as: t1,
1093
- children,
1094
- media: mediaProp,
1095
- ref: forwardedRef,
1096
- ...rest
1097
- } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = mediaProp, $[4] = rest, $[5] = t1) : (children = $[1], forwardedRef = $[2], mediaProp = $[3], rest = $[4], t1 = $[5]);
1098
- const Element = t1 === void 0 ? DEFAULT_ELEMENT_QUERY_ELEMENT : t1, breakpoints = mediaProp ?? DEFAULT_BREAKPOINTS, [element, setElement] = useState(null), elementSize = useElementSize(element);
1099
- let t2;
1100
- t2 = elementSize?.border.width ?? window.innerWidth;
1101
- const width = t2;
1102
- let t3, t4;
1103
- if ($[6] !== breakpoints || $[7] !== width) {
1104
- const eq = findMaxBreakpoints(breakpoints, width);
1105
- t4 = eq.length ? eq.join(" ") : void 0, $[6] = breakpoints, $[7] = width, $[8] = t4;
1106
- } else
1107
- t4 = $[8];
1108
- t3 = t4;
1109
- const max = t3;
1110
- let t5, t6;
1111
- if ($[9] !== breakpoints || $[10] !== width) {
1112
- const eq_0 = findMinBreakpoints(breakpoints, width);
1113
- t6 = eq_0.length ? eq_0.join(" ") : void 0, $[9] = breakpoints, $[10] = width, $[11] = t6;
1114
- } else
1115
- t6 = $[11];
1116
- t5 = t6;
1117
- const min = t5;
1118
- let t7, t8;
1119
- $[12] !== element ? (t7 = () => element, t8 = [element], $[12] = element, $[13] = t7, $[14] = t8) : (t7 = $[13], t8 = $[14]), useImperativeHandle(forwardedRef, t7, t8);
1120
- let t9;
1121
- 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;
1122
- }
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,269 +1366,95 @@ 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;
1602
- }
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);
1606
- }
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);
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");
1623
1402
  }
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,
1403
+ function _temp$1() {
1404
+ return EMPTY_ARRAY;
1405
+ }
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);
1418
+ }
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;
1435
+ $[9] !== className || $[10] !== radius ? (t7 = kbd({
1436
+ className,
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];
1666
1441
  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;
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;
1679
1443
  }
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,
1688
- 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);
1833
- }
1834
- const DEFAULT_HOTKEYS_ELEMENT = "kbd";
1835
- function Hotkeys(props) {
1836
- const $ = c(27), t0 = props;
1837
- let fontSize, gap, gapX, gapY, keys, padding, radius, rest, t1, t2;
1838
- $[0] !== t0 ? ({
1839
- as: t1,
1840
- fontSize,
1841
- gap,
1842
- gapX,
1843
- gapY,
1844
- keys,
1845
- padding,
1846
- radius,
1847
- space: t2,
1444
+ const DEFAULT_HOTKEYS_ELEMENT = "kbd";
1445
+ function Hotkeys(props) {
1446
+ const $ = c(27), t0 = props;
1447
+ let fontSize, gap, gapX, gapY, keys, padding, radius, rest, t1, t2;
1448
+ $[0] !== t0 ? ({
1449
+ as: t1,
1450
+ fontSize,
1451
+ gap,
1452
+ gapX,
1453
+ gapY,
1454
+ keys,
1455
+ padding,
1456
+ radius,
1457
+ space: t2,
1848
1458
  ...rest
1849
1459
  } = t0, $[0] = t0, $[1] = fontSize, $[2] = gap, $[3] = gapX, $[4] = gapY, $[5] = keys, $[6] = padding, $[7] = radius, $[8] = rest, $[9] = t1, $[10] = t2) : (fontSize = $[1], gap = $[2], gapX = $[3], gapY = $[4], keys = $[5], padding = $[6], radius = $[7], rest = $[8], t1 = $[9], t2 = $[10]);
1850
1460
  const as = t1 === void 0 ? DEFAULT_HOTKEYS_ELEMENT : t1, space = t2 === void 0 ? 1 : t2;
@@ -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,