@shoper/phoenix_design_system 1.18.23-9 → 1.18.24
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.
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js +77 -14
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/search/search.js +4 -28
- package/build/cjs/packages/phoenix/src/components/form/search/search.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +13 -3
- package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/select/select.js +18 -37
- package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/modal/modal.js +67 -13
- package/build/cjs/packages/phoenix/src/components/modal/modal.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/modal/modal_constants.js +3 -1
- package/build/cjs/packages/phoenix/src/components/modal/modal_constants.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/sheet/sheet.js +63 -9
- package/build/cjs/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/sheet/sheet_constants.js +3 -1
- package/build/cjs/packages/phoenix/src/components/sheet/sheet_constants.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.d.ts +6 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +77 -14
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/search/search.d.ts +0 -5
- package/build/esm/packages/phoenix/src/components/form/search/search.js +4 -28
- package/build/esm/packages/phoenix/src/components/form/search/search.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js +13 -3
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/select/select.d.ts +0 -1
- package/build/esm/packages/phoenix/src/components/form/select/select.js +18 -37
- package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/modal/modal.d.ts +9 -1
- package/build/esm/packages/phoenix/src/components/modal/modal.js +69 -15
- package/build/esm/packages/phoenix/src/components/modal/modal.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/modal/modal_constants.js +3 -2
- package/build/esm/packages/phoenix/src/components/modal/modal_constants.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/sheet/sheet.d.ts +9 -1
- package/build/esm/packages/phoenix/src/components/sheet/sheet.js +65 -11
- package/build/esm/packages/phoenix/src/components/sheet/sheet.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/sheet/sheet_constants.js +3 -2
- package/build/esm/packages/phoenix/src/components/sheet/sheet_constants.js.map +1 -1
- package/package.json +1 -1
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +0 -38
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +0 -1
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +0 -66
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +0 -1
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +0 -14
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +0 -1
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +0 -22
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +0 -1
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js +0 -29
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js.map +0 -1
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js +0 -62
- package/build/cjs/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.d.ts +0 -13
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js +0 -34
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.d.ts +0 -15
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js +0 -2
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/focus_trap_controller_types.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.d.ts +0 -14
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js +0 -62
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.d.ts +0 -8
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js +0 -2
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/base_focus_trap_strategy_types.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.d.ts +0 -6
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js +0 -10
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.d.ts +0 -3
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js +0 -2
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/cyclic_focus_trap_strategy/cyclic_focus_trap_strategy_types.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.d.ts +0 -13
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js +0 -17
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/focus_trap_strategy_constants.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.d.ts +0 -7
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js +0 -25
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.d.ts +0 -4
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.js +0 -2
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/sentinel_focus_trap_strategy/sentinel_focus_trap_strategy_types.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.d.ts +0 -8
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js +0 -58
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.d.ts +0 -4
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.js +0 -2
- package/build/esm/packages/phoenix/src/controllers/focus_trap_controller/strategies/toggler_focus_trap_strategy/toggler_focus_trap_strategy_types.js.map +0 -1
|
@@ -16,7 +16,6 @@ var v4 = require('../../../../../external/uuid/dist/esm-browser/v4.js');
|
|
|
16
16
|
var portal_constants = require('../portal/portal_constants.js');
|
|
17
17
|
var backdrop_controller = require('../backdrop/controller/backdrop_controller.js');
|
|
18
18
|
var click_outside_controller = require('../../controllers/click_outside_controller/click_outside_controller.js');
|
|
19
|
-
var focus_trap_controller = require('../../controllers/focus_trap_controller/focus_trap_controller.js');
|
|
20
19
|
var throttle = require('../../../../../external/lodash/throttle.js');
|
|
21
20
|
var relative_position_controller = require('../../controllers/relative_position_controller/relative_position_controller.js');
|
|
22
21
|
|
|
@@ -35,11 +34,6 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
35
34
|
this.preventFocusTrap = false;
|
|
36
35
|
this.noAutoFocus = false;
|
|
37
36
|
this._backdropController = new backdrop_controller.BackdropController();
|
|
38
|
-
this._focusTrapController = new focus_trap_controller.FocusTrapController(this, {
|
|
39
|
-
mode: 'toggler',
|
|
40
|
-
getContainer: () => { var _a; return (_a = this.$dropdownContent) !== null && _a !== void 0 ? _a : undefined; },
|
|
41
|
-
getToggler: () => this.$dropdownToggler
|
|
42
|
-
});
|
|
43
37
|
this._handleClickOutside = async (target) => {
|
|
44
38
|
var _a, _b;
|
|
45
39
|
if (!this.opened)
|
|
@@ -77,8 +71,6 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
77
71
|
this._dispatchShowDropdownEvent();
|
|
78
72
|
(_a = this.$dropdownContent) === null || _a === void 0 ? void 0 : _a.classList.remove(`${dropdown_constants.DROPDOWN_CONTENT_CSS_CLASSES.show}-${this.transition}-start`, `${dropdown_constants.DROPDOWN_CONTENT_CSS_CLASSES.show}-${this.transition}-end`);
|
|
79
73
|
this._toggleScroll();
|
|
80
|
-
if (!this.preventFocusTrap)
|
|
81
|
-
this._focusTrapController.activate();
|
|
82
74
|
resolve();
|
|
83
75
|
}, transitionDuration);
|
|
84
76
|
});
|
|
@@ -119,7 +111,6 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
119
111
|
var _a;
|
|
120
112
|
(_a = this.$dropdownContent) === null || _a === void 0 ? void 0 : _a.classList.remove(`${dropdown_constants.DROPDOWN_CONTENT_CSS_CLASSES.hide}-${this.transition}-start`, `${dropdown_constants.DROPDOWN_CONTENT_CSS_CLASSES.hide}-${this.transition}-end`);
|
|
121
113
|
this.opened = false;
|
|
122
|
-
this._focusTrapController.deactivate();
|
|
123
114
|
this._dispatchHideDropdownEvent();
|
|
124
115
|
resolve();
|
|
125
116
|
}, transitionDuration);
|
|
@@ -151,16 +142,31 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
151
142
|
await this.hide();
|
|
152
143
|
};
|
|
153
144
|
this._keepFocusWithinDropdownForwards = (ev) => {
|
|
154
|
-
|
|
145
|
+
var _a, _b;
|
|
146
|
+
if (ev.shiftKey === true || !this.$dropdownContent || !this.opened)
|
|
155
147
|
return;
|
|
156
|
-
|
|
148
|
+
const $target = ev.target;
|
|
149
|
+
if (((_a = this.$dropdownContent) === null || _a === void 0 ? void 0 : _a.contains($target)) && this.preventFocusTrap) {
|
|
157
150
|
this._handleFocusOnNextElementAfterDropdown(ev);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if ((_b = this.$dropdownToggler) === null || _b === void 0 ? void 0 : _b.contains($target)) {
|
|
154
|
+
this._handleFocusFromTogglerForwards(ev);
|
|
155
|
+
return;
|
|
158
156
|
}
|
|
157
|
+
this._handleFocusFromSentinelEndForwards(ev, $target);
|
|
159
158
|
};
|
|
160
159
|
this._keepFocusWithinDropdownBackwards = (ev) => {
|
|
161
|
-
if (!this.opened || !this.$dropdownContent
|
|
160
|
+
if (!this.opened || !this.$dropdownContent)
|
|
162
161
|
return;
|
|
163
|
-
|
|
162
|
+
const $target = ev.target;
|
|
163
|
+
if (this.preventFocusTrap) {
|
|
164
|
+
this._handleDefaultFocusFromDropdownBackwards(ev);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
this._handleFocusFromTogglerBackwards(ev, $target);
|
|
168
|
+
this._handleFocusFromSentinelStartBackwards(ev, $target);
|
|
169
|
+
}
|
|
164
170
|
};
|
|
165
171
|
this._hoverToggle = async (ev) => {
|
|
166
172
|
if (window.innerWidth < global_constants.BREAKPOINTS.xs)
|
|
@@ -182,7 +188,7 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
182
188
|
this._focusOnFirstContentElement = () => {
|
|
183
189
|
if (!this.$dropdownContent)
|
|
184
190
|
return;
|
|
185
|
-
const $firstFocusableElement = this.
|
|
191
|
+
const $firstFocusableElement = this._getTrulyFocusableElements(this.$dropdownContent)[0];
|
|
186
192
|
if ($firstFocusableElement)
|
|
187
193
|
$firstFocusableElement.focus();
|
|
188
194
|
};
|
|
@@ -300,11 +306,68 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
300
306
|
utilities.UiDomUtils.getNextFocusableElement(this.$dropdownToggler || this).focus();
|
|
301
307
|
return;
|
|
302
308
|
}
|
|
309
|
+
_handleFocusFromTogglerForwards(ev) {
|
|
310
|
+
if (!this.$dropdownContent)
|
|
311
|
+
return;
|
|
312
|
+
const trulyFocusableElements = this._getTrulyFocusableElements(this.$dropdownContent);
|
|
313
|
+
if (trulyFocusableElements.length === 0)
|
|
314
|
+
return;
|
|
315
|
+
ev.preventDefault();
|
|
316
|
+
trulyFocusableElements[0].focus();
|
|
317
|
+
}
|
|
318
|
+
_handleFocusFromSentinelEndForwards(ev, $target) {
|
|
319
|
+
var _a;
|
|
320
|
+
if (!this.$dropdownContent)
|
|
321
|
+
return;
|
|
322
|
+
const trulyFocusableElements = this._getTrulyFocusableElements(this.$dropdownContent);
|
|
323
|
+
const $lastFocusableElement = trulyFocusableElements.slice(-1)[0];
|
|
324
|
+
if ($target !== $lastFocusableElement)
|
|
325
|
+
return;
|
|
326
|
+
ev.preventDefault();
|
|
327
|
+
(_a = this.$dropdownToggler) === null || _a === void 0 ? void 0 : _a.focus();
|
|
328
|
+
}
|
|
303
329
|
_handleDefaultFocusFromDropdownBackwards(ev) {
|
|
304
330
|
ev.preventDefault();
|
|
305
331
|
this.hide();
|
|
306
332
|
utilities.UiDomUtils.getPreviousFocusableElement(this.$dropdownToggler || this).focus();
|
|
307
333
|
}
|
|
334
|
+
_handleFocusFromTogglerBackwards(ev, $target) {
|
|
335
|
+
var _a;
|
|
336
|
+
if ($target !== this.$dropdownToggler && !((_a = this.$dropdownToggler) === null || _a === void 0 ? void 0 : _a.contains($target)) || !this.$dropdownContent)
|
|
337
|
+
return;
|
|
338
|
+
ev.preventDefault();
|
|
339
|
+
const trulyFocusableElements = this._getTrulyFocusableElements(this.$dropdownContent);
|
|
340
|
+
if (trulyFocusableElements.length === 0)
|
|
341
|
+
return;
|
|
342
|
+
const $lastFocusableElement = trulyFocusableElements.slice(-1)[0];
|
|
343
|
+
$lastFocusableElement.focus();
|
|
344
|
+
}
|
|
345
|
+
_handleFocusFromSentinelStartBackwards(ev, $target) {
|
|
346
|
+
var _a;
|
|
347
|
+
if (!this.$dropdownContent)
|
|
348
|
+
return;
|
|
349
|
+
const $firstFocusableElement = this._getTrulyFocusableElements(this.$dropdownContent)[0];
|
|
350
|
+
if ($target !== $firstFocusableElement)
|
|
351
|
+
return;
|
|
352
|
+
ev.preventDefault();
|
|
353
|
+
(_a = this.$dropdownToggler) === null || _a === void 0 ? void 0 : _a.focus();
|
|
354
|
+
}
|
|
355
|
+
_getTrulyFocusableElements($container) {
|
|
356
|
+
const focusableElements = utilities.UiDomUtils.getFocusableElements($container);
|
|
357
|
+
return focusableElements.filter(($el) => this._isElementTrulyFocusable($el));
|
|
358
|
+
}
|
|
359
|
+
_isElementTrulyFocusable($el) {
|
|
360
|
+
const style = window.getComputedStyle($el);
|
|
361
|
+
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
if ($el.nodeName === 'H-PORTAL')
|
|
365
|
+
return true;
|
|
366
|
+
const $parent = $el.parentElement;
|
|
367
|
+
if (!$parent)
|
|
368
|
+
return true;
|
|
369
|
+
return this._isElementTrulyFocusable($parent);
|
|
370
|
+
}
|
|
308
371
|
_isHoveredWithinDropdown(element) {
|
|
309
372
|
var _a;
|
|
310
373
|
if (element === this)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,qDAAyD;AAC1E;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,qDAAyD;AAC1E;AACA;AACA;AACA,uBAAuB,4CAAgD;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -16,7 +16,6 @@ var ref_js = require('lit-html/directives/ref.js');
|
|
|
16
16
|
var context_provider_controller = require('../../../core/context/context_provider_controller.js');
|
|
17
17
|
var global_constants = require('../../../global_constants.js');
|
|
18
18
|
var v4 = require('../../../../../../external/uuid/dist/esm-browser/v4.js');
|
|
19
|
-
var focus_trap_controller = require('../../../controllers/focus_trap_controller/focus_trap_controller.js');
|
|
20
19
|
var modal_constants = require('../../modal/modal_constants.js');
|
|
21
20
|
var sheet_constants = require('../../sheet/sheet_constants.js');
|
|
22
21
|
var when = require('../../../../../../external/lit-html/directives/when.js');
|
|
@@ -30,14 +29,9 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
30
29
|
this.isSearchUxFixesFlagEnabled = false;
|
|
31
30
|
this.displayMode = 'dropdown';
|
|
32
31
|
this._togglerElement = null;
|
|
33
|
-
this._mobileDialogOpener = null;
|
|
34
32
|
this._id = v4['default']();
|
|
35
33
|
this._openSearchButtonAriaLabelId = `${this._id}-open-search-button-aria-label`;
|
|
36
34
|
this._searchContentContainerId = v4['default']();
|
|
37
|
-
this.mobileFocusTrapController = new focus_trap_controller.FocusTrapController(this, {
|
|
38
|
-
mode: 'cyclic',
|
|
39
|
-
getContainer: () => this
|
|
40
|
-
});
|
|
41
35
|
this._searchResultsRef = ref_js.createRef();
|
|
42
36
|
this._searchHistoryRef = ref_js.createRef();
|
|
43
37
|
this._searchMessageRef = ref_js.createRef();
|
|
@@ -333,7 +327,6 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
333
327
|
if (window.innerWidth > global_constants.BREAKPOINTS.sm) {
|
|
334
328
|
const hasBeenOpened = this.classList.contains(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
|
|
335
329
|
this.classList.remove(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
|
|
336
|
-
this._deactivateMobileDialog();
|
|
337
330
|
if (hasBeenOpened && this.displayMode !== 'dropdown') {
|
|
338
331
|
const $storefrontSearch = document.querySelector(`h-storefront-search[module-instance-id="${this.moduleInstanceId}"]`);
|
|
339
332
|
const searchOverlayTriggerName = (_a = $storefrontSearch === null || $storefrontSearch === void 0 ? void 0 : $storefrontSearch.querySelector('[aria-haspopup="dialog"]')) === null || _a === void 0 ? void 0 : _a.getAttribute('name');
|
|
@@ -349,7 +342,6 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
349
342
|
};
|
|
350
343
|
this._openMobileView = () => {
|
|
351
344
|
this.classList.add(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
|
|
352
|
-
this._activateMobileDialog();
|
|
353
345
|
};
|
|
354
346
|
this._isSuggesterLayerVisible = () => {
|
|
355
347
|
var _a;
|
|
@@ -370,19 +362,6 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
370
362
|
document.removeEventListener('focusin', this._resetSearchOnFocusOutside);
|
|
371
363
|
}
|
|
372
364
|
};
|
|
373
|
-
this._activateMobileDialog = () => {
|
|
374
|
-
if (this.displayMode !== 'dropdown')
|
|
375
|
-
return;
|
|
376
|
-
this._mobileDialogOpener = document.activeElement;
|
|
377
|
-
this.setAttribute('role', 'dialog');
|
|
378
|
-
this.setAttribute('aria-modal', 'true');
|
|
379
|
-
this.mobileFocusTrapController.activate();
|
|
380
|
-
};
|
|
381
|
-
this._deactivateMobileDialog = () => {
|
|
382
|
-
this.removeAttribute('role');
|
|
383
|
-
this.removeAttribute('aria-modal');
|
|
384
|
-
this.mobileFocusTrapController.deactivate();
|
|
385
|
-
};
|
|
386
365
|
this._setupAriaAttributes = () => {
|
|
387
366
|
var _a;
|
|
388
367
|
if (this._translations.openSearchButtonAriaLabel) {
|
|
@@ -391,7 +370,6 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
391
370
|
};
|
|
392
371
|
this._handleOpenSearch = () => {
|
|
393
372
|
this.classList.add(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
|
|
394
|
-
this._activateMobileDialog();
|
|
395
373
|
const shouldShowMessage = this._searchPhrase !== '';
|
|
396
374
|
this._updateSearchView(this._searchPhrase, shouldShowMessage, false);
|
|
397
375
|
const $searchInput = this.querySelector(`
|
|
@@ -400,7 +378,7 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
400
378
|
$searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
|
|
401
379
|
};
|
|
402
380
|
this._handleOpenSearchWithKeyboard = (ev) => {
|
|
403
|
-
if (ev.code !== 'Enter'
|
|
381
|
+
if (ev.code !== 'Enter')
|
|
404
382
|
return;
|
|
405
383
|
ev.preventDefault();
|
|
406
384
|
this._handleOpenSearch();
|
|
@@ -512,10 +490,8 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
512
490
|
this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.submit, this._handleSubmitForm);
|
|
513
491
|
this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.close, () => {
|
|
514
492
|
this.classList.remove(search_constants.SEARCH_CLASS_NAMES.mobileOpened);
|
|
515
|
-
this._deactivateMobileDialog();
|
|
516
493
|
this._resetSearchView();
|
|
517
494
|
this.isSearchUxFixesFlagEnabled && this._removeSearchKeyboardNavigation();
|
|
518
|
-
requestAnimationFrame(() => { var _a; return (_a = this._mobileDialogOpener) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
519
495
|
});
|
|
520
496
|
this.addEventListener(search_constants.SEARCH_CUSTOM_EVENT_NAMES.loadMoreHistoryItems, () => {
|
|
521
497
|
const contentLength = this._searchHistory.length;
|
|
@@ -634,13 +610,13 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
634
610
|
if (!this._togglerElement)
|
|
635
611
|
return;
|
|
636
612
|
this._togglerElement.addEventListener('click', this._handleOpenSearch);
|
|
637
|
-
this._togglerElement.addEventListener('
|
|
613
|
+
this._togglerElement.addEventListener('keyup', this._handleOpenSearchWithKeyboard);
|
|
638
614
|
}
|
|
639
615
|
_teardownToggler() {
|
|
640
616
|
if (!this._togglerElement)
|
|
641
617
|
return;
|
|
642
618
|
this._togglerElement.removeEventListener('click', this._handleOpenSearch);
|
|
643
|
-
this._togglerElement.removeEventListener('
|
|
619
|
+
this._togglerElement.removeEventListener('keyup', this._handleOpenSearchWithKeyboard);
|
|
644
620
|
}
|
|
645
621
|
render() {
|
|
646
622
|
super.render();
|
|
@@ -650,7 +626,7 @@ exports.HSearch = class HSearch extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
650
626
|
tabindex="0"
|
|
651
627
|
aria-haspopup="dialog"
|
|
652
628
|
@click=${this._handleOpenSearch}
|
|
653
|
-
@
|
|
629
|
+
@keyup=${this._handleOpenSearchWithKeyboard}
|
|
654
630
|
>
|
|
655
631
|
${when.when(this._translations.openSearchButtonAriaLabel, () => lit.html `
|
|
656
632
|
<span id="${this._openSearchButtonAriaLabelId}" class="sr-only">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,wDAA4D;AAC7E;AACA;AACA
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,wDAA4D;AAC7E;AACA;AACA,mBAAmB,wDAA4D;AAC/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/input/search_input.js
CHANGED
|
@@ -72,15 +72,25 @@ exports.HSearchInput = class HSearchInput extends phoenix_light_lit_element.Phoe
|
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
|
-
this.input.addEventListener('
|
|
76
|
-
if (ev.key
|
|
75
|
+
this.input.addEventListener('keyup', (ev) => {
|
|
76
|
+
if (ev.key === 'ArrowUp' || ev.key === 'ArrowDown' || ev.key === 'Escape')
|
|
77
77
|
return;
|
|
78
|
+
if (ev.key !== 'Enter') {
|
|
79
|
+
this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.keyup, {
|
|
80
|
+
detail: {
|
|
81
|
+
searchPhrase: ev.target.value
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
78
86
|
if (this._isSearchPhraseCleared) {
|
|
79
87
|
this._isSearchPhraseCleared = false;
|
|
80
88
|
return;
|
|
81
89
|
}
|
|
82
90
|
this.emitCustomEvent(search_constants.SEARCH_CUSTOM_EVENT_NAMES.submit, {
|
|
83
|
-
detail: {
|
|
91
|
+
detail: {
|
|
92
|
+
searchPhrase: ev.target.value
|
|
93
|
+
}
|
|
84
94
|
});
|
|
85
95
|
});
|
|
86
96
|
this.input.addEventListener('keyup', debounce['default']((ev) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,qDAAyD;AACjF;AACA;AACA;AACA;AACA,uBAAuB,qDAAyD;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,qDAAyD;AACjF;AACA;AACA;AACA;AACA,uBAAuB,qDAAyD;AAChF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -34,7 +34,6 @@ var select_toggler_keyboard_controller = require('./controllers/select_toggler_k
|
|
|
34
34
|
|
|
35
35
|
exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
36
36
|
constructor() {
|
|
37
|
-
var _a;
|
|
38
37
|
super();
|
|
39
38
|
this.multiple = false;
|
|
40
39
|
this.opened = false;
|
|
@@ -43,7 +42,6 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
43
42
|
this.type = select_constants.SELECT_TYPES.select;
|
|
44
43
|
this.noDeselect = false;
|
|
45
44
|
this.assistiveTitleId = '';
|
|
46
|
-
this.isDevSelectPlaceholderFlagEnabled = false;
|
|
47
45
|
this.isReactiveSelectionFlagEnabled = false;
|
|
48
46
|
this.translations = {};
|
|
49
47
|
this._selectOptionsId = v4['default']();
|
|
@@ -55,6 +53,7 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
55
53
|
this._$dropdownContent = ref_js.createRef();
|
|
56
54
|
this.$dropdownToggler = ref_js.createRef();
|
|
57
55
|
this._selectContext = new context_provider_controller.ContextProviderController(this);
|
|
56
|
+
this.$placeholder = 'Select';
|
|
58
57
|
this._updateOptions = () => {
|
|
59
58
|
const $options = this._getOptions();
|
|
60
59
|
this._$options = $options.reduce((acc, $option) => {
|
|
@@ -112,28 +111,18 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
112
111
|
});
|
|
113
112
|
};
|
|
114
113
|
this._updateLabelAria = (options) => {
|
|
115
|
-
var _a
|
|
114
|
+
var _a;
|
|
116
115
|
if (!this.$searchLabel)
|
|
117
116
|
return;
|
|
118
117
|
(_a = this.$searchLabel.querySelector(`[id="value-label"]`)) === null || _a === void 0 ? void 0 : _a.remove();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this.$searchLabel.appendChild(valueLabelSpan);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
this.$searchLabel.innerHTML = `
|
|
131
|
-
${(_b = this.$searchLabel) === null || _b === void 0 ? void 0 : _b.innerHTML}
|
|
132
|
-
<span id="value-label" class="sr-only">
|
|
133
|
-
${options.reduce((totalSelectedContent, currentOption) => (totalSelectedContent += currentOption.content), '')}
|
|
134
|
-
</span>
|
|
135
|
-
`;
|
|
136
|
-
}
|
|
118
|
+
const hasValidOptions = options.some((option) => !option.isPlaceholder);
|
|
119
|
+
if (!hasValidOptions)
|
|
120
|
+
return;
|
|
121
|
+
const valueLabelSpan = document.createElement('span');
|
|
122
|
+
valueLabelSpan.id = 'value-label';
|
|
123
|
+
valueLabelSpan.className = 'sr-only';
|
|
124
|
+
valueLabelSpan.textContent = options.reduce((totalSelectedContent, currentOption) => totalSelectedContent + currentOption.content, '');
|
|
125
|
+
this.$searchLabel.appendChild(valueLabelSpan);
|
|
137
126
|
};
|
|
138
127
|
this._handleOptionClicked = ({ detail }) => {
|
|
139
128
|
if (!(detail === null || detail === void 0 ? void 0 : detail.$option))
|
|
@@ -185,8 +174,6 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
185
174
|
};
|
|
186
175
|
const $options = Array.from(this.querySelectorAll(select_components_constatns.SELECT_RELATED_COMPONENTS_NAMES.option));
|
|
187
176
|
$options.forEach(($option) => $option.setAttribute('slot', select_constants.SELECT_SLOT_NAMES.content));
|
|
188
|
-
const $placeholderEl = this.querySelector(`[slot="${select_components_constatns.SELECT_INPUT_PLACEHOLDER_SLOT_NAME}"]`);
|
|
189
|
-
this.$placeholder = $placeholderEl && ((_a = $placeholderEl.textContent) === null || _a === void 0 ? void 0 : _a.trim()) ? $placeholderEl : 'Select';
|
|
190
177
|
if (this.multiple)
|
|
191
178
|
this.type = select_constants.SELECT_TYPES.multiple;
|
|
192
179
|
}
|
|
@@ -232,9 +219,7 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
232
219
|
}
|
|
233
220
|
if (changedProperties.has('optionsList')) {
|
|
234
221
|
this._updateOptions();
|
|
235
|
-
|
|
236
|
-
this._addPlaceholderOptionIfNeeded();
|
|
237
|
-
}
|
|
222
|
+
this._addPlaceholderOptionIfNeeded();
|
|
238
223
|
}
|
|
239
224
|
if (this._$optionsList.value) {
|
|
240
225
|
(_a = this.listBoxController) === null || _a === void 0 ? void 0 : _a.hostDisconnected();
|
|
@@ -267,7 +252,7 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
267
252
|
$searchInput ? $searchInput.focus() : $optionToFocus === null || $optionToFocus === void 0 ? void 0 : $optionToFocus.focus();
|
|
268
253
|
}
|
|
269
254
|
connectedCallback() {
|
|
270
|
-
var _a;
|
|
255
|
+
var _a, _b;
|
|
271
256
|
super.connectedCallback();
|
|
272
257
|
this.classList.add(select_constants.SELECT_CSS_CLASSES.select);
|
|
273
258
|
if (!this.searchDisabled) {
|
|
@@ -282,10 +267,12 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
282
267
|
this._selectController.options$.subscribe(this._optionsObserver);
|
|
283
268
|
this._selectedOptionsAriaObserver = new observer.Observer((selectedOptions) => this._updateLabelAria(selectedOptions));
|
|
284
269
|
this._selectController.selectedOptions$.subscribe(this._selectedOptionsAriaObserver);
|
|
285
|
-
this.
|
|
286
|
-
if (
|
|
287
|
-
this
|
|
270
|
+
const $placeholderEl = this.querySelector(`[slot="${select_components_constatns.SELECT_INPUT_PLACEHOLDER_SLOT_NAME}"]`);
|
|
271
|
+
if ($placeholderEl && ((_b = $placeholderEl.textContent) === null || _b === void 0 ? void 0 : _b.trim())) {
|
|
272
|
+
this.$placeholder = $placeholderEl;
|
|
288
273
|
}
|
|
274
|
+
this._updateOptions();
|
|
275
|
+
this._addPlaceholderOptionIfNeeded();
|
|
289
276
|
this._setupEvents();
|
|
290
277
|
}
|
|
291
278
|
firstUpdated(changedProperties) {
|
|
@@ -515,9 +502,7 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
515
502
|
<h-select-close-btn class="${select_constants.SELECT_CSS_CLASSES.selectCloseMobileButton}" @close=${this._closeSelect}></h-select-close-btn>
|
|
516
503
|
|
|
517
504
|
<div class=${select_constants.SELECT_CSS_CLASSES.selectLabel}>
|
|
518
|
-
${this.
|
|
519
|
-
? (_b = this.$searchLabel) === null || _b === void 0 ? void 0 : _b.cloneNode(true)
|
|
520
|
-
: lit.html `${this._getClonedPlaceholderElement()}`}
|
|
505
|
+
${(_b = this.$searchLabel) === null || _b === void 0 ? void 0 : _b.cloneNode(true)}
|
|
521
506
|
</div>
|
|
522
507
|
|
|
523
508
|
${isSearchEnabled
|
|
@@ -633,10 +618,6 @@ tslib_es6.__decorate([
|
|
|
633
618
|
decorators_js.property({ type: String, attribute: 'assistive-title-id' }),
|
|
634
619
|
tslib_es6.__metadata("design:type", String)
|
|
635
620
|
], exports.HSelect.prototype, "assistiveTitleId", void 0);
|
|
636
|
-
tslib_es6.__decorate([
|
|
637
|
-
decorators_js.property({ type: Boolean, attribute: 'is-dev-select-placeholder-flag-enabled' }),
|
|
638
|
-
tslib_es6.__metadata("design:type", Boolean)
|
|
639
|
-
], exports.HSelect.prototype, "isDevSelectPlaceholderFlagEnabled", void 0);
|
|
640
621
|
tslib_es6.__decorate([
|
|
641
622
|
decorators_js.property({ type: Boolean, attribute: 'is-reactive-selection-flag-enabled' }),
|
|
642
623
|
tslib_es6.__metadata("design:type", Boolean)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,wDAA4D;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,wDAA4D;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
|
|
6
|
+
var utilities = require('@dreamcommerce/utilities');
|
|
6
7
|
var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
|
|
7
8
|
var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
|
|
8
9
|
var decorators_js = require('@lit/reactive-element/decorators.js');
|
|
10
|
+
require('@lit/reactive-element');
|
|
9
11
|
var litHtml = require('lit-html');
|
|
10
12
|
var ref_js = require('lit-html/directives/ref.js');
|
|
11
13
|
var portal_constants = require('../portal/portal_constants.js');
|
|
12
14
|
var backdrop_constants = require('../backdrop/backdrop_constants.js');
|
|
13
15
|
var backdrop_controller = require('../backdrop/controller/backdrop_controller.js');
|
|
14
|
-
var focus_trap_controller = require('../../controllers/focus_trap_controller/focus_trap_controller.js');
|
|
15
16
|
var modal_constants = require('./modal_constants.js');
|
|
16
17
|
var modal_close = require('./modal_close.js');
|
|
17
18
|
|
|
@@ -24,31 +25,54 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
24
25
|
this.transition = 'scale';
|
|
25
26
|
this.modalLabel = '';
|
|
26
27
|
this.noAutofocus = false;
|
|
28
|
+
this._firstFocusableElement = undefined;
|
|
29
|
+
this._focusableElements = null;
|
|
30
|
+
this._lastFocusableElement = undefined;
|
|
27
31
|
this._focusedToggler = null;
|
|
28
32
|
this._contentRef = ref_js.createRef();
|
|
33
|
+
this._focusSentinelStart = ref_js.createRef();
|
|
34
|
+
this._focusSentinelEnd = ref_js.createRef();
|
|
29
35
|
this._propsChangeStrategies = {
|
|
30
36
|
[modal_constants.MODAL_OPENED_PROP]: {
|
|
31
37
|
true: () => {
|
|
38
|
+
const scrollY = window.scrollY;
|
|
32
39
|
HModal_1.openModals = [...HModal_1.openModals, this];
|
|
33
40
|
document.addEventListener('keydown', this._bindCloseOnEsc);
|
|
34
41
|
document.addEventListener(backdrop_constants.BACKDROP_EVENTS.clicked, this.close);
|
|
35
42
|
this._dispatchModalOpenedEvent();
|
|
36
|
-
this.
|
|
43
|
+
if (!this.noAutofocus) {
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = this._firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
47
|
+
window.scrollTo(0, scrollY);
|
|
48
|
+
}, 0);
|
|
49
|
+
}
|
|
37
50
|
},
|
|
38
51
|
false: () => {
|
|
39
52
|
HModal_1.openModals = HModal_1.openModals.filter((modal) => modal !== this);
|
|
40
53
|
document.removeEventListener('keydown', this._bindCloseOnEsc);
|
|
41
54
|
document.removeEventListener(backdrop_constants.BACKDROP_EVENTS.clicked, this.close);
|
|
42
|
-
this._focusTrapController.deactivate();
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
};
|
|
46
58
|
this._backdropController = new backdrop_controller.BackdropController();
|
|
47
|
-
this.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
this._keepFocusWithinModal = (ev) => {
|
|
60
|
+
var _a;
|
|
61
|
+
const isTabPressed = ev.code === 'Tab';
|
|
62
|
+
if (isTabPressed && this._contentRef.value) {
|
|
63
|
+
if (ev.shiftKey) {
|
|
64
|
+
if (document.activeElement === this._firstFocusableElement) {
|
|
65
|
+
const focusableElements = utilities.UiDomUtils.getFocusableElements(this._contentRef.value);
|
|
66
|
+
(_a = focusableElements[focusableElements.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
67
|
+
ev.preventDefault();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (document.activeElement === this._lastFocusableElement) {
|
|
71
|
+
utilities.UiDomUtils.setFocusToFirstFocusableElementInContainer(this._contentRef.value);
|
|
72
|
+
ev.preventDefault();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
52
76
|
this._handleCloseFromCloseComponent = async (ev) => {
|
|
53
77
|
var _a;
|
|
54
78
|
ev.stopPropagation();
|
|
@@ -109,6 +133,7 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
109
133
|
});
|
|
110
134
|
};
|
|
111
135
|
this.hidden = true;
|
|
136
|
+
this._focusableElements = [...this.querySelectorAll(modal_constants.FOCUSABLE_ELEMENTS_WITHIN_MODAL)];
|
|
112
137
|
}
|
|
113
138
|
static _appendModalsPortal() {
|
|
114
139
|
const $modalsPortalTarget = document.querySelector(`h-portal-target[name="${modal_constants.MODALS_PORTAL_NAME}"]`);
|
|
@@ -124,6 +149,7 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
124
149
|
connectedCallback() {
|
|
125
150
|
super.connectedCallback();
|
|
126
151
|
HModal_1._appendModalsPortal();
|
|
152
|
+
document.addEventListener('keyup', this._keepFocusWithinModal);
|
|
127
153
|
document.addEventListener(modal_constants.MODAL_EVENTS.close, this._handleCloseFromCloseComponent);
|
|
128
154
|
}
|
|
129
155
|
disconnectedCallback() {
|
|
@@ -132,14 +158,29 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
132
158
|
this.close();
|
|
133
159
|
document.removeEventListener(modal_constants.MODAL_EVENTS.close, this._handleCloseFromCloseComponent);
|
|
134
160
|
document.removeEventListener('keydown', this._bindCloseOnEsc);
|
|
161
|
+
document.removeEventListener('keyup', this._keepFocusWithinModal);
|
|
162
|
+
}
|
|
163
|
+
firstUpdated(props) {
|
|
164
|
+
super.firstUpdated(props);
|
|
165
|
+
this._firstFocusableElement = this._focusSentinelStart.value;
|
|
166
|
+
this._lastFocusableElement = this._focusSentinelEnd.value;
|
|
135
167
|
}
|
|
136
168
|
updated(changedProps) {
|
|
137
169
|
if (changedProps.has(modal_constants.MODAL_OPENED_PROP)) {
|
|
138
170
|
this._propsChangeStrategies[modal_constants.MODAL_OPENED_PROP][String(this[modal_constants.MODAL_OPENED_PROP])]();
|
|
139
171
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
172
|
+
}
|
|
173
|
+
_setFocusToFirstFocusableElementInModalOrCloseBtn() {
|
|
174
|
+
if (this.noAutofocus)
|
|
175
|
+
return;
|
|
176
|
+
requestAnimationFrame(() => {
|
|
177
|
+
if (this._contentRef.value) {
|
|
178
|
+
const focusableElements = utilities.UiDomUtils.getFocusableElements(this._contentRef.value);
|
|
179
|
+
if (focusableElements.length > 0) {
|
|
180
|
+
focusableElements.length > 1 ? focusableElements[1].focus() : focusableElements[0].focus();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
143
184
|
}
|
|
144
185
|
async open() {
|
|
145
186
|
this._focusedToggler = document.activeElement;
|
|
@@ -156,6 +197,7 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
156
197
|
setTimeout(() => {
|
|
157
198
|
var _a;
|
|
158
199
|
(_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`modal_show-${this.transition}-start`, `modal_show-${this.transition}-end`);
|
|
200
|
+
this._setFocusToFirstFocusableElementInModalOrCloseBtn();
|
|
159
201
|
resolve();
|
|
160
202
|
}, transitionDuration);
|
|
161
203
|
});
|
|
@@ -183,11 +225,11 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
|
|
|
183
225
|
return litHtml.html `
|
|
184
226
|
<h-portal ?disabled="${!this.opened}" to="${modal_constants.MODALS_PORTAL_NAME}" hidden>
|
|
185
227
|
<div class="modal-wrapper ${this.class}">
|
|
186
|
-
<div tabindex="0"></div>
|
|
228
|
+
<div tabindex="0" ${ref_js.ref(this._focusSentinelStart)}></div>
|
|
187
229
|
<div ${ref_js.ref(this._contentRef)} class="modal" role="dialog" aria-label="${this.modalLabel}">
|
|
188
230
|
<div class="modal__container">${this.getSlot('header')} ${this.getSlot('body')} ${this.getSlot('footer')}</div>
|
|
189
231
|
</div>
|
|
190
|
-
<div tabindex="0"></div>
|
|
232
|
+
<div tabindex="0" ${ref_js.ref(this._focusSentinelEnd)}></div>
|
|
191
233
|
</div>
|
|
192
234
|
</h-portal>
|
|
193
235
|
`;
|
|
@@ -214,6 +256,18 @@ tslib_es6.__decorate([
|
|
|
214
256
|
decorators_js.property({ type: Boolean, attribute: 'no-autofocus' }),
|
|
215
257
|
tslib_es6.__metadata("design:type", Object)
|
|
216
258
|
], exports.HModal.prototype, "noAutofocus", void 0);
|
|
259
|
+
tslib_es6.__decorate([
|
|
260
|
+
decorators_js.state(),
|
|
261
|
+
tslib_es6.__metadata("design:type", Object)
|
|
262
|
+
], exports.HModal.prototype, "_firstFocusableElement", void 0);
|
|
263
|
+
tslib_es6.__decorate([
|
|
264
|
+
decorators_js.state(),
|
|
265
|
+
tslib_es6.__metadata("design:type", Object)
|
|
266
|
+
], exports.HModal.prototype, "_focusableElements", void 0);
|
|
267
|
+
tslib_es6.__decorate([
|
|
268
|
+
decorators_js.state(),
|
|
269
|
+
tslib_es6.__metadata("design:type", Object)
|
|
270
|
+
], exports.HModal.prototype, "_lastFocusableElement", void 0);
|
|
217
271
|
exports.HModal = HModal_1 = tslib_es6.__decorate([
|
|
218
272
|
phoenix_custom_element.phoenixCustomElement('h-modal'),
|
|
219
273
|
tslib_es6.__metadata("design:paramtypes", [])
|