polaris_view_components 0.3.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -3
  3. data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +119 -0
  4. data/app/assets/javascripts/polaris_view_components/button_controller.js +47 -0
  5. data/app/assets/javascripts/polaris_view_components/frame_controller.js +41 -0
  6. data/app/assets/javascripts/polaris_view_components/index.js +19 -1
  7. data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
  8. data/app/assets/javascripts/polaris_view_components/option_list_controller.js +41 -0
  9. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +28 -0
  10. data/app/assets/javascripts/polaris_view_components/popover_controller.js +49 -0
  11. data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
  12. data/app/assets/javascripts/polaris_view_components/select_controller.js +6 -4
  13. data/app/assets/javascripts/polaris_view_components/text_field_controller.js +4 -0
  14. data/app/assets/javascripts/polaris_view_components/toast_controller.js +68 -0
  15. data/app/assets/javascripts/polaris_view_components.js +1936 -5
  16. data/app/assets/stylesheets/polaris_view_components/custom.css +109 -0
  17. data/app/assets/stylesheets/polaris_view_components/shopify_navigation.css +0 -4
  18. data/app/assets/stylesheets/polaris_view_components/spacer_component.css +39 -0
  19. data/app/assets/stylesheets/polaris_view_components.css +118 -3
  20. data/app/assets/stylesheets/polaris_view_components.postcss.css +2 -0
  21. data/app/components/polaris/action.rb +3 -3
  22. data/app/components/polaris/action_list/item_component.html.erb +35 -0
  23. data/app/components/polaris/action_list/item_component.rb +41 -0
  24. data/app/components/polaris/action_list/section_component.html.erb +16 -0
  25. data/app/components/polaris/action_list/section_component.rb +26 -0
  26. data/app/components/polaris/action_list_component.html.erb +13 -0
  27. data/app/components/polaris/action_list_component.rb +25 -0
  28. data/app/components/polaris/application_component.rb +19 -19
  29. data/app/components/polaris/autocomplete/action_component.rb +7 -0
  30. data/app/components/polaris/autocomplete/option_component.rb +35 -0
  31. data/app/components/polaris/autocomplete/section_component.html.erb +9 -0
  32. data/app/components/polaris/autocomplete/section_component.rb +12 -0
  33. data/app/components/polaris/autocomplete_component.html.erb +30 -0
  34. data/app/components/polaris/autocomplete_component.rb +58 -0
  35. data/app/components/polaris/avatar_component.rb +1 -1
  36. data/app/components/polaris/badge_component.rb +1 -1
  37. data/app/components/polaris/banner_component.rb +6 -6
  38. data/app/components/polaris/base_button.rb +1 -1
  39. data/app/components/polaris/base_checkbox.rb +48 -0
  40. data/app/components/polaris/base_radio_button.rb +38 -0
  41. data/app/components/polaris/button_component.html.erb +13 -0
  42. data/app/components/polaris/button_group_component.rb +5 -5
  43. data/app/components/polaris/callout_card_component.rb +5 -5
  44. data/app/components/polaris/caption_component.rb +2 -2
  45. data/app/components/polaris/card/header_component.rb +1 -3
  46. data/app/components/polaris/card/section_component.rb +6 -2
  47. data/app/components/polaris/card_component.html.erb +4 -0
  48. data/app/components/polaris/card_component.rb +5 -6
  49. data/app/components/polaris/character_count.rb +10 -10
  50. data/app/components/polaris/checkbox_component.html.erb +1 -5
  51. data/app/components/polaris/checkbox_component.rb +19 -12
  52. data/app/components/polaris/choice_component.rb +1 -1
  53. data/app/components/polaris/choice_list_component.rb +5 -5
  54. data/app/components/polaris/data_table/cell_component.html.erb +18 -0
  55. data/app/components/polaris/data_table/cell_component.rb +49 -0
  56. data/app/components/polaris/data_table/column_component.rb +19 -0
  57. data/app/components/polaris/data_table_component.html.erb +77 -0
  58. data/app/components/polaris/data_table_component.rb +42 -0
  59. data/app/components/polaris/description_list_component.rb +3 -3
  60. data/app/components/polaris/display_text_component.rb +2 -2
  61. data/app/components/polaris/dropzone/component.rb +36 -38
  62. data/app/components/polaris/empty_state_component.html.erb +16 -11
  63. data/app/components/polaris/empty_state_component.rb +4 -3
  64. data/app/components/polaris/exception_list/item_component.rb +2 -2
  65. data/app/components/polaris/exception_list_component.rb +1 -1
  66. data/app/components/polaris/filters_component.html.erb +35 -0
  67. data/app/components/polaris/filters_component.rb +91 -0
  68. data/app/components/polaris/footer_help_component.rb +1 -1
  69. data/app/components/polaris/form_layout/group_component.rb +3 -3
  70. data/app/components/polaris/form_layout/item_component.rb +1 -1
  71. data/app/components/polaris/form_layout_component.rb +3 -3
  72. data/app/components/polaris/frame/save_bar_component.html.erb +23 -0
  73. data/app/components/polaris/frame/save_bar_component.rb +31 -0
  74. data/app/components/polaris/frame/top_bar_component.html.erb +30 -0
  75. data/app/components/polaris/frame/top_bar_component.rb +18 -0
  76. data/app/components/polaris/frame_component.html.erb +44 -0
  77. data/app/components/polaris/frame_component.rb +33 -0
  78. data/app/components/polaris/heading_component.rb +1 -1
  79. data/app/components/polaris/headless_button.html.erb +13 -0
  80. data/app/components/polaris/headless_button.rb +17 -5
  81. data/app/components/polaris/icon_component.rb +2 -2
  82. data/app/components/polaris/index_table/cell_component.rb +22 -0
  83. data/app/components/polaris/index_table/column_component.rb +13 -0
  84. data/app/components/polaris/index_table_component.html.erb +28 -0
  85. data/app/components/polaris/index_table_component.rb +25 -0
  86. data/app/components/polaris/inline_error_component.html.erb +2 -2
  87. data/app/components/polaris/inline_error_component.rb +7 -1
  88. data/app/components/polaris/label_component.rb +2 -2
  89. data/app/components/polaris/labelled_component.rb +2 -2
  90. data/app/components/polaris/layout/annotated_section.rb +1 -1
  91. data/app/components/polaris/layout/section.rb +2 -0
  92. data/app/components/polaris/layout_component.rb +3 -3
  93. data/app/components/polaris/link_component.rb +5 -3
  94. data/app/components/polaris/list_component.rb +3 -3
  95. data/app/components/polaris/logo.rb +13 -0
  96. data/app/components/polaris/modal/section_component.rb +19 -0
  97. data/app/components/polaris/modal_component.html.erb +79 -0
  98. data/app/components/polaris/modal_component.rb +98 -0
  99. data/app/components/polaris/navigation/item_component.html.erb +31 -0
  100. data/app/components/polaris/navigation/item_component.rb +85 -0
  101. data/app/components/polaris/navigation/section_component.html.erb +17 -0
  102. data/app/components/polaris/navigation/section_component.rb +64 -0
  103. data/app/components/polaris/navigation_component.html.erb +29 -0
  104. data/app/components/polaris/navigation_component.rb +15 -0
  105. data/app/components/polaris/option_list/checkbox_component.html.erb +14 -0
  106. data/app/components/polaris/option_list/checkbox_component.rb +37 -0
  107. data/app/components/polaris/option_list/option_component.rb +24 -0
  108. data/app/components/polaris/option_list/radio_button_component.rb +54 -0
  109. data/app/components/polaris/option_list/section_component.html.erb +14 -0
  110. data/app/components/polaris/option_list/section_component.rb +53 -0
  111. data/app/components/polaris/option_list_component.html.erb +15 -0
  112. data/app/components/polaris/option_list_component.rb +67 -0
  113. data/app/components/polaris/page_actions_component.rb +21 -6
  114. data/app/components/polaris/page_component.rb +4 -4
  115. data/app/components/polaris/pagination_component.rb +1 -5
  116. data/app/components/polaris/popover/pane_component.html.erb +25 -0
  117. data/app/components/polaris/popover/pane_component.rb +20 -0
  118. data/app/components/polaris/popover/section_component.rb +19 -0
  119. data/app/components/polaris/popover_component.html.erb +31 -0
  120. data/app/components/polaris/popover_component.rb +107 -0
  121. data/app/components/polaris/progress_bar_component.rb +5 -5
  122. data/app/components/polaris/radio_button_component.html.erb +1 -6
  123. data/app/components/polaris/radio_button_component.rb +17 -7
  124. data/app/components/polaris/resource_item_component.html.erb +16 -6
  125. data/app/components/polaris/resource_item_component.rb +42 -9
  126. data/app/components/polaris/resource_list_component.html.erb +10 -0
  127. data/app/components/polaris/resource_list_component.rb +4 -10
  128. data/app/components/polaris/scrollable_component.html.erb +5 -0
  129. data/app/components/polaris/scrollable_component.rb +48 -0
  130. data/app/components/polaris/select_component.rb +10 -5
  131. data/app/components/polaris/setting_toggle_component.html.erb +10 -0
  132. data/app/components/polaris/setting_toggle_component.rb +24 -0
  133. data/app/components/polaris/shopify_navigation_component.rb +6 -6
  134. data/app/components/polaris/skeleton_body_text_component.rb +1 -1
  135. data/app/components/polaris/spacer_component.rb +50 -0
  136. data/app/components/polaris/spinner_component.rb +2 -2
  137. data/app/components/polaris/stack_component.rb +5 -5
  138. data/app/components/polaris/subheading_component.rb +1 -1
  139. data/app/components/polaris/tabs/tab_component.html.erb +10 -0
  140. data/app/components/polaris/tabs/tab_component.rb +34 -0
  141. data/app/components/polaris/tabs_component.html.erb +7 -0
  142. data/app/components/polaris/tabs_component.rb +37 -0
  143. data/app/components/polaris/tag_component.rb +2 -2
  144. data/app/components/polaris/text_container_component.rb +2 -2
  145. data/app/components/polaris/text_field_component.rb +24 -10
  146. data/app/components/polaris/text_style_component.rb +11 -2
  147. data/app/components/polaris/thumbnail_component.rb +2 -2
  148. data/app/components/polaris/toast_component.html.erb +21 -0
  149. data/app/components/polaris/toast_component.rb +40 -0
  150. data/app/components/polaris/top_bar/user_menu_component.html.erb +19 -0
  151. data/app/components/polaris/top_bar/user_menu_component.rb +9 -0
  152. data/app/helpers/polaris/form_builder.rb +31 -4
  153. data/app/helpers/polaris/url_helper.rb +3 -3
  154. data/app/helpers/polaris/view_helper.rb +37 -6
  155. data/app/validators/type_validator.rb +2 -2
  156. data/lib/generators/polaris_view_components/install_generator.rb +5 -5
  157. data/lib/polaris/view_components/engine.rb +11 -2
  158. data/lib/polaris/view_components/version.rb +1 -1
  159. data/lib/polaris_view_components.rb +1 -1
  160. metadata +88 -12
  161. data/app/components/polaris/choice_list/component.html.erb +0 -34
  162. data/app/components/polaris/choice_list/component.rb +0 -65
  163. data/app/helpers/polaris/action_helper.rb +0 -14
@@ -1,5 +1,1812 @@
1
1
  import { Controller } from "@hotwired/stimulus";
2
2
 
3
+ import { get } from "@rails/request.js";
4
+
5
+ class Autocomplete extends Controller {
6
+ static targets=[ "popover", "input", "results", "option", "emptyState" ];
7
+ static values={
8
+ url: String
9
+ };
10
+ connect() {
11
+ this.inputTarget.addEventListener("input", this.onInputChange);
12
+ }
13
+ disconnect() {
14
+ this.inputTarget.removeEventListener("input", this.onInputChange);
15
+ }
16
+ toggle() {
17
+ if (this.visibleOptions.length > 0) {
18
+ this.hideEmptyState();
19
+ this.popoverController.show();
20
+ } else if (this.value.length > 0 && this.hasEmptyStateTarget) {
21
+ this.showEmptyState();
22
+ } else {
23
+ this.popoverController.forceHide();
24
+ }
25
+ }
26
+ select(event) {
27
+ const input = event.currentTarget;
28
+ const label = input.closest("li").dataset.label;
29
+ const changeEvent = new CustomEvent("polaris-autocomplete:change", {
30
+ detail: {
31
+ value: input.value,
32
+ label: label,
33
+ selected: input.checked
34
+ }
35
+ });
36
+ this.element.dispatchEvent(changeEvent);
37
+ }
38
+ onInputChange=debounce$1((() => {
39
+ if (this.isRemote) {
40
+ this.fetchResults();
41
+ } else {
42
+ this.filterOptions();
43
+ }
44
+ }), 200);
45
+ get isRemote() {
46
+ return this.urlValue.length > 0;
47
+ }
48
+ get popoverController() {
49
+ return this.application.getControllerForElementAndIdentifier(this.popoverTarget, "polaris-popover");
50
+ }
51
+ get value() {
52
+ return this.inputTarget.value;
53
+ }
54
+ get visibleOptions() {
55
+ return this.optionTargets.filter((option => !option.classList.contains("Polaris--hidden")));
56
+ }
57
+ filterOptions() {
58
+ if (this.value === "") {
59
+ this.optionTargets.forEach((option => {
60
+ option.classList.remove("Polaris--hidden");
61
+ }));
62
+ } else {
63
+ const filterRegex = new RegExp(this.value, "i");
64
+ this.optionTargets.forEach((option => {
65
+ if (option.dataset.label.match(filterRegex)) {
66
+ option.classList.remove("Polaris--hidden");
67
+ } else {
68
+ option.classList.add("Polaris--hidden");
69
+ }
70
+ }));
71
+ }
72
+ this.toggle();
73
+ }
74
+ async fetchResults() {
75
+ const response = await get(this.urlValue, {
76
+ query: {
77
+ q: this.value
78
+ }
79
+ });
80
+ if (response.ok) {
81
+ const results = await response.html;
82
+ this.resultsTarget.innerHTML = results;
83
+ this.toggle();
84
+ }
85
+ }
86
+ showEmptyState() {
87
+ if (this.hasEmptyStateTarget) {
88
+ this.resultsTarget.classList.add("Polaris--hidden");
89
+ this.emptyStateTarget.classList.remove("Polaris--hidden");
90
+ }
91
+ }
92
+ hideEmptyState() {
93
+ if (this.hasEmptyStateTarget) {
94
+ this.emptyStateTarget.classList.add("Polaris--hidden");
95
+ this.resultsTarget.classList.remove("Polaris--hidden");
96
+ }
97
+ }
98
+ }
99
+
100
+ const debounce$1 = (fn, delay = 10) => {
101
+ let timeoutId = null;
102
+ return (...args) => {
103
+ clearTimeout(timeoutId);
104
+ timeoutId = setTimeout(fn, delay);
105
+ };
106
+ };
107
+
108
+ class Button extends Controller {
109
+ disable(event) {
110
+ if (this.button.disabled) {
111
+ event.preventDefault();
112
+ } else {
113
+ this.button.disabled = true;
114
+ this.button.classList.add("Polaris-Button--disabled", "Polaris-Button--loading");
115
+ this.buttonContent.insertAdjacentHTML("afterbegin", this.spinnerHTML);
116
+ }
117
+ }
118
+ enable() {
119
+ if (this.button.disabled) {
120
+ this.button.disabled = false;
121
+ this.button.classList.remove("Polaris-Button--disabled", "Polaris-Button--loading");
122
+ if (this.spinner) this.spinner.remove();
123
+ }
124
+ }
125
+ get button() {
126
+ return this.element;
127
+ }
128
+ get buttonContent() {
129
+ return this.button.querySelector(".Polaris-Button__Content");
130
+ }
131
+ get spinner() {
132
+ return this.button.querySelector(".Polaris-Button__Spinner");
133
+ }
134
+ get spinnerHTML() {
135
+ return `\n <span class="Polaris-Button__Spinner">\n <span class="Polaris-Spinner Polaris-Spinner--sizeSmall">\n <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">\n <path d="M7.229 1.173a9.25 9.25 0 1011.655 11.412 1.25 1.25 0 10-2.4-.698 6.75 6.75 0 11-8.506-8.329 1.25 1.25 0 10-.75-2.385z"></path>\n </svg>\n </span>\n </span>\n `;
136
+ }
137
+ }
138
+
139
+ const alpineNames = {
140
+ enterFromClass: "enter",
141
+ enterActiveClass: "enterStart",
142
+ enterToClass: "enterEnd",
143
+ leaveFromClass: "leave",
144
+ leaveActiveClass: "leaveStart",
145
+ leaveToClass: "leaveEnd"
146
+ };
147
+
148
+ const defaultOptions = {
149
+ transitioned: false,
150
+ hiddenClass: "hidden",
151
+ preserveOriginalClass: true,
152
+ removeToClasses: true
153
+ };
154
+
155
+ const useTransition = (controller, options = {}) => {
156
+ var _a, _b, _c;
157
+ const targetName = controller.element.dataset.transitionTarget;
158
+ let targetFromAttribute;
159
+ if (targetName) {
160
+ targetFromAttribute = controller[`${targetName}Target`];
161
+ }
162
+ const targetElement = (options === null || options === void 0 ? void 0 : options.element) || targetFromAttribute || controller.element;
163
+ if (!(targetElement instanceof HTMLElement || targetElement instanceof SVGElement)) return;
164
+ const dataset = targetElement.dataset;
165
+ const leaveAfter = parseInt(dataset.leaveAfter || "") || options.leaveAfter || 0;
166
+ const {transitioned: transitioned, hiddenClass: hiddenClass, preserveOriginalClass: preserveOriginalClass, removeToClasses: removeToClasses} = Object.assign(defaultOptions, options);
167
+ const controllerEnter = (_a = controller.enter) === null || _a === void 0 ? void 0 : _a.bind(controller);
168
+ const controllerLeave = (_b = controller.leave) === null || _b === void 0 ? void 0 : _b.bind(controller);
169
+ const controllerToggleTransition = (_c = controller.toggleTransition) === null || _c === void 0 ? void 0 : _c.bind(controller);
170
+ async function enter(event) {
171
+ if (controller.transitioned) return;
172
+ controller.transitioned = true;
173
+ controllerEnter && controllerEnter(event);
174
+ const enterFromClasses = getAttribute("enterFrom", options, dataset);
175
+ const enterActiveClasses = getAttribute("enterActive", options, dataset);
176
+ const enterToClasses = getAttribute("enterTo", options, dataset);
177
+ const leaveToClasses = getAttribute("leaveTo", options, dataset);
178
+ if (!!hiddenClass) {
179
+ targetElement.classList.remove(hiddenClass);
180
+ }
181
+ if (!removeToClasses) {
182
+ removeClasses(targetElement, leaveToClasses);
183
+ }
184
+ await transition(targetElement, enterFromClasses, enterActiveClasses, enterToClasses, hiddenClass, preserveOriginalClass, removeToClasses);
185
+ if (leaveAfter > 0) {
186
+ setTimeout((() => {
187
+ leave(event);
188
+ }), leaveAfter);
189
+ }
190
+ }
191
+ async function leave(event) {
192
+ if (!controller.transitioned) return;
193
+ controller.transitioned = false;
194
+ controllerLeave && controllerLeave(event);
195
+ const leaveFromClasses = getAttribute("leaveFrom", options, dataset);
196
+ const leaveActiveClasses = getAttribute("leaveActive", options, dataset);
197
+ const leaveToClasses = getAttribute("leaveTo", options, dataset);
198
+ const enterToClasses = getAttribute("enterTo", options, dataset);
199
+ if (!removeToClasses) {
200
+ removeClasses(targetElement, enterToClasses);
201
+ }
202
+ await transition(targetElement, leaveFromClasses, leaveActiveClasses, leaveToClasses, hiddenClass, preserveOriginalClass, removeToClasses);
203
+ if (!!hiddenClass) {
204
+ targetElement.classList.add(hiddenClass);
205
+ }
206
+ }
207
+ function toggleTransition(event) {
208
+ controllerToggleTransition && controllerToggleTransition(event);
209
+ if (controller.transitioned) {
210
+ leave();
211
+ } else {
212
+ enter();
213
+ }
214
+ }
215
+ async function transition(element, initialClasses, activeClasses, endClasses, hiddenClass, preserveOriginalClass, removeEndClasses) {
216
+ const stashedClasses = [];
217
+ if (preserveOriginalClass) {
218
+ initialClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
219
+ activeClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
220
+ endClasses.forEach((cls => element.classList.contains(cls) && cls !== hiddenClass && stashedClasses.push(cls)));
221
+ }
222
+ addClasses(element, initialClasses);
223
+ removeClasses(element, stashedClasses);
224
+ addClasses(element, activeClasses);
225
+ await nextAnimationFrame();
226
+ removeClasses(element, initialClasses);
227
+ addClasses(element, endClasses);
228
+ await afterTransition(element);
229
+ removeClasses(element, activeClasses);
230
+ if (removeEndClasses) {
231
+ removeClasses(element, endClasses);
232
+ }
233
+ addClasses(element, stashedClasses);
234
+ }
235
+ function initialState() {
236
+ controller.transitioned = transitioned;
237
+ if (transitioned) {
238
+ if (!!hiddenClass) {
239
+ targetElement.classList.remove(hiddenClass);
240
+ }
241
+ enter();
242
+ } else {
243
+ if (!!hiddenClass) {
244
+ targetElement.classList.add(hiddenClass);
245
+ }
246
+ leave();
247
+ }
248
+ }
249
+ function addClasses(element, classes) {
250
+ if (classes.length > 0) {
251
+ element.classList.add(...classes);
252
+ }
253
+ }
254
+ function removeClasses(element, classes) {
255
+ if (classes.length > 0) {
256
+ element.classList.remove(...classes);
257
+ }
258
+ }
259
+ initialState();
260
+ Object.assign(controller, {
261
+ enter: enter,
262
+ leave: leave,
263
+ toggleTransition: toggleTransition
264
+ });
265
+ return [ enter, leave, toggleTransition ];
266
+ };
267
+
268
+ function getAttribute(name, options, dataset) {
269
+ const datasetName = `transition${name[0].toUpperCase()}${name.substr(1)}`;
270
+ const datasetAlpineName = alpineNames[name];
271
+ const classes = options[name] || dataset[datasetName] || dataset[datasetAlpineName] || " ";
272
+ return isEmpty(classes) ? [] : classes.split(" ");
273
+ }
274
+
275
+ async function afterTransition(element) {
276
+ return new Promise((resolve => {
277
+ const duration = Number(getComputedStyle(element).transitionDuration.split(",")[0].replace("s", "")) * 1e3;
278
+ setTimeout((() => {
279
+ resolve(duration);
280
+ }), duration);
281
+ }));
282
+ }
283
+
284
+ async function nextAnimationFrame() {
285
+ return new Promise((resolve => {
286
+ requestAnimationFrame((() => {
287
+ requestAnimationFrame(resolve);
288
+ }));
289
+ }));
290
+ }
291
+
292
+ function isEmpty(str) {
293
+ return str.length === 0 || !str.trim();
294
+ }
295
+
296
+ class Frame extends Controller {
297
+ static targets=[ "navigationOverlay", "navigation", "saveBar" ];
298
+ connect() {
299
+ if (!this.hasNavigationTarget) {
300
+ return;
301
+ }
302
+ useTransition(this, {
303
+ element: this.navigationTarget,
304
+ enterFrom: "Polaris-Frame__Navigation--enter",
305
+ enterTo: "Polaris-Frame__Navigation--visible Polaris-Frame__Navigation--enterActive",
306
+ leaveActive: "Polaris-Frame__Navigation--exitActive",
307
+ leaveFrom: "Polaris-Frame__Navigation--exit",
308
+ leaveTo: "",
309
+ removeToClasses: false,
310
+ hiddenClass: false
311
+ });
312
+ }
313
+ openMenu() {
314
+ this.enter();
315
+ this.navigationOverlayTarget.classList.add("Polaris-Backdrop", "Polaris-Backdrop--belowNavigation");
316
+ }
317
+ closeMenu() {
318
+ this.leave();
319
+ this.navigationOverlayTarget.classList.remove("Polaris-Backdrop", "Polaris-Backdrop--belowNavigation");
320
+ }
321
+ showSaveBar() {
322
+ this.saveBarTarget.classList.add("Polaris-Frame-CSSAnimation--endFade");
323
+ }
324
+ hideSaveBar() {
325
+ this.saveBarTarget.classList.remove("Polaris-Frame-CSSAnimation--endFade");
326
+ }
327
+ }
328
+
329
+ class Modal extends Controller {
330
+ static classes=[ "hidden", "backdrop" ];
331
+ static values={
332
+ open: Boolean
333
+ };
334
+ connect() {
335
+ if (this.openValue) {
336
+ this.open();
337
+ }
338
+ }
339
+ open() {
340
+ this.element.classList.remove(this.hiddenClass);
341
+ this.element.insertAdjacentHTML("afterend", `<div class="${this.backdropClass}"></div>`);
342
+ this.backdrop = this.element.nextElementSibling;
343
+ }
344
+ close() {
345
+ this.element.classList.add(this.hiddenClass);
346
+ this.backdrop.remove();
347
+ }
348
+ }
349
+
350
+ class OptionList extends Controller {
351
+ static targets=[ "radioButton" ];
352
+ static classes=[ "selected" ];
353
+ connect() {
354
+ this.updateSelected();
355
+ }
356
+ update(event) {
357
+ const target = event.currentTarget;
358
+ target.classList.add(this.selectedClass);
359
+ this.deselectAll(target);
360
+ }
361
+ updateSelected() {
362
+ this.radioButtonTargets.forEach((element => {
363
+ const input = element.querySelector("input[type=radio]");
364
+ if (input.checked) {
365
+ element.classList.add(this.selectedClass);
366
+ } else {
367
+ element.classList.remove(this.selectedClass);
368
+ }
369
+ }));
370
+ }
371
+ deselectAll(target) {
372
+ this.radioButtonTargets.forEach((element => {
373
+ if (!element.isEqualNode(target)) {
374
+ const input = element.querySelector("input[type=radio]");
375
+ input.checked = false;
376
+ element.classList.remove(this.selectedClass);
377
+ }
378
+ }));
379
+ }
380
+ }
381
+
382
+ class Polaris extends Controller {
383
+ openModal() {
384
+ this.findElement("modal").open();
385
+ }
386
+ disableButton() {
387
+ this.findElement("button").disable();
388
+ }
389
+ enableButton() {
390
+ this.findElement("button").enable();
391
+ }
392
+ showToast() {
393
+ this.findElement("toast").show();
394
+ }
395
+ findElement(type) {
396
+ const targetId = this.element.dataset.target.replace("#", "");
397
+ const target = document.getElementById(targetId);
398
+ const controllerName = `polaris-${type}`;
399
+ return this.application.getControllerForElementAndIdentifier(target, controllerName);
400
+ }
401
+ }
402
+
403
+ var top = "top";
404
+
405
+ var bottom = "bottom";
406
+
407
+ var right = "right";
408
+
409
+ var left = "left";
410
+
411
+ var auto = "auto";
412
+
413
+ var basePlacements = [ top, bottom, right, left ];
414
+
415
+ var start = "start";
416
+
417
+ var end = "end";
418
+
419
+ var clippingParents = "clippingParents";
420
+
421
+ var viewport = "viewport";
422
+
423
+ var popper = "popper";
424
+
425
+ var reference = "reference";
426
+
427
+ var variationPlacements = basePlacements.reduce((function(acc, placement) {
428
+ return acc.concat([ placement + "-" + start, placement + "-" + end ]);
429
+ }), []);
430
+
431
+ var placements = [].concat(basePlacements, [ auto ]).reduce((function(acc, placement) {
432
+ return acc.concat([ placement, placement + "-" + start, placement + "-" + end ]);
433
+ }), []);
434
+
435
+ var beforeRead = "beforeRead";
436
+
437
+ var read = "read";
438
+
439
+ var afterRead = "afterRead";
440
+
441
+ var beforeMain = "beforeMain";
442
+
443
+ var main = "main";
444
+
445
+ var afterMain = "afterMain";
446
+
447
+ var beforeWrite = "beforeWrite";
448
+
449
+ var write = "write";
450
+
451
+ var afterWrite = "afterWrite";
452
+
453
+ var modifierPhases = [ beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite ];
454
+
455
+ function getNodeName(element) {
456
+ return element ? (element.nodeName || "").toLowerCase() : null;
457
+ }
458
+
459
+ function getWindow(node) {
460
+ if (node == null) {
461
+ return window;
462
+ }
463
+ if (node.toString() !== "[object Window]") {
464
+ var ownerDocument = node.ownerDocument;
465
+ return ownerDocument ? ownerDocument.defaultView || window : window;
466
+ }
467
+ return node;
468
+ }
469
+
470
+ function isElement(node) {
471
+ var OwnElement = getWindow(node).Element;
472
+ return node instanceof OwnElement || node instanceof Element;
473
+ }
474
+
475
+ function isHTMLElement(node) {
476
+ var OwnElement = getWindow(node).HTMLElement;
477
+ return node instanceof OwnElement || node instanceof HTMLElement;
478
+ }
479
+
480
+ function isShadowRoot(node) {
481
+ if (typeof ShadowRoot === "undefined") {
482
+ return false;
483
+ }
484
+ var OwnElement = getWindow(node).ShadowRoot;
485
+ return node instanceof OwnElement || node instanceof ShadowRoot;
486
+ }
487
+
488
+ function applyStyles(_ref) {
489
+ var state = _ref.state;
490
+ Object.keys(state.elements).forEach((function(name) {
491
+ var style = state.styles[name] || {};
492
+ var attributes = state.attributes[name] || {};
493
+ var element = state.elements[name];
494
+ if (!isHTMLElement(element) || !getNodeName(element)) {
495
+ return;
496
+ }
497
+ Object.assign(element.style, style);
498
+ Object.keys(attributes).forEach((function(name) {
499
+ var value = attributes[name];
500
+ if (value === false) {
501
+ element.removeAttribute(name);
502
+ } else {
503
+ element.setAttribute(name, value === true ? "" : value);
504
+ }
505
+ }));
506
+ }));
507
+ }
508
+
509
+ function effect$2(_ref2) {
510
+ var state = _ref2.state;
511
+ var initialStyles = {
512
+ popper: {
513
+ position: state.options.strategy,
514
+ left: "0",
515
+ top: "0",
516
+ margin: "0"
517
+ },
518
+ arrow: {
519
+ position: "absolute"
520
+ },
521
+ reference: {}
522
+ };
523
+ Object.assign(state.elements.popper.style, initialStyles.popper);
524
+ state.styles = initialStyles;
525
+ if (state.elements.arrow) {
526
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
527
+ }
528
+ return function() {
529
+ Object.keys(state.elements).forEach((function(name) {
530
+ var element = state.elements[name];
531
+ var attributes = state.attributes[name] || {};
532
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
533
+ var style = styleProperties.reduce((function(style, property) {
534
+ style[property] = "";
535
+ return style;
536
+ }), {});
537
+ if (!isHTMLElement(element) || !getNodeName(element)) {
538
+ return;
539
+ }
540
+ Object.assign(element.style, style);
541
+ Object.keys(attributes).forEach((function(attribute) {
542
+ element.removeAttribute(attribute);
543
+ }));
544
+ }));
545
+ };
546
+ }
547
+
548
+ var applyStyles$1 = {
549
+ name: "applyStyles",
550
+ enabled: true,
551
+ phase: "write",
552
+ fn: applyStyles,
553
+ effect: effect$2,
554
+ requires: [ "computeStyles" ]
555
+ };
556
+
557
+ function getBasePlacement(placement) {
558
+ return placement.split("-")[0];
559
+ }
560
+
561
+ function getBoundingClientRect(element, includeScale) {
562
+ var rect = element.getBoundingClientRect();
563
+ var scaleX = 1;
564
+ var scaleY = 1;
565
+ return {
566
+ width: rect.width / scaleX,
567
+ height: rect.height / scaleY,
568
+ top: rect.top / scaleY,
569
+ right: rect.right / scaleX,
570
+ bottom: rect.bottom / scaleY,
571
+ left: rect.left / scaleX,
572
+ x: rect.left / scaleX,
573
+ y: rect.top / scaleY
574
+ };
575
+ }
576
+
577
+ function getLayoutRect(element) {
578
+ var clientRect = getBoundingClientRect(element);
579
+ var width = element.offsetWidth;
580
+ var height = element.offsetHeight;
581
+ if (Math.abs(clientRect.width - width) <= 1) {
582
+ width = clientRect.width;
583
+ }
584
+ if (Math.abs(clientRect.height - height) <= 1) {
585
+ height = clientRect.height;
586
+ }
587
+ return {
588
+ x: element.offsetLeft,
589
+ y: element.offsetTop,
590
+ width: width,
591
+ height: height
592
+ };
593
+ }
594
+
595
+ function contains(parent, child) {
596
+ var rootNode = child.getRootNode && child.getRootNode();
597
+ if (parent.contains(child)) {
598
+ return true;
599
+ } else if (rootNode && isShadowRoot(rootNode)) {
600
+ var next = child;
601
+ do {
602
+ if (next && parent.isSameNode(next)) {
603
+ return true;
604
+ }
605
+ next = next.parentNode || next.host;
606
+ } while (next);
607
+ }
608
+ return false;
609
+ }
610
+
611
+ function getComputedStyle$1(element) {
612
+ return getWindow(element).getComputedStyle(element);
613
+ }
614
+
615
+ function isTableElement(element) {
616
+ return [ "table", "td", "th" ].indexOf(getNodeName(element)) >= 0;
617
+ }
618
+
619
+ function getDocumentElement(element) {
620
+ return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;
621
+ }
622
+
623
+ function getParentNode(element) {
624
+ if (getNodeName(element) === "html") {
625
+ return element;
626
+ }
627
+ return element.assignedSlot || element.parentNode || (isShadowRoot(element) ? element.host : null) || getDocumentElement(element);
628
+ }
629
+
630
+ function getTrueOffsetParent(element) {
631
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
632
+ return null;
633
+ }
634
+ return element.offsetParent;
635
+ }
636
+
637
+ function getContainingBlock(element) {
638
+ var isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") !== -1;
639
+ var isIE = navigator.userAgent.indexOf("Trident") !== -1;
640
+ if (isIE && isHTMLElement(element)) {
641
+ var elementCss = getComputedStyle$1(element);
642
+ if (elementCss.position === "fixed") {
643
+ return null;
644
+ }
645
+ }
646
+ var currentNode = getParentNode(element);
647
+ while (isHTMLElement(currentNode) && [ "html", "body" ].indexOf(getNodeName(currentNode)) < 0) {
648
+ var css = getComputedStyle$1(currentNode);
649
+ if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || [ "transform", "perspective" ].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
650
+ return currentNode;
651
+ } else {
652
+ currentNode = currentNode.parentNode;
653
+ }
654
+ }
655
+ return null;
656
+ }
657
+
658
+ function getOffsetParent(element) {
659
+ var window = getWindow(element);
660
+ var offsetParent = getTrueOffsetParent(element);
661
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
662
+ offsetParent = getTrueOffsetParent(offsetParent);
663
+ }
664
+ if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
665
+ return window;
666
+ }
667
+ return offsetParent || getContainingBlock(element) || window;
668
+ }
669
+
670
+ function getMainAxisFromPlacement(placement) {
671
+ return [ "top", "bottom" ].indexOf(placement) >= 0 ? "x" : "y";
672
+ }
673
+
674
+ var max = Math.max;
675
+
676
+ var min = Math.min;
677
+
678
+ var round = Math.round;
679
+
680
+ function within(min$1, value, max$1) {
681
+ return max(min$1, min(value, max$1));
682
+ }
683
+
684
+ function getFreshSideObject() {
685
+ return {
686
+ top: 0,
687
+ right: 0,
688
+ bottom: 0,
689
+ left: 0
690
+ };
691
+ }
692
+
693
+ function mergePaddingObject(paddingObject) {
694
+ return Object.assign({}, getFreshSideObject(), paddingObject);
695
+ }
696
+
697
+ function expandToHashMap(value, keys) {
698
+ return keys.reduce((function(hashMap, key) {
699
+ hashMap[key] = value;
700
+ return hashMap;
701
+ }), {});
702
+ }
703
+
704
+ var toPaddingObject = function toPaddingObject(padding, state) {
705
+ padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
706
+ placement: state.placement
707
+ })) : padding;
708
+ return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
709
+ };
710
+
711
+ function arrow(_ref) {
712
+ var _state$modifiersData$;
713
+ var state = _ref.state, name = _ref.name, options = _ref.options;
714
+ var arrowElement = state.elements.arrow;
715
+ var popperOffsets = state.modifiersData.popperOffsets;
716
+ var basePlacement = getBasePlacement(state.placement);
717
+ var axis = getMainAxisFromPlacement(basePlacement);
718
+ var isVertical = [ left, right ].indexOf(basePlacement) >= 0;
719
+ var len = isVertical ? "height" : "width";
720
+ if (!arrowElement || !popperOffsets) {
721
+ return;
722
+ }
723
+ var paddingObject = toPaddingObject(options.padding, state);
724
+ var arrowRect = getLayoutRect(arrowElement);
725
+ var minProp = axis === "y" ? top : left;
726
+ var maxProp = axis === "y" ? bottom : right;
727
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
728
+ var startDiff = popperOffsets[axis] - state.rects.reference[axis];
729
+ var arrowOffsetParent = getOffsetParent(arrowElement);
730
+ var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
731
+ var centerToReference = endDiff / 2 - startDiff / 2;
732
+ var min = paddingObject[minProp];
733
+ var max = clientSize - arrowRect[len] - paddingObject[maxProp];
734
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
735
+ var offset = within(min, center, max);
736
+ var axisProp = axis;
737
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset,
738
+ _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
739
+ }
740
+
741
+ function effect$1(_ref2) {
742
+ var state = _ref2.state, options = _ref2.options;
743
+ var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
744
+ if (arrowElement == null) {
745
+ return;
746
+ }
747
+ if (typeof arrowElement === "string") {
748
+ arrowElement = state.elements.popper.querySelector(arrowElement);
749
+ if (!arrowElement) {
750
+ return;
751
+ }
752
+ }
753
+ if (!contains(state.elements.popper, arrowElement)) {
754
+ return;
755
+ }
756
+ state.elements.arrow = arrowElement;
757
+ }
758
+
759
+ var arrow$1 = {
760
+ name: "arrow",
761
+ enabled: true,
762
+ phase: "main",
763
+ fn: arrow,
764
+ effect: effect$1,
765
+ requires: [ "popperOffsets" ],
766
+ requiresIfExists: [ "preventOverflow" ]
767
+ };
768
+
769
+ function getVariation(placement) {
770
+ return placement.split("-")[1];
771
+ }
772
+
773
+ var unsetSides = {
774
+ top: "auto",
775
+ right: "auto",
776
+ bottom: "auto",
777
+ left: "auto"
778
+ };
779
+
780
+ function roundOffsetsByDPR(_ref) {
781
+ var x = _ref.x, y = _ref.y;
782
+ var win = window;
783
+ var dpr = win.devicePixelRatio || 1;
784
+ return {
785
+ x: round(round(x * dpr) / dpr) || 0,
786
+ y: round(round(y * dpr) / dpr) || 0
787
+ };
788
+ }
789
+
790
+ function mapToStyles(_ref2) {
791
+ var _Object$assign2;
792
+ var popper = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets;
793
+ var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === "function" ? roundOffsets(offsets) : offsets, _ref3$x = _ref3.x, x = _ref3$x === void 0 ? 0 : _ref3$x, _ref3$y = _ref3.y, y = _ref3$y === void 0 ? 0 : _ref3$y;
794
+ var hasX = offsets.hasOwnProperty("x");
795
+ var hasY = offsets.hasOwnProperty("y");
796
+ var sideX = left;
797
+ var sideY = top;
798
+ var win = window;
799
+ if (adaptive) {
800
+ var offsetParent = getOffsetParent(popper);
801
+ var heightProp = "clientHeight";
802
+ var widthProp = "clientWidth";
803
+ if (offsetParent === getWindow(popper)) {
804
+ offsetParent = getDocumentElement(popper);
805
+ if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
806
+ heightProp = "scrollHeight";
807
+ widthProp = "scrollWidth";
808
+ }
809
+ }
810
+ offsetParent = offsetParent;
811
+ if (placement === top || (placement === left || placement === right) && variation === end) {
812
+ sideY = bottom;
813
+ y -= offsetParent[heightProp] - popperRect.height;
814
+ y *= gpuAcceleration ? 1 : -1;
815
+ }
816
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
817
+ sideX = right;
818
+ x -= offsetParent[widthProp] - popperRect.width;
819
+ x *= gpuAcceleration ? 1 : -1;
820
+ }
821
+ }
822
+ var commonStyles = Object.assign({
823
+ position: position
824
+ }, adaptive && unsetSides);
825
+ if (gpuAcceleration) {
826
+ var _Object$assign;
827
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "",
828
+ _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)",
829
+ _Object$assign));
830
+ }
831
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "",
832
+ _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
833
+ }
834
+
835
+ function computeStyles(_ref4) {
836
+ var state = _ref4.state, options = _ref4.options;
837
+ var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
838
+ var commonStyles = {
839
+ placement: getBasePlacement(state.placement),
840
+ variation: getVariation(state.placement),
841
+ popper: state.elements.popper,
842
+ popperRect: state.rects.popper,
843
+ gpuAcceleration: gpuAcceleration
844
+ };
845
+ if (state.modifiersData.popperOffsets != null) {
846
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
847
+ offsets: state.modifiersData.popperOffsets,
848
+ position: state.options.strategy,
849
+ adaptive: adaptive,
850
+ roundOffsets: roundOffsets
851
+ })));
852
+ }
853
+ if (state.modifiersData.arrow != null) {
854
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
855
+ offsets: state.modifiersData.arrow,
856
+ position: "absolute",
857
+ adaptive: false,
858
+ roundOffsets: roundOffsets
859
+ })));
860
+ }
861
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
862
+ "data-popper-placement": state.placement
863
+ });
864
+ }
865
+
866
+ var computeStyles$1 = {
867
+ name: "computeStyles",
868
+ enabled: true,
869
+ phase: "beforeWrite",
870
+ fn: computeStyles,
871
+ data: {}
872
+ };
873
+
874
+ var passive = {
875
+ passive: true
876
+ };
877
+
878
+ function effect(_ref) {
879
+ var state = _ref.state, instance = _ref.instance, options = _ref.options;
880
+ var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
881
+ var window = getWindow(state.elements.popper);
882
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
883
+ if (scroll) {
884
+ scrollParents.forEach((function(scrollParent) {
885
+ scrollParent.addEventListener("scroll", instance.update, passive);
886
+ }));
887
+ }
888
+ if (resize) {
889
+ window.addEventListener("resize", instance.update, passive);
890
+ }
891
+ return function() {
892
+ if (scroll) {
893
+ scrollParents.forEach((function(scrollParent) {
894
+ scrollParent.removeEventListener("scroll", instance.update, passive);
895
+ }));
896
+ }
897
+ if (resize) {
898
+ window.removeEventListener("resize", instance.update, passive);
899
+ }
900
+ };
901
+ }
902
+
903
+ var eventListeners = {
904
+ name: "eventListeners",
905
+ enabled: true,
906
+ phase: "write",
907
+ fn: function fn() {},
908
+ effect: effect,
909
+ data: {}
910
+ };
911
+
912
+ var hash$1 = {
913
+ left: "right",
914
+ right: "left",
915
+ bottom: "top",
916
+ top: "bottom"
917
+ };
918
+
919
+ function getOppositePlacement(placement) {
920
+ return placement.replace(/left|right|bottom|top/g, (function(matched) {
921
+ return hash$1[matched];
922
+ }));
923
+ }
924
+
925
+ var hash = {
926
+ start: "end",
927
+ end: "start"
928
+ };
929
+
930
+ function getOppositeVariationPlacement(placement) {
931
+ return placement.replace(/start|end/g, (function(matched) {
932
+ return hash[matched];
933
+ }));
934
+ }
935
+
936
+ function getWindowScroll(node) {
937
+ var win = getWindow(node);
938
+ var scrollLeft = win.pageXOffset;
939
+ var scrollTop = win.pageYOffset;
940
+ return {
941
+ scrollLeft: scrollLeft,
942
+ scrollTop: scrollTop
943
+ };
944
+ }
945
+
946
+ function getWindowScrollBarX(element) {
947
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
948
+ }
949
+
950
+ function getViewportRect(element) {
951
+ var win = getWindow(element);
952
+ var html = getDocumentElement(element);
953
+ var visualViewport = win.visualViewport;
954
+ var width = html.clientWidth;
955
+ var height = html.clientHeight;
956
+ var x = 0;
957
+ var y = 0;
958
+ if (visualViewport) {
959
+ width = visualViewport.width;
960
+ height = visualViewport.height;
961
+ if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
962
+ x = visualViewport.offsetLeft;
963
+ y = visualViewport.offsetTop;
964
+ }
965
+ }
966
+ return {
967
+ width: width,
968
+ height: height,
969
+ x: x + getWindowScrollBarX(element),
970
+ y: y
971
+ };
972
+ }
973
+
974
+ function getDocumentRect(element) {
975
+ var _element$ownerDocumen;
976
+ var html = getDocumentElement(element);
977
+ var winScroll = getWindowScroll(element);
978
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
979
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
980
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
981
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
982
+ var y = -winScroll.scrollTop;
983
+ if (getComputedStyle$1(body || html).direction === "rtl") {
984
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
985
+ }
986
+ return {
987
+ width: width,
988
+ height: height,
989
+ x: x,
990
+ y: y
991
+ };
992
+ }
993
+
994
+ function isScrollParent(element) {
995
+ var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
996
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
997
+ }
998
+
999
+ function getScrollParent(node) {
1000
+ if ([ "html", "body", "#document" ].indexOf(getNodeName(node)) >= 0) {
1001
+ return node.ownerDocument.body;
1002
+ }
1003
+ if (isHTMLElement(node) && isScrollParent(node)) {
1004
+ return node;
1005
+ }
1006
+ return getScrollParent(getParentNode(node));
1007
+ }
1008
+
1009
+ function listScrollParents(element, list) {
1010
+ var _element$ownerDocumen;
1011
+ if (list === void 0) {
1012
+ list = [];
1013
+ }
1014
+ var scrollParent = getScrollParent(element);
1015
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
1016
+ var win = getWindow(scrollParent);
1017
+ var target = isBody ? [ win ].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
1018
+ var updatedList = list.concat(target);
1019
+ return isBody ? updatedList : updatedList.concat(listScrollParents(getParentNode(target)));
1020
+ }
1021
+
1022
+ function rectToClientRect(rect) {
1023
+ return Object.assign({}, rect, {
1024
+ left: rect.x,
1025
+ top: rect.y,
1026
+ right: rect.x + rect.width,
1027
+ bottom: rect.y + rect.height
1028
+ });
1029
+ }
1030
+
1031
+ function getInnerBoundingClientRect(element) {
1032
+ var rect = getBoundingClientRect(element);
1033
+ rect.top = rect.top + element.clientTop;
1034
+ rect.left = rect.left + element.clientLeft;
1035
+ rect.bottom = rect.top + element.clientHeight;
1036
+ rect.right = rect.left + element.clientWidth;
1037
+ rect.width = element.clientWidth;
1038
+ rect.height = element.clientHeight;
1039
+ rect.x = rect.left;
1040
+ rect.y = rect.top;
1041
+ return rect;
1042
+ }
1043
+
1044
+ function getClientRectFromMixedType(element, clippingParent) {
1045
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1046
+ }
1047
+
1048
+ function getClippingParents(element) {
1049
+ var clippingParents = listScrollParents(getParentNode(element));
1050
+ var canEscapeClipping = [ "absolute", "fixed" ].indexOf(getComputedStyle$1(element).position) >= 0;
1051
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1052
+ if (!isElement(clipperElement)) {
1053
+ return [];
1054
+ }
1055
+ return clippingParents.filter((function(clippingParent) {
1056
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
1057
+ }));
1058
+ }
1059
+
1060
+ function getClippingRect(element, boundary, rootBoundary) {
1061
+ var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
1062
+ var clippingParents = [].concat(mainClippingParents, [ rootBoundary ]);
1063
+ var firstClippingParent = clippingParents[0];
1064
+ var clippingRect = clippingParents.reduce((function(accRect, clippingParent) {
1065
+ var rect = getClientRectFromMixedType(element, clippingParent);
1066
+ accRect.top = max(rect.top, accRect.top);
1067
+ accRect.right = min(rect.right, accRect.right);
1068
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1069
+ accRect.left = max(rect.left, accRect.left);
1070
+ return accRect;
1071
+ }), getClientRectFromMixedType(element, firstClippingParent));
1072
+ clippingRect.width = clippingRect.right - clippingRect.left;
1073
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
1074
+ clippingRect.x = clippingRect.left;
1075
+ clippingRect.y = clippingRect.top;
1076
+ return clippingRect;
1077
+ }
1078
+
1079
+ function computeOffsets(_ref) {
1080
+ var reference = _ref.reference, element = _ref.element, placement = _ref.placement;
1081
+ var basePlacement = placement ? getBasePlacement(placement) : null;
1082
+ var variation = placement ? getVariation(placement) : null;
1083
+ var commonX = reference.x + reference.width / 2 - element.width / 2;
1084
+ var commonY = reference.y + reference.height / 2 - element.height / 2;
1085
+ var offsets;
1086
+ switch (basePlacement) {
1087
+ case top:
1088
+ offsets = {
1089
+ x: commonX,
1090
+ y: reference.y - element.height
1091
+ };
1092
+ break;
1093
+
1094
+ case bottom:
1095
+ offsets = {
1096
+ x: commonX,
1097
+ y: reference.y + reference.height
1098
+ };
1099
+ break;
1100
+
1101
+ case right:
1102
+ offsets = {
1103
+ x: reference.x + reference.width,
1104
+ y: commonY
1105
+ };
1106
+ break;
1107
+
1108
+ case left:
1109
+ offsets = {
1110
+ x: reference.x - element.width,
1111
+ y: commonY
1112
+ };
1113
+ break;
1114
+
1115
+ default:
1116
+ offsets = {
1117
+ x: reference.x,
1118
+ y: reference.y
1119
+ };
1120
+ }
1121
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
1122
+ if (mainAxis != null) {
1123
+ var len = mainAxis === "y" ? "height" : "width";
1124
+ switch (variation) {
1125
+ case start:
1126
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
1127
+ break;
1128
+
1129
+ case end:
1130
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
1131
+ break;
1132
+ }
1133
+ }
1134
+ return offsets;
1135
+ }
1136
+
1137
+ function detectOverflow(state, options) {
1138
+ if (options === void 0) {
1139
+ options = {};
1140
+ }
1141
+ var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
1142
+ var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
1143
+ var altContext = elementContext === popper ? reference : popper;
1144
+ var popperRect = state.rects.popper;
1145
+ var element = state.elements[altBoundary ? altContext : elementContext];
1146
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
1147
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
1148
+ var popperOffsets = computeOffsets({
1149
+ reference: referenceClientRect,
1150
+ element: popperRect,
1151
+ strategy: "absolute",
1152
+ placement: placement
1153
+ });
1154
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
1155
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
1156
+ var overflowOffsets = {
1157
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
1158
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
1159
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
1160
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
1161
+ };
1162
+ var offsetData = state.modifiersData.offset;
1163
+ if (elementContext === popper && offsetData) {
1164
+ var offset = offsetData[placement];
1165
+ Object.keys(overflowOffsets).forEach((function(key) {
1166
+ var multiply = [ right, bottom ].indexOf(key) >= 0 ? 1 : -1;
1167
+ var axis = [ top, bottom ].indexOf(key) >= 0 ? "y" : "x";
1168
+ overflowOffsets[key] += offset[axis] * multiply;
1169
+ }));
1170
+ }
1171
+ return overflowOffsets;
1172
+ }
1173
+
1174
+ function computeAutoPlacement(state, options) {
1175
+ if (options === void 0) {
1176
+ options = {};
1177
+ }
1178
+ var _options = options, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
1179
+ var variation = getVariation(placement);
1180
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter((function(placement) {
1181
+ return getVariation(placement) === variation;
1182
+ })) : basePlacements;
1183
+ var allowedPlacements = placements$1.filter((function(placement) {
1184
+ return allowedAutoPlacements.indexOf(placement) >= 0;
1185
+ }));
1186
+ if (allowedPlacements.length === 0) {
1187
+ allowedPlacements = placements$1;
1188
+ }
1189
+ var overflows = allowedPlacements.reduce((function(acc, placement) {
1190
+ acc[placement] = detectOverflow(state, {
1191
+ placement: placement,
1192
+ boundary: boundary,
1193
+ rootBoundary: rootBoundary,
1194
+ padding: padding
1195
+ })[getBasePlacement(placement)];
1196
+ return acc;
1197
+ }), {});
1198
+ return Object.keys(overflows).sort((function(a, b) {
1199
+ return overflows[a] - overflows[b];
1200
+ }));
1201
+ }
1202
+
1203
+ function getExpandedFallbackPlacements(placement) {
1204
+ if (getBasePlacement(placement) === auto) {
1205
+ return [];
1206
+ }
1207
+ var oppositePlacement = getOppositePlacement(placement);
1208
+ return [ getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement) ];
1209
+ }
1210
+
1211
+ function flip(_ref) {
1212
+ var state = _ref.state, options = _ref.options, name = _ref.name;
1213
+ if (state.modifiersData[name]._skip) {
1214
+ return;
1215
+ }
1216
+ var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options.fallbackPlacements, padding = options.padding, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, _options$flipVariatio = options.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options.allowedAutoPlacements;
1217
+ var preferredPlacement = state.options.placement;
1218
+ var basePlacement = getBasePlacement(preferredPlacement);
1219
+ var isBasePlacement = basePlacement === preferredPlacement;
1220
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [ getOppositePlacement(preferredPlacement) ] : getExpandedFallbackPlacements(preferredPlacement));
1221
+ var placements = [ preferredPlacement ].concat(fallbackPlacements).reduce((function(acc, placement) {
1222
+ return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
1223
+ placement: placement,
1224
+ boundary: boundary,
1225
+ rootBoundary: rootBoundary,
1226
+ padding: padding,
1227
+ flipVariations: flipVariations,
1228
+ allowedAutoPlacements: allowedAutoPlacements
1229
+ }) : placement);
1230
+ }), []);
1231
+ var referenceRect = state.rects.reference;
1232
+ var popperRect = state.rects.popper;
1233
+ var checksMap = new Map;
1234
+ var makeFallbackChecks = true;
1235
+ var firstFittingPlacement = placements[0];
1236
+ for (var i = 0; i < placements.length; i++) {
1237
+ var placement = placements[i];
1238
+ var _basePlacement = getBasePlacement(placement);
1239
+ var isStartVariation = getVariation(placement) === start;
1240
+ var isVertical = [ top, bottom ].indexOf(_basePlacement) >= 0;
1241
+ var len = isVertical ? "width" : "height";
1242
+ var overflow = detectOverflow(state, {
1243
+ placement: placement,
1244
+ boundary: boundary,
1245
+ rootBoundary: rootBoundary,
1246
+ altBoundary: altBoundary,
1247
+ padding: padding
1248
+ });
1249
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
1250
+ if (referenceRect[len] > popperRect[len]) {
1251
+ mainVariationSide = getOppositePlacement(mainVariationSide);
1252
+ }
1253
+ var altVariationSide = getOppositePlacement(mainVariationSide);
1254
+ var checks = [];
1255
+ if (checkMainAxis) {
1256
+ checks.push(overflow[_basePlacement] <= 0);
1257
+ }
1258
+ if (checkAltAxis) {
1259
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
1260
+ }
1261
+ if (checks.every((function(check) {
1262
+ return check;
1263
+ }))) {
1264
+ firstFittingPlacement = placement;
1265
+ makeFallbackChecks = false;
1266
+ break;
1267
+ }
1268
+ checksMap.set(placement, checks);
1269
+ }
1270
+ if (makeFallbackChecks) {
1271
+ var numberOfChecks = flipVariations ? 3 : 1;
1272
+ var _loop = function _loop(_i) {
1273
+ var fittingPlacement = placements.find((function(placement) {
1274
+ var checks = checksMap.get(placement);
1275
+ if (checks) {
1276
+ return checks.slice(0, _i).every((function(check) {
1277
+ return check;
1278
+ }));
1279
+ }
1280
+ }));
1281
+ if (fittingPlacement) {
1282
+ firstFittingPlacement = fittingPlacement;
1283
+ return "break";
1284
+ }
1285
+ };
1286
+ for (var _i = numberOfChecks; _i > 0; _i--) {
1287
+ var _ret = _loop(_i);
1288
+ if (_ret === "break") break;
1289
+ }
1290
+ }
1291
+ if (state.placement !== firstFittingPlacement) {
1292
+ state.modifiersData[name]._skip = true;
1293
+ state.placement = firstFittingPlacement;
1294
+ state.reset = true;
1295
+ }
1296
+ }
1297
+
1298
+ var flip$1 = {
1299
+ name: "flip",
1300
+ enabled: true,
1301
+ phase: "main",
1302
+ fn: flip,
1303
+ requiresIfExists: [ "offset" ],
1304
+ data: {
1305
+ _skip: false
1306
+ }
1307
+ };
1308
+
1309
+ function getSideOffsets(overflow, rect, preventedOffsets) {
1310
+ if (preventedOffsets === void 0) {
1311
+ preventedOffsets = {
1312
+ x: 0,
1313
+ y: 0
1314
+ };
1315
+ }
1316
+ return {
1317
+ top: overflow.top - rect.height - preventedOffsets.y,
1318
+ right: overflow.right - rect.width + preventedOffsets.x,
1319
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
1320
+ left: overflow.left - rect.width - preventedOffsets.x
1321
+ };
1322
+ }
1323
+
1324
+ function isAnySideFullyClipped(overflow) {
1325
+ return [ top, right, bottom, left ].some((function(side) {
1326
+ return overflow[side] >= 0;
1327
+ }));
1328
+ }
1329
+
1330
+ function hide(_ref) {
1331
+ var state = _ref.state, name = _ref.name;
1332
+ var referenceRect = state.rects.reference;
1333
+ var popperRect = state.rects.popper;
1334
+ var preventedOffsets = state.modifiersData.preventOverflow;
1335
+ var referenceOverflow = detectOverflow(state, {
1336
+ elementContext: "reference"
1337
+ });
1338
+ var popperAltOverflow = detectOverflow(state, {
1339
+ altBoundary: true
1340
+ });
1341
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
1342
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
1343
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
1344
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
1345
+ state.modifiersData[name] = {
1346
+ referenceClippingOffsets: referenceClippingOffsets,
1347
+ popperEscapeOffsets: popperEscapeOffsets,
1348
+ isReferenceHidden: isReferenceHidden,
1349
+ hasPopperEscaped: hasPopperEscaped
1350
+ };
1351
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1352
+ "data-popper-reference-hidden": isReferenceHidden,
1353
+ "data-popper-escaped": hasPopperEscaped
1354
+ });
1355
+ }
1356
+
1357
+ var hide$1 = {
1358
+ name: "hide",
1359
+ enabled: true,
1360
+ phase: "main",
1361
+ requiresIfExists: [ "preventOverflow" ],
1362
+ fn: hide
1363
+ };
1364
+
1365
+ function distanceAndSkiddingToXY(placement, rects, offset) {
1366
+ var basePlacement = getBasePlacement(placement);
1367
+ var invertDistance = [ left, top ].indexOf(basePlacement) >= 0 ? -1 : 1;
1368
+ var _ref = typeof offset === "function" ? offset(Object.assign({}, rects, {
1369
+ placement: placement
1370
+ })) : offset, skidding = _ref[0], distance = _ref[1];
1371
+ skidding = skidding || 0;
1372
+ distance = (distance || 0) * invertDistance;
1373
+ return [ left, right ].indexOf(basePlacement) >= 0 ? {
1374
+ x: distance,
1375
+ y: skidding
1376
+ } : {
1377
+ x: skidding,
1378
+ y: distance
1379
+ };
1380
+ }
1381
+
1382
+ function offset(_ref2) {
1383
+ var state = _ref2.state, options = _ref2.options, name = _ref2.name;
1384
+ var _options$offset = options.offset, offset = _options$offset === void 0 ? [ 0, 0 ] : _options$offset;
1385
+ var data = placements.reduce((function(acc, placement) {
1386
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
1387
+ return acc;
1388
+ }), {});
1389
+ var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
1390
+ if (state.modifiersData.popperOffsets != null) {
1391
+ state.modifiersData.popperOffsets.x += x;
1392
+ state.modifiersData.popperOffsets.y += y;
1393
+ }
1394
+ state.modifiersData[name] = data;
1395
+ }
1396
+
1397
+ var offset$1 = {
1398
+ name: "offset",
1399
+ enabled: true,
1400
+ phase: "main",
1401
+ requires: [ "popperOffsets" ],
1402
+ fn: offset
1403
+ };
1404
+
1405
+ function popperOffsets(_ref) {
1406
+ var state = _ref.state, name = _ref.name;
1407
+ state.modifiersData[name] = computeOffsets({
1408
+ reference: state.rects.reference,
1409
+ element: state.rects.popper,
1410
+ strategy: "absolute",
1411
+ placement: state.placement
1412
+ });
1413
+ }
1414
+
1415
+ var popperOffsets$1 = {
1416
+ name: "popperOffsets",
1417
+ enabled: true,
1418
+ phase: "read",
1419
+ fn: popperOffsets,
1420
+ data: {}
1421
+ };
1422
+
1423
+ function getAltAxis(axis) {
1424
+ return axis === "x" ? "y" : "x";
1425
+ }
1426
+
1427
+ function preventOverflow(_ref) {
1428
+ var state = _ref.state, options = _ref.options, name = _ref.name;
1429
+ var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
1430
+ var overflow = detectOverflow(state, {
1431
+ boundary: boundary,
1432
+ rootBoundary: rootBoundary,
1433
+ padding: padding,
1434
+ altBoundary: altBoundary
1435
+ });
1436
+ var basePlacement = getBasePlacement(state.placement);
1437
+ var variation = getVariation(state.placement);
1438
+ var isBasePlacement = !variation;
1439
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
1440
+ var altAxis = getAltAxis(mainAxis);
1441
+ var popperOffsets = state.modifiersData.popperOffsets;
1442
+ var referenceRect = state.rects.reference;
1443
+ var popperRect = state.rects.popper;
1444
+ var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
1445
+ placement: state.placement
1446
+ })) : tetherOffset;
1447
+ var data = {
1448
+ x: 0,
1449
+ y: 0
1450
+ };
1451
+ if (!popperOffsets) {
1452
+ return;
1453
+ }
1454
+ if (checkMainAxis || checkAltAxis) {
1455
+ var mainSide = mainAxis === "y" ? top : left;
1456
+ var altSide = mainAxis === "y" ? bottom : right;
1457
+ var len = mainAxis === "y" ? "height" : "width";
1458
+ var offset = popperOffsets[mainAxis];
1459
+ var min$1 = popperOffsets[mainAxis] + overflow[mainSide];
1460
+ var max$1 = popperOffsets[mainAxis] - overflow[altSide];
1461
+ var additive = tether ? -popperRect[len] / 2 : 0;
1462
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
1463
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
1464
+ var arrowElement = state.elements.arrow;
1465
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
1466
+ width: 0,
1467
+ height: 0
1468
+ };
1469
+ var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
1470
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
1471
+ var arrowPaddingMax = arrowPaddingObject[altSide];
1472
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1473
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
1474
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
1475
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1476
+ var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1477
+ var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
1478
+ var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
1479
+ var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
1480
+ if (checkMainAxis) {
1481
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1482
+ popperOffsets[mainAxis] = preventedOffset;
1483
+ data[mainAxis] = preventedOffset - offset;
1484
+ }
1485
+ if (checkAltAxis) {
1486
+ var _mainSide = mainAxis === "x" ? top : left;
1487
+ var _altSide = mainAxis === "x" ? bottom : right;
1488
+ var _offset = popperOffsets[altAxis];
1489
+ var _min = _offset + overflow[_mainSide];
1490
+ var _max = _offset - overflow[_altSide];
1491
+ var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max);
1492
+ popperOffsets[altAxis] = _preventedOffset;
1493
+ data[altAxis] = _preventedOffset - _offset;
1494
+ }
1495
+ }
1496
+ state.modifiersData[name] = data;
1497
+ }
1498
+
1499
+ var preventOverflow$1 = {
1500
+ name: "preventOverflow",
1501
+ enabled: true,
1502
+ phase: "main",
1503
+ fn: preventOverflow,
1504
+ requiresIfExists: [ "offset" ]
1505
+ };
1506
+
1507
+ function getHTMLElementScroll(element) {
1508
+ return {
1509
+ scrollLeft: element.scrollLeft,
1510
+ scrollTop: element.scrollTop
1511
+ };
1512
+ }
1513
+
1514
+ function getNodeScroll(node) {
1515
+ if (node === getWindow(node) || !isHTMLElement(node)) {
1516
+ return getWindowScroll(node);
1517
+ } else {
1518
+ return getHTMLElementScroll(node);
1519
+ }
1520
+ }
1521
+
1522
+ function isElementScaled(element) {
1523
+ var rect = element.getBoundingClientRect();
1524
+ var scaleX = rect.width / element.offsetWidth || 1;
1525
+ var scaleY = rect.height / element.offsetHeight || 1;
1526
+ return scaleX !== 1 || scaleY !== 1;
1527
+ }
1528
+
1529
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1530
+ if (isFixed === void 0) {
1531
+ isFixed = false;
1532
+ }
1533
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
1534
+ isHTMLElement(offsetParent) && isElementScaled(offsetParent);
1535
+ var documentElement = getDocumentElement(offsetParent);
1536
+ var rect = getBoundingClientRect(elementOrVirtualElement);
1537
+ var scroll = {
1538
+ scrollLeft: 0,
1539
+ scrollTop: 0
1540
+ };
1541
+ var offsets = {
1542
+ x: 0,
1543
+ y: 0
1544
+ };
1545
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1546
+ if (getNodeName(offsetParent) !== "body" || isScrollParent(documentElement)) {
1547
+ scroll = getNodeScroll(offsetParent);
1548
+ }
1549
+ if (isHTMLElement(offsetParent)) {
1550
+ offsets = getBoundingClientRect(offsetParent);
1551
+ offsets.x += offsetParent.clientLeft;
1552
+ offsets.y += offsetParent.clientTop;
1553
+ } else if (documentElement) {
1554
+ offsets.x = getWindowScrollBarX(documentElement);
1555
+ }
1556
+ }
1557
+ return {
1558
+ x: rect.left + scroll.scrollLeft - offsets.x,
1559
+ y: rect.top + scroll.scrollTop - offsets.y,
1560
+ width: rect.width,
1561
+ height: rect.height
1562
+ };
1563
+ }
1564
+
1565
+ function order(modifiers) {
1566
+ var map = new Map;
1567
+ var visited = new Set;
1568
+ var result = [];
1569
+ modifiers.forEach((function(modifier) {
1570
+ map.set(modifier.name, modifier);
1571
+ }));
1572
+ function sort(modifier) {
1573
+ visited.add(modifier.name);
1574
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
1575
+ requires.forEach((function(dep) {
1576
+ if (!visited.has(dep)) {
1577
+ var depModifier = map.get(dep);
1578
+ if (depModifier) {
1579
+ sort(depModifier);
1580
+ }
1581
+ }
1582
+ }));
1583
+ result.push(modifier);
1584
+ }
1585
+ modifiers.forEach((function(modifier) {
1586
+ if (!visited.has(modifier.name)) {
1587
+ sort(modifier);
1588
+ }
1589
+ }));
1590
+ return result;
1591
+ }
1592
+
1593
+ function orderModifiers(modifiers) {
1594
+ var orderedModifiers = order(modifiers);
1595
+ return modifierPhases.reduce((function(acc, phase) {
1596
+ return acc.concat(orderedModifiers.filter((function(modifier) {
1597
+ return modifier.phase === phase;
1598
+ })));
1599
+ }), []);
1600
+ }
1601
+
1602
+ function debounce(fn) {
1603
+ var pending;
1604
+ return function() {
1605
+ if (!pending) {
1606
+ pending = new Promise((function(resolve) {
1607
+ Promise.resolve().then((function() {
1608
+ pending = undefined;
1609
+ resolve(fn());
1610
+ }));
1611
+ }));
1612
+ }
1613
+ return pending;
1614
+ };
1615
+ }
1616
+
1617
+ function mergeByName(modifiers) {
1618
+ var merged = modifiers.reduce((function(merged, current) {
1619
+ var existing = merged[current.name];
1620
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
1621
+ options: Object.assign({}, existing.options, current.options),
1622
+ data: Object.assign({}, existing.data, current.data)
1623
+ }) : current;
1624
+ return merged;
1625
+ }), {});
1626
+ return Object.keys(merged).map((function(key) {
1627
+ return merged[key];
1628
+ }));
1629
+ }
1630
+
1631
+ var DEFAULT_OPTIONS = {
1632
+ placement: "bottom",
1633
+ modifiers: [],
1634
+ strategy: "absolute"
1635
+ };
1636
+
1637
+ function areValidElements() {
1638
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1639
+ args[_key] = arguments[_key];
1640
+ }
1641
+ return !args.some((function(element) {
1642
+ return !(element && typeof element.getBoundingClientRect === "function");
1643
+ }));
1644
+ }
1645
+
1646
+ function popperGenerator(generatorOptions) {
1647
+ if (generatorOptions === void 0) {
1648
+ generatorOptions = {};
1649
+ }
1650
+ var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
1651
+ return function createPopper(reference, popper, options) {
1652
+ if (options === void 0) {
1653
+ options = defaultOptions;
1654
+ }
1655
+ var state = {
1656
+ placement: "bottom",
1657
+ orderedModifiers: [],
1658
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
1659
+ modifiersData: {},
1660
+ elements: {
1661
+ reference: reference,
1662
+ popper: popper
1663
+ },
1664
+ attributes: {},
1665
+ styles: {}
1666
+ };
1667
+ var effectCleanupFns = [];
1668
+ var isDestroyed = false;
1669
+ var instance = {
1670
+ state: state,
1671
+ setOptions: function setOptions(setOptionsAction) {
1672
+ var options = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
1673
+ cleanupModifierEffects();
1674
+ state.options = Object.assign({}, defaultOptions, state.options, options);
1675
+ state.scrollParents = {
1676
+ reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1677
+ popper: listScrollParents(popper)
1678
+ };
1679
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers)));
1680
+ state.orderedModifiers = orderedModifiers.filter((function(m) {
1681
+ return m.enabled;
1682
+ }));
1683
+ runModifierEffects();
1684
+ return instance.update();
1685
+ },
1686
+ forceUpdate: function forceUpdate() {
1687
+ if (isDestroyed) {
1688
+ return;
1689
+ }
1690
+ var _state$elements = state.elements, reference = _state$elements.reference, popper = _state$elements.popper;
1691
+ if (!areValidElements(reference, popper)) {
1692
+ return;
1693
+ }
1694
+ state.rects = {
1695
+ reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === "fixed"),
1696
+ popper: getLayoutRect(popper)
1697
+ };
1698
+ state.reset = false;
1699
+ state.placement = state.options.placement;
1700
+ state.orderedModifiers.forEach((function(modifier) {
1701
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1702
+ }));
1703
+ for (var index = 0; index < state.orderedModifiers.length; index++) {
1704
+ if (state.reset === true) {
1705
+ state.reset = false;
1706
+ index = -1;
1707
+ continue;
1708
+ }
1709
+ var _state$orderedModifie = state.orderedModifiers[index], fn = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name;
1710
+ if (typeof fn === "function") {
1711
+ state = fn({
1712
+ state: state,
1713
+ options: _options,
1714
+ name: name,
1715
+ instance: instance
1716
+ }) || state;
1717
+ }
1718
+ }
1719
+ },
1720
+ update: debounce((function() {
1721
+ return new Promise((function(resolve) {
1722
+ instance.forceUpdate();
1723
+ resolve(state);
1724
+ }));
1725
+ })),
1726
+ destroy: function destroy() {
1727
+ cleanupModifierEffects();
1728
+ isDestroyed = true;
1729
+ }
1730
+ };
1731
+ if (!areValidElements(reference, popper)) {
1732
+ return instance;
1733
+ }
1734
+ instance.setOptions(options).then((function(state) {
1735
+ if (!isDestroyed && options.onFirstUpdate) {
1736
+ options.onFirstUpdate(state);
1737
+ }
1738
+ }));
1739
+ function runModifierEffects() {
1740
+ state.orderedModifiers.forEach((function(_ref3) {
1741
+ var name = _ref3.name, _ref3$options = _ref3.options, options = _ref3$options === void 0 ? {} : _ref3$options, effect = _ref3.effect;
1742
+ if (typeof effect === "function") {
1743
+ var cleanupFn = effect({
1744
+ state: state,
1745
+ name: name,
1746
+ instance: instance,
1747
+ options: options
1748
+ });
1749
+ var noopFn = function noopFn() {};
1750
+ effectCleanupFns.push(cleanupFn || noopFn);
1751
+ }
1752
+ }));
1753
+ }
1754
+ function cleanupModifierEffects() {
1755
+ effectCleanupFns.forEach((function(fn) {
1756
+ return fn();
1757
+ }));
1758
+ effectCleanupFns = [];
1759
+ }
1760
+ return instance;
1761
+ };
1762
+ }
1763
+
1764
+ var defaultModifiers = [ eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1 ];
1765
+
1766
+ var createPopper = popperGenerator({
1767
+ defaultModifiers: defaultModifiers
1768
+ });
1769
+
1770
+ class Popover extends Controller {
1771
+ static targets=[ "activator", "popover" ];
1772
+ static classes=[ "open", "closed" ];
1773
+ static values={
1774
+ placement: String,
1775
+ active: Boolean
1776
+ };
1777
+ connect() {
1778
+ createPopper(this.activatorTarget, this.popoverTarget, {
1779
+ placement: this.placementValue,
1780
+ modifiers: [ {
1781
+ name: "offset",
1782
+ options: {
1783
+ offset: [ 0, 5 ]
1784
+ }
1785
+ } ]
1786
+ });
1787
+ if (this.activeValue) {
1788
+ this.show();
1789
+ }
1790
+ }
1791
+ toggle() {
1792
+ this.popoverTarget.classList.toggle(this.closedClass);
1793
+ this.popoverTarget.classList.toggle(this.openClass);
1794
+ }
1795
+ show() {
1796
+ this.popoverTarget.classList.remove(this.closedClass);
1797
+ this.popoverTarget.classList.add(this.openClass);
1798
+ }
1799
+ hide(event) {
1800
+ if (!this.element.contains(event.target) && !this.popoverTarget.classList.contains(this.closedClass)) {
1801
+ this.forceHide();
1802
+ }
1803
+ }
1804
+ forceHide() {
1805
+ this.popoverTarget.classList.remove(this.openClass);
1806
+ this.popoverTarget.classList.add(this.closedClass);
1807
+ }
1808
+ }
1809
+
3
1810
  class ResourceItem extends Controller {
4
1811
  static targets=[ "link" ];
5
1812
  open(event) {
@@ -12,11 +1819,65 @@ class ResourceItem extends Controller {
12
1819
  }
13
1820
  }
14
1821
 
1822
+ class Scrollable extends Controller {
1823
+ static targets=[ "topEdge", "bottomEdge" ];
1824
+ static classes=[ "topShadow", "bottomShadow" ];
1825
+ static values={
1826
+ shadow: Boolean
1827
+ };
1828
+ initialize() {
1829
+ this.topEdgeReached = false;
1830
+ this.bottomEdgeReached = true;
1831
+ }
1832
+ connect() {
1833
+ if (this.shadowValue) {
1834
+ this.observer = new IntersectionObserver(this.handleIntersection);
1835
+ this.observer.observe(this.topEdgeTarget);
1836
+ this.observer.observe(this.bottomEdgeTarget);
1837
+ }
1838
+ }
1839
+ disconnect() {
1840
+ if (this.shadowValue) {
1841
+ this.observer.disconnect();
1842
+ }
1843
+ }
1844
+ handleIntersection=entries => {
1845
+ entries.forEach((entry => {
1846
+ const target = entry.target.dataset.polarisScrollableTarget;
1847
+ switch (target) {
1848
+ case "topEdge":
1849
+ this.topEdgeReached = entry.isIntersecting;
1850
+ break;
1851
+
1852
+ case "bottomEdge":
1853
+ this.bottomEdgeReached = entry.isIntersecting;
1854
+ break;
1855
+ }
1856
+ }));
1857
+ this.updateShadows();
1858
+ };
1859
+ updateShadows() {
1860
+ if (!this.topEdgeReached && !this.bottomEdgeReached) {
1861
+ this.element.classList.add(this.topShadowClass, this.bottomShadowClass);
1862
+ } else if (this.topEdgeReached && this.bottomEdgeReached) {
1863
+ this.element.classList.remove(this.topShadowClass, this.bottomShadowClass);
1864
+ } else if (this.topEdgeReached) {
1865
+ this.element.classList.remove(this.topShadowClass);
1866
+ this.element.classList.add(this.bottomShadowClass);
1867
+ } else if (this.bottomEdgeReached) {
1868
+ this.element.classList.add(this.topShadowClass);
1869
+ this.element.classList.remove(this.bottomShadowClass);
1870
+ }
1871
+ }
1872
+ }
1873
+
15
1874
  class Select extends Controller {
16
- static targets=[ "selectedOption" ];
17
- update(event) {
18
- const select = event.currentTarget;
19
- const option = select.options[select.selectedIndex];
1875
+ static targets=[ "select", "selectedOption" ];
1876
+ connect() {
1877
+ this.update();
1878
+ }
1879
+ update() {
1880
+ const option = this.selectTarget.options[this.selectTarget.selectedIndex];
20
1881
  this.selectedOptionTarget.innerText = option.text;
21
1882
  }
22
1883
  }
@@ -93,15 +1954,85 @@ class TextField extends Controller {
93
1954
  return;
94
1955
  }
95
1956
  const decimalPlaces = Math.max(dpl(numericValue), dpl(this.stepValue));
1957
+ const oldValue = this.value;
96
1958
  const newValue = Math.min(Number(this.maxValue), Math.max(numericValue + steps * this.stepValue, Number(this.minValue)));
97
1959
  this.value = String(newValue.toFixed(decimalPlaces));
1960
+ if (this.value != oldValue) {
1961
+ this.inputTarget.dispatchEvent(new Event("change"));
1962
+ }
1963
+ }
1964
+ }
1965
+
1966
+ class Toast extends Controller {
1967
+ static activeClass="Polaris-Frame-ToastManager--toastWrapperEnterDone";
1968
+ static defaultDuration=5e3;
1969
+ static defaultDurationWithAction=1e4;
1970
+ static values={
1971
+ hidden: Boolean,
1972
+ duration: Number,
1973
+ hasAction: Boolean
1974
+ };
1975
+ connect() {
1976
+ if (!this.hiddenValue) {
1977
+ this.show();
1978
+ }
1979
+ }
1980
+ show=() => {
1981
+ this.element.dataset.position = this.position;
1982
+ this.element.style.cssText = this.getStyle(this.position);
1983
+ this.element.classList.add(this.constructor.activeClass);
1984
+ setTimeout(this.close, this.timeoutDuration);
1985
+ };
1986
+ close=() => {
1987
+ this.element.classList.remove(this.constructor.activeClass);
1988
+ this.element.addEventListener("transitionend", this.updatePositions, false);
1989
+ };
1990
+ updatePositions=() => {
1991
+ this.visibleToasts.sort(((a, b) => parseInt(a.dataset.position) - parseInt(b.dataset.position))).forEach(((toast, index) => {
1992
+ const position = index + 1;
1993
+ toast.dataset.position = position;
1994
+ toast.style.cssText = this.getStyle(position);
1995
+ }));
1996
+ this.element.removeEventListener("transitionend", this.updatePositions, false);
1997
+ };
1998
+ getStyle(position) {
1999
+ const translateIn = -80 * position;
2000
+ const translateOut = 150 - 80 * position;
2001
+ return `--toast-translate-y-in: ${translateIn}px; --toast-translate-y-out: ${translateOut}px;`;
2002
+ }
2003
+ get timeoutDuration() {
2004
+ if (this.durationValue > 0) {
2005
+ return this.durationValue;
2006
+ } else if (this.hasActionValue) {
2007
+ return this.constructor.defaultDurationWithAction;
2008
+ } else {
2009
+ return this.constructor.defaultDuration;
2010
+ }
2011
+ }
2012
+ get toastManager() {
2013
+ return this.element.closest(".Polaris-Frame-ToastManager");
2014
+ }
2015
+ get visibleToasts() {
2016
+ return [ ...this.toastManager.querySelectorAll(`.${this.constructor.activeClass}`) ];
2017
+ }
2018
+ get position() {
2019
+ return this.visibleToasts.filter((el => !this.element.isEqualNode(el))).length + 1;
98
2020
  }
99
2021
  }
100
2022
 
101
2023
  function registerPolarisControllers(application) {
2024
+ application.register("polaris-autocomplete", Autocomplete);
2025
+ application.register("polaris-button", Button);
2026
+ application.register("polaris-frame", Frame);
2027
+ application.register("polaris-modal", Modal);
2028
+ application.register("polaris-option-list", OptionList);
2029
+ application.register("polaris", Polaris);
2030
+ application.register("polaris-popover", Popover);
102
2031
  application.register("polaris-resource-item", ResourceItem);
2032
+ application.register("polaris-scrollable", Scrollable);
103
2033
  application.register("polaris-select", Select);
104
2034
  application.register("polaris-text-field", TextField);
2035
+ application.register("polaris-toast", Toast);
105
2036
  }
106
2037
 
107
- export { ResourceItem, Select, TextField, registerPolarisControllers };
2038
+ export { Frame, Modal, Polaris, Popover, ResourceItem, Scrollable, Select, TextField, registerPolarisControllers };