@vonage/vivid 4.10.0 → 4.12.0

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 (94) hide show
  1. package/custom-elements.json +8630 -6433
  2. package/lib/badge/badge.d.ts +1 -1
  3. package/lib/breadcrumb-item/breadcrumb-item.d.ts +1 -1
  4. package/lib/button/button.d.ts +1 -1
  5. package/lib/checkbox/checkbox.d.ts +5 -3
  6. package/lib/checkbox/checkbox.form-associated.d.ts +10 -0
  7. package/lib/enums.d.ts +1 -0
  8. package/lib/fab/fab.d.ts +2 -2
  9. package/lib/file-picker/file-picker.d.ts +3 -0
  10. package/lib/slider/slider.d.ts +30 -6
  11. package/lib/slider/slider.form-associated.d.ts +10 -0
  12. package/lib/split-button/split-button.d.ts +1 -1
  13. package/lib/tabs/tabs.d.ts +1 -0
  14. package/package.json +1 -1
  15. package/shared/aria-global2.cjs +93 -0
  16. package/shared/aria-global2.js +91 -0
  17. package/shared/breadcrumb-item.cjs +2 -89
  18. package/shared/breadcrumb-item.js +1 -88
  19. package/shared/definition11.cjs +200 -4
  20. package/shared/definition11.js +198 -3
  21. package/shared/definition15.cjs +34 -91
  22. package/shared/definition15.js +35 -92
  23. package/shared/definition16.cjs +9 -7
  24. package/shared/definition16.js +9 -7
  25. package/shared/definition20.cjs +1 -1
  26. package/shared/definition20.js +1 -1
  27. package/shared/definition21.cjs +1 -1
  28. package/shared/definition21.js +1 -1
  29. package/shared/definition24.cjs +156 -2
  30. package/shared/definition24.js +157 -3
  31. package/shared/definition25.cjs +106 -56
  32. package/shared/definition25.js +106 -56
  33. package/shared/definition35.cjs +2 -2
  34. package/shared/definition35.js +2 -2
  35. package/shared/definition37.cjs +1 -1
  36. package/shared/definition37.js +1 -1
  37. package/shared/definition4.cjs +5 -6
  38. package/shared/definition4.js +1 -2
  39. package/shared/definition40.cjs +11 -4
  40. package/shared/definition40.js +8 -1
  41. package/shared/definition42.cjs +3 -22
  42. package/shared/definition42.js +2 -21
  43. package/shared/definition43.cjs +1 -2
  44. package/shared/definition43.js +1 -2
  45. package/shared/definition44.js +1 -1
  46. package/shared/definition47.cjs +369 -502
  47. package/shared/definition47.js +370 -503
  48. package/shared/definition5.cjs +4 -4
  49. package/shared/definition5.js +1 -1
  50. package/shared/definition51.cjs +1 -1
  51. package/shared/definition51.js +1 -1
  52. package/shared/definition52.cjs +63 -26
  53. package/shared/definition52.js +63 -26
  54. package/shared/definition56.cjs +41 -43
  55. package/shared/definition56.js +41 -43
  56. package/shared/definition57.cjs +1 -1
  57. package/shared/definition57.js +1 -1
  58. package/shared/definition58.cjs +1 -1
  59. package/shared/definition58.js +1 -1
  60. package/shared/definition59.cjs +1 -1
  61. package/shared/definition59.js +1 -1
  62. package/shared/definition64.cjs +278 -90
  63. package/shared/definition64.js +278 -90
  64. package/shared/definition7.cjs +1 -1
  65. package/shared/definition7.js +1 -1
  66. package/shared/definition8.cjs +1 -1
  67. package/shared/definition8.js +1 -1
  68. package/shared/enums.cjs +1 -0
  69. package/shared/enums.js +1 -0
  70. package/shared/form-associated.js +1 -1
  71. package/shared/{patterns → foundation/anchor}/anchor.d.ts +1 -1
  72. package/shared/foundation/button/button.d.ts +27 -0
  73. package/shared/foundation/button/button.template.d.ts +4 -0
  74. package/shared/foundation/button/index.d.ts +2 -0
  75. package/shared/foundation/patterns/index.d.ts +1 -0
  76. package/shared/index.cjs +22 -2
  77. package/shared/index.js +22 -2
  78. package/shared/key-codes2.js +1 -1
  79. package/shared/presentationDate.cjs +4328 -4042
  80. package/shared/presentationDate.js +4327 -4041
  81. package/shared/slider.template.cjs +23 -1
  82. package/shared/slider.template.js +21 -2
  83. package/styles/core/all.css +1 -1
  84. package/styles/core/theme.css +1 -1
  85. package/styles/core/typography.css +1 -1
  86. package/styles/tokens/theme-dark.css +4 -4
  87. package/styles/tokens/theme-light.css +4 -4
  88. package/styles/tokens/vivid-2-compat.css +1 -1
  89. package/vivid.api.json +52 -4
  90. package/shared/aria2.cjs +0 -11
  91. package/shared/aria2.js +0 -9
  92. package/shared/button.cjs +0 -202
  93. package/shared/button.js +0 -200
  94. /package/shared/{patterns → foundation/patterns}/aria-global.d.ts +0 -0
@@ -7,6 +7,11 @@ const ref = require('./ref.cjs');
7
7
  const when = require('./when.cjs');
8
8
  const classNames = require('./class-names.cjs');
9
9
 
10
+ /**
11
+ * Custom positioning reference element.
12
+ * @see https://floating-ui.com/docs/virtual-elements
13
+ */
14
+
10
15
  const sides = ['top', 'right', 'bottom', 'left'];
11
16
  const alignments = ['start', 'end'];
12
17
  const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
@@ -121,12 +126,21 @@ function getPaddingObject(padding) {
121
126
  };
122
127
  }
123
128
  function rectToClientRect(rect) {
129
+ const {
130
+ x,
131
+ y,
132
+ width,
133
+ height
134
+ } = rect;
124
135
  return {
125
- ...rect,
126
- top: rect.y,
127
- left: rect.x,
128
- right: rect.x + rect.width,
129
- bottom: rect.y + rect.height
136
+ width,
137
+ height,
138
+ top: y,
139
+ left: x,
140
+ right: x + width,
141
+ bottom: y + height,
142
+ x,
143
+ y
130
144
  };
131
145
  }
132
146
 
@@ -188,7 +202,7 @@ function computeCoordsFromPlacement(_ref, placement, rtl) {
188
202
 
189
203
  /**
190
204
  * Computes the `x` and `y` coordinates that will place the floating element
191
- * next to a reference element when it is given a certain positioning strategy.
205
+ * next to a given reference element.
192
206
  *
193
207
  * This export does not have any `platform` interface logic. You will need to
194
208
  * write one for the platform you are using Floating UI with.
@@ -266,7 +280,6 @@ const computePosition$1 = async (reference, floating, config) => {
266
280
  } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
267
281
  }
268
282
  i = -1;
269
- continue;
270
283
  }
271
284
  }
272
285
  return {
@@ -316,9 +329,10 @@ async function detectOverflow(state, options) {
316
329
  strategy
317
330
  }));
318
331
  const rect = elementContext === 'floating' ? {
319
- ...rects.floating,
320
332
  x,
321
- y
333
+ y,
334
+ width: rects.floating.width,
335
+ height: rects.floating.height
322
336
  } : rects.reference;
323
337
  const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
324
338
  const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
@@ -329,6 +343,7 @@ async function detectOverflow(state, options) {
329
343
  y: 1
330
344
  };
331
345
  const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
346
+ elements,
332
347
  rect,
333
348
  offsetParent,
334
349
  strategy
@@ -346,7 +361,7 @@ async function detectOverflow(state, options) {
346
361
  * appears centered to the reference element.
347
362
  * @see https://floating-ui.com/docs/arrow
348
363
  */
349
- const arrow = options => ({
364
+ const arrow$1 = options => ({
350
365
  name: 'arrow',
351
366
  options,
352
367
  async fn(state) {
@@ -407,7 +422,7 @@ const arrow = options => ({
407
422
  // to point to nothing for an aligned placement, adjust the offset of the
408
423
  // floating element itself. To ensure `shift()` continues to take action,
409
424
  // a single reset is performed when this is true.
410
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
425
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
411
426
  const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
412
427
  return {
413
428
  [axis]: coords[axis] + alignmentOffset,
@@ -438,7 +453,7 @@ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
438
453
  * preferred placement. Alternative to `flip`.
439
454
  * @see https://floating-ui.com/docs/autoPlacement
440
455
  */
441
- const autoPlacement = function (options) {
456
+ const autoPlacement$1 = function (options) {
442
457
  if (options === void 0) {
443
458
  options = {};
444
459
  }
@@ -532,7 +547,7 @@ const autoPlacement = function (options) {
532
547
  * clipping boundary. Alternative to `autoPlacement`.
533
548
  * @see https://floating-ui.com/docs/flip
534
549
  */
535
- const flip = function (options) {
550
+ const flip$1 = function (options) {
536
551
  if (options === void 0) {
537
552
  options = {};
538
553
  }
@@ -567,10 +582,12 @@ const flip = function (options) {
567
582
  return {};
568
583
  }
569
584
  const side = getSide(placement);
585
+ const initialSideAxis = getSideAxis(initialPlacement);
570
586
  const isBasePlacement = getSide(initialPlacement) === initialPlacement;
571
587
  const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
572
588
  const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
573
- if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
589
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
590
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
574
591
  fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
575
592
  }
576
593
  const placements = [initialPlacement, ...fallbackPlacements];
@@ -616,8 +633,17 @@ const flip = function (options) {
616
633
  switch (fallbackStrategy) {
617
634
  case 'bestFit':
618
635
  {
619
- var _overflowsData$map$so;
620
- const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
636
+ var _overflowsData$filter2;
637
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
638
+ if (hasFallbackAxisSideDirection) {
639
+ const currentSideAxis = getSideAxis(d.placement);
640
+ return currentSideAxis === initialSideAxis ||
641
+ // Create a bias to the `y` side axis due to horizontal
642
+ // reading directions favoring greater width.
643
+ currentSideAxis === 'y';
644
+ }
645
+ return true;
646
+ }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
621
647
  if (placement) {
622
648
  resetPlacement = placement;
623
649
  }
@@ -657,7 +683,7 @@ function isAnySideFullyClipped(overflow) {
657
683
  * when it is not in the same clipping context as the reference element.
658
684
  * @see https://floating-ui.com/docs/hide
659
685
  */
660
- const hide = function (options) {
686
+ const hide$1 = function (options) {
661
687
  if (options === void 0) {
662
688
  options = {};
663
689
  }
@@ -742,7 +768,7 @@ function getRectsByLine(rects) {
742
768
  * over multiple lines, such as hyperlinks or range selections.
743
769
  * @see https://floating-ui.com/docs/inline
744
770
  */
745
- const inline = function (options) {
771
+ const inline$1 = function (options) {
746
772
  if (options === void 0) {
747
773
  options = {};
748
774
  }
@@ -843,6 +869,7 @@ const inline = function (options) {
843
869
 
844
870
  // For type backwards-compatibility, the `OffsetOptions` type was also
845
871
  // Derivable.
872
+
846
873
  async function convertValueToCoords(state, options) {
847
874
  const {
848
875
  placement,
@@ -867,10 +894,9 @@ async function convertValueToCoords(state, options) {
867
894
  crossAxis: 0,
868
895
  alignmentAxis: null
869
896
  } : {
870
- mainAxis: 0,
871
- crossAxis: 0,
872
- alignmentAxis: null,
873
- ...rawValue
897
+ mainAxis: rawValue.mainAxis || 0,
898
+ crossAxis: rawValue.crossAxis || 0,
899
+ alignmentAxis: rawValue.alignmentAxis
874
900
  };
875
901
  if (alignment && typeof alignmentAxis === 'number') {
876
902
  crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
@@ -891,7 +917,10 @@ async function convertValueToCoords(state, options) {
891
917
  * object may be passed.
892
918
  * @see https://floating-ui.com/docs/offset
893
919
  */
894
- const offset = function (options) {
920
+ const offset$1 = function (options) {
921
+ if (options === void 0) {
922
+ options = 0;
923
+ }
895
924
  return {
896
925
  name: 'offset',
897
926
  options,
@@ -928,7 +957,7 @@ const offset = function (options) {
928
957
  * width of the reference element.
929
958
  * @see https://floating-ui.com/docs/size
930
959
  */
931
- const size = function (options) {
960
+ const size$1 = function (options) {
932
961
  if (options === void 0) {
933
962
  options = {};
934
963
  }
@@ -936,6 +965,7 @@ const size = function (options) {
936
965
  name: 'size',
937
966
  options,
938
967
  async fn(state) {
968
+ var _state$middlewareData, _state$middlewareData2;
939
969
  const {
940
970
  placement,
941
971
  rects,
@@ -963,17 +993,18 @@ const size = function (options) {
963
993
  widthSide = side;
964
994
  heightSide = alignment === 'end' ? 'top' : 'bottom';
965
995
  }
966
- const overflowAvailableHeight = height - overflow[heightSide];
967
- const overflowAvailableWidth = width - overflow[widthSide];
996
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
997
+ const maximumClippingWidth = width - overflow.left - overflow.right;
998
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
999
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
968
1000
  const noShift = !state.middlewareData.shift;
969
1001
  let availableHeight = overflowAvailableHeight;
970
1002
  let availableWidth = overflowAvailableWidth;
971
- if (isYAxis) {
972
- const maximumClippingWidth = width - overflow.left - overflow.right;
973
- availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
974
- } else {
975
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
976
- availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
1003
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
1004
+ availableWidth = maximumClippingWidth;
1005
+ }
1006
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
1007
+ availableHeight = maximumClippingHeight;
977
1008
  }
978
1009
  if (noShift && !alignment) {
979
1010
  const xMin = max(overflow.left, 0);
@@ -1004,6 +1035,9 @@ const size = function (options) {
1004
1035
  };
1005
1036
  };
1006
1037
 
1038
+ function hasWindow() {
1039
+ return typeof window !== 'undefined';
1040
+ }
1007
1041
  function getNodeName(node) {
1008
1042
  if (isNode(node)) {
1009
1043
  return (node.nodeName || '').toLowerCase();
@@ -1015,24 +1049,32 @@ function getNodeName(node) {
1015
1049
  }
1016
1050
  function getWindow(node) {
1017
1051
  var _node$ownerDocument;
1018
- return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1052
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1019
1053
  }
1020
1054
  function getDocumentElement(node) {
1021
1055
  var _ref;
1022
1056
  return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1023
1057
  }
1024
1058
  function isNode(value) {
1059
+ if (!hasWindow()) {
1060
+ return false;
1061
+ }
1025
1062
  return value instanceof Node || value instanceof getWindow(value).Node;
1026
1063
  }
1027
1064
  function isElement(value) {
1065
+ if (!hasWindow()) {
1066
+ return false;
1067
+ }
1028
1068
  return value instanceof Element || value instanceof getWindow(value).Element;
1029
1069
  }
1030
1070
  function isHTMLElement(value) {
1071
+ if (!hasWindow()) {
1072
+ return false;
1073
+ }
1031
1074
  return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1032
1075
  }
1033
1076
  function isShadowRoot(value) {
1034
- // Browsers without `ShadowRoot` support.
1035
- if (typeof ShadowRoot === 'undefined') {
1077
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
1036
1078
  return false;
1037
1079
  }
1038
1080
  return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
@@ -1049,9 +1091,18 @@ function isOverflowElement(element) {
1049
1091
  function isTableElement(element) {
1050
1092
  return ['table', 'td', 'th'].includes(getNodeName(element));
1051
1093
  }
1052
- function isContainingBlock(element) {
1094
+ function isTopLayer(element) {
1095
+ return [':popover-open', ':modal'].some(selector => {
1096
+ try {
1097
+ return element.matches(selector);
1098
+ } catch (e) {
1099
+ return false;
1100
+ }
1101
+ });
1102
+ }
1103
+ function isContainingBlock(elementOrCss) {
1053
1104
  const webkit = isWebKit();
1054
- const css = getComputedStyle(element);
1105
+ const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
1055
1106
 
1056
1107
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1057
1108
  return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
@@ -1061,9 +1112,10 @@ function getContainingBlock(element) {
1061
1112
  while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1062
1113
  if (isContainingBlock(currentNode)) {
1063
1114
  return currentNode;
1064
- } else {
1065
- currentNode = getParentNode(currentNode);
1115
+ } else if (isTopLayer(currentNode)) {
1116
+ return null;
1066
1117
  }
1118
+ currentNode = getParentNode(currentNode);
1067
1119
  }
1068
1120
  return null;
1069
1121
  }
@@ -1085,8 +1137,8 @@ function getNodeScroll(element) {
1085
1137
  };
1086
1138
  }
1087
1139
  return {
1088
- scrollLeft: element.pageXOffset,
1089
- scrollTop: element.pageYOffset
1140
+ scrollLeft: element.scrollX,
1141
+ scrollTop: element.scrollY
1090
1142
  };
1091
1143
  }
1092
1144
  function getParentNode(node) {
@@ -1126,10 +1178,14 @@ function getOverflowAncestors(node, list, traverseIframes) {
1126
1178
  const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1127
1179
  const win = getWindow(scrollableAncestor);
1128
1180
  if (isBody) {
1129
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
1181
+ const frameElement = getFrameElement(win);
1182
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1130
1183
  }
1131
1184
  return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1132
1185
  }
1186
+ function getFrameElement(win) {
1187
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1188
+ }
1133
1189
 
1134
1190
  function getCssDimensions(element) {
1135
1191
  const css = getComputedStyle(element);
@@ -1232,8 +1288,9 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
1232
1288
  if (domElement) {
1233
1289
  const win = getWindow(domElement);
1234
1290
  const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1235
- let currentIFrame = win.frameElement;
1236
- while (currentIFrame && offsetParent && offsetWin !== win) {
1291
+ let currentWin = win;
1292
+ let currentIFrame = getFrameElement(currentWin);
1293
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1237
1294
  const iframeScale = getScale(currentIFrame);
1238
1295
  const iframeRect = currentIFrame.getBoundingClientRect();
1239
1296
  const css = getComputedStyle(currentIFrame);
@@ -1245,7 +1302,8 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
1245
1302
  height *= iframeScale.y;
1246
1303
  x += left;
1247
1304
  y += top;
1248
- currentIFrame = getWindow(currentIFrame).frameElement;
1305
+ currentWin = getWindow(currentIFrame);
1306
+ currentIFrame = getFrameElement(currentWin);
1249
1307
  }
1250
1308
  }
1251
1309
  return rectToClientRect({
@@ -1256,15 +1314,42 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
1256
1314
  });
1257
1315
  }
1258
1316
 
1317
+ // If <html> has a CSS width greater than the viewport, then this will be
1318
+ // incorrect for RTL.
1319
+ function getWindowScrollBarX(element, rect) {
1320
+ const leftScroll = getNodeScroll(element).scrollLeft;
1321
+ if (!rect) {
1322
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1323
+ }
1324
+ return rect.left + leftScroll;
1325
+ }
1326
+
1327
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
1328
+ if (ignoreScrollbarX === void 0) {
1329
+ ignoreScrollbarX = false;
1330
+ }
1331
+ const htmlRect = documentElement.getBoundingClientRect();
1332
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
1333
+ // RTL <body> scrollbar.
1334
+ getWindowScrollBarX(documentElement, htmlRect));
1335
+ const y = htmlRect.top + scroll.scrollTop;
1336
+ return {
1337
+ x,
1338
+ y
1339
+ };
1340
+ }
1341
+
1259
1342
  function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1260
1343
  let {
1344
+ elements,
1261
1345
  rect,
1262
1346
  offsetParent,
1263
1347
  strategy
1264
1348
  } = _ref;
1265
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1349
+ const isFixed = strategy === 'fixed';
1266
1350
  const documentElement = getDocumentElement(offsetParent);
1267
- if (offsetParent === documentElement) {
1351
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1352
+ if (offsetParent === documentElement || topLayer && isFixed) {
1268
1353
  return rect;
1269
1354
  }
1270
1355
  let scroll = {
@@ -1273,7 +1358,8 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1273
1358
  };
1274
1359
  let scale = createCoords(1);
1275
1360
  const offsets = createCoords(0);
1276
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1361
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1362
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1277
1363
  if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1278
1364
  scroll = getNodeScroll(offsetParent);
1279
1365
  }
@@ -1284,11 +1370,12 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1284
1370
  offsets.y = offsetRect.y + offsetParent.clientTop;
1285
1371
  }
1286
1372
  }
1373
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
1287
1374
  return {
1288
1375
  width: rect.width * scale.x,
1289
1376
  height: rect.height * scale.y,
1290
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
1291
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
1377
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1378
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1292
1379
  };
1293
1380
  }
1294
1381
 
@@ -1296,12 +1383,6 @@ function getClientRects(element) {
1296
1383
  return Array.from(element.getClientRects());
1297
1384
  }
1298
1385
 
1299
- function getWindowScrollBarX(element) {
1300
- // If <html> has a CSS width greater than the viewport, then this will be
1301
- // incorrect for RTL.
1302
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1303
- }
1304
-
1305
1386
  // Gets the entire size of the scrollable document area, even extending outside
1306
1387
  // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1307
1388
  function getDocumentRect(element) {
@@ -1376,9 +1457,10 @@ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy)
1376
1457
  } else {
1377
1458
  const visualOffsets = getVisualOffsets(element);
1378
1459
  rect = {
1379
- ...clippingAncestor,
1380
1460
  x: clippingAncestor.x - visualOffsets.x,
1381
- y: clippingAncestor.y - visualOffsets.y
1461
+ y: clippingAncestor.y - visualOffsets.y,
1462
+ width: clippingAncestor.width,
1463
+ height: clippingAncestor.height
1382
1464
  };
1383
1465
  }
1384
1466
  return rectToClientRect(rect);
@@ -1434,7 +1516,7 @@ function getClippingRect(_ref) {
1434
1516
  rootBoundary,
1435
1517
  strategy
1436
1518
  } = _ref;
1437
- const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
1519
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1438
1520
  const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1439
1521
  const firstClippingAncestor = clippingAncestors[0];
1440
1522
  const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
@@ -1454,7 +1536,14 @@ function getClippingRect(_ref) {
1454
1536
  }
1455
1537
 
1456
1538
  function getDimensions(element) {
1457
- return getCssDimensions(element);
1539
+ const {
1540
+ width,
1541
+ height
1542
+ } = getCssDimensions(element);
1543
+ return {
1544
+ width,
1545
+ height
1546
+ };
1458
1547
  }
1459
1548
 
1460
1549
  function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
@@ -1476,17 +1565,26 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1476
1565
  offsets.x = offsetRect.x + offsetParent.clientLeft;
1477
1566
  offsets.y = offsetRect.y + offsetParent.clientTop;
1478
1567
  } else if (documentElement) {
1568
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1569
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1479
1570
  offsets.x = getWindowScrollBarX(documentElement);
1480
1571
  }
1481
1572
  }
1573
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1574
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1575
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1482
1576
  return {
1483
- x: rect.left + scroll.scrollLeft - offsets.x,
1484
- y: rect.top + scroll.scrollTop - offsets.y,
1577
+ x,
1578
+ y,
1485
1579
  width: rect.width,
1486
1580
  height: rect.height
1487
1581
  };
1488
1582
  }
1489
1583
 
1584
+ function isStaticPositioned(element) {
1585
+ return getComputedStyle(element).position === 'static';
1586
+ }
1587
+
1490
1588
  function getTrueOffsetParent(element, polyfill) {
1491
1589
  if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1492
1590
  return null;
@@ -1494,40 +1592,56 @@ function getTrueOffsetParent(element, polyfill) {
1494
1592
  if (polyfill) {
1495
1593
  return polyfill(element);
1496
1594
  }
1497
- return element.offsetParent;
1595
+ let rawOffsetParent = element.offsetParent;
1596
+
1597
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1598
+ // while Chrome and Safari return the <body> element. The <body> element must
1599
+ // be used to perform the correct calculations even if the <html> element is
1600
+ // non-static.
1601
+ if (getDocumentElement(element) === rawOffsetParent) {
1602
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1603
+ }
1604
+ return rawOffsetParent;
1498
1605
  }
1499
1606
 
1500
1607
  // Gets the closest ancestor positioned element. Handles some edge cases,
1501
1608
  // such as table ancestors and cross browser bugs.
1502
1609
  function getOffsetParent(element, polyfill) {
1503
- const window = getWindow(element);
1610
+ const win = getWindow(element);
1611
+ if (isTopLayer(element)) {
1612
+ return win;
1613
+ }
1504
1614
  if (!isHTMLElement(element)) {
1505
- return window;
1615
+ let svgOffsetParent = getParentNode(element);
1616
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1617
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1618
+ return svgOffsetParent;
1619
+ }
1620
+ svgOffsetParent = getParentNode(svgOffsetParent);
1621
+ }
1622
+ return win;
1506
1623
  }
1507
1624
  let offsetParent = getTrueOffsetParent(element, polyfill);
1508
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1625
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1509
1626
  offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1510
1627
  }
1511
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1512
- return window;
1628
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1629
+ return win;
1513
1630
  }
1514
- return offsetParent || getContainingBlock(element) || window;
1631
+ return offsetParent || getContainingBlock(element) || win;
1515
1632
  }
1516
1633
 
1517
- const getElementRects = async function (_ref) {
1518
- let {
1519
- reference,
1520
- floating,
1521
- strategy
1522
- } = _ref;
1634
+ const getElementRects = async function (data) {
1523
1635
  const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1524
1636
  const getDimensionsFn = this.getDimensions;
1637
+ const floatingDimensions = await getDimensionsFn(data.floating);
1525
1638
  return {
1526
- reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
1639
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1527
1640
  floating: {
1528
1641
  x: 0,
1529
1642
  y: 0,
1530
- ...(await getDimensionsFn(floating))
1643
+ width: floatingDimensions.width,
1644
+ height: floatingDimensions.height
1531
1645
  }
1532
1646
  };
1533
1647
  };
@@ -1555,8 +1669,9 @@ function observeMove(element, onMove) {
1555
1669
  let timeoutId;
1556
1670
  const root = getDocumentElement(element);
1557
1671
  function cleanup() {
1672
+ var _io;
1558
1673
  clearTimeout(timeoutId);
1559
- io && io.disconnect();
1674
+ (_io = io) == null || _io.disconnect();
1560
1675
  io = null;
1561
1676
  }
1562
1677
  function refresh(skip, threshold) {
@@ -1596,9 +1711,11 @@ function observeMove(element, onMove) {
1596
1711
  return refresh();
1597
1712
  }
1598
1713
  if (!ratio) {
1714
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1715
+ // to prevent an infinite loop of updates.
1599
1716
  timeoutId = setTimeout(() => {
1600
1717
  refresh(false, 1e-7);
1601
- }, 100);
1718
+ }, 1000);
1602
1719
  } else {
1603
1720
  refresh(false, ratio);
1604
1721
  }
@@ -1662,7 +1779,8 @@ function autoUpdate(reference, floating, update, options) {
1662
1779
  resizeObserver.unobserve(floating);
1663
1780
  cancelAnimationFrame(reobserveFrame);
1664
1781
  reobserveFrame = requestAnimationFrame(() => {
1665
- resizeObserver && resizeObserver.observe(floating);
1782
+ var _resizeObserver;
1783
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1666
1784
  });
1667
1785
  }
1668
1786
  update();
@@ -1687,12 +1805,13 @@ function autoUpdate(reference, floating, update, options) {
1687
1805
  }
1688
1806
  update();
1689
1807
  return () => {
1808
+ var _resizeObserver2;
1690
1809
  ancestors.forEach(ancestor => {
1691
1810
  ancestorScroll && ancestor.removeEventListener('scroll', update);
1692
1811
  ancestorResize && ancestor.removeEventListener('resize', update);
1693
1812
  });
1694
- cleanupIo && cleanupIo();
1695
- resizeObserver && resizeObserver.disconnect();
1813
+ cleanupIo == null || cleanupIo();
1814
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1696
1815
  resizeObserver = null;
1697
1816
  if (animationFrame) {
1698
1817
  cancelAnimationFrame(frameId);
@@ -1700,10 +1819,63 @@ function autoUpdate(reference, floating, update, options) {
1700
1819
  };
1701
1820
  }
1702
1821
 
1822
+ /**
1823
+ * Modifies the placement by translating the floating element along the
1824
+ * specified axes.
1825
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1826
+ * object may be passed.
1827
+ * @see https://floating-ui.com/docs/offset
1828
+ */
1829
+ const offset = offset$1;
1830
+
1831
+ /**
1832
+ * Optimizes the visibility of the floating element by choosing the placement
1833
+ * that has the most space available automatically, without needing to specify a
1834
+ * preferred placement. Alternative to `flip`.
1835
+ * @see https://floating-ui.com/docs/autoPlacement
1836
+ */
1837
+ const autoPlacement = autoPlacement$1;
1838
+
1839
+ /**
1840
+ * Optimizes the visibility of the floating element by flipping the `placement`
1841
+ * in order to keep it in view when the preferred placement(s) will overflow the
1842
+ * clipping boundary. Alternative to `autoPlacement`.
1843
+ * @see https://floating-ui.com/docs/flip
1844
+ */
1845
+ const flip = flip$1;
1846
+
1847
+ /**
1848
+ * Provides data that allows you to change the size of the floating element —
1849
+ * for instance, prevent it from overflowing the clipping boundary or match the
1850
+ * width of the reference element.
1851
+ * @see https://floating-ui.com/docs/size
1852
+ */
1853
+ const size = size$1;
1854
+
1855
+ /**
1856
+ * Provides data to hide the floating element in applicable situations, such as
1857
+ * when it is not in the same clipping context as the reference element.
1858
+ * @see https://floating-ui.com/docs/hide
1859
+ */
1860
+ const hide = hide$1;
1861
+
1862
+ /**
1863
+ * Provides data to position an inner element of the floating element so that it
1864
+ * appears centered to the reference element.
1865
+ * @see https://floating-ui.com/docs/arrow
1866
+ */
1867
+ const arrow = arrow$1;
1868
+
1869
+ /**
1870
+ * Provides improved positioning for inline reference elements that can span
1871
+ * over multiple lines, such as hyperlinks or range selections.
1872
+ * @see https://floating-ui.com/docs/inline
1873
+ */
1874
+ const inline = inline$1;
1875
+
1703
1876
  /**
1704
1877
  * Computes the `x` and `y` coordinates that will place the floating element
1705
- * next to a reference element when it is given a certain CSS positioning
1706
- * strategy.
1878
+ * next to a given reference element.
1707
1879
  */
1708
1880
  const computePosition = (reference, floating, options) => {
1709
1881
  // This caches the expensive `getClippingElementAncestors` function so that
@@ -1803,7 +1975,10 @@ class Popup extends index.FoundationElement {
1803
1975
  #cleanup;
1804
1976
  openChanged(_, newValue) {
1805
1977
  newValue ? this.$emit("vwc-popup:open") : this.$emit("vwc-popup:close");
1806
- index.DOM.queueUpdate(() => this.#updateAutoUpdate());
1978
+ index.DOM.queueUpdate(() => {
1979
+ this.#updateAutoUpdate();
1980
+ this.#togglePopover();
1981
+ });
1807
1982
  }
1808
1983
  /**
1809
1984
  * @internal
@@ -1817,6 +1992,9 @@ class Popup extends index.FoundationElement {
1817
1992
  anchorChanged() {
1818
1993
  this.#updateAutoUpdate();
1819
1994
  }
1995
+ strategyChanged() {
1996
+ this.#togglePopover();
1997
+ }
1820
1998
  connectedCallback() {
1821
1999
  super.connectedCallback();
1822
2000
  this.#updateAutoUpdate();
@@ -1838,6 +2016,15 @@ class Popup extends index.FoundationElement {
1838
2016
  );
1839
2017
  }
1840
2018
  }
2019
+ #togglePopover() {
2020
+ if (this.popupEl && this.strategy === "fixed") {
2021
+ if (this.open) {
2022
+ this.popupEl.showPopover();
2023
+ } else {
2024
+ this.popupEl.hidePopover();
2025
+ }
2026
+ }
2027
+ }
1841
2028
  /**
1842
2029
  * Updates popup's position
1843
2030
  *
@@ -1923,7 +2110,7 @@ __decorateClass([
1923
2110
  index.observable
1924
2111
  ], Popup.prototype, "anchor");
1925
2112
 
1926
- const styles = ":host{display:var(--_popup-display, inline)}.control{border-radius:inherit;background:var(--vvd-color-surface-4dp);contain:layout}.control:not(.open){display:none}.popup-wrapper{white-space:initial;z-index:var(--_popup-z-index, 10);border-radius:8px;inline-size:max-content}.popup-wrapper:not(.absolute){position:fixed}.popup-wrapper.absolute{position:absolute;top:0;left:0}.popup-content{display:grid;color:var(--vvd-color-canvas-text)}.dismissible .popup-content{align-content:start;grid-template-columns:1fr auto}.arrow{position:absolute;z-index:-1;width:8px;height:8px;background:var(--vvd-color-surface-4dp);transform:rotate(45deg)}.dismissible-button{align-self:flex-start;margin-block-start:4px;margin-inline-end:4px}";
2113
+ const styles = ":host{display:var(--_popup-display, inline)}.control{border-radius:inherit;background:var(--vvd-color-surface-4dp);contain:layout}.control:not(.open){display:none}.popup-wrapper{white-space:initial;z-index:var(--_popup-z-index, 10);overflow:visible;padding:0;border:none;border-radius:8px;margin:0;inline-size:max-content}.popup-wrapper:not(.absolute){position:fixed}.popup-wrapper.absolute{position:absolute;top:0;left:0}.popup-content{display:grid;color:var(--vvd-color-canvas-text)}.dismissible .popup-content{align-content:start;grid-template-columns:1fr auto}.arrow{position:absolute;z-index:-1;width:8px;height:8px;background:var(--vvd-color-surface-4dp);transform:rotate(45deg)}.dismissible-button{align-self:flex-start;margin-block-start:4px;margin-inline-end:4px}";
1927
2114
 
1928
2115
  const getClasses = ({ open, dismissible, alternate }) => classNames.classNames(
1929
2116
  "control",
@@ -1931,14 +2118,15 @@ const getClasses = ({ open, dismissible, alternate }) => classNames.classNames(
1931
2118
  ["dismissible", Boolean(dismissible)],
1932
2119
  ["alternate", Boolean(alternate)]
1933
2120
  );
2121
+ function handlePopover(x) {
2122
+ return x.strategy && x.strategy === "fixed" ? "manual" : null;
2123
+ }
1934
2124
  const popupTemplate = (context) => {
1935
2125
  const elevationTag = context.tagFor(definition.Elevation);
1936
- const buttonTag = context.tagFor(definition$1.Button);
2126
+ const buttonTag = context.tagFor(definition$1.Button$1);
1937
2127
  return index.html`
1938
2128
  <${elevationTag}>
1939
- <div class="popup-wrapper ${(x) => x.strategy}" ${ref.ref(
1940
- "popupEl"
1941
- )} part="popup-base">
2129
+ <div popover="${handlePopover}" class="popup-wrapper ${(x) => x.strategy}" ${ref.ref("popupEl")} part="popup-base">
1942
2130
  <div class="${getClasses}" aria-hidden="${(x) => x.open ? "false" : "true"}"
1943
2131
  part="${(x) => x.alternate ? "vvd-theme-alternate" : ""}">
1944
2132
  <div class="popup-content">