@aurodesignsystem-dev/auro-formkit 0.0.0-pr1379.0 → 0.0.0-pr1379.10

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