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

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 (76) hide show
  1. package/dist/_chunks-cjs/_visual-editing.cjs +197 -197
  2. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
  3. package/dist/_chunks-es/_visual-editing.js +199 -199
  4. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  5. package/dist/_visual-editing.d.cts +1 -0
  6. package/dist/_visual-editing.d.ts +1 -0
  7. package/dist/css.cjs +1 -1
  8. package/dist/css.d.cts +1 -1
  9. package/dist/css.d.ts +1 -1
  10. package/dist/css.js +1 -1
  11. package/dist/index.cjs +141 -141
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +1 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +143 -143
  16. package/dist/index.js.map +1 -1
  17. package/dist/theme.cjs +2605 -1075
  18. package/dist/theme.cjs.map +1 -1
  19. package/dist/theme.d.cts +1 -1
  20. package/dist/theme.d.ts +1 -1
  21. package/dist/theme.js +2689 -1159
  22. package/dist/theme.js.map +1 -1
  23. package/dist/ui.css +1 -1
  24. package/exports/_visual-editing.ts +1 -1
  25. package/package.json +13 -26
  26. package/src/core/components/dialog/dialog.tsx +2 -9
  27. package/src/core/components/dialog/dialogCard.tsx +2 -1
  28. package/src/core/components/index.ts +1 -0
  29. package/src/core/components/menu/menu.tsx +1 -2
  30. package/src/core/components/toast/toastLayer.tsx +1 -2
  31. package/src/core/components/toast/toastProvider.tsx +1 -1
  32. package/src/core/{utils → components}/virtualList/__workshop__/index.ts +1 -1
  33. package/src/core/primitives/badge/badge.tsx +2 -1
  34. package/src/core/primitives/index.ts +3 -0
  35. package/src/core/{utils → primitives}/layer/__workshop__/index.ts +1 -1
  36. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +1 -0
  37. package/src/core/primitives/popover/popover.tsx +2 -1
  38. package/src/core/primitives/popover/popoverLayer.tsx +2 -1
  39. package/src/core/primitives/stack/stack.tsx +1 -0
  40. package/src/core/primitives/switch/switch.tsx +1 -1
  41. package/src/core/primitives/tooltip/tooltip.tsx +2 -1
  42. package/src/core/primitives/tooltip/tooltipLayer.tsx +2 -1
  43. package/src/core/utils/getElementRef.ts +1 -0
  44. package/src/core/utils/index.ts +0 -4
  45. package/src/css/primitives/avatar/avatar.css.ts +5 -0
  46. package/src/css/primitives/badge/badge.css.ts +2 -1
  47. package/src/css/primitives/label/label.css.ts +1 -0
  48. package/src/css/props/width/types.ts +1 -1
  49. package/src/css/props/width/width.css.ts +3 -0
  50. package/src/theme/v2/build/buildTheme.test.ts +8 -8
  51. package/src/theme/v2/build/buildTheme.ts +32 -7
  52. /package/src/core/{utils → components}/virtualList/__workshop__/changingProps.tsx +0 -0
  53. /package/src/core/{utils → components}/virtualList/__workshop__/elementScroll.tsx +0 -0
  54. /package/src/core/{utils → components}/virtualList/__workshop__/infiniteList.tsx +0 -0
  55. /package/src/core/{utils → components}/virtualList/__workshop__/windowScrolll.tsx +0 -0
  56. /package/src/core/{utils → components}/virtualList/index.ts +0 -0
  57. /package/src/core/{utils → components}/virtualList/virtualList.tsx +0 -0
  58. /package/src/core/{utils → primitives}/arrow/arrow.tsx +0 -0
  59. /package/src/core/{utils → primitives}/arrow/cmds.ts +0 -0
  60. /package/src/core/{utils → primitives}/arrow/index.ts +0 -0
  61. /package/src/core/{utils → primitives}/layer/__workshop__/_debug.tsx +0 -0
  62. /package/src/core/{utils → primitives}/layer/__workshop__/multipleRoots.tsx +0 -0
  63. /package/src/core/{utils → primitives}/layer/__workshop__/nested.tsx +0 -0
  64. /package/src/core/{utils → primitives}/layer/__workshop__/responsiveZOffset.tsx +0 -0
  65. /package/src/core/{utils → primitives}/layer/getLayerContext.test.ts +0 -0
  66. /package/src/core/{utils → primitives}/layer/getLayerContext.ts +0 -0
  67. /package/src/core/{utils → primitives}/layer/index.ts +0 -0
  68. /package/src/core/{utils → primitives}/layer/layer.test.tsx +0 -0
  69. /package/src/core/{utils → primitives}/layer/layer.tsx +0 -0
  70. /package/src/core/{utils → primitives}/layer/layerCard.tsx +0 -0
  71. /package/src/core/{utils → primitives}/layer/layerContext.ts +0 -0
  72. /package/src/core/{utils → primitives}/layer/layerProvider.tsx +0 -0
  73. /package/src/core/{utils → primitives}/layer/types.ts +0 -0
  74. /package/src/core/{utils → primitives}/layer/useLayer.ts +0 -0
  75. /package/src/core/{utils → primitives}/srOnly/index.ts +0 -0
  76. /package/src/core/{utils → primitives}/srOnly/srOnly.tsx +0 -0
@@ -1,17 +1,17 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { c } from "react-compiler-runtime";
3
3
  import { getScopedTheme, getTheme_v2 } from "@sanity/ui/theme";
4
- import { createContext, useContext, useEffect, useDebugValue, useState, useSyncExternalStore, isValidElement, lazy, Suspense, useImperativeHandle, useRef, useMemo, useCallback, cloneElement, useId, useLayoutEffect, Children } from "react";
4
+ import { createContext, useContext, useEffect, useDebugValue, useState, useSyncExternalStore, isValidElement, lazy, Suspense, useRef, useImperativeHandle, useMemo, useCallback, cloneElement, useId, useLayoutEffect, Children } from "react";
5
5
  import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1 } from "styled-components";
6
- import { BREAKPOINTS, box, text, textOverflow, animatedSpinnerIcon, spinner, button, buttonLoadingBox, card, code, kbd, _arrow, vars, _arrowSvg, _arrowStrokeMask, _arrowStroke, _arrowShape, popoverCard, popover, stack, textInput, textInputPrefix, textInputElement, _inputElement, _inputPresentation, textInputSuffix, tooltip, menu, menuDivider, _selectable } from "@sanity/ui/css";
6
+ import { BREAKPOINTS, _arrow, vars, _arrowSvg, _arrowStrokeMask, _arrowStroke, _arrowShape, box, text, textOverflow, animatedSpinnerIcon, spinner, button, buttonLoadingBox, card, code, kbd, popoverCard, popover, stack, textInput, textInputPrefix, textInputElement, _inputElement, _inputPresentation, textInputSuffix, tooltip, menu, menuDivider, _selectable } from "@sanity/ui/css";
7
7
  import { ResizeObserver } from "@juggle/resize-observer";
8
8
  import { useEffectEvent } from "use-effect-event";
9
9
  import { SpinnerIcon, CloseIcon, ChevronRightIcon } from "@sanity/icons";
10
10
  import { isValidElementType } from "react-is";
11
11
  import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate } from "@floating-ui/react-dom";
12
12
  import { motion, AnimatePresence } from "framer-motion";
13
- import { assignInlineVars } from "@vanilla-extract/dynamic";
14
13
  import { createPortal } from "react-dom";
14
+ import { assignInlineVars } from "@vanilla-extract/dynamic";
15
15
  function getGlobalScope() {
16
16
  if (typeof globalThis < "u") return globalThis;
17
17
  if (typeof window < "u") return window;
@@ -363,6 +363,113 @@ function useResponsiveProp(val, defaultVal) {
363
363
  const [t1, setCache] = useState(t0), [cachedVal, cachedHash] = t1, hash = JSON.stringify(val ?? defaultVal);
364
364
  return hash !== cachedHash && setCache([_getResponsiveProp(val, defaultVal), hash]), cachedVal;
365
365
  }
366
+ function moveTowardsLength(movingPoint, targetPoint, amount) {
367
+ const width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
368
+ return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
369
+ }
370
+ function moveTowardsFractional(movingPoint, targetPoint, fraction) {
371
+ return {
372
+ x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
373
+ y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
374
+ };
375
+ }
376
+ function getRoundedCommands(points) {
377
+ const len = points.length, cmds = [];
378
+ for (let i = 0; i < len; i += 1) {
379
+ const point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
380
+ if (prevPoint && point.radius) {
381
+ const curveStart = moveTowardsLength(point, prevPoint, point.radius), curveEnd = moveTowardsLength(point, nextPoint, point.radius), startControl = moveTowardsFractional(curveStart, point, 0.5), endControl = moveTowardsFractional(point, curveEnd, 0.5);
382
+ cmds.push({
383
+ type: "point",
384
+ ...curveStart
385
+ }), cmds.push({
386
+ type: "curve",
387
+ curveEnd,
388
+ startControl,
389
+ endControl
390
+ });
391
+ } else
392
+ cmds.push({
393
+ type: "point",
394
+ ...point
395
+ });
396
+ }
397
+ return cmds;
398
+ }
399
+ function compileCommands(cmds) {
400
+ return cmds.map((n, idx) => n.type === "point" ? `${idx === 0 ? "M" : "L"} ${n.x} ${n.y}` : n.type === "curve" ? `C ${n.startControl.x} ${n.startControl.y} ${n.endControl.x} ${n.endControl.y} ${n.curveEnd.x} ${n.curveEnd.y}` : "").join(" ");
401
+ }
402
+ const DEFAULT_ARROW_ELEMENT = "div";
403
+ function Arrow(props) {
404
+ const $ = c(34), t0 = props;
405
+ let h, rest, style, t1, t2, w;
406
+ $[0] !== t0 ? ({
407
+ as: t1,
408
+ width: w,
409
+ height: h,
410
+ radius: t2,
411
+ style,
412
+ ...rest
413
+ } = t0, $[0] = t0, $[1] = h, $[2] = rest, $[3] = style, $[4] = t1, $[5] = t2, $[6] = w) : (h = $[1], rest = $[2], style = $[3], t1 = $[4], t2 = $[5], w = $[6]);
414
+ const Element = t1 === void 0 ? DEFAULT_ARROW_ELEMENT : t1, radius = t2 === void 0 ? 0 : t2, center = w / 2;
415
+ let t3;
416
+ const points = [{
417
+ x: 0,
418
+ y: 0
419
+ }, {
420
+ x: radius,
421
+ y: 0,
422
+ radius
423
+ }, {
424
+ x: center,
425
+ y: h - 1,
426
+ radius
427
+ }, {
428
+ x: w - radius,
429
+ y: 0,
430
+ radius
431
+ }, {
432
+ x: w,
433
+ y: 0
434
+ }], cmds = getRoundedCommands(points);
435
+ t3 = compileCommands(cmds);
436
+ const path = t3, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`;
437
+ let t4;
438
+ $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = _arrow(), $[7] = t4) : t4 = $[7];
439
+ const t5 = `${w}px`;
440
+ let t6;
441
+ $[8] !== t5 ? (t6 = assignInlineVars({
442
+ [vars.arrow.size]: t5
443
+ }), $[8] = t5, $[9] = t6) : t6 = $[9];
444
+ let t7;
445
+ $[10] !== style || $[11] !== t6 ? (t7 = {
446
+ ...style,
447
+ ...t6
448
+ }, $[10] = style, $[11] = t6, $[12] = t7) : t7 = $[12];
449
+ let t8;
450
+ $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = _arrowSvg(), $[13] = t8) : t8 = $[13];
451
+ const t9 = `0 0 ${w} ${w}`;
452
+ let t10;
453
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t10 = _arrowStrokeMask(), $[14] = t10) : t10 = $[14];
454
+ let t11;
455
+ $[15] !== w ? (t11 = /* @__PURE__ */ jsx("mask", { id: "stroke-mask", children: /* @__PURE__ */ jsx("rect", { className: t10, x: 0, width: w, height: w, fill: "white" }) }), $[15] = w, $[16] = t11) : t11 = $[16];
456
+ let t12;
457
+ $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = _arrowStroke(), $[17] = t12) : t12 = $[17];
458
+ let t13;
459
+ $[18] !== strokePath ? (t13 = /* @__PURE__ */ jsx("path", { className: t12, d: strokePath, mask: "url(#stroke-mask)" }), $[18] = strokePath, $[19] = t13) : t13 = $[19];
460
+ let t14;
461
+ $[20] === Symbol.for("react.memo_cache_sentinel") ? (t14 = _arrowShape(), $[20] = t14) : t14 = $[20];
462
+ let t15;
463
+ $[21] !== fillPath ? (t15 = /* @__PURE__ */ jsx("path", { className: t14, d: fillPath }), $[21] = fillPath, $[22] = t15) : t15 = $[22];
464
+ let t16;
465
+ $[23] !== t11 || $[24] !== t13 || $[25] !== t15 || $[26] !== t9 || $[27] !== w ? (t16 = /* @__PURE__ */ jsxs("svg", { className: t8, width: w, height: w, viewBox: t9, children: [
466
+ t11,
467
+ t13,
468
+ t15
469
+ ] }), $[23] = t11, $[24] = t13, $[25] = t15, $[26] = t9, $[27] = w, $[28] = t16) : t16 = $[28];
470
+ let t17;
471
+ return $[29] !== Element || $[30] !== rest || $[31] !== t16 || $[32] !== t7 ? (t17 = /* @__PURE__ */ jsx(Element, { ...rest, className: t4, style: t7, children: t16 }), $[29] = Element, $[30] = rest, $[31] = t16, $[32] = t7, $[33] = t17) : t17 = $[33], t17;
472
+ }
366
473
  const DEFAULT_BOX_ELEMENT = "div";
367
474
  function Box(props) {
368
475
  const $ = c(154), t0 = props;
@@ -794,202 +901,6 @@ function KBD(props) {
794
901
  let t9;
795
902
  return $[15] !== display || $[16] !== padding || $[17] !== rest || $[18] !== t6 || $[19] !== t7 || $[20] !== t8 ? (t9 = /* @__PURE__ */ jsx(Box, { "data-ui": "KBD", ...rest, as: t6, className: t7, display, muted: !0, padding, children: t8 }), $[15] = display, $[16] = padding, $[17] = rest, $[18] = t6, $[19] = t7, $[20] = t8, $[21] = t9) : t9 = $[21], t9;
796
903
  }
797
- const origin = {
798
- name: "@sanity/ui/origin",
799
- fn({
800
- middlewareData,
801
- placement,
802
- rects
803
- }) {
804
- const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
805
- if (floatingWidth <= 0 || floatingHeight <= 0)
806
- return {};
807
- const isVerticalPlacement = ["bottom", "top"].includes(side), {
808
- originX,
809
- originY
810
- } = isVerticalPlacement ? {
811
- originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),
812
- originY: side === "bottom" ? 0 : 1
813
- } : {
814
- originX: side === "left" ? 1 : 0,
815
- originY: clamp(0.5 - shiftY / floatingHeight, 0, 1)
816
- };
817
- return {
818
- data: {
819
- originX,
820
- originY
821
- }
822
- };
823
- }
824
- };
825
- function clamp(num, min, max) {
826
- return Math.min(Math.max(num, min), max);
827
- }
828
- function moveTowardsLength(movingPoint, targetPoint, amount) {
829
- const width = targetPoint.x - movingPoint.x, height = targetPoint.y - movingPoint.y, distance = Math.sqrt(width * width + height * height);
830
- return moveTowardsFractional(movingPoint, targetPoint, Math.min(1, amount / distance));
831
- }
832
- function moveTowardsFractional(movingPoint, targetPoint, fraction) {
833
- return {
834
- x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction,
835
- y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction
836
- };
837
- }
838
- function getRoundedCommands(points) {
839
- const len = points.length, cmds = [];
840
- for (let i = 0; i < len; i += 1) {
841
- const point = points[i], prevPoint = points[i - 1], nextPoint = points[i + 1];
842
- if (prevPoint && point.radius) {
843
- const curveStart = moveTowardsLength(point, prevPoint, point.radius), curveEnd = moveTowardsLength(point, nextPoint, point.radius), startControl = moveTowardsFractional(curveStart, point, 0.5), endControl = moveTowardsFractional(point, curveEnd, 0.5);
844
- cmds.push({
845
- type: "point",
846
- ...curveStart
847
- }), cmds.push({
848
- type: "curve",
849
- curveEnd,
850
- startControl,
851
- endControl
852
- });
853
- } else
854
- cmds.push({
855
- type: "point",
856
- ...point
857
- });
858
- }
859
- return cmds;
860
- }
861
- function compileCommands(cmds) {
862
- return cmds.map((n, idx) => n.type === "point" ? `${idx === 0 ? "M" : "L"} ${n.x} ${n.y}` : n.type === "curve" ? `C ${n.startControl.x} ${n.startControl.y} ${n.endControl.x} ${n.endControl.y} ${n.curveEnd.x} ${n.curveEnd.y}` : "").join(" ");
863
- }
864
- const DEFAULT_ARROW_ELEMENT = "div";
865
- function Arrow(props) {
866
- const $ = c(34), t0 = props;
867
- let h, rest, style, t1, t2, w;
868
- $[0] !== t0 ? ({
869
- as: t1,
870
- width: w,
871
- height: h,
872
- radius: t2,
873
- style,
874
- ...rest
875
- } = t0, $[0] = t0, $[1] = h, $[2] = rest, $[3] = style, $[4] = t1, $[5] = t2, $[6] = w) : (h = $[1], rest = $[2], style = $[3], t1 = $[4], t2 = $[5], w = $[6]);
876
- const Element = t1 === void 0 ? DEFAULT_ARROW_ELEMENT : t1, radius = t2 === void 0 ? 0 : t2, center = w / 2;
877
- let t3;
878
- const points = [{
879
- x: 0,
880
- y: 0
881
- }, {
882
- x: radius,
883
- y: 0,
884
- radius
885
- }, {
886
- x: center,
887
- y: h - 1,
888
- radius
889
- }, {
890
- x: w - radius,
891
- y: 0,
892
- radius
893
- }, {
894
- x: w,
895
- y: 0
896
- }], cmds = getRoundedCommands(points);
897
- t3 = compileCommands(cmds);
898
- const path = t3, strokePath = `${path}`, fillPath = `${path} M ${w} -1 M 0 -1 Z`;
899
- let t4;
900
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t4 = _arrow(), $[7] = t4) : t4 = $[7];
901
- const t5 = `${w}px`;
902
- let t6;
903
- $[8] !== t5 ? (t6 = assignInlineVars({
904
- [vars.arrow.size]: t5
905
- }), $[8] = t5, $[9] = t6) : t6 = $[9];
906
- let t7;
907
- $[10] !== style || $[11] !== t6 ? (t7 = {
908
- ...style,
909
- ...t6
910
- }, $[10] = style, $[11] = t6, $[12] = t7) : t7 = $[12];
911
- let t8;
912
- $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = _arrowSvg(), $[13] = t8) : t8 = $[13];
913
- const t9 = `0 0 ${w} ${w}`;
914
- let t10;
915
- $[14] === Symbol.for("react.memo_cache_sentinel") ? (t10 = _arrowStrokeMask(), $[14] = t10) : t10 = $[14];
916
- let t11;
917
- $[15] !== w ? (t11 = /* @__PURE__ */ jsx("mask", { id: "stroke-mask", children: /* @__PURE__ */ jsx("rect", { className: t10, x: 0, width: w, height: w, fill: "white" }) }), $[15] = w, $[16] = t11) : t11 = $[16];
918
- let t12;
919
- $[17] === Symbol.for("react.memo_cache_sentinel") ? (t12 = _arrowStroke(), $[17] = t12) : t12 = $[17];
920
- let t13;
921
- $[18] !== strokePath ? (t13 = /* @__PURE__ */ jsx("path", { className: t12, d: strokePath, mask: "url(#stroke-mask)" }), $[18] = strokePath, $[19] = t13) : t13 = $[19];
922
- let t14;
923
- $[20] === Symbol.for("react.memo_cache_sentinel") ? (t14 = _arrowShape(), $[20] = t14) : t14 = $[20];
924
- let t15;
925
- $[21] !== fillPath ? (t15 = /* @__PURE__ */ jsx("path", { className: t14, d: fillPath }), $[21] = fillPath, $[22] = t15) : t15 = $[22];
926
- let t16;
927
- $[23] !== t11 || $[24] !== t13 || $[25] !== t15 || $[26] !== t9 || $[27] !== w ? (t16 = /* @__PURE__ */ jsxs("svg", { className: t8, width: w, height: w, viewBox: t9, children: [
928
- t11,
929
- t13,
930
- t15
931
- ] }), $[23] = t11, $[24] = t13, $[25] = t15, $[26] = t9, $[27] = w, $[28] = t16) : t16 = $[28];
932
- let t17;
933
- return $[29] !== Element || $[30] !== rest || $[31] !== t16 || $[32] !== t7 ? (t17 = /* @__PURE__ */ jsx(Element, { ...rest, className: t4, style: t7, children: t16 }), $[29] = Element, $[30] = rest, $[31] = t16, $[32] = t7, $[33] = t17) : t17 = $[33], t17;
934
- }
935
- const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null), DEFAULT_VALUE = {
936
- version: 0,
937
- element: null
938
- };
939
- function useBoundaryElement() {
940
- const value = useContext(BoundaryElementContext);
941
- if (value && (!isRecord(value) || value.version !== 0))
942
- throw new Error("useBoundaryElement(): the context value is not compatible");
943
- return value || DEFAULT_VALUE;
944
- }
945
- function findMaxBreakpoints(media2, width) {
946
- const ret = [];
947
- for (let i = 0; i < media2.length; i += 1)
948
- media2[i] > width && ret.push(i);
949
- return ret;
950
- }
951
- function findMinBreakpoints(media2, width) {
952
- const ret = [];
953
- for (let i = 0; i < media2.length; i += 1)
954
- media2[i] <= width && ret.push(i);
955
- return ret;
956
- }
957
- const DEFAULT_ELEMENT_QUERY_ELEMENT = "div", DEFAULT_BREAKPOINTS = Object.values(BREAKPOINTS);
958
- function ElementQuery(props) {
959
- const $ = c(21), t0 = props;
960
- let children, forwardedRef, mediaProp, rest, t1;
961
- $[0] !== t0 ? ({
962
- as: t1,
963
- children,
964
- media: mediaProp,
965
- ref: forwardedRef,
966
- ...rest
967
- } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = mediaProp, $[4] = rest, $[5] = t1) : (children = $[1], forwardedRef = $[2], mediaProp = $[3], rest = $[4], t1 = $[5]);
968
- const Element = t1 === void 0 ? DEFAULT_ELEMENT_QUERY_ELEMENT : t1, breakpoints = mediaProp ?? DEFAULT_BREAKPOINTS, [element, setElement] = useState(null), elementSize = useElementSize(element);
969
- let t2;
970
- t2 = elementSize?.border.width ?? window.innerWidth;
971
- const width = t2;
972
- let t3, t4;
973
- if ($[6] !== breakpoints || $[7] !== width) {
974
- const eq = findMaxBreakpoints(breakpoints, width);
975
- t4 = eq.length ? eq.join(" ") : void 0, $[6] = breakpoints, $[7] = width, $[8] = t4;
976
- } else
977
- t4 = $[8];
978
- t3 = t4;
979
- const max = t3;
980
- let t5, t6;
981
- if ($[9] !== breakpoints || $[10] !== width) {
982
- const eq_0 = findMinBreakpoints(breakpoints, width);
983
- t6 = eq_0.length ? eq_0.join(" ") : void 0, $[9] = breakpoints, $[10] = width, $[11] = t6;
984
- } else
985
- t6 = $[11];
986
- t5 = t6;
987
- const min = t5;
988
- let t7, t8;
989
- $[12] !== element ? (t7 = () => element, t8 = [element], $[12] = element, $[13] = t7, $[14] = t8) : (t7 = $[13], t8 = $[14]), useImperativeHandle(forwardedRef, t7, t8);
990
- let t9;
991
- return $[15] !== Element || $[16] !== children || $[17] !== max || $[18] !== min || $[19] !== rest ? (t9 = /* @__PURE__ */ jsx(Element, { "data-ui": "ElementQuery", ...rest, "data-eq-max": max, "data-eq-min": min, ref: setElement, children }), $[15] = Element, $[16] = children, $[17] = max, $[18] = min, $[19] = rest, $[20] = t9) : t9 = $[20], t9;
992
- }
993
904
  function getLayerContext(contextValue) {
994
905
  if (!isRecord(contextValue) || contextValue.version !== 0)
995
906
  throw new Error("the context value is not compatible");
@@ -1120,6 +1031,95 @@ function Layer(props) {
1120
1031
  let t4;
1121
1032
  return $[9] !== t3 || $[10] !== zOffset ? (t4 = /* @__PURE__ */ jsx(LayerProvider, { zOffset, children: t3 }), $[9] = t3, $[10] = zOffset, $[11] = t4) : t4 = $[11], t4;
1122
1033
  }
1034
+ const origin = {
1035
+ name: "@sanity/ui/origin",
1036
+ fn({
1037
+ middlewareData,
1038
+ placement,
1039
+ rects
1040
+ }) {
1041
+ const [side] = placement.split("-"), floatingWidth = rects.floating.width, floatingHeight = rects.floating.height, shiftX = middlewareData.shift?.x || 0, shiftY = middlewareData.shift?.y || 0;
1042
+ if (floatingWidth <= 0 || floatingHeight <= 0)
1043
+ return {};
1044
+ const isVerticalPlacement = ["bottom", "top"].includes(side), {
1045
+ originX,
1046
+ originY
1047
+ } = isVerticalPlacement ? {
1048
+ originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),
1049
+ originY: side === "bottom" ? 0 : 1
1050
+ } : {
1051
+ originX: side === "left" ? 1 : 0,
1052
+ originY: clamp(0.5 - shiftY / floatingHeight, 0, 1)
1053
+ };
1054
+ return {
1055
+ data: {
1056
+ originX,
1057
+ originY
1058
+ }
1059
+ };
1060
+ }
1061
+ };
1062
+ function clamp(num, min, max) {
1063
+ return Math.min(Math.max(num, min), max);
1064
+ }
1065
+ const BoundaryElementContext = createGlobalScopedContext("@sanity/ui/context/boundaryElement", null), DEFAULT_VALUE = {
1066
+ version: 0,
1067
+ element: null
1068
+ };
1069
+ function useBoundaryElement() {
1070
+ const value = useContext(BoundaryElementContext);
1071
+ if (value && (!isRecord(value) || value.version !== 0))
1072
+ throw new Error("useBoundaryElement(): the context value is not compatible");
1073
+ return value || DEFAULT_VALUE;
1074
+ }
1075
+ function findMaxBreakpoints(media2, width) {
1076
+ const ret = [];
1077
+ for (let i = 0; i < media2.length; i += 1)
1078
+ media2[i] > width && ret.push(i);
1079
+ return ret;
1080
+ }
1081
+ function findMinBreakpoints(media2, width) {
1082
+ const ret = [];
1083
+ for (let i = 0; i < media2.length; i += 1)
1084
+ media2[i] <= width && ret.push(i);
1085
+ return ret;
1086
+ }
1087
+ const DEFAULT_ELEMENT_QUERY_ELEMENT = "div", DEFAULT_BREAKPOINTS = Object.values(BREAKPOINTS);
1088
+ function ElementQuery(props) {
1089
+ const $ = c(21), t0 = props;
1090
+ let children, forwardedRef, mediaProp, rest, t1;
1091
+ $[0] !== t0 ? ({
1092
+ as: t1,
1093
+ children,
1094
+ media: mediaProp,
1095
+ ref: forwardedRef,
1096
+ ...rest
1097
+ } = t0, $[0] = t0, $[1] = children, $[2] = forwardedRef, $[3] = mediaProp, $[4] = rest, $[5] = t1) : (children = $[1], forwardedRef = $[2], mediaProp = $[3], rest = $[4], t1 = $[5]);
1098
+ const Element = t1 === void 0 ? DEFAULT_ELEMENT_QUERY_ELEMENT : t1, breakpoints = mediaProp ?? DEFAULT_BREAKPOINTS, [element, setElement] = useState(null), elementSize = useElementSize(element);
1099
+ let t2;
1100
+ t2 = elementSize?.border.width ?? window.innerWidth;
1101
+ const width = t2;
1102
+ let t3, t4;
1103
+ if ($[6] !== breakpoints || $[7] !== width) {
1104
+ const eq = findMaxBreakpoints(breakpoints, width);
1105
+ t4 = eq.length ? eq.join(" ") : void 0, $[6] = breakpoints, $[7] = width, $[8] = t4;
1106
+ } else
1107
+ t4 = $[8];
1108
+ t3 = t4;
1109
+ const max = t3;
1110
+ let t5, t6;
1111
+ if ($[9] !== breakpoints || $[10] !== width) {
1112
+ const eq_0 = findMinBreakpoints(breakpoints, width);
1113
+ t6 = eq_0.length ? eq_0.join(" ") : void 0, $[9] = breakpoints, $[10] = width, $[11] = t6;
1114
+ } else
1115
+ t6 = $[11];
1116
+ t5 = t6;
1117
+ const min = t5;
1118
+ let t7, t8;
1119
+ $[12] !== element ? (t7 = () => element, t8 = [element], $[12] = element, $[13] = t7, $[14] = t8) : (t7 = $[13], t8 = $[14]), useImperativeHandle(forwardedRef, t7, t8);
1120
+ let t9;
1121
+ return $[15] !== Element || $[16] !== children || $[17] !== max || $[18] !== min || $[19] !== rest ? (t9 = /* @__PURE__ */ jsx(Element, { "data-ui": "ElementQuery", ...rest, "data-eq-max": max, "data-eq-min": min, ref: setElement, children }), $[15] = Element, $[16] = children, $[17] = max, $[18] = min, $[19] = rest, $[20] = t9) : t9 = $[20], t9;
1122
+ }
1123
1123
  const key = "@sanity/ui/context/portal", elementKey = Symbol.for(`${key}/element`);
1124
1124
  globalScope[elementKey] = null;
1125
1125
  const defaultContextValue = {