@aurodesignsystem-dev/auro-formkit 0.0.0-pr1413.2 → 0.0.0-pr1419.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 (231) hide show
  1. package/package.json +32 -31
  2. package/components/bibtemplate/dist/auro-bibtemplate.d.ts +0 -66
  3. package/components/bibtemplate/dist/buttonVersion.d.ts +0 -2
  4. package/components/bibtemplate/dist/headerVersion.d.ts +0 -2
  5. package/components/bibtemplate/dist/iconVersion.d.ts +0 -2
  6. package/components/bibtemplate/dist/index.d.ts +0 -2
  7. package/components/bibtemplate/dist/index.js +0 -395
  8. package/components/bibtemplate/dist/registered.js +0 -395
  9. package/components/bibtemplate/dist/styles/color-css.d.ts +0 -2
  10. package/components/bibtemplate/dist/styles/style-css.d.ts +0 -2
  11. package/components/bibtemplate/dist/styles/tokens-css.d.ts +0 -2
  12. package/components/checkbox/demo/api.md +0 -489
  13. package/components/checkbox/demo/api.min.js +0 -2133
  14. package/components/checkbox/demo/index.md +0 -55
  15. package/components/checkbox/demo/index.min.js +0 -2108
  16. package/components/checkbox/demo/keyboardBehavior.md +0 -0
  17. package/components/checkbox/demo/readme.md +0 -142
  18. package/components/checkbox/dist/auro-checkbox-group.d.ts +0 -176
  19. package/components/checkbox/dist/auro-checkbox.d.ts +0 -209
  20. package/components/checkbox/dist/index.d.ts +0 -3
  21. package/components/checkbox/dist/index.js +0 -2057
  22. package/components/checkbox/dist/registered.js +0 -2058
  23. package/components/checkbox/dist/styles/auro-checkbox-css.d.ts +0 -2
  24. package/components/checkbox/dist/styles/auro-checkbox-group-css.d.ts +0 -2
  25. package/components/checkbox/dist/styles/color-css.d.ts +0 -2
  26. package/components/checkbox/dist/styles/colorGroup-css.d.ts +0 -2
  27. package/components/checkbox/dist/styles/tokens-css.d.ts +0 -2
  28. package/components/combobox/demo/api.md +0 -2287
  29. package/components/combobox/demo/api.min.js +0 -17800
  30. package/components/combobox/demo/index.md +0 -196
  31. package/components/combobox/demo/index.min.js +0 -17705
  32. package/components/combobox/demo/keyboardBehavior.md +0 -281
  33. package/components/combobox/demo/readme.md +0 -158
  34. package/components/combobox/dist/auro-combobox.d.ts +0 -566
  35. package/components/combobox/dist/comboboxKeyboardStrategy.d.ts +0 -8
  36. package/components/combobox/dist/index.d.ts +0 -2
  37. package/components/combobox/dist/index.js +0 -15604
  38. package/components/combobox/dist/registered.js +0 -15606
  39. package/components/combobox/dist/styles/emphasized/style-css.d.ts +0 -2
  40. package/components/combobox/dist/styles/snowflake/style-css.d.ts +0 -2
  41. package/components/combobox/dist/styles/style-css.d.ts +0 -2
  42. package/components/counter/demo/api.md +0 -1285
  43. package/components/counter/demo/api.min.js +0 -8112
  44. package/components/counter/demo/index.md +0 -92
  45. package/components/counter/demo/index.min.js +0 -8093
  46. package/components/counter/demo/keyboardBehavior.md +0 -127
  47. package/components/counter/demo/readme.md +0 -161
  48. package/components/counter/dist/auro-counter-button.d.ts +0 -14
  49. package/components/counter/dist/auro-counter-group.d.ts +0 -390
  50. package/components/counter/dist/auro-counter-wrapper.d.ts +0 -17
  51. package/components/counter/dist/auro-counter.d.ts +0 -136
  52. package/components/counter/dist/buttonVersion.d.ts +0 -2
  53. package/components/counter/dist/iconVersion.d.ts +0 -2
  54. package/components/counter/dist/index.d.ts +0 -3
  55. package/components/counter/dist/index.js +0 -8015
  56. package/components/counter/dist/keyboardStrategy.d.ts +0 -4
  57. package/components/counter/dist/registered.js +0 -8016
  58. package/components/counter/dist/styles/color-css.d.ts +0 -2
  59. package/components/counter/dist/styles/counter-button-color-css.d.ts +0 -2
  60. package/components/counter/dist/styles/counter-button-css.d.ts +0 -2
  61. package/components/counter/dist/styles/counter-group-css.d.ts +0 -2
  62. package/components/counter/dist/styles/counter-wrapper-color-css.d.ts +0 -2
  63. package/components/counter/dist/styles/counter-wrapper-css.d.ts +0 -2
  64. package/components/counter/dist/styles/shapeSize-css.d.ts +0 -2
  65. package/components/counter/dist/styles/style-css.d.ts +0 -2
  66. package/components/counter/dist/styles/tokens-css.d.ts +0 -2
  67. package/components/datepicker/demo/api.md +0 -1824
  68. package/components/datepicker/demo/api.min.js +0 -24510
  69. package/components/datepicker/demo/index.md +0 -158
  70. package/components/datepicker/demo/index.min.js +0 -24231
  71. package/components/datepicker/demo/keyboardBehavior.md +0 -24
  72. package/components/datepicker/demo/readme.md +0 -137
  73. package/components/datepicker/dist/auro-calendar-cell.d.ts +0 -169
  74. package/components/datepicker/dist/auro-calendar-month.d.ts +0 -20
  75. package/components/datepicker/dist/auro-calendar.d.ts +0 -173
  76. package/components/datepicker/dist/auro-datepicker.d.ts +0 -715
  77. package/components/datepicker/dist/buttonVersion.d.ts +0 -2
  78. package/components/datepicker/dist/datepickerKeyboardStrategy.d.ts +0 -1
  79. package/components/datepicker/dist/iconVersion.d.ts +0 -2
  80. package/components/datepicker/dist/index.d.ts +0 -2
  81. package/components/datepicker/dist/index.js +0 -24146
  82. package/components/datepicker/dist/popoverVersion.d.ts +0 -2
  83. package/components/datepicker/dist/registered.js +0 -24146
  84. package/components/datepicker/dist/styles/classic/color-css.d.ts +0 -2
  85. package/components/datepicker/dist/styles/classic/style-css.d.ts +0 -2
  86. package/components/datepicker/dist/styles/color-calendar-css.d.ts +0 -2
  87. package/components/datepicker/dist/styles/color-cell-css.d.ts +0 -2
  88. package/components/datepicker/dist/styles/color-css.d.ts +0 -2
  89. package/components/datepicker/dist/styles/color-month-css.d.ts +0 -2
  90. package/components/datepicker/dist/styles/shapeSize-css.d.ts +0 -2
  91. package/components/datepicker/dist/styles/snowflake/color-css.d.ts +0 -2
  92. package/components/datepicker/dist/styles/snowflake/style-css.d.ts +0 -2
  93. package/components/datepicker/dist/styles/style-auro-calendar-cell-css.d.ts +0 -2
  94. package/components/datepicker/dist/styles/style-auro-calendar-css.d.ts +0 -2
  95. package/components/datepicker/dist/styles/style-auro-calendar-month-css.d.ts +0 -2
  96. package/components/datepicker/dist/styles/style-css.d.ts +0 -2
  97. package/components/datepicker/dist/styles/tokens-css.d.ts +0 -2
  98. package/components/datepicker/dist/utilities.d.ts +0 -78
  99. package/components/datepicker/dist/utilitiesCalendar.d.ts +0 -38
  100. package/components/datepicker/dist/utilitiesCalendarRender.d.ts +0 -50
  101. package/components/datepicker/dist/vendor/wc-range-datepicker/day.d.ts +0 -5
  102. package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker-calendar.d.ts +0 -60
  103. package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker-cell.d.ts +0 -1
  104. package/components/datepicker/dist/vendor/wc-range-datepicker/range-datepicker.d.ts +0 -57
  105. package/components/dropdown/demo/api.md +0 -1358
  106. package/components/dropdown/demo/api.min.js +0 -4894
  107. package/components/dropdown/demo/index.md +0 -283
  108. package/components/dropdown/demo/index.min.js +0 -4829
  109. package/components/dropdown/demo/keyboardBehavior.md +0 -77
  110. package/components/dropdown/demo/readme.md +0 -160
  111. package/components/dropdown/dist/auro-dropdown.d.ts +0 -482
  112. package/components/dropdown/dist/auro-dropdownBib.d.ts +0 -128
  113. package/components/dropdown/dist/dropdownBibKeyboardStrategy.d.ts +0 -7
  114. package/components/dropdown/dist/iconVersion.d.ts +0 -2
  115. package/components/dropdown/dist/index.d.ts +0 -2
  116. package/components/dropdown/dist/index.js +0 -4722
  117. package/components/dropdown/dist/registered.js +0 -4722
  118. package/components/dropdown/dist/styles/classic/bibColors-css.d.ts +0 -2
  119. package/components/dropdown/dist/styles/classic/bibStyles-css.d.ts +0 -2
  120. package/components/dropdown/dist/styles/classic/color-css.d.ts +0 -2
  121. package/components/dropdown/dist/styles/classic/style-css.d.ts +0 -2
  122. package/components/dropdown/dist/styles/color-css.d.ts +0 -2
  123. package/components/dropdown/dist/styles/emphasized/style-css.d.ts +0 -2
  124. package/components/dropdown/dist/styles/shapeSize-css.d.ts +0 -2
  125. package/components/dropdown/dist/styles/snowflake/style-css.d.ts +0 -2
  126. package/components/dropdown/dist/styles/style-css.d.ts +0 -2
  127. package/components/dropdown/dist/styles/tokens-css.d.ts +0 -2
  128. package/components/form/demo/api.md +0 -319
  129. package/components/form/demo/api.min.js +0 -70505
  130. package/components/form/demo/index.md +0 -128
  131. package/components/form/demo/index.min.js +0 -70505
  132. package/components/form/demo/keyboardBehavior.md +0 -0
  133. package/components/form/demo/readme.md +0 -145
  134. package/components/form/dist/auro-form.d.ts +0 -280
  135. package/components/form/dist/index.d.ts +0 -2
  136. package/components/form/dist/index.js +0 -718
  137. package/components/form/dist/registered.d.ts +0 -1
  138. package/components/form/dist/registered.js +0 -718
  139. package/components/form/dist/styles/style-css.d.ts +0 -2
  140. package/components/helptext/dist/auro-helptext.d.ts +0 -69
  141. package/components/helptext/dist/index.d.ts +0 -2
  142. package/components/helptext/dist/index.js +0 -231
  143. package/components/helptext/dist/registered.js +0 -231
  144. package/components/helptext/dist/styles/color-css.d.ts +0 -2
  145. package/components/helptext/dist/styles/style-css.d.ts +0 -2
  146. package/components/helptext/dist/styles/tokens-css.d.ts +0 -2
  147. package/components/input/demo/api.md +0 -1397
  148. package/components/input/demo/api.min.js +0 -7460
  149. package/components/input/demo/index.md +0 -161
  150. package/components/input/demo/index.min.js +0 -7380
  151. package/components/input/demo/keyboardBehavior.md +0 -0
  152. package/components/input/demo/readme.md +0 -134
  153. package/components/input/dist/auro-input.d.ts +0 -206
  154. package/components/input/dist/base-input.d.ts +0 -629
  155. package/components/input/dist/buttonVersion.d.ts +0 -2
  156. package/components/input/dist/i18n.d.ts +0 -18
  157. package/components/input/dist/iconVersion.d.ts +0 -2
  158. package/components/input/dist/index.d.ts +0 -2
  159. package/components/input/dist/index.js +0 -7292
  160. package/components/input/dist/registered.js +0 -7292
  161. package/components/input/dist/styles/classic/color-css.d.ts +0 -2
  162. package/components/input/dist/styles/classic/style-css.d.ts +0 -2
  163. package/components/input/dist/styles/color-css.d.ts +0 -2
  164. package/components/input/dist/styles/default/borders-css.d.ts +0 -2
  165. package/components/input/dist/styles/default/color-css.d.ts +0 -2
  166. package/components/input/dist/styles/default/mixins-css.d.ts +0 -2
  167. package/components/input/dist/styles/default/notificationIcons-css.d.ts +0 -2
  168. package/components/input/dist/styles/default/style-css.d.ts +0 -2
  169. package/components/input/dist/styles/emphasized/color-css.d.ts +0 -2
  170. package/components/input/dist/styles/emphasized/style-css.d.ts +0 -2
  171. package/components/input/dist/styles/mixins-css.d.ts +0 -2
  172. package/components/input/dist/styles/shapeSize-css.d.ts +0 -2
  173. package/components/input/dist/styles/snowflake/style-css.d.ts +0 -2
  174. package/components/input/dist/styles/style-css.d.ts +0 -2
  175. package/components/input/dist/styles/tokens-css.d.ts +0 -2
  176. package/components/input/dist/utilities.d.ts +0 -25
  177. package/components/layoutElement/dist/auroElement.d.ts +0 -40
  178. package/components/layoutElement/dist/index.d.ts +0 -2
  179. package/components/layoutElement/dist/index.js +0 -107
  180. package/components/layoutElement/dist/registered.js +0 -107
  181. package/components/menu/demo/api.md +0 -1200
  182. package/components/menu/demo/api.min.js +0 -2413
  183. package/components/menu/demo/index.md +0 -72
  184. package/components/menu/demo/index.min.js +0 -2306
  185. package/components/menu/demo/keyboardBehavior.md +0 -0
  186. package/components/menu/demo/readme.md +0 -145
  187. package/components/menu/dist/auro-menu-utils.d.ts +0 -34
  188. package/components/menu/dist/auro-menu.context.d.ts +0 -239
  189. package/components/menu/dist/auro-menu.d.ts +0 -316
  190. package/components/menu/dist/auro-menuoption.d.ts +0 -210
  191. package/components/menu/dist/iconVersion.d.ts +0 -2
  192. package/components/menu/dist/index.d.ts +0 -4
  193. package/components/menu/dist/index.js +0 -2269
  194. package/components/menu/dist/registered.js +0 -2217
  195. package/components/menu/dist/styles/default/color-menu-css.d.ts +0 -2
  196. package/components/menu/dist/styles/default/color-menuoption-css.d.ts +0 -2
  197. package/components/menu/dist/styles/default/style-menu-css.d.ts +0 -2
  198. package/components/menu/dist/styles/default/style-menuoption-css.d.ts +0 -2
  199. package/components/menu/dist/styles/default/tokens-css.d.ts +0 -2
  200. package/components/radio/demo/api.md +0 -675
  201. package/components/radio/demo/api.min.js +0 -2210
  202. package/components/radio/demo/index.md +0 -73
  203. package/components/radio/demo/index.min.js +0 -2167
  204. package/components/radio/demo/keyboardBehavior.md +0 -0
  205. package/components/radio/demo/readme.md +0 -141
  206. package/components/radio/dist/auro-radio-group.d.ts +0 -250
  207. package/components/radio/dist/auro-radio.d.ts +0 -180
  208. package/components/radio/dist/index.d.ts +0 -3
  209. package/components/radio/dist/index.js +0 -2116
  210. package/components/radio/dist/registered.js +0 -2117
  211. package/components/radio/dist/styles/auro-radio-group-css.d.ts +0 -2
  212. package/components/radio/dist/styles/color-css.d.ts +0 -2
  213. package/components/radio/dist/styles/groupColor-css.d.ts +0 -2
  214. package/components/radio/dist/styles/style-css.d.ts +0 -2
  215. package/components/radio/dist/styles/tokens-css.d.ts +0 -2
  216. package/components/select/demo/api.md +0 -2378
  217. package/components/select/demo/api.min.js +0 -10400
  218. package/components/select/demo/index.md +0 -355
  219. package/components/select/demo/index.min.js +0 -10307
  220. package/components/select/demo/keyboardBehavior.md +0 -246
  221. package/components/select/demo/readme.md +0 -148
  222. package/components/select/dist/auro-select.d.ts +0 -545
  223. package/components/select/dist/index.d.ts +0 -2
  224. package/components/select/dist/index.js +0 -8218
  225. package/components/select/dist/registered.js +0 -8218
  226. package/components/select/dist/selectKeyboardStrategy.d.ts +0 -11
  227. package/components/select/dist/styles/emphasized/color-css.d.ts +0 -2
  228. package/components/select/dist/styles/shapeSize-css.d.ts +0 -2
  229. package/components/select/dist/styles/style-css.d.ts +0 -2
  230. package/components/select/dist/styles/tokens-css.d.ts +0 -2
  231. package/custom-elements.json +0 -18768
@@ -1,4722 +0,0 @@
1
- import { unsafeStatic, literal, html as html$1 } from 'lit/static-html.js';
2
- import { classMap } from 'lit/directives/class-map.js';
3
- import { createRef, ref } from 'lit/directives/ref.js';
4
- import { css, html, LitElement } from 'lit';
5
- import { ifDefined } from 'lit/directives/if-defined.js';
6
- import 'lit-html';
7
- import 'lit-html/directives/unsafe-html.js';
8
-
9
- // Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
10
- // See LICENSE in the project root for license information.
11
-
12
- // ---------------------------------------------------------------------
13
-
14
- /* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
15
-
16
- let AuroLibraryRuntimeUtils$1 = class AuroLibraryRuntimeUtils {
17
-
18
- /* eslint-disable jsdoc/require-param */
19
-
20
- /**
21
- * This will register a new custom element with the browser.
22
- * @param {String} name - The name of the custom element.
23
- * @param {Object} componentClass - The class to register as a custom element.
24
- * @returns {void}
25
- */
26
- registerComponent(name, componentClass) {
27
- if (!customElements.get(name)) {
28
- customElements.define(name, class extends componentClass {});
29
- }
30
- }
31
-
32
- /**
33
- * Finds and returns the closest HTML Element based on a selector.
34
- * @returns {void}
35
- */
36
- closestElement(
37
- selector, // selector like in .closest()
38
- base = this, // extra functionality to skip a parent
39
- __Closest = (el, found = el && el.closest(selector)) =>
40
- !el || el === document || el === window
41
- ? null // standard .closest() returns null for non-found selectors also
42
- : found
43
- ? found // found a selector INside this element
44
- : __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
45
- ) {
46
- return __Closest(base);
47
- }
48
- /* eslint-enable jsdoc/require-param */
49
-
50
- /**
51
- * If the element passed is registered with a different tag name than what is passed in, the tag name is added as an attribute to the element.
52
- * @param {Object} elem - The element to check.
53
- * @param {String} tagName - The name of the Auro component to check for or add as an attribute.
54
- * @returns {void}
55
- */
56
- handleComponentTagRename(elem, tagName) {
57
- const tag = tagName.toLowerCase();
58
- const elemTag = elem.tagName.toLowerCase();
59
-
60
- if (elemTag !== tag) {
61
- elem.setAttribute(tag, true);
62
- }
63
- }
64
-
65
- /**
66
- * Validates if an element is a specific Auro component.
67
- * @param {Object} elem - The element to validate.
68
- * @param {String} tagName - The name of the Auro component to check against.
69
- * @returns {Boolean} - Returns true if the element is the specified Auro component.
70
- */
71
- elementMatch(elem, tagName) {
72
- const tag = tagName.toLowerCase();
73
- const elemTag = elem.tagName.toLowerCase();
74
-
75
- return elemTag === tag || elem.hasAttribute(tag);
76
- }
77
-
78
- /**
79
- * Gets the text content of a named slot.
80
- * @returns {String}
81
- * @private
82
- */
83
- getSlotText(elem, name) {
84
- const slot = elem.shadowRoot?.querySelector(`slot[name="${name}"]`);
85
- const nodes = slot?.assignedNodes({ flatten: true }) || [];
86
- const text = nodes.map(n => n.textContent?.trim()).join(' ').trim();
87
-
88
- return text || null;
89
- }
90
- };
91
-
92
- /**
93
- * Custom positioning reference element.
94
- * @see https://floating-ui.com/docs/virtual-elements
95
- */
96
-
97
- const sides = ['top', 'right', 'bottom', 'left'];
98
- const alignments = ['start', 'end'];
99
- const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
100
- const min = Math.min;
101
- const max = Math.max;
102
- const round = Math.round;
103
- const floor = Math.floor;
104
- const createCoords = v => ({
105
- x: v,
106
- y: v
107
- });
108
- const oppositeSideMap = {
109
- left: 'right',
110
- right: 'left',
111
- bottom: 'top',
112
- top: 'bottom'
113
- };
114
- const oppositeAlignmentMap = {
115
- start: 'end',
116
- end: 'start'
117
- };
118
- function clamp(start, value, end) {
119
- return max(start, min(value, end));
120
- }
121
- function evaluate(value, param) {
122
- return typeof value === 'function' ? value(param) : value;
123
- }
124
- function getSide(placement) {
125
- return placement.split('-')[0];
126
- }
127
- function getAlignment(placement) {
128
- return placement.split('-')[1];
129
- }
130
- function getOppositeAxis(axis) {
131
- return axis === 'x' ? 'y' : 'x';
132
- }
133
- function getAxisLength(axis) {
134
- return axis === 'y' ? 'height' : 'width';
135
- }
136
- const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
137
- function getSideAxis(placement) {
138
- return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
139
- }
140
- function getAlignmentAxis(placement) {
141
- return getOppositeAxis(getSideAxis(placement));
142
- }
143
- function getAlignmentSides(placement, rects, rtl) {
144
- if (rtl === void 0) {
145
- rtl = false;
146
- }
147
- const alignment = getAlignment(placement);
148
- const alignmentAxis = getAlignmentAxis(placement);
149
- const length = getAxisLength(alignmentAxis);
150
- let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
151
- if (rects.reference[length] > rects.floating[length]) {
152
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
153
- }
154
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
155
- }
156
- function getExpandedPlacements(placement) {
157
- const oppositePlacement = getOppositePlacement(placement);
158
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
159
- }
160
- function getOppositeAlignmentPlacement(placement) {
161
- return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
162
- }
163
- const lrPlacement = ['left', 'right'];
164
- const rlPlacement = ['right', 'left'];
165
- const tbPlacement = ['top', 'bottom'];
166
- const btPlacement = ['bottom', 'top'];
167
- function getSideList(side, isStart, rtl) {
168
- switch (side) {
169
- case 'top':
170
- case 'bottom':
171
- if (rtl) return isStart ? rlPlacement : lrPlacement;
172
- return isStart ? lrPlacement : rlPlacement;
173
- case 'left':
174
- case 'right':
175
- return isStart ? tbPlacement : btPlacement;
176
- default:
177
- return [];
178
- }
179
- }
180
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
181
- const alignment = getAlignment(placement);
182
- let list = getSideList(getSide(placement), direction === 'start', rtl);
183
- if (alignment) {
184
- list = list.map(side => side + "-" + alignment);
185
- if (flipAlignment) {
186
- list = list.concat(list.map(getOppositeAlignmentPlacement));
187
- }
188
- }
189
- return list;
190
- }
191
- function getOppositePlacement(placement) {
192
- return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
193
- }
194
- function expandPaddingObject(padding) {
195
- return {
196
- top: 0,
197
- right: 0,
198
- bottom: 0,
199
- left: 0,
200
- ...padding
201
- };
202
- }
203
- function getPaddingObject(padding) {
204
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
205
- top: padding,
206
- right: padding,
207
- bottom: padding,
208
- left: padding
209
- };
210
- }
211
- function rectToClientRect(rect) {
212
- const {
213
- x,
214
- y,
215
- width,
216
- height
217
- } = rect;
218
- return {
219
- width,
220
- height,
221
- top: y,
222
- left: x,
223
- right: x + width,
224
- bottom: y + height,
225
- x,
226
- y
227
- };
228
- }
229
-
230
- function computeCoordsFromPlacement(_ref, placement, rtl) {
231
- let {
232
- reference,
233
- floating
234
- } = _ref;
235
- const sideAxis = getSideAxis(placement);
236
- const alignmentAxis = getAlignmentAxis(placement);
237
- const alignLength = getAxisLength(alignmentAxis);
238
- const side = getSide(placement);
239
- const isVertical = sideAxis === 'y';
240
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
241
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
242
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
243
- let coords;
244
- switch (side) {
245
- case 'top':
246
- coords = {
247
- x: commonX,
248
- y: reference.y - floating.height
249
- };
250
- break;
251
- case 'bottom':
252
- coords = {
253
- x: commonX,
254
- y: reference.y + reference.height
255
- };
256
- break;
257
- case 'right':
258
- coords = {
259
- x: reference.x + reference.width,
260
- y: commonY
261
- };
262
- break;
263
- case 'left':
264
- coords = {
265
- x: reference.x - floating.width,
266
- y: commonY
267
- };
268
- break;
269
- default:
270
- coords = {
271
- x: reference.x,
272
- y: reference.y
273
- };
274
- }
275
- switch (getAlignment(placement)) {
276
- case 'start':
277
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
278
- break;
279
- case 'end':
280
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
281
- break;
282
- }
283
- return coords;
284
- }
285
-
286
- /**
287
- * Resolves with an object of overflow side offsets that determine how much the
288
- * element is overflowing a given clipping boundary on each side.
289
- * - positive = overflowing the boundary by that number of pixels
290
- * - negative = how many pixels left before it will overflow
291
- * - 0 = lies flush with the boundary
292
- * @see https://floating-ui.com/docs/detectOverflow
293
- */
294
- async function detectOverflow(state, options) {
295
- var _await$platform$isEle;
296
- if (options === void 0) {
297
- options = {};
298
- }
299
- const {
300
- x,
301
- y,
302
- platform,
303
- rects,
304
- elements,
305
- strategy
306
- } = state;
307
- const {
308
- boundary = 'clippingAncestors',
309
- rootBoundary = 'viewport',
310
- elementContext = 'floating',
311
- altBoundary = false,
312
- padding = 0
313
- } = evaluate(options, state);
314
- const paddingObject = getPaddingObject(padding);
315
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
316
- const element = elements[altBoundary ? altContext : elementContext];
317
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
318
- element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
319
- boundary,
320
- rootBoundary,
321
- strategy
322
- }));
323
- const rect = elementContext === 'floating' ? {
324
- x,
325
- y,
326
- width: rects.floating.width,
327
- height: rects.floating.height
328
- } : rects.reference;
329
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
330
- const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
331
- x: 1,
332
- y: 1
333
- } : {
334
- x: 1,
335
- y: 1
336
- };
337
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
338
- elements,
339
- rect,
340
- offsetParent,
341
- strategy
342
- }) : rect);
343
- return {
344
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
345
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
346
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
347
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
348
- };
349
- }
350
-
351
- /**
352
- * Computes the `x` and `y` coordinates that will place the floating element
353
- * next to a given reference element.
354
- *
355
- * This export does not have any `platform` interface logic. You will need to
356
- * write one for the platform you are using Floating UI with.
357
- */
358
- const computePosition$1 = async (reference, floating, config) => {
359
- const {
360
- placement = 'bottom',
361
- strategy = 'absolute',
362
- middleware = [],
363
- platform
364
- } = config;
365
- const validMiddleware = middleware.filter(Boolean);
366
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
367
- let rects = await platform.getElementRects({
368
- reference,
369
- floating,
370
- strategy
371
- });
372
- let {
373
- x,
374
- y
375
- } = computeCoordsFromPlacement(rects, placement, rtl);
376
- let statefulPlacement = placement;
377
- let middlewareData = {};
378
- let resetCount = 0;
379
- for (let i = 0; i < validMiddleware.length; i++) {
380
- var _platform$detectOverf;
381
- const {
382
- name,
383
- fn
384
- } = validMiddleware[i];
385
- const {
386
- x: nextX,
387
- y: nextY,
388
- data,
389
- reset
390
- } = await fn({
391
- x,
392
- y,
393
- initialPlacement: placement,
394
- placement: statefulPlacement,
395
- strategy,
396
- middlewareData,
397
- rects,
398
- platform: {
399
- ...platform,
400
- detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
401
- },
402
- elements: {
403
- reference,
404
- floating
405
- }
406
- });
407
- x = nextX != null ? nextX : x;
408
- y = nextY != null ? nextY : y;
409
- middlewareData = {
410
- ...middlewareData,
411
- [name]: {
412
- ...middlewareData[name],
413
- ...data
414
- }
415
- };
416
- if (reset && resetCount <= 50) {
417
- resetCount++;
418
- if (typeof reset === 'object') {
419
- if (reset.placement) {
420
- statefulPlacement = reset.placement;
421
- }
422
- if (reset.rects) {
423
- rects = reset.rects === true ? await platform.getElementRects({
424
- reference,
425
- floating,
426
- strategy
427
- }) : reset.rects;
428
- }
429
- ({
430
- x,
431
- y
432
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
433
- }
434
- i = -1;
435
- }
436
- }
437
- return {
438
- x,
439
- y,
440
- placement: statefulPlacement,
441
- strategy,
442
- middlewareData
443
- };
444
- };
445
-
446
- function getPlacementList(alignment, autoAlignment, allowedPlacements) {
447
- const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
448
- return allowedPlacementsSortedByAlignment.filter(placement => {
449
- if (alignment) {
450
- return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
451
- }
452
- return true;
453
- });
454
- }
455
- /**
456
- * Optimizes the visibility of the floating element by choosing the placement
457
- * that has the most space available automatically, without needing to specify a
458
- * preferred placement. Alternative to `flip`.
459
- * @see https://floating-ui.com/docs/autoPlacement
460
- */
461
- const autoPlacement$1 = function (options) {
462
- if (options === void 0) {
463
- options = {};
464
- }
465
- return {
466
- name: 'autoPlacement',
467
- options,
468
- async fn(state) {
469
- var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
470
- const {
471
- rects,
472
- middlewareData,
473
- placement,
474
- platform,
475
- elements
476
- } = state;
477
- const {
478
- crossAxis = false,
479
- alignment,
480
- allowedPlacements = placements,
481
- autoAlignment = true,
482
- ...detectOverflowOptions
483
- } = evaluate(options, state);
484
- const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
485
- const overflow = await platform.detectOverflow(state, detectOverflowOptions);
486
- const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
487
- const currentPlacement = placements$1[currentIndex];
488
- if (currentPlacement == null) {
489
- return {};
490
- }
491
- const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
492
-
493
- // Make `computeCoords` start from the right place.
494
- if (placement !== currentPlacement) {
495
- return {
496
- reset: {
497
- placement: placements$1[0]
498
- }
499
- };
500
- }
501
- const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
502
- const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
503
- placement: currentPlacement,
504
- overflows: currentOverflows
505
- }];
506
- const nextPlacement = placements$1[currentIndex + 1];
507
-
508
- // There are more placements to check.
509
- if (nextPlacement) {
510
- return {
511
- data: {
512
- index: currentIndex + 1,
513
- overflows: allOverflows
514
- },
515
- reset: {
516
- placement: nextPlacement
517
- }
518
- };
519
- }
520
- const placementsSortedByMostSpace = allOverflows.map(d => {
521
- const alignment = getAlignment(d.placement);
522
- return [d.placement, alignment && crossAxis ?
523
- // Check along the mainAxis and main crossAxis side.
524
- d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
525
- // Check only the mainAxis.
526
- d.overflows[0], d.overflows];
527
- }).sort((a, b) => a[1] - b[1]);
528
- const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
529
- // Aligned placements should not check their opposite crossAxis
530
- // side.
531
- getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
532
- const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
533
- if (resetPlacement !== placement) {
534
- return {
535
- data: {
536
- index: currentIndex + 1,
537
- overflows: allOverflows
538
- },
539
- reset: {
540
- placement: resetPlacement
541
- }
542
- };
543
- }
544
- return {};
545
- }
546
- };
547
- };
548
-
549
- /**
550
- * Optimizes the visibility of the floating element by flipping the `placement`
551
- * in order to keep it in view when the preferred placement(s) will overflow the
552
- * clipping boundary. Alternative to `autoPlacement`.
553
- * @see https://floating-ui.com/docs/flip
554
- */
555
- const flip$1 = function (options) {
556
- if (options === void 0) {
557
- options = {};
558
- }
559
- return {
560
- name: 'flip',
561
- options,
562
- async fn(state) {
563
- var _middlewareData$arrow, _middlewareData$flip;
564
- const {
565
- placement,
566
- middlewareData,
567
- rects,
568
- initialPlacement,
569
- platform,
570
- elements
571
- } = state;
572
- const {
573
- mainAxis: checkMainAxis = true,
574
- crossAxis: checkCrossAxis = true,
575
- fallbackPlacements: specifiedFallbackPlacements,
576
- fallbackStrategy = 'bestFit',
577
- fallbackAxisSideDirection = 'none',
578
- flipAlignment = true,
579
- ...detectOverflowOptions
580
- } = evaluate(options, state);
581
-
582
- // If a reset by the arrow was caused due to an alignment offset being
583
- // added, we should skip any logic now since `flip()` has already done its
584
- // work.
585
- // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
586
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
587
- return {};
588
- }
589
- const side = getSide(placement);
590
- const initialSideAxis = getSideAxis(initialPlacement);
591
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
592
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
593
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
594
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
595
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
596
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
597
- }
598
- const placements = [initialPlacement, ...fallbackPlacements];
599
- const overflow = await platform.detectOverflow(state, detectOverflowOptions);
600
- const overflows = [];
601
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
602
- if (checkMainAxis) {
603
- overflows.push(overflow[side]);
604
- }
605
- if (checkCrossAxis) {
606
- const sides = getAlignmentSides(placement, rects, rtl);
607
- overflows.push(overflow[sides[0]], overflow[sides[1]]);
608
- }
609
- overflowsData = [...overflowsData, {
610
- placement,
611
- overflows
612
- }];
613
-
614
- // One or more sides is overflowing.
615
- if (!overflows.every(side => side <= 0)) {
616
- var _middlewareData$flip2, _overflowsData$filter;
617
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
618
- const nextPlacement = placements[nextIndex];
619
- if (nextPlacement) {
620
- const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
621
- if (!ignoreCrossAxisOverflow ||
622
- // We leave the current main axis only if every placement on that axis
623
- // overflows the main axis.
624
- overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
625
- // Try next placement and re-run the lifecycle.
626
- return {
627
- data: {
628
- index: nextIndex,
629
- overflows: overflowsData
630
- },
631
- reset: {
632
- placement: nextPlacement
633
- }
634
- };
635
- }
636
- }
637
-
638
- // First, find the candidates that fit on the mainAxis side of overflow,
639
- // then find the placement that fits the best on the main crossAxis side.
640
- let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
641
-
642
- // Otherwise fallback.
643
- if (!resetPlacement) {
644
- switch (fallbackStrategy) {
645
- case 'bestFit':
646
- {
647
- var _overflowsData$filter2;
648
- const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
649
- if (hasFallbackAxisSideDirection) {
650
- const currentSideAxis = getSideAxis(d.placement);
651
- return currentSideAxis === initialSideAxis ||
652
- // Create a bias to the `y` side axis due to horizontal
653
- // reading directions favoring greater width.
654
- currentSideAxis === 'y';
655
- }
656
- return true;
657
- }).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];
658
- if (placement) {
659
- resetPlacement = placement;
660
- }
661
- break;
662
- }
663
- case 'initialPlacement':
664
- resetPlacement = initialPlacement;
665
- break;
666
- }
667
- }
668
- if (placement !== resetPlacement) {
669
- return {
670
- reset: {
671
- placement: resetPlacement
672
- }
673
- };
674
- }
675
- }
676
- return {};
677
- }
678
- };
679
- };
680
-
681
- const originSides = /*#__PURE__*/new Set(['left', 'top']);
682
-
683
- // For type backwards-compatibility, the `OffsetOptions` type was also
684
- // Derivable.
685
-
686
- async function convertValueToCoords(state, options) {
687
- const {
688
- placement,
689
- platform,
690
- elements
691
- } = state;
692
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
693
- const side = getSide(placement);
694
- const alignment = getAlignment(placement);
695
- const isVertical = getSideAxis(placement) === 'y';
696
- const mainAxisMulti = originSides.has(side) ? -1 : 1;
697
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
698
- const rawValue = evaluate(options, state);
699
-
700
- // eslint-disable-next-line prefer-const
701
- let {
702
- mainAxis,
703
- crossAxis,
704
- alignmentAxis
705
- } = typeof rawValue === 'number' ? {
706
- mainAxis: rawValue,
707
- crossAxis: 0,
708
- alignmentAxis: null
709
- } : {
710
- mainAxis: rawValue.mainAxis || 0,
711
- crossAxis: rawValue.crossAxis || 0,
712
- alignmentAxis: rawValue.alignmentAxis
713
- };
714
- if (alignment && typeof alignmentAxis === 'number') {
715
- crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
716
- }
717
- return isVertical ? {
718
- x: crossAxis * crossAxisMulti,
719
- y: mainAxis * mainAxisMulti
720
- } : {
721
- x: mainAxis * mainAxisMulti,
722
- y: crossAxis * crossAxisMulti
723
- };
724
- }
725
-
726
- /**
727
- * Modifies the placement by translating the floating element along the
728
- * specified axes.
729
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
730
- * object may be passed.
731
- * @see https://floating-ui.com/docs/offset
732
- */
733
- const offset$1 = function (options) {
734
- if (options === void 0) {
735
- options = 0;
736
- }
737
- return {
738
- name: 'offset',
739
- options,
740
- async fn(state) {
741
- var _middlewareData$offse, _middlewareData$arrow;
742
- const {
743
- x,
744
- y,
745
- placement,
746
- middlewareData
747
- } = state;
748
- const diffCoords = await convertValueToCoords(state, options);
749
-
750
- // If the placement is the same and the arrow caused an alignment offset
751
- // then we don't need to change the positioning coordinates.
752
- if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
753
- return {};
754
- }
755
- return {
756
- x: x + diffCoords.x,
757
- y: y + diffCoords.y,
758
- data: {
759
- ...diffCoords,
760
- placement
761
- }
762
- };
763
- }
764
- };
765
- };
766
-
767
- /**
768
- * Optimizes the visibility of the floating element by shifting it in order to
769
- * keep it in view when it will overflow the clipping boundary.
770
- * @see https://floating-ui.com/docs/shift
771
- */
772
- const shift$1 = function (options) {
773
- if (options === void 0) {
774
- options = {};
775
- }
776
- return {
777
- name: 'shift',
778
- options,
779
- async fn(state) {
780
- const {
781
- x,
782
- y,
783
- placement,
784
- platform
785
- } = state;
786
- const {
787
- mainAxis: checkMainAxis = true,
788
- crossAxis: checkCrossAxis = false,
789
- limiter = {
790
- fn: _ref => {
791
- let {
792
- x,
793
- y
794
- } = _ref;
795
- return {
796
- x,
797
- y
798
- };
799
- }
800
- },
801
- ...detectOverflowOptions
802
- } = evaluate(options, state);
803
- const coords = {
804
- x,
805
- y
806
- };
807
- const overflow = await platform.detectOverflow(state, detectOverflowOptions);
808
- const crossAxis = getSideAxis(getSide(placement));
809
- const mainAxis = getOppositeAxis(crossAxis);
810
- let mainAxisCoord = coords[mainAxis];
811
- let crossAxisCoord = coords[crossAxis];
812
- if (checkMainAxis) {
813
- const minSide = mainAxis === 'y' ? 'top' : 'left';
814
- const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
815
- const min = mainAxisCoord + overflow[minSide];
816
- const max = mainAxisCoord - overflow[maxSide];
817
- mainAxisCoord = clamp(min, mainAxisCoord, max);
818
- }
819
- if (checkCrossAxis) {
820
- const minSide = crossAxis === 'y' ? 'top' : 'left';
821
- const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
822
- const min = crossAxisCoord + overflow[minSide];
823
- const max = crossAxisCoord - overflow[maxSide];
824
- crossAxisCoord = clamp(min, crossAxisCoord, max);
825
- }
826
- const limitedCoords = limiter.fn({
827
- ...state,
828
- [mainAxis]: mainAxisCoord,
829
- [crossAxis]: crossAxisCoord
830
- });
831
- return {
832
- ...limitedCoords,
833
- data: {
834
- x: limitedCoords.x - x,
835
- y: limitedCoords.y - y,
836
- enabled: {
837
- [mainAxis]: checkMainAxis,
838
- [crossAxis]: checkCrossAxis
839
- }
840
- }
841
- };
842
- }
843
- };
844
- };
845
-
846
- function hasWindow() {
847
- return typeof window !== 'undefined';
848
- }
849
- function getNodeName(node) {
850
- if (isNode(node)) {
851
- return (node.nodeName || '').toLowerCase();
852
- }
853
- // Mocked nodes in testing environments may not be instances of Node. By
854
- // returning `#document` an infinite loop won't occur.
855
- // https://github.com/floating-ui/floating-ui/issues/2317
856
- return '#document';
857
- }
858
- function getWindow(node) {
859
- var _node$ownerDocument;
860
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
861
- }
862
- function getDocumentElement(node) {
863
- var _ref;
864
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
865
- }
866
- function isNode(value) {
867
- if (!hasWindow()) {
868
- return false;
869
- }
870
- return value instanceof Node || value instanceof getWindow(value).Node;
871
- }
872
- function isElement(value) {
873
- if (!hasWindow()) {
874
- return false;
875
- }
876
- return value instanceof Element || value instanceof getWindow(value).Element;
877
- }
878
- function isHTMLElement(value) {
879
- if (!hasWindow()) {
880
- return false;
881
- }
882
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
883
- }
884
- function isShadowRoot(value) {
885
- if (!hasWindow() || typeof ShadowRoot === 'undefined') {
886
- return false;
887
- }
888
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
889
- }
890
- const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
891
- function isOverflowElement(element) {
892
- const {
893
- overflow,
894
- overflowX,
895
- overflowY,
896
- display
897
- } = getComputedStyle$1(element);
898
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
899
- }
900
- const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
901
- function isTableElement(element) {
902
- return tableElements.has(getNodeName(element));
903
- }
904
- const topLayerSelectors = [':popover-open', ':modal'];
905
- function isTopLayer(element) {
906
- return topLayerSelectors.some(selector => {
907
- try {
908
- return element.matches(selector);
909
- } catch (_e) {
910
- return false;
911
- }
912
- });
913
- }
914
- const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
915
- const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
916
- const containValues = ['paint', 'layout', 'strict', 'content'];
917
- function isContainingBlock(elementOrCss) {
918
- const webkit = isWebKit();
919
- const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
920
-
921
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
922
- // https://drafts.csswg.org/css-transforms-2/#individual-transforms
923
- return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
924
- }
925
- function getContainingBlock(element) {
926
- let currentNode = getParentNode(element);
927
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
928
- if (isContainingBlock(currentNode)) {
929
- return currentNode;
930
- } else if (isTopLayer(currentNode)) {
931
- return null;
932
- }
933
- currentNode = getParentNode(currentNode);
934
- }
935
- return null;
936
- }
937
- function isWebKit() {
938
- if (typeof CSS === 'undefined' || !CSS.supports) return false;
939
- return CSS.supports('-webkit-backdrop-filter', 'none');
940
- }
941
- const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
942
- function isLastTraversableNode(node) {
943
- return lastTraversableNodeNames.has(getNodeName(node));
944
- }
945
- function getComputedStyle$1(element) {
946
- return getWindow(element).getComputedStyle(element);
947
- }
948
- function getNodeScroll(element) {
949
- if (isElement(element)) {
950
- return {
951
- scrollLeft: element.scrollLeft,
952
- scrollTop: element.scrollTop
953
- };
954
- }
955
- return {
956
- scrollLeft: element.scrollX,
957
- scrollTop: element.scrollY
958
- };
959
- }
960
- function getParentNode(node) {
961
- if (getNodeName(node) === 'html') {
962
- return node;
963
- }
964
- const result =
965
- // Step into the shadow DOM of the parent of a slotted node.
966
- node.assignedSlot ||
967
- // DOM Element detected.
968
- node.parentNode ||
969
- // ShadowRoot detected.
970
- isShadowRoot(node) && node.host ||
971
- // Fallback.
972
- getDocumentElement(node);
973
- return isShadowRoot(result) ? result.host : result;
974
- }
975
- function getNearestOverflowAncestor(node) {
976
- const parentNode = getParentNode(node);
977
- if (isLastTraversableNode(parentNode)) {
978
- return node.ownerDocument ? node.ownerDocument.body : node.body;
979
- }
980
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
981
- return parentNode;
982
- }
983
- return getNearestOverflowAncestor(parentNode);
984
- }
985
- function getOverflowAncestors(node, list, traverseIframes) {
986
- var _node$ownerDocument2;
987
- if (list === void 0) {
988
- list = [];
989
- }
990
- if (traverseIframes === void 0) {
991
- traverseIframes = true;
992
- }
993
- const scrollableAncestor = getNearestOverflowAncestor(node);
994
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
995
- const win = getWindow(scrollableAncestor);
996
- if (isBody) {
997
- const frameElement = getFrameElement(win);
998
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
999
- }
1000
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1001
- }
1002
- function getFrameElement(win) {
1003
- return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1004
- }
1005
-
1006
- function getCssDimensions(element) {
1007
- const css = getComputedStyle$1(element);
1008
- // In testing environments, the `width` and `height` properties are empty
1009
- // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1010
- let width = parseFloat(css.width) || 0;
1011
- let height = parseFloat(css.height) || 0;
1012
- const hasOffset = isHTMLElement(element);
1013
- const offsetWidth = hasOffset ? element.offsetWidth : width;
1014
- const offsetHeight = hasOffset ? element.offsetHeight : height;
1015
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1016
- if (shouldFallback) {
1017
- width = offsetWidth;
1018
- height = offsetHeight;
1019
- }
1020
- return {
1021
- width,
1022
- height,
1023
- $: shouldFallback
1024
- };
1025
- }
1026
-
1027
- function unwrapElement(element) {
1028
- return !isElement(element) ? element.contextElement : element;
1029
- }
1030
-
1031
- function getScale(element) {
1032
- const domElement = unwrapElement(element);
1033
- if (!isHTMLElement(domElement)) {
1034
- return createCoords(1);
1035
- }
1036
- const rect = domElement.getBoundingClientRect();
1037
- const {
1038
- width,
1039
- height,
1040
- $
1041
- } = getCssDimensions(domElement);
1042
- let x = ($ ? round(rect.width) : rect.width) / width;
1043
- let y = ($ ? round(rect.height) : rect.height) / height;
1044
-
1045
- // 0, NaN, or Infinity should always fallback to 1.
1046
-
1047
- if (!x || !Number.isFinite(x)) {
1048
- x = 1;
1049
- }
1050
- if (!y || !Number.isFinite(y)) {
1051
- y = 1;
1052
- }
1053
- return {
1054
- x,
1055
- y
1056
- };
1057
- }
1058
-
1059
- const noOffsets = /*#__PURE__*/createCoords(0);
1060
- function getVisualOffsets(element) {
1061
- const win = getWindow(element);
1062
- if (!isWebKit() || !win.visualViewport) {
1063
- return noOffsets;
1064
- }
1065
- return {
1066
- x: win.visualViewport.offsetLeft,
1067
- y: win.visualViewport.offsetTop
1068
- };
1069
- }
1070
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1071
- if (isFixed === void 0) {
1072
- isFixed = false;
1073
- }
1074
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1075
- return false;
1076
- }
1077
- return isFixed;
1078
- }
1079
-
1080
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1081
- if (includeScale === void 0) {
1082
- includeScale = false;
1083
- }
1084
- if (isFixedStrategy === void 0) {
1085
- isFixedStrategy = false;
1086
- }
1087
- const clientRect = element.getBoundingClientRect();
1088
- const domElement = unwrapElement(element);
1089
- let scale = createCoords(1);
1090
- if (includeScale) {
1091
- if (offsetParent) {
1092
- if (isElement(offsetParent)) {
1093
- scale = getScale(offsetParent);
1094
- }
1095
- } else {
1096
- scale = getScale(element);
1097
- }
1098
- }
1099
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1100
- let x = (clientRect.left + visualOffsets.x) / scale.x;
1101
- let y = (clientRect.top + visualOffsets.y) / scale.y;
1102
- let width = clientRect.width / scale.x;
1103
- let height = clientRect.height / scale.y;
1104
- if (domElement) {
1105
- const win = getWindow(domElement);
1106
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1107
- let currentWin = win;
1108
- let currentIFrame = getFrameElement(currentWin);
1109
- while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1110
- const iframeScale = getScale(currentIFrame);
1111
- const iframeRect = currentIFrame.getBoundingClientRect();
1112
- const css = getComputedStyle$1(currentIFrame);
1113
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1114
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1115
- x *= iframeScale.x;
1116
- y *= iframeScale.y;
1117
- width *= iframeScale.x;
1118
- height *= iframeScale.y;
1119
- x += left;
1120
- y += top;
1121
- currentWin = getWindow(currentIFrame);
1122
- currentIFrame = getFrameElement(currentWin);
1123
- }
1124
- }
1125
- return rectToClientRect({
1126
- width,
1127
- height,
1128
- x,
1129
- y
1130
- });
1131
- }
1132
-
1133
- // If <html> has a CSS width greater than the viewport, then this will be
1134
- // incorrect for RTL.
1135
- function getWindowScrollBarX(element, rect) {
1136
- const leftScroll = getNodeScroll(element).scrollLeft;
1137
- if (!rect) {
1138
- return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1139
- }
1140
- return rect.left + leftScroll;
1141
- }
1142
-
1143
- function getHTMLOffset(documentElement, scroll) {
1144
- const htmlRect = documentElement.getBoundingClientRect();
1145
- const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
1146
- const y = htmlRect.top + scroll.scrollTop;
1147
- return {
1148
- x,
1149
- y
1150
- };
1151
- }
1152
-
1153
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1154
- let {
1155
- elements,
1156
- rect,
1157
- offsetParent,
1158
- strategy
1159
- } = _ref;
1160
- const isFixed = strategy === 'fixed';
1161
- const documentElement = getDocumentElement(offsetParent);
1162
- const topLayer = elements ? isTopLayer(elements.floating) : false;
1163
- if (offsetParent === documentElement || topLayer && isFixed) {
1164
- return rect;
1165
- }
1166
- let scroll = {
1167
- scrollLeft: 0,
1168
- scrollTop: 0
1169
- };
1170
- let scale = createCoords(1);
1171
- const offsets = createCoords(0);
1172
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1173
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1174
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1175
- scroll = getNodeScroll(offsetParent);
1176
- }
1177
- if (isHTMLElement(offsetParent)) {
1178
- const offsetRect = getBoundingClientRect(offsetParent);
1179
- scale = getScale(offsetParent);
1180
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1181
- offsets.y = offsetRect.y + offsetParent.clientTop;
1182
- }
1183
- }
1184
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1185
- return {
1186
- width: rect.width * scale.x,
1187
- height: rect.height * scale.y,
1188
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1189
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1190
- };
1191
- }
1192
-
1193
- function getClientRects(element) {
1194
- return Array.from(element.getClientRects());
1195
- }
1196
-
1197
- // Gets the entire size of the scrollable document area, even extending outside
1198
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1199
- function getDocumentRect(element) {
1200
- const html = getDocumentElement(element);
1201
- const scroll = getNodeScroll(element);
1202
- const body = element.ownerDocument.body;
1203
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1204
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1205
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1206
- const y = -scroll.scrollTop;
1207
- if (getComputedStyle$1(body).direction === 'rtl') {
1208
- x += max(html.clientWidth, body.clientWidth) - width;
1209
- }
1210
- return {
1211
- width,
1212
- height,
1213
- x,
1214
- y
1215
- };
1216
- }
1217
-
1218
- // Safety check: ensure the scrollbar space is reasonable in case this
1219
- // calculation is affected by unusual styles.
1220
- // Most scrollbars leave 15-18px of space.
1221
- const SCROLLBAR_MAX = 25;
1222
- function getViewportRect(element, strategy) {
1223
- const win = getWindow(element);
1224
- const html = getDocumentElement(element);
1225
- const visualViewport = win.visualViewport;
1226
- let width = html.clientWidth;
1227
- let height = html.clientHeight;
1228
- let x = 0;
1229
- let y = 0;
1230
- if (visualViewport) {
1231
- width = visualViewport.width;
1232
- height = visualViewport.height;
1233
- const visualViewportBased = isWebKit();
1234
- if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1235
- x = visualViewport.offsetLeft;
1236
- y = visualViewport.offsetTop;
1237
- }
1238
- }
1239
- const windowScrollbarX = getWindowScrollBarX(html);
1240
- // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
1241
- // visual width of the <html> but this is not considered in the size
1242
- // of `html.clientWidth`.
1243
- if (windowScrollbarX <= 0) {
1244
- const doc = html.ownerDocument;
1245
- const body = doc.body;
1246
- const bodyStyles = getComputedStyle(body);
1247
- const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
1248
- const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
1249
- if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
1250
- width -= clippingStableScrollbarWidth;
1251
- }
1252
- } else if (windowScrollbarX <= SCROLLBAR_MAX) {
1253
- // If the <body> scrollbar is on the left, the width needs to be extended
1254
- // by the scrollbar amount so there isn't extra space on the right.
1255
- width += windowScrollbarX;
1256
- }
1257
- return {
1258
- width,
1259
- height,
1260
- x,
1261
- y
1262
- };
1263
- }
1264
-
1265
- const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
1266
- // Returns the inner client rect, subtracting scrollbars if present.
1267
- function getInnerBoundingClientRect(element, strategy) {
1268
- const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1269
- const top = clientRect.top + element.clientTop;
1270
- const left = clientRect.left + element.clientLeft;
1271
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1272
- const width = element.clientWidth * scale.x;
1273
- const height = element.clientHeight * scale.y;
1274
- const x = left * scale.x;
1275
- const y = top * scale.y;
1276
- return {
1277
- width,
1278
- height,
1279
- x,
1280
- y
1281
- };
1282
- }
1283
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1284
- let rect;
1285
- if (clippingAncestor === 'viewport') {
1286
- rect = getViewportRect(element, strategy);
1287
- } else if (clippingAncestor === 'document') {
1288
- rect = getDocumentRect(getDocumentElement(element));
1289
- } else if (isElement(clippingAncestor)) {
1290
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1291
- } else {
1292
- const visualOffsets = getVisualOffsets(element);
1293
- rect = {
1294
- x: clippingAncestor.x - visualOffsets.x,
1295
- y: clippingAncestor.y - visualOffsets.y,
1296
- width: clippingAncestor.width,
1297
- height: clippingAncestor.height
1298
- };
1299
- }
1300
- return rectToClientRect(rect);
1301
- }
1302
- function hasFixedPositionAncestor(element, stopNode) {
1303
- const parentNode = getParentNode(element);
1304
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1305
- return false;
1306
- }
1307
- return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1308
- }
1309
-
1310
- // A "clipping ancestor" is an `overflow` element with the characteristic of
1311
- // clipping (or hiding) child elements. This returns all clipping ancestors
1312
- // of the given element up the tree.
1313
- function getClippingElementAncestors(element, cache) {
1314
- const cachedResult = cache.get(element);
1315
- if (cachedResult) {
1316
- return cachedResult;
1317
- }
1318
- let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1319
- let currentContainingBlockComputedStyle = null;
1320
- const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1321
- let currentNode = elementIsFixed ? getParentNode(element) : element;
1322
-
1323
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1324
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1325
- const computedStyle = getComputedStyle$1(currentNode);
1326
- const currentNodeIsContaining = isContainingBlock(currentNode);
1327
- if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1328
- currentContainingBlockComputedStyle = null;
1329
- }
1330
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1331
- if (shouldDropCurrentNode) {
1332
- // Drop non-containing blocks.
1333
- result = result.filter(ancestor => ancestor !== currentNode);
1334
- } else {
1335
- // Record last containing block for next iteration.
1336
- currentContainingBlockComputedStyle = computedStyle;
1337
- }
1338
- currentNode = getParentNode(currentNode);
1339
- }
1340
- cache.set(element, result);
1341
- return result;
1342
- }
1343
-
1344
- // Gets the maximum area that the element is visible in due to any number of
1345
- // clipping ancestors.
1346
- function getClippingRect(_ref) {
1347
- let {
1348
- element,
1349
- boundary,
1350
- rootBoundary,
1351
- strategy
1352
- } = _ref;
1353
- const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1354
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1355
- const firstClippingAncestor = clippingAncestors[0];
1356
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1357
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1358
- accRect.top = max(rect.top, accRect.top);
1359
- accRect.right = min(rect.right, accRect.right);
1360
- accRect.bottom = min(rect.bottom, accRect.bottom);
1361
- accRect.left = max(rect.left, accRect.left);
1362
- return accRect;
1363
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1364
- return {
1365
- width: clippingRect.right - clippingRect.left,
1366
- height: clippingRect.bottom - clippingRect.top,
1367
- x: clippingRect.left,
1368
- y: clippingRect.top
1369
- };
1370
- }
1371
-
1372
- function getDimensions(element) {
1373
- const {
1374
- width,
1375
- height
1376
- } = getCssDimensions(element);
1377
- return {
1378
- width,
1379
- height
1380
- };
1381
- }
1382
-
1383
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1384
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1385
- const documentElement = getDocumentElement(offsetParent);
1386
- const isFixed = strategy === 'fixed';
1387
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1388
- let scroll = {
1389
- scrollLeft: 0,
1390
- scrollTop: 0
1391
- };
1392
- const offsets = createCoords(0);
1393
-
1394
- // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1395
- // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1396
- function setLeftRTLScrollbarOffset() {
1397
- offsets.x = getWindowScrollBarX(documentElement);
1398
- }
1399
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1400
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1401
- scroll = getNodeScroll(offsetParent);
1402
- }
1403
- if (isOffsetParentAnElement) {
1404
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1405
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1406
- offsets.y = offsetRect.y + offsetParent.clientTop;
1407
- } else if (documentElement) {
1408
- setLeftRTLScrollbarOffset();
1409
- }
1410
- }
1411
- if (isFixed && !isOffsetParentAnElement && documentElement) {
1412
- setLeftRTLScrollbarOffset();
1413
- }
1414
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1415
- const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1416
- const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1417
- return {
1418
- x,
1419
- y,
1420
- width: rect.width,
1421
- height: rect.height
1422
- };
1423
- }
1424
-
1425
- function isStaticPositioned(element) {
1426
- return getComputedStyle$1(element).position === 'static';
1427
- }
1428
-
1429
- function getTrueOffsetParent(element, polyfill) {
1430
- if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1431
- return null;
1432
- }
1433
- if (polyfill) {
1434
- return polyfill(element);
1435
- }
1436
- let rawOffsetParent = element.offsetParent;
1437
-
1438
- // Firefox returns the <html> element as the offsetParent if it's non-static,
1439
- // while Chrome and Safari return the <body> element. The <body> element must
1440
- // be used to perform the correct calculations even if the <html> element is
1441
- // non-static.
1442
- if (getDocumentElement(element) === rawOffsetParent) {
1443
- rawOffsetParent = rawOffsetParent.ownerDocument.body;
1444
- }
1445
- return rawOffsetParent;
1446
- }
1447
-
1448
- // Gets the closest ancestor positioned element. Handles some edge cases,
1449
- // such as table ancestors and cross browser bugs.
1450
- function getOffsetParent(element, polyfill) {
1451
- const win = getWindow(element);
1452
- if (isTopLayer(element)) {
1453
- return win;
1454
- }
1455
- if (!isHTMLElement(element)) {
1456
- let svgOffsetParent = getParentNode(element);
1457
- while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1458
- if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1459
- return svgOffsetParent;
1460
- }
1461
- svgOffsetParent = getParentNode(svgOffsetParent);
1462
- }
1463
- return win;
1464
- }
1465
- let offsetParent = getTrueOffsetParent(element, polyfill);
1466
- while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1467
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1468
- }
1469
- if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1470
- return win;
1471
- }
1472
- return offsetParent || getContainingBlock(element) || win;
1473
- }
1474
-
1475
- const getElementRects = async function (data) {
1476
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1477
- const getDimensionsFn = this.getDimensions;
1478
- const floatingDimensions = await getDimensionsFn(data.floating);
1479
- return {
1480
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1481
- floating: {
1482
- x: 0,
1483
- y: 0,
1484
- width: floatingDimensions.width,
1485
- height: floatingDimensions.height
1486
- }
1487
- };
1488
- };
1489
-
1490
- function isRTL(element) {
1491
- return getComputedStyle$1(element).direction === 'rtl';
1492
- }
1493
-
1494
- const platform = {
1495
- convertOffsetParentRelativeRectToViewportRelativeRect,
1496
- getDocumentElement,
1497
- getClippingRect,
1498
- getOffsetParent,
1499
- getElementRects,
1500
- getClientRects,
1501
- getDimensions,
1502
- getScale,
1503
- isElement,
1504
- isRTL
1505
- };
1506
-
1507
- function rectsAreEqual(a, b) {
1508
- return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
1509
- }
1510
-
1511
- // https://samthor.au/2021/observing-dom/
1512
- function observeMove(element, onMove) {
1513
- let io = null;
1514
- let timeoutId;
1515
- const root = getDocumentElement(element);
1516
- function cleanup() {
1517
- var _io;
1518
- clearTimeout(timeoutId);
1519
- (_io = io) == null || _io.disconnect();
1520
- io = null;
1521
- }
1522
- function refresh(skip, threshold) {
1523
- if (skip === void 0) {
1524
- skip = false;
1525
- }
1526
- if (threshold === void 0) {
1527
- threshold = 1;
1528
- }
1529
- cleanup();
1530
- const elementRectForRootMargin = element.getBoundingClientRect();
1531
- const {
1532
- left,
1533
- top,
1534
- width,
1535
- height
1536
- } = elementRectForRootMargin;
1537
- if (!skip) {
1538
- onMove();
1539
- }
1540
- if (!width || !height) {
1541
- return;
1542
- }
1543
- const insetTop = floor(top);
1544
- const insetRight = floor(root.clientWidth - (left + width));
1545
- const insetBottom = floor(root.clientHeight - (top + height));
1546
- const insetLeft = floor(left);
1547
- const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1548
- const options = {
1549
- rootMargin,
1550
- threshold: max(0, min(1, threshold)) || 1
1551
- };
1552
- let isFirstUpdate = true;
1553
- function handleObserve(entries) {
1554
- const ratio = entries[0].intersectionRatio;
1555
- if (ratio !== threshold) {
1556
- if (!isFirstUpdate) {
1557
- return refresh();
1558
- }
1559
- if (!ratio) {
1560
- // If the reference is clipped, the ratio is 0. Throttle the refresh
1561
- // to prevent an infinite loop of updates.
1562
- timeoutId = setTimeout(() => {
1563
- refresh(false, 1e-7);
1564
- }, 1000);
1565
- } else {
1566
- refresh(false, ratio);
1567
- }
1568
- }
1569
- if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
1570
- // It's possible that even though the ratio is reported as 1, the
1571
- // element is not actually fully within the IntersectionObserver's root
1572
- // area anymore. This can happen under performance constraints. This may
1573
- // be a bug in the browser's IntersectionObserver implementation. To
1574
- // work around this, we compare the element's bounding rect now with
1575
- // what it was at the time we created the IntersectionObserver. If they
1576
- // are not equal then the element moved, so we refresh.
1577
- refresh();
1578
- }
1579
- isFirstUpdate = false;
1580
- }
1581
-
1582
- // Older browsers don't support a `document` as the root and will throw an
1583
- // error.
1584
- try {
1585
- io = new IntersectionObserver(handleObserve, {
1586
- ...options,
1587
- // Handle <iframe>s
1588
- root: root.ownerDocument
1589
- });
1590
- } catch (_e) {
1591
- io = new IntersectionObserver(handleObserve, options);
1592
- }
1593
- io.observe(element);
1594
- }
1595
- refresh(true);
1596
- return cleanup;
1597
- }
1598
-
1599
- /**
1600
- * Automatically updates the position of the floating element when necessary.
1601
- * Should only be called when the floating element is mounted on the DOM or
1602
- * visible on the screen.
1603
- * @returns cleanup function that should be invoked when the floating element is
1604
- * removed from the DOM or hidden from the screen.
1605
- * @see https://floating-ui.com/docs/autoUpdate
1606
- */
1607
- function autoUpdate(reference, floating, update, options) {
1608
- if (options === void 0) {
1609
- options = {};
1610
- }
1611
- const {
1612
- ancestorScroll = true,
1613
- ancestorResize = true,
1614
- elementResize = typeof ResizeObserver === 'function',
1615
- layoutShift = typeof IntersectionObserver === 'function',
1616
- animationFrame = false
1617
- } = options;
1618
- const referenceEl = unwrapElement(reference);
1619
- const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1620
- ancestors.forEach(ancestor => {
1621
- ancestorScroll && ancestor.addEventListener('scroll', update, {
1622
- passive: true
1623
- });
1624
- ancestorResize && ancestor.addEventListener('resize', update);
1625
- });
1626
- const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1627
- let reobserveFrame = -1;
1628
- let resizeObserver = null;
1629
- if (elementResize) {
1630
- resizeObserver = new ResizeObserver(_ref => {
1631
- let [firstEntry] = _ref;
1632
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1633
- // Prevent update loops when using the `size` middleware.
1634
- // https://github.com/floating-ui/floating-ui/issues/1740
1635
- resizeObserver.unobserve(floating);
1636
- cancelAnimationFrame(reobserveFrame);
1637
- reobserveFrame = requestAnimationFrame(() => {
1638
- var _resizeObserver;
1639
- (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1640
- });
1641
- }
1642
- update();
1643
- });
1644
- if (referenceEl && !animationFrame) {
1645
- resizeObserver.observe(referenceEl);
1646
- }
1647
- resizeObserver.observe(floating);
1648
- }
1649
- let frameId;
1650
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1651
- if (animationFrame) {
1652
- frameLoop();
1653
- }
1654
- function frameLoop() {
1655
- const nextRefRect = getBoundingClientRect(reference);
1656
- if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
1657
- update();
1658
- }
1659
- prevRefRect = nextRefRect;
1660
- frameId = requestAnimationFrame(frameLoop);
1661
- }
1662
- update();
1663
- return () => {
1664
- var _resizeObserver2;
1665
- ancestors.forEach(ancestor => {
1666
- ancestorScroll && ancestor.removeEventListener('scroll', update);
1667
- ancestorResize && ancestor.removeEventListener('resize', update);
1668
- });
1669
- cleanupIo == null || cleanupIo();
1670
- (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1671
- resizeObserver = null;
1672
- if (animationFrame) {
1673
- cancelAnimationFrame(frameId);
1674
- }
1675
- };
1676
- }
1677
-
1678
- /**
1679
- * Modifies the placement by translating the floating element along the
1680
- * specified axes.
1681
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
1682
- * object may be passed.
1683
- * @see https://floating-ui.com/docs/offset
1684
- */
1685
- const offset = offset$1;
1686
-
1687
- /**
1688
- * Optimizes the visibility of the floating element by choosing the placement
1689
- * that has the most space available automatically, without needing to specify a
1690
- * preferred placement. Alternative to `flip`.
1691
- * @see https://floating-ui.com/docs/autoPlacement
1692
- */
1693
- const autoPlacement = autoPlacement$1;
1694
-
1695
- /**
1696
- * Optimizes the visibility of the floating element by shifting it in order to
1697
- * keep it in view when it will overflow the clipping boundary.
1698
- * @see https://floating-ui.com/docs/shift
1699
- */
1700
- const shift = shift$1;
1701
-
1702
- /**
1703
- * Optimizes the visibility of the floating element by flipping the `placement`
1704
- * in order to keep it in view when the preferred placement(s) will overflow the
1705
- * clipping boundary. Alternative to `autoPlacement`.
1706
- * @see https://floating-ui.com/docs/flip
1707
- */
1708
- const flip = flip$1;
1709
-
1710
- /**
1711
- * Computes the `x` and `y` coordinates that will place the floating element
1712
- * next to a given reference element.
1713
- */
1714
- const computePosition = (reference, floating, options) => {
1715
- // This caches the expensive `getClippingElementAncestors` function so that
1716
- // multiple lifecycle resets re-use the same result. It only lives for a
1717
- // single call. If other functions become expensive, we can add them as well.
1718
- const cache = new Map();
1719
- const mergedOptions = {
1720
- platform,
1721
- ...options
1722
- };
1723
- const platformWithCache = {
1724
- ...mergedOptions.platform,
1725
- _c: cache
1726
- };
1727
- return computePosition$1(reference, floating, {
1728
- ...mergedOptions,
1729
- platform: platformWithCache
1730
- });
1731
- };
1732
-
1733
- /* eslint-disable line-comment-position, no-inline-comments */
1734
-
1735
-
1736
- const MAX_CONFIGURATION_COUNT = 10;
1737
-
1738
- class AuroFloatingUI {
1739
- /**
1740
- * @private
1741
- */
1742
- static isMousePressed = false;
1743
-
1744
- /**
1745
- * @private
1746
- */
1747
- static isMousePressHandlerInitialized = false;
1748
-
1749
- /**
1750
- * @private
1751
- */
1752
- static setupMousePressChecker() {
1753
- if (
1754
- !AuroFloatingUI.isMousePressHandlerInitialized &&
1755
- window &&
1756
- window.addEventListener
1757
- ) {
1758
- AuroFloatingUI.isMousePressHandlerInitialized = true;
1759
-
1760
- // Track timeout for isMousePressed reset to avoid race conditions
1761
- if (!AuroFloatingUI._mousePressedTimeout) {
1762
- AuroFloatingUI._mousePressedTimeout = null;
1763
- }
1764
- const mouseEventGlobalHandler = (event) => {
1765
- const isPressed = event.type === "mousedown";
1766
- if (isPressed) {
1767
- // Clear any pending timeout to prevent race condition
1768
- if (AuroFloatingUI._mousePressedTimeout !== null) {
1769
- clearTimeout(AuroFloatingUI._mousePressedTimeout);
1770
- AuroFloatingUI._mousePressedTimeout = null;
1771
- }
1772
- if (!AuroFloatingUI.isMousePressed) {
1773
- AuroFloatingUI.isMousePressed = true;
1774
- }
1775
- } else if (AuroFloatingUI.isMousePressed && !isPressed) {
1776
- // Schedule reset and track timeout ID
1777
- AuroFloatingUI._mousePressedTimeout = setTimeout(() => {
1778
- AuroFloatingUI.isMousePressed = false;
1779
- AuroFloatingUI._mousePressedTimeout = null;
1780
- }, 0);
1781
- }
1782
- };
1783
-
1784
- window.addEventListener("mousedown", mouseEventGlobalHandler);
1785
- window.addEventListener("mouseup", mouseEventGlobalHandler);
1786
- }
1787
- }
1788
-
1789
- constructor(element, behavior) {
1790
- this.element = element;
1791
- this.behavior = behavior;
1792
-
1793
- // Store event listener references for cleanup
1794
- this.focusHandler = null;
1795
- this.clickHandler = null;
1796
- this.keyDownHandler = null;
1797
-
1798
- /**
1799
- * @private
1800
- */
1801
- this.enableKeyboardHandling = true;
1802
-
1803
- /**
1804
- * @private
1805
- */
1806
- this.configureTrial = 0;
1807
-
1808
- /**
1809
- * @private
1810
- */
1811
- this.eventPrefix = undefined;
1812
-
1813
- /**
1814
- * @private
1815
- */
1816
- this.id = undefined;
1817
-
1818
- /**
1819
- * @private
1820
- */
1821
- this.showing = false;
1822
-
1823
- /**
1824
- * @private
1825
- */
1826
- this.strategy = undefined;
1827
- }
1828
-
1829
- /**
1830
- * Mirrors the size of the bibSizer element to the bib content.
1831
- * Copies the width, height, max-width, and max-height styles from the bibSizer element to the bib content container.
1832
- * This ensures that the bib content has the same dimensions as the sizer element.
1833
- */
1834
- mirrorSize() {
1835
- // mirror the boxsize from bibSizer
1836
- if (this.element.bibSizer && this.element.matchWidth) {
1837
- const sizerStyle = window.getComputedStyle(this.element.bibSizer);
1838
- const bibContent =
1839
- this.element.bib.shadowRoot.querySelector(".container");
1840
- if (sizerStyle.width !== "0px") {
1841
- bibContent.style.width = sizerStyle.width;
1842
- }
1843
- if (sizerStyle.height !== "0px") {
1844
- bibContent.style.height = sizerStyle.height;
1845
- }
1846
- bibContent.style.maxWidth = sizerStyle.maxWidth;
1847
- bibContent.style.maxHeight = sizerStyle.maxHeight;
1848
- }
1849
- }
1850
-
1851
- /**
1852
- * @private
1853
- * Determines the positioning strategy based on the current viewport size and mobile breakpoint.
1854
- *
1855
- * This method checks if the current viewport width is less than or equal to the specified mobile fullscreen breakpoint
1856
- * defined in the bib element. If it is, the strategy is set to 'fullscreen'; otherwise, it defaults to 'floating'.
1857
- *
1858
- * @returns {String} The positioning strategy, one of 'fullscreen', 'floating', 'cover'.
1859
- */
1860
- getPositioningStrategy() {
1861
- const breakpoint =
1862
- this.element.bib.mobileFullscreenBreakpoint ||
1863
- this.element.floaterConfig?.fullscreenBreakpoint;
1864
- switch (this.behavior) {
1865
- case "tooltip":
1866
- return "floating";
1867
- case "dialog":
1868
- case "drawer":
1869
- if (breakpoint) {
1870
- const smallerThanBreakpoint = window.matchMedia(
1871
- `(max-width: ${breakpoint})`,
1872
- ).matches;
1873
-
1874
- this.element.expanded = smallerThanBreakpoint;
1875
- }
1876
- if (this.element.nested) {
1877
- return "cover";
1878
- }
1879
- return "fullscreen";
1880
- case "dropdown":
1881
- case undefined:
1882
- case null:
1883
- if (breakpoint) {
1884
- const smallerThanBreakpoint = window.matchMedia(
1885
- `(max-width: ${breakpoint})`,
1886
- ).matches;
1887
- if (smallerThanBreakpoint) {
1888
- return "fullscreen";
1889
- }
1890
- }
1891
- return "floating";
1892
- default:
1893
- return this.behavior;
1894
- }
1895
- }
1896
-
1897
- /**
1898
- * @private
1899
- * Positions the bib element based on the current configuration and positioning strategy.
1900
- *
1901
- * This method determines the appropriate positioning strategy (fullscreen or not) and configures the bib accordingly.
1902
- * It also sets up middleware for the floater configuration, computes the position of the bib relative to the trigger element,
1903
- * and applies the calculated position to the bib's style.
1904
- */
1905
- position() {
1906
- const strategy = this.getPositioningStrategy();
1907
- this.configureBibStrategy(strategy);
1908
-
1909
- if (strategy === "floating") {
1910
- this.mirrorSize();
1911
- // Define the middlware for the floater configuration
1912
- const middleware = [
1913
- offset(this.element.floaterConfig?.offset || 0),
1914
- ...(this.element.floaterConfig?.shift ? [shift()] : []), // Add shift middleware if shift is enabled.
1915
- ...(this.element.floaterConfig?.flip ? [flip()] : []), // Add flip middleware if flip is enabled.
1916
- ...(this.element.floaterConfig?.autoPlacement ? [autoPlacement()] : []), // Add autoPlacement middleware if autoPlacement is enabled.
1917
- ];
1918
-
1919
- // Compute the position of the bib
1920
- computePosition(this.element.trigger, this.element.bib, {
1921
- strategy: this.element.floaterConfig?.strategy || "fixed",
1922
- placement: this.element.floaterConfig?.placement,
1923
- middleware: middleware || [],
1924
- }).then(({ x, y }) => {
1925
- // eslint-disable-line id-length
1926
- Object.assign(this.element.bib.style, {
1927
- left: `${x}px`,
1928
- top: `${y}px`,
1929
- });
1930
- });
1931
- } else if (strategy === "cover") {
1932
- // Compute the position of the bib
1933
- computePosition(this.element.parentNode, this.element.bib, {
1934
- placement: "bottom-start",
1935
- }).then(({ x, y }) => {
1936
- // eslint-disable-line id-length
1937
- Object.assign(this.element.bib.style, {
1938
- left: `${x}px`,
1939
- top: `${y - this.element.parentNode.offsetHeight}px`,
1940
- width: `${this.element.parentNode.offsetWidth}px`,
1941
- height: `${this.element.parentNode.offsetHeight}px`,
1942
- });
1943
- });
1944
- }
1945
- }
1946
-
1947
- /**
1948
- * @private
1949
- * Controls whether to lock the scrolling for the document's body.
1950
- * @param {Boolean} lock - If true, locks the body's scrolling functionlity; otherwise, unlock.
1951
- */
1952
- lockScroll(lock = true) {
1953
- if (lock) {
1954
- document.body.style.overflow = "hidden"; // hide body's scrollbar
1955
-
1956
- // Move `bib` by the amount the viewport is shifted to stay aligned in fullscreen.
1957
- this.element.bib.style.transform = `translateY(${window?.visualViewport?.offsetTop}px)`;
1958
- } else {
1959
- document.body.style.overflow = "";
1960
- }
1961
- }
1962
-
1963
- /**
1964
- * @private
1965
- * Configures the bib element's display strategy.
1966
- *
1967
- * Sets the bib to fullscreen or floating mode based on the provided strategy.
1968
- * Dispatches a 'strategy-change' event if the strategy changes.
1969
- *
1970
- * @param {string} strategy - The positioning strategy ('fullscreen' or 'floating').
1971
- */
1972
- configureBibStrategy(value) {
1973
- if (value === "fullscreen") {
1974
- this.element.isBibFullscreen = true;
1975
- // reset the prev position
1976
- this.element.bib.setAttribute("isfullscreen", "");
1977
- this.element.bib.style.position = "fixed";
1978
- this.element.bib.style.top = "0px";
1979
- this.element.bib.style.left = "0px";
1980
- this.element.bib.style.width = "";
1981
- this.element.bib.style.height = "";
1982
- this.element.style.contain = "";
1983
-
1984
- // reset the size that was mirroring `size` css-part
1985
- const bibContent =
1986
- this.element.bib.shadowRoot.querySelector(".container");
1987
- if (bibContent) {
1988
- bibContent.style.width = "";
1989
- bibContent.style.height = "";
1990
- bibContent.style.maxWidth = "";
1991
- bibContent.style.maxHeight = `${window?.visualViewport?.height}px`;
1992
- this.configureTrial = 0;
1993
- } else if (this.configureTrial < MAX_CONFIGURATION_COUNT) {
1994
- this.configureTrial += 1;
1995
-
1996
- setTimeout(() => {
1997
- this.configureBibStrategy(value);
1998
- }, 0);
1999
- }
2000
-
2001
- if (this.element.isPopoverVisible) {
2002
- this.lockScroll(true);
2003
- }
2004
- } else {
2005
- this.element.bib.style.position = "";
2006
- this.element.bib.removeAttribute("isfullscreen");
2007
- this.element.isBibFullscreen = false;
2008
- this.element.style.contain = "layout";
2009
- }
2010
-
2011
- const isChanged = this.strategy && this.strategy !== value;
2012
- this.strategy = value;
2013
- if (isChanged) {
2014
- const event = new CustomEvent(
2015
- this.eventPrefix
2016
- ? `${this.eventPrefix}-strategy-change`
2017
- : "strategy-change",
2018
- {
2019
- detail: {
2020
- value,
2021
- },
2022
- composed: true,
2023
- },
2024
- );
2025
-
2026
- this.element.dispatchEvent(event);
2027
- }
2028
- }
2029
-
2030
- updateState() {
2031
- const isVisible = this.element.isPopoverVisible;
2032
- if (!isVisible) {
2033
- this.cleanupHideHandlers();
2034
- try {
2035
- this.element.cleanup?.();
2036
- } catch (error) {
2037
- // Do nothing
2038
- }
2039
- }
2040
- }
2041
-
2042
- /**
2043
- * @private
2044
- * getting called on 'blur' in trigger or `focusin` in document
2045
- *
2046
- * Hides the bib if focus moves outside of the trigger or bib, unless a 'noHideOnThisFocusLoss' flag is set.
2047
- * This method checks if the currently active element is still within the trigger or bib.
2048
- * If not, and if the bib isn't in fullscreen mode with focus lost, it hides the bib.
2049
- */
2050
- handleFocusLoss() {
2051
- // if mouse is being pressed, skip and let click event to handle the action
2052
- if (AuroFloatingUI.isMousePressed) {
2053
- return;
2054
- }
2055
-
2056
- if (
2057
- this.element.noHideOnThisFocusLoss ||
2058
- this.element.hasAttribute("noHideOnThisFocusLoss")
2059
- ) {
2060
- return;
2061
- }
2062
-
2063
- // if focus is still inside of trigger or bib, do not close
2064
- if (
2065
- this.element.matches(":focus") ||
2066
- this.element.matches(":focus-within")
2067
- ) {
2068
- return;
2069
- }
2070
-
2071
- // if fullscreen bib is in fullscreen mode, do not close
2072
- if (this.element.bib.hasAttribute("isfullscreen")) {
2073
- return;
2074
- }
2075
-
2076
- this.hideBib("keydown");
2077
- }
2078
-
2079
- setupHideHandlers() {
2080
- // Define handlers & store references
2081
- this.focusHandler = () => this.handleFocusLoss();
2082
-
2083
- this.clickHandler = (evt) => {
2084
- // When the bib is fullscreen (modal dialog), don't close on outside
2085
- // clicks. VoiceOver's synthetic click events inside a top-layer modal
2086
- // <dialog> may not include the bib in composedPath(), causing false
2087
- // positives. This mirrors the fullscreen guard in handleFocusLoss().
2088
- if (this.element.bib && this.element.bib.hasAttribute("isfullscreen")) {
2089
- return;
2090
- }
2091
-
2092
- if (
2093
- (!evt.composedPath().includes(this.element.trigger) &&
2094
- !evt.composedPath().includes(this.element.bib)) ||
2095
- (this.element.bib.backdrop &&
2096
- evt.composedPath().includes(this.element.bib.backdrop))
2097
- ) {
2098
- const existedVisibleFloatingUI =
2099
- document.expandedAuroFormkitDropdown || document.expandedAuroFloater;
2100
-
2101
- if (
2102
- existedVisibleFloatingUI &&
2103
- existedVisibleFloatingUI.element.isPopoverVisible
2104
- ) {
2105
- // if something else is open, close that
2106
- existedVisibleFloatingUI.hideBib();
2107
- document.expandedAuroFormkitDropdown = null;
2108
- document.expandedAuroFloater = this;
2109
- } else {
2110
- this.hideBib("click");
2111
- }
2112
- }
2113
- };
2114
-
2115
- // ESC key handler
2116
- this.keyDownHandler = (evt) => {
2117
- if (evt.key === "Escape" && this.element.isPopoverVisible) {
2118
- const existedVisibleFloatingUI =
2119
- document.expandedAuroFormkitDropdown || document.expandedAuroFloater;
2120
- if (
2121
- existedVisibleFloatingUI &&
2122
- existedVisibleFloatingUI !== this &&
2123
- existedVisibleFloatingUI.element.isPopoverVisible
2124
- ) {
2125
- // if something else is open, let it handle itself
2126
- return;
2127
- }
2128
- this.hideBib("keydown");
2129
- }
2130
- };
2131
-
2132
- if (this.behavior !== "drawer" && this.behavior !== "dialog") {
2133
- // Add event listeners using the stored references
2134
- document.addEventListener("focusin", this.focusHandler);
2135
- }
2136
-
2137
- if (this.enableKeyboardHandling) {
2138
- document.addEventListener("keydown", this.keyDownHandler);
2139
- }
2140
-
2141
- // send this task to the end of queue to prevent conflicting
2142
- // it conflicts if showBib gets call from a button that's not this.element.trigger
2143
- setTimeout(() => {
2144
- window.addEventListener("click", this.clickHandler);
2145
- }, 0);
2146
- }
2147
-
2148
- cleanupHideHandlers() {
2149
- // Remove event listeners if they exist
2150
-
2151
- if (this.focusHandler) {
2152
- document.removeEventListener("focusin", this.focusHandler);
2153
- this.focusHandler = null;
2154
- }
2155
-
2156
- if (this.clickHandler) {
2157
- window.removeEventListener("click", this.clickHandler);
2158
- this.clickHandler = null;
2159
- }
2160
-
2161
- if (this.keyDownHandler) {
2162
- document.removeEventListener("keydown", this.keyDownHandler);
2163
- this.keyDownHandler = null;
2164
- }
2165
- }
2166
-
2167
- handleUpdate(changedProperties) {
2168
- if (changedProperties.has("isPopoverVisible")) {
2169
- this.updateState();
2170
- }
2171
- }
2172
-
2173
- updateCurrentExpandedDropdown() {
2174
- // Close any other dropdown that is already open
2175
- const existedVisibleFloatingUI =
2176
- document.expandedAuroFormkitDropdown || document.expandedAuroFloater;
2177
- if (
2178
- existedVisibleFloatingUI &&
2179
- existedVisibleFloatingUI !== this &&
2180
- existedVisibleFloatingUI.element.isPopoverVisible &&
2181
- existedVisibleFloatingUI.eventPrefix === this.eventPrefix
2182
- ) {
2183
- existedVisibleFloatingUI.hideBib();
2184
- }
2185
-
2186
- document.expandedAuroFloater = this;
2187
- }
2188
-
2189
- showBib() {
2190
- if (!this.element.disabled && !this.showing) {
2191
- this.updateCurrentExpandedDropdown();
2192
- this.element.triggerChevron?.setAttribute("data-expanded", true);
2193
-
2194
- // prevent double showing: isPopovervisible gets first and showBib gets called later
2195
- if (!this.showing) {
2196
- if (!this.element.modal) {
2197
- this.setupHideHandlers();
2198
- }
2199
- this.showing = true;
2200
- this.element.isPopoverVisible = true;
2201
- this.position();
2202
- this.dispatchEventDropdownToggle();
2203
- }
2204
-
2205
- // Setup auto update to handle resize and scroll
2206
- this.element.cleanup = autoUpdate(
2207
- this.element.trigger || this.element.parentNode,
2208
- this.element.bib,
2209
- () => {
2210
- this.position();
2211
- },
2212
- );
2213
- }
2214
- }
2215
-
2216
- /**
2217
- * Hides the floating UI element.
2218
- * @param {String} eventType - The event type that triggered the hiding action.
2219
- */
2220
- hideBib(eventType = "unknown") {
2221
- if (this.element.disabled) {
2222
- return;
2223
- }
2224
-
2225
- // noToggle dropdowns should not close when the trigger is clicked (the
2226
- // "toggle" behavior), but they CAN still close via other interactions like
2227
- // Escape key or focus loss.
2228
- if (this.element.noToggle && eventType === "click") {
2229
- return;
2230
- }
2231
-
2232
- this.lockScroll(false);
2233
- this.element.triggerChevron?.removeAttribute("data-expanded");
2234
-
2235
- if (this.element.isPopoverVisible) {
2236
- this.element.isPopoverVisible = false;
2237
- }
2238
- if (this.showing) {
2239
- this.cleanupHideHandlers();
2240
- this.showing = false;
2241
- this.dispatchEventDropdownToggle(eventType);
2242
- }
2243
-
2244
- // Only clear the global reference if the bib was actually hidden.
2245
- // Clearing it when hideBib is blocked (e.g. noToggle + click) corrupts
2246
- // the singleton state so other dropdowns can't detect this one is still open.
2247
- document.expandedAuroFloater = null;
2248
- }
2249
-
2250
- /**
2251
- * @private
2252
- * @returns {void} Dispatches event with an object showing the state of the dropdown.
2253
- * @param {String} eventType - The event type that triggered the toggle action.
2254
- */
2255
- dispatchEventDropdownToggle(eventType) {
2256
- const event = new CustomEvent(
2257
- this.eventPrefix ? `${this.eventPrefix}-toggled` : "toggled",
2258
- {
2259
- detail: {
2260
- expanded: this.showing,
2261
- eventType: eventType || "unknown",
2262
- },
2263
- composed: true,
2264
- },
2265
- );
2266
-
2267
- this.element.dispatchEvent(event);
2268
- }
2269
-
2270
- handleClick() {
2271
- if (this.element.isPopoverVisible) {
2272
- this.hideBib("click");
2273
- } else {
2274
- this.showBib();
2275
- }
2276
-
2277
- const event = new CustomEvent(
2278
- this.eventPrefix ? `${this.eventPrefix}-triggerClick` : "triggerClick",
2279
- {
2280
- composed: true,
2281
- detail: {
2282
- expanded: this.element.isPopoverVisible,
2283
- },
2284
- },
2285
- );
2286
-
2287
- this.element.dispatchEvent(event);
2288
- }
2289
-
2290
- handleEvent(event) {
2291
- if (!this.element.disableEventShow) {
2292
- switch (event.type) {
2293
- case "keydown": {
2294
- // Support both Enter and Space keys for accessibility
2295
- // Space is included as it's expected behavior for interactive elements
2296
-
2297
- const origin = event.composedPath()[0];
2298
- if (
2299
- event.key === "Enter" ||
2300
- (event.key === " " && (!origin || origin.tagName !== "INPUT"))
2301
- ) {
2302
- event.preventDefault();
2303
- this.handleClick();
2304
- }
2305
- break;
2306
- }
2307
- case "mouseenter":
2308
- if (this.element.hoverToggle) {
2309
- this.showBib();
2310
- }
2311
- break;
2312
- case "mouseleave":
2313
- if (this.element.hoverToggle) {
2314
- this.hideBib("mouseleave");
2315
- }
2316
- break;
2317
- case "focus":
2318
- if (this.element.focusShow) {
2319
- /*
2320
- This needs to better handle clicking that gives focus -
2321
- currently it shows and then immediately hides the bib
2322
- */
2323
- this.showBib();
2324
- }
2325
- break;
2326
- case "blur":
2327
- // send this task 100ms later queue to
2328
- // wait a frame in case focus moves within the floating element/bib
2329
- setTimeout(() => this.handleFocusLoss(), 0);
2330
- break;
2331
- case "click":
2332
- if (document.activeElement === document.body) {
2333
- event.currentTarget.focus();
2334
- }
2335
- this.handleClick();
2336
- break;
2337
- // Do nothing
2338
- }
2339
- }
2340
- }
2341
-
2342
- /**
2343
- * Manages the tabIndex of the trigger element based on its focusability.
2344
- *
2345
- * If the trigger element or any of its children are inherently focusable, the tabIndex of the component is set to -1.
2346
- * This prevents the component itself from being focusable when the trigger element already handles focus.
2347
- */
2348
- handleTriggerTabIndex() {
2349
- const focusableElementSelectors = [
2350
- "a",
2351
- "button",
2352
- 'input:not([type="hidden"])',
2353
- "select",
2354
- "textarea",
2355
- '[tabindex]:not([tabindex="-1"])',
2356
- "auro-button",
2357
- "auro-input",
2358
- "auro-hyperlink",
2359
- ];
2360
-
2361
- const triggerNode = this.element.querySelectorAll('[slot="trigger"]')[0];
2362
- if (!triggerNode) {
2363
- return;
2364
- }
2365
- const triggerNodeTagName = triggerNode.tagName.toLowerCase();
2366
-
2367
- focusableElementSelectors.forEach((selector) => {
2368
- // Check if the trigger node element is focusable
2369
- if (triggerNodeTagName === selector) {
2370
- this.element.tabIndex = -1;
2371
- return;
2372
- }
2373
-
2374
- // Check if any child is focusable
2375
- if (triggerNode.querySelector(selector)) {
2376
- this.element.tabIndex = -1;
2377
- }
2378
- });
2379
- }
2380
-
2381
- /**
2382
- *
2383
- * @param {*} eventPrefix
2384
- */
2385
- regenerateBibId() {
2386
- this.id = this.element.getAttribute("id");
2387
- if (!this.id) {
2388
- this.id = window.crypto.randomUUID();
2389
- this.element.setAttribute("id", this.id);
2390
- }
2391
-
2392
- this.element.bib.setAttribute("id", `${this.id}-floater-bib`);
2393
- }
2394
-
2395
- configure(elem, eventPrefix, enableKeyboardHandling = true) {
2396
- AuroFloatingUI.setupMousePressChecker();
2397
- this.enableKeyboardHandling = enableKeyboardHandling;
2398
-
2399
- this.eventPrefix = eventPrefix;
2400
- if (this.element !== elem) {
2401
- this.element = elem;
2402
- }
2403
-
2404
- if (this.behavior !== this.element.behavior) {
2405
- this.behavior = this.element.behavior;
2406
- }
2407
-
2408
- if (this.element.trigger) {
2409
- this.disconnect();
2410
- }
2411
- this.element.trigger =
2412
- this.element.triggerElement ||
2413
- this.element.shadowRoot.querySelector("#trigger") ||
2414
- this.element.trigger;
2415
- this.element.bib =
2416
- this.element.shadowRoot.querySelector("#bib") || this.element.bib;
2417
- this.element.bibSizer = this.element.shadowRoot.querySelector("#bibSizer");
2418
- this.element.triggerChevron =
2419
- this.element.shadowRoot.querySelector("#showStateIcon");
2420
-
2421
- if (this.element.floaterConfig) {
2422
- this.element.hoverToggle = this.element.floaterConfig.hoverToggle;
2423
- }
2424
-
2425
- this.regenerateBibId();
2426
- this.handleTriggerTabIndex();
2427
-
2428
- this.handleEvent = this.handleEvent.bind(this);
2429
- if (this.element.trigger) {
2430
- if (this.enableKeyboardHandling) {
2431
- this.element.trigger.addEventListener("keydown", this.handleEvent);
2432
- }
2433
- this.element.trigger.addEventListener("click", this.handleEvent);
2434
- this.element.trigger.addEventListener("mouseenter", this.handleEvent);
2435
- this.element.trigger.addEventListener("mouseleave", this.handleEvent);
2436
- this.element.trigger.addEventListener("focus", this.handleEvent);
2437
- this.element.trigger.addEventListener("blur", this.handleEvent);
2438
- }
2439
- }
2440
-
2441
- disconnect() {
2442
- this.cleanupHideHandlers();
2443
- if (this.element) {
2444
- this.element.cleanup?.();
2445
-
2446
- if (this.element.bib) {
2447
- this.element.shadowRoot.append(this.element.bib);
2448
- }
2449
-
2450
- // Remove event & keyboard listeners
2451
- if (this.element?.trigger) {
2452
- this.element.trigger.removeEventListener("keydown", this.handleEvent);
2453
- this.element.trigger.removeEventListener("click", this.handleEvent);
2454
- this.element.trigger.removeEventListener(
2455
- "mouseenter",
2456
- this.handleEvent,
2457
- );
2458
- this.element.trigger.removeEventListener(
2459
- "mouseleave",
2460
- this.handleEvent,
2461
- );
2462
- this.element.trigger.removeEventListener("focus", this.handleEvent);
2463
- this.element.trigger.removeEventListener("blur", this.handleEvent);
2464
- }
2465
- }
2466
- }
2467
- }
2468
-
2469
- // Selectors for focusable elements
2470
- const FOCUSABLE_SELECTORS = [
2471
- "a[href]",
2472
- "button:not([disabled])",
2473
- "textarea:not([disabled])",
2474
- "input:not([disabled])",
2475
- "select:not([disabled])",
2476
- '[role="tab"]:not([disabled])',
2477
- '[role="link"]:not([disabled])',
2478
- '[role="button"]:not([disabled])',
2479
- '[tabindex]:not([tabindex="-1"])',
2480
- '[contenteditable]:not([contenteditable="false"])',
2481
- ];
2482
-
2483
- // List of custom components that are known to be focusable
2484
- const FOCUSABLE_COMPONENTS = [
2485
- "auro-checkbox",
2486
- "auro-radio",
2487
- "auro-dropdown",
2488
- "auro-button",
2489
- "auro-combobox",
2490
- "auro-input",
2491
- "auro-counter",
2492
- // 'auro-menu', // Auro menu is not focusable by default, it uses a different interaction model
2493
- "auro-select",
2494
- "auro-datepicker",
2495
- "auro-hyperlink",
2496
- "auro-accordion",
2497
- ];
2498
-
2499
- /**
2500
- * Determines if a given element is a custom focusable component.
2501
- * Returns true if the element matches a known focusable component and is not disabled.
2502
- *
2503
- * @param {HTMLElement} element The element to check for focusability.
2504
- * @returns {boolean} True if the element is a focusable custom component, false otherwise.
2505
- */
2506
- function isFocusableComponent(element) {
2507
- const componentName = element.tagName.toLowerCase();
2508
-
2509
- // Guard Clause: Element is a focusable component
2510
- if (
2511
- !FOCUSABLE_COMPONENTS.some(
2512
- (name) => element.hasAttribute(name) || componentName === name,
2513
- )
2514
- )
2515
- return false;
2516
-
2517
- // Guard Clause: Element is not disabled
2518
- if (element.hasAttribute("disabled")) return false;
2519
-
2520
- // Guard Clause: The element is a hyperlink and has no href attribute
2521
- if (componentName.match("hyperlink") && !element.hasAttribute("href"))
2522
- return false;
2523
-
2524
- // If all guard clauses pass, the element is a focusable component
2525
- return true;
2526
- }
2527
-
2528
- /**
2529
- * Safely get a numeric tabindex for an element.
2530
- * Returns a number if the tabindex is a valid integer, otherwise null.
2531
- *
2532
- * @param {HTMLElement} element The element whose tabindex to read.
2533
- * @returns {?number} The numeric tabindex or null if missing/invalid.
2534
- */
2535
- function getNumericTabIndex(element) {
2536
- const raw = element.getAttribute("tabindex");
2537
- if (raw == null) return null;
2538
-
2539
- const value = Number.parseInt(raw, 10);
2540
- return Number.isNaN(value) ? null : value;
2541
- }
2542
-
2543
- /**
2544
- * Retrieves all focusable elements within the container in DOM order, including those in shadow DOM and slots.
2545
- * Returns a unique, ordered array of elements that can receive focus.
2546
- * Also sorts elements with tabindex first, preserving their order.
2547
- *
2548
- * @param {HTMLElement} container The container to search within
2549
- * @returns {Array<HTMLElement>} An array of focusable elements within the container.
2550
- */
2551
- function getFocusableElements(container) {
2552
- // Get elements in DOM order by walking the tree
2553
- const orderedFocusableElements = [];
2554
-
2555
- // Define a recursive function to collect focusable elements in DOM order
2556
- const collectFocusableElements = (root) => {
2557
- // Check if current element is focusable
2558
- if (root.nodeType === Node.ELEMENT_NODE) {
2559
- // Check if this is a custom component that is focusable
2560
- const isComponentFocusable = isFocusableComponent(root);
2561
-
2562
- if (isComponentFocusable) {
2563
- // Add the component itself as a focusable element and don't traverse its shadow DOM
2564
- orderedFocusableElements.push(root);
2565
- return; // Skip traversing inside this component
2566
- }
2567
-
2568
- // Check if the element itself matches any selector
2569
- for (const selector of FOCUSABLE_SELECTORS) {
2570
- if (root.matches?.(selector)) {
2571
- orderedFocusableElements.push(root);
2572
- break; // Once we know it's focusable, no need to check other selectors
2573
- }
2574
- }
2575
-
2576
- // Process shadow DOM only for non-Auro components
2577
- if (root.shadowRoot) {
2578
- // Process shadow DOM children in order
2579
- if (root.shadowRoot.children) {
2580
- Array.from(root.shadowRoot.children).forEach((child) => {
2581
- collectFocusableElements(child);
2582
- });
2583
- }
2584
- }
2585
-
2586
- // Process slots and their assigned nodes in order
2587
- if (root.tagName === "SLOT") {
2588
- const assignedNodes = root.assignedNodes({ flatten: true });
2589
- for (const node of assignedNodes) {
2590
- collectFocusableElements(node);
2591
- }
2592
- } else {
2593
- // Process light DOM children in order
2594
- if (root.children) {
2595
- Array.from(root.children).forEach((child) => {
2596
- collectFocusableElements(child);
2597
- });
2598
- }
2599
- }
2600
- }
2601
- };
2602
-
2603
- // Start the traversal from the container
2604
- collectFocusableElements(container);
2605
-
2606
- // Remove duplicates that might have been collected through different paths
2607
- // while preserving order
2608
- const uniqueElements = [];
2609
- const seen = new Set();
2610
-
2611
- for (const element of orderedFocusableElements) {
2612
- if (!seen.has(element)) {
2613
- seen.add(element);
2614
- uniqueElements.push(element);
2615
- }
2616
- }
2617
-
2618
- // Move tab-indexed elements to the front while preserving their order
2619
- // This ensures that elements with tabindex are prioritized in the focus order
2620
-
2621
- // First extract elements with valid positive tabindex
2622
- const elementsWithTabindex = uniqueElements.filter((el) => {
2623
- const tabindex = getNumericTabIndex(el);
2624
- return tabindex !== null && tabindex > 0;
2625
- });
2626
-
2627
- // Sort these elements by their tabindex value
2628
- elementsWithTabindex.sort((a, b) => {
2629
- const aIndex = getNumericTabIndex(a) ?? 0;
2630
- const bIndex = getNumericTabIndex(b) ?? 0;
2631
- return aIndex - bIndex;
2632
- });
2633
-
2634
- // Elements without tabindex (preserving their original order)
2635
- const elementsWithoutTabindex = uniqueElements.filter((el) => {
2636
- const tabindex = getNumericTabIndex(el);
2637
-
2638
- // Elements without tabindex or with tabindex of 0 stay in DOM order
2639
- return tabindex === null || tabindex === 0;
2640
- });
2641
-
2642
- // Combine both arrays with tabindex elements first
2643
- const tabIndexedUniqueElements = [
2644
- ...elementsWithTabindex,
2645
- ...elementsWithoutTabindex,
2646
- ];
2647
-
2648
- return tabIndexedUniqueElements;
2649
- }
2650
-
2651
- /**
2652
- * FocusTrap manages keyboard focus within a specified container element, ensuring that focus does not leave the container when tabbing.
2653
- * It is commonly used for modal dialogs or overlays to improve accessibility by trapping focus within interactive UI components.
2654
- */
2655
- class FocusTrap {
2656
- /**
2657
- * Creates a new FocusTrap instance for the given container element.
2658
- * Initializes event listeners and prepares the container for focus management.
2659
- *
2660
- * @param {HTMLElement} container The DOM element to trap focus within.
2661
- * @param {boolean} [controlTabOrder=false] If true enables manual control of the tab order by the FocusTrap.
2662
- * @throws {Error} If the provided container is not a valid HTMLElement.
2663
- */
2664
- constructor(container, controlTabOrder = false) {
2665
- if (!container || !(container instanceof HTMLElement)) {
2666
- throw new Error("FocusTrap requires a valid HTMLElement.");
2667
- }
2668
-
2669
- this.container = container;
2670
- this.tabDirection = "forward"; // or 'backward';
2671
- this.controlTabOrder = controlTabOrder;
2672
-
2673
- this._init();
2674
- }
2675
-
2676
- /**
2677
- * Initializes the focus trap by setting up event listeners and attributes on the container.
2678
- * Prepares the container for focus management, including support for shadow DOM and inert attributes.
2679
- *
2680
- * @private
2681
- */
2682
- _init() {
2683
- // Add inert attribute to prevent focusing programmatically as well (if supported)
2684
- if ("inert" in HTMLElement.prototype) {
2685
- this.container.inert = false; // Ensure the container isn't inert
2686
- this.container.setAttribute("data-focus-trap-container", true); // Mark for identification
2687
- }
2688
-
2689
- // Track tab direction
2690
- this.container.addEventListener("keydown", this._onKeydown);
2691
- }
2692
-
2693
- /**
2694
- * Gets an array of currently active (focused) elements in the document and shadow DOM.
2695
- * @returns {Array<HTMLElement>} An array of focusable elements within the container.
2696
- * @private
2697
- */
2698
- _getActiveElements() {
2699
- // Get the active element(s) in the document and shadow root
2700
- // This will include the active element in the shadow DOM if it exists
2701
- // Active element may be inside the shadow DOM depending on delegatesFocus, so we need to check both
2702
- let { activeElement } = document;
2703
- const actives = [activeElement];
2704
- while (activeElement?.shadowRoot?.activeElement) {
2705
- actives.push(activeElement.shadowRoot.activeElement);
2706
- activeElement = activeElement.shadowRoot.activeElement;
2707
- }
2708
- return actives;
2709
- }
2710
-
2711
- /**
2712
- * Gets the next focus index based on the current index and focusable elements.
2713
- * @param {number} currentIndex The current index of the focused element.
2714
- * @param {Array<HTMLElement>} focusables The array of focusable elements.
2715
- * @returns {number|null} The next focus index or null if not determined.
2716
- */
2717
- _getNextFocusIndex(currentIndex, focusables, actives) {
2718
- if (this.controlTabOrder) {
2719
- // Calculate the new index based on the current index and tab direction
2720
- let newFocusIndex =
2721
- currentIndex + (this.tabDirection === "forward" ? 1 : -1);
2722
-
2723
- // Wrap-around logic
2724
- if (newFocusIndex < 0) newFocusIndex = focusables.length - 1;
2725
- if (newFocusIndex >= focusables.length) newFocusIndex = 0;
2726
-
2727
- // Early return with the new index
2728
- return newFocusIndex;
2729
- }
2730
-
2731
- // Determine if we need to wrap
2732
- const atFirst =
2733
- actives.includes(focusables[0]) || actives.includes(this.container);
2734
- const atLast = actives.includes(focusables[focusables.length - 1]);
2735
-
2736
- // Only wrap if at the ends
2737
- if (this.tabDirection === "backward" && atFirst) {
2738
- return focusables.length - 1;
2739
- }
2740
-
2741
- if (this.tabDirection === "forward" && atLast) {
2742
- return 0;
2743
- }
2744
-
2745
- // No wrap, so don't change focus, return early
2746
- return null;
2747
- }
2748
-
2749
- /**
2750
- * Handles the Tab key press event to manage focus within the container.
2751
- * @param {KeyboardEvent} e The keyboard event triggered by the user.
2752
- * @returns {void}
2753
- */
2754
- _handleTabKey(e) {
2755
- // Update the focusable elements
2756
- const focusables = this._getFocusableElements();
2757
-
2758
- // If there are no focusable elements, exit
2759
- if (!focusables.length) return;
2760
-
2761
- // Set the tab direction based on the key pressed
2762
- this.tabDirection = e.shiftKey ? "backward" : "forward";
2763
-
2764
- // Get the active elements that are currently focused
2765
- const actives = this._getActiveElements();
2766
-
2767
- // If we're at either end of the focusable elements, wrap around to the other end
2768
- let focusIndex = focusables.findIndex((el) => actives.includes(el));
2769
-
2770
- // Fallback if we have no focused element
2771
- if (focusIndex === -1) focusIndex = 0;
2772
-
2773
- // Get the next focus index based on the current focus index, tab direction, and controlTabOrder setting
2774
- // Is null if no new focus index is determined
2775
- const newFocusIndex = this._getNextFocusIndex(
2776
- focusIndex,
2777
- focusables,
2778
- actives,
2779
- );
2780
-
2781
- // If we have a new focus index, set focus to that element
2782
- if (newFocusIndex !== null) {
2783
- e.preventDefault();
2784
- focusables[newFocusIndex].focus();
2785
- }
2786
- }
2787
-
2788
- /**
2789
- * Catches the keydown event
2790
- * @param {KeyboardEvent} e The keyboard event triggered by user interaction.
2791
- * @private
2792
- */
2793
- _onKeydown = (e) => {
2794
- // Handle tab
2795
- if (e.key === "Tab") this._handleTabKey(e);
2796
- };
2797
-
2798
- /**
2799
- * Retrieves all focusable elements within the container in DOM order, including those in shadow DOM and slots.
2800
- * Returns a unique, ordered array of elements that can receive focus.
2801
- *
2802
- * @returns {Array<HTMLElement>} An array of focusable elements within the container.
2803
- * @private
2804
- */
2805
- _getFocusableElements() {
2806
- // Use the imported utility function to get focusable elements
2807
- const elements = getFocusableElements(this.container);
2808
-
2809
- // Return the elements found
2810
- return elements;
2811
- }
2812
-
2813
- /**
2814
- * Moves focus to the first focusable element within the container.
2815
- * Useful for setting initial focus when activating the focus trap.
2816
- */
2817
- focusFirstElement() {
2818
- const focusables = this._getFocusableElements();
2819
- if (focusables.length) focusables[0].focus();
2820
- }
2821
-
2822
- /**
2823
- * Moves focus to the last focusable element within the container.
2824
- * Useful for setting focus when deactivating or cycling focus in reverse.
2825
- */
2826
- focusLastElement() {
2827
- const focusables = this._getFocusableElements();
2828
- if (focusables.length) focusables[focusables.length - 1].focus();
2829
- }
2830
-
2831
- /**
2832
- * Removes event listeners and attributes added by the focus trap.
2833
- * Call this method to clean up when the focus trap is no longer needed.
2834
- */
2835
- disconnect() {
2836
- if (this.container.hasAttribute("data-focus-trap-container")) {
2837
- this.container.removeAttribute("data-focus-trap-container");
2838
- }
2839
-
2840
- this.container.removeEventListener("keydown", this._onKeydown);
2841
- }
2842
- }
2843
-
2844
- // Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
2845
- // See LICENSE in the project root for license information.
2846
-
2847
-
2848
- class AuroDependencyVersioning {
2849
-
2850
- /**
2851
- * Generates a unique string to be used for child auro element naming.
2852
- * @private
2853
- * @param {string} baseName - Defines the first part of the unique element name.
2854
- * @param {string} version - Version of the component that will be appended to the baseName.
2855
- * @returns {string} - Unique string to be used for naming.
2856
- */
2857
- generateElementName(baseName, version) {
2858
- let result = baseName;
2859
-
2860
- result += '-';
2861
- result += version.replace(/[.]/g, '_');
2862
-
2863
- return result;
2864
- }
2865
-
2866
- /**
2867
- * Generates a unique string to be used for child auro element naming.
2868
- * @param {string} baseName - Defines the first part of the unique element name.
2869
- * @param {string} version - Version of the component that will be appended to the baseName.
2870
- * @returns {string} - Unique string to be used for naming.
2871
- */
2872
- generateTag(baseName, version, tagClass) {
2873
- const elementName = this.generateElementName(baseName, version);
2874
- const tag = literal`${unsafeStatic(elementName)}`;
2875
-
2876
- if (!customElements.get(elementName)) {
2877
- customElements.define(elementName, class extends tagClass {});
2878
- }
2879
-
2880
- return tag;
2881
- }
2882
- }
2883
-
2884
- class p{registerComponent(t,a){customElements.get(t)||customElements.define(t,class extends a{});}closestElement(t,a=this,e=(a,s=a&&a.closest(t))=>a&&a!==document&&a!==window?s||e(a.getRootNode().host):null){return e(a)}handleComponentTagRename(t,a){const e=a.toLowerCase();t.tagName.toLowerCase()!==e&&t.setAttribute(e,true);}elementMatch(t,a){const e=a.toLowerCase();return t.tagName.toLowerCase()===e||t.hasAttribute(e)}getSlotText(t,a){const e=t.shadowRoot?.querySelector(`slot[name="${a}"]`);return (e?.assignedNodes({flatten:true})||[]).map(t=>t.textContent?.trim()).join(" ").trim()||null}}var u='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-labelledby="error__desc" class="ico_squareLarge" data-deprecated="true" role="img" style="min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor" viewBox="0 0 24 24" part="svg"><title/><desc id="error__desc">Error alert indicator.</desc><path d="m13.047 5.599 6.786 11.586A1.207 1.207 0 0 1 18.786 19H5.214a1.207 1.207 0 0 1-1.047-1.815l6.786-11.586a1.214 1.214 0 0 1 2.094 0m-1.165.87a.23.23 0 0 0-.085.085L5.419 17.442a.232.232 0 0 0 .203.35h12.756a.234.234 0 0 0 .203-.35L12.203 6.554a.236.236 0 0 0-.321-.084M12 15.5a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m-.024-6.22c.325 0 .589.261.589.583v4.434a.586.586 0 0 1-.589.583.586.586 0 0 1-.588-.583V9.863c0-.322.264-.583.588-.583"/></svg>';class m extends LitElement{static get properties(){return {hidden:{type:Boolean,reflect:true},hiddenVisually:{type:Boolean,reflect:true},hiddenAudible:{type:Boolean,reflect:true}}}hideAudible(t){return t?"true":"false"}}const g=new Map,f=(t,a={})=>{const e=a.responseParser||(t=>t.text());return g.has(t)||g.set(t,fetch(t).then(e)),g.get(t)};var w=css`:focus:not(:focus-visible){outline:3px solid transparent}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}.ico_squareLarge{fill:currentColor;height:var(--auro-size-lg, var(--ds-size-300, 1.5rem))}.ico_squareSmall{fill:currentColor;height:.6rem}.ico_squareMed{fill:currentColor;height:var(--auro-size-md, var(--ds-size-200, 1rem))}.ico_squareSml{fill:currentColor;height:var(--auro-size-sm, var(--ds-size-150, .75rem))}:host{color:currentColor;vertical-align:middle;display:inline-block}svg{min-width:var(--ds-auro-icon-size, 1.5rem)!important;width:var(--ds-auro-icon-size, 1.5rem)!important;height:var(--ds-auro-icon-size, 1.5rem)!important}.componentWrapper{display:flex;line-height:var(--ds-auro-icon-size)}.svgWrapper{height:var(--ds-auro-icon-size);width:var(--ds-auro-icon-size)}.svgWrapper [part=svg]{display:flex}.labelWrapper{margin-left:var(--ds-size-50, .25rem)}.labelWrapper ::slotted(*){line-height:inherit!important}
2885
- `;class z extends m{constructor(){super(),this._initializeDefaults();}_initializeDefaults(){this.onDark=false,this.appearance="default";}static get properties(){return {...m.properties,onDark:{type:Boolean,reflect:true},appearance:{type:String,reflect:true},svg:{attribute:false,reflect:true}}}static get styles(){return w}async fetchIcon(t,a){let e="";e="logos"===t?await f(`${this.uri}/${t}/${a}.svg`):await f(`${this.uri}/icons/${t}/${a}.svg`);return (new DOMParser).parseFromString(e,"text/html").body.querySelector("svg")}async firstUpdated(){try{if(!this.customSvg){const t=await this.fetchIcon(this.category,this.name);if(t)this.svg=t;else if(!t){const t=(new DOMParser).parseFromString(u,"text/html");this.svg=t.body.firstChild;}}}catch(t){this.svg=void 0;}}}css`.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}:host{display:inline-block;--ds-auro-icon-size: 100%;width:100%;height:100%}:host .logo{color:var(--ds-auro-alaska-color)}:host([onDark]),:host([appearance=inverse]){--ds-auro-alaska-color: #FFF}
2886
- `;var y=css`:host{--ds-auro-icon-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-alaska-color: #02426D;--ds-auro-icon-size: var(--ds-size-300, 1.5rem)}
2887
- `;var x=css`:host{color:var(--ds-auro-icon-color)}:host([customColor]){color:inherit}:host(:not([onDark])[variant=accent1]),:host(:not([appearance=inverse])[variant=accent1]){--ds-auro-icon-color: var(--ds-basic-color-texticon-accent1, #265688)}:host(:not([onDark])[variant=disabled]),:host(:not([appearance=inverse])[variant=disabled]){--ds-auro-icon-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(:not([onDark])[variant=muted]),:host(:not([appearance=inverse])[variant=muted]){--ds-auro-icon-color: var(--ds-basic-color-texticon-muted, #676767)}:host(:not([onDark])[variant=statusDefault]),:host(:not([appearance=inverse])[variant=statusDefault]){--ds-auro-icon-color: var(--ds-basic-color-status-default, #afb9c6)}:host(:not([onDark])[variant=statusInfo]),:host(:not([appearance=inverse])[variant=statusInfo]){--ds-auro-icon-color: var(--ds-basic-color-status-info, #01426a)}:host(:not([onDark])[variant=statusSuccess]),:host(:not([appearance=inverse])[variant=statusSuccess]){--ds-auro-icon-color: var(--ds-basic-color-status-success, #447a1f)}:host(:not([onDark])[variant=statusWarning]),:host(:not([appearance=inverse])[variant=statusWarning]){--ds-auro-icon-color: var(--ds-basic-color-status-warning, #fac200)}:host(:not([onDark])[variant=statusError]),:host(:not([appearance=inverse])[variant=statusError]){--ds-auro-icon-color: var(--ds-basic-color-status-error, #e31f26)}:host(:not([onDark])[variant=statusInfoSubtle]),:host(:not([appearance=inverse])[variant=statusInfoSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-info-subtle, #ebf3f9)}:host(:not([onDark])[variant=statusSuccessSubtle]),:host(:not([appearance=inverse])[variant=statusSuccessSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-success-subtle, #d6eac7)}:host(:not([onDark])[variant=statusWarningSubtle]),:host(:not([appearance=inverse])[variant=statusWarningSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-warning-subtle, #fff0b2)}:host(:not([onDark])[variant=statusErrorSubtle]),:host(:not([appearance=inverse])[variant=statusErrorSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-error-subtle, #fbc6c6)}:host(:not([onDark])[variant=fareBasicEconomy]),:host(:not([appearance=inverse])[variant=fareBasicEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-basiceconomy, #97eaf8)}:host(:not([onDark])[variant=fareBusiness]),:host(:not([appearance=inverse])[variant=fareBusiness]){--ds-auro-icon-color: var(--ds-basic-color-fare-business, #01426a)}:host(:not([onDark])[variant=fareEconomy]),:host(:not([appearance=inverse])[variant=fareEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-economy, #0074ca)}:host(:not([onDark])[variant=fareFirst]),:host(:not([appearance=inverse])[variant=fareFirst]){--ds-auro-icon-color: var(--ds-basic-color-fare-first, #00274a)}:host(:not([onDark])[variant=farePremiumEconomy]),:host(:not([appearance=inverse])[variant=farePremiumEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-premiumeconomy, #005154)}:host(:not([onDark])[variant=tierOneWorldEmerald]),:host(:not([appearance=inverse])[variant=tierOneWorldEmerald]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-emerald, #139142)}:host(:not([onDark])[variant=tierOneWorldSapphire]),:host(:not([appearance=inverse])[variant=tierOneWorldSapphire]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-sapphire, #015daa)}:host(:not([onDark])[variant=tierOneWorldRuby]),:host(:not([appearance=inverse])[variant=tierOneWorldRuby]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-ruby, #a41d4a)}:host([onDark]),:host([appearance=inverse]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse, #ffffff)}:host([onDark][variant=disabled]),:host([appearance=inverse][variant=disabled]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}:host([onDark][variant=muted]),:host([appearance=inverse][variant=muted]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse-muted, #ccd2db)}:host([onDark][variant=statusError]),:host([appearance=inverse][variant=statusError]){--ds-auro-icon-color: var(--ds-advanced-color-state-error-inverse, #f9a4a8)}
2888
- `;class _ extends z{constructor(){super(),this._initializeDefaults();}_initializeDefaults(){this.variant=void 0,this.uri="https://cdn.jsdelivr.net/npm/@alaskaairux/icons@latest/dist",this.runtimeUtils=new p;}static get properties(){return {...z.properties,ariaHidden:{type:String,reflect:true},category:{type:String,reflect:true},customColor:{type:Boolean,reflect:true},customSvg:{type:Boolean},label:{type:Boolean,reflect:true},name:{type:String,reflect:true},variant:{type:String,reflect:true}}}static get styles(){return [z.styles,y,w,x]}static register(t="auro-icon"){p.prototype.registerComponent(t,_);}connectedCallback(){super.connectedCallback(),this.runtimeUtils.handleComponentTagRename(this,"auro-icon");}exposeCssParts(){this.setAttribute("exportparts","svg:iconSvg");}async firstUpdated(){if(await super.firstUpdated(),this.hasAttribute("ariaHidden")&&this.svg){const t=this.svg.querySelector("desc");t&&(t.remove(),this.svg.removeAttribute("aria-labelledby"));}}render(){const t={labelWrapper:true,util_displayHiddenVisually:!this.label};return html`
2889
- <div class="componentWrapper">
2890
- <div
2891
- class="${classMap({svgWrapper:true})}"
2892
- title="${ifDefined(this.title||void 0)}">
2893
- <span aria-hidden="${ifDefined(this.ariaHidden||true)}" part="svg">
2894
- ${this.customSvg?html`
2895
- <slot name="svg"></slot>
2896
- `:html`
2897
- ${this.svg}
2898
- `}
2899
- </span>
2900
- </div>
2901
-
2902
- <div class="${classMap(t)}" part="label">
2903
- <slot></slot>
2904
- </div>
2905
- </div>
2906
- `}}
2907
-
2908
- var iconVersion = '9.1.2';
2909
-
2910
- /**
2911
- * Computes display state once per keydown event.
2912
- * Centralizes null-safety checks and makes the shared/modal/popover branching explicit.
2913
- *
2914
- * @param {HTMLElement} component - The component with a dropdown reference.
2915
- * @param {Object} [options] - Optional config.
2916
- * @param {HTMLElement} [options.dropdown] - Explicit dropdown reference. Falls back to component.dropdown.
2917
- * @param {Function} [options.inputResolver] - Called with (component, ctx) to resolve the active input element.
2918
- * @returns {{isExpanded: boolean, isModal: boolean, isPopover: boolean, activeInput: HTMLElement|null}}
2919
- * isModal and isPopover reflect the display mode (fullscreen vs not) regardless of expanded state.
2920
- */
2921
- function createDisplayContext(component, options = {}) {
2922
- const dd = options.dropdown || component.dropdown;
2923
- // isPopoverVisible reflects as the `open` attribute.
2924
- // It reports whether the bib is open in any mode (popover or modal).
2925
- const isExpanded = Boolean(dd && dd.isPopoverVisible);
2926
- const isFullscreen = Boolean(dd && dd.isBibFullscreen);
2927
-
2928
- const ctx = {
2929
- isExpanded,
2930
- isModal: isFullscreen,
2931
- isPopover: !isFullscreen,
2932
- activeInput: null,
2933
- };
2934
-
2935
- if (options.inputResolver) {
2936
- const resolvedInput = options.inputResolver(component, ctx);
2937
- // Guard against resolvers returning undefined or non-HTMLElement values.
2938
- ctx.activeInput = resolvedInput instanceof HTMLElement ? resolvedInput : null;
2939
- }
2940
-
2941
- return ctx;
2942
- }
2943
-
2944
- /**
2945
- * Wires up a keydown listener that dispatches to strategy[evt.key] or strategy.default.
2946
- * Handles both sync and async handlers.
2947
- * @param {HTMLElement} component - The component to attach the listener to.
2948
- * @param {Object} strategy - Map of key names to handler functions.
2949
- * @param {Object} [options] - Optional config passed to createDisplayContext.
2950
- */
2951
- function applyKeyboardStrategy(component, strategy, options = {}) {
2952
- component.addEventListener('keydown', async (evt) => {
2953
- const handler = strategy[evt.key] || strategy.default;
2954
- if (typeof handler === 'function') {
2955
- const ctx = createDisplayContext(component, options);
2956
- await handler(component, evt, ctx);
2957
- }
2958
- });
2959
- }
2960
-
2961
- var styleCss$2 = css`:host{position:fixed;z-index:var(--depth-tooltip, 400);display:none;isolation:isolate}:host dialog{width:auto;max-width:none;height:auto;max-height:none;padding:0;border:none;margin:0;outline:none;transform:translateZ(0)}:host dialog::backdrop{background:transparent}:host(:not([isfullscreen])) dialog{position:relative;inset:unset}:host(:not([isfullscreen])) .container.shape-box{border-radius:unset}:host(:not([isfullscreen])) .container[class*=shape-pill],:host(:not([isfullscreen])) .container[class*=shape-snowflake]{border-radius:30px}:host(:not([isfullscreen])) .container[class*=shape-rounded]{border-radius:16px}:host(:not([matchWidth])) .container{min-width:fit-content}:host([isfullscreen]){position:fixed;top:0;left:0}:host([isfullscreen]) .container{width:100dvw;max-width:none;height:100dvh;max-height:none;border-radius:unset;margin-top:0;box-shadow:unset;overscroll-behavior:contain}:host([isfullscreen]) .container::backdrop{background:var(--ds-color-background-primary, #fff)}:host(:popover-open){position:fixed;overflow:visible;padding:0;border:none;margin:0;background:transparent;inset:unset;outline:none}:host([data-show]){display:flex}:host([common]:not([isfullscreen])) .container,:host([rounded]:not([isfullscreen])) .container{border-radius:var(--ds-border-radius, 0.375rem)}:host([common][isfullscreen]) .container,:host([rounded][isfullscreen]) .container{border-radius:unset;box-shadow:unset}.container{display:inline-block;overflow:auto;box-sizing:border-box;border-radius:var(--ds-border-radius, 0.375rem);margin:var(--ds-size-50, 0.25rem) 0}.util_displayHiddenVisually{position:absolute;overflow:hidden;width:1px;height:1px;padding:0;border:0;margin:-1px;clip-path:inset(50%);white-space:nowrap}`;
2962
-
2963
- var colorCss$2 = css`.container{background-color:var(--ds-auro-dropdownbib-container-color);box-shadow:var(--ds-auro-dropdownbib-boxshadow-color);color:var(--ds-auro-dropdownbib-text-color)}`;
2964
-
2965
- var tokensCss$1 = css`:host(:not([ondark])),:host(:not([appearance=inverse])){--ds-auro-dropdown-label-text-color: var(--ds-basic-color-texticon-muted, #676767);--ds-auro-dropdown-trigger-background-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-dropdown-trigger-hover-background-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-dropdown-trigger-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-dropdown-trigger-border-color: var(--ds-basic-color-border-bold, #585e67);--ds-auro-dropdown-trigger-outline-color: transparent;--ds-auro-dropdown-trigger-text-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-dropdownbib-boxshadow-color: var(--ds-elevation-200, 0px 0px 10px rgba(0, 0, 0, 0.15));--ds-auro-dropdownbib-background-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-dropdownbib-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-dropdownbib-text-color: var(--ds-basic-color-texticon-default, #2a2a2a)}:host([ondark]),:host([appearance=inverse]){--ds-auro-dropdown-label-text-color: var(--ds-basic-color-texticon-inverse-muted, #ccd2db);--ds-auro-dropdown-trigger-background-color: var(--ds-advanced-color-shared-background-inverse, rgba(255, 255, 255, 0.15));--ds-auro-dropdown-trigger-hover-background-color: var(--ds-advanced-color-shared-background-inverse, rgba(255, 255, 255, 0.15));--ds-auro-dropdown-trigger-container-color: var(--ds-advanced-color-shared-background-inverse, rgba(255, 255, 255, 0.15));--ds-auro-dropdown-trigger-border-color: var(--ds-basic-color-border-inverse, #ffffff);--ds-auro-dropdown-trigger-outline-color: transparent;--ds-auro-dropdown-trigger-text-color: var(--ds-basic-color-texticon-inverse, #ffffff);--ds-auro-dropdownbib-boxshadow-color: var(--ds-elevation-200, 0px 0px 10px rgba(0, 0, 0, 0.15));--ds-auro-dropdownbib-background-color: var(--ds-advanced-color-shared-background-inverse, rgba(255, 255, 255, 0.15));--ds-auro-dropdownbib-container-color: var(--ds-advanced-color-shared-background-inverse, rgba(255, 255, 255, 0.15));--ds-auro-dropdownbib-text-color: var(--ds-basic-color-texticon-inverse, #ffffff)}`;
2966
-
2967
- /**
2968
- * Creates a keyboard strategy for dialog-specific key handling.
2969
- * All other keydown behavior is left to the browser's native bubbling path.
2970
- * @param {HTMLElement} bib - The dropdown bib element.
2971
- * @returns {Object} Keyboard handlers keyed by `event.key`.
2972
- */
2973
- // eslint-disable-next-line no-unused-vars
2974
- function createDropdownBibKeyboardStrategy(bib) {
2975
- return {
2976
- // eslint-disable-next-line no-unused-vars
2977
- Enter(_dialog, event) {
2978
- // Floating UI handles Enter key to open the dropdown
2979
- },
2980
- // eslint-disable-next-line no-unused-vars
2981
- Escape(_dialog, event) {
2982
- // Floating UI handles Escape key to close the dropdown
2983
- }
2984
- };
2985
- }
2986
-
2987
- // Copyright (c) 2020 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
2988
- // See LICENSE in the project root for license information.
2989
- /* eslint-disable max-lines */
2990
- // ---------------------------------------------------------------------
2991
-
2992
-
2993
- const DESIGN_TOKEN_BREAKPOINT_PREFIX = '--ds-grid-breakpoint-';
2994
- const DESIGN_TOKEN_BREAKPOINT_OPTIONS = [
2995
- 'xl',
2996
- 'lg',
2997
- 'md',
2998
- 'sm',
2999
- 'xs',
3000
- ];
3001
-
3002
- /**
3003
- * @prop { String } fullscreenBreakpoint - Defines the screen size breakpoint (`lg`, `md`, `sm`, or `xs`) at which the dropdown switches to fullscreen mode on mobile. When expanded, the dropdown will automatically display in fullscreen mode if the screen size is equal to or smaller than the selected breakpoint.
3004
- * @csspart bibContainer - Apply css to the bib container.
3005
- */
3006
-
3007
- class AuroDropdownBib extends LitElement {
3008
- // not extending AuroElement because Bib needs only `shape` prop
3009
- constructor() {
3010
- super();
3011
-
3012
- /**
3013
- * @private
3014
- */
3015
- this._mobileBreakpointValue = undefined;
3016
-
3017
- AuroLibraryRuntimeUtils$1.prototype.handleComponentTagRename(this, 'auro-dropdownbib');
3018
-
3019
- this.shape = "rounded";
3020
- this.matchWidth = false;
3021
- this.hasActiveDescendant = false;
3022
- }
3023
-
3024
- static get styles() {
3025
- return [
3026
- styleCss$2,
3027
- colorCss$2,
3028
- tokensCss$1
3029
- ];
3030
- }
3031
-
3032
- static get properties() {
3033
- return {
3034
-
3035
- /**
3036
- * If declared, will take the fullscreen when the bib is displayed.
3037
- */
3038
- isFullscreen: {
3039
- type: Boolean,
3040
- reflect: true
3041
- },
3042
-
3043
- /**
3044
- * If declared, will apply all styles for the common theme.
3045
- */
3046
- common: {
3047
- type: Boolean,
3048
- reflect: true
3049
- },
3050
-
3051
- /**
3052
- * If declared, will apply extra padding to bib content.
3053
- */
3054
- inset: {
3055
- type: Boolean,
3056
- reflect: true
3057
- },
3058
-
3059
- /**
3060
- * If declared, the bib width will match the trigger width.
3061
- * @private
3062
- */
3063
- matchWidth: {
3064
- type: Boolean,
3065
- reflect: true
3066
- },
3067
-
3068
- /**
3069
- * If declared, will apply border-radius to the bib.
3070
- */
3071
- rounded: {
3072
- type: Boolean,
3073
- reflect: true
3074
- },
3075
-
3076
- /**
3077
- * A reference to the associated bib template element.
3078
- */
3079
- bibTemplate: {
3080
- type: Object
3081
- },
3082
-
3083
- shape: {
3084
- type: String,
3085
- reflect: true
3086
- },
3087
-
3088
- /**
3089
- * Accessible label for the dialog element, used when displayed as a modal.
3090
- * Applied via aria-labelledby on a visually hidden element rather than
3091
- * aria-label because iOS VoiceOver does not reliably read aria-label
3092
- * on <dialog> elements.
3093
- * @private
3094
- */
3095
- dialogLabel: {
3096
- type: String
3097
- },
3098
-
3099
- /**
3100
- * Overrides the native role of the dialog element.
3101
- * For example, set to `"presentation"` on desktop combobox to prevent
3102
- * VoiceOver from announcing "listbox inside of a dialog".
3103
- * When `undefined`, the dialog keeps its native role.
3104
- * @private
3105
- */
3106
- dialogRole: {
3107
- type: String
3108
- },
3109
-
3110
- /**
3111
- * Tracks whether a menu option is currently highlighted.
3112
- * @private
3113
- */
3114
- hasActiveDescendant: {
3115
- type: Boolean
3116
- }
3117
- };
3118
- }
3119
-
3120
- set mobileFullscreenBreakpoint(value) {
3121
- // verify the defined breakpoint is valid and exit out if not
3122
- // 'disabled' is a design token breakpoint so it acts as our "undefined" value
3123
- const validatedValue = DESIGN_TOKEN_BREAKPOINT_OPTIONS.includes(value) ? value : undefined;
3124
- if (!validatedValue) {
3125
- this._mobileBreakpointValue = undefined;
3126
- } else {
3127
- // get the pixel value for the defined breakpoint
3128
- const docStyle = getComputedStyle(document.documentElement);
3129
- this._mobileBreakpointValue = docStyle.getPropertyValue(DESIGN_TOKEN_BREAKPOINT_PREFIX + value);
3130
- }
3131
- }
3132
-
3133
- get mobileFullscreenBreakpoint() {
3134
- return this._mobileBreakpointValue;
3135
- }
3136
-
3137
- updated(changedProperties) {
3138
- if (changedProperties.has('isFullscreen')) {
3139
- this.childNodes.forEach((child) => {
3140
- // skip any text that is not in an HTMLElement on setting `isFullscreen` attr.
3141
- if (child.nodeName !== '#text') {
3142
- if (this.isFullscreen) {
3143
- child.setAttribute('isFullscreen', 'true');
3144
- } else {
3145
- child.removeAttribute('isFullscreen');
3146
- }
3147
- }
3148
- });
3149
-
3150
- if (this.bibTemplate) {
3151
- // If the bib template is found, set the fullscreen attribute
3152
- if (this.isFullscreen) {
3153
- this.bibTemplate.setAttribute('isFullscreen', 'true');
3154
- } else {
3155
- this.bibTemplate.removeAttribute('isFullscreen');
3156
- }
3157
- }
3158
- }
3159
- }
3160
-
3161
- connectedCallback() {
3162
- super.connectedCallback();
3163
-
3164
- // Listen for the auro-bibtemplate-connected event to set the fullscreen attribute
3165
- this.addEventListener('auro-bibtemplate-connected', (event) => {
3166
- const bibTemplate = event.detail.element;
3167
- this.bibTemplate = bibTemplate;
3168
-
3169
- if (bibTemplate) {
3170
- // If the bib template is found, set the fullscreen attribute
3171
- if (this.isFullscreen) {
3172
- bibTemplate.setAttribute('isFullscreen', 'true');
3173
- } else {
3174
- bibTemplate.removeAttribute('isFullscreen');
3175
- }
3176
- }
3177
- });
3178
- }
3179
-
3180
- firstUpdated(changedProperties) {
3181
- super.firstUpdated(changedProperties);
3182
-
3183
- const dialog = this.shadowRoot.querySelector('dialog');
3184
- this._setupCancelHandler(dialog);
3185
- applyKeyboardStrategy(dialog, createDropdownBibKeyboardStrategy());
3186
-
3187
- this.dispatchEvent(new CustomEvent('auro-dropdownbib-connected', {
3188
- bubbles: true,
3189
- composed: true,
3190
- detail: {
3191
- element: this
3192
- }
3193
- }));
3194
- }
3195
-
3196
- /**
3197
- * Forwards the dialog's native `cancel` event (fired on ESC) as
3198
- * an `auro-bib-cancel` custom event so parent components can close.
3199
- * @param {HTMLDialogElement} dialog - The dialog element to attach the cancel listener to.
3200
- * @private
3201
- */
3202
- _setupCancelHandler(dialog) {
3203
- dialog.addEventListener('cancel', (event) => {
3204
- event.preventDefault();
3205
- this.dispatchEvent(new CustomEvent('auro-bib-cancel', {
3206
- bubbles: true,
3207
- composed: true
3208
- }));
3209
- });
3210
- }
3211
-
3212
-
3213
- /**
3214
- * Blocks touch-driven page scroll while a fullscreen modal dialog is open.
3215
- *
3216
- * The showModal() function places the dialog in the browser's **top layer**,
3217
- * which is a separate rendering layer above the normal DOM. On mobile, the
3218
- * compositor processes visual-viewport panning before top-layer touch
3219
- * handling. This means the entire viewport — including the top-layer dialog
3220
- * — can be panned by a touch gesture, causing the page behind the dialog to
3221
- * scroll into view. To prevent this, we add a touchmove listener that cancels
3222
- * the event if the touch started outside the dialog or any scrollable child within it.
3223
- *
3224
- * @private
3225
- */
3226
- _lockTouchScroll() {
3227
- const dialog = this.shadowRoot.querySelector('dialog');
3228
-
3229
- this._touchMoveHandler = (event) => {
3230
- // Walk the composed path (which crosses shadow DOM boundaries) to
3231
- // check whether the touch started inside a scrollable element that
3232
- // lives within the dialog. If so, allow the scroll.
3233
- for (const el of event.composedPath()) {
3234
- if (el === dialog) {
3235
- // Reached the dialog boundary without finding a scrollable child.
3236
- break;
3237
- }
3238
- if (el instanceof HTMLElement && el.scrollHeight > el.clientHeight) {
3239
- const { overflowY } = getComputedStyle(el);
3240
- if (overflowY === 'auto' || overflowY === 'scroll') {
3241
- return;
3242
- }
3243
- }
3244
- }
3245
-
3246
- event.preventDefault();
3247
- };
3248
-
3249
- document.addEventListener('touchmove', this._touchMoveHandler, { passive: false });
3250
- }
3251
-
3252
- /**
3253
- * Removes the touchmove listener added by _lockTouchScroll().
3254
- * @private
3255
- */
3256
- _unlockTouchScroll() {
3257
- if (this._touchMoveHandler) {
3258
- document.removeEventListener('touchmove', this._touchMoveHandler);
3259
- this._touchMoveHandler = undefined;
3260
- }
3261
- }
3262
-
3263
- open(modal = true) {
3264
- const dialog = this.shadowRoot.querySelector('dialog');
3265
-
3266
- if (dialog && !dialog.open) {
3267
- if (modal) {
3268
- // Prevent showModal() from scrolling the page to bring the dialog
3269
- // into view. Locking overflow on <html> blocks the viewport scroll
3270
- // that browsers perform natively; we release it immediately after
3271
- // so it doesn't interfere with the modal's focus management.
3272
- const { documentElement } = document;
3273
- const prevOverflow = documentElement.style.overflow;
3274
- documentElement.style.overflow = 'hidden';
3275
-
3276
- try {
3277
- dialog.showModal();
3278
- } finally {
3279
- // Restore overflow immediately — the lock was only needed to
3280
- // suppress the browser's native scroll-into-view behavior
3281
- // triggered by showModal(). Keeping it locked would block
3282
- // scrolling inside the modal.
3283
- documentElement.style.overflow = prevOverflow;
3284
- }
3285
-
3286
- this._lockTouchScroll();
3287
-
3288
- } else {
3289
- // Open the inner dialog so slotted content renders.
3290
- dialog.setAttribute('open', '');
3291
-
3292
- // Use popover on the host for top-layer placement without focus
3293
- // management or inertness. This escapes ancestor container-type
3294
- // containment that would trap position:fixed relative to the container.
3295
- // Set popover dynamically to avoid UA [popover]:not(:popover-open) { display: none }
3296
- // interfering with Floating UI measurement before showPopover().
3297
- this.setAttribute('popover', 'manual');
3298
- this.showPopover();
3299
- }
3300
- }
3301
- }
3302
-
3303
- /**
3304
- * Closes the dialog.
3305
- */
3306
- close() {
3307
- this.hasActiveDescendant = false;
3308
-
3309
- const dialog = this.shadowRoot.querySelector('dialog');
3310
-
3311
- if (dialog && dialog.open) {
3312
- this._unlockTouchScroll();
3313
- dialog.close();
3314
- }
3315
- // Clean up the popover used for desktop top-layer placement.
3316
- // Remove the attribute entirely so the UA rule
3317
- // [popover]:not(:popover-open) { display: none } doesn't hide
3318
- // the host while Floating UI measures it for the next open.
3319
- if (this.matches(':popover-open')) {
3320
- this.hidePopover();
3321
- this.removeAttribute('popover');
3322
- }
3323
- }
3324
-
3325
- // function that renders the HTML and CSS into the scope of the component
3326
- render() {
3327
- const classes = {
3328
- container: true
3329
- };
3330
-
3331
- // Since this class does not inherit from AuroElement, we apply the shape-related class within the `render` function,
3332
- // mimicking the class naming convention used in AuroElement.resetShapeClasses.
3333
- classes[`shape-${this.shape}`] = true;
3334
-
3335
- return html$1`
3336
- <dialog class="${classMap(classes)}" part="bibContainer" role="${ifDefined(this.dialogRole)}" aria-labelledby="${ifDefined(this.dialogLabel ? 'dialogLabel' : undefined)}">
3337
- ${this.dialogLabel ? html$1`<span id="dialogLabel" class="util_displayHiddenVisually">${this.dialogLabel}</span>` : ''}
3338
- <slot></slot>
3339
- </dialog>
3340
- `;
3341
- }
3342
- }
3343
-
3344
- var shapeSizeCss = css`.shape-classic-xl,.shape-classic-lg,.shape-classic-md,.shape-classic-sm,.shape-classic-xs{min-height:56px;max-height:56px;border-style:solid;border-width:1px;border-radius:var(--ds-border-radius, 0.375rem)}.shape-classic-xl.simple,.shape-classic-lg.simple,.shape-classic-md.simple,.shape-classic-sm.simple,.shape-classic-xs.simple{border-width:0px;min-height:58px;max-height:58px;background-color:unset;box-shadow:none}.shape-classic-xl.thin,.shape-classic-lg.thin,.shape-classic-md.thin,.shape-classic-sm.thin,.shape-classic-xs.thin{border-width:1px;min-height:56px;max-height:56px;background-color:unset}.shape-classic-xl.parentBorder,.shape-classic-lg.parentBorder,.shape-classic-md.parentBorder,.shape-classic-sm.parentBorder,.shape-classic-xs.parentBorder{border:0;box-shadow:unset;min-height:54px;max-height:54px}.shape-snowflake-xl,.shape-snowflake-lg,.shape-snowflake-md,.shape-snowflake-sm,.shape-snowflake-xs{min-height:56px;max-height:56px;border-style:solid;border-width:2px;border-color:transparent;border-radius:30px}.shape-snowflake-xl.simple,.shape-snowflake-lg.simple,.shape-snowflake-md.simple,.shape-snowflake-sm.simple,.shape-snowflake-xs.simple{border-width:0px;min-height:60px;max-height:60px;background-color:unset;box-shadow:none}.shape-snowflake-xl.thin,.shape-snowflake-lg.thin,.shape-snowflake-md.thin,.shape-snowflake-sm.thin,.shape-snowflake-xs.thin{border-width:1px;min-height:58px;max-height:58px;background-color:unset}.shape-snowflake-xl.parentBorder,.shape-snowflake-lg.parentBorder,.shape-snowflake-md.parentBorder,.shape-snowflake-sm.parentBorder,.shape-snowflake-xs.parentBorder{border:0;box-shadow:unset;min-height:56px;max-height:56px}.shape-box-xl{min-height:68px;max-height:68px;border-style:solid;border-width:2px;border-color:transparent}.shape-box-xl.simple{border-width:0px;min-height:72px;max-height:72px;background-color:unset;box-shadow:none}.shape-box-xl.thin{border-width:1px;min-height:70px;max-height:70px;background-color:unset}.shape-box-xl.parentBorder{border:0;box-shadow:unset;min-height:68px;max-height:68px}.shape-box-lg{min-height:52px;max-height:52px;border-style:solid;border-width:2px;border-color:transparent}.shape-box-lg.simple{border-width:0px;min-height:56px;max-height:56px;background-color:unset;box-shadow:none}.shape-box-lg.thin{border-width:1px;min-height:54px;max-height:54px;background-color:unset}.shape-box-lg.parentBorder{border:0;box-shadow:unset;min-height:52px;max-height:52px}.shape-box-md{min-height:44px;max-height:44px;border-style:solid;border-width:2px;border-color:transparent}.shape-box-md.simple{border-width:0px;min-height:48px;max-height:48px;background-color:unset;box-shadow:none}.shape-box-md.thin{border-width:1px;min-height:46px;max-height:46px;background-color:unset}.shape-box-md.parentBorder{border:0;box-shadow:unset;min-height:44px;max-height:44px}.shape-box-sm{min-height:32px;max-height:32px;border-style:solid;border-width:2px;border-color:transparent}.shape-box-sm.simple{border-width:0px;min-height:36px;max-height:36px;background-color:unset;box-shadow:none}.shape-box-sm.thin{border-width:1px;min-height:34px;max-height:34px;background-color:unset}.shape-box-sm.parentBorder{border:0;box-shadow:unset;min-height:32px;max-height:32px}.shape-box-xs{min-height:20px;max-height:20px;border-style:solid;border-width:2px;border-color:transparent}.shape-box-xs.simple{border-width:0px;min-height:24px;max-height:24px;background-color:unset;box-shadow:none}.shape-box-xs.thin{border-width:1px;min-height:22px;max-height:22px;background-color:unset}.shape-box-xs.parentBorder{border:0;box-shadow:unset;min-height:20px;max-height:20px}.shape-rounded-lg{min-height:56px;max-height:56px;border-style:solid;border-width:2px;border-color:transparent;border-radius:6px}.shape-rounded-lg.simple{border-width:0px;min-height:56px;max-height:56px;background-color:unset;box-shadow:none}.shape-rounded-lg.thin{border-width:1px;min-height:54px;max-height:54px;background-color:unset}.shape-rounded-lg.parentBorder{border:0;box-shadow:unset;min-height:52px;max-height:52px}.shape-pill-xl{min-height:68px;max-height:68px;border-style:solid;border-width:2px;border-color:transparent;border-radius:36px}.shape-pill-xl.simple{border-width:0px;min-height:72px;max-height:72px;background-color:unset;box-shadow:none}.shape-pill-xl.thin{border-width:1px;min-height:70px;max-height:70px;background-color:unset}.shape-pill-xl.parentBorder{border:0;box-shadow:unset;min-height:68px;max-height:68px}.shape-pill-left-xl{min-height:68px;max-height:68px;border-style:solid;border-width:2px;border-color:transparent;border-radius:36px 0 0 36px}.shape-pill-left-xl.simple{border-width:0px;min-height:72px;max-height:72px;background-color:unset;box-shadow:none}.shape-pill-left-xl.thin{border-width:1px;min-height:70px;max-height:70px;background-color:unset}.shape-pill-left-xl.parentBorder{border:0;box-shadow:unset;min-height:68px;max-height:68px}.shape-pill-right-xl{min-height:68px;max-height:68px;border-style:solid;border-width:2px;border-color:transparent;border-radius:0 36px 36px 0}.shape-pill-right-xl.simple{border-width:0px;min-height:72px;max-height:72px;background-color:unset;box-shadow:none}.shape-pill-right-xl.thin{border-width:1px;min-height:70px;max-height:70px;background-color:unset}.shape-pill-right-xl.parentBorder{border:0;box-shadow:unset;min-height:68px;max-height:68px}.shape-pill-md{min-height:44px;max-height:44px;border-style:solid;border-width:2px;border-color:transparent;border-radius:36px}.shape-pill-md.simple{border-width:0px;min-height:48px;max-height:48px;background-color:unset;box-shadow:none}.shape-pill-md.thin{border-width:1px;min-height:46px;max-height:46px;background-color:unset}.shape-pill-md.parentBorder{border:0;box-shadow:unset;min-height:44px;max-height:44px}.shape-pill-left-md{min-height:44px;max-height:44px;border-style:solid;border-width:2px;border-color:transparent;border-radius:36px 0 0 36px}.shape-pill-left-md.simple{border-width:0px;min-height:48px;max-height:48px;background-color:unset;box-shadow:none}.shape-pill-left-md.thin{border-width:1px;min-height:46px;max-height:46px;background-color:unset}.shape-pill-left-md.parentBorder{border:0;box-shadow:unset;min-height:44px;max-height:44px}.shape-pill-right-md{min-height:44px;max-height:44px;border-style:solid;border-width:2px;border-color:transparent;border-radius:0 36px 36px 0}.shape-pill-right-md.simple{border-width:0px;min-height:48px;max-height:48px;background-color:unset;box-shadow:none}.shape-pill-right-md.thin{border-width:1px;min-height:46px;max-height:46px;background-color:unset}.shape-pill-right-md.parentBorder{border:0;box-shadow:unset;min-height:44px;max-height:44px}`;
3345
-
3346
- var colorCss$1 = css`:host(:not([layout*=classic])){--ds-auro-dropdown-trigger-border-color: transparent}:host(:not([disabled],[onDark])) .wrapper:focus-within,:host(:not([disabled],[onDark])) .wrapper:active,:host(:not([disabled],[appearance=inverse])) .wrapper:focus-within,:host(:not([disabled],[appearance=inverse])) .wrapper:active{--ds-auro-dropdown-trigger-border-color: var(--ds-advanced-color-state-focused, #01426a);--ds-auro-dropdown-trigger-outline-color: var(--ds-advanced-color-state-focused, #01426a)}:host(:not([disabled],[onDark])) .wrapper:hover,:host(:not([disabled],[appearance=inverse])) .wrapper:hover{--ds-auro-dropdown-trigger-background-color: var(--ds-auro-dropdown-trigger-hover-background-color)}:host(:not([ondark])) .wrapper,:host(:not([appearance=inverse])) .wrapper{border-color:var(--ds-auro-dropdown-trigger-border-color);background-color:var(--ds-auro-dropdown-trigger-background-color);color:var(--ds-auro-dropdown-trigger-text-color)}:host(:not([onDark])[disabled]),:host(:not([appearance=inverse])[disabled]){--ds-auro-dropdown-trigger-text-color: var(--ds-basic-color-texticon-disabled, #d0d0d0);--ds-auro-dropdown-label-text-color: var(--ds-basic-color-texticon-disabled, #d0d0d0);--ds-auro-dropdown-trigger-border-color: var(--ds-basic-color-border-subtle, #dddddd)}:host(:not([onDark])[disabled]) #triggerLabel,:host(:not([appearance=inverse])[disabled]) #triggerLabel{cursor:default}:host(:not([ondark])[error]),:host(:not([appearance=inverse])[error]){--ds-auro-dropdown-trigger-border-color: var(--ds-basic-color-status-error, #e31f26)}:host(:not([disabled])[onDark]) .wrapper:focus-within,:host(:not([disabled])[onDark]) .wrapper:active,:host(:not([disabled])[appearance=inverse]) .wrapper:focus-within,:host(:not([disabled])[appearance=inverse]) .wrapper:active{--ds-auro-dropdown-trigger-border-color: var(--ds-advanced-color-state-focused-inverse, #ffffff);--ds-auro-dropdown-trigger-outline-color: var(--ds-advanced-color-state-focused-inverse, #ffffff)}:host(:not([disabled])[onDark]) .wrapper:hover,:host(:not([disabled])[appearance=inverse]) .wrapper:hover{--ds-auro-dropdown-trigger-background-color: var(--ds-auro-dropdown-trigger-hover-background-color)}:host([onDark]) .label,:host([onDark]) .helpText,:host([appearance=inverse]) .label,:host([appearance=inverse]) .helpText{color:var(--ds-auro-dropdown-label-text-color)}:host([onDark]) .wrapper,:host([appearance=inverse]) .wrapper{border-color:var(--ds-auro-dropdown-trigger-border-color);background-color:var(--ds-auro-dropdown-trigger-background-color);color:var(--ds-auro-dropdown-trigger-text-color)}:host([onDark][disabled]),:host([appearance=inverse][disabled]){--ds-auro-dropdown-trigger-text-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894);--ds-auro-dropdown-label-text-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894);--ds-auro-dropdown-trigger-container-color: var(--ds-advanced-color-shared-background-inverse-disabled, rgba(255, 255, 255, 0.1))}:host([onDark][disabled]) #triggerLabel,:host([appearance=inverse][disabled]) #triggerLabel{cursor:default}:host([ondark][error]),:host([appearance=inverse][error]){--ds-auro-dropdown-trigger-border-color: var(--ds-advanced-color-state-error-inverse, #f9a4a8)}`;
3347
-
3348
- var styleCss$1 = css`:host{position:relative;display:block;text-align:left}:host([open]){z-index:var(--depth-tooltip, 400)}.wrapper{display:flex;flex:1;flex-direction:row;align-items:center;justify-content:center;outline:none}.triggerContentWrapper{display:flex;overflow:hidden;width:100%;flex:1;align-items:center;justify-content:center;text-overflow:ellipsis;white-space:nowrap}:host([matchwidth]) #bibSizer{width:100%}`;
3349
-
3350
- var classicColorCss = css``;
3351
-
3352
- var classicLayoutCss = css`@media(hover: hover){:host(:not([disabled])) .wrapper:hover{cursor:pointer}}:host([layout*=classic]){position:relative;max-width:100%}:host([layout*=classic]) #bibSizer{position:absolute;z-index:-1;opacity:0;pointer-events:none}:host([layout*=classic]) label{transition:font-size .3s cubic-bezier(0.215, 0.61, 0.355, 1);white-space:normal}:host([layout*=classic]) .wrapper{display:flex;flex-direction:row;box-shadow:inset 0 0 0 1px var(--ds-auro-dropdown-trigger-outline-color)}:host([layout*=classic]) .triggerContentWrapper{overflow:hidden;flex:1;justify-content:start;text-overflow:ellipsis;white-space:nowrap}:host([layout*=classic]) #showStateIcon{display:flex;overflow:hidden;height:100%;align-items:center;padding-right:var(--ds-size-150, 0.75rem)}:host([layout*=classic]) #showStateIcon [auro-icon]{height:var(--ds-size-300, 1.5rem)}:host([layout*=classic]) #showStateIcon[data-expanded=true] [auro-icon]{transform:rotate(-180deg)}`;
3353
-
3354
- var styleEmphasizedCss = css`.layout-emphasized .chevron,.layout-emphasized-left .chevron,.layout-emphasized-right .chevron{margin-right:var(--ds-size-300, 1.5rem)}:host([layout*=emphasized][shape*=pill]:not([layout*=right])) .leftIndent{width:calc(100% - var(--ds-size-300, 1.5rem));margin-left:var(--ds-size-300, 1.5rem)}:host([layout*=emphasized][shape*=pill]:not([layout*=left])) .rightIndent{width:calc(100% - var(--ds-size-300, 1.5rem));margin-right:var(--ds-size-300, 1.5rem)}:host([layout*=emphasized][shape*=pill]:not([layout*=left]):not([layout*=right])) .rightIndent{width:calc(100% - var(--ds-size-600, 3rem));margin-right:var(--ds-size-300, 1.5rem)}`;
3355
-
3356
- var styleSnowflakeCss = css`:host([layout*=snowflake]) .leftIndent{width:calc(100% - var(--ds-size-400, 2rem));margin-left:var(--ds-size-200, 1rem)}:host([layout*=snowflake]) .rightIndent{width:calc(100% - var(--ds-size-400, 2rem));margin-right:var(--ds-size-200, 1rem)}:host([layout*=snowflake]) .trigger,:host([layout*=snowflake]) .helpText{text-align:center}.layout-snowflake .chevron,.layout-snowflake-left .chevron,.layout-snowflake-right .chevron{margin-right:var(--ds-size-200, 1rem)}`;
3357
-
3358
- var colorCss = css`:host([error]){--ds-auro-helptext-color: var(--ds-basic-color-status-error, #e31f26)}:host([onDark]),:host([appearance=inverse]){--ds-auro-helptext-color: var(--ds-basic-color-texticon-inverse-muted, #ccd2db)}:host([onDark][error]),:host([appearance=inverse][error]){--ds-auro-helptext-color: var(--ds-advanced-color-state-error-inverse, #f9a4a8)}.helptext-wrapper{color:var(--ds-auro-helptext-color)}`;
3359
-
3360
- var styleCss = css`.body-default{font-size:var(--wcss-body-default-font-size, 1rem);line-height:var(--wcss-body-default-line-height, 1.5rem)}.body-default,.body-lg{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-lg{font-size:var(--wcss-body-lg-font-size, 1.125rem);line-height:var(--wcss-body-lg-line-height, 1.625rem)}.body-sm{font-size:var(--wcss-body-sm-font-size, 0.875rem);line-height:var(--wcss-body-sm-line-height, 1.25rem)}.body-sm,.body-xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0)}.body-xs{font-size:var(--wcss-body-xs-font-size, 0.75rem);line-height:var(--wcss-body-xs-line-height, 1rem)}.body-2xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:var(--wcss-body-2xs-font-size, 0.625rem);font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);line-height:var(--wcss-body-2xs-line-height, 0.875rem)}.display-2xl{font-family:var(--wcss-display-2xl-family, "AS Circular"),var(--wcss-display-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-2xl-font-size, clamp(3.5rem, 6vw, 5.375rem));font-weight:var(--wcss-display-2xl-weight, 300);letter-spacing:var(--wcss-display-2xl-letter-spacing, 0);line-height:var(--wcss-display-2xl-line-height, 1.3)}.display-xl{font-family:var(--wcss-display-xl-family, "AS Circular"),var(--wcss-display-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-xl-font-size, clamp(3rem, 5.3333333333vw, 4.5rem));font-weight:var(--wcss-display-xl-weight, 300);letter-spacing:var(--wcss-display-xl-letter-spacing, 0);line-height:var(--wcss-display-xl-line-height, 1.3)}.display-lg{font-family:var(--wcss-display-lg-family, "AS Circular"),var(--wcss-display-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-lg-font-size, clamp(2.75rem, 4.6666666667vw, 4rem));font-weight:var(--wcss-display-lg-weight, 300);letter-spacing:var(--wcss-display-lg-letter-spacing, 0);line-height:var(--wcss-display-lg-line-height, 1.3)}.display-md{font-family:var(--wcss-display-md-family, "AS Circular"),var(--wcss-display-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-md-font-size, clamp(2.5rem, 4vw, 3.5rem));font-weight:var(--wcss-display-md-weight, 300);letter-spacing:var(--wcss-display-md-letter-spacing, 0);line-height:var(--wcss-display-md-line-height, 1.3)}.display-sm{font-family:var(--wcss-display-sm-family, "AS Circular"),var(--wcss-display-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-sm-font-size, clamp(2rem, 3.6666666667vw, 3rem));font-weight:var(--wcss-display-sm-weight, 300);letter-spacing:var(--wcss-display-sm-letter-spacing, 0);line-height:var(--wcss-display-sm-line-height, 1.3)}.display-xs{font-family:var(--wcss-display-xs-family, "AS Circular"),var(--wcss-display-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-display-xs-font-size, clamp(1.75rem, 3vw, 2.375rem));font-weight:var(--wcss-display-xs-weight, 300);letter-spacing:var(--wcss-display-xs-letter-spacing, 0);line-height:var(--wcss-display-xs-line-height, 1.3)}.heading-xl{font-family:var(--wcss-heading-xl-family, "AS Circular"),var(--wcss-heading-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-xl-font-size, clamp(2rem, 3vw, 2.5rem));font-weight:var(--wcss-heading-xl-weight, 300);letter-spacing:var(--wcss-heading-xl-letter-spacing, 0);line-height:var(--wcss-heading-xl-line-height, 1.3)}.heading-lg{font-family:var(--wcss-heading-lg-family, "AS Circular"),var(--wcss-heading-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-lg-font-size, clamp(1.75rem, 2.6666666667vw, 2.25rem));font-weight:var(--wcss-heading-lg-weight, 300);letter-spacing:var(--wcss-heading-lg-letter-spacing, 0);line-height:var(--wcss-heading-lg-line-height, 1.3)}.heading-md{font-family:var(--wcss-heading-md-family, "AS Circular"),var(--wcss-heading-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-md-font-size, clamp(1.625rem, 2.3333333333vw, 1.75rem));font-weight:var(--wcss-heading-md-weight, 300);letter-spacing:var(--wcss-heading-md-letter-spacing, 0);line-height:var(--wcss-heading-md-line-height, 1.3)}.heading-sm{font-family:var(--wcss-heading-sm-family, "AS Circular"),var(--wcss-heading-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-sm-font-size, clamp(1.375rem, 2vw, 1.5rem));font-weight:var(--wcss-heading-sm-weight, 300);letter-spacing:var(--wcss-heading-sm-letter-spacing, 0);line-height:var(--wcss-heading-sm-line-height, 1.3)}.heading-xs{font-family:var(--wcss-heading-xs-family, "AS Circular"),var(--wcss-heading-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-xs-font-size, clamp(1.25rem, 1.6666666667vw, 1.25rem));font-weight:var(--wcss-heading-xs-weight, 450);letter-spacing:var(--wcss-heading-xs-letter-spacing, 0);line-height:var(--wcss-heading-xs-line-height, 1.3)}.heading-2xs{font-family:var(--wcss-heading-2xs-family, "AS Circular"),var(--wcss-heading-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-heading-2xs-font-size, clamp(1.125rem, 1.5vw, 1.125rem));font-weight:var(--wcss-heading-2xs-weight, 450);letter-spacing:var(--wcss-heading-2xs-letter-spacing, 0);line-height:var(--wcss-heading-2xs-line-height, 1.3)}.accent-2xl{font-family:var(--wcss-accent-2xl-family, "Good OT"),var(--wcss-accent-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-2xl-font-size, clamp(2rem, 3.1666666667vw, 2.375rem));font-weight:var(--wcss-accent-2xl-weight, 450);letter-spacing:var(--wcss-accent-2xl-letter-spacing, 0.05em);line-height:var(--wcss-accent-2xl-line-height, 1)}.accent-2xl,.accent-xl{text-transform:uppercase}.accent-xl{font-family:var(--wcss-accent-xl-family, "Good OT"),var(--wcss-accent-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-xl-font-size, clamp(1.625rem, 2.3333333333vw, 2rem));font-weight:var(--wcss-accent-xl-weight, 450);letter-spacing:var(--wcss-accent-xl-letter-spacing, 0.05em);line-height:var(--wcss-accent-xl-line-height, 1.3)}.accent-lg{font-family:var(--wcss-accent-lg-family, "Good OT"),var(--wcss-accent-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-lg-font-size, clamp(1.5rem, 2.1666666667vw, 1.75rem));font-weight:var(--wcss-accent-lg-weight, 450);letter-spacing:var(--wcss-accent-lg-letter-spacing, 0.05em);line-height:var(--wcss-accent-lg-line-height, 1.3)}.accent-lg,.accent-md{text-transform:uppercase}.accent-md{font-family:var(--wcss-accent-md-family, "Good OT"),var(--wcss-accent-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-md-font-size, clamp(1.375rem, 1.8333333333vw, 1.5rem));font-weight:var(--wcss-accent-md-weight, 500);letter-spacing:var(--wcss-accent-md-letter-spacing, 0.05em);line-height:var(--wcss-accent-md-line-height, 1.3)}.accent-sm{font-family:var(--wcss-accent-sm-family, "Good OT"),var(--wcss-accent-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-sm-font-size, clamp(1.125rem, 1.5vw, 1.25rem));font-weight:var(--wcss-accent-sm-weight, 500);letter-spacing:var(--wcss-accent-sm-letter-spacing, 0.05em);line-height:var(--wcss-accent-sm-line-height, 1.3)}.accent-sm,.accent-xs{text-transform:uppercase}.accent-xs{font-family:var(--wcss-accent-xs-family, "Good OT"),var(--wcss-accent-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-xs-font-size, clamp(1rem, 1.3333333333vw, 1rem));font-weight:var(--wcss-accent-xs-weight, 500);letter-spacing:var(--wcss-accent-xs-letter-spacing, 0.1em);line-height:var(--wcss-accent-xs-line-height, 1.3)}.accent-2xs{font-family:var(--wcss-accent-2xs-family, "Good OT"),var(--wcss-accent-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);font-size:var(--wcss-accent-2xs-font-size, clamp(0.875rem, 1.1666666667vw, 0.875rem));font-weight:var(--wcss-accent-2xs-weight, 450);letter-spacing:var(--wcss-accent-2xs-letter-spacing, 0.1em);line-height:var(--wcss-accent-2xs-line-height, 1.3);text-transform:uppercase}:host{position:relative;display:block}.helptext-wrapper{display:none}.helptext-wrapper[visible]{display:block}::slotted(*:not(:empty)){margin-top:var(--ds-size-50, 0.25rem);margin-bottom:0}::slotted(p){margin-block:0}`;
3361
-
3362
- var tokensCss = css`:host{--ds-auro-helptext-color: var(--ds-basic-color-texticon-muted, #676767)}`;
3363
-
3364
- // Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
3365
- // See LICENSE in the project root for license information.
3366
-
3367
- // ---------------------------------------------------------------------
3368
-
3369
- /* eslint-disable line-comment-position, no-inline-comments, no-confusing-arrow, no-nested-ternary, implicit-arrow-linebreak */
3370
-
3371
- class AuroLibraryRuntimeUtils {
3372
-
3373
- /* eslint-disable jsdoc/require-param */
3374
-
3375
- /**
3376
- * This will register a new custom element with the browser.
3377
- * @param {String} name - The name of the custom element.
3378
- * @param {Object} componentClass - The class to register as a custom element.
3379
- * @returns {void}
3380
- */
3381
- registerComponent(name, componentClass) {
3382
- if (!customElements.get(name)) {
3383
- customElements.define(name, class extends componentClass {});
3384
- }
3385
- }
3386
-
3387
- /**
3388
- * Finds and returns the closest HTML Element based on a selector.
3389
- * @returns {void}
3390
- */
3391
- closestElement(
3392
- selector, // selector like in .closest()
3393
- base = this, // extra functionality to skip a parent
3394
- __Closest = (el, found = el && el.closest(selector)) =>
3395
- !el || el === document || el === window
3396
- ? null // standard .closest() returns null for non-found selectors also
3397
- : found
3398
- ? found // found a selector INside this element
3399
- : __Closest(el.getRootNode().host) // recursion!! break out to parent DOM
3400
- ) {
3401
- return __Closest(base);
3402
- }
3403
- /* eslint-enable jsdoc/require-param */
3404
-
3405
- /**
3406
- * If the element passed is registered with a different tag name than what is passed in, the tag name is added as an attribute to the element.
3407
- * @param {Object} elem - The element to check.
3408
- * @param {String} tagName - The name of the Auro component to check for or add as an attribute.
3409
- * @returns {void}
3410
- */
3411
- handleComponentTagRename(elem, tagName) {
3412
- const tag = tagName.toLowerCase();
3413
- const elemTag = elem.tagName.toLowerCase();
3414
-
3415
- if (elemTag !== tag) {
3416
- elem.setAttribute(tag, true);
3417
- }
3418
- }
3419
-
3420
- /**
3421
- * Validates if an element is a specific Auro component.
3422
- * @param {Object} elem - The element to validate.
3423
- * @param {String} tagName - The name of the Auro component to check against.
3424
- * @returns {Boolean} - Returns true if the element is the specified Auro component.
3425
- */
3426
- elementMatch(elem, tagName) {
3427
- const tag = tagName.toLowerCase();
3428
- const elemTag = elem.tagName.toLowerCase();
3429
-
3430
- return elemTag === tag || elem.hasAttribute(tag);
3431
- }
3432
-
3433
- /**
3434
- * Gets the text content of a named slot.
3435
- * @returns {String}
3436
- * @private
3437
- */
3438
- getSlotText(elem, name) {
3439
- const slot = elem.shadowRoot?.querySelector(`slot[name="${name}"]`);
3440
- const nodes = slot?.assignedNodes({ flatten: true }) || [];
3441
- const text = nodes.map(n => n.textContent?.trim()).join(' ').trim();
3442
-
3443
- return text || null;
3444
- }
3445
- }
3446
-
3447
- // Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
3448
- // See LICENSE in the project root for license information.
3449
-
3450
-
3451
- /**
3452
- * Displays help text or error messages within form elements - Internal Use Only.
3453
- */
3454
- class AuroHelpText extends LitElement {
3455
-
3456
- constructor() {
3457
- super();
3458
-
3459
- this.error = false;
3460
- this.appearance = "default";
3461
- this.onDark = false;
3462
- this.hasTextContent = false;
3463
-
3464
- AuroLibraryRuntimeUtils.prototype.handleComponentTagRename(this, 'auro-helptext');
3465
- }
3466
-
3467
- static get styles() {
3468
- return [
3469
- colorCss,
3470
- styleCss,
3471
- tokensCss
3472
- ];
3473
- }
3474
-
3475
- // function to define props used within the scope of this component
3476
- static get properties() {
3477
- return {
3478
-
3479
- /**
3480
- * Defines whether the component will be on lighter or darker backgrounds.
3481
- * @property {'default', 'inverse'}
3482
- * @default 'default'
3483
- */
3484
- appearance: {
3485
- type: String,
3486
- reflect: true
3487
- },
3488
-
3489
- /**
3490
- * @private
3491
- */
3492
- slotNodes: {
3493
- type: Boolean,
3494
- },
3495
-
3496
- /**
3497
- * @private
3498
- */
3499
- hasTextContent: {
3500
- type: Boolean,
3501
- },
3502
-
3503
- /**
3504
- * If declared, make font color red.
3505
- */
3506
- error: {
3507
- type: Boolean,
3508
- reflect: true,
3509
- },
3510
-
3511
- /**
3512
- * DEPRECATED - use `appearance` instead.
3513
- */
3514
- onDark: {
3515
- type: Boolean,
3516
- reflect: true
3517
- }
3518
- };
3519
- }
3520
-
3521
- /**
3522
- * This will register this element with the browser.
3523
- * @param {string} [name="auro-helptext"] - The name of element that you want to register to.
3524
- *
3525
- * @example
3526
- * AuroCheckbox.register("custom-helptext") // this will register this element to <custom-helptext/>
3527
- *
3528
- */
3529
- static register(name = "auro-helptext") {
3530
- AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroHelpText);
3531
- }
3532
-
3533
- updated() {
3534
- this.handleSlotChange();
3535
- }
3536
-
3537
- handleSlotChange(event) {
3538
- if (event) {
3539
- this.slotNodes = event.target.assignedNodes();
3540
- }
3541
-
3542
- this.hasTextContent = this.checkSlotsForContent(this.slotNodes);
3543
- }
3544
-
3545
- /**
3546
- * Checks if any of the provided nodes or their nested slot nodes contain non-empty text content.
3547
- *
3548
- * @param {NodeList|Array} nodes - The list of nodes to check for content.
3549
- * @returns {boolean} - Returns true if any node or nested slot node contains non-empty text content, otherwise false.
3550
- * @private
3551
- */
3552
- checkSlotsForContent(nodes) {
3553
- if (!nodes) {
3554
- return false;
3555
- }
3556
-
3557
- return nodes.some((node) => {
3558
- if (node.textContent.trim()) {
3559
- return true;
3560
- }
3561
-
3562
- if (!node.querySelector) {
3563
- return false;
3564
- }
3565
-
3566
- const nestedSlot = node.tagName === 'SLOT' ? node : node.querySelector('slot');
3567
- if (!nestedSlot) {
3568
- return false;
3569
- }
3570
-
3571
- const nestedSlotNodes = nestedSlot.assignedNodes();
3572
- return this.checkSlotsForContent(nestedSlotNodes);
3573
- });
3574
- }
3575
-
3576
- // function that renders the HTML and CSS into the scope of the component
3577
- render() {
3578
- return html`
3579
- <div class="helptext-wrapper body-xs" ?visible="${this.hasTextContent}">
3580
- <slot @slotchange=${this.handleSlotChange}></slot>
3581
- </div>
3582
- `;
3583
- }
3584
- }
3585
-
3586
- var formkitVersion = '202604031554';
3587
-
3588
- class AuroElement extends LitElement {
3589
- static get properties() {
3590
- return {
3591
-
3592
- /**
3593
- * Defines the language of an element.
3594
- * @default {'default'}
3595
- */
3596
- layout: {
3597
- type: String,
3598
- attribute: "layout",
3599
- reflect: true
3600
- },
3601
-
3602
- shape: {
3603
- type: String,
3604
- attribute: "shape",
3605
- reflect: true
3606
- },
3607
-
3608
- size: {
3609
- type: String,
3610
- attribute: "size",
3611
- reflect: true
3612
- },
3613
-
3614
- onDark: {
3615
- type: Boolean,
3616
- attribute: "ondark",
3617
- reflect: true
3618
- }
3619
- };
3620
- }
3621
-
3622
- /**
3623
- * Returns true if the element has focus.
3624
- * @private
3625
- * @returns {boolean} - Returns true if the element has focus.
3626
- */
3627
- get componentHasFocus() {
3628
- return this.matches(':focus') || this.matches(':focus-within');
3629
- }
3630
-
3631
- resetShapeClasses() {
3632
- const wrapper = this.shadowRoot.querySelector('.wrapper');
3633
-
3634
- if (wrapper) {
3635
- wrapper.classList.forEach((className) => {
3636
- if (className.startsWith('shape-')) {
3637
- wrapper.classList.remove(className);
3638
- }
3639
- });
3640
-
3641
- if (this.shape && this.size) {
3642
- wrapper.classList.add(`shape-${this.shape.toLowerCase()}-${this.size.toLowerCase()}`);
3643
- } else {
3644
- wrapper.classList.add('shape-none');
3645
- }
3646
- }
3647
-
3648
- }
3649
-
3650
- resetLayoutClasses() {
3651
- if (this.layout) {
3652
- const wrapper = this.shadowRoot.querySelector('.wrapper');
3653
-
3654
- if (wrapper) {
3655
- wrapper.classList.forEach((className) => {
3656
- if (className.startsWith('layout-')) {
3657
- wrapper.classList.remove(className);
3658
- }
3659
- });
3660
-
3661
- wrapper.classList.add(`layout-${this.layout.toLowerCase()}`);
3662
- }
3663
- }
3664
- }
3665
-
3666
- updateComponentArchitecture() {
3667
- this.resetLayoutClasses();
3668
- this.resetShapeClasses();
3669
- }
3670
-
3671
- updated(changedProperties) {
3672
- if (changedProperties.has('layout') || changedProperties.has('shape') || changedProperties.has('size')) {
3673
- this.updateComponentArchitecture();
3674
- }
3675
- }
3676
-
3677
- // Try to render the defined `this.layout` layout. If that fails, fall back to the default layout.
3678
- // This will catch if an invalid layout value is passed in and render the default layout if so.
3679
- render() {
3680
- try {
3681
- return this.renderLayout();
3682
- } catch (error) {
3683
- // failed to get the defined layout
3684
- console.error('Failed to get the defined layout - using the default layout', error); // eslint-disable-line no-console
3685
-
3686
- // fallback to the default layout
3687
- return this.getLayout('default');
3688
- }
3689
- }
3690
- }
3691
-
3692
- // Copyright (c) 2026 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
3693
- // See LICENSE in the project root for license information.
3694
-
3695
-
3696
- /**
3697
- * The `auro-dropdown` element provides a way to place content in a bib that can be toggled.
3698
- * @customElement auro-dropdown
3699
- *
3700
- * @slot - Default slot for the dropdown bib content.
3701
- * @slot helpText - Defines the content of the helpText.
3702
- * @slot trigger - Defines the content of the trigger.
3703
- * @csspart trigger - The trigger content container.
3704
- * @csspart chevron - The collapsed/expanded state icon container.
3705
- * @csspart size - The size of the dropdown bib. (height, width, maxHeight, maxWidth only)
3706
- * @csspart helpText - The helpText content container.
3707
- * @event auroDropdown-triggerClick - Notifies that the trigger has been clicked.
3708
- * @event auroDropdown-toggled - Notifies that the visibility of the dropdown bib has changed.
3709
- * @event auroDropdown-idAdded - Notifies consumers that the unique ID for the dropdown bib has been generated.
3710
- */
3711
- class AuroDropdown extends AuroElement {
3712
- static get shadowRootOptions() {
3713
- return {
3714
- ...AuroElement.shadowRootOptions,
3715
- delegatesFocus: true,
3716
- };
3717
- }
3718
-
3719
- constructor() {
3720
- super();
3721
-
3722
- this.isPopoverVisible = false;
3723
- this.isBibFullscreen = false;
3724
- this.matchWidth = false;
3725
- this.noHideOnThisFocusLoss = false;
3726
-
3727
- this.errorMessage = undefined; // TODO - check with Doug if there is still more to do here
3728
-
3729
- // Layout Config
3730
- this.layout = undefined;
3731
- this.shape = undefined;
3732
- this.size = undefined;
3733
-
3734
- this.parentBorder = false;
3735
-
3736
- /** @private */
3737
- this.handleDropdownToggle = this.handleDropdownToggle.bind(this);
3738
-
3739
- /** @private */
3740
- this.bibElement = createRef();
3741
-
3742
- this._intializeDefaults();
3743
- }
3744
-
3745
- /**
3746
- * @private
3747
- * @returns {object} Class definition for the wrapper element.
3748
- */
3749
- get commonWrapperClasses() {
3750
- return {
3751
- 'trigger': true,
3752
- 'wrapper': true,
3753
- 'hasFocus': this.hasFocus,
3754
- 'simple': this.simple,
3755
- 'parentBorder': this.parentBorder
3756
- };
3757
- }
3758
-
3759
- /**
3760
- * @private
3761
- * @returns {void} Internal defaults.
3762
- */
3763
- _intializeDefaults() {
3764
- this.appearance = 'default';
3765
- this.chevron = false;
3766
- this.disabled = false;
3767
- this.disableKeyboardHandling = false;
3768
- this.error = false;
3769
- this.tabIndex = 0;
3770
- this.noToggle = false;
3771
- this.a11yRole = 'button';
3772
- this.onDark = false;
3773
- this.showTriggerBorders = true;
3774
- this.triggerContentFocusable = false;
3775
- this.simple = false;
3776
-
3777
- // floaterConfig
3778
- this.placement = 'bottom-start';
3779
- this.offset = 0;
3780
- this.noFlip = false;
3781
- this.shift = false;
3782
- this.autoPlacement = false;
3783
-
3784
- /**
3785
- * @private
3786
- */
3787
- this.hasTriggerContent = false;
3788
-
3789
- /**
3790
- * @private
3791
- */
3792
- this.triggerContentSlot = undefined;
3793
-
3794
- /**
3795
- * @private
3796
- */
3797
- this.runtimeUtils = new AuroLibraryRuntimeUtils$1();
3798
-
3799
- /**
3800
- * @private
3801
- */
3802
- this.floater = new AuroFloatingUI();
3803
-
3804
- /**
3805
- * Generate unique names for dependency components.
3806
- */
3807
- const versioning = new AuroDependencyVersioning();
3808
-
3809
- /**
3810
- * @private
3811
- */
3812
- this.iconTag = versioning.generateTag('auro-formkit-dropdown-icon', iconVersion, _);
3813
-
3814
- /**
3815
- * @private
3816
- */
3817
- this.dropdownBibTag = versioning.generateTag('auro-formkit-dropdown-dropdownbib', formkitVersion, AuroDropdownBib);
3818
-
3819
- /**
3820
- * @private
3821
- */
3822
- this.helpTextTag = versioning.generateTag('auro-formkit-dropdown-helptext', formkitVersion, AuroHelpText);
3823
-
3824
- /**
3825
- * @private
3826
- */
3827
- this.bindFocusEventToTrigger = this.bindFocusEventToTrigger.bind(this);
3828
- }
3829
-
3830
- /**
3831
- * @ignore
3832
- */
3833
- get floaterConfig() {
3834
- return {
3835
- placement: this.placement,
3836
- flip: !this.noFlip,
3837
- shift: this.shift,
3838
- autoPlacement: this.autoPlacement,
3839
- offset: this.offset,
3840
- };
3841
- }
3842
-
3843
- /**
3844
- * Public method to hide the dropdown.
3845
- * @returns {void}
3846
- */
3847
- hide() {
3848
- this.floater.hideBib();
3849
- }
3850
-
3851
- /**
3852
- * Public method to show the dropdown.
3853
- * @returns {void}
3854
- */
3855
- show() {
3856
- this.floater.showBib();
3857
-
3858
- // Open dialog synchronously so callers remain in the user gesture
3859
- // chain. This is critical for mobile browsers (iOS Safari) to keep
3860
- // the virtual keyboard open when transitioning from the trigger
3861
- // input to an input inside the fullscreen dialog. Without this,
3862
- // showModal() fires asynchronously via Lit's update cycle, which
3863
- // falls outside the user activation window and causes iOS to
3864
- // dismiss the keyboard.
3865
- if (this.bibElement && this.bibElement.value) {
3866
- this.bibElement.value.open(this.isBibFullscreen);
3867
- }
3868
- }
3869
-
3870
- /**
3871
- * When bib is open, focus on the first element inside of bib.
3872
- * If not, trigger element will get focus.
3873
- */
3874
- focus() {
3875
- if (this.isPopoverVisible && this.bibContent) {
3876
- const focusables = getFocusableElements(this.bibContent);
3877
- if (focusables.length > 0) {
3878
- focusables[0].focus();
3879
- }
3880
- } else {
3881
- this.trigger.focus();
3882
- }
3883
- }
3884
-
3885
- /**
3886
- * Sets the active descendant element for accessibility.
3887
- * Uses ariaActiveDescendantElement to cross shadow DOM boundaries.
3888
- * This function is used in components that contain `auro-dropdown` to set the active descendant.
3889
- * @private
3890
- * @param {HTMLElement|null} element - The element to set as the active descendant, or null to clear.
3891
- * @returns {void}
3892
- */
3893
- setActiveDescendant(element) {
3894
- if (!this.trigger) {
3895
- return;
3896
- }
3897
-
3898
- if (element) {
3899
- this.trigger.ariaActiveDescendantElement = element;
3900
- } else {
3901
- this.trigger.ariaActiveDescendantElement = null;
3902
- this.trigger.removeAttribute('aria-activedescendant');
3903
- }
3904
-
3905
- // In fullscreen, focus stays on the close button while arrow keys
3906
- // highlight options via active-descendant. Without this flag the
3907
- // keyboard bridge clicks the close button on Enter (closing the
3908
- // bib without selecting). When true, the bridge skips the button
3909
- // click and forwards Enter to the parent to make the selection.
3910
- if (this.bibContent) {
3911
- this.bibContent.hasActiveDescendant = this.isBibFullscreen && Boolean(element);
3912
- }
3913
- }
3914
-
3915
- // function to define props used within the scope of this component
3916
- static get properties() {
3917
- return {
3918
-
3919
- /**
3920
- * The value for the role attribute of the trigger element.
3921
- */
3922
- a11yRole: {
3923
- type: String,
3924
- attribute: false,
3925
- reflect: false
3926
- },
3927
-
3928
- /**
3929
- * Defines whether the component will be on lighter or darker backgrounds.
3930
- * @type {'default' | 'inverse'}
3931
- * @default 'default'
3932
- */
3933
- appearance: {
3934
- type: String,
3935
- reflect: true
3936
- },
3937
-
3938
- /**
3939
- * If declared, bib's position will be automatically calculated where to appear.
3940
- */
3941
- autoPlacement: {
3942
- type: Boolean,
3943
- reflect: true
3944
- },
3945
-
3946
- /**
3947
- * If declared, the dropdown will only show by calling the API .show() public method.
3948
- */
3949
- disableEventShow: {
3950
- type: Boolean,
3951
- reflect: true
3952
- },
3953
-
3954
- /**
3955
- * If declared, applies a border around the trigger slot.
3956
- */
3957
- simple: {
3958
- type: Boolean,
3959
- reflect: true
3960
- },
3961
-
3962
- /**
3963
- * If declared, the dropdown displays a chevron on the right.
3964
- */
3965
- chevron: {
3966
- type: Boolean,
3967
- reflect: true,
3968
- attribute: 'chevron'
3969
- },
3970
-
3971
- /**
3972
- * If declared, the dropdown is not interactive.
3973
- */
3974
- disabled: {
3975
- type: Boolean,
3976
- reflect: true
3977
- },
3978
-
3979
- /**
3980
- * If declared, the dropdown will not handle keyboard events and will require the consumer to manage this behavior.
3981
- */
3982
- disableKeyboardHandling: {
3983
- type: Boolean,
3984
- reflect: true
3985
- },
3986
-
3987
- /**
3988
- * @private
3989
- */
3990
- dropdownWidth: {
3991
- type: Number
3992
- },
3993
-
3994
- /**
3995
- * The unique ID for the dropdown bib element.
3996
- * @private
3997
- */
3998
- dropdownId: {
3999
- type: String,
4000
- reflect: false,
4001
- attribute: false
4002
- },
4003
-
4004
- /**
4005
- * If declared, will apply error UI to the dropdown.
4006
- */
4007
- error: {
4008
- type: Boolean,
4009
- reflect: true
4010
- },
4011
-
4012
- /**
4013
- * Contains the help text message for the current validity error.
4014
- */
4015
- errorMessage: {
4016
- type: String
4017
- },
4018
-
4019
- /**
4020
- * If declared, the bib will display when focus is applied to the trigger.
4021
- */
4022
- focusShow: {
4023
- type: Boolean,
4024
- reflect: true
4025
- },
4026
-
4027
- /**
4028
- * If true, the dropdown bib is displayed.
4029
- */
4030
- isPopoverVisible: {
4031
- type: Boolean,
4032
- reflect: true,
4033
- attribute: 'open'
4034
- },
4035
-
4036
- /**
4037
- * If true, the dropdown bib is taking the fullscreen when it's open.
4038
- */
4039
- isBibFullscreen: {
4040
- type: Boolean,
4041
- reflect: true
4042
- },
4043
-
4044
- /**
4045
- * If declared, the trigger will toggle the dropdown on mouseover/mouseout.
4046
- */
4047
- hoverToggle: {
4048
- type: Boolean,
4049
- reflect: true
4050
- },
4051
-
4052
- /**
4053
- * @private
4054
- */
4055
- hasTriggerContent: {
4056
- type: Boolean
4057
- },
4058
-
4059
- /**
4060
- * Defines the screen size breakpoint at which the dropdown switches to fullscreen mode on mobile. `disabled` indicates a dropdown should _never_ enter fullscreen.
4061
- *
4062
- * When expanded, the dropdown will automatically display in fullscreen mode
4063
- * if the screen size is equal to or smaller than the selected breakpoint.
4064
- * @type {'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'disabled'}
4065
- * @default 'sm'
4066
- */
4067
- fullscreenBreakpoint: {
4068
- type: String,
4069
- reflect: true
4070
- },
4071
-
4072
- /**
4073
- * Sets the layout of the dropdown.
4074
- * @type {'classic' | 'emphasized' | 'snowflake'}
4075
- * @default 'classic'
4076
- */
4077
- layout: {
4078
- type: String,
4079
- reflect: true
4080
- },
4081
-
4082
- /**
4083
- * Defines if the trigger should size based on the parent element providing the border UI.
4084
- * @private
4085
- */
4086
- parentBorder: {
4087
- type: Boolean,
4088
- reflect: true
4089
- },
4090
-
4091
- /**
4092
- * If declared, the popover and trigger will be set to the same width.
4093
- */
4094
- matchWidth: {
4095
- type: Boolean,
4096
- reflect: true
4097
- },
4098
-
4099
- /**
4100
- * If declared, the bib will NOT flip to an alternate position
4101
- * when there isn't enough space in the specified `placement`.
4102
- */
4103
- noFlip: {
4104
- type: Boolean,
4105
- reflect: true
4106
- },
4107
-
4108
- /**
4109
- * If declared, the dropdown will shift its position to avoid being cut off by the viewport.
4110
- */
4111
- shift: {
4112
- type: Boolean,
4113
- reflect: true
4114
- },
4115
-
4116
- /**
4117
- * If declared, the dropdown will not hide when moving focus outside the element.
4118
- */
4119
- noHideOnThisFocusLoss: {
4120
- type: Boolean,
4121
- reflect: true
4122
- },
4123
-
4124
- /**
4125
- * If declared, the trigger will only show the dropdown bib.
4126
- */
4127
- noToggle: {
4128
- type: Boolean,
4129
- reflect: true
4130
- },
4131
-
4132
- /**
4133
- * Gap between the trigger element and bib.
4134
- * @default 0
4135
- */
4136
- offset: {
4137
- type: Number,
4138
- reflect: true
4139
- },
4140
-
4141
- /**
4142
- * DEPRECATED - use `appearance="inverse"` instead.
4143
- */
4144
- onDark: {
4145
- type: Boolean,
4146
- reflect: true
4147
- },
4148
-
4149
- /**
4150
- * If declared, and a function is set, that function will execute when the slot content is updated.
4151
- */
4152
- onSlotChange: {
4153
- type: Function,
4154
- reflect: false
4155
- },
4156
-
4157
- /**
4158
- * Position where the bib should appear relative to the trigger.
4159
- * @type {'top' | 'right' | 'bottom' | 'left' | 'bottom-start' | 'top-start' | 'top-end' | 'right-start' | 'right-end' | 'bottom-end' | 'left-start' | 'left-end'}
4160
- * @default 'bottom-start'
4161
- */
4162
- placement: {
4163
- type: String,
4164
- reflect: true
4165
- },
4166
-
4167
- /**
4168
- * @private
4169
- */
4170
- tabIndex: {
4171
- type: Number
4172
- },
4173
-
4174
- /**
4175
- * Accessible label for the dropdown bib dialog element.
4176
- * @private
4177
- */
4178
- bibDialogLabel: {
4179
- type: String,
4180
- attribute: false,
4181
- reflect: false
4182
- }
4183
- };
4184
- }
4185
-
4186
- static get styles() {
4187
- return [
4188
- styleCss$1,
4189
- tokensCss$1,
4190
- colorCss$1,
4191
-
4192
- // default layout
4193
- classicColorCss,
4194
- classicLayoutCss,
4195
-
4196
- // emphasized layout
4197
- styleEmphasizedCss,
4198
-
4199
- // snowflake layout
4200
- styleSnowflakeCss,
4201
-
4202
- shapeSizeCss
4203
- ];
4204
- }
4205
-
4206
- /**
4207
- * This will register this element with the browser.
4208
- * @param {string} [name="auro-dropdown"] - The name of the element that you want to register.
4209
- *
4210
- * @example
4211
- * AuroDropdown.register("custom-dropdown") // this will register this element to <custom-dropdown/>
4212
- *
4213
- */
4214
- static register(name = "auro-dropdown") {
4215
- AuroLibraryRuntimeUtils$1.prototype.registerComponent(name, AuroDropdown);
4216
- }
4217
-
4218
- /**
4219
- * Accessor for reusing the focusable entity query string.
4220
- * @private
4221
- * @returns {string}
4222
- */
4223
- get focusableEntityQuery () {
4224
- return 'auro-input, [auro-input], auro-button, [auro-button], button, input';
4225
- }
4226
-
4227
- connectedCallback() {
4228
- super.connectedCallback();
4229
- }
4230
-
4231
- disconnectedCallback() {
4232
- super.disconnectedCallback();
4233
- if (this.floater) {
4234
- this.floater.hideBib('disconnect');
4235
- this.floater.disconnect();
4236
- }
4237
- this.clearTriggerFocusEventBinding();
4238
- }
4239
-
4240
- updated(changedProperties) {
4241
- super.updated(changedProperties);
4242
- this.floater.handleUpdate(changedProperties);
4243
-
4244
- // Note: `disabled` is not a breakpoint (it is not a screen size),
4245
- // so it looks like we never consume this - however, dropdownBib handles this in the setter as "undefined"
4246
- if (changedProperties.has('fullscreenBreakpoint')) {
4247
- this.bibContent.mobileFullscreenBreakpoint = this.fullscreenBreakpoint;
4248
- }
4249
-
4250
- // when trigger's content is changed without any attribute or node change,
4251
- // `requestUpdate` needs to be called to update hasTriggerContent
4252
- if (changedProperties.size === 0 || changedProperties.has('isPopoverVisible')) {
4253
- this.handleTriggerContentSlotChange();
4254
- }
4255
-
4256
- if (changedProperties.has('isPopoverVisible') && this.bibElement.value) {
4257
- if (this.isPopoverVisible) {
4258
- // Fullscreen: use showModal() for native accessibility (inert outside, focus trap)
4259
- // Desktop: use show() for Floating UI positioning + FocusTrap for focus management
4260
- const useModal = this.isBibFullscreen;
4261
- this.bibElement.value.open(useModal);
4262
- } else {
4263
- this.bibElement.value.close();
4264
- }
4265
- }
4266
-
4267
- // When fullscreen strategy changes while open, re-open dialog with correct mode
4268
- // (e.g. resizing from desktop → mobile while dropdown is open)
4269
- if (changedProperties.has('isBibFullscreen') && this.isPopoverVisible && this.bibElement.value) {
4270
- const useModal = this.isBibFullscreen;
4271
- this.bibElement.value.close();
4272
- this.bibElement.value.open(useModal);
4273
- }
4274
- }
4275
-
4276
- /**
4277
- * Handles the custom event `auroDropdown-toggled` to update the visibility of the dropdown bib.
4278
- * @private
4279
- * @param {CustomEvent} event - The custom event that contains the dropdown toggle information.
4280
- */
4281
- handleDropdownToggle(event) {
4282
- this.updateFocusTrap();
4283
- this.isPopoverVisible = event.detail.expanded;
4284
- const eventType = event.detail.eventType || "unknown";
4285
- if (!this.isPopoverVisible && this.hasFocus && eventType === "keydown") {
4286
- this.trigger.focus();
4287
- }
4288
- }
4289
-
4290
- firstUpdated() {
4291
- // Configure the floater to, this will generate the ID for the bib
4292
- this.floater.configure(this, 'auroDropdown', !this.disableKeyboardHandling);
4293
-
4294
- // Prevent `contain: layout` on the dropdown host. Layout containment
4295
- // creates a containing block for position:fixed descendants (the bib),
4296
- // which clips the bib inside ancestor overflow contexts such as a
4297
- // <dialog> element. Without it, the bib's position:fixed is relative
4298
- // to the viewport, letting Floating UI's flip middleware detect
4299
- // viewport boundaries and the bib escape overflow clipping.
4300
- const origConfigureBibStrategy = this.floater.configureBibStrategy.bind(this.floater);
4301
- this.floater.configureBibStrategy = (value) => {
4302
- origConfigureBibStrategy(value);
4303
- this.style.contain = '';
4304
- };
4305
-
4306
- this.addEventListener('auroDropdown-toggled', this.handleDropdownToggle);
4307
-
4308
- // Handle ESC key from dialog's cancel event
4309
- this.addEventListener('auro-bib-cancel', () => {
4310
- this.floater.hideBib('keydown');
4311
- });
4312
-
4313
- /**
4314
- * @description Let subscribers know that the dropdown ID ha been generated and added.
4315
- * @event auroDropdown-idAdded
4316
- * @type {Object<key: 'id', value: string>} - The ID of the dropdown bib element.
4317
- */
4318
- this.dispatchEvent(new CustomEvent('auroDropdown-idAdded', {detail: {id: this.floater.element.id}}));
4319
-
4320
- // Set the bib ID locally for aria-controls (must be in the same shadow root as the trigger)
4321
- if (!this.triggerContentFocusable) {
4322
- this.dropdownId = this.floater.element.bib.id;
4323
- }
4324
-
4325
- this.bibContent = this.floater.element.bib;
4326
-
4327
- // Add the tag name as an attribute if it is different than the component name
4328
- this.runtimeUtils.handleComponentTagRename(this, 'auro-dropdown');
4329
-
4330
- this.trigger.addEventListener('click', () => {
4331
- this.dispatchEvent(new CustomEvent('auroDropdown-triggerClick', {
4332
- bubbles: true,
4333
- composed: true
4334
- }));
4335
- });
4336
- }
4337
-
4338
- /**
4339
- * Exposes CSS parts for styling from parent components.
4340
- * @returns {void}
4341
- */
4342
- exposeCssParts() {
4343
- this.setAttribute('exportparts', 'trigger:dropdownTrigger, chevron:dropdownChevron, helpText:dropdownHelpText, size:dropdownSize');
4344
- }
4345
-
4346
- /**
4347
- * Determines if content is within a custom slot.
4348
- * @private
4349
- * @param {HTMLElement} element - The element to check.
4350
- * @returns {Boolean}
4351
- */
4352
- isCustomSlotContent(element) {
4353
- let currentElement = element;
4354
-
4355
- let inCustomSlot = false;
4356
-
4357
- while (currentElement) {
4358
- currentElement = currentElement.parentElement;
4359
-
4360
- if (currentElement && currentElement.hasAttribute('slot')) {
4361
- inCustomSlot = true;
4362
- break;
4363
- }
4364
- }
4365
-
4366
- return inCustomSlot;
4367
- }
4368
-
4369
- /**
4370
- * Function to support @focusin event.
4371
- * @private
4372
- * @return {void}
4373
- */
4374
- handleFocusin() {
4375
- this.hasFocus = true;
4376
- }
4377
-
4378
- /**
4379
- * @private
4380
- */
4381
- updateFocusTrap() {
4382
- if (this.isPopoverVisible) {
4383
- if (!this.isBibFullscreen) {
4384
- // Desktop: show() doesn't trap focus, so use FocusTrap
4385
- this.focusTrap = new FocusTrap(this.bibContent);
4386
- this.focusTrap.focusFirstElement();
4387
- }
4388
- // Fullscreen: showModal() provides native focus trapping
4389
- return;
4390
- }
4391
-
4392
- if (this.focusTrap) {
4393
- this.focusTrap.disconnect();
4394
- this.focusTrap = undefined;
4395
- }
4396
- }
4397
-
4398
- /**
4399
- * Function to support @focusout event.
4400
- * @private
4401
- * @return {void}
4402
- */
4403
- handleFocusout() {
4404
- this.hasFocus = false;
4405
- }
4406
-
4407
- /**
4408
- * Creates and dispatches a duplicate focus event on the trigger element.
4409
- * @private
4410
- * @param {Event} event - The original focus event.
4411
- */
4412
- bindFocusEventToTrigger(event) {
4413
- const dupEvent = new FocusEvent(event.type, {
4414
- bubbles: false,
4415
- cancelable: false,
4416
- composed: true,
4417
- });
4418
- this.trigger.dispatchEvent(dupEvent);
4419
- }
4420
-
4421
- /**
4422
- * Sets up event listeners to deliver focus and blur events from nested Auro components within the trigger slot to trigger.
4423
- * This ensures that focus/blur events originating from within these components are propagated to the trigger element itself.
4424
- * @private
4425
- */
4426
- setupTriggerFocusEventBinding() {
4427
- if (!this.triggerContentSlot || this.triggerContentSlot.length === 0) {
4428
- return;
4429
- }
4430
-
4431
- this.triggerContentSlot.forEach((node) => {
4432
- if (node.querySelectorAll) {
4433
- const auroElements = node.querySelectorAll(this.focusableEntityQuery);
4434
- auroElements.forEach((auroEl) => {
4435
- auroEl.addEventListener('focus', this.bindFocusEventToTrigger);
4436
- auroEl.addEventListener('blur', this.bindFocusEventToTrigger);
4437
- });
4438
- }
4439
- });
4440
- }
4441
-
4442
- /**
4443
- * Clears focus and blur event listeners from nested Auro components within the trigger slot.
4444
- * @private
4445
- * @returns {void}
4446
- */
4447
- clearTriggerFocusEventBinding() {
4448
- if (!this.triggerContentSlot || this.triggerContentSlot.length === 0) {
4449
- return;
4450
- }
4451
-
4452
- this.triggerContentSlot.forEach((node) => {
4453
- if (node.querySelectorAll) {
4454
- const auroElements = node.querySelectorAll(this.focusableEntityQuery);
4455
- auroElements.forEach((auroEl) => {
4456
- auroEl.removeEventListener('focus', this.bindFocusEventToTrigger);
4457
- auroEl.removeEventListener('blur', this.bindFocusEventToTrigger);
4458
- });
4459
- }
4460
- });
4461
- }
4462
-
4463
- /*
4464
- * Sets aria attributes for the trigger element if a custom one is passed in.
4465
- * @private
4466
- * @method setTriggerAriaAttributes
4467
- * @param { HTMLElement } triggerElement - The custom trigger element.
4468
- */
4469
- clearTriggerA11yAttributes(triggerElement) {
4470
-
4471
- if (!triggerElement || !triggerElement.removeAttribute) {
4472
- return;
4473
- }
4474
-
4475
- // Reset appropriate attributes for a11y
4476
- triggerElement.removeAttribute('aria-labelledby');
4477
- if (triggerElement.getAttribute('id') === `${this.id}-trigger-element`) {
4478
- triggerElement.removeAttribute('id');
4479
- }
4480
- triggerElement.removeAttribute('role');
4481
- triggerElement.removeAttribute('aria-expanded');
4482
-
4483
- triggerElement.removeAttribute('aria-controls');
4484
- triggerElement.removeAttribute('aria-autocomplete');
4485
- }
4486
-
4487
- /**
4488
- * Handles changes to the trigger content slot and updates related properties.
4489
- *
4490
- * It first updates the floater settings
4491
- * Then, it retrieves the assigned nodes from the event target and checks if any of
4492
- * the nodes contain non-empty text content, updating the `hasTriggerContent` property accordingly.
4493
- *
4494
- * @private
4495
- * @method handleTriggerContentSlotChange
4496
- * @param {Event} event - Native slotchange event.
4497
- * @returns {void}
4498
- */
4499
- handleTriggerContentSlotChange(event) {
4500
- this.floater.handleTriggerTabIndex();
4501
-
4502
- // Get the trigger
4503
- const trigger = this.shadowRoot.querySelector('#trigger');
4504
-
4505
- // Get the trigger slot
4506
- const triggerSlot = this.shadowRoot.querySelector('.triggerContentWrapper slot');
4507
-
4508
- // If there's a trigger slot
4509
- if (triggerSlot) {
4510
-
4511
- // Get the content nodes to see if there are any children
4512
- const triggerContentNodes = triggerSlot.assignedNodes();
4513
-
4514
- // If there are children
4515
- if (triggerContentNodes) {
4516
-
4517
- // See if any of them are focusable elements
4518
- this.triggerContentFocusable = triggerContentNodes.some((node) => getFocusableElements(node).length > 0);
4519
-
4520
- // If any of them are focusable elements
4521
- if (this.triggerContentFocusable) {
4522
-
4523
- // Assume the consumer will be providing their own a11y in whatever they passed in
4524
- this.clearTriggerA11yAttributes(trigger);
4525
-
4526
- // Remove the tabindex from the trigger so it doesn't interrupt focus flow
4527
- trigger.removeAttribute('tabindex');
4528
- } else {
4529
-
4530
- // Add the tabindex to the trigger so that it's in the focus flow
4531
- trigger.setAttribute('tabindex', '0');
4532
- }
4533
- }
4534
- }
4535
-
4536
- if (event) {
4537
- // Wrap in a try-catch block to handle errors when trying to use assignedNodes from the NodeJS test environment.
4538
- try {
4539
- this.triggerNode = event.target;
4540
- this.triggerContentSlot = event.target.assignedNodes();
4541
- } catch (error) {
4542
- console.warn('auro-dropdown: Unable to access the trigger content slot.', error); // eslint-disable-line no-console
4543
- }
4544
- }
4545
-
4546
- if (this.triggerContentSlot) {
4547
- this.setupTriggerFocusEventBinding();
4548
-
4549
- this.hasTriggerContent = this.triggerContentSlot.some((slot) => {
4550
- if (slot.textContent.trim()) {
4551
- return true;
4552
- }
4553
- const slotInSlot = slot.querySelector('slot');
4554
- if (!slotInSlot) {
4555
- return false;
4556
- }
4557
- const slotsInSlotNodes = slotInSlot.assignedNodes();
4558
- return slotsInSlotNodes.some((ss) => Boolean(ss.textContent.trim()));
4559
- });
4560
- } else {
4561
- this.hasTriggerContent = false;
4562
- }
4563
- }
4564
-
4565
- /**
4566
- * Handles the default slot change event and updates the content.
4567
- *
4568
- * This method retrieves all nodes assigned to the default slot of the event target and appends them
4569
- * to the `bibContent` element. If a callback function `onSlotChange` is defined, it is invoked to
4570
- * notify about the slot change.
4571
- *
4572
- * @private
4573
- * @method handleDefaultSlot
4574
- * @fires Function#onSlotChange - Optional callback invoked when the slot content changes.
4575
- */
4576
- handleDefaultSlot() {
4577
-
4578
- if (this.onSlotChange) {
4579
- this.onSlotChange();
4580
- }
4581
- }
4582
-
4583
- /**
4584
- * Returns HTML for the common portion of the layouts.
4585
- * @private
4586
- * @param {Object} helpTextClasses - Classes to apply to the help text container.
4587
- * @returns {html} - Returns HTML.
4588
- */
4589
- renderBasicHtml(helpTextClasses) {
4590
- return html$1`
4591
- <div>
4592
- <div
4593
- id="trigger"
4594
- class="${classMap(this.commonWrapperClasses)}" part="wrapper"
4595
- tabindex="${ifDefined(this.triggerContentFocusable ? undefined : this.tabIndex)}"
4596
- role="${ifDefined(this.triggerContentFocusable ? undefined : this.a11yRole)}"
4597
- aria-expanded="${ifDefined(this.a11yRole === 'button' || this.triggerContentFocusable ? undefined : this.isPopoverVisible)}"
4598
- aria-controls="${ifDefined(this.a11yRole === 'button' || this.triggerContentFocusable ? undefined : this.dropdownId)}"
4599
- aria-labelledby="${ifDefined(this.triggerContentFocusable ? undefined : 'triggerLabel')}"
4600
- aria-disabled="${ifDefined(this.disabled ? 'true' : undefined)}"
4601
- @focusin="${this.handleFocusin}"
4602
- @blur="${this.handleFocusOut}">
4603
- <div class="triggerContentWrapper" id="triggerLabel">
4604
- <slot
4605
- name="trigger"
4606
- @slotchange="${this.handleTriggerContentSlotChange}"></slot>
4607
- </div>
4608
- ${this.chevron ? html$1`
4609
- <div
4610
- id="showStateIcon"
4611
- class="chevron"
4612
- part="chevron"
4613
- aria-hidden="true">
4614
- <${this.iconTag}
4615
- category="interface"
4616
- name="${this.isPopoverVisible ? 'chevron-up' : `chevron-down`}"
4617
- appearance="${this.onDark ? 'inverse' : this.appearance}"
4618
- variant="${this.disabled ? 'disabled' : 'muted'}"
4619
- ariaHidden="true">
4620
- </${this.iconTag}>
4621
- </div>
4622
- ` : undefined }
4623
- </div>
4624
- <div class="${classMap(helpTextClasses)}">
4625
- <slot name="helpText"></slot>
4626
- </div>
4627
- <div id="bibSizer" part="size"></div>
4628
- <${this.dropdownBibTag}
4629
- id="bib"
4630
- shape="${this.shape}"
4631
- ?data-show="${this.isPopoverVisible}"
4632
- ?isfullscreen="${this.isBibFullscreen}"
4633
- .dialogLabel="${this.bibDialogLabel}"
4634
- ${ref(this.bibElement)}
4635
- >
4636
- <div class="slotContent">
4637
- <slot @slotchange="${this.handleDefaultSlot}"></slot>
4638
- </div>
4639
- </${this.dropdownBibTag}>
4640
- </div>
4641
- `;
4642
- }
4643
-
4644
- /**
4645
- * Returns HTML for the classic layout. Does not support type="*".
4646
- * @private
4647
- * @returns {html} - Returns HTML for the classic layout.
4648
- */
4649
- renderLayoutClassic() {
4650
- // TODO: check with Doug why this was never used?
4651
- const helpTextClasses = {
4652
- 'helpText': true
4653
- };
4654
-
4655
- return html$1`
4656
- ${this.renderBasicHtml(helpTextClasses)}
4657
- `;
4658
- }
4659
-
4660
- /**
4661
- * Returns HTML for the snowflake layout. Does not support type="*".
4662
- * @private
4663
- * @returns {html} - Returns HTML for the snowflake layout.
4664
- */
4665
- renderLayoutSnowflake() {
4666
- const helpTextClasses = {
4667
- 'helpText': true,
4668
- 'leftIndent': true,
4669
- 'rightIndent': true
4670
- };
4671
-
4672
- return html$1`
4673
- ${this.renderBasicHtml(helpTextClasses)}
4674
- `;
4675
- }
4676
-
4677
- /**
4678
- * Returns HTML for the emphasized layout. Does not support type="*".
4679
- * @private
4680
- * @returns {html} - Returns HTML for the emphasized layout.
4681
- */
4682
- renderLayoutEmphasized() {
4683
- const helpTextClasses = {
4684
- 'helpText': true,
4685
- 'leftIndent': this.shape.toLowerCase().includes('pill') && !this.shape.toLowerCase().includes('right'),
4686
- 'rightIndent': this.shape.toLowerCase().includes('pill') && !this.shape.toLowerCase().includes('left')
4687
- };
4688
-
4689
- return html$1`
4690
- ${this.renderBasicHtml(helpTextClasses)}
4691
- `;
4692
- }
4693
-
4694
- /**
4695
- * Logic to determine the layout of the component.
4696
- * @private
4697
- * @param {string} [ForcedLayout] - Used to force a specific layout, pass in the layout name to use.
4698
- * @returns {HTMLCollection} - Returns the HTML for the layout.
4699
- */
4700
- renderLayout(ForcedLayout) {
4701
- const layout = ForcedLayout || this.layout;
4702
-
4703
- switch (layout) {
4704
- case 'emphasized':
4705
- return this.renderLayoutEmphasized();
4706
- case 'emphasized-left':
4707
- return this.renderLayoutEmphasized();
4708
- case 'emphasized-right':
4709
- return this.renderLayoutEmphasized();
4710
- case 'snowflake':
4711
- return this.renderLayoutSnowflake();
4712
- case 'snowflake-left':
4713
- return this.renderLayoutSnowflake();
4714
- case 'snowflake-right':
4715
- return this.renderLayoutSnowflake();
4716
- default:
4717
- return this.renderLayoutClassic();
4718
- }
4719
- }
4720
- }
4721
-
4722
- export { AuroDropdown };