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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +1 -1
  2. package/dist/_chunks-cjs/_visual-editing.cjs +710 -840
  3. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
  4. package/dist/_chunks-cjs/refractor.cjs +2 -2
  5. package/dist/_chunks-cjs/refractor.cjs.map +1 -1
  6. package/dist/_chunks-es/_visual-editing.js +705 -834
  7. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  8. package/dist/_chunks-es/refractor.js +1 -1
  9. package/dist/css/layers.css +4 -0
  10. package/dist/css/primitives/popover/popover.css +4 -0
  11. package/dist/css.cjs +58 -49
  12. package/dist/css.cjs.map +1 -1
  13. package/dist/css.d.cts +13 -5
  14. package/dist/css.d.ts +13 -5
  15. package/dist/css.js +58 -49
  16. package/dist/css.js.map +1 -1
  17. package/dist/index.cjs +2006 -1824
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.css +1 -0
  20. package/dist/index.d.cts +34 -17
  21. package/dist/index.d.ts +34 -17
  22. package/dist/index.js +2002 -1821
  23. package/dist/index.js.map +1 -1
  24. package/dist/theme.cjs +7 -7
  25. package/dist/theme.cjs.map +1 -1
  26. package/dist/theme.js +7 -7
  27. package/dist/theme.js.map +1 -1
  28. package/exports/_visual-editing.ts +1 -1
  29. package/package.json +10 -15
  30. package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +2 -2
  31. package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +1 -1
  32. package/src/core/components/autocomplete/autocomplete.tsx +13 -17
  33. package/src/core/components/autocomplete/autocompleteOption.tsx +1 -1
  34. package/src/core/components/autocomplete/constants.ts +3 -1
  35. package/src/core/components/autocomplete/types.ts +1 -1
  36. package/src/core/components/breadcrumbs/breadcrumbs.tsx +8 -3
  37. package/src/core/components/dialog/__workshop__/activate.tsx +11 -3
  38. package/src/core/components/dialog/__workshop__/panes.tsx +12 -5
  39. package/src/core/components/dialog/dialog.tsx +12 -6
  40. package/src/core/components/dialog/dialogCard.tsx +89 -54
  41. package/src/core/components/dialog/dialogContext.ts +1 -1
  42. package/src/core/components/dialog/dialogProvider.tsx +1 -1
  43. package/src/core/components/dialog/index.ts +1 -0
  44. package/src/core/components/dialog/isTargetWithinScope.ts +1 -1
  45. package/src/core/components/hotkeys/hotkeys.tsx +3 -2
  46. package/src/core/components/menu/__workshop__/avatarMenu.tsx +12 -6
  47. package/src/core/components/menu/__workshop__/customSelectedState.tsx +1 -5
  48. package/src/core/components/menu/__workshop__/shouldFocus.tsx +1 -2
  49. package/src/core/components/menu/helpers.ts +1 -1
  50. package/src/core/components/menu/menu.tsx +6 -3
  51. package/src/core/components/menu/menuButton.tsx +5 -3
  52. package/src/core/components/menu/menuDivider.tsx +1 -1
  53. package/src/core/components/menu/menuGroup.tsx +8 -4
  54. package/src/core/components/menu/menuItem.tsx +4 -2
  55. package/src/core/components/tab/tab.tsx +2 -2
  56. package/src/core/components/tab/tabList.tsx +2 -2
  57. package/src/core/components/tab/tabPanel.tsx +2 -2
  58. package/src/core/components/toast/toast.tsx +7 -2
  59. package/src/core/components/toast/toastLayer.tsx +3 -2
  60. package/src/core/components/toast/toastProvider.tsx +1 -1
  61. package/src/core/components/tree/tree.tsx +2 -2
  62. package/src/core/components/tree/treeGroup.tsx +2 -2
  63. package/src/core/components/tree/treeItem.tsx +13 -6
  64. package/src/core/components/tree/types.ts +0 -1
  65. package/src/core/components/virtualList/virtualList.tsx +10 -5
  66. package/src/core/helpers/focus.ts +0 -8
  67. package/src/core/hooks/useArrayProp.ts +1 -1
  68. package/src/core/hooks/useElementRect/__workshop__/example.tsx +1 -3
  69. package/src/core/hooks/useElementSize.ts +1 -1
  70. package/src/core/hooks/useResponsiveProp.ts +1 -1
  71. package/src/core/index.ts +83 -7
  72. package/src/core/observers/{elementSizeObserver.ts → elementSize.ts} +1 -1
  73. package/src/core/primitives/_selectable/index.ts +1 -0
  74. package/src/core/primitives/_selectable/selectable.tsx +13 -3
  75. package/src/core/{types/selectable.ts → primitives/_selectable/types.ts} +1 -1
  76. package/src/core/primitives/arrow/arrow.tsx +1 -1
  77. package/src/core/primitives/avatar/avatar.tsx +4 -3
  78. package/src/core/primitives/avatar/avatarCounter.tsx +3 -3
  79. package/src/core/primitives/avatar/avatarStack.tsx +4 -4
  80. package/src/core/primitives/avatar/types.ts +17 -0
  81. package/src/core/primitives/badge/badge.tsx +2 -1
  82. package/src/core/primitives/badge/types.ts +11 -2
  83. package/src/core/primitives/box/__workshop__/responsive.tsx +0 -1
  84. package/src/core/primitives/box/box.tsx +1 -1
  85. package/src/core/primitives/box/index.ts +1 -0
  86. package/src/core/primitives/button/__workshop__/disabled.tsx +37 -51
  87. package/src/core/primitives/button/__workshop__/index.ts +5 -0
  88. package/src/core/primitives/button/__workshop__/textOverflow.tsx +13 -0
  89. package/src/core/primitives/button/button.tsx +15 -14
  90. package/src/core/primitives/button/index.ts +1 -0
  91. package/src/core/primitives/card/__workshop__/listNavigation.tsx +2 -2
  92. package/src/core/primitives/card/card.tsx +1 -1
  93. package/src/core/primitives/card/types.ts +3 -0
  94. package/src/core/primitives/checkbox/__workshop__/tones.tsx +9 -1
  95. package/src/core/primitives/checkbox/checkbox.tsx +3 -4
  96. package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +17 -42
  97. package/src/core/primitives/code/code.tsx +1 -1
  98. package/src/core/primitives/container/container.tsx +1 -1
  99. package/src/core/primitives/flex/flex.tsx +1 -1
  100. package/src/core/primitives/flex/index.ts +1 -0
  101. package/src/core/primitives/grid/grid.tsx +1 -1
  102. package/src/core/primitives/grid/index.ts +1 -0
  103. package/src/core/primitives/heading/heading.tsx +1 -1
  104. package/src/core/primitives/inline/inline.tsx +1 -1
  105. package/src/core/primitives/kbd/kbd.tsx +1 -1
  106. package/src/core/primitives/label/label.tsx +1 -1
  107. package/src/core/primitives/layer/layer.test.tsx +1 -1
  108. package/src/core/primitives/layer/layer.tsx +2 -2
  109. package/src/core/primitives/layer/layerCard.tsx +3 -3
  110. package/src/core/primitives/layer/layerProvider.tsx +2 -1
  111. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +12 -10
  112. package/src/core/primitives/popover/__workshop__/TestStory.tsx +9 -8
  113. package/src/core/primitives/popover/constants.ts +1 -1
  114. package/src/core/primitives/popover/floating-ui/size.ts +1 -1
  115. package/src/core/primitives/popover/popover.tsx +7 -4
  116. package/src/core/primitives/popover/popoverLayer.tsx +2 -1
  117. package/src/core/primitives/popover/types.ts +5 -0
  118. package/src/core/primitives/radio/radio.tsx +2 -2
  119. package/src/core/primitives/select/select.tsx +2 -2
  120. package/src/core/{components → primitives}/skeleton/__workshop__/index.ts +1 -1
  121. package/src/core/{components → primitives}/skeleton/codeSkeleton.tsx +1 -1
  122. package/src/core/{components → primitives}/skeleton/headingSkeleton.tsx +1 -1
  123. package/src/core/{components → primitives}/skeleton/labelSkeleton.tsx +1 -1
  124. package/src/core/{components → primitives}/skeleton/skeleton.tsx +7 -8
  125. package/src/core/{components → primitives}/skeleton/textSkeleton.tsx +1 -1
  126. package/src/core/primitives/spinner/spinner.tsx +1 -1
  127. package/src/core/primitives/srOnly/srOnly.tsx +1 -1
  128. package/src/core/primitives/stack/stack.tsx +1 -1
  129. package/src/core/primitives/switch/switch.tsx +1 -6
  130. package/src/core/primitives/text/__workshop__/colored.tsx +2 -2
  131. package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +17 -42
  132. package/src/core/primitives/text/text.tsx +3 -1
  133. package/src/core/primitives/textArea/__workshop__/plain.tsx +2 -2
  134. package/src/core/primitives/textArea/textArea.tsx +2 -2
  135. package/src/core/primitives/textInput/textInput.tsx +3 -2
  136. package/src/core/primitives/tooltip/constants.ts +1 -1
  137. package/src/core/primitives/tooltip/tooltip.tsx +5 -3
  138. package/src/core/primitives/tooltip/tooltipLayer.tsx +1 -1
  139. package/src/core/primitives/types.ts +8 -10
  140. package/src/core/types/radius.ts +1 -1
  141. package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +9 -5
  142. package/src/core/utils/elementQuery/elementQuery.tsx +2 -2
  143. package/src/core/utils/portal/portal.tsx +1 -1
  144. package/src/css/components/dialog/dialog.css.ts +26 -1
  145. package/src/css/components/dialog/dialog.ts +27 -7
  146. package/src/css/components/skeleton/skeleton.ts +3 -1
  147. package/src/css/components/skeleton/types.ts +3 -1
  148. package/src/css/index.ts +75 -5
  149. package/src/css/primitives/_input/input.ts +2 -1
  150. package/src/css/primitives/_input/types.ts +2 -1
  151. package/src/css/primitives/_selectable/_selectable.css.ts +32 -24
  152. package/src/css/primitives/_selectable/selectable.ts +1 -1
  153. package/src/css/primitives/_selectable/types.ts +1 -1
  154. package/src/css/primitives/avatar/avatar.css.ts +8 -4
  155. package/src/css/primitives/avatar/avatar.ts +1 -1
  156. package/src/css/primitives/badge/types.ts +0 -2
  157. package/src/css/primitives/box/box.ts +35 -37
  158. package/src/css/primitives/box/types.ts +34 -36
  159. package/src/css/primitives/button/button.css.ts +4 -0
  160. package/src/css/primitives/button/button.ts +5 -2
  161. package/src/css/primitives/button/types.ts +4 -11
  162. package/src/css/primitives/card/__workshop__/color.tsx +70 -0
  163. package/src/css/primitives/card/__workshop__/index.ts +14 -0
  164. package/src/css/primitives/card/card.css.ts +4 -0
  165. package/src/css/primitives/code/code.ts +3 -1
  166. package/src/css/primitives/code/types.ts +2 -1
  167. package/src/css/primitives/container/container.ts +3 -1
  168. package/src/css/primitives/heading/heading.ts +4 -1
  169. package/src/css/primitives/heading/types.ts +3 -1
  170. package/src/css/primitives/kbd/kbd.ts +1 -1
  171. package/src/css/primitives/kbd/types.ts +1 -1
  172. package/src/css/primitives/label/label.ts +4 -1
  173. package/src/css/primitives/label/types.ts +3 -1
  174. package/src/css/primitives/switch/switch.css.ts +1 -1
  175. package/src/css/primitives/text/text.ts +6 -1
  176. package/src/css/primitives/text/types.ts +5 -2
  177. package/src/theme/v3/defaultFonts.ts +6 -6
  178. package/src/theme/v3/defaultTokens.ts +1 -1
  179. package/bin/sanity-ui.cjs +0 -5
  180. package/dist/ui.css +0 -1
  181. package/src/cli/buildCommand.ts +0 -10
  182. package/src/cli/index.ts +0 -26
  183. package/src/core/components/autocomplete/index.ts +0 -2
  184. package/src/core/components/index.ts +0 -10
  185. package/src/core/helpers/index.ts +0 -5
  186. package/src/core/hooks/index.ts +0 -13
  187. package/src/core/observers/index.ts +0 -2
  188. package/src/core/primitives/index.ts +0 -30
  189. package/src/core/types/avatar.ts +0 -16
  190. package/src/core/types/card.ts +0 -4
  191. package/src/core/types/index.ts +0 -15
  192. package/src/core/types/popover.ts +0 -4
  193. package/src/core/utils/index.ts +0 -4
  194. package/src/css/__theme/index.ts +0 -16
  195. package/src/css/__theme/lib/contract/buildVarContract.ts +0 -78
  196. package/src/css/__theme/lib/contract/index.ts +0 -4
  197. package/src/css/__theme/lib/contract/types.ts +0 -17
  198. package/src/css/__theme/resolveTheme.ts +0 -865
  199. package/src/css/components/index.ts +0 -6
  200. package/src/css/primitives/index.ts +0 -24
  201. package/src/css/props/index.ts +0 -37
  202. package/src/css/utils/srOnly/index.ts +0 -1
  203. /package/src/core/{global.ts → __DEV__.ts} +0 -0
  204. /package/src/core/{types/dialog.ts → components/dialog/types.ts} +0 -0
  205. /package/src/core/observers/{resizeObserver.ts → resize.ts} +0 -0
  206. /package/src/core/{types/badge.ts → primitives/badge/types2.ts} +0 -0
  207. /package/src/core/{types/box.ts → primitives/box/types.ts} +0 -0
  208. /package/src/core/{types/button.ts → primitives/button/types.ts} +0 -0
  209. /package/src/core/{types/flex.ts → primitives/flex/types.ts} +0 -0
  210. /package/src/core/{types/grid.ts → primitives/grid/types.ts} +0 -0
  211. /package/src/core/{components → primitives}/skeleton/__workshop__/delay.tsx +0 -0
  212. /package/src/core/{components → primitives}/skeleton/__workshop__/skeleton.tsx +0 -0
  213. /package/src/core/{components → primitives}/skeleton/index.ts +0 -0
  214. /package/src/core/types/{text.ts → textAlign.ts} +0 -0
  215. /package/src/css/{utils → primitives/srOnly}/index.ts +0 -0
  216. /package/src/css/{utils → primitives}/srOnly/srOnly.css.ts +0 -0
  217. /package/src/css/{utils → primitives}/srOnly/srOnly.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- var jsxRuntime = require("react/jsx-runtime"), reactCompilerRuntime = require("react-compiler-runtime"), theme = require("@sanity/ui/theme"), react = require("react"), styledComponents = require("styled-components"), css = require("@sanity/ui/css"), resizeObserver = require("@juggle/resize-observer"), useEffectEvent = require("use-effect-event"), icons = require("@sanity/icons"), reactIs = require("react-is"), reactDom$1 = require("@floating-ui/react-dom"), framerMotion = require("framer-motion"), reactDom = require("react-dom"), dynamic = require("@vanilla-extract/dynamic");
2
+ var jsxRuntime = require("react/jsx-runtime"), compilerRuntime = require("react/compiler-runtime"), theme = require("@sanity/ui/theme"), react = require("react"), styledComponents = require("styled-components"), css = require("@sanity/ui/css"), useEffectEvent = require("use-effect-event"), icons = require("@sanity/icons"), reactIs = require("react-is"), reactDom$1 = require("@floating-ui/react-dom"), framerMotion = require("framer-motion"), reactDom = require("react-dom"), dynamic = require("@vanilla-extract/dynamic");
3
3
  function getGlobalScope() {
4
4
  if (typeof globalThis < "u") return globalThis;
5
5
  if (typeof window < "u") return window;
@@ -14,7 +14,7 @@ function createGlobalScopedContext(key2, defaultValue) {
14
14
  }
15
15
  const CardContext = createGlobalScopedContext("@sanity/ui/context/card", null);
16
16
  function CardProvider(props) {
17
- const $ = reactCompilerRuntime.c(7), {
17
+ const $ = compilerRuntime.c(7), {
18
18
  children,
19
19
  tone,
20
20
  scheme,
@@ -31,7 +31,7 @@ function CardProvider(props) {
31
31
  }
32
32
  const ThemeContext = createGlobalScopedContext("@sanity/ui/context/theme", null);
33
33
  function ThemeProvider(props) {
34
- const $ = reactCompilerRuntime.c(19), parentTheme = react.useContext(ThemeContext), {
34
+ const $ = compilerRuntime.c(19), parentTheme = react.useContext(ThemeContext), {
35
35
  children
36
36
  } = props, scheme = props.scheme ?? (parentTheme?.scheme || "light"), rootTheme = props.theme ?? (parentTheme?.theme || null), tone = props.tone ?? (parentTheme?.tone || "default");
37
37
  let t0;
@@ -77,7 +77,7 @@ function useRootTheme() {
77
77
  return value;
78
78
  }
79
79
  function ThemeColorProvider(props) {
80
- const $ = reactCompilerRuntime.c(5), {
80
+ const $ = compilerRuntime.c(5), {
81
81
  children,
82
82
  scheme,
83
83
  tone
@@ -89,7 +89,7 @@ function useTheme() {
89
89
  return styledComponents.useTheme();
90
90
  }
91
91
  function useTheme_v2() {
92
- const $ = reactCompilerRuntime.c(2), t0 = styledComponents.useTheme();
92
+ const $ = compilerRuntime.c(2), t0 = styledComponents.useTheme();
93
93
  let t1;
94
94
  return $[0] !== t0 ? (t1 = theme.getTheme_v2(t0), $[0] = t0, $[1] = t1) : t1 = $[1], t1;
95
95
  }
@@ -162,305 +162,16 @@ function _getArrayProp(val, defaultVal) {
162
162
  function _getResponsiveProp(val, defaultVal) {
163
163
  return val === void 0 ? defaultVal || EMPTY_ARRAY : isArray(val) || isRecord(val) ? val : [val];
164
164
  }
165
- function useClickOutsideEvent(listener, t0, boundaryElement) {
166
- const $ = reactCompilerRuntime.c(9), elementsArg = t0 === void 0 ? _temp$5 : t0;
167
- let t1;
168
- $[0] !== boundaryElement || $[1] !== elementsArg || $[2] !== listener ? (t1 = (evt) => {
169
- if (!listener)
170
- return;
171
- const target = evt.target;
172
- if (!(target instanceof Node))
173
- return;
174
- const resolvedBoundaryElement = boundaryElement?.();
175
- if (resolvedBoundaryElement && !resolvedBoundaryElement.contains(target))
176
- return;
177
- const elements = elementsArg().flat();
178
- for (const el of elements)
179
- if (el && (target === el || el.contains(target)))
180
- return;
181
- listener(evt);
182
- }, $[0] = boundaryElement, $[1] = elementsArg, $[2] = listener, $[3] = t1) : t1 = $[3];
183
- const onEvent = useEffectEvent.useEffectEvent(t1), hasListener = !!listener;
184
- let t2;
185
- $[4] !== hasListener || $[5] !== onEvent ? (t2 = () => {
186
- if (!hasListener)
187
- return;
188
- const handleEvent = (evt_0) => onEvent(evt_0);
189
- return document.addEventListener("mousedown", handleEvent), () => {
190
- document.removeEventListener("mousedown", handleEvent);
191
- };
192
- }, $[4] = hasListener, $[5] = onEvent, $[6] = t2) : t2 = $[6];
193
- let t3;
194
- $[7] !== hasListener ? (t3 = [hasListener], $[7] = hasListener, $[8] = t3) : t3 = $[8], react.useEffect(t2, t3), react.useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
195
- }
196
- function _temp$5() {
197
- return EMPTY_ARRAY;
198
- }
199
- function useCustomValidity(ref, customValidity) {
200
- const $ = reactCompilerRuntime.c(6);
201
- let t0;
202
- $[0] !== customValidity || $[1] !== ref.current ? (t0 = () => {
203
- ref.current?.setCustomValidity(customValidity || "");
204
- }, $[0] = customValidity, $[1] = ref.current, $[2] = t0) : t0 = $[2];
205
- let t1;
206
- $[3] !== customValidity || $[4] !== ref ? (t1 = [customValidity, ref], $[3] = customValidity, $[4] = ref, $[5] = t1) : t1 = $[5], react.useEffect(t0, t1);
207
- }
208
- const _ResizeObserver = typeof document < "u" && typeof window < "u" && window.ResizeObserver ? window.ResizeObserver : resizeObserver.ResizeObserver, _elementSizeObserver = _createElementSizeObserver();
209
- function _createElementRectValueListener() {
210
- return {
211
- subscribe(element, subscriber) {
212
- const resizeObserver2 = new _ResizeObserver(([entry]) => {
213
- subscriber({
214
- _contentRect: entry.contentRect,
215
- border: {
216
- width: entry.borderBoxSize[0].inlineSize,
217
- height: entry.borderBoxSize[0].blockSize
218
- },
219
- content: {
220
- width: entry.contentRect.width,
221
- height: entry.contentRect.height
222
- }
223
- });
224
- });
225
- return resizeObserver2.observe(element), () => {
226
- resizeObserver2.unobserve(element), resizeObserver2.disconnect();
227
- };
228
- }
229
- };
230
- }
231
- function _createElementSizeObserver() {
232
- const disposeCache = /* @__PURE__ */ new WeakMap(), subscribersCache = /* @__PURE__ */ new WeakMap();
233
- return {
234
- subscribe(element, subscriber) {
235
- const subscribers = subscribersCache.get(element) || [];
236
- let dispose = disposeCache.get(element);
237
- return subscribersCache.has(element) || (subscribersCache.set(element, subscribers), dispose = _createElementRectValueListener().subscribe(element, (elementRect) => {
238
- for (const sub of subscribers)
239
- sub(elementRect);
240
- })), subscribers.push(subscriber), () => {
241
- const idx = subscribers.indexOf(subscriber);
242
- idx > -1 && subscribers.splice(idx, 1), subscribers.length === 0 && dispose && dispose();
243
- };
244
- }
245
- };
246
- }
247
- function useElementSize(element) {
248
- const $ = reactCompilerRuntime.c(3), [size2, setSize] = react.useState(null);
249
- let t0, t1;
250
- return $[0] !== element ? (t0 = () => {
251
- if (element)
252
- return _elementSizeObserver.subscribe(element, setSize);
253
- }, t1 = [element], $[0] = element, $[1] = t0, $[2] = t1) : (t0 = $[1], t1 = $[2]), react.useEffect(t0, t1), size2;
254
- }
255
- function useGlobalKeyDown(onKeyDown) {
256
- const $ = reactCompilerRuntime.c(5);
257
- let t0;
258
- $[0] !== onKeyDown ? (t0 = (event) => onKeyDown(event), $[0] = onKeyDown, $[1] = t0) : t0 = $[1];
259
- const handleKeyDown = useEffectEvent.useEffectEvent(t0);
260
- let t1;
261
- $[2] !== handleKeyDown ? (t1 = () => {
262
- const handler = (event_0) => handleKeyDown(event_0);
263
- return window.addEventListener("keydown", handler), () => window.removeEventListener("keydown", handler);
264
- }, $[2] = handleKeyDown, $[3] = t1) : t1 = $[3];
265
- let t2;
266
- $[4] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[4] = t2) : t2 = $[4], react.useEffect(t1, t2);
267
- }
268
- function useMatchMedia(mediaQueryString, getServerSnapshot2) {
269
- const $ = reactCompilerRuntime.c(4);
270
- react.useDebugValue(mediaQueryString);
271
- let t0;
272
- $[0] !== mediaQueryString ? (t0 = (onStoreChange) => {
273
- const media2 = window.matchMedia(mediaQueryString);
274
- return media2.addEventListener("change", onStoreChange), () => media2.removeEventListener("change", onStoreChange);
275
- }, $[0] = mediaQueryString, $[1] = t0) : t0 = $[1];
276
- let t1;
277
- return $[2] !== mediaQueryString ? (t1 = () => window.matchMedia(mediaQueryString).matches, $[2] = mediaQueryString, $[3] = t1) : t1 = $[3], react.useSyncExternalStore(t0, t1, getServerSnapshot2);
278
- }
279
- const media = Object.values(css.BREAKPOINTS);
280
- function _getMediaQuery(media2, index) {
281
- 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)`;
282
- }
283
- function _createMediaStore() {
284
- const mediaLen = media.length;
285
- let sizes;
286
- const getSizes = () => {
287
- if (!sizes) {
288
- sizes = [];
289
- for (let index = mediaLen; index > -1; index -= 1) {
290
- const mediaQuery = _getMediaQuery(media, index);
291
- sizes.push({
292
- index,
293
- mq: window.matchMedia(mediaQuery)
294
- });
295
- }
296
- }
297
- return sizes;
298
- };
299
- return {
300
- getSnapshot: () => {
301
- for (const {
302
- index,
303
- mq
304
- } of getSizes())
305
- if (mq.matches) return index;
306
- return 0;
307
- },
308
- subscribe: (onStoreChange) => {
309
- const disposeFns = [];
310
- for (const {
311
- mq
312
- } of getSizes()) {
313
- const handleChange = () => {
314
- mq.matches && onStoreChange();
315
- };
316
- mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
317
- }
318
- return () => {
319
- for (const disposeFn of disposeFns)
320
- disposeFn();
321
- };
322
- }
323
- };
324
- }
325
- function getServerSnapshot() {
326
- return 0;
327
- }
328
- function useMediaIndex() {
329
- const $ = reactCompilerRuntime.c(1);
330
- let t0, t1;
331
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = _createMediaStore(), $[0] = t1) : t1 = $[0], t0 = t1;
332
- const store = t0;
333
- return react.useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
334
- }
335
- function usePrefersDark(t0) {
336
- return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp$4 : t0);
337
- }
338
- function _temp$4() {
339
- return !1;
340
- }
341
- function usePrefersReducedMotion(t0) {
342
- return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$3 : t0);
343
- }
344
- function _temp$3() {
345
- return !1;
346
- }
347
165
  function useResponsiveProp(val, defaultVal) {
348
- const $ = reactCompilerRuntime.c(3);
166
+ const $ = compilerRuntime.c(3);
349
167
  let t0;
350
168
  $[0] !== defaultVal || $[1] !== val ? (t0 = () => [_getResponsiveProp(val, defaultVal), JSON.stringify(val ?? defaultVal)], $[0] = defaultVal, $[1] = val, $[2] = t0) : t0 = $[2];
351
169
  const [t1, setCache] = react.useState(t0), [cachedVal, cachedHash] = t1, hash = JSON.stringify(val ?? defaultVal);
352
170
  return hash !== cachedHash && setCache([_getResponsiveProp(val, defaultVal), hash]), cachedVal;
353
171
  }
354
- function moveTowardsLength(movingPoint, targetPoint, amount) {
355
- const width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
356
- return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
357
- }
358
- function moveTowardsFractional(movingPoint, targetPoint, fraction) {
359
- return {
360
- x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
361
- y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
362
- };
363
- }
364
- function getRoundedCommands(points) {
365
- const len = points.length, cmds = [];
366
- for (let i = 0; i < len; i += 1) {
367
- const point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
368
- if (prevPoint && point.radius) {
369
- 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);
370
- cmds.push({
371
- type: "point",
372
- ...curveStart
373
- }), cmds.push({
374
- type: "curve",
375
- curveEnd,
376
- startControl,
377
- endControl
378
- });
379
- } else
380
- cmds.push({
381
- type: "point",
382
- ...point
383
- });
384
- }
385
- return cmds;
386
- }
387
- function compileCommands(cmds) {
388
- 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(" ");
389
- }
390
- const DEFAULT_ARROW_ELEMENT = "div";
391
- function Arrow(props) {
392
- const $ = reactCompilerRuntime.c(34), t0 = props;
393
- let h, rest, style, t1, t2, w;
394
- $[0] !== t0 ? ({
395
- as: t1,
396
- width: w,
397
- height: h,
398
- radius: t2,
399
- style,
400
- ...rest
401
- } = 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]);
402
- const Element = t1 === void 0 ? DEFAULT_ARROW_ELEMENT : t1, radius = t2 === void 0 ? 0 : t2, center = w / 2;
403
- let t3;
404
- const points = [{
405
- x: 0,
406
- y: 0
407
- }, {
408
- x: radius,
409
- y: 0,
410
- radius
411
- }, {
412
- x: center,
413
- y: h - 1,
414
- radius
415
- }, {
416
- x: w - radius,
417
- y: 0,
418
- radius
419
- }, {
420
- x: w,
421
- y: 0
422
- }], cmds = getRoundedCommands(points);
423
- t3 = compileCommands(cmds);
424
- const path = t3, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`;
425
- let t4;
426
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = css._arrow(), $[7] = t4) : t4 = $[7];
427
- const t5 = `${w}px`;
428
- let t6;
429
- $[8] !== t5 ? (t6 = dynamic.assignInlineVars({
430
- [css.vars.arrow.size]: t5
431
- }), $[8] = t5, $[9] = t6) : t6 = $[9];
432
- let t7;
433
- $[10] !== style || $[11] !== t6 ? (t7 = {
434
- ...style,
435
- ...t6
436
- }, $[10] = style, $[11] = t6, $[12] = t7) : t7 = $[12];
437
- let t8;
438
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = css._arrowSvg(), $[13] = t8) : t8 = $[13];
439
- const t9 = `0 0 ${w} ${w}`;
440
- let t10;
441
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t10 = css._arrowStrokeMask(), $[14] = t10) : t10 = $[14];
442
- let t11;
443
- $[15] !== w ? (t11 = /* @__PURE__ */ jsxRuntime.jsx("mask", { id: "stroke-mask", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { className: t10, x: 0, width: w, height: w, fill: "white" }) }), $[15] = w, $[16] = t11) : t11 = $[16];
444
- let t12;
445
- $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = css._arrowStroke(), $[17] = t12) : t12 = $[17];
446
- let t13;
447
- $[18] !== strokePath ? (t13 = /* @__PURE__ */ jsxRuntime.jsx("path", { className: t12, d: strokePath, mask: "url(#stroke-mask)" }), $[18] = strokePath, $[19] = t13) : t13 = $[19];
448
- let t14;
449
- $[20] === Symbol.for("react.memo_cache_sentinel") ? (t14 = css._arrowShape(), $[20] = t14) : t14 = $[20];
450
- let t15;
451
- $[21] !== fillPath ? (t15 = /* @__PURE__ */ jsxRuntime.jsx("path", { className: t14, d: fillPath }), $[21] = fillPath, $[22] = t15) : t15 = $[22];
452
- let t16;
453
- $[23] !== t11 || $[24] !== t13 || $[25] !== t15 || $[26] !== t9 || $[27] !== w ? (t16 = /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: t8, width: w, height: w, viewBox: t9, children: [
454
- t11,
455
- t13,
456
- t15
457
- ] }), $[23] = t11, $[24] = t13, $[25] = t15, $[26] = t9, $[27] = w, $[28] = t16) : t16 = $[28];
458
- let t17;
459
- return $[29] !== Element || $[30] !== rest || $[31] !== t16 || $[32] !== t7 ? (t17 = /* @__PURE__ */ jsxRuntime.jsx(Element, { ...rest, className: t4, style: t7, children: t16 }), $[29] = Element, $[30] = rest, $[31] = t16, $[32] = t7, $[33] = t17) : t17 = $[33], t17;
460
- }
461
172
  const DEFAULT_BOX_ELEMENT = "div";
462
173
  function Box(props) {
463
- const $ = reactCompilerRuntime.c(154), t0 = props;
174
+ const $ = compilerRuntime.c(154), t0 = props;
464
175
  let alignItems, autoCols, autoFlow, autoRows, borderBottom, borderLeft, borderRight, borderTop, children, className, column, columnEnd, columnStart, columns, flex, flexDirection, flexWrap, gap, gapX, gapY, gridAutoColumns, gridAutoFlow, gridAutoRows, gridColumn, gridColumnEnd, gridColumnStart, gridRow, gridRowEnd, gridRowStart, gridTemplateColumns, gridTemplateRows, height, inset, insetBottom, insetLeft, insetRight, insetTop, justifyContent, marginBottom, marginLeft, marginRight, marginTop, marginX, marginY, maxWidth, muted, outline, overflow, overflowX, overflowY, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, pointerEvents, position, radius, rest, row, rowEnd, rowStart, rows, shadow, t1, t2, t3, t4, t5, t6, t7, t8, textAlign, width;
465
176
  $[0] !== t0 ? ({
466
177
  alignItems,
@@ -620,8 +331,8 @@ function Box(props) {
620
331
  }
621
332
  const DEFAULT_TEXT_ELEMENT = "div";
622
333
  function Text(props) {
623
- const $ = reactCompilerRuntime.c(30), t0 = props;
624
- let accent, align, children, className, flex, muted, rest, t1, t2, t3, textOverflowProp;
334
+ const $ = compilerRuntime.c(32), t0 = props;
335
+ let accent, align, children, className, flex, muted, rest, t1, t2, t3, t4, textOverflowProp;
625
336
  $[0] !== t0 ? ({
626
337
  accent,
627
338
  align,
@@ -629,34 +340,36 @@ function Text(props) {
629
340
  children,
630
341
  className,
631
342
  flex,
343
+ maxWidth: t2,
632
344
  muted,
633
- size: t2,
345
+ size: t3,
634
346
  textOverflow: textOverflowProp,
635
- weight: t3,
347
+ weight: t4,
636
348
  ...rest
637
- } = 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]);
638
- const Element = t1 === void 0 ? DEFAULT_TEXT_ELEMENT : t1, size2 = t2 === void 0 ? 2 : t2, weight = t3 === void 0 ? "regular" : t3;
639
- let t4;
640
- $[12] !== accent || $[13] !== align || $[14] !== className || $[15] !== flex || $[16] !== muted || $[17] !== size2 || $[18] !== weight ? (t4 = css.text({
349
+ } = 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]);
350
+ 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;
351
+ let t5;
352
+ $[13] !== accent || $[14] !== align || $[15] !== className || $[16] !== flex || $[17] !== maxWidth || $[18] !== muted || $[19] !== size2 || $[20] !== weight ? (t5 = css.text({
641
353
  className,
642
354
  accent,
643
355
  align,
644
356
  flex,
357
+ maxWidth,
645
358
  muted,
646
359
  size: size2,
647
360
  weight
648
- }), $[12] = accent, $[13] = align, $[14] = className, $[15] = flex, $[16] = muted, $[17] = size2, $[18] = weight, $[19] = t4) : t4 = $[19];
649
- let t5;
650
- $[20] !== textOverflowProp ? (t5 = css.textOverflow({
651
- textOverflow: textOverflowProp
652
- }), $[20] = textOverflowProp, $[21] = t5) : t5 = $[21];
361
+ }), $[13] = accent, $[14] = align, $[15] = className, $[16] = flex, $[17] = maxWidth, $[18] = muted, $[19] = size2, $[20] = weight, $[21] = t5) : t5 = $[21];
653
362
  let t6;
654
- $[22] !== children || $[23] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t5, children }), $[22] = children, $[23] = t5, $[24] = t6) : t6 = $[24];
363
+ $[22] !== textOverflowProp ? (t6 = css.textOverflow({
364
+ textOverflow: textOverflowProp
365
+ }), $[22] = textOverflowProp, $[23] = t6) : t6 = $[23];
655
366
  let t7;
656
- return $[25] !== Element || $[26] !== rest || $[27] !== t4 || $[28] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(Element, { "data-ui": "Text", ...rest, className: t4, children: t6 }), $[25] = Element, $[26] = rest, $[27] = t4, $[28] = t6, $[29] = t7) : t7 = $[29], t7;
367
+ $[24] !== children || $[25] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t6, children }), $[24] = children, $[25] = t6, $[26] = t7) : t7 = $[26];
368
+ let t8;
369
+ return $[27] !== Element || $[28] !== rest || $[29] !== t5 || $[30] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(Element, { "data-ui": "Text", ...rest, className: t5, children: t7 }), $[27] = Element, $[28] = rest, $[29] = t5, $[30] = t7, $[31] = t8) : t8 = $[31], t8;
657
370
  }
658
371
  function AnimatedSpinnerIcon(props) {
659
- const $ = reactCompilerRuntime.c(5);
372
+ const $ = compilerRuntime.c(5);
660
373
  let rest;
661
374
  $[0] !== props ? ({
662
375
  ...rest
@@ -668,7 +381,7 @@ function AnimatedSpinnerIcon(props) {
668
381
  }
669
382
  const DEFAULT_SPINNER_ELEMENT = "div";
670
383
  function Spinner(props) {
671
- const $ = reactCompilerRuntime.c(11), t0 = props;
384
+ const $ = compilerRuntime.c(11), t0 = props;
672
385
  let className, rest, t1;
673
386
  $[0] !== t0 ? ({
674
387
  as: t1,
@@ -693,7 +406,6 @@ function Button(props) {
693
406
  children,
694
407
  className,
695
408
  disabled,
696
- display = "inline-flex",
697
409
  flex,
698
410
  fontSize = 1,
699
411
  gap = props.space ?? props.padding ?? 3,
@@ -733,7 +445,6 @@ function Button(props) {
733
445
  ...rest,
734
446
  className: css.button({
735
447
  className,
736
- display,
737
448
  flex,
738
449
  mode,
739
450
  radius,
@@ -752,7 +463,7 @@ function Button(props) {
752
463
  react.isValidElement(IconComponent) && IconComponent,
753
464
  reactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
754
465
  ] }),
755
- text && /* @__PURE__ */ jsxRuntime.jsx(Text, { align: textAlign, as: "span", flex: "none", muted, size: fontSize, textOverflow, weight: textWeight, children: text }),
466
+ text && /* @__PURE__ */ jsxRuntime.jsx(Box, { as: "span", maxWidth: "auto", children: /* @__PURE__ */ jsxRuntime.jsx(Text, { align: textAlign, as: "span", muted, size: fontSize, textOverflow, weight: textWeight, children: text }) }),
756
467
  IconRightComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { as: "span", flex: "none", muted: !0, size: fontSize, children: [
757
468
  react.isValidElement(IconRightComponent) && IconRightComponent,
758
469
  reactIs.isValidElementType(IconRightComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconRightComponent, {})
@@ -768,7 +479,7 @@ function useCard() {
768
479
  }
769
480
  const DEFAULT_CARD_ELEMENT = "div";
770
481
  function Card(props) {
771
- const $ = reactCompilerRuntime.c(38), t0 = props;
482
+ const $ = compilerRuntime.c(38), t0 = props;
772
483
  let className, disabled, pressed, rest, schemeProp, selected, style, t1, t2, t3, t4, t5;
773
484
  $[0] !== t0 ? ({
774
485
  __unstable_checkered: t1,
@@ -806,90 +517,131 @@ function Card(props) {
806
517
  }
807
518
  return node;
808
519
  }
809
- const LazyRefractor = react.lazy(() => Promise.resolve().then(function() {
810
- return require("./refractor.cjs");
811
- })), DEFAULT_CODE_ELEMENT = "pre";
812
- function Code(props) {
813
- const $ = reactCompilerRuntime.c(25), t0 = props;
814
- let children, className, languageProp, rest, t1, t2, t3;
815
- $[0] !== t0 ? ({
816
- as: t1,
817
- children,
818
- className,
819
- language: languageProp,
820
- size: t2,
821
- weight: t3,
822
- ...rest
823
- } = 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]);
824
- 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;
825
- let t4;
826
- $[8] !== className || $[9] !== size2 || $[10] !== weight ? (t4 = css.code({
827
- className,
828
- size: size2,
829
- weight
830
- }), $[8] = className, $[9] = size2, $[10] = weight, $[11] = t4) : t4 = $[11];
831
- let t5;
832
- $[12] !== children ? (t5 = /* @__PURE__ */ jsxRuntime.jsx("code", { children }), $[12] = children, $[13] = t5) : t5 = $[13];
833
- let t6;
834
- $[14] !== children || $[15] !== language ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(LazyRefractor, { language, value: children }), $[14] = children, $[15] = language, $[16] = t6) : t6 = $[16];
835
- let t7;
836
- $[17] !== t5 || $[18] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback: t5, children: t6 }), $[17] = t5, $[18] = t6, $[19] = t7) : t7 = $[19];
837
- let t8;
838
- return $[20] !== Element || $[21] !== rest || $[22] !== t4 || $[23] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(Element, { "data-ui": "Code", ...rest, className: t4, children: t7 }), $[20] = Element, $[21] = rest, $[22] = t4, $[23] = t7, $[24] = t8) : t8 = $[24], t8;
520
+ function useMatchMedia(mediaQueryString, getServerSnapshot2) {
521
+ const $ = compilerRuntime.c(4);
522
+ react.useDebugValue(mediaQueryString);
523
+ let t0;
524
+ $[0] !== mediaQueryString ? (t0 = (onStoreChange) => {
525
+ const media2 = window.matchMedia(mediaQueryString);
526
+ return media2.addEventListener("change", onStoreChange), () => media2.removeEventListener("change", onStoreChange);
527
+ }, $[0] = mediaQueryString, $[1] = t0) : t0 = $[1];
528
+ let t1;
529
+ return $[2] !== mediaQueryString ? (t1 = () => window.matchMedia(mediaQueryString).matches, $[2] = mediaQueryString, $[3] = t1) : t1 = $[3], react.useSyncExternalStore(t0, t1, getServerSnapshot2);
839
530
  }
840
- const DEFAULT_FLEX_ELEMENT = "div";
841
- function Flex(props) {
842
- const $ = reactCompilerRuntime.c(14), t0 = props;
843
- let align, justify, rest, t1, t2, wrap;
844
- $[0] !== t0 ? ({
845
- align,
846
- as: t1,
847
- direction: t2,
848
- justify,
849
- wrap,
850
- ...rest
851
- } = 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]);
852
- const as = t1 === void 0 ? DEFAULT_FLEX_ELEMENT : t1, direction = t2 === void 0 ? "row" : t2;
853
- let t3;
854
- return $[7] !== align || $[8] !== as || $[9] !== direction || $[10] !== justify || $[11] !== rest || $[12] !== wrap ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Flex", ...rest, alignItems: align, as, display: "flex", flexDirection: direction, flexWrap: wrap, justifyContent: justify }), $[7] = align, $[8] = as, $[9] = direction, $[10] = justify, $[11] = rest, $[12] = wrap, $[13] = t3) : t3 = $[13], t3;
531
+ function usePrefersReducedMotion(t0) {
532
+ return useMatchMedia("(prefers-reduced-motion: reduce)", t0 === void 0 ? _temp$5 : t0);
855
533
  }
856
- const DEFAULT_GRID_ELEMENT = "div";
857
- function Grid(props) {
858
- const $ = reactCompilerRuntime.c(8), t0 = props;
859
- let children, rest, t1;
860
- $[0] !== t0 ? ({
861
- as: t1,
534
+ function _temp$5() {
535
+ return !1;
536
+ }
537
+ const origin = {
538
+ name: "@sanity/ui/origin",
539
+ fn({
540
+ middlewareData,
541
+ placement,
542
+ rects
543
+ }) {
544
+ const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
545
+ if (floatingWidth <= 0 || floatingHeight <= 0)
546
+ return {};
547
+ const isVerticalPlacement = ["bottom", "top"].includes(side), {
548
+ originX,
549
+ originY
550
+ } = isVerticalPlacement ? {
551
+ originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),
552
+ originY: side === "bottom" ? 0 : 1
553
+ } : {
554
+ originX: side === "left" ? 1 : 0,
555
+ originY: clamp(0.5 - shiftY / floatingHeight, 0, 1)
556
+ };
557
+ return {
558
+ data: {
559
+ originX,
560
+ originY
561
+ }
562
+ };
563
+ }
564
+ };
565
+ function clamp(num, min, max) {
566
+ return Math.min(Math.max(num, min), max);
567
+ }
568
+ const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null), DEFAULT_VALUE = {
569
+ version: 0,
570
+ element: null
571
+ };
572
+ function useBoundaryElement() {
573
+ const value = react.useContext(BoundaryElementContext);
574
+ if (value && (!isRecord(value) || value.version !== 0))
575
+ throw new Error("useBoundaryElement(): the context value is not compatible");
576
+ return value || DEFAULT_VALUE;
577
+ }
578
+ const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
579
+ globalScope[elementKey] = null;
580
+ const defaultContextValue = {
581
+ version: 0,
582
+ boundaryElement: null,
583
+ get element() {
584
+ return typeof document > "u" ? null : (globalScope[elementKey] || (globalScope[elementKey] = document.createElement("div"), globalScope[elementKey].setAttribute("data-portal", ""), document.body.appendChild(globalScope[elementKey])), globalScope[elementKey]);
585
+ }
586
+ }, PortalContext = createGlobalScopedContext(key, defaultContextValue);
587
+ function usePortal() {
588
+ const value = react.useContext(PortalContext);
589
+ if (!value)
590
+ throw new Error("usePortal(): missing context value");
591
+ if (!isRecord(value) || value.version !== 0)
592
+ throw new Error("usePortal(): the context value is not compatible");
593
+ return value;
594
+ }
595
+ function Portal(props) {
596
+ const $ = compilerRuntime.c(6), {
862
597
  children,
863
- ...rest
864
- } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1) : (children = $[1], rest = $[2], t1 = $[3]);
865
- const as = t1 === void 0 ? DEFAULT_GRID_ELEMENT : t1;
598
+ __unstable_name: name
599
+ } = props, card = useCard(), portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
600
+ if (!portalElement)
601
+ return null;
602
+ const t0 = card?.scheme || "light";
603
+ let t1;
604
+ $[0] !== children || $[1] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: "transparent", scheme: t0, children }), $[0] = children, $[1] = t0, $[2] = t1) : t1 = $[2];
866
605
  let t2;
867
- return $[4] !== as || $[5] !== children || $[6] !== rest ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Grid", ...rest, as, display: "grid", children }), $[4] = as, $[5] = children, $[6] = rest, $[7] = t2) : t2 = $[7], t2;
606
+ return $[3] !== portalElement || $[4] !== t1 ? (t2 = reactDom.createPortal(t1, portalElement), $[3] = portalElement, $[4] = t1, $[5] = t2) : t2 = $[5], t2;
868
607
  }
869
- const DEFAULT_KBD_ELEMENT = "kbd";
870
- function KBD(props) {
871
- const $ = reactCompilerRuntime.c(22), t0 = props;
872
- let children, className, rest, t1, t2, t3, t4, t5;
873
- $[0] !== t0 ? ({
874
- as: t1,
608
+ function PortalProvider(props) {
609
+ const $ = compilerRuntime.c(7), {
610
+ boundaryElement,
875
611
  children,
876
- className,
877
- display: t2,
878
- fontSize: t3,
879
- padding: t4,
880
- radius: t5,
881
- ...rest
882
- } = 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]);
883
- 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;
884
- let t7;
885
- $[9] !== className || $[10] !== radius ? (t7 = css.kbd({
886
- className,
887
- radius
888
- }), $[9] = className, $[10] = radius, $[11] = t7) : t7 = $[11];
889
- let t8;
890
- $[12] !== children || $[13] !== fontSize ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(Text, { as: "span", muted: !0, size: fontSize, weight: "semibold", children }), $[12] = children, $[13] = fontSize, $[14] = t8) : t8 = $[14];
891
- let t9;
892
- return $[15] !== display || $[16] !== padding || $[17] !== rest || $[18] !== t6 || $[19] !== t7 || $[20] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.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;
612
+ element,
613
+ __unstable_elements: elementsProp
614
+ } = props, elements = useUnique(elementsProp), fallbackElement = react.useSyncExternalStore(emptySubscribe, _temp$4, _temp2$2);
615
+ let t0;
616
+ const t1 = boundaryElement || null, t2 = element || fallbackElement;
617
+ let t3;
618
+ $[0] !== elements || $[1] !== t1 || $[2] !== t2 ? (t3 = {
619
+ version: 0,
620
+ boundaryElement: t1,
621
+ element: t2,
622
+ elements
623
+ }, $[0] = elements, $[1] = t1, $[2] = t2, $[3] = t3) : t3 = $[3], t0 = t3;
624
+ const value = t0;
625
+ let t4;
626
+ return $[4] !== children || $[5] !== value ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children }), $[4] = children, $[5] = value, $[6] = t4) : t4 = $[6], t4;
627
+ }
628
+ function _temp2$2() {
629
+ return null;
630
+ }
631
+ function _temp$4() {
632
+ return document.body;
633
+ }
634
+ const emptySubscribe = () => () => {
635
+ };
636
+ function useUnique(value) {
637
+ const valueRef = react.useRef(value);
638
+ return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
639
+ }
640
+ function _isEqual(objA, objB) {
641
+ if (!objA || !objB)
642
+ return objA === objB;
643
+ const keysA = Object.keys(objA), keysB = Object.keys(objB);
644
+ return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
893
645
  }
894
646
  function getLayerContext(contextValue) {
895
647
  if (!isRecord(contextValue) || contextValue.version !== 0)
@@ -902,7 +654,7 @@ function getLayerContext(contextValue) {
902
654
  }
903
655
  const LayerContext = createGlobalScopedContext("@sanity/ui/context/layer", null);
904
656
  function useLayer() {
905
- const $ = reactCompilerRuntime.c(2), value = react.useContext(LayerContext);
657
+ const $ = compilerRuntime.c(2), value = react.useContext(LayerContext);
906
658
  if (!value)
907
659
  throw new Error("useLayer(): missing context value");
908
660
  try {
@@ -915,7 +667,7 @@ function useLayer() {
915
667
  }
916
668
  const DEFAULT_LAYER_CARD_ELEMENT = "div";
917
669
  function LayerCard(props) {
918
- const $ = reactCompilerRuntime.c(27), t0 = props;
670
+ const $ = compilerRuntime.c(27), t0 = props;
919
671
  let children, forwardedRef, onActivate, onFocus, rest, t1, t2, t3;
920
672
  $[0] !== t0 ? ({
921
673
  as: t1,
@@ -954,8 +706,64 @@ function LayerCard(props) {
954
706
  let t10;
955
707
  return $[20] !== children || $[21] !== handleFocus || $[22] !== position || $[23] !== rest || $[24] !== t8 || $[25] !== t9 ? (t10 = /* @__PURE__ */ jsxRuntime.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;
956
708
  }
709
+ const media = Object.values(css.BREAKPOINTS);
710
+ function _getMediaQuery(media2, index) {
711
+ 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)`;
712
+ }
713
+ function _createMediaStore() {
714
+ const mediaLen = media.length;
715
+ let sizes;
716
+ const getSizes = () => {
717
+ if (!sizes) {
718
+ sizes = [];
719
+ for (let index = mediaLen; index > -1; index -= 1) {
720
+ const mediaQuery = _getMediaQuery(media, index);
721
+ sizes.push({
722
+ index,
723
+ mq: window.matchMedia(mediaQuery)
724
+ });
725
+ }
726
+ }
727
+ return sizes;
728
+ };
729
+ return {
730
+ getSnapshot: () => {
731
+ for (const {
732
+ index,
733
+ mq
734
+ } of getSizes())
735
+ if (mq.matches) return index;
736
+ return 0;
737
+ },
738
+ subscribe: (onStoreChange) => {
739
+ const disposeFns = [];
740
+ for (const {
741
+ mq
742
+ } of getSizes()) {
743
+ const handleChange = () => {
744
+ mq.matches && onStoreChange();
745
+ };
746
+ mq.addEventListener("change", handleChange), disposeFns.push(() => mq.removeEventListener("change", handleChange));
747
+ }
748
+ return () => {
749
+ for (const disposeFn of disposeFns)
750
+ disposeFn();
751
+ };
752
+ }
753
+ };
754
+ }
755
+ function getServerSnapshot() {
756
+ return 0;
757
+ }
758
+ function useMediaIndex() {
759
+ const $ = compilerRuntime.c(1);
760
+ let t0, t1;
761
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = _createMediaStore(), $[0] = t1) : t1 = $[0], t0 = t1;
762
+ const store = t0;
763
+ return react.useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
764
+ }
957
765
  function LayerProvider(props) {
958
- const $ = reactCompilerRuntime.c(19), {
766
+ const $ = compilerRuntime.c(19), {
959
767
  children,
960
768
  zOffset: t0
961
769
  } = props, zOffsetProp = t0 === void 0 ? 0 : t0, parentContextValue = react.useContext(LayerContext);
@@ -974,13 +782,13 @@ function LayerProvider(props) {
974
782
  [childLevel]: prevLen + 1
975
783
  };
976
784
  return setSize(Object.keys(nextState).length), nextState;
977
- }) : setSize(_temp$2), () => {
785
+ }) : setSize(_temp$3), () => {
978
786
  childLevel !== void 0 ? setChildLayers((state_0) => {
979
787
  const nextState_0 = {
980
788
  ...state_0
981
789
  };
982
790
  return nextState_0[childLevel] === 1 ? (delete nextState_0[childLevel], setSize(Object.keys(nextState_0).length)) : nextState_0[childLevel] = nextState_0[childLevel] - 1, nextState_0;
983
- }) : setSize(_temp2$2), parentDispose?.();
791
+ }) : setSize(_temp2$1), parentDispose?.();
984
792
  };
985
793
  }, $[3] = parentRegisterChild, $[4] = setChildLayers, $[5] = t3) : t3 = $[5];
986
794
  const registerChild = t3;
@@ -999,15 +807,15 @@ function LayerProvider(props) {
999
807
  let t8;
1000
808
  return $[16] !== children || $[17] !== value ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(LayerContext.Provider, { value, children }), $[16] = children, $[17] = value, $[18] = t8) : t8 = $[18], t8;
1001
809
  }
1002
- function _temp2$2(v_0) {
810
+ function _temp2$1(v_0) {
1003
811
  return v_0 - 1;
1004
812
  }
1005
- function _temp$2(v) {
813
+ function _temp$3(v) {
1006
814
  return v + 1;
1007
815
  }
1008
816
  const DEFAULT_LAYER_ELEMENT = "div";
1009
817
  function Layer(props) {
1010
- const $ = reactCompilerRuntime.c(12), t0 = props;
818
+ const $ = compilerRuntime.c(12), t0 = props;
1011
819
  let children, rest, t1, t2;
1012
820
  $[0] !== t0 ? ({
1013
821
  as: t1,
@@ -1021,163 +829,6 @@ function Layer(props) {
1021
829
  let t4;
1022
830
  return $[9] !== t3 || $[10] !== zOffset ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(LayerProvider, { zOffset, children: t3 }), $[9] = t3, $[10] = zOffset, $[11] = t4) : t4 = $[11], t4;
1023
831
  }
1024
- const origin = {
1025
- name: "@sanity/ui/origin",
1026
- fn({
1027
- middlewareData,
1028
- placement,
1029
- rects
1030
- }) {
1031
- const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
1032
- if (floatingWidth <= 0 || floatingHeight <= 0)
1033
- return {};
1034
- const isVerticalPlacement = ["bottom", "top"].includes(side), {
1035
- originX,
1036
- originY
1037
- } = isVerticalPlacement ? {
1038
- originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),
1039
- originY: side === "bottom" ? 0 : 1
1040
- } : {
1041
- originX: side === "left" ? 1 : 0,
1042
- originY: clamp(0.5 - shiftY / floatingHeight, 0, 1)
1043
- };
1044
- return {
1045
- data: {
1046
- originX,
1047
- originY
1048
- }
1049
- };
1050
- }
1051
- };
1052
- function clamp(num, min, max) {
1053
- return Math.min(Math.max(num, min), max);
1054
- }
1055
- const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null), DEFAULT_VALUE = {
1056
- version: 0,
1057
- element: null
1058
- };
1059
- function useBoundaryElement() {
1060
- const value = react.useContext(BoundaryElementContext);
1061
- if (value && (!isRecord(value) || value.version !== 0))
1062
- throw new Error("useBoundaryElement(): the context value is not compatible");
1063
- return value || DEFAULT_VALUE;
1064
- }
1065
- function findMaxBreakpoints(media2, width) {
1066
- const ret = [];
1067
- for (let i = 0; i < media2.length; i += 1)
1068
- media2[i] > width && ret.push(i);
1069
- return ret;
1070
- }
1071
- function findMinBreakpoints(media2, width) {
1072
- const ret = [];
1073
- for (let i = 0; i < media2.length; i += 1)
1074
- media2[i] <= width && ret.push(i);
1075
- return ret;
1076
- }
1077
- const DEFAULT_ELEMENT_QUERY_ELEMENT = "div", DEFAULT_BREAKPOINTS = Object.values(css.BREAKPOINTS);
1078
- function ElementQuery(props) {
1079
- const $ = reactCompilerRuntime.c(21), t0 = props;
1080
- let children, forwardedRef, mediaProp, rest, t1;
1081
- $[0] !== t0 ? ({
1082
- as: t1,
1083
- children,
1084
- media: mediaProp,
1085
- ref: forwardedRef,
1086
- ...rest
1087
- } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = mediaProp, $[4] = rest, $[5] = t1) : (children = $[1], forwardedRef = $[2], mediaProp = $[3], rest = $[4], t1 = $[5]);
1088
- const Element = t1 === void 0 ? DEFAULT_ELEMENT_QUERY_ELEMENT : t1, breakpoints = mediaProp ?? DEFAULT_BREAKPOINTS, [element, setElement] = react.useState(null), elementSize = useElementSize(element);
1089
- let t2;
1090
- t2 = elementSize?.border.width ?? window.innerWidth;
1091
- const width = t2;
1092
- let t3, t4;
1093
- if ($[6] !== breakpoints || $[7] !== width) {
1094
- const eq = findMaxBreakpoints(breakpoints, width);
1095
- t4 = eq.length ? eq.join(" ") : void 0, $[6] = breakpoints, $[7] = width, $[8] = t4;
1096
- } else
1097
- t4 = $[8];
1098
- t3 = t4;
1099
- const max = t3;
1100
- let t5, t6;
1101
- if ($[9] !== breakpoints || $[10] !== width) {
1102
- const eq_0 = findMinBreakpoints(breakpoints, width);
1103
- t6 = eq_0.length ? eq_0.join(" ") : void 0, $[9] = breakpoints, $[10] = width, $[11] = t6;
1104
- } else
1105
- t6 = $[11];
1106
- t5 = t6;
1107
- const min = t5;
1108
- let t7, t8;
1109
- $[12] !== element ? (t7 = () => element, t8 = [element], $[12] = element, $[13] = t7, $[14] = t8) : (t7 = $[13], t8 = $[14]), react.useImperativeHandle(forwardedRef, t7, t8);
1110
- let t9;
1111
- return $[15] !== Element || $[16] !== children || $[17] !== max || $[18] !== min || $[19] !== rest ? (t9 = /* @__PURE__ */ jsxRuntime.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;
1112
- }
1113
- const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
1114
- globalScope[elementKey] = null;
1115
- const defaultContextValue = {
1116
- version: 0,
1117
- boundaryElement: null,
1118
- get element() {
1119
- return typeof document > "u" ? null : (globalScope[elementKey] || (globalScope[elementKey] = document.createElement("div"), globalScope[elementKey].setAttribute("data-portal", ""), document.body.appendChild(globalScope[elementKey])), globalScope[elementKey]);
1120
- }
1121
- }, PortalContext = createGlobalScopedContext(key, defaultContextValue);
1122
- function usePortal() {
1123
- const value = react.useContext(PortalContext);
1124
- if (!value)
1125
- throw new Error("usePortal(): missing context value");
1126
- if (!isRecord(value) || value.version !== 0)
1127
- throw new Error("usePortal(): the context value is not compatible");
1128
- return value;
1129
- }
1130
- function Portal(props) {
1131
- const $ = reactCompilerRuntime.c(6), {
1132
- children,
1133
- __unstable_name: name
1134
- } = props, card = useCard(), portal = usePortal(), portalElement = (name ? portal.elements && portal.elements[name] : portal.element) || portal.elements?.default;
1135
- if (!portalElement)
1136
- return null;
1137
- const t0 = card?.scheme || "light";
1138
- let t1;
1139
- $[0] !== children || $[1] !== t0 ? (t1 = /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: "transparent", scheme: t0, children }), $[0] = children, $[1] = t0, $[2] = t1) : t1 = $[2];
1140
- let t2;
1141
- return $[3] !== portalElement || $[4] !== t1 ? (t2 = reactDom.createPortal(t1, portalElement), $[3] = portalElement, $[4] = t1, $[5] = t2) : t2 = $[5], t2;
1142
- }
1143
- function PortalProvider(props) {
1144
- const $ = reactCompilerRuntime.c(7), {
1145
- boundaryElement,
1146
- children,
1147
- element,
1148
- __unstable_elements: elementsProp
1149
- } = props, elements = useUnique(elementsProp), fallbackElement = react.useSyncExternalStore(emptySubscribe, _temp$1, _temp2$1);
1150
- let t0;
1151
- const t1 = boundaryElement || null, t2 = element || fallbackElement;
1152
- let t3;
1153
- $[0] !== elements || $[1] !== t1 || $[2] !== t2 ? (t3 = {
1154
- version: 0,
1155
- boundaryElement: t1,
1156
- element: t2,
1157
- elements
1158
- }, $[0] = elements, $[1] = t1, $[2] = t2, $[3] = t3) : t3 = $[3], t0 = t3;
1159
- const value = t0;
1160
- let t4;
1161
- return $[4] !== children || $[5] !== value ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(PortalContext.Provider, { value, children }), $[4] = children, $[5] = value, $[6] = t4) : t4 = $[6], t4;
1162
- }
1163
- function _temp2$1() {
1164
- return null;
1165
- }
1166
- function _temp$1() {
1167
- return document.body;
1168
- }
1169
- const emptySubscribe = () => () => {
1170
- };
1171
- function useUnique(value) {
1172
- const valueRef = react.useRef(value);
1173
- return _isEqual(valueRef.current, value) || (valueRef.current = value), valueRef.current;
1174
- }
1175
- function _isEqual(objA, objB) {
1176
- if (!objA || !objB)
1177
- return objA === objB;
1178
- const keysA = Object.keys(objA), keysB = Object.keys(objB);
1179
- return keysA.length !== keysB.length ? !1 : keysA.every((key2) => objA[key2] === objB[key2]);
1180
- }
1181
832
  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 = {
1182
833
  top: ["bottom", "left", "right"],
1183
834
  "top-start": ["bottom-start", "left-start", "right-start"],
@@ -1233,8 +884,131 @@ function size(options) {
1233
884
  }
1234
885
  };
1235
886
  }
887
+ function moveTowardsLength(movingPoint, targetPoint, amount) {
888
+ const width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
889
+ return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
890
+ }
891
+ function moveTowardsFractional(movingPoint, targetPoint, fraction) {
892
+ return {
893
+ x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
894
+ y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
895
+ };
896
+ }
897
+ function getRoundedCommands(points) {
898
+ const len = points.length, cmds = [];
899
+ for (let i = 0; i < len; i += 1) {
900
+ const point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
901
+ if (prevPoint && point.radius) {
902
+ 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);
903
+ cmds.push({
904
+ type: "point",
905
+ ...curveStart
906
+ }), cmds.push({
907
+ type: "curve",
908
+ curveEnd,
909
+ startControl,
910
+ endControl
911
+ });
912
+ } else
913
+ cmds.push({
914
+ type: "point",
915
+ ...point
916
+ });
917
+ }
918
+ return cmds;
919
+ }
920
+ function compileCommands(cmds) {
921
+ 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(" ");
922
+ }
923
+ const DEFAULT_ARROW_ELEMENT = "div";
924
+ function Arrow(props) {
925
+ const $ = compilerRuntime.c(34), t0 = props;
926
+ let h, rest, style, t1, t2, w;
927
+ $[0] !== t0 ? ({
928
+ as: t1,
929
+ width: w,
930
+ height: h,
931
+ radius: t2,
932
+ style,
933
+ ...rest
934
+ } = 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]);
935
+ const Element = t1 === void 0 ? DEFAULT_ARROW_ELEMENT : t1, radius = t2 === void 0 ? 0 : t2, center = w / 2;
936
+ let t3;
937
+ const points = [{
938
+ x: 0,
939
+ y: 0
940
+ }, {
941
+ x: radius,
942
+ y: 0,
943
+ radius
944
+ }, {
945
+ x: center,
946
+ y: h - 1,
947
+ radius
948
+ }, {
949
+ x: w - radius,
950
+ y: 0,
951
+ radius
952
+ }, {
953
+ x: w,
954
+ y: 0
955
+ }], cmds = getRoundedCommands(points);
956
+ t3 = compileCommands(cmds);
957
+ const path = t3, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`;
958
+ let t4;
959
+ $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = css._arrow(), $[7] = t4) : t4 = $[7];
960
+ const t5 = `${w}px`;
961
+ let t6;
962
+ $[8] !== t5 ? (t6 = dynamic.assignInlineVars({
963
+ [css.vars.arrow.size]: t5
964
+ }), $[8] = t5, $[9] = t6) : t6 = $[9];
965
+ let t7;
966
+ $[10] !== style || $[11] !== t6 ? (t7 = {
967
+ ...style,
968
+ ...t6
969
+ }, $[10] = style, $[11] = t6, $[12] = t7) : t7 = $[12];
970
+ let t8;
971
+ $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = css._arrowSvg(), $[13] = t8) : t8 = $[13];
972
+ const t9 = `0 0 ${w} ${w}`;
973
+ let t10;
974
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t10 = css._arrowStrokeMask(), $[14] = t10) : t10 = $[14];
975
+ let t11;
976
+ $[15] !== w ? (t11 = /* @__PURE__ */ jsxRuntime.jsx("mask", { id: "stroke-mask", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { className: t10, x: 0, width: w, height: w, fill: "white" }) }), $[15] = w, $[16] = t11) : t11 = $[16];
977
+ let t12;
978
+ $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = css._arrowStroke(), $[17] = t12) : t12 = $[17];
979
+ let t13;
980
+ $[18] !== strokePath ? (t13 = /* @__PURE__ */ jsxRuntime.jsx("path", { className: t12, d: strokePath, mask: "url(#stroke-mask)" }), $[18] = strokePath, $[19] = t13) : t13 = $[19];
981
+ let t14;
982
+ $[20] === Symbol.for("react.memo_cache_sentinel") ? (t14 = css._arrowShape(), $[20] = t14) : t14 = $[20];
983
+ let t15;
984
+ $[21] !== fillPath ? (t15 = /* @__PURE__ */ jsxRuntime.jsx("path", { className: t14, d: fillPath }), $[21] = fillPath, $[22] = t15) : t15 = $[22];
985
+ let t16;
986
+ $[23] !== t11 || $[24] !== t13 || $[25] !== t15 || $[26] !== t9 || $[27] !== w ? (t16 = /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: t8, width: w, height: w, viewBox: t9, children: [
987
+ t11,
988
+ t13,
989
+ t15
990
+ ] }), $[23] = t11, $[24] = t13, $[25] = t15, $[26] = t9, $[27] = w, $[28] = t16) : t16 = $[28];
991
+ let t17;
992
+ return $[29] !== Element || $[30] !== rest || $[31] !== t16 || $[32] !== t7 ? (t17 = /* @__PURE__ */ jsxRuntime.jsx(Element, { ...rest, className: t4, style: t7, children: t16 }), $[29] = Element, $[30] = rest, $[31] = t16, $[32] = t7, $[33] = t17) : t17 = $[33], t17;
993
+ }
994
+ const DEFAULT_FLEX_ELEMENT = "div";
995
+ function Flex(props) {
996
+ const $ = compilerRuntime.c(14), t0 = props;
997
+ let align, justify, rest, t1, t2, wrap;
998
+ $[0] !== t0 ? ({
999
+ align,
1000
+ as: t1,
1001
+ direction: t2,
1002
+ justify,
1003
+ wrap,
1004
+ ...rest
1005
+ } = 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]);
1006
+ const as = t1 === void 0 ? DEFAULT_FLEX_ELEMENT : t1, direction = t2 === void 0 ? "row" : t2;
1007
+ let t3;
1008
+ return $[7] !== align || $[8] !== as || $[9] !== direction || $[10] !== justify || $[11] !== rest || $[12] !== wrap ? (t3 = /* @__PURE__ */ jsxRuntime.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;
1009
+ }
1236
1010
  function PopoverLayer(props) {
1237
- const $ = reactCompilerRuntime.c(65);
1011
+ const $ = compilerRuntime.c(65);
1238
1012
  let animate, arrow, arrowRef, arrowX, arrowY, children, marginsProp, maxWidth, originX, originY, overflow, padding, placement, radius, referenceWidth, rest, shadow, strategy, style, t0, xProp, yProp;
1239
1013
  $[0] !== props ? ({
1240
1014
  __unstable_margins: marginsProp,
@@ -1309,7 +1083,7 @@ function PopoverLayer(props) {
1309
1083
  }
1310
1084
  const DEFAULT_POPOVER_ELEMENT = "div";
1311
1085
  function ViewportOverlay() {
1312
- const $ = reactCompilerRuntime.c(2), {
1086
+ const $ = compilerRuntime.c(2), {
1313
1087
  zIndex
1314
1088
  } = useLayer();
1315
1089
  let t0;
@@ -1439,7 +1213,7 @@ function getElementRef$1(element) {
1439
1213
  }
1440
1214
  const DEFAULT_STACK_ELEMENT = "div";
1441
1215
  function Stack(props) {
1442
- const $ = reactCompilerRuntime.c(13), t0 = props;
1216
+ const $ = compilerRuntime.c(13), t0 = props;
1443
1217
  let className, gap, rest, space, t1;
1444
1218
  $[0] !== t0 ? ({
1445
1219
  as: t1,
@@ -1457,9 +1231,18 @@ function Stack(props) {
1457
1231
  let t4;
1458
1232
  return $[8] !== as || $[9] !== rest || $[10] !== t2 || $[11] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.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;
1459
1233
  }
1234
+ function useCustomValidity(ref, customValidity) {
1235
+ const $ = compilerRuntime.c(6);
1236
+ let t0;
1237
+ $[0] !== customValidity || $[1] !== ref.current ? (t0 = () => {
1238
+ ref.current?.setCustomValidity(customValidity || "");
1239
+ }, $[0] = customValidity, $[1] = ref.current, $[2] = t0) : t0 = $[2];
1240
+ let t1;
1241
+ $[3] !== customValidity || $[4] !== ref ? (t1 = [customValidity, ref], $[3] = customValidity, $[4] = ref, $[5] = t1) : t1 = $[5], react.useEffect(t0, t1);
1242
+ }
1460
1243
  const DEFAULT_TEXT_INPUT_ELEMENT = "input";
1461
1244
  function TextInput(props) {
1462
- const $ = reactCompilerRuntime.c(89), t0 = props;
1245
+ const $ = compilerRuntime.c(89), t0 = props;
1463
1246
  let IconComponent, IconRightComponent, __unstable_disableFocusRing, className, clearButton, customValidity, forwardedRef, gap, onClear, prefix, readOnly, rest, suffix, t1, t2, t3, t4, t5, t6, t7, t8, width;
1464
1247
  if ($[0] !== t0) {
1465
1248
  const {
@@ -1493,7 +1276,7 @@ function TextInput(props) {
1493
1276
  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 = react.useRef(null), responsivePadding = useResponsiveProp(padding), withClearButton = !!clearButton;
1494
1277
  let t9;
1495
1278
  $[23] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => ref.current, $[23] = t9) : t9 = $[23], react.useImperativeHandle(forwardedRef, t9), useCustomValidity(ref, customValidity);
1496
- const handleClearMouseDown = _temp;
1279
+ const handleClearMouseDown = _temp$2;
1497
1280
  let t10;
1498
1281
  $[24] !== onClear ? (t10 = (event_0) => {
1499
1282
  event_0.preventDefault(), event_0.stopPropagation(), onClear && onClear(), ref.current?.focus();
@@ -1572,258 +1355,84 @@ function _temp2(t0) {
1572
1355
  const [key2, value] = t0;
1573
1356
  return value === 0 ? [key2, 0] : value === 1 ? [key2, 1] : value === 2 ? [key2, 1] : [key2, typeof value == "number" ? value - 2 : 0];
1574
1357
  }
1575
- function _temp(event) {
1358
+ function _temp$2(event) {
1576
1359
  event.preventDefault(), event.stopPropagation();
1577
1360
  }
1578
- function useDelayedState(initialState) {
1579
- const $ = reactCompilerRuntime.c(3), [state, setState] = react.useState(initialState), delayedAction = react.useRef(void 0);
1580
- let t0;
1581
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (nextState, delay) => {
1582
- const action = () => {
1583
- setState(nextState);
1584
- };
1585
- if (delayedAction.current && (clearTimeout(delayedAction.current), delayedAction.current = void 0), !delay)
1586
- return action();
1587
- delayedAction.current = setTimeout(action, delay);
1588
- }, $[0] = t0) : t0 = $[0];
1589
- const onStateChange = t0;
1361
+ function useClickOutsideEvent(listener, t0, boundaryElement) {
1362
+ const $ = compilerRuntime.c(9), elementsArg = t0 === void 0 ? _temp$1 : t0;
1590
1363
  let t1;
1591
- return $[1] !== state ? (t1 = [state, onStateChange], $[1] = state, $[2] = t1) : t1 = $[2], t1;
1364
+ $[0] !== boundaryElement || $[1] !== elementsArg || $[2] !== listener ? (t1 = (evt) => {
1365
+ if (!listener)
1366
+ return;
1367
+ const target = evt.target;
1368
+ if (!(target instanceof Node))
1369
+ return;
1370
+ const resolvedBoundaryElement = boundaryElement?.();
1371
+ if (resolvedBoundaryElement && !resolvedBoundaryElement.contains(target))
1372
+ return;
1373
+ const elements = elementsArg().flat();
1374
+ for (const el of elements)
1375
+ if (el && (target === el || el.contains(target)))
1376
+ return;
1377
+ listener(evt);
1378
+ }, $[0] = boundaryElement, $[1] = elementsArg, $[2] = listener, $[3] = t1) : t1 = $[3];
1379
+ const onEvent = useEffectEvent.useEffectEvent(t1), hasListener = !!listener;
1380
+ let t2;
1381
+ $[4] !== hasListener || $[5] !== onEvent ? (t2 = () => {
1382
+ if (!hasListener)
1383
+ return;
1384
+ const handleEvent = (evt_0) => onEvent(evt_0);
1385
+ return document.addEventListener("mousedown", handleEvent), () => {
1386
+ document.removeEventListener("mousedown", handleEvent);
1387
+ };
1388
+ }, $[4] = hasListener, $[5] = onEvent, $[6] = t2) : t2 = $[6];
1389
+ let t3;
1390
+ $[7] !== hasListener ? (t3 = [hasListener], $[7] = hasListener, $[8] = t3) : t3 = $[8], react.useEffect(t2, t3), react.useDebugValue(listener ? "MouseDown On" : "MouseDown Off");
1592
1391
  }
1593
- function getElementRef(element) {
1594
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
1595
- 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);
1392
+ function _temp$1() {
1393
+ return EMPTY_ARRAY;
1596
1394
  }
1597
- 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 = {
1598
- top: ["top-end", "top-start", "bottom", "left", "right"],
1599
- "top-start": ["top", "top-end", "bottom-start", "left-start", "right-start"],
1600
- "top-end": ["top", "top-start", "bottom-end", "left-end", "right-end"],
1601
- bottom: ["bottom-end", "bottom-start", "top", "left", "right"],
1602
- "bottom-start": ["bottom", "bottom-end", "top-start", "left-start", "right-start"],
1603
- "bottom-end": ["bottom", "bottom-start", "top-end", "left-end", "right-end"],
1604
- left: ["left-end", "left-start", "right", "top", "bottom"],
1605
- "left-start": ["left", "left-end", "right-start", "top-start", "bottom-start"],
1606
- "left-end": ["left", "left-start", "right-end", "top-end", "bottom-end"],
1607
- right: ["right-end", "right-start", "left", "top", "bottom"],
1608
- "right-start": ["right", "right-end", "left-start", "top-start", "bottom-start"],
1609
- "right-end": ["right", "right-start", "left-end", "top-end", "bottom-end"]
1610
- }, TooltipDelayGroupContext = createGlobalScopedContext("@sanity/ui/context/tooltipDelayGroup", null);
1611
- function useTooltipDelayGroup() {
1612
- return react.useContext(TooltipDelayGroupContext);
1395
+ function useGlobalKeyDown(onKeyDown) {
1396
+ const $ = compilerRuntime.c(5);
1397
+ let t0;
1398
+ $[0] !== onKeyDown ? (t0 = (event) => onKeyDown(event), $[0] = onKeyDown, $[1] = t0) : t0 = $[1];
1399
+ const handleKeyDown = useEffectEvent.useEffectEvent(t0);
1400
+ let t1;
1401
+ $[2] !== handleKeyDown ? (t1 = () => {
1402
+ const handler = (event_0) => handleKeyDown(event_0);
1403
+ return window.addEventListener("keydown", handler), () => window.removeEventListener("keydown", handler);
1404
+ }, $[2] = handleKeyDown, $[3] = t1) : t1 = $[3];
1405
+ let t2;
1406
+ $[4] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [], $[4] = t2) : t2 = $[4], react.useEffect(t1, t2);
1613
1407
  }
1614
- function TooltipLayer(props) {
1615
- const $ = reactCompilerRuntime.c(50);
1616
- let animate, arrow, arrowRef, arrowX, arrowY, children, originX, originY, padding, placement, radius, rest, scheme, shadow, style, t0;
1617
- $[0] !== props ? ({
1618
- animate,
1619
- arrow,
1620
- arrowRef,
1621
- arrowX,
1622
- arrowY,
1408
+ const DEFAULT_KBD_ELEMENT = "kbd";
1409
+ function KBD(props) {
1410
+ const $ = compilerRuntime.c(22), t0 = props;
1411
+ let children, className, rest, t1, t2, t3, t4, t5;
1412
+ $[0] !== t0 ? ({
1413
+ as: t1,
1623
1414
  children,
1624
- originX,
1625
- originY,
1626
- padding,
1627
- placement,
1628
- radius,
1629
- scheme,
1630
- shadow,
1631
- style,
1632
- tone: t0,
1415
+ className,
1416
+ display: t2,
1417
+ fontSize: t3,
1418
+ padding: t4,
1419
+ radius: t5,
1633
1420
  ...rest
1634
- } = props, $[0] = props, $[1] = animate, $[2] = arrow, $[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], arrow = $[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]);
1635
- const tone = t0 === void 0 ? "inherit" : t0;
1636
- let t1;
1637
- const t2 = animate ? "transform" : void 0;
1638
- let t3;
1639
- $[17] !== originX || $[18] !== originY || $[19] !== style || $[20] !== t2 ? (t3 = {
1640
- originX,
1641
- originY,
1642
- willChange: t2,
1643
- ...style
1644
- }, $[17] = originX, $[18] = originY, $[19] = style, $[20] = t2, $[21] = t3) : t3 = $[21], t1 = t3;
1645
- const rootStyle = t1;
1646
- let t4;
1647
- const t5 = arrowX !== null ? arrowX : void 0, t6 = arrowY !== null ? arrowY : void 0;
1421
+ } = 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]);
1422
+ 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;
1648
1423
  let t7;
1649
- $[22] !== t5 || $[23] !== t6 ? (t7 = {
1650
- left: t5,
1651
- top: t6,
1652
- right: void 0,
1653
- bottom: void 0
1654
- }, $[22] = t5, $[23] = t6, $[24] = t7) : t7 = $[24], t4 = t7;
1655
- const arrowStyle = t4, t8 = animate ? "" : void 0;
1656
- let t9;
1657
- $[25] !== animate ? (t9 = animate ? ["hidden", "initial"] : void 0, $[25] = animate, $[26] = t9) : t9 = $[26];
1658
- let t10;
1659
- $[27] !== animate ? (t10 = animate ? ["visible", "scaleIn"] : void 0, $[27] = animate, $[28] = t10) : t10 = $[28];
1660
- let t11;
1661
- $[29] !== animate ? (t11 = animate ? ["hidden", "scaleOut"] : void 0, $[29] = animate, $[30] = t11) : t11 = $[30];
1662
- let t12;
1663
- $[31] !== arrow || $[32] !== arrowRef || $[33] !== arrowStyle ? (t12 = arrow && /* @__PURE__ */ jsxRuntime.jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_TOOLTIP_ARROW_WIDTH, height: DEFAULT_TOOLTIP_ARROW_HEIGHT, radius: DEFAULT_TOOLTIP_ARROW_RADIUS }), $[31] = arrow, $[32] = arrowRef, $[33] = arrowStyle, $[34] = t12) : t12 = $[34];
1664
- let t13;
1665
- 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__ */ jsxRuntime.jsxs(Layer, { "data-ui": "Tooltip__layer", ...rest, as: framerMotion.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: [
1666
- children,
1667
- t12
1668
- ] }), $[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;
1669
- }
1670
- const DEFAULT_TOOLTIP_ELEMENT = "div";
1671
- function Tooltip(props) {
1672
- const boundaryElementContext = useBoundaryElement(), {
1673
- animate: _animate = !1,
1674
- arrow: arrowProp = !1,
1675
- as = DEFAULT_TOOLTIP_ELEMENT,
1676
- boundaryElement = boundaryElementContext?.element,
1677
- children: childProp,
1424
+ $[9] !== className || $[10] !== radius ? (t7 = css.kbd({
1678
1425
  className,
1679
- content,
1680
- delay,
1681
- disabled,
1682
- fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"],
1683
- padding = 2,
1684
- placement: placementProp = "bottom",
1685
- portal: portalProp,
1686
- radius = 3,
1687
- ref: forwardedRef,
1688
- scheme,
1689
- shadow = 2,
1690
- zOffset = Z_OFFSETS.tooltip,
1691
- tone = "inherit",
1692
- ...rest
1693
- } = props, card = useCard(), animate = usePrefersReducedMotion() ? !1 : _animate, ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport", [tooltipMaxWidth, setTooltipMaxWidth] = react.useState(0);
1694
- react.useImperativeHandle(forwardedRef, () => ref.current);
1695
- const portal = usePortal(), portalElement = typeof portalProp == "string" ? portal.elements?.[portalProp] || null : portal.element, middleware = react.useMemo(() => {
1696
- const ret = [];
1697
- return ret.push(reactDom$1.flip({
1698
- boundary: boundaryElement || void 0,
1699
- fallbackPlacements,
1700
- padding: DEFAULT_TOOLTIP_PADDING,
1701
- rootBoundary
1702
- })), ret.push(reactDom$1.offset({
1703
- mainAxis: DEFAULT_TOOLTIP_DISTANCE
1704
- })), ret.push(reactDom$1.shift({
1705
- boundary: boundaryElement || void 0,
1706
- rootBoundary,
1707
- padding: DEFAULT_TOOLTIP_PADDING
1708
- })), arrowProp && ret.push(reactDom$1.arrow({
1709
- element: arrowRef,
1710
- padding: DEFAULT_TOOLTIP_PADDING
1711
- })), animate && ret.push(origin), ret;
1712
- }, [animate, arrowProp, boundaryElement, fallbackPlacements]), {
1713
- floatingStyles,
1714
- placement,
1715
- middlewareData,
1716
- refs,
1717
- update
1718
- } = reactDom$1.useFloating({
1719
- middleware,
1720
- placement: placementProp,
1721
- whileElementsMounted: reactDom$1.autoUpdate,
1722
- elements: {
1723
- reference: referenceElement
1724
- },
1725
- transform: !1
1726
- }), arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, tooltipId = react.useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), {
1727
- setIsGroupActive,
1728
- setOpenTooltipId
1729
- } = 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 = react.useCallback((open, immediate) => {
1730
- if (isInsideGroup)
1731
- if (open) {
1732
- const groupedOpenDelay = immediate ? 0 : openDelay;
1733
- setIsGroupActive?.(open, groupedOpenDelay), setOpenTooltipId?.(tooltipId, groupedOpenDelay);
1734
- } else {
1735
- const groupDeactivateDelay = closeDelay > 200 ? closeDelay : 200;
1736
- setIsGroupActive?.(open, groupDeactivateDelay), setOpenTooltipId?.(null, immediate ? 0 : closeDelay);
1737
- }
1738
- else
1739
- setIsOpen(open, immediate ? 0 : open ? openDelay : closeDelay);
1740
- }, [isInsideGroup, openDelay, setIsGroupActive, setOpenTooltipId, tooltipId, closeDelay, setIsOpen]), handleBlur = react.useCallback((e) => {
1741
- handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
1742
- }, [childProp?.props, handleIsOpenChange]), handleClick = react.useCallback((e_0) => {
1743
- handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e_0);
1744
- }, [childProp?.props, handleIsOpenChange]), handleContextMenu = react.useCallback((e_1) => {
1745
- handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e_1);
1746
- }, [childProp?.props, handleIsOpenChange]), handleFocus = react.useCallback((e_2) => {
1747
- handleIsOpenChange(!0), childProp?.props?.onFocus?.(e_2);
1748
- }, [childProp?.props, handleIsOpenChange]), handleMouseEnter = react.useCallback((e_3) => {
1749
- handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e_3);
1750
- }, [childProp?.props, handleIsOpenChange]), handleMouseLeave = react.useCallback((e_4) => {
1751
- handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e_4);
1752
- }, [childProp?.props, handleIsOpenChange]);
1753
- useCloseOnMouseLeave({
1754
- handleIsOpenChange,
1755
- referenceElement,
1756
- showTooltip,
1757
- isInsideGroup
1758
- }), react.useEffect(() => {
1759
- disabled && showTooltip && handleIsOpenChange(!1);
1760
- }, [disabled, handleIsOpenChange, showTooltip]), react.useEffect(() => {
1761
- !content && showTooltip && handleIsOpenChange(!1);
1762
- }, [content, handleIsOpenChange, showTooltip]), react.useEffect(() => {
1763
- if (!showTooltip) return;
1764
- function handleWindowKeyDown(event) {
1765
- event.key === "Escape" && handleIsOpenChange(!1, !0);
1766
- }
1767
- return window.addEventListener("keydown", handleWindowKeyDown), () => {
1768
- window.removeEventListener("keydown", handleWindowKeyDown);
1769
- };
1770
- }, [handleIsOpenChange, showTooltip]), react.useLayoutEffect(() => {
1771
- const availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
1772
- setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
1773
- }, [boundaryElement, portalElement]);
1774
- const setArrow = react.useCallback((arrowEl) => {
1775
- arrowRef.current = arrowEl, update();
1776
- }, [update]), setFloating = react.useCallback((node) => {
1777
- ref.current = node, refs.setFloating(node);
1778
- }, [refs]), child = react.useMemo(() => childProp ? react.cloneElement(childProp, {
1779
- onBlur: handleBlur,
1780
- onFocus: handleFocus,
1781
- onMouseEnter: handleMouseEnter,
1782
- onMouseLeave: handleMouseLeave,
1783
- onClick: handleClick,
1784
- onContextMenu: handleContextMenu,
1785
- ref: setReferenceElement
1786
- }) : null, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave]);
1787
- if (react.useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
1788
- if (disabled) return child;
1789
- const node_0 = /* @__PURE__ */ jsxRuntime.jsx(TooltipLayer, { "data-ui": "Tooltip", ...rest, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: css.tooltip({
1790
- className
1791
- }), originX, originY, padding, placement, radius, ref: setFloating, scheme, shadow, style: {
1792
- ...floatingStyles,
1793
- maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
1794
- }, tone, zOffset, children: content }), children = showTooltip && (portalProp ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portalProp == "string" ? portalProp : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: tone === "inherit" ? card?.tone ?? "default" : tone, scheme: scheme ?? "light", children: node_0 }) }) : node_0);
1795
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1796
- animate ? /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }) : children,
1797
- child
1798
- ] });
1799
- }
1800
- function useCloseOnMouseLeave(t0) {
1801
- const $ = reactCompilerRuntime.c(10), {
1802
- handleIsOpenChange,
1803
- referenceElement,
1804
- showTooltip,
1805
- isInsideGroup
1806
- } = t0;
1807
- let t1;
1808
- $[0] !== handleIsOpenChange || $[1] !== referenceElement ? (t1 = (target, teardown) => {
1809
- referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
1810
- }, $[0] = handleIsOpenChange, $[1] = referenceElement, $[2] = t1) : t1 = $[2];
1811
- const onMouseMove = useEffectEvent.useEffectEvent(t1);
1812
- let t2;
1813
- $[3] !== isInsideGroup || $[4] !== onMouseMove || $[5] !== showTooltip ? (t2 = () => {
1814
- if (!showTooltip || isInsideGroup)
1815
- return;
1816
- const handleMouseMove = (event) => {
1817
- onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
1818
- };
1819
- return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
1820
- }, $[3] = isInsideGroup, $[4] = onMouseMove, $[5] = showTooltip, $[6] = t2) : t2 = $[6];
1821
- let t3;
1822
- $[7] !== isInsideGroup || $[8] !== showTooltip ? (t3 = [isInsideGroup, showTooltip], $[7] = isInsideGroup, $[8] = showTooltip, $[9] = t3) : t3 = $[9], react.useEffect(t2, t3);
1426
+ radius
1427
+ }), $[9] = className, $[10] = radius, $[11] = t7) : t7 = $[11];
1428
+ let t8;
1429
+ $[12] !== children || $[13] !== fontSize ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(Text, { as: "span", muted: !0, size: fontSize, weight: "semibold", children }), $[12] = children, $[13] = fontSize, $[14] = t8) : t8 = $[14];
1430
+ let t9;
1431
+ return $[15] !== display || $[16] !== padding || $[17] !== rest || $[18] !== t6 || $[19] !== t7 || $[20] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.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;
1823
1432
  }
1824
1433
  const DEFAULT_HOTKEYS_ELEMENT = "kbd";
1825
1434
  function Hotkeys(props) {
1826
- const $ = reactCompilerRuntime.c(27), t0 = props;
1435
+ const $ = compilerRuntime.c(27), t0 = props;
1827
1436
  let fontSize, gap, gapX, gapY, keys, padding, radius, rest, t1, t2;
1828
1437
  $[0] !== t0 ? ({
1829
1438
  as: t1,
@@ -1990,7 +1599,7 @@ function useMenuController(props) {
1990
1599
  }
1991
1600
  const DEFAULT_MENU_ELEMENT = "div";
1992
1601
  function Menu(props) {
1993
- const $ = reactCompilerRuntime.c(58), t0 = props;
1602
+ const $ = compilerRuntime.c(58), t0 = props;
1994
1603
  let _shouldFocus, children, className, forwardedRef, gap, onClickOutside, onEscape, onItemClick, onItemSelect, onKeyDown, originElement, registerElement, rest, t1, t2, t3;
1995
1604
  if ($[0] !== t0) {
1996
1605
  const {
@@ -2082,7 +1691,7 @@ function Menu(props) {
2082
1691
  }
2083
1692
  const DEFAULT_MENU_DIVIDER_ELEMENT = "hr";
2084
1693
  function MenuDivider(props) {
2085
- const $ = reactCompilerRuntime.c(10), t0 = props;
1694
+ const $ = compilerRuntime.c(10), t0 = props;
2086
1695
  let className, rest, t1;
2087
1696
  $[0] !== t0 ? ({
2088
1697
  as: t1,
@@ -2099,24 +1708,26 @@ function MenuDivider(props) {
2099
1708
  }
2100
1709
  const DEFAULT_SELECTABLE_ELEMENT = "button";
2101
1710
  function Selectable(props) {
2102
- const $ = reactCompilerRuntime.c(14), t0 = props;
2103
- let className, radius, rest, t1, tone;
1711
+ const $ = compilerRuntime.c(16), t0 = props;
1712
+ let className, radius, rest, selected, t1, tone;
2104
1713
  $[0] !== t0 ? ({
2105
1714
  as: t1,
2106
1715
  className,
2107
1716
  radius,
1717
+ selected,
2108
1718
  tone,
2109
1719
  ...rest
2110
- } = t0, $[0] = t0, $[1] = className, $[2] = radius, $[3] = rest, $[4] = t1, $[5] = tone) : (className = $[1], radius = $[2], rest = $[3], t1 = $[4], tone = $[5]);
1720
+ } = 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]);
2111
1721
  const as = t1 === void 0 ? DEFAULT_SELECTABLE_ELEMENT : t1;
2112
1722
  let t2;
2113
- $[6] !== className || $[7] !== radius || $[8] !== tone ? (t2 = css._selectable({
1723
+ $[7] !== className || $[8] !== radius || $[9] !== tone ? (t2 = css._selectable({
2114
1724
  className,
2115
1725
  radius,
2116
1726
  tone
2117
- }), $[6] = className, $[7] = radius, $[8] = tone, $[9] = t2) : t2 = $[9];
2118
- let t3;
2119
- return $[10] !== as || $[11] !== rest || $[12] !== t2 ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(Box, { ...rest, as, className: t2 }), $[10] = as, $[11] = rest, $[12] = t2, $[13] = t3) : t3 = $[13], t3;
1727
+ }), $[7] = className, $[8] = radius, $[9] = tone, $[10] = t2) : t2 = $[10];
1728
+ const t3 = selected ? "" : void 0;
1729
+ let t4;
1730
+ return $[11] !== as || $[12] !== rest || $[13] !== t2 || $[14] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(Box, { ...rest, as, className: t2, "data-selected": t3 }), $[11] = as, $[12] = rest, $[13] = t2, $[14] = t3, $[15] = t4) : t4 = $[15], t4;
2120
1731
  }
2121
1732
  function useMenu() {
2122
1733
  const value = react.useContext(MenuContext);
@@ -2128,7 +1739,7 @@ function useMenu() {
2128
1739
  }
2129
1740
  const DEFAULT_MENU_GROUP_ELEMENT = "button";
2130
1741
  function MenuGroup(props) {
2131
- const $ = reactCompilerRuntime.c(79), t0 = props;
1742
+ const $ = compilerRuntime.c(78), t0 = props;
2132
1743
  let IconComponent, children, gap, menuProps, onClick, popover, rest, t1, t2, t3, t4, t5, t6, text;
2133
1744
  $[0] !== t0 ? ({
2134
1745
  as: t1,
@@ -2208,32 +1819,32 @@ function MenuGroup(props) {
2208
1819
  return;
2209
1820
  }
2210
1821
  }, $[46] = t21) : t21 = $[46];
2211
- 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;
2212
- let t27;
2213
- $[47] !== IconComponent || $[48] !== fontSize ? (t27 = IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize, children: [
1822
+ const handleKeyDown = t21, t22 = as === "button" ? withinMenu : void 0, t23 = as === "button" ? "button" : void 0, t24 = gap ?? space;
1823
+ let t25;
1824
+ $[47] !== IconComponent || $[48] !== fontSize ? (t25 = IconComponent && /* @__PURE__ */ jsxRuntime.jsxs(Text, { size: fontSize, children: [
2214
1825
  react.isValidElement(IconComponent) && IconComponent,
2215
1826
  reactIs.isValidElementType(IconComponent) && /* @__PURE__ */ jsxRuntime.jsx(IconComponent, {})
2216
- ] }), $[47] = IconComponent, $[48] = fontSize, $[49] = t27) : t27 = $[49];
1827
+ ] }), $[47] = IconComponent, $[48] = fontSize, $[49] = t25) : t25 = $[49];
1828
+ let t26;
1829
+ $[50] !== fontSize || $[51] !== text ? (t26 = /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize, textOverflow: "ellipsis", weight: "medium", children: text }) }), $[50] = fontSize, $[51] = text, $[52] = t26) : t26 = $[52];
1830
+ let t27;
1831
+ $[53] === Symbol.for("react.memo_cache_sentinel") ? (t27 = /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}), $[53] = t27) : t27 = $[53];
2217
1832
  let t28;
2218
- $[50] !== fontSize || $[51] !== text ? (t28 = /* @__PURE__ */ jsxRuntime.jsx(Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize, textOverflow: "ellipsis", weight: "medium", children: text }) }), $[50] = fontSize, $[51] = text, $[52] = t28) : t28 = $[52];
1833
+ $[54] !== fontSize ? (t28 = /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize, children: t27 }), $[54] = fontSize, $[55] = t28) : t28 = $[55];
2219
1834
  let t29;
2220
- $[53] === Symbol.for("react.memo_cache_sentinel") ? (t29 = /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightIcon, {}), $[53] = t29) : t29 = $[53];
1835
+ $[56] !== padding || $[57] !== t24 || $[58] !== t25 || $[59] !== t26 || $[60] !== t28 ? (t29 = /* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: t24, padding, children: [
1836
+ t25,
1837
+ t26,
1838
+ t28
1839
+ ] }), $[56] = padding, $[57] = t24, $[58] = t25, $[59] = t26, $[60] = t28, $[61] = t29) : t29 = $[61];
2221
1840
  let t30;
2222
- $[54] !== fontSize ? (t30 = /* @__PURE__ */ jsxRuntime.jsx(Text, { size: fontSize, children: t29 }), $[54] = fontSize, $[55] = t30) : t30 = $[55];
1841
+ $[62] !== as || $[63] !== handleClick || $[64] !== handleMouseEnter || $[65] !== radius || $[66] !== rest || $[67] !== t22 || $[68] !== t23 || $[69] !== t29 || $[70] !== tone || $[71] !== withinMenu ? (t30 = /* @__PURE__ */ jsxRuntime.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];
2223
1842
  let t31;
2224
- $[56] !== padding || $[57] !== t26 || $[58] !== t27 || $[59] !== t28 || $[60] !== t30 ? (t31 = /* @__PURE__ */ jsxRuntime.jsxs(Flex, { gap: t26, padding, children: [
2225
- t27,
2226
- t28,
2227
- t30
2228
- ] }), $[56] = padding, $[57] = t26, $[58] = t27, $[59] = t28, $[60] = t30, $[61] = t31) : t31 = $[61];
2229
- let t32;
2230
- $[62] !== as || $[63] !== handleClick || $[64] !== handleMouseEnter || $[65] !== radius || $[66] !== rest || $[67] !== t22 || $[68] !== t23 || $[69] !== t24 || $[70] !== t25 || $[71] !== t31 || $[72] !== tone ? (t32 = /* @__PURE__ */ jsxRuntime.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];
2231
- let t33;
2232
- return $[74] !== childMenu || $[75] !== open || $[76] !== popover || $[77] !== t32 ? (t33 = /* @__PURE__ */ jsxRuntime.jsx(Popover, { ...popover, content: childMenu, "data-ui": "MenuGroup__popover", open, children: t32 }), $[74] = childMenu, $[75] = open, $[76] = popover, $[77] = t32, $[78] = t33) : t33 = $[78], t33;
1843
+ return $[73] !== childMenu || $[74] !== open || $[75] !== popover || $[76] !== t30 ? (t31 = /* @__PURE__ */ jsxRuntime.jsx(Popover, { ...popover, content: childMenu, "data-ui": "MenuGroup__popover", open, children: t30 }), $[73] = childMenu, $[74] = open, $[75] = popover, $[76] = t30, $[77] = t31) : t31 = $[77], t31;
2233
1844
  }
2234
1845
  const DEFAULT_MENU_ITEM_ELEMENT = "button";
2235
1846
  function MenuItem(props) {
2236
- const $ = reactCompilerRuntime.c(75), t0 = props;
1847
+ const $ = compilerRuntime.c(75), t0 = props;
2237
1848
  let IconComponent, IconRightComponent, children, disabled, forwardedRef, gap, gapX, gapY, hotkeys, onClick, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, pressed, rest, selectedProp, t1, t2, t3, t4, t5, t6, text;
2238
1849
  $[0] !== t0 ? ({
2239
1850
  as: t1,
@@ -2321,7 +1932,7 @@ function MenuItem(props) {
2321
1932
  }
2322
1933
  const DEFAULT_TAB_ELEMENT = "button";
2323
1934
  function Tab(props) {
2324
- const $ = reactCompilerRuntime.c(33), t0 = props;
1935
+ const $ = compilerRuntime.c(33), t0 = props;
2325
1936
  let focused, forwardedRef, icon, id, label, onClick, onFocus, rest, selected, t1, t2, t3;
2326
1937
  $[0] !== t0 ? ({
2327
1938
  as: t1,
@@ -2360,7 +1971,7 @@ function Tab(props) {
2360
1971
  }
2361
1972
  const DEFAULT_TAB_LIST_ELEMENT = "div";
2362
1973
  function TabList(props) {
2363
- const $ = reactCompilerRuntime.c(21), t0 = props;
1974
+ const $ = compilerRuntime.c(21), t0 = props;
2364
1975
  let childrenProp, rest, t1, t2, t3, t4;
2365
1976
  $[0] !== t0 ? ({
2366
1977
  as: t1,
@@ -2394,6 +2005,271 @@ function TabList(props) {
2394
2005
  function _isReactElement(node) {
2395
2006
  return !!node;
2396
2007
  }
2008
+ const DEFAULT_GRID_ELEMENT = "div";
2009
+ function Grid(props) {
2010
+ const $ = compilerRuntime.c(8), t0 = props;
2011
+ let children, rest, t1;
2012
+ $[0] !== t0 ? ({
2013
+ as: t1,
2014
+ children,
2015
+ ...rest
2016
+ } = t0, $[0] = t0, $[1] = children, $[2] = rest, $[3] = t1) : (children = $[1], rest = $[2], t1 = $[3]);
2017
+ const as = t1 === void 0 ? DEFAULT_GRID_ELEMENT : t1;
2018
+ let t2;
2019
+ return $[4] !== as || $[5] !== children || $[6] !== rest ? (t2 = /* @__PURE__ */ jsxRuntime.jsx(Box, { "data-ui": "Grid", ...rest, as, display: "grid", children }), $[4] = as, $[5] = children, $[6] = rest, $[7] = t2) : t2 = $[7], t2;
2020
+ }
2021
+ function usePrefersDark(t0) {
2022
+ return useMatchMedia("(prefers-color-scheme: dark)", t0 === void 0 ? _temp : t0);
2023
+ }
2024
+ function _temp() {
2025
+ return !1;
2026
+ }
2027
+ function useDelayedState(initialState) {
2028
+ const $ = compilerRuntime.c(3), [state, setState] = react.useState(initialState), delayedAction = react.useRef(void 0);
2029
+ let t0;
2030
+ $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (nextState, delay) => {
2031
+ const action = () => {
2032
+ setState(nextState);
2033
+ };
2034
+ if (delayedAction.current && (clearTimeout(delayedAction.current), delayedAction.current = void 0), !delay)
2035
+ return action();
2036
+ delayedAction.current = setTimeout(action, delay);
2037
+ }, $[0] = t0) : t0 = $[0];
2038
+ const onStateChange = t0;
2039
+ let t1;
2040
+ return $[1] !== state ? (t1 = [state, onStateChange], $[1] = state, $[2] = t1) : t1 = $[2], t1;
2041
+ }
2042
+ function getElementRef(element) {
2043
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
2044
+ 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);
2045
+ }
2046
+ 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 = {
2047
+ top: ["top-end", "top-start", "bottom", "left", "right"],
2048
+ "top-start": ["top", "top-end", "bottom-start", "left-start", "right-start"],
2049
+ "top-end": ["top", "top-start", "bottom-end", "left-end", "right-end"],
2050
+ bottom: ["bottom-end", "bottom-start", "top", "left", "right"],
2051
+ "bottom-start": ["bottom", "bottom-end", "top-start", "left-start", "right-start"],
2052
+ "bottom-end": ["bottom", "bottom-start", "top-end", "left-end", "right-end"],
2053
+ left: ["left-end", "left-start", "right", "top", "bottom"],
2054
+ "left-start": ["left", "left-end", "right-start", "top-start", "bottom-start"],
2055
+ "left-end": ["left", "left-start", "right-end", "top-end", "bottom-end"],
2056
+ right: ["right-end", "right-start", "left", "top", "bottom"],
2057
+ "right-start": ["right", "right-end", "left-start", "top-start", "bottom-start"],
2058
+ "right-end": ["right", "right-start", "left-end", "top-end", "bottom-end"]
2059
+ }, TooltipDelayGroupContext = createGlobalScopedContext("@sanity/ui/context/tooltipDelayGroup", null);
2060
+ function useTooltipDelayGroup() {
2061
+ return react.useContext(TooltipDelayGroupContext);
2062
+ }
2063
+ function TooltipLayer(props) {
2064
+ const $ = compilerRuntime.c(50);
2065
+ let animate, arrow, arrowRef, arrowX, arrowY, children, originX, originY, padding, placement, radius, rest, scheme, shadow, style, t0;
2066
+ $[0] !== props ? ({
2067
+ animate,
2068
+ arrow,
2069
+ arrowRef,
2070
+ arrowX,
2071
+ arrowY,
2072
+ children,
2073
+ originX,
2074
+ originY,
2075
+ padding,
2076
+ placement,
2077
+ radius,
2078
+ scheme,
2079
+ shadow,
2080
+ style,
2081
+ tone: t0,
2082
+ ...rest
2083
+ } = props, $[0] = props, $[1] = animate, $[2] = arrow, $[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], arrow = $[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]);
2084
+ const tone = t0 === void 0 ? "inherit" : t0;
2085
+ let t1;
2086
+ const t2 = animate ? "transform" : void 0;
2087
+ let t3;
2088
+ $[17] !== originX || $[18] !== originY || $[19] !== style || $[20] !== t2 ? (t3 = {
2089
+ originX,
2090
+ originY,
2091
+ willChange: t2,
2092
+ ...style
2093
+ }, $[17] = originX, $[18] = originY, $[19] = style, $[20] = t2, $[21] = t3) : t3 = $[21], t1 = t3;
2094
+ const rootStyle = t1;
2095
+ let t4;
2096
+ const t5 = arrowX !== null ? arrowX : void 0, t6 = arrowY !== null ? arrowY : void 0;
2097
+ let t7;
2098
+ $[22] !== t5 || $[23] !== t6 ? (t7 = {
2099
+ left: t5,
2100
+ top: t6,
2101
+ right: void 0,
2102
+ bottom: void 0
2103
+ }, $[22] = t5, $[23] = t6, $[24] = t7) : t7 = $[24], t4 = t7;
2104
+ const arrowStyle = t4, t8 = animate ? "" : void 0;
2105
+ let t9;
2106
+ $[25] !== animate ? (t9 = animate ? ["hidden", "initial"] : void 0, $[25] = animate, $[26] = t9) : t9 = $[26];
2107
+ let t10;
2108
+ $[27] !== animate ? (t10 = animate ? ["visible", "scaleIn"] : void 0, $[27] = animate, $[28] = t10) : t10 = $[28];
2109
+ let t11;
2110
+ $[29] !== animate ? (t11 = animate ? ["hidden", "scaleOut"] : void 0, $[29] = animate, $[30] = t11) : t11 = $[30];
2111
+ let t12;
2112
+ $[31] !== arrow || $[32] !== arrowRef || $[33] !== arrowStyle ? (t12 = arrow && /* @__PURE__ */ jsxRuntime.jsx(Arrow, { ref: arrowRef, style: arrowStyle, width: DEFAULT_TOOLTIP_ARROW_WIDTH, height: DEFAULT_TOOLTIP_ARROW_HEIGHT, radius: DEFAULT_TOOLTIP_ARROW_RADIUS }), $[31] = arrow, $[32] = arrowRef, $[33] = arrowStyle, $[34] = t12) : t12 = $[34];
2113
+ let t13;
2114
+ 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__ */ jsxRuntime.jsxs(Layer, { "data-ui": "Tooltip__layer", ...rest, as: framerMotion.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: [
2115
+ children,
2116
+ t12
2117
+ ] }), $[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;
2118
+ }
2119
+ const DEFAULT_TOOLTIP_ELEMENT = "div";
2120
+ function Tooltip(props) {
2121
+ const boundaryElementContext = useBoundaryElement(), {
2122
+ animate: _animate = !1,
2123
+ arrow: arrowProp = !1,
2124
+ as = DEFAULT_TOOLTIP_ELEMENT,
2125
+ boundaryElement = boundaryElementContext?.element,
2126
+ children: childProp,
2127
+ className,
2128
+ content,
2129
+ delay,
2130
+ disabled,
2131
+ fallbackPlacements = props.fallbackPlacements ?? DEFAULT_FALLBACK_PLACEMENTS[props.placement ?? "bottom"],
2132
+ padding = 2,
2133
+ placement: placementProp = "bottom",
2134
+ portal: portalProp,
2135
+ radius = 3,
2136
+ ref: forwardedRef,
2137
+ scheme,
2138
+ shadow = 2,
2139
+ zOffset = Z_OFFSETS.tooltip,
2140
+ tone = "inherit",
2141
+ ...rest
2142
+ } = props, card = useCard(), animate = usePrefersReducedMotion() ? !1 : _animate, ref = react.useRef(null), [referenceElement, setReferenceElement] = react.useState(null), arrowRef = react.useRef(null), rootBoundary = "viewport", [tooltipMaxWidth, setTooltipMaxWidth] = react.useState(0);
2143
+ react.useImperativeHandle(forwardedRef, () => ref.current);
2144
+ const portal = usePortal(), portalElement = typeof portalProp == "string" ? portal.elements?.[portalProp] || null : portal.element, middleware = react.useMemo(() => {
2145
+ const ret = [];
2146
+ return ret.push(reactDom$1.flip({
2147
+ boundary: boundaryElement || void 0,
2148
+ fallbackPlacements,
2149
+ padding: DEFAULT_TOOLTIP_PADDING,
2150
+ rootBoundary
2151
+ })), ret.push(reactDom$1.offset({
2152
+ mainAxis: DEFAULT_TOOLTIP_DISTANCE
2153
+ })), ret.push(reactDom$1.shift({
2154
+ boundary: boundaryElement || void 0,
2155
+ rootBoundary,
2156
+ padding: DEFAULT_TOOLTIP_PADDING
2157
+ })), arrowProp && ret.push(reactDom$1.arrow({
2158
+ element: arrowRef,
2159
+ padding: DEFAULT_TOOLTIP_PADDING
2160
+ })), animate && ret.push(origin), ret;
2161
+ }, [animate, arrowProp, boundaryElement, fallbackPlacements]), {
2162
+ floatingStyles,
2163
+ placement,
2164
+ middlewareData,
2165
+ refs,
2166
+ update
2167
+ } = reactDom$1.useFloating({
2168
+ middleware,
2169
+ placement: placementProp,
2170
+ whileElementsMounted: reactDom$1.autoUpdate,
2171
+ elements: {
2172
+ reference: referenceElement
2173
+ },
2174
+ transform: !1
2175
+ }), arrowX = middlewareData.arrow?.x, arrowY = middlewareData.arrow?.y, originX = middlewareData["@sanity/ui/origin"]?.originX, originY = middlewareData["@sanity/ui/origin"]?.originY, tooltipId = react.useId(), [isOpen, setIsOpen] = useDelayedState(!1), delayGroupContext = useTooltipDelayGroup(), {
2176
+ setIsGroupActive,
2177
+ setOpenTooltipId
2178
+ } = 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 = react.useCallback((open, immediate) => {
2179
+ if (isInsideGroup)
2180
+ if (open) {
2181
+ const groupedOpenDelay = immediate ? 0 : openDelay;
2182
+ setIsGroupActive?.(open, groupedOpenDelay), setOpenTooltipId?.(tooltipId, groupedOpenDelay);
2183
+ } else {
2184
+ const groupDeactivateDelay = closeDelay > 200 ? closeDelay : 200;
2185
+ setIsGroupActive?.(open, groupDeactivateDelay), setOpenTooltipId?.(null, immediate ? 0 : closeDelay);
2186
+ }
2187
+ else
2188
+ setIsOpen(open, immediate ? 0 : open ? openDelay : closeDelay);
2189
+ }, [isInsideGroup, openDelay, setIsGroupActive, setOpenTooltipId, tooltipId, closeDelay, setIsOpen]), handleBlur = react.useCallback((e) => {
2190
+ handleIsOpenChange(!1), childProp?.props?.onBlur?.(e);
2191
+ }, [childProp?.props, handleIsOpenChange]), handleClick = react.useCallback((e_0) => {
2192
+ handleIsOpenChange(!1, !0), childProp?.props.onClick?.(e_0);
2193
+ }, [childProp?.props, handleIsOpenChange]), handleContextMenu = react.useCallback((e_1) => {
2194
+ handleIsOpenChange(!1, !0), childProp?.props.onContextMenu?.(e_1);
2195
+ }, [childProp?.props, handleIsOpenChange]), handleFocus = react.useCallback((e_2) => {
2196
+ handleIsOpenChange(!0), childProp?.props?.onFocus?.(e_2);
2197
+ }, [childProp?.props, handleIsOpenChange]), handleMouseEnter = react.useCallback((e_3) => {
2198
+ handleIsOpenChange(!0), childProp?.props?.onMouseEnter?.(e_3);
2199
+ }, [childProp?.props, handleIsOpenChange]), handleMouseLeave = react.useCallback((e_4) => {
2200
+ handleIsOpenChange(!1), childProp?.props?.onMouseLeave?.(e_4);
2201
+ }, [childProp?.props, handleIsOpenChange]);
2202
+ useCloseOnMouseLeave({
2203
+ handleIsOpenChange,
2204
+ referenceElement,
2205
+ showTooltip,
2206
+ isInsideGroup
2207
+ }), react.useEffect(() => {
2208
+ disabled && showTooltip && handleIsOpenChange(!1);
2209
+ }, [disabled, handleIsOpenChange, showTooltip]), react.useEffect(() => {
2210
+ !content && showTooltip && handleIsOpenChange(!1);
2211
+ }, [content, handleIsOpenChange, showTooltip]), react.useEffect(() => {
2212
+ if (!showTooltip) return;
2213
+ function handleWindowKeyDown(event) {
2214
+ event.key === "Escape" && handleIsOpenChange(!1, !0);
2215
+ }
2216
+ return window.addEventListener("keydown", handleWindowKeyDown), () => {
2217
+ window.removeEventListener("keydown", handleWindowKeyDown);
2218
+ };
2219
+ }, [handleIsOpenChange, showTooltip]), react.useLayoutEffect(() => {
2220
+ const availableWidths = [...boundaryElement ? [boundaryElement.offsetWidth] : [], portalElement?.offsetWidth || document.body.offsetWidth];
2221
+ setTooltipMaxWidth(Math.min(...availableWidths) - DEFAULT_TOOLTIP_PADDING * 2);
2222
+ }, [boundaryElement, portalElement]);
2223
+ const setArrow = react.useCallback((arrowEl) => {
2224
+ arrowRef.current = arrowEl, update();
2225
+ }, [update]), setFloating = react.useCallback((node) => {
2226
+ ref.current = node, refs.setFloating(node);
2227
+ }, [refs]), child = react.useMemo(() => childProp ? react.cloneElement(childProp, {
2228
+ onBlur: handleBlur,
2229
+ onFocus: handleFocus,
2230
+ onMouseEnter: handleMouseEnter,
2231
+ onMouseLeave: handleMouseLeave,
2232
+ onClick: handleClick,
2233
+ onContextMenu: handleContextMenu,
2234
+ ref: setReferenceElement
2235
+ }) : null, [childProp, handleBlur, handleClick, handleContextMenu, handleFocus, handleMouseEnter, handleMouseLeave]);
2236
+ if (react.useImperativeHandle(childProp ? getElementRef(childProp) : null, () => referenceElement, [referenceElement]), !child) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {});
2237
+ if (disabled) return child;
2238
+ const node_0 = /* @__PURE__ */ jsxRuntime.jsx(TooltipLayer, { "data-ui": "Tooltip", ...rest, animate, arrow: arrowProp, arrowRef: setArrow, arrowX, arrowY, as, className: css.tooltip({
2239
+ className
2240
+ }), originX, originY, padding, placement, radius, ref: setFloating, scheme, shadow, style: {
2241
+ ...floatingStyles,
2242
+ maxWidth: tooltipMaxWidth > 0 ? `${tooltipMaxWidth}px` : void 0
2243
+ }, tone, zOffset, children: content }), children = showTooltip && (portalProp ? /* @__PURE__ */ jsxRuntime.jsx(Portal, { __unstable_name: typeof portalProp == "string" ? portalProp : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(CardProvider, { tone: tone === "inherit" ? card?.tone ?? "default" : tone, scheme: scheme ?? "light", children: node_0 }) }) : node_0);
2244
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2245
+ animate ? /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children }) : children,
2246
+ child
2247
+ ] });
2248
+ }
2249
+ function useCloseOnMouseLeave(t0) {
2250
+ const $ = compilerRuntime.c(10), {
2251
+ handleIsOpenChange,
2252
+ referenceElement,
2253
+ showTooltip,
2254
+ isInsideGroup
2255
+ } = t0;
2256
+ let t1;
2257
+ $[0] !== handleIsOpenChange || $[1] !== referenceElement ? (t1 = (target, teardown) => {
2258
+ referenceElement && (referenceElement === target || target instanceof Node && referenceElement.contains(target) || (handleIsOpenChange(!1), teardown()));
2259
+ }, $[0] = handleIsOpenChange, $[1] = referenceElement, $[2] = t1) : t1 = $[2];
2260
+ const onMouseMove = useEffectEvent.useEffectEvent(t1);
2261
+ let t2;
2262
+ $[3] !== isInsideGroup || $[4] !== onMouseMove || $[5] !== showTooltip ? (t2 = () => {
2263
+ if (!showTooltip || isInsideGroup)
2264
+ return;
2265
+ const handleMouseMove = (event) => {
2266
+ onMouseMove(event.target, () => window.removeEventListener("mousemove", handleMouseMove));
2267
+ };
2268
+ return window.addEventListener("mousemove", handleMouseMove), () => window.removeEventListener("mousemove", handleMouseMove);
2269
+ }, $[3] = isInsideGroup, $[4] = onMouseMove, $[5] = showTooltip, $[6] = t2) : t2 = $[6];
2270
+ let t3;
2271
+ $[7] !== isInsideGroup || $[8] !== showTooltip ? (t3 = [isInsideGroup, showTooltip], $[7] = isInsideGroup, $[8] = showTooltip, $[9] = t3) : t3 = $[9], react.useEffect(t2, t3);
2272
+ }
2397
2273
  exports.AnimatedSpinnerIcon = AnimatedSpinnerIcon;
2398
2274
  exports.Arrow = Arrow;
2399
2275
  exports.BoundaryElementContext = BoundaryElementContext;
@@ -2401,13 +2277,10 @@ exports.Box = Box;
2401
2277
  exports.Button = Button;
2402
2278
  exports.Card = Card;
2403
2279
  exports.CardProvider = CardProvider;
2404
- exports.Code = Code;
2405
2280
  exports.DEFAULT_ARROW_ELEMENT = DEFAULT_ARROW_ELEMENT;
2406
2281
  exports.DEFAULT_BOX_ELEMENT = DEFAULT_BOX_ELEMENT;
2407
2282
  exports.DEFAULT_BUTTON_ELEMENT = DEFAULT_BUTTON_ELEMENT;
2408
2283
  exports.DEFAULT_CARD_ELEMENT = DEFAULT_CARD_ELEMENT;
2409
- exports.DEFAULT_CODE_ELEMENT = DEFAULT_CODE_ELEMENT;
2410
- exports.DEFAULT_ELEMENT_QUERY_ELEMENT = DEFAULT_ELEMENT_QUERY_ELEMENT;
2411
2284
  exports.DEFAULT_FLEX_ELEMENT = DEFAULT_FLEX_ELEMENT;
2412
2285
  exports.DEFAULT_GRID_ELEMENT = DEFAULT_GRID_ELEMENT;
2413
2286
  exports.DEFAULT_HOTKEYS_ELEMENT = DEFAULT_HOTKEYS_ELEMENT;
@@ -2418,6 +2291,7 @@ exports.DEFAULT_MENU_ELEMENT = DEFAULT_MENU_ELEMENT;
2418
2291
  exports.DEFAULT_MENU_GROUP_ELEMENT = DEFAULT_MENU_GROUP_ELEMENT;
2419
2292
  exports.DEFAULT_MENU_ITEM_ELEMENT = DEFAULT_MENU_ITEM_ELEMENT;
2420
2293
  exports.DEFAULT_POPOVER_ELEMENT = DEFAULT_POPOVER_ELEMENT;
2294
+ exports.DEFAULT_SELECTABLE_ELEMENT = DEFAULT_SELECTABLE_ELEMENT;
2421
2295
  exports.DEFAULT_SPINNER_ELEMENT = DEFAULT_SPINNER_ELEMENT;
2422
2296
  exports.DEFAULT_STACK_ELEMENT = DEFAULT_STACK_ELEMENT;
2423
2297
  exports.DEFAULT_TAB_ELEMENT = DEFAULT_TAB_ELEMENT;
@@ -2427,7 +2301,6 @@ exports.DEFAULT_TEXT_INPUT_ELEMENT = DEFAULT_TEXT_INPUT_ELEMENT;
2427
2301
  exports.DEFAULT_TOOLTIP_ELEMENT = DEFAULT_TOOLTIP_ELEMENT;
2428
2302
  exports.EMPTY_ARRAY = EMPTY_ARRAY;
2429
2303
  exports.EMPTY_RECORD = EMPTY_RECORD;
2430
- exports.ElementQuery = ElementQuery;
2431
2304
  exports.Flex = Flex;
2432
2305
  exports.Grid = Grid;
2433
2306
  exports.Hotkeys = Hotkeys;
@@ -2453,8 +2326,6 @@ exports.ThemeProvider = ThemeProvider;
2453
2326
  exports.Tooltip = Tooltip;
2454
2327
  exports.TooltipDelayGroupContext = TooltipDelayGroupContext;
2455
2328
  exports.Z_OFFSETS = Z_OFFSETS;
2456
- exports._ResizeObserver = _ResizeObserver;
2457
- exports._elementSizeObserver = _elementSizeObserver;
2458
2329
  exports._getArrayProp = _getArrayProp;
2459
2330
  exports._getResponsiveProp = _getResponsiveProp;
2460
2331
  exports._isEnterToClickElement = _isEnterToClickElement;
@@ -2472,7 +2343,6 @@ exports.useCard = useCard;
2472
2343
  exports.useClickOutsideEvent = useClickOutsideEvent;
2473
2344
  exports.useCustomValidity = useCustomValidity;
2474
2345
  exports.useDelayedState = useDelayedState;
2475
- exports.useElementSize = useElementSize;
2476
2346
  exports.useGlobalKeyDown = useGlobalKeyDown;
2477
2347
  exports.useLayer = useLayer;
2478
2348
  exports.useMatchMedia = useMatchMedia;