@vonage/vivid 4.9.0 → 4.11.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 (103) hide show
  1. package/custom-elements.json +2792 -83
  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 +8 -2
  6. package/lib/checkbox/checkbox.form-associated.d.ts +10 -0
  7. package/lib/dialog/dialog.d.ts +4 -0
  8. package/lib/divider/divider.d.ts +11 -2
  9. package/lib/enums.d.ts +1 -0
  10. package/lib/fab/fab.d.ts +1 -1
  11. package/lib/file-picker/file-picker.d.ts +3 -0
  12. package/lib/icon/icon.d.ts +2 -1
  13. package/lib/slider/slider.d.ts +30 -6
  14. package/lib/slider/slider.form-associated.d.ts +10 -0
  15. package/lib/split-button/split-button.d.ts +1 -1
  16. package/lib/tabs/tabs.d.ts +1 -0
  17. package/lib/text-field/text-field.d.ts +1 -0
  18. package/package.json +1 -1
  19. package/shared/aria-global2.cjs +93 -0
  20. package/shared/aria-global2.js +91 -0
  21. package/shared/breadcrumb-item.cjs +2 -89
  22. package/shared/breadcrumb-item.js +1 -88
  23. package/shared/definition11.cjs +201 -5
  24. package/shared/definition11.js +199 -4
  25. package/shared/definition15.cjs +49 -90
  26. package/shared/definition15.js +50 -91
  27. package/shared/definition16.cjs +9 -7
  28. package/shared/definition16.js +9 -7
  29. package/shared/definition20.cjs +16 -11
  30. package/shared/definition20.js +16 -11
  31. package/shared/definition21.cjs +34 -4
  32. package/shared/definition21.js +34 -4
  33. package/shared/definition22.cjs +32 -51
  34. package/shared/definition22.js +33 -52
  35. package/shared/definition24.cjs +156 -2
  36. package/shared/definition24.js +157 -3
  37. package/shared/definition25.cjs +106 -56
  38. package/shared/definition25.js +106 -56
  39. package/shared/definition29.cjs +1 -1
  40. package/shared/definition29.js +1 -1
  41. package/shared/definition30.cjs +1 -1
  42. package/shared/definition30.js +1 -1
  43. package/shared/definition35.cjs +2 -2
  44. package/shared/definition35.js +2 -2
  45. package/shared/definition37.cjs +1 -1
  46. package/shared/definition37.js +1 -1
  47. package/shared/definition4.cjs +5 -6
  48. package/shared/definition4.js +1 -2
  49. package/shared/definition40.cjs +11 -4
  50. package/shared/definition40.js +8 -1
  51. package/shared/definition42.cjs +3 -22
  52. package/shared/definition42.js +2 -21
  53. package/shared/definition43.cjs +1 -2
  54. package/shared/definition43.js +1 -2
  55. package/shared/definition44.js +1 -1
  56. package/shared/definition47.cjs +369 -502
  57. package/shared/definition47.js +370 -503
  58. package/shared/definition5.cjs +5 -5
  59. package/shared/definition5.js +2 -2
  60. package/shared/definition51.cjs +1 -1
  61. package/shared/definition51.js +1 -1
  62. package/shared/definition52.cjs +63 -26
  63. package/shared/definition52.js +63 -26
  64. package/shared/definition56.cjs +45 -43
  65. package/shared/definition56.js +45 -43
  66. package/shared/definition57.cjs +1 -1
  67. package/shared/definition57.js +1 -1
  68. package/shared/definition64.cjs +242 -79
  69. package/shared/definition64.js +242 -79
  70. package/shared/definition7.cjs +1 -1
  71. package/shared/definition7.js +1 -1
  72. package/shared/definition8.cjs +1 -1
  73. package/shared/definition8.js +1 -1
  74. package/shared/enums.cjs +1 -0
  75. package/shared/enums.js +1 -0
  76. package/shared/form-associated.js +1 -1
  77. package/shared/{patterns → foundation/anchor}/anchor.d.ts +1 -1
  78. package/shared/foundation/button/button.d.ts +27 -0
  79. package/shared/foundation/button/button.template.d.ts +4 -0
  80. package/shared/foundation/button/index.d.ts +2 -0
  81. package/shared/foundation/patterns/index.d.ts +1 -0
  82. package/shared/icon.cjs +11 -5
  83. package/shared/icon.js +11 -5
  84. package/shared/index.cjs +22 -2
  85. package/shared/index.js +22 -2
  86. package/shared/key-codes2.js +1 -1
  87. package/shared/patterns/form-elements/form-elements.d.ts +6 -6
  88. package/shared/presentationDate.cjs +4328 -4042
  89. package/shared/presentationDate.js +4327 -4041
  90. package/shared/slider.template.cjs +23 -1
  91. package/shared/slider.template.js +21 -2
  92. package/styles/core/all.css +1 -1
  93. package/styles/core/theme.css +1 -1
  94. package/styles/core/typography.css +1 -1
  95. package/styles/tokens/theme-dark.css +35 -14
  96. package/styles/tokens/theme-light.css +35 -14
  97. package/styles/tokens/vivid-2-compat.css +1 -1
  98. package/vivid.api.json +62 -5
  99. package/shared/aria2.cjs +0 -11
  100. package/shared/aria2.js +0 -9
  101. package/shared/button.cjs +0 -202
  102. package/shared/button.js +0 -200
  103. /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({
@@ -1258,13 +1316,15 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
1258
1316
 
1259
1317
  function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1260
1318
  let {
1319
+ elements,
1261
1320
  rect,
1262
1321
  offsetParent,
1263
1322
  strategy
1264
1323
  } = _ref;
1265
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1324
+ const isFixed = strategy === 'fixed';
1266
1325
  const documentElement = getDocumentElement(offsetParent);
1267
- if (offsetParent === documentElement) {
1326
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1327
+ if (offsetParent === documentElement || topLayer && isFixed) {
1268
1328
  return rect;
1269
1329
  }
1270
1330
  let scroll = {
@@ -1273,7 +1333,8 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1273
1333
  };
1274
1334
  let scale = createCoords(1);
1275
1335
  const offsets = createCoords(0);
1276
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1336
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1337
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1277
1338
  if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1278
1339
  scroll = getNodeScroll(offsetParent);
1279
1340
  }
@@ -1296,10 +1357,14 @@ function getClientRects(element) {
1296
1357
  return Array.from(element.getClientRects());
1297
1358
  }
1298
1359
 
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;
1360
+ // If <html> has a CSS width greater than the viewport, then this will be
1361
+ // incorrect for RTL.
1362
+ function getWindowScrollBarX(element, rect) {
1363
+ const leftScroll = getNodeScroll(element).scrollLeft;
1364
+ if (!rect) {
1365
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1366
+ }
1367
+ return rect.left + leftScroll;
1303
1368
  }
1304
1369
 
1305
1370
  // Gets the entire size of the scrollable document area, even extending outside
@@ -1434,7 +1499,7 @@ function getClippingRect(_ref) {
1434
1499
  rootBoundary,
1435
1500
  strategy
1436
1501
  } = _ref;
1437
- const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
1502
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1438
1503
  const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1439
1504
  const firstClippingAncestor = clippingAncestors[0];
1440
1505
  const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
@@ -1454,7 +1519,14 @@ function getClippingRect(_ref) {
1454
1519
  }
1455
1520
 
1456
1521
  function getDimensions(element) {
1457
- return getCssDimensions(element);
1522
+ const {
1523
+ width,
1524
+ height
1525
+ } = getCssDimensions(element);
1526
+ return {
1527
+ width,
1528
+ height
1529
+ };
1458
1530
  }
1459
1531
 
1460
1532
  function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
@@ -1476,17 +1548,34 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1476
1548
  offsets.x = offsetRect.x + offsetParent.clientLeft;
1477
1549
  offsets.y = offsetRect.y + offsetParent.clientTop;
1478
1550
  } else if (documentElement) {
1551
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1552
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1479
1553
  offsets.x = getWindowScrollBarX(documentElement);
1480
1554
  }
1481
1555
  }
1556
+ let htmlX = 0;
1557
+ let htmlY = 0;
1558
+ if (documentElement && !isOffsetParentAnElement && !isFixed) {
1559
+ const htmlRect = documentElement.getBoundingClientRect();
1560
+ htmlY = htmlRect.top + scroll.scrollTop;
1561
+ htmlX = htmlRect.left + scroll.scrollLeft -
1562
+ // RTL <body> scrollbar.
1563
+ getWindowScrollBarX(documentElement, htmlRect);
1564
+ }
1565
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlX;
1566
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlY;
1482
1567
  return {
1483
- x: rect.left + scroll.scrollLeft - offsets.x,
1484
- y: rect.top + scroll.scrollTop - offsets.y,
1568
+ x,
1569
+ y,
1485
1570
  width: rect.width,
1486
1571
  height: rect.height
1487
1572
  };
1488
1573
  }
1489
1574
 
1575
+ function isStaticPositioned(element) {
1576
+ return getComputedStyle(element).position === 'static';
1577
+ }
1578
+
1490
1579
  function getTrueOffsetParent(element, polyfill) {
1491
1580
  if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1492
1581
  return null;
@@ -1494,40 +1583,56 @@ function getTrueOffsetParent(element, polyfill) {
1494
1583
  if (polyfill) {
1495
1584
  return polyfill(element);
1496
1585
  }
1497
- return element.offsetParent;
1586
+ let rawOffsetParent = element.offsetParent;
1587
+
1588
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1589
+ // while Chrome and Safari return the <body> element. The <body> element must
1590
+ // be used to perform the correct calculations even if the <html> element is
1591
+ // non-static.
1592
+ if (getDocumentElement(element) === rawOffsetParent) {
1593
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1594
+ }
1595
+ return rawOffsetParent;
1498
1596
  }
1499
1597
 
1500
1598
  // Gets the closest ancestor positioned element. Handles some edge cases,
1501
1599
  // such as table ancestors and cross browser bugs.
1502
1600
  function getOffsetParent(element, polyfill) {
1503
- const window = getWindow(element);
1601
+ const win = getWindow(element);
1602
+ if (isTopLayer(element)) {
1603
+ return win;
1604
+ }
1504
1605
  if (!isHTMLElement(element)) {
1505
- return window;
1606
+ let svgOffsetParent = getParentNode(element);
1607
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1608
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1609
+ return svgOffsetParent;
1610
+ }
1611
+ svgOffsetParent = getParentNode(svgOffsetParent);
1612
+ }
1613
+ return win;
1506
1614
  }
1507
1615
  let offsetParent = getTrueOffsetParent(element, polyfill);
1508
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1616
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1509
1617
  offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1510
1618
  }
1511
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1512
- return window;
1619
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1620
+ return win;
1513
1621
  }
1514
- return offsetParent || getContainingBlock(element) || window;
1622
+ return offsetParent || getContainingBlock(element) || win;
1515
1623
  }
1516
1624
 
1517
- const getElementRects = async function (_ref) {
1518
- let {
1519
- reference,
1520
- floating,
1521
- strategy
1522
- } = _ref;
1625
+ const getElementRects = async function (data) {
1523
1626
  const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1524
1627
  const getDimensionsFn = this.getDimensions;
1628
+ const floatingDimensions = await getDimensionsFn(data.floating);
1525
1629
  return {
1526
- reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
1630
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1527
1631
  floating: {
1528
1632
  x: 0,
1529
1633
  y: 0,
1530
- ...(await getDimensionsFn(floating))
1634
+ width: floatingDimensions.width,
1635
+ height: floatingDimensions.height
1531
1636
  }
1532
1637
  };
1533
1638
  };
@@ -1555,8 +1660,9 @@ function observeMove(element, onMove) {
1555
1660
  let timeoutId;
1556
1661
  const root = getDocumentElement(element);
1557
1662
  function cleanup() {
1663
+ var _io;
1558
1664
  clearTimeout(timeoutId);
1559
- io && io.disconnect();
1665
+ (_io = io) == null || _io.disconnect();
1560
1666
  io = null;
1561
1667
  }
1562
1668
  function refresh(skip, threshold) {
@@ -1596,9 +1702,11 @@ function observeMove(element, onMove) {
1596
1702
  return refresh();
1597
1703
  }
1598
1704
  if (!ratio) {
1705
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1706
+ // to prevent an infinite loop of updates.
1599
1707
  timeoutId = setTimeout(() => {
1600
1708
  refresh(false, 1e-7);
1601
- }, 100);
1709
+ }, 1000);
1602
1710
  } else {
1603
1711
  refresh(false, ratio);
1604
1712
  }
@@ -1662,7 +1770,8 @@ function autoUpdate(reference, floating, update, options) {
1662
1770
  resizeObserver.unobserve(floating);
1663
1771
  cancelAnimationFrame(reobserveFrame);
1664
1772
  reobserveFrame = requestAnimationFrame(() => {
1665
- resizeObserver && resizeObserver.observe(floating);
1773
+ var _resizeObserver;
1774
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1666
1775
  });
1667
1776
  }
1668
1777
  update();
@@ -1687,12 +1796,13 @@ function autoUpdate(reference, floating, update, options) {
1687
1796
  }
1688
1797
  update();
1689
1798
  return () => {
1799
+ var _resizeObserver2;
1690
1800
  ancestors.forEach(ancestor => {
1691
1801
  ancestorScroll && ancestor.removeEventListener('scroll', update);
1692
1802
  ancestorResize && ancestor.removeEventListener('resize', update);
1693
1803
  });
1694
- cleanupIo && cleanupIo();
1695
- resizeObserver && resizeObserver.disconnect();
1804
+ cleanupIo == null || cleanupIo();
1805
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1696
1806
  resizeObserver = null;
1697
1807
  if (animationFrame) {
1698
1808
  cancelAnimationFrame(frameId);
@@ -1700,10 +1810,63 @@ function autoUpdate(reference, floating, update, options) {
1700
1810
  };
1701
1811
  }
1702
1812
 
1813
+ /**
1814
+ * Modifies the placement by translating the floating element along the
1815
+ * specified axes.
1816
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1817
+ * object may be passed.
1818
+ * @see https://floating-ui.com/docs/offset
1819
+ */
1820
+ const offset = offset$1;
1821
+
1822
+ /**
1823
+ * Optimizes the visibility of the floating element by choosing the placement
1824
+ * that has the most space available automatically, without needing to specify a
1825
+ * preferred placement. Alternative to `flip`.
1826
+ * @see https://floating-ui.com/docs/autoPlacement
1827
+ */
1828
+ const autoPlacement = autoPlacement$1;
1829
+
1830
+ /**
1831
+ * Optimizes the visibility of the floating element by flipping the `placement`
1832
+ * in order to keep it in view when the preferred placement(s) will overflow the
1833
+ * clipping boundary. Alternative to `autoPlacement`.
1834
+ * @see https://floating-ui.com/docs/flip
1835
+ */
1836
+ const flip = flip$1;
1837
+
1838
+ /**
1839
+ * Provides data that allows you to change the size of the floating element —
1840
+ * for instance, prevent it from overflowing the clipping boundary or match the
1841
+ * width of the reference element.
1842
+ * @see https://floating-ui.com/docs/size
1843
+ */
1844
+ const size = size$1;
1845
+
1846
+ /**
1847
+ * Provides data to hide the floating element in applicable situations, such as
1848
+ * when it is not in the same clipping context as the reference element.
1849
+ * @see https://floating-ui.com/docs/hide
1850
+ */
1851
+ const hide = hide$1;
1852
+
1853
+ /**
1854
+ * Provides data to position an inner element of the floating element so that it
1855
+ * appears centered to the reference element.
1856
+ * @see https://floating-ui.com/docs/arrow
1857
+ */
1858
+ const arrow = arrow$1;
1859
+
1860
+ /**
1861
+ * Provides improved positioning for inline reference elements that can span
1862
+ * over multiple lines, such as hyperlinks or range selections.
1863
+ * @see https://floating-ui.com/docs/inline
1864
+ */
1865
+ const inline = inline$1;
1866
+
1703
1867
  /**
1704
1868
  * 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.
1869
+ * next to a given reference element.
1707
1870
  */
1708
1871
  const computePosition = (reference, floating, options) => {
1709
1872
  // This caches the expensive `getClippingElementAncestors` function so that
@@ -1933,7 +2096,7 @@ const getClasses = ({ open, dismissible, alternate }) => classNames.classNames(
1933
2096
  );
1934
2097
  const popupTemplate = (context) => {
1935
2098
  const elevationTag = context.tagFor(definition.Elevation);
1936
- const buttonTag = context.tagFor(definition$1.Button);
2099
+ const buttonTag = context.tagFor(definition$1.Button$1);
1937
2100
  return index.html`
1938
2101
  <${elevationTag}>
1939
2102
  <div class="popup-wrapper ${(x) => x.strategy}" ${ref.ref(