@sanity/ui 3.0.0-static.27 → 3.0.0-static.29

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 (229) hide show
  1. package/README.md +5 -8
  2. package/dist/_chunks-cjs/_visual-editing.cjs +744 -874
  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 +788 -917
  7. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  8. package/dist/_chunks-es/refractor.js +1 -1
  9. package/dist/{css.cjs → css/index.cjs} +72 -53
  10. package/dist/css/index.cjs.map +1 -0
  11. package/dist/css/index.css +1 -0
  12. package/dist/{css.d.ts → css/index.d.cts} +26 -8
  13. package/dist/{css.d.cts → css/index.d.ts} +26 -8
  14. package/dist/{css.js → css/index.js} +72 -53
  15. package/dist/css/index.js.map +1 -0
  16. package/dist/css/layers.css +4 -0
  17. package/dist/css/primitives/popover/popover.css +4 -0
  18. package/dist/index.cjs +2049 -1811
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +62 -26
  21. package/dist/index.d.ts +62 -26
  22. package/dist/index.js +2056 -1819
  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 +14 -19
  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 +15 -19
  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 +21 -17
  59. package/src/core/components/toast/toastLayer.tsx +3 -2
  60. package/src/core/components/toast/toastProvider.tsx +15 -11
  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 +84 -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/root/Root.tsx +89 -0
  120. package/src/core/primitives/root/__workshop__/boundary.tsx +5 -0
  121. package/src/core/primitives/root/__workshop__/index.ts +8 -0
  122. package/src/core/primitives/root/index.ts +1 -0
  123. package/src/core/primitives/select/select.tsx +2 -2
  124. package/src/core/{components → primitives}/skeleton/__workshop__/index.ts +1 -1
  125. package/src/core/{components → primitives}/skeleton/codeSkeleton.tsx +1 -1
  126. package/src/core/{components → primitives}/skeleton/headingSkeleton.tsx +1 -1
  127. package/src/core/{components → primitives}/skeleton/labelSkeleton.tsx +1 -1
  128. package/src/core/{components → primitives}/skeleton/skeleton.tsx +7 -8
  129. package/src/core/{components → primitives}/skeleton/textSkeleton.tsx +1 -1
  130. package/src/core/primitives/spinner/spinner.tsx +1 -1
  131. package/src/core/primitives/srOnly/srOnly.tsx +1 -1
  132. package/src/core/primitives/stack/stack.tsx +1 -1
  133. package/src/core/primitives/switch/switch.tsx +1 -6
  134. package/src/core/primitives/text/__workshop__/colored.tsx +2 -2
  135. package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +17 -42
  136. package/src/core/primitives/text/text.tsx +3 -1
  137. package/src/core/primitives/textArea/__workshop__/plain.tsx +2 -2
  138. package/src/core/primitives/textArea/textArea.tsx +2 -2
  139. package/src/core/primitives/textInput/textInput.tsx +3 -2
  140. package/src/core/primitives/tooltip/constants.ts +1 -1
  141. package/src/core/primitives/tooltip/tooltip.tsx +5 -3
  142. package/src/core/primitives/tooltip/tooltipLayer.tsx +1 -1
  143. package/src/core/primitives/types.ts +8 -10
  144. package/src/core/types/radius.ts +1 -1
  145. package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +9 -5
  146. package/src/core/utils/elementQuery/elementQuery.tsx +2 -2
  147. package/src/core/utils/portal/portal.tsx +1 -1
  148. package/src/css/components/dialog/dialog.css.ts +26 -1
  149. package/src/css/components/dialog/dialog.ts +27 -7
  150. package/src/css/components/skeleton/skeleton.ts +3 -1
  151. package/src/css/components/skeleton/types.ts +3 -1
  152. package/src/css/components/toast/toast.css.ts +1 -0
  153. package/src/css/defaultTheme.css.ts +55 -2
  154. package/src/css/index.ts +77 -5
  155. package/src/css/primitives/_input/input.ts +2 -1
  156. package/src/css/primitives/_input/types.ts +2 -1
  157. package/src/css/primitives/_selectable/_selectable.css.ts +32 -24
  158. package/src/css/primitives/_selectable/selectable.ts +1 -1
  159. package/src/css/primitives/_selectable/types.ts +1 -1
  160. package/src/css/primitives/avatar/avatar.css.ts +8 -4
  161. package/src/css/primitives/avatar/avatar.ts +1 -1
  162. package/src/css/primitives/badge/types.ts +0 -2
  163. package/src/css/primitives/box/box.ts +35 -37
  164. package/src/css/primitives/box/types.ts +34 -36
  165. package/src/css/primitives/button/button.css.ts +4 -0
  166. package/src/css/primitives/button/button.ts +5 -2
  167. package/src/css/primitives/button/types.ts +4 -11
  168. package/src/css/primitives/card/__workshop__/color.tsx +70 -0
  169. package/src/css/primitives/card/__workshop__/index.ts +14 -0
  170. package/src/css/primitives/card/card.css.ts +4 -0
  171. package/src/css/primitives/code/code.ts +3 -1
  172. package/src/css/primitives/code/types.ts +2 -1
  173. package/src/css/primitives/container/container.ts +3 -1
  174. package/src/css/primitives/heading/heading.ts +4 -1
  175. package/src/css/primitives/heading/types.ts +3 -1
  176. package/src/css/primitives/kbd/kbd.ts +1 -1
  177. package/src/css/primitives/kbd/types.ts +1 -1
  178. package/src/css/primitives/label/label.ts +4 -1
  179. package/src/css/primitives/label/types.ts +3 -1
  180. package/src/css/primitives/root/index.ts +2 -0
  181. package/src/css/primitives/root/root.css.ts +15 -0
  182. package/src/css/primitives/root/root.ts +17 -0
  183. package/src/css/primitives/root/types.ts +10 -0
  184. package/src/css/primitives/switch/switch.css.ts +1 -1
  185. package/src/css/primitives/text/text.ts +6 -1
  186. package/src/css/primitives/text/types.ts +5 -2
  187. package/src/theme/v3/defaultFonts.ts +6 -6
  188. package/src/theme/v3/defaultTokens.ts +1 -1
  189. package/bin/sanity-ui.cjs +0 -5
  190. package/dist/css.cjs.map +0 -1
  191. package/dist/css.js.map +0 -1
  192. package/dist/ui.css +0 -1
  193. package/src/cli/buildCommand.ts +0 -10
  194. package/src/cli/index.ts +0 -26
  195. package/src/core/components/autocomplete/index.ts +0 -2
  196. package/src/core/components/index.ts +0 -10
  197. package/src/core/helpers/index.ts +0 -5
  198. package/src/core/hooks/index.ts +0 -13
  199. package/src/core/observers/index.ts +0 -2
  200. package/src/core/primitives/index.ts +0 -30
  201. package/src/core/types/avatar.ts +0 -16
  202. package/src/core/types/card.ts +0 -4
  203. package/src/core/types/index.ts +0 -15
  204. package/src/core/types/popover.ts +0 -4
  205. package/src/core/utils/index.ts +0 -4
  206. package/src/css/__theme/index.ts +0 -16
  207. package/src/css/__theme/lib/contract/buildVarContract.ts +0 -78
  208. package/src/css/__theme/lib/contract/index.ts +0 -4
  209. package/src/css/__theme/lib/contract/types.ts +0 -17
  210. package/src/css/__theme/resolveTheme.ts +0 -865
  211. package/src/css/components/index.ts +0 -6
  212. package/src/css/primitives/index.ts +0 -24
  213. package/src/css/props/index.ts +0 -37
  214. package/src/css/utils/srOnly/index.ts +0 -1
  215. /package/src/core/{global.ts → __DEV__.ts} +0 -0
  216. /package/src/core/{types/dialog.ts → components/dialog/types.ts} +0 -0
  217. /package/src/core/observers/{resizeObserver.ts → resize.ts} +0 -0
  218. /package/src/core/{types/badge.ts → primitives/badge/types2.ts} +0 -0
  219. /package/src/core/{types/box.ts → primitives/box/types.ts} +0 -0
  220. /package/src/core/{types/button.ts → primitives/button/types.ts} +0 -0
  221. /package/src/core/{types/flex.ts → primitives/flex/types.ts} +0 -0
  222. /package/src/core/{types/grid.ts → primitives/grid/types.ts} +0 -0
  223. /package/src/core/{components → primitives}/skeleton/__workshop__/delay.tsx +0 -0
  224. /package/src/core/{components → primitives}/skeleton/__workshop__/skeleton.tsx +0 -0
  225. /package/src/core/{components → primitives}/skeleton/index.ts +0 -0
  226. /package/src/core/types/{text.ts → textAlign.ts} +0 -0
  227. /package/src/css/{utils → primitives/srOnly}/index.ts +0 -0
  228. /package/src/css/{utils → primitives}/srOnly/srOnly.css.ts +0 -0
  229. /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, _selectable, 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, 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;
@@ -630,42 +340,67 @@ function Box(props) {
630
340
  let t10;
631
341
  return $[149] !== Element || $[150] !== children || $[151] !== rest || $[152] !== t9 ? (t10 = /* @__PURE__ */ jsx(Element, { "data-ui": "Box", ...rest, className: t9, children }), $[149] = Element, $[150] = children, $[151] = rest, $[152] = t9, $[153] = t10) : t10 = $[153], t10;
632
342
  }
633
- const DEFAULT_TEXT_ELEMENT = "div";
634
- function Text(props) {
635
- const $ = c(30), t0 = props;
636
- let accent, align, children, className, flex, muted, rest, t1, t2, t3, textOverflowProp;
637
- $[0] !== t0 ? ({
343
+ const DEFAULT_SELECTABLE_ELEMENT = "button";
344
+ function Selectable(props) {
345
+ const $ = c(16), t0 = props;
346
+ let className, radius, rest, selected, t1, tone;
347
+ $[0] !== t0 ? ({
348
+ as: t1,
349
+ className,
350
+ radius,
351
+ selected,
352
+ tone,
353
+ ...rest
354
+ } = 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]);
355
+ const as = t1 === void 0 ? DEFAULT_SELECTABLE_ELEMENT : t1;
356
+ let t2;
357
+ $[7] !== className || $[8] !== radius || $[9] !== tone ? (t2 = _selectable({
358
+ className,
359
+ radius,
360
+ tone
361
+ }), $[7] = className, $[8] = radius, $[9] = tone, $[10] = t2) : t2 = $[10];
362
+ const t3 = selected ? "" : void 0;
363
+ let t4;
364
+ 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;
365
+ }
366
+ const DEFAULT_TEXT_ELEMENT = "div";
367
+ function Text(props) {
368
+ const $ = c(32), t0 = props;
369
+ let accent, align, children, className, flex, muted, rest, t1, t2, t3, t4, textOverflowProp;
370
+ $[0] !== t0 ? ({
638
371
  accent,
639
372
  align,
640
373
  as: t1,
641
374
  children,
642
375
  className,
643
376
  flex,
377
+ maxWidth: t2,
644
378
  muted,
645
- size: t2,
379
+ size: t3,
646
380
  textOverflow: textOverflowProp,
647
- weight: t3,
381
+ weight: t4,
648
382
  ...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({
383
+ } = 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]);
384
+ 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;
385
+ let t5;
386
+ $[13] !== accent || $[14] !== align || $[15] !== className || $[16] !== flex || $[17] !== maxWidth || $[18] !== muted || $[19] !== size2 || $[20] !== weight ? (t5 = text({
653
387
  className,
654
388
  accent,
655
389
  align,
656
390
  flex,
391
+ maxWidth,
657
392
  muted,
658
393
  size: size2,
659
394
  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];
395
+ }), $[13] = accent, $[14] = align, $[15] = className, $[16] = flex, $[17] = maxWidth, $[18] = muted, $[19] = size2, $[20] = weight, $[21] = t5) : t5 = $[21];
665
396
  let t6;
666
- $[22] !== children || $[23] !== t5 ? (t6 = /* @__PURE__ */ jsx("span", { className: t5, children }), $[22] = children, $[23] = t5, $[24] = t6) : t6 = $[24];
397
+ $[22] !== textOverflowProp ? (t6 = textOverflow({
398
+ textOverflow: textOverflowProp
399
+ }), $[22] = textOverflowProp, $[23] = t6) : t6 = $[23];
667
400
  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;
401
+ $[24] !== children || $[25] !== t6 ? (t7 = /* @__PURE__ */ jsx("span", { className: t6, children }), $[24] = children, $[25] = t6, $[26] = t7) : t7 = $[26];
402
+ let t8;
403
+ 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
404
  }
670
405
  function AnimatedSpinnerIcon(props) {
671
406
  const $ = c(5);
@@ -705,7 +440,6 @@ function Button(props) {
705
440
  children,
706
441
  className,
707
442
  disabled,
708
- display = "inline-flex",
709
443
  flex,
710
444
  fontSize = 1,
711
445
  gap = props.space ?? props.padding ?? 3,
@@ -745,7 +479,6 @@ function Button(props) {
745
479
  ...rest,
746
480
  className: button({
747
481
  className,
748
- display,
749
482
  flex,
750
483
  mode,
751
484
  radius,
@@ -764,7 +497,7 @@ function Button(props) {
764
497
  isValidElement(IconComponent) && IconComponent,
765
498
  isValidElementType(IconComponent) && /* @__PURE__ */ jsx(IconComponent, {})
766
499
  ] }),
767
- text2 && /* @__PURE__ */ jsx(Text, { align: textAlign, as: "span", flex: "none", muted, size: fontSize, textOverflow: textOverflow2, weight: textWeight, children: text2 }),
500
+ 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
501
  IconRightComponent && /* @__PURE__ */ jsxs(Text, { as: "span", flex: "none", muted: !0, size: fontSize, children: [
769
502
  isValidElement(IconRightComponent) && IconRightComponent,
770
503
  isValidElementType(IconRightComponent) && /* @__PURE__ */ jsx(IconRightComponent, {})
@@ -775,6 +508,64 @@ function Button(props) {
775
508
  }
776
509
  );
777
510
  }
511
+ function useMatchMedia(mediaQueryString, getServerSnapshot2) {
512
+ const $ = c(4);
513
+ useDebugValue(mediaQueryString);
514
+ let t0;
515
+ $[0] !== mediaQueryString ? (t0 = (onStoreChange) => {
516
+ const media2 = window.matchMedia(mediaQueryString);
517
+ return media2.addEventListener("change", onStoreChange), () => media2.removeEventListener("change", onStoreChange);
518
+ }, $[0] = mediaQueryString, $[1] = t0) : t0 = $[1];
519
+ let t1;
520
+ return $[2] !== mediaQueryString ? (t1 = () => window.matchMedia(mediaQueryString).matches, $[2] = mediaQueryString, $[3] = t1) : t1 = $[3], useSyncExternalStore(t0, t1, getServerSnapshot2);
521
+ }
522
+ function usePrefersReducedMotion(t0) {
523
+ return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$5 : t0);
524
+ }
525
+ function _temp$5() {
526
+ return !1;
527
+ }
528
+ const origin = {
529
+ name: "@sanity/ui/origin",
530
+ fn({
531
+ middlewareData,
532
+ placement,
533
+ rects
534
+ }) {
535
+ const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
536
+ if (floatingWidth <= 0 || floatingHeight <= 0)
537
+ return {};
538
+ const isVerticalPlacement = ["bottom", "top"].includes(side), {
539
+ originX,
540
+ originY
541
+ } = isVerticalPlacement ? {
542
+ originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),
543
+ originY: side === "bottom" ? 0 : 1
544
+ } : {
545
+ originX: side === "left" ? 1 : 0,
546
+ originY: clamp(0.5 - shiftY / floatingHeight, 0, 1)
547
+ };
548
+ return {
549
+ data: {
550
+ originX,
551
+ originY
552
+ }
553
+ };
554
+ }
555
+ };
556
+ function clamp(num, min, max) {
557
+ return Math.min(Math.max(num, min), max);
558
+ }
559
+ const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null), DEFAULT_VALUE = {
560
+ version: 0,
561
+ element: null
562
+ };
563
+ function useBoundaryElement() {
564
+ const value = useContext(BoundaryElementContext);
565
+ if (value && (!isRecord(value) || value.version !== 0))
566
+ throw new Error("useBoundaryElement(): the context value is not compatible");
567
+ return value || DEFAULT_VALUE;
568
+ }
778
569
  function useCard() {
779
570
  return useContext(CardContext);
780
571
  }
@@ -818,88 +609,73 @@ function Card(props) {
818
609
  }
819
610
  return node;
820
611
  }
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;
849
- }
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;
612
+ const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
613
+ globalScope[elementKey] = null;
614
+ const defaultContextValue = {
615
+ version: 0,
616
+ boundaryElement: null,
617
+ get element() {
618
+ return typeof document > "u" ? null : (globalScope[elementKey] || (globalScope[elementKey] = document.createElement("div"), globalScope[elementKey].setAttribute("data-portal", ""), document.body.appendChild(globalScope[elementKey])), globalScope[elementKey]);
619
+ }
620
+ }, PortalContext = createGlobalScopedContext(key, defaultContextValue);
621
+ function usePortal() {
622
+ const value = useContext(PortalContext);
623
+ if (!value)
624
+ throw new Error("usePortal(): missing context value");
625
+ if (!isRecord(value) || value.version !== 0)
626
+ throw new Error("usePortal(): the context value is not compatible");
627
+ return value;
865
628
  }
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,
629
+ function Portal(props) {
630
+ const $ = c(6), {
872
631
  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;
632
+ __unstable_name: name
633
+ } = props, card2 = useCard(), portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
634
+ if (!portalElement)
635
+ return null;
636
+ const t0 = card2?.scheme || "light";
637
+ let t1;
638
+ $[0] !== children || $[1] !== t0 ? (t1 = /* @__PURE__ */ jsx(CardProvider, { tone: "transparent", scheme: t0, children }), $[0] = children, $[1] = t0, $[2] = t1) : t1 = $[2];
876
639
  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;
640
+ return $[3] !== portalElement || $[4] !== t1 ? (t2 = createPortal(t1, portalElement), $[3] = portalElement, $[4] = t1, $[5] = t2) : t2 = $[5], t2;
878
641
  }
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,
642
+ function PortalProvider(props) {
643
+ const $ = c(7), {
644
+ boundaryElement,
885
645
  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;
646
+ element,
647
+ __unstable_elements: elementsProp
648
+ } = props, elements = useUnique(elementsProp), fallbackElement = useSyncExternalStore(emptySubscribe, _temp$4, _temp2$2);
649
+ let t0;
650
+ const t1 = boundaryElement || null, t2 = element || fallbackElement;
651
+ let t3;
652
+ $[0] !== elements || $[1] !== t1 || $[2] !== t2 ? (t3 = {
653
+ version: 0,
654
+ boundaryElement: t1,
655
+ element: t2,
656
+ elements
657
+ }, $[0] = elements, $[1] = t1, $[2] = t2, $[3] = t3) : t3 = $[3], t0 = t3;
658
+ const value = t0;
659
+ let t4;
660
+ return $[4] !== children || $[5] !== value ? (t4 = /* @__PURE__ */ jsx(PortalContext.Provider, { value, children }), $[4] = children, $[5] = value, $[6] = t4) : t4 = $[6], t4;
661
+ }
662
+ function _temp2$2() {
663
+ return null;
664
+ }
665
+ function _temp$4() {
666
+ return document.body;
667
+ }
668
+ const emptySubscribe = () => () => {
669
+ };
670
+ function useUnique(value) {
671
+ const valueRef = useRef(value);
672
+ return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
673
+ }
674
+ function _isEqual(objA, objB) {
675
+ if (!objA || !objB)
676
+ return objA === objB;
677
+ const keysA = Object.keys(objA), keysB = Object.keys(objB);
678
+ return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
903
679
  }
904
680
  function getLayerContext(contextValue) {
905
681
  if (!isRecord(contextValue) || contextValue.version !== 0)
@@ -964,59 +740,115 @@ function LayerCard(props) {
964
740
  let t10;
965
741
  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
742
  }
967
- function LayerProvider(props) {
968
- const $ = c(19), {
969
- children,
970
- zOffset: t0
971
- } = props, zOffsetProp = t0 === void 0 ? 0 : t0, parentContextValue = useContext(LayerContext);
972
- let t1;
973
- $[0] !== parentContextValue ? (t1 = parentContextValue && getLayerContext(parentContextValue), $[0] = parentContextValue, $[1] = t1) : t1 = $[1];
974
- const parent = t1, parentRegisterChild = parent?.registerChild, level = (parent?.level ?? 0) + 1, zOffset = useResponsiveProp(zOffsetProp), maxMediaIndex = Object.values(zOffset).length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + (zOffset[mediaIndex] ?? 0) : zOffset[mediaIndex] ?? 0;
975
- let t2;
976
- $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[2] = t2) : t2 = $[2];
977
- const [, setChildLayers] = useState(t2), [size2, setSize] = useState(0), isTopLayer = size2 === 0;
978
- let t3;
979
- $[3] !== parentRegisterChild || $[4] !== setChildLayers ? (t3 = (childLevel) => {
980
- const parentDispose = parentRegisterChild?.(childLevel);
981
- return childLevel !== void 0 ? setChildLayers((state) => {
982
- const prevLen = state[childLevel] ?? 0, nextState = {
983
- ...state,
984
- [childLevel]: prevLen + 1
985
- };
986
- return setSize(Object.keys(nextState).length), nextState;
987
- }) : setSize(_temp$2), () => {
988
- childLevel !== void 0 ? setChildLayers((state_0) => {
989
- const nextState_0 = {
990
- ...state_0
991
- };
992
- 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?.();
994
- };
995
- }, $[3] = parentRegisterChild, $[4] = setChildLayers, $[5] = t3) : t3 = $[5];
996
- const registerChild = t3;
997
- let t4, t5;
998
- $[6] !== level || $[7] !== parentRegisterChild ? (t4 = () => parentRegisterChild?.(level), t5 = [level, parentRegisterChild], $[6] = level, $[7] = parentRegisterChild, $[8] = t4, $[9] = t5) : (t4 = $[8], t5 = $[9]), useEffect(t4, t5);
999
- let t6, t7;
1000
- $[10] !== isTopLayer || $[11] !== level || $[12] !== registerChild || $[13] !== size2 || $[14] !== zIndex ? (t7 = {
1001
- version: 0,
1002
- isTopLayer,
1003
- level,
1004
- registerChild,
1005
- size: size2,
1006
- zIndex
1007
- }, $[10] = isTopLayer, $[11] = level, $[12] = registerChild, $[13] = size2, $[14] = zIndex, $[15] = t7) : t7 = $[15], t6 = t7;
1008
- const value = t6;
1009
- let t8;
1010
- return $[16] !== children || $[17] !== value ? (t8 = /* @__PURE__ */ jsx(LayerContext.Provider, { value, children }), $[16] = children, $[17] = value, $[18] = t8) : t8 = $[18], t8;
1011
- }
1012
- function _temp2$2(v_0) {
1013
- return v_0 - 1;
1014
- }
1015
- function _temp$2(v) {
1016
- return v + 1;
743
+ const media = Object.values(BREAKPOINTS);
744
+ function _getMediaQuery(media2, index) {
745
+ 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)`;
1017
746
  }
1018
- const DEFAULT_LAYER_ELEMENT = "div";
1019
- function Layer(props) {
747
+ function _createMediaStore() {
748
+ const mediaLen = media.length;
749
+ let sizes;
750
+ const getSizes = () => {
751
+ if (!sizes) {
752
+ sizes = [];
753
+ for (let index = mediaLen; index > -1; index -= 1) {
754
+ const mediaQuery = _getMediaQuery(media, index);
755
+ sizes.push({
756
+ index,
757
+ mq: window.matchMedia(mediaQuery)
758
+ });
759
+ }
760
+ }
761
+ return sizes;
762
+ };
763
+ return {
764
+ getSnapshot: () => {
765
+ for (const {
766
+ index,
767
+ mq
768
+ } of getSizes())
769
+ if (mq.matches) return index;
770
+ return 0;
771
+ },
772
+ subscribe: (onStoreChange) => {
773
+ const disposeFns = [];
774
+ for (const {
775
+ mq
776
+ } of getSizes()) {
777
+ const handleChange = () => {
778
+ mq.matches && onStoreChange();
779
+ };
780
+ mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
781
+ }
782
+ return () => {
783
+ for (const disposeFn of disposeFns)
784
+ disposeFn();
785
+ };
786
+ }
787
+ };
788
+ }
789
+ function getServerSnapshot() {
790
+ return 0;
791
+ }
792
+ function useMediaIndex() {
793
+ const $ = c(1);
794
+ let t0, t1;
795
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = _createMediaStore(), $[0] = t1) : t1 = $[0], t0 = t1;
796
+ const store = t0;
797
+ return useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
798
+ }
799
+ function LayerProvider(props) {
800
+ const $ = c(19), {
801
+ children,
802
+ zOffset: t0
803
+ } = props, zOffsetProp = t0 === void 0 ? 0 : t0, parentContextValue = useContext(LayerContext);
804
+ let t1;
805
+ $[0] !== parentContextValue ? (t1 = parentContextValue && getLayerContext(parentContextValue), $[0] = parentContextValue, $[1] = t1) : t1 = $[1];
806
+ const parent = t1, parentRegisterChild = parent?.registerChild, level = (parent?.level ?? 0) + 1, zOffset = useResponsiveProp(zOffsetProp), maxMediaIndex = Object.values(zOffset).length - 1, mediaIndex = Math.min(useMediaIndex(), maxMediaIndex), zIndex = parent ? parent.zIndex + (zOffset[mediaIndex] ?? 0) : zOffset[mediaIndex] ?? 0;
807
+ let t2;
808
+ $[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {}, $[2] = t2) : t2 = $[2];
809
+ const [, setChildLayers] = useState(t2), [size2, setSize] = useState(0), isTopLayer = size2 === 0;
810
+ let t3;
811
+ $[3] !== parentRegisterChild || $[4] !== setChildLayers ? (t3 = (childLevel) => {
812
+ const parentDispose = parentRegisterChild?.(childLevel);
813
+ return childLevel !== void 0 ? setChildLayers((state) => {
814
+ const prevLen = state[childLevel] ?? 0, nextState = {
815
+ ...state,
816
+ [childLevel]: prevLen + 1
817
+ };
818
+ return setSize(Object.keys(nextState).length), nextState;
819
+ }) : setSize(_temp$3), () => {
820
+ childLevel !== void 0 ? setChildLayers((state_0) => {
821
+ const nextState_0 = {
822
+ ...state_0
823
+ };
824
+ return nextState_0[childLevel] === 1 ? (delete nextState_0[childLevel], setSize(Object.keys(nextState_0).length)) : nextState_0[childLevel] = nextState_0[childLevel] - 1, nextState_0;
825
+ }) : setSize(_temp2$1), parentDispose?.();
826
+ };
827
+ }, $[3] = parentRegisterChild, $[4] = setChildLayers, $[5] = t3) : t3 = $[5];
828
+ const registerChild = t3;
829
+ let t4, t5;
830
+ $[6] !== level || $[7] !== parentRegisterChild ? (t4 = () => parentRegisterChild?.(level), t5 = [level, parentRegisterChild], $[6] = level, $[7] = parentRegisterChild, $[8] = t4, $[9] = t5) : (t4 = $[8], t5 = $[9]), useEffect(t4, t5);
831
+ let t6, t7;
832
+ $[10] !== isTopLayer || $[11] !== level || $[12] !== registerChild || $[13] !== size2 || $[14] !== zIndex ? (t7 = {
833
+ version: 0,
834
+ isTopLayer,
835
+ level,
836
+ registerChild,
837
+ size: size2,
838
+ zIndex
839
+ }, $[10] = isTopLayer, $[11] = level, $[12] = registerChild, $[13] = size2, $[14] = zIndex, $[15] = t7) : t7 = $[15], t6 = t7;
840
+ const value = t6;
841
+ let t8;
842
+ return $[16] !== children || $[17] !== value ? (t8 = /* @__PURE__ */ jsx(LayerContext.Provider, { value, children }), $[16] = children, $[17] = value, $[18] = t8) : t8 = $[18], t8;
843
+ }
844
+ function _temp2$1(v_0) {
845
+ return v_0 - 1;
846
+ }
847
+ function _temp$3(v) {
848
+ return v + 1;
849
+ }
850
+ const DEFAULT_LAYER_ELEMENT = "div";
851
+ function Layer(props) {
1020
852
  const $ = c(12), t0 = props;
1021
853
  let children, rest, t1, t2;
1022
854
  $[0] !== t0 ? ({
@@ -1031,163 +863,6 @@ function Layer(props) {
1031
863
  let t4;
1032
864
  return $[9] !== t3 || $[10] !== zOffset ? (t4 = /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: t3 }), $[9] = t3, $[10] = zOffset, $[11] = t4) : t4 = $[11], t4;
1033
865
  }
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
866
  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
867
  top: ["bottom", "left", "right"],
1193
868
  "top-start": ["bottom-start", "left-start", "right-start"],
@@ -1243,39 +918,162 @@ function size(options) {
1243
918
  }
1244
919
  };
1245
920
  }
1246
- function PopoverLayer(props) {
1247
- const $ = c(65);
1248
- let animate, arrow2, arrowRef, arrowX, arrowY, children, marginsProp, maxWidth, originX, originY, overflow, padding, placement, radius, referenceWidth, rest, shadow, strategy, style, t0, xProp, yProp;
1249
- $[0] !== props ? ({
1250
- __unstable_margins: marginsProp,
1251
- animate,
1252
- arrow: arrow2,
1253
- arrowRef,
1254
- arrowX,
1255
- arrowY,
1256
- children,
1257
- maxWidth,
1258
- padding,
1259
- placement,
1260
- originX,
1261
- originY,
1262
- overflow,
1263
- radius,
1264
- referenceWidth,
1265
- shadow,
1266
- strategy,
1267
- style,
1268
- tone: t0,
1269
- x: xProp,
1270
- y: yProp,
1271
- ...rest
1272
- } = props, $[0] = props, $[1] = animate, $[2] = arrow2, $[3] = arrowRef, $[4] = arrowX, $[5] = arrowY, $[6] = children, $[7] = marginsProp, $[8] = maxWidth, $[9] = originX, $[10] = originY, $[11] = overflow, $[12] = padding, $[13] = placement, $[14] = radius, $[15] = referenceWidth, $[16] = rest, $[17] = shadow, $[18] = strategy, $[19] = style, $[20] = t0, $[21] = xProp, $[22] = yProp) : (animate = $[1], arrow2 = $[2], arrowRef = $[3], arrowX = $[4], arrowY = $[5], children = $[6], marginsProp = $[7], maxWidth = $[8], originX = $[9], originY = $[10], overflow = $[11], padding = $[12], placement = $[13], radius = $[14], referenceWidth = $[15], rest = $[16], shadow = $[17], strategy = $[18], style = $[19], t0 = $[20], xProp = $[21], yProp = $[22]);
1273
- const tone = t0 === void 0 ? "inherit" : t0;
1274
- let t1;
1275
- t1 = marginsProp || DEFAULT_POPOVER_MARGINS;
1276
- const margins = t1, x = (xProp ?? 0) + margins[3], y = (yProp ?? 0) + margins[0];
1277
- let t2;
1278
- const t3 = animate ? "transform" : void 0;
921
+ function moveTowardsLength(movingPoint, targetPoint, amount) {
922
+ const width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
923
+ return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
924
+ }
925
+ function moveTowardsFractional(movingPoint, targetPoint, fraction) {
926
+ return {
927
+ x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
928
+ y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
929
+ };
930
+ }
931
+ function getRoundedCommands(points) {
932
+ const len = points.length, cmds = [];
933
+ for (let i = 0; i < len; i += 1) {
934
+ const point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
935
+ if (prevPoint && point.radius) {
936
+ 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);
937
+ cmds.push({
938
+ type: "point",
939
+ ...curveStart
940
+ }), cmds.push({
941
+ type: "curve",
942
+ curveEnd,
943
+ startControl,
944
+ endControl
945
+ });
946
+ } else
947
+ cmds.push({
948
+ type: "point",
949
+ ...point
950
+ });
951
+ }
952
+ return cmds;
953
+ }
954
+ function compileCommands(cmds) {
955
+ 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(" ");
956
+ }
957
+ const DEFAULT_ARROW_ELEMENT = "div";
958
+ function Arrow(props) {
959
+ const $ = c(34), t0 = props;
960
+ let h, rest, style, t1, t2, w;
961
+ $[0] !== t0 ? ({
962
+ as: t1,
963
+ width: w,
964
+ height: h,
965
+ radius: t2,
966
+ style,
967
+ ...rest
968
+ } = 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]);
969
+ const Element = t1 === void 0 ? DEFAULT_ARROW_ELEMENT : t1, radius = t2 === void 0 ? 0 : t2, center = w / 2;
970
+ let t3;
971
+ const points = [{
972
+ x: 0,
973
+ y: 0
974
+ }, {
975
+ x: radius,
976
+ y: 0,
977
+ radius
978
+ }, {
979
+ x: center,
980
+ y: h - 1,
981
+ radius
982
+ }, {
983
+ x: w - radius,
984
+ y: 0,
985
+ radius
986
+ }, {
987
+ x: w,
988
+ y: 0
989
+ }], cmds = getRoundedCommands(points);
990
+ t3 = compileCommands(cmds);
991
+ const path = t3, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`;
992
+ let t4;
993
+ $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = _arrow(), $[7] = t4) : t4 = $[7];
994
+ const t5 = `${w}px`;
995
+ let t6;
996
+ $[8] !== t5 ? (t6 = assignInlineVars({
997
+ [vars.arrow.size]: t5
998
+ }), $[8] = t5, $[9] = t6) : t6 = $[9];
999
+ let t7;
1000
+ $[10] !== style || $[11] !== t6 ? (t7 = {
1001
+ ...style,
1002
+ ...t6
1003
+ }, $[10] = style, $[11] = t6, $[12] = t7) : t7 = $[12];
1004
+ let t8;
1005
+ $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = _arrowSvg(), $[13] = t8) : t8 = $[13];
1006
+ const t9 = `0 0 ${w} ${w}`;
1007
+ let t10;
1008
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t10 = _arrowStrokeMask(), $[14] = t10) : t10 = $[14];
1009
+ let t11;
1010
+ $[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];
1011
+ let t12;
1012
+ $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = _arrowStroke(), $[17] = t12) : t12 = $[17];
1013
+ let t13;
1014
+ $[18] !== strokePath ? (t13 = /* @__PURE__ */ jsx("path", { className: t12, d: strokePath, mask: "url(#stroke-mask)" }), $[18] = strokePath, $[19] = t13) : t13 = $[19];
1015
+ let t14;
1016
+ $[20] === Symbol.for("react.memo_cache_sentinel") ? (t14 = _arrowShape(), $[20] = t14) : t14 = $[20];
1017
+ let t15;
1018
+ $[21] !== fillPath ? (t15 = /* @__PURE__ */ jsx("path", { className: t14, d: fillPath }), $[21] = fillPath, $[22] = t15) : t15 = $[22];
1019
+ let t16;
1020
+ $[23] !== t11 || $[24] !== t13 || $[25] !== t15 || $[26] !== t9 || $[27] !== w ? (t16 = /* @__PURE__ */ jsxs("svg", { className: t8, width: w, height: w, viewBox: t9, children: [
1021
+ t11,
1022
+ t13,
1023
+ t15
1024
+ ] }), $[23] = t11, $[24] = t13, $[25] = t15, $[26] = t9, $[27] = w, $[28] = t16) : t16 = $[28];
1025
+ let t17;
1026
+ 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;
1027
+ }
1028
+ const DEFAULT_FLEX_ELEMENT = "div";
1029
+ function Flex(props) {
1030
+ const $ = c(14), t0 = props;
1031
+ let align, justify, rest, t1, t2, wrap;
1032
+ $[0] !== t0 ? ({
1033
+ align,
1034
+ as: t1,
1035
+ direction: t2,
1036
+ justify,
1037
+ wrap,
1038
+ ...rest
1039
+ } = 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]);
1040
+ const as = t1 === void 0 ? DEFAULT_FLEX_ELEMENT : t1, direction = t2 === void 0 ? "row" : t2;
1041
+ let t3;
1042
+ 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;
1043
+ }
1044
+ function PopoverLayer(props) {
1045
+ const $ = c(65);
1046
+ let animate, arrow2, arrowRef, arrowX, arrowY, children, marginsProp, maxWidth, originX, originY, overflow, padding, placement, radius, referenceWidth, rest, shadow, strategy, style, t0, xProp, yProp;
1047
+ $[0] !== props ? ({
1048
+ __unstable_margins: marginsProp,
1049
+ animate,
1050
+ arrow: arrow2,
1051
+ arrowRef,
1052
+ arrowX,
1053
+ arrowY,
1054
+ children,
1055
+ maxWidth,
1056
+ padding,
1057
+ placement,
1058
+ originX,
1059
+ originY,
1060
+ overflow,
1061
+ radius,
1062
+ referenceWidth,
1063
+ shadow,
1064
+ strategy,
1065
+ style,
1066
+ tone: t0,
1067
+ x: xProp,
1068
+ y: yProp,
1069
+ ...rest
1070
+ } = props, $[0] = props, $[1] = animate, $[2] = arrow2, $[3] = arrowRef, $[4] = arrowX, $[5] = arrowY, $[6] = children, $[7] = marginsProp, $[8] = maxWidth, $[9] = originX, $[10] = originY, $[11] = overflow, $[12] = padding, $[13] = placement, $[14] = radius, $[15] = referenceWidth, $[16] = rest, $[17] = shadow, $[18] = strategy, $[19] = style, $[20] = t0, $[21] = xProp, $[22] = yProp) : (animate = $[1], arrow2 = $[2], arrowRef = $[3], arrowX = $[4], arrowY = $[5], children = $[6], marginsProp = $[7], maxWidth = $[8], originX = $[9], originY = $[10], overflow = $[11], padding = $[12], placement = $[13], radius = $[14], referenceWidth = $[15], rest = $[16], shadow = $[17], strategy = $[18], style = $[19], t0 = $[20], xProp = $[21], yProp = $[22]);
1071
+ const tone = t0 === void 0 ? "inherit" : t0;
1072
+ let t1;
1073
+ t1 = marginsProp || DEFAULT_POPOVER_MARGINS;
1074
+ const margins = t1, x = (xProp ?? 0) + margins[3], y = (yProp ?? 0) + margins[0];
1075
+ let t2;
1076
+ const t3 = animate ? "transform" : void 0;
1279
1077
  let t4;
1280
1078
  $[23] !== originX || $[24] !== originY || $[25] !== referenceWidth || $[26] !== style || $[27] !== t3 || $[28] !== x || $[29] !== y ? (t4 = {
1281
1079
  left: x,
@@ -1467,6 +1265,15 @@ function Stack(props) {
1467
1265
  let t4;
1468
1266
  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
1267
  }
1268
+ function useCustomValidity(ref, customValidity) {
1269
+ const $ = c(6);
1270
+ let t0;
1271
+ $[0] !== customValidity || $[1] !== ref.current ? (t0 = () => {
1272
+ ref.current?.setCustomValidity(customValidity || "");
1273
+ }, $[0] = customValidity, $[1] = ref.current, $[2] = t0) : t0 = $[2];
1274
+ let t1;
1275
+ $[3] !== customValidity || $[4] !== ref ? (t1 = [customValidity, ref], $[3] = customValidity, $[4] = ref, $[5] = t1) : t1 = $[5], useEffect(t0, t1);
1276
+ }
1470
1277
  const DEFAULT_TEXT_INPUT_ELEMENT = "input";
1471
1278
  function TextInput(props) {
1472
1279
  const $ = c(89), t0 = props;
@@ -1503,7 +1310,7 @@ function TextInput(props) {
1503
1310
  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
1311
  let t9;
1505
1312
  $[23] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => ref.current, $[23] = t9) : t9 = $[23], useImperativeHandle(forwardedRef, t9), useCustomValidity(ref, customValidity);
1506
- const handleClearMouseDown = _temp;
1313
+ const handleClearMouseDown = _temp$2;
1507
1314
  let t10;
1508
1315
  $[24] !== onClear ? (t10 = (event_0) => {
1509
1316
  event_0.preventDefault(), event_0.stopPropagation(), onClear && onClear(), ref.current?.focus();
@@ -1582,254 +1389,80 @@ function _temp2(t0) {
1582
1389
  const [key2, value] = t0;
1583
1390
  return value === 0 ? [key2, 0] : value === 1 ? [key2, 1] : value === 2 ? [key2, 1] : [key2, typeof value == "number" ? value - 2 : 0];
1584
1391
  }
1585
- function _temp(event) {
1392
+ function _temp$2(event) {
1586
1393
  event.preventDefault(), event.stopPropagation();
1587
1394
  }
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;
1395
+ function useClickOutsideEvent(listener, t0, boundaryElement) {
1396
+ const $ = c(9), elementsArg = t0 === void 0 ? _temp$1 : t0;
1600
1397
  let t1;
1601
- return $[1] !== state ? (t1 = [state, onStateChange], $[1] = state, $[2] = t1) : t1 = $[2], t1;
1398
+ $[0] !== boundaryElement || $[1] !== elementsArg || $[2] !== listener ? (t1 = (evt) => {
1399
+ if (!listener)
1400
+ return;
1401
+ const target = evt.target;
1402
+ if (!(target instanceof Node))
1403
+ return;
1404
+ const resolvedBoundaryElement = boundaryElement?.();
1405
+ if (resolvedBoundaryElement && !resolvedBoundaryElement.contains(target))
1406
+ return;
1407
+ const elements = elementsArg().flat();
1408
+ for (const el of elements)
1409
+ if (el && (target === el || el.contains(target)))
1410
+ return;
1411
+ listener(evt);
1412
+ }, $[0] = boundaryElement, $[1] = elementsArg, $[2] = listener, $[3] = t1) : t1 = $[3];
1413
+ const onEvent = useEffectEvent(t1), hasListener = !!listener;
1414
+ let t2;
1415
+ $[4] !== hasListener || $[5] !== onEvent ? (t2 = () => {
1416
+ if (!hasListener)
1417
+ return;
1418
+ const handleEvent = (evt_0) => onEvent(evt_0);
1419
+ return document.addEventListener("mousedown", handleEvent), () => {
1420
+ document.removeEventListener("mousedown", handleEvent);
1421
+ };
1422
+ }, $[4] = hasListener, $[5] = onEvent, $[6] = t2) : t2 = $[6];
1423
+ let t3;
1424
+ $[7] !== hasListener ? (t3 = [hasListener], $[7] = hasListener, $[8] = t3) : t3 = $[8], useEffect(t2, t3), useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
1602
1425
  }
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);
1426
+ function _temp$1() {
1427
+ return EMPTY_ARRAY;
1606
1428
  }
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);
1429
+ function useGlobalKeyDown(onKeyDown) {
1430
+ const $ = c(5);
1431
+ let t0;
1432
+ $[0] !== onKeyDown ? (t0 = (event) => onKeyDown(event), $[0] = onKeyDown, $[1] = t0) : t0 = $[1];
1433
+ const handleKeyDown = useEffectEvent(t0);
1434
+ let t1;
1435
+ $[2] !== handleKeyDown ? (t1 = () => {
1436
+ const handler = (event_0) => handleKeyDown(event_0);
1437
+ return window.addEventListener("keydown", handler), () => window.removeEventListener("keydown", handler);
1438
+ }, $[2] = handleKeyDown, $[3] = t1) : t1 = $[3];
1439
+ let t2;
1440
+ $[4] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[4] = t2) : t2 = $[4], useEffect(t1, t2);
1623
1441
  }
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,
1442
+ const DEFAULT_KBD_ELEMENT = "kbd";
1443
+ function KBD(props) {
1444
+ const $ = c(22), t0 = props;
1445
+ let children, className, rest, t1, t2, t3, t4, t5;
1446
+ $[0] !== t0 ? ({
1447
+ as: t1,
1633
1448
  children,
1634
- originX,
1635
- originY,
1636
- padding,
1637
- placement,
1638
- radius,
1639
- scheme,
1640
- shadow,
1641
- style,
1642
- tone: t0,
1449
+ className,
1450
+ display: t2,
1451
+ fontSize: t3,
1452
+ padding: t4,
1453
+ radius: t5,
1643
1454
  ...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;
1455
+ } = 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]);
1456
+ 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
1457
  let t7;
1659
- $[22] !== t5 || $[23] !== t6 ? (t7 = {
1660
- left: t5,
1661
- top: t6,
1662
- right: void 0,
1663
- bottom: void 0
1664
- }, $[22] = t5, $[23] = t6, $[24] = t7) : t7 = $[24], t4 = t7;
1665
- const arrowStyle = t4, t8 = animate ? "" : void 0;
1666
- let t9;
1667
- $[25] !== animate ? (t9 = animate ? ["hidden", "initial"] : void 0, $[25] = animate, $[26] = t9) : t9 = $[26];
1668
- let t10;
1669
- $[27] !== animate ? (t10 = animate ? ["visible", "scaleIn"] : void 0, $[27] = animate, $[28] = t10) : t10 = $[28];
1670
- let t11;
1671
- $[29] !== animate ? (t11 = animate ? ["hidden", "scaleOut"] : void 0, $[29] = animate, $[30] = t11) : t11 = $[30];
1672
- let t12;
1673
- $[31] !== arrow2 || $[32] !== arrowRef || $[33] !== arrowStyle ? (t12 = arrow2 && /* @__PURE__ */ jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_TOOLTIP_ARROW_WIDTH, height: DEFAULT_TOOLTIP_ARROW_HEIGHT, radius: DEFAULT_TOOLTIP_ARROW_RADIUS }), $[31] = arrow2, $[32] = arrowRef, $[33] = arrowStyle, $[34] = t12) : t12 = $[34];
1674
- let t13;
1675
- return $[35] !== children || $[36] !== padding || $[37] !== placement || $[38] !== radius || $[39] !== rest || $[40] !== rootStyle || $[41] !== scheme || $[42] !== shadow || $[43] !== t10 || $[44] !== t11 || $[45] !== t12 || $[46] !== t8 || $[47] !== t9 || $[48] !== tone ? (t13 = /* @__PURE__ */ jsxs(Layer, { "data-ui": "Tooltip__layer", ...rest, as: motion.div, "data-animate": t8, "data-placement": placement, padding, radius, scheme, shadow, style: rootStyle, variants: POPOVER_MOTION_PROPS.card, transition: POPOVER_MOTION_PROPS.transition, initial: t9, animate: t10, exit: t11, tone, children: [
1676
- children,
1677
- t12
1678
- ] }), $[35] = children, $[36] = padding, $[37] = placement, $[38] = radius, $[39] = rest, $[40] = rootStyle, $[41] = scheme, $[42] = shadow, $[43] = t10, $[44] = t11, $[45] = t12, $[46] = t8, $[47] = t9, $[48] = tone, $[49] = t13) : t13 = $[49], t13;
1679
- }
1680
- const DEFAULT_TOOLTIP_ELEMENT = "div";
1681
- function Tooltip(props) {
1682
- const boundaryElementContext = useBoundaryElement(), {
1683
- animate: _animate = !1,
1684
- arrow: arrowProp = !1,
1685
- as = DEFAULT_TOOLTIP_ELEMENT,
1686
- boundaryElement = boundaryElementContext?.element,
1687
- children: childProp,
1458
+ $[9] !== className || $[10] !== radius ? (t7 = kbd({
1688
1459
  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);
1460
+ radius
1461
+ }), $[9] = className, $[10] = radius, $[11] = t7) : t7 = $[11];
1462
+ let t8;
1463
+ $[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];
1464
+ let t9;
1465
+ return $[15] !== display || $[16] !== padding || $[17] !== rest || $[18] !== t6 || $[19] !== t7 || $[20] !== t8 ? (t9 = /* @__PURE__ */ jsx(Box, { "data-ui": "KBD", ...rest, as: t6, className: t7, display, muted: !0, padding, children: t8 }), $[15] = display, $[16] = padding, $[17] = rest, $[18] = t6, $[19] = t7, $[20] = t8, $[21] = t9) : t9 = $[21], t9;
1833
1466
  }
1834
1467
  const DEFAULT_HOTKEYS_ELEMENT = "kbd";
1835
1468
  function Hotkeys(props) {
@@ -2107,27 +1740,6 @@ function MenuDivider(props) {
2107
1740
  let t3;
2108
1741
  return $[6] !== Element || $[7] !== rest || $[8] !== t2 ? (t3 = /* @__PURE__ */ jsx(Element, { ...rest, className: t2 }), $[6] = Element, $[7] = rest, $[8] = t2, $[9] = t3) : t3 = $[9], t3;
2109
1742
  }
2110
- const DEFAULT_SELECTABLE_ELEMENT = "button";
2111
- function Selectable(props) {
2112
- const $ = c(14), t0 = props;
2113
- let className, radius, rest, t1, tone;
2114
- $[0] !== t0 ? ({
2115
- as: t1,
2116
- className,
2117
- radius,
2118
- tone,
2119
- ...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]);
2121
- const as = t1 === void 0 ? DEFAULT_SELECTABLE_ELEMENT : t1;
2122
- let t2;
2123
- $[6] !== className || $[7] !== radius || $[8] !== tone ? (t2 = _selectable({
2124
- className,
2125
- radius,
2126
- 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;
2130
- }
2131
1743
  function useMenu() {
2132
1744
  const value = useContext(MenuContext);
2133
1745
  if (!value)
@@ -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,