@vonage/vivid 4.2.0 → 4.4.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 (155) hide show
  1. package/appearance-ui/index.cjs +1 -2
  2. package/appearance-ui/index.js +1 -2
  3. package/custom-elements.json +435 -41
  4. package/index.cjs +1 -0
  5. package/index.js +1 -1
  6. package/lib/button/button.d.ts +1 -0
  7. package/lib/dialog/dialog.d.ts +1 -0
  8. package/lib/empty-state/definition.d.ts +1 -0
  9. package/lib/empty-state/empty-state.d.ts +5 -0
  10. package/lib/enums.d.ts +4 -0
  11. package/lib/popup/popup.d.ts +5 -0
  12. package/lib/range-slider/range-slider.d.ts +2 -0
  13. package/lib/slider/slider.d.ts +5 -0
  14. package/lib/slider/slider.template.d.ts +2 -2
  15. package/lib/switch/switch.d.ts +1 -1
  16. package/package.json +1 -1
  17. package/shared/affix.cjs +1 -2
  18. package/shared/affix.js +1 -2
  19. package/shared/anchored.cjs +1 -2
  20. package/shared/anchored.js +1 -2
  21. package/shared/calendar-event.cjs +1 -2
  22. package/shared/calendar-event.js +1 -2
  23. package/shared/definition.cjs +2 -3
  24. package/shared/definition.js +2 -3
  25. package/shared/definition11.cjs +29 -13
  26. package/shared/definition11.js +29 -14
  27. package/shared/definition12.cjs +1 -1
  28. package/shared/definition12.js +1 -1
  29. package/shared/definition13.cjs +1 -2
  30. package/shared/definition13.js +1 -2
  31. package/shared/definition14.cjs +1 -2
  32. package/shared/definition14.js +1 -2
  33. package/shared/definition15.cjs +1 -2
  34. package/shared/definition15.js +1 -2
  35. package/shared/definition16.cjs +1 -2
  36. package/shared/definition16.js +1 -2
  37. package/shared/definition17.cjs +4 -8
  38. package/shared/definition17.js +4 -8
  39. package/shared/definition18.cjs +14 -22
  40. package/shared/definition18.js +14 -22
  41. package/shared/definition19.cjs +29 -50
  42. package/shared/definition19.js +29 -50
  43. package/shared/definition20.cjs +1 -2
  44. package/shared/definition20.js +1 -2
  45. package/shared/definition21.cjs +68 -32
  46. package/shared/definition21.js +68 -32
  47. package/shared/definition23.cjs +19 -5
  48. package/shared/definition23.js +20 -6
  49. package/shared/definition24.cjs +2 -3
  50. package/shared/definition24.js +2 -3
  51. package/shared/definition25.cjs +23 -48
  52. package/shared/definition25.js +23 -48
  53. package/shared/definition26.cjs +1 -2
  54. package/shared/definition26.js +1 -2
  55. package/shared/definition28.cjs +1 -2
  56. package/shared/definition28.js +1 -2
  57. package/shared/definition29.cjs +19 -39
  58. package/shared/definition29.js +19 -39
  59. package/shared/definition3.cjs +1 -2
  60. package/shared/definition3.js +1 -2
  61. package/shared/definition30.cjs +1 -1
  62. package/shared/definition30.js +1 -1
  63. package/shared/definition31.cjs +1 -2
  64. package/shared/definition31.js +1 -2
  65. package/shared/definition34.cjs +1 -2
  66. package/shared/definition34.js +1 -2
  67. package/shared/definition35.cjs +14 -26
  68. package/shared/definition35.js +14 -26
  69. package/shared/definition36.cjs +1 -2
  70. package/shared/definition36.js +1 -2
  71. package/shared/definition37.cjs +8 -16
  72. package/shared/definition37.js +8 -16
  73. package/shared/definition38.cjs +1 -2
  74. package/shared/definition38.js +1 -2
  75. package/shared/definition39.cjs +1 -2
  76. package/shared/definition39.js +1 -2
  77. package/shared/definition4.cjs +7 -13
  78. package/shared/definition4.js +7 -13
  79. package/shared/definition40.cjs +1 -2
  80. package/shared/definition40.js +1 -2
  81. package/shared/definition42.cjs +172 -106
  82. package/shared/definition42.js +172 -106
  83. package/shared/definition43.cjs +7 -6
  84. package/shared/definition43.js +5 -4
  85. package/shared/definition44.cjs +4 -8
  86. package/shared/definition44.js +4 -8
  87. package/shared/definition45.cjs +1 -2
  88. package/shared/definition45.js +1 -2
  89. package/shared/definition46.cjs +96 -12
  90. package/shared/definition46.js +97 -13
  91. package/shared/definition47.cjs +1 -2
  92. package/shared/definition47.js +1 -2
  93. package/shared/definition48.cjs +2 -3
  94. package/shared/definition48.js +2 -3
  95. package/shared/definition5.cjs +1 -2
  96. package/shared/definition5.js +1 -2
  97. package/shared/definition50.cjs +1 -2
  98. package/shared/definition50.js +1 -2
  99. package/shared/definition51.cjs +5 -10
  100. package/shared/definition51.js +5 -10
  101. package/shared/definition52.cjs +1 -2
  102. package/shared/definition52.js +1 -2
  103. package/shared/definition53.cjs +1 -2
  104. package/shared/definition53.js +1 -2
  105. package/shared/definition54.cjs +9 -21
  106. package/shared/definition54.js +9 -21
  107. package/shared/definition55.cjs +24 -43
  108. package/shared/definition55.js +24 -43
  109. package/shared/definition56.cjs +24 -39
  110. package/shared/definition56.js +24 -39
  111. package/shared/definition57.cjs +22 -45
  112. package/shared/definition57.js +22 -45
  113. package/shared/definition58.cjs +18 -37
  114. package/shared/definition58.js +18 -37
  115. package/shared/definition59.cjs +1 -2
  116. package/shared/definition59.js +1 -2
  117. package/shared/definition6.cjs +1 -2
  118. package/shared/definition6.js +1 -2
  119. package/shared/definition62.cjs +1 -2
  120. package/shared/definition62.js +1 -2
  121. package/shared/definition63.cjs +156 -4
  122. package/shared/definition63.js +157 -6
  123. package/shared/definition7.cjs +1 -2
  124. package/shared/definition7.js +1 -2
  125. package/shared/definition8.cjs +1 -2
  126. package/shared/definition8.js +1 -2
  127. package/shared/definition9.cjs +1 -2
  128. package/shared/definition9.js +1 -2
  129. package/shared/enums.cjs +6 -0
  130. package/shared/enums.js +6 -1
  131. package/shared/icon.cjs +2 -3
  132. package/shared/icon.js +2 -3
  133. package/shared/index2.cjs +3 -6
  134. package/shared/index2.js +3 -6
  135. package/shared/listbox.cjs +1 -2
  136. package/shared/listbox.js +1 -2
  137. package/shared/patterns/anchored.d.ts +4 -4
  138. package/shared/patterns/chevron.d.ts +2 -0
  139. package/shared/presentationDate.cjs +2 -3
  140. package/shared/presentationDate.js +2 -3
  141. package/shared/radio.cjs +1 -2
  142. package/shared/radio.js +1 -2
  143. package/shared/slider.template.cjs +27 -4
  144. package/shared/slider.template.js +27 -4
  145. package/shared/text-anchor.cjs +1 -2
  146. package/shared/text-anchor.js +1 -2
  147. package/shared/video-player.cjs +4 -8
  148. package/shared/video-player.js +4 -8
  149. package/styles/core/all.css +1 -1
  150. package/styles/core/theme.css +1 -1
  151. package/styles/core/typography.css +1 -1
  152. package/styles/tokens/theme-dark.css +4 -4
  153. package/styles/tokens/theme-light.css +4 -4
  154. package/styles/tokens/vivid-2-compat.css +1 -1
  155. package/vivid.api.json +3228 -1108
@@ -9,39 +9,26 @@ const styles = ":host{display:var(--_popup-display, inline)}:host([slotted-ancho
9
9
 
10
10
  var __defProp = Object.defineProperty;
11
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __typeError = (msg) => {
13
+ throw TypeError(msg);
14
+ };
12
15
  var __decorateClass = (decorators, target, key, kind) => {
13
16
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
14
17
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
15
18
  if (decorator = decorators[i])
16
19
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
17
- if (kind && result)
18
- __defProp(target, key, result);
20
+ if (kind && result) __defProp(target, key, result);
19
21
  return result;
20
22
  };
21
- var __accessCheck = (obj, member, msg) => {
22
- if (!member.has(obj))
23
- throw TypeError("Cannot " + msg);
24
- };
25
- var __privateGet = (obj, member, getter) => {
26
- __accessCheck(obj, member, "read from private field");
27
- return getter ? getter.call(obj) : member.get(obj);
28
- };
29
- var __privateAdd = (obj, member, value) => {
30
- if (member.has(obj))
31
- throw TypeError("Cannot add the same private member more than once");
32
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
33
- };
34
- var __privateMethod = (obj, member, method) => {
35
- __accessCheck(obj, member, "access private method");
36
- return method;
37
- };
38
- var _setupAnchor, setupAnchor_fn, _cleanupAnchor, cleanupAnchor_fn, _show, _hide, _updateListeners, updateListeners_fn, _closeOnEscape;
23
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
24
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
25
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
26
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
27
+ var _Tooltip_instances, setupAnchor_fn, cleanupAnchor_fn, _show, _hide, updateListeners_fn, _closeOnEscape;
39
28
  let Tooltip = class extends index.FoundationElement {
40
29
  constructor() {
41
30
  super(...arguments);
42
- __privateAdd(this, _setupAnchor);
43
- __privateAdd(this, _cleanupAnchor);
44
- __privateAdd(this, _updateListeners);
31
+ __privateAdd(this, _Tooltip_instances);
45
32
  this.open = false;
46
33
  __privateAdd(this, _show, () => {
47
34
  this.open = true;
@@ -50,44 +37,39 @@ let Tooltip = class extends index.FoundationElement {
50
37
  this.open = false;
51
38
  });
52
39
  __privateAdd(this, _closeOnEscape, (e) => {
53
- if (e.key === "Escape")
54
- __privateGet(this, _hide).call(this);
40
+ if (e.key === "Escape") __privateGet(this, _hide).call(this);
55
41
  });
56
42
  }
57
43
  connectedCallback() {
58
44
  super.connectedCallback();
59
- __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
45
+ __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
60
46
  }
61
47
  disconnectedCallback() {
62
48
  super.disconnectedCallback();
63
- __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
49
+ __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
64
50
  }
65
51
  /**
66
52
  * @internal
67
53
  */
68
54
  _anchorElChanged(oldValue, newValue) {
69
- if (oldValue)
70
- __privateMethod(this, _cleanupAnchor, cleanupAnchor_fn).call(this, oldValue);
71
- if (newValue)
72
- __privateMethod(this, _setupAnchor, setupAnchor_fn).call(this, newValue);
55
+ if (oldValue) __privateMethod(this, _Tooltip_instances, cleanupAnchor_fn).call(this, oldValue);
56
+ if (newValue) __privateMethod(this, _Tooltip_instances, setupAnchor_fn).call(this, newValue);
73
57
  }
74
58
  /**
75
59
  * @internal
76
60
  */
77
61
  openChanged(oldValue) {
78
- if (oldValue === void 0)
79
- return;
80
- __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
62
+ if (oldValue === void 0) return;
63
+ __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
81
64
  }
82
65
  };
83
- _setupAnchor = new WeakSet();
66
+ _Tooltip_instances = new WeakSet();
84
67
  setupAnchor_fn = function(a) {
85
68
  a.addEventListener("mouseover", __privateGet(this, _show));
86
69
  a.addEventListener("mouseout", __privateGet(this, _hide));
87
70
  a.addEventListener("focusin", __privateGet(this, _show));
88
71
  a.addEventListener("focusout", __privateGet(this, _hide));
89
72
  };
90
- _cleanupAnchor = new WeakSet();
91
73
  cleanupAnchor_fn = function(a) {
92
74
  a.removeEventListener("mouseover", __privateGet(this, _show));
93
75
  a.removeEventListener("mouseout", __privateGet(this, _hide));
@@ -96,7 +78,6 @@ cleanupAnchor_fn = function(a) {
96
78
  };
97
79
  _show = new WeakMap();
98
80
  _hide = new WeakMap();
99
- _updateListeners = new WeakSet();
100
81
  updateListeners_fn = function() {
101
82
  document.removeEventListener("keydown", __privateGet(this, _closeOnEscape));
102
83
  if (this.open && this.isConnected) {
@@ -7,39 +7,26 @@ const styles = ":host{display:var(--_popup-display, inline)}:host([slotted-ancho
7
7
 
8
8
  var __defProp = Object.defineProperty;
9
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __typeError = (msg) => {
11
+ throw TypeError(msg);
12
+ };
10
13
  var __decorateClass = (decorators, target, key, kind) => {
11
14
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
12
15
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
13
16
  if (decorator = decorators[i])
14
17
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
15
- if (kind && result)
16
- __defProp(target, key, result);
18
+ if (kind && result) __defProp(target, key, result);
17
19
  return result;
18
20
  };
19
- var __accessCheck = (obj, member, msg) => {
20
- if (!member.has(obj))
21
- throw TypeError("Cannot " + msg);
22
- };
23
- var __privateGet = (obj, member, getter) => {
24
- __accessCheck(obj, member, "read from private field");
25
- return getter ? getter.call(obj) : member.get(obj);
26
- };
27
- var __privateAdd = (obj, member, value) => {
28
- if (member.has(obj))
29
- throw TypeError("Cannot add the same private member more than once");
30
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
31
- };
32
- var __privateMethod = (obj, member, method) => {
33
- __accessCheck(obj, member, "access private method");
34
- return method;
35
- };
36
- var _setupAnchor, setupAnchor_fn, _cleanupAnchor, cleanupAnchor_fn, _show, _hide, _updateListeners, updateListeners_fn, _closeOnEscape;
21
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
22
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
23
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
24
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
25
+ var _Tooltip_instances, setupAnchor_fn, cleanupAnchor_fn, _show, _hide, updateListeners_fn, _closeOnEscape;
37
26
  let Tooltip = class extends FoundationElement {
38
27
  constructor() {
39
28
  super(...arguments);
40
- __privateAdd(this, _setupAnchor);
41
- __privateAdd(this, _cleanupAnchor);
42
- __privateAdd(this, _updateListeners);
29
+ __privateAdd(this, _Tooltip_instances);
43
30
  this.open = false;
44
31
  __privateAdd(this, _show, () => {
45
32
  this.open = true;
@@ -48,44 +35,39 @@ let Tooltip = class extends FoundationElement {
48
35
  this.open = false;
49
36
  });
50
37
  __privateAdd(this, _closeOnEscape, (e) => {
51
- if (e.key === "Escape")
52
- __privateGet(this, _hide).call(this);
38
+ if (e.key === "Escape") __privateGet(this, _hide).call(this);
53
39
  });
54
40
  }
55
41
  connectedCallback() {
56
42
  super.connectedCallback();
57
- __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
43
+ __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
58
44
  }
59
45
  disconnectedCallback() {
60
46
  super.disconnectedCallback();
61
- __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
47
+ __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
62
48
  }
63
49
  /**
64
50
  * @internal
65
51
  */
66
52
  _anchorElChanged(oldValue, newValue) {
67
- if (oldValue)
68
- __privateMethod(this, _cleanupAnchor, cleanupAnchor_fn).call(this, oldValue);
69
- if (newValue)
70
- __privateMethod(this, _setupAnchor, setupAnchor_fn).call(this, newValue);
53
+ if (oldValue) __privateMethod(this, _Tooltip_instances, cleanupAnchor_fn).call(this, oldValue);
54
+ if (newValue) __privateMethod(this, _Tooltip_instances, setupAnchor_fn).call(this, newValue);
71
55
  }
72
56
  /**
73
57
  * @internal
74
58
  */
75
59
  openChanged(oldValue) {
76
- if (oldValue === void 0)
77
- return;
78
- __privateMethod(this, _updateListeners, updateListeners_fn).call(this);
60
+ if (oldValue === void 0) return;
61
+ __privateMethod(this, _Tooltip_instances, updateListeners_fn).call(this);
79
62
  }
80
63
  };
81
- _setupAnchor = new WeakSet();
64
+ _Tooltip_instances = new WeakSet();
82
65
  setupAnchor_fn = function(a) {
83
66
  a.addEventListener("mouseover", __privateGet(this, _show));
84
67
  a.addEventListener("mouseout", __privateGet(this, _hide));
85
68
  a.addEventListener("focusin", __privateGet(this, _show));
86
69
  a.addEventListener("focusout", __privateGet(this, _hide));
87
70
  };
88
- _cleanupAnchor = new WeakSet();
89
71
  cleanupAnchor_fn = function(a) {
90
72
  a.removeEventListener("mouseover", __privateGet(this, _show));
91
73
  a.removeEventListener("mouseout", __privateGet(this, _hide));
@@ -94,7 +76,6 @@ cleanupAnchor_fn = function(a) {
94
76
  };
95
77
  _show = new WeakMap();
96
78
  _hide = new WeakMap();
97
- _updateListeners = new WeakSet();
98
79
  updateListeners_fn = function() {
99
80
  document.removeEventListener("keydown", __privateGet(this, _closeOnEscape));
100
81
  if (this.open && this.isConnected) {
@@ -20,8 +20,7 @@ var __decorateClass = (decorators, target, key, kind) => {
20
20
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
21
21
  if (decorator = decorators[i])
22
22
  result = (decorator(target, key, result) ) || result;
23
- if (result)
24
- __defProp(target, key, result);
23
+ if (result) __defProp(target, key, result);
25
24
  return result;
26
25
  };
27
26
  class TreeItem extends treeItem.TreeItem {
@@ -18,8 +18,7 @@ var __decorateClass = (decorators, target, key, kind) => {
18
18
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
19
19
  if (decorator = decorators[i])
20
20
  result = (decorator(target, key, result) ) || result;
21
- if (result)
22
- __defProp(target, key, result);
21
+ if (result) __defProp(target, key, result);
23
22
  return result;
24
23
  };
25
24
  class TreeItem extends TreeItem$1 {
@@ -14,8 +14,7 @@ var __decorateClass = (decorators, target, key, kind) => {
14
14
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
15
15
  if (decorator = decorators[i])
16
16
  result = (decorator(target, key, result) ) || result;
17
- if (result)
18
- __defProp(target, key, result);
17
+ if (result) __defProp(target, key, result);
19
18
  return result;
20
19
  };
21
20
  class Avatar extends index.FoundationElement {
@@ -12,8 +12,7 @@ var __decorateClass = (decorators, target, key, kind) => {
12
12
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
13
13
  if (decorator = decorators[i])
14
14
  result = (decorator(target, key, result) ) || result;
15
- if (result)
16
- __defProp(target, key, result);
15
+ if (result) __defProp(target, key, result);
17
16
  return result;
18
17
  };
19
18
  class Avatar extends FoundationElement {
@@ -9,8 +9,7 @@ var __decorateClass = (decorators, target, key, kind) => {
9
9
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
10
10
  if (decorator = decorators[i])
11
11
  result = (decorator(target, key, result) ) || result;
12
- if (result)
13
- __defProp(target, key, result);
12
+ if (result) __defProp(target, key, result);
14
13
  return result;
15
14
  };
16
15
  class Elevation extends index.FoundationElement {
@@ -7,8 +7,7 @@ var __decorateClass = (decorators, target, key, kind) => {
7
7
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
8
8
  if (decorator = decorators[i])
9
9
  result = (decorator(target, key, result) ) || result;
10
- if (result)
11
- __defProp(target, key, result);
10
+ if (result) __defProp(target, key, result);
12
11
  return result;
13
12
  };
14
13
  class Elevation extends FoundationElement {
@@ -8,6 +8,8 @@ const when = require('./when.cjs');
8
8
  const classNames = require('./class-names.cjs');
9
9
 
10
10
  const sides = ['top', 'right', 'bottom', 'left'];
11
+ const alignments = ['start', 'end'];
12
+ const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
11
13
  const min = Math.min;
12
14
  const max = Math.max;
13
15
  const round = Math.round;
@@ -421,6 +423,109 @@ const arrow = options => ({
421
423
  }
422
424
  });
423
425
 
426
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
427
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
428
+ return allowedPlacementsSortedByAlignment.filter(placement => {
429
+ if (alignment) {
430
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
431
+ }
432
+ return true;
433
+ });
434
+ }
435
+ /**
436
+ * Optimizes the visibility of the floating element by choosing the placement
437
+ * that has the most space available automatically, without needing to specify a
438
+ * preferred placement. Alternative to `flip`.
439
+ * @see https://floating-ui.com/docs/autoPlacement
440
+ */
441
+ const autoPlacement = function (options) {
442
+ if (options === void 0) {
443
+ options = {};
444
+ }
445
+ return {
446
+ name: 'autoPlacement',
447
+ options,
448
+ async fn(state) {
449
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
450
+ const {
451
+ rects,
452
+ middlewareData,
453
+ placement,
454
+ platform,
455
+ elements
456
+ } = state;
457
+ const {
458
+ crossAxis = false,
459
+ alignment,
460
+ allowedPlacements = placements,
461
+ autoAlignment = true,
462
+ ...detectOverflowOptions
463
+ } = evaluate(options, state);
464
+ const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
465
+ const overflow = await detectOverflow(state, detectOverflowOptions);
466
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
467
+ const currentPlacement = placements$1[currentIndex];
468
+ if (currentPlacement == null) {
469
+ return {};
470
+ }
471
+ const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
472
+
473
+ // Make `computeCoords` start from the right place.
474
+ if (placement !== currentPlacement) {
475
+ return {
476
+ reset: {
477
+ placement: placements$1[0]
478
+ }
479
+ };
480
+ }
481
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
482
+ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
483
+ placement: currentPlacement,
484
+ overflows: currentOverflows
485
+ }];
486
+ const nextPlacement = placements$1[currentIndex + 1];
487
+
488
+ // There are more placements to check.
489
+ if (nextPlacement) {
490
+ return {
491
+ data: {
492
+ index: currentIndex + 1,
493
+ overflows: allOverflows
494
+ },
495
+ reset: {
496
+ placement: nextPlacement
497
+ }
498
+ };
499
+ }
500
+ const placementsSortedByMostSpace = allOverflows.map(d => {
501
+ const alignment = getAlignment(d.placement);
502
+ return [d.placement, alignment && crossAxis ?
503
+ // Check along the mainAxis and main crossAxis side.
504
+ d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
505
+ // Check only the mainAxis.
506
+ d.overflows[0], d.overflows];
507
+ }).sort((a, b) => a[1] - b[1]);
508
+ const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
509
+ // Aligned placements should not check their opposite crossAxis
510
+ // side.
511
+ getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
512
+ const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
513
+ if (resetPlacement !== placement) {
514
+ return {
515
+ data: {
516
+ index: currentIndex + 1,
517
+ overflows: allOverflows
518
+ },
519
+ reset: {
520
+ placement: resetPlacement
521
+ }
522
+ };
523
+ }
524
+ return {};
525
+ }
526
+ };
527
+ };
528
+
424
529
  /**
425
530
  * Optimizes the visibility of the floating element by flipping the `placement`
426
531
  * in order to keep it in view when the preferred placement(s) will overflow the
@@ -1625,10 +1730,37 @@ var __decorateClass = (decorators, target, key, kind) => {
1625
1730
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
1626
1731
  if (decorator = decorators[i])
1627
1732
  result = (decorator(target, key, result) ) || result;
1628
- if (result)
1629
- __defProp(target, key, result);
1733
+ if (result) __defProp(target, key, result);
1630
1734
  return result;
1631
1735
  };
1736
+ const PlacementStrategy = {
1737
+ Flip: "flip",
1738
+ AutoPlacementHorizontal: "auto-placement-horizontal",
1739
+ AutoPlacementVertical: "auto-placement-vertical"
1740
+ };
1741
+ const placementStrategyMiddlewares = {
1742
+ [PlacementStrategy.Flip]: flip(),
1743
+ [PlacementStrategy.AutoPlacementHorizontal]: autoPlacement({
1744
+ allowedPlacements: [
1745
+ "bottom",
1746
+ "top",
1747
+ "bottom-start",
1748
+ "bottom-end",
1749
+ "top-start",
1750
+ "top-end"
1751
+ ]
1752
+ }),
1753
+ [PlacementStrategy.AutoPlacementVertical]: autoPlacement({
1754
+ allowedPlacements: [
1755
+ "left",
1756
+ "right",
1757
+ "left-start",
1758
+ "left-end",
1759
+ "right-start",
1760
+ "right-end"
1761
+ ]
1762
+ })
1763
+ };
1632
1764
  class Popup extends index.FoundationElement {
1633
1765
  constructor() {
1634
1766
  super(...arguments);
@@ -1636,12 +1768,19 @@ class Popup extends index.FoundationElement {
1636
1768
  this.dismissible = false;
1637
1769
  this.arrow = false;
1638
1770
  this.alternate = false;
1771
+ /**
1772
+ * The placement strategy of the popup.
1773
+ *
1774
+ * @public
1775
+ */
1776
+ this.placementStrategy = PlacementStrategy.Flip;
1777
+ this.animationFrame = false;
1639
1778
  this.strategy = "fixed";
1640
1779
  }
1641
1780
  get #middleware() {
1642
1781
  let middleware = [
1643
1782
  inline(),
1644
- flip(),
1783
+ placementStrategyMiddlewares[this.placementStrategy],
1645
1784
  hide(),
1646
1785
  size({
1647
1786
  apply({ availableWidth, availableHeight, elements }) {
@@ -1664,6 +1803,12 @@ class Popup extends index.FoundationElement {
1664
1803
  #cleanup;
1665
1804
  openChanged(_, newValue) {
1666
1805
  newValue ? this.$emit("vwc-popup:open") : this.$emit("vwc-popup:close");
1806
+ index.DOM.queueUpdate(() => this.#updateAutoUpdate());
1807
+ }
1808
+ /**
1809
+ * @internal
1810
+ */
1811
+ animationFrameChanged() {
1667
1812
  this.#updateAutoUpdate();
1668
1813
  }
1669
1814
  /**
@@ -1686,7 +1831,10 @@ class Popup extends index.FoundationElement {
1686
1831
  this.#cleanup = autoUpdate(
1687
1832
  this.anchorEl,
1688
1833
  this.popupEl,
1689
- () => this.updatePosition()
1834
+ () => this.updatePosition(),
1835
+ {
1836
+ animationFrame: this.animationFrame
1837
+ }
1690
1838
  );
1691
1839
  }
1692
1840
  }
@@ -1765,6 +1913,9 @@ __decorateClass([
1765
1913
  __decorateClass([
1766
1914
  index.attr({ mode: "fromView" })
1767
1915
  ], Popup.prototype, "placement");
1916
+ __decorateClass([
1917
+ index.attr({ mode: "boolean", attribute: "animation-frame" })
1918
+ ], Popup.prototype, "animationFrame");
1768
1919
  __decorateClass([
1769
1920
  index.attr({ mode: "fromView" })
1770
1921
  ], Popup.prototype, "strategy");
@@ -1819,6 +1970,7 @@ const popupRegistries = [
1819
1970
  ];
1820
1971
  const registerPopup = index.registerFactory(popupRegistries);
1821
1972
 
1973
+ exports.PlacementStrategy = PlacementStrategy;
1822
1974
  exports.Popup = Popup;
1823
1975
  exports.popupRegistries = popupRegistries;
1824
1976
  exports.registerPopup = registerPopup;