@shoper/phoenix_design_system 1.13.0 → 1.14.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/packages/phoenix/src/components/color_swatches/color_item/color_item.js +21 -29
- package/build/cjs/packages/phoenix/src/components/color_swatches/color_item/color_item.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/color_swatches/color_item/color_item_constants.js +0 -4
- package/build/cjs/packages/phoenix/src/components/color_swatches/color_item/color_item_constants.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches.js +121 -11
- package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches_constants.js +0 -2
- package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches_constants.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js +114 -37
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_close.js +4 -4
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_content.js +12 -9
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_content.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js +13 -24
- package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/select/select.js +3 -4
- package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/messages/base_message.js +16 -47
- package/build/cjs/packages/phoenix/src/components/messages/base_message.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js +0 -2
- package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
- package/build/cjs/packages/phoenix/src/controllers/keystrokes_controller/keystrokes_controller.js +13 -2
- package/build/cjs/packages/phoenix/src/controllers/keystrokes_controller/keystrokes_controller.js.map +1 -1
- package/build/cjs/packages/phoenix/src/index.js +5 -5
- package/build/esm/packages/phoenix/src/components/color_swatches/color_item/color_item.d.ts +3 -6
- package/build/esm/packages/phoenix/src/components/color_swatches/color_item/color_item.js +22 -30
- package/build/esm/packages/phoenix/src/components/color_swatches/color_item/color_item.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/color_swatches/color_item/color_item_constants.js +1 -4
- package/build/esm/packages/phoenix/src/components/color_swatches/color_item/color_item_constants.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches.d.ts +11 -1
- package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches.js +124 -14
- package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches_constants.js +1 -2
- package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches_constants.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.d.ts +13 -4
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +115 -38
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_close.js +4 -4
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_content.d.ts +1 -2
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_content.js +12 -9
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_content.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.d.ts +1 -2
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js +14 -25
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/select/select.js +3 -4
- package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/messages/base_message.d.ts +2 -3
- package/build/esm/packages/phoenix/src/components/messages/base_message.js +18 -49
- package/build/esm/packages/phoenix/src/components/messages/base_message.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js +3 -4
- package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/keystrokes_controller/keystrokes_controller.d.ts +2 -1
- package/build/esm/packages/phoenix/src/controllers/keystrokes_controller/keystrokes_controller.js +13 -2
- package/build/esm/packages/phoenix/src/controllers/keystrokes_controller/keystrokes_controller.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/keystrokes_controller/keystrokes_controller_types.d.ts +1 -0
- package/build/esm/packages/phoenix/src/index.js +1 -1
- package/package.json +1 -1
|
@@ -7,47 +7,40 @@ var decorators = require('lit/decorators');
|
|
|
7
7
|
var utilities = require('@dreamcommerce/utilities');
|
|
8
8
|
var phoenix_light_lit_element = require('../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
|
|
9
9
|
var phoenix_custom_element = require('../../../core/decorators/phoenix_custom_element.js');
|
|
10
|
-
var btn_controller = require('../../../controllers/btn_controller/btn_controller.js');
|
|
11
10
|
var color_item_constants = require('./color_item_constants.js');
|
|
12
11
|
|
|
13
12
|
exports.HColorItem = class HColorItem extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
14
13
|
constructor() {
|
|
15
|
-
super();
|
|
14
|
+
super(...arguments);
|
|
16
15
|
this.disabled = false;
|
|
17
16
|
this.selected = false;
|
|
18
17
|
this.unclickable = false;
|
|
19
|
-
this.
|
|
20
|
-
|
|
18
|
+
this._$colorSwatches = null;
|
|
19
|
+
this._setupAriaAttributes = () => {
|
|
20
|
+
var _a;
|
|
21
|
+
this._$colorSwatches = this.closest('h-color-swatches');
|
|
22
|
+
this.setAttribute('role', ((_a = this._$colorSwatches) === null || _a === void 0 ? void 0 : _a.multiple) ? 'checkbox' : 'radio');
|
|
23
|
+
this.setAttribute('aria-label', this.label ? this.label : this.color);
|
|
24
|
+
};
|
|
25
|
+
this._setupClasses = () => {
|
|
26
|
+
this.classList.add(color_item_constants.COLOR_ITEM_CSS_CLASSES.colorItem);
|
|
27
|
+
if (this.size)
|
|
28
|
+
this.classList.add(color_item_constants.COLOR_ITEM_CSS_CLASSES[this.size]);
|
|
21
29
|
};
|
|
22
|
-
this._btnController = new btn_controller.BtnController(this, this._dispatchClickedEvent);
|
|
23
30
|
}
|
|
24
31
|
connectedCallback() {
|
|
25
32
|
super.connectedCallback();
|
|
26
|
-
this.
|
|
33
|
+
this._setupAriaAttributes();
|
|
34
|
+
this._setupClasses();
|
|
27
35
|
this.style.backgroundColor = this.setBgColor(this.disabled);
|
|
28
|
-
this.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
if (this.unclickable) {
|
|
37
|
+
this.removeAttribute('tabindex');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.setAttribute('tabindex', '0');
|
|
41
|
+
}
|
|
32
42
|
if (!this.value)
|
|
33
43
|
this.value = this.color;
|
|
34
|
-
if (this.size)
|
|
35
|
-
this.classList.add(color_item_constants.COLOR_ITEM_CSS_CLASSES[this.size]);
|
|
36
|
-
}
|
|
37
|
-
attributeChangedCallback(name, value, newValue) {
|
|
38
|
-
super.attributeChangedCallback(name, value, newValue);
|
|
39
|
-
switch (name) {
|
|
40
|
-
case color_item_constants.COLOR_ITEM_SELECTED_ATTRIBUTE: {
|
|
41
|
-
this._syncAriaPressed();
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
_syncAriaPressed() {
|
|
47
|
-
this.selected ? this.setAttribute('aria-pressed', '') : this.removeAttribute('aria-pressed');
|
|
48
|
-
}
|
|
49
|
-
setupEvents() {
|
|
50
|
-
!this.unclickable && this.addEventListener('click', this._dispatchClickedEvent);
|
|
51
44
|
}
|
|
52
45
|
setBgColor(itemIsDisabled) {
|
|
53
46
|
return itemIsDisabled ? utilities.ColorUtils.hexToRgba(this.color, 0.5) : this.color;
|
|
@@ -82,7 +75,6 @@ tslib_es6.__decorate([
|
|
|
82
75
|
tslib_es6.__metadata("design:type", Boolean)
|
|
83
76
|
], exports.HColorItem.prototype, "unclickable", void 0);
|
|
84
77
|
exports.HColorItem = tslib_es6.__decorate([
|
|
85
|
-
phoenix_custom_element.phoenixCustomElement('h-color-item')
|
|
86
|
-
tslib_es6.__metadata("design:paramtypes", [])
|
|
78
|
+
phoenix_custom_element.phoenixCustomElement('h-color-item')
|
|
87
79
|
], exports.HColorItem);
|
|
88
80
|
//# sourceMappingURL=color_item.js.map
|
package/build/cjs/packages/phoenix/src/components/color_swatches/color_item/color_item.js.map
CHANGED
|
@@ -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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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/color_swatches/color_item/color_item_constants.js
CHANGED
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const colorItemBaseCssClass = 'color-item';
|
|
6
|
-
const COLOR_ITEM_EVENT_NAMES = {
|
|
7
|
-
selected: 'colorItemSelected'
|
|
8
|
-
};
|
|
9
6
|
const COLOR_ITEM_SIZES = {
|
|
10
7
|
s: 's',
|
|
11
8
|
xs: 'xs'
|
|
@@ -18,7 +15,6 @@ const COLOR_ITEM_CSS_CLASSES = {
|
|
|
18
15
|
const COLOR_ITEM_SELECTED_ATTRIBUTE = 'selected';
|
|
19
16
|
|
|
20
17
|
exports.COLOR_ITEM_CSS_CLASSES = COLOR_ITEM_CSS_CLASSES;
|
|
21
|
-
exports.COLOR_ITEM_EVENT_NAMES = COLOR_ITEM_EVENT_NAMES;
|
|
22
18
|
exports.COLOR_ITEM_SELECTED_ATTRIBUTE = COLOR_ITEM_SELECTED_ATTRIBUTE;
|
|
23
19
|
exports.COLOR_ITEM_SIZES = COLOR_ITEM_SIZES;
|
|
24
20
|
//# sourceMappingURL=color_item_constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -8,6 +8,7 @@ var decorators = require('lit/decorators');
|
|
|
8
8
|
var utilities = require('@dreamcommerce/utilities');
|
|
9
9
|
var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
|
|
10
10
|
var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
|
|
11
|
+
var keystrokes_controller = require('../../controllers/keystrokes_controller/keystrokes_controller.js');
|
|
11
12
|
require('lit-html');
|
|
12
13
|
var color_swatches_constants = require('./color_swatches_constants.js');
|
|
13
14
|
var color_item_constants = require('./color_item/color_item_constants.js');
|
|
@@ -18,8 +19,87 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
|
|
|
18
19
|
this.multiple = false;
|
|
19
20
|
this.selectedColors = [];
|
|
20
21
|
this.showMoreBtnText = 'Pokaż wszystkie kolory';
|
|
21
|
-
this.
|
|
22
|
-
|
|
22
|
+
this._setupEvents = () => {
|
|
23
|
+
if (this.getAttribute('role') === 'group') {
|
|
24
|
+
this._setupCheckboxGroupEvents();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this._setupRadioGroupEvents();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
this._setupCheckboxGroupEvents = () => {
|
|
31
|
+
this._setupColorClickEvents();
|
|
32
|
+
};
|
|
33
|
+
this._setupRadioGroupEvents = () => {
|
|
34
|
+
document.body.addEventListener('keydown', this._focusOnSelectedColor);
|
|
35
|
+
this.addEventListener('keydown', this._handleTabNavigation);
|
|
36
|
+
this.addEventListener('keyup', this._handleRadioNavigation);
|
|
37
|
+
this._setupColorClickEvents();
|
|
38
|
+
};
|
|
39
|
+
this._setupColorClickEvents = () => {
|
|
40
|
+
if (!this._$colorSwatchesChildren)
|
|
41
|
+
return;
|
|
42
|
+
this._$colorSwatchesChildren.forEach(($colorItem) => {
|
|
43
|
+
$colorItem.addEventListener('click', this._handleColorClicked);
|
|
44
|
+
new keystrokes_controller.KeystrokesController({
|
|
45
|
+
host: this,
|
|
46
|
+
keys: [' '],
|
|
47
|
+
callback: this._handleColorClicked,
|
|
48
|
+
target: $colorItem
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
this._handleColorClicked = (ev) => {
|
|
53
|
+
ev.preventDefault();
|
|
54
|
+
const $colorItem = ev.target;
|
|
55
|
+
if ($colorItem.unclickable)
|
|
56
|
+
return;
|
|
57
|
+
this._toggleColorItem($colorItem);
|
|
58
|
+
this._dispatchColorChangeEvent($colorItem);
|
|
59
|
+
};
|
|
60
|
+
this._handleTabNavigation = (ev) => {
|
|
61
|
+
if (ev.key !== 'Tab')
|
|
62
|
+
return;
|
|
63
|
+
ev.preventDefault();
|
|
64
|
+
if (ev.shiftKey) {
|
|
65
|
+
const $firstFocusableColor = utilities.UiDomUtils.getFocusableElement(this);
|
|
66
|
+
utilities.UiDomUtils.getPreviousFocusableElement($firstFocusableColor).focus();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const $LastFocusableColor = utilities.UiDomUtils.getLastFocusableElement(this);
|
|
70
|
+
utilities.UiDomUtils.getNextFocusableElement($LastFocusableColor).focus();
|
|
71
|
+
};
|
|
72
|
+
this._handleRadioNavigation = (ev) => {
|
|
73
|
+
const changeToNextKeys = ['ArrowDown', 'ArrowRight'];
|
|
74
|
+
const changeToPreviousKeys = ['ArrowUp', 'ArrowLeft'];
|
|
75
|
+
if (!changeToNextKeys.includes(ev.key) && !changeToPreviousKeys.includes(ev.key))
|
|
76
|
+
return;
|
|
77
|
+
ev.preventDefault();
|
|
78
|
+
if (changeToNextKeys.includes(ev.key)) {
|
|
79
|
+
this._handleChangeToNextColorItem(ev);
|
|
80
|
+
}
|
|
81
|
+
if (changeToPreviousKeys.includes(ev.key)) {
|
|
82
|
+
this._handleChangeToPreviousColorItem(ev);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
this._focusOnSelectedColor = (ev) => {
|
|
86
|
+
if (ev.key !== 'Tab' || this.multiple)
|
|
87
|
+
return;
|
|
88
|
+
if (ev.shiftKey) {
|
|
89
|
+
const $previousFocusableElement = utilities.UiDomUtils.getPreviousFocusableElement(document.activeElement);
|
|
90
|
+
if (this.contains($previousFocusableElement) && this.selectedColors.length > 0) {
|
|
91
|
+
ev.preventDefault();
|
|
92
|
+
this.selectedColors[0].focus();
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const $nextFocusableElement = utilities.UiDomUtils.getNextFocusableElement(document.activeElement);
|
|
97
|
+
if (this.contains($nextFocusableElement) && this.selectedColors.length > 0) {
|
|
98
|
+
ev.preventDefault();
|
|
99
|
+
this.selectedColors[0].focus();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
this._handleColorChange = ($colorItem) => {
|
|
23
103
|
this._toggleColorItem($colorItem);
|
|
24
104
|
this._dispatchColorChangeEvent($colorItem);
|
|
25
105
|
};
|
|
@@ -56,6 +136,8 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
|
|
|
56
136
|
}
|
|
57
137
|
connectedCallback() {
|
|
58
138
|
super.connectedCallback();
|
|
139
|
+
this.setAttribute('role', this.multiple ? 'group' : 'radiogroup');
|
|
140
|
+
this._$colorSwatchesChildren = [...this.children];
|
|
59
141
|
this._setupEvents();
|
|
60
142
|
this._addCssClasses();
|
|
61
143
|
this.numberOfVisibleColors && this._hideItems(this.numberOfVisibleColors);
|
|
@@ -68,11 +150,9 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
|
|
|
68
150
|
this.classList.add(color_swatches_constants.COLOR_SWATCHES_CSS_CLASSES.colorSwatches);
|
|
69
151
|
}
|
|
70
152
|
_hideItems(numberOfVisibleColors) {
|
|
71
|
-
var _a;
|
|
72
|
-
this._$colorSwatchesChildren = (_a = document.querySelector(color_swatches_constants.COLOR_SWATCHES_TAG_NAME)) === null || _a === void 0 ? void 0 : _a.children;
|
|
73
153
|
if (!this._$colorSwatchesChildren)
|
|
74
154
|
return;
|
|
75
|
-
|
|
155
|
+
this._$colorSwatchesChildren.forEach(($colorSwatchesChild, index) => {
|
|
76
156
|
if (index > numberOfVisibleColors - 1) {
|
|
77
157
|
$colorSwatchesChild.setAttribute(color_swatches_constants.COLOR_SWATCHES_HIDDEN_ATTRIBUTE, '');
|
|
78
158
|
}
|
|
@@ -83,17 +163,40 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
|
|
|
83
163
|
var _a;
|
|
84
164
|
if (!this._$colorSwatchesChildren)
|
|
85
165
|
return;
|
|
86
|
-
|
|
166
|
+
this._$colorSwatchesChildren.forEach(($colorSwatchesChild) => {
|
|
87
167
|
$colorSwatchesChild.removeAttribute(color_swatches_constants.COLOR_SWATCHES_HIDDEN_ATTRIBUTE);
|
|
88
168
|
});
|
|
89
169
|
(_a = this.querySelector('h-color-swatches-show-more')) === null || _a === void 0 ? void 0 : _a.setAttribute(color_swatches_constants.COLOR_SWATCHES_HIDDEN_ATTRIBUTE, '');
|
|
90
170
|
});
|
|
91
171
|
}
|
|
92
|
-
|
|
93
|
-
|
|
172
|
+
_handleChangeToNextColorItem({ target }) {
|
|
173
|
+
const $colorItem = target;
|
|
174
|
+
const $nextFocusableElement = utilities.UiDomUtils.getNextFocusableElement($colorItem);
|
|
175
|
+
let $nextColorItem;
|
|
176
|
+
if (!this.contains($nextFocusableElement)) {
|
|
177
|
+
$nextColorItem = utilities.UiDomUtils.getFocusableElement(this);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
$nextColorItem = $nextFocusableElement;
|
|
181
|
+
}
|
|
182
|
+
$nextColorItem.focus();
|
|
183
|
+
this._handleColorChange($nextColorItem);
|
|
184
|
+
}
|
|
185
|
+
_handleChangeToPreviousColorItem({ target }) {
|
|
186
|
+
const $colorItem = target;
|
|
187
|
+
const $previousFocusableElement = utilities.UiDomUtils.getPreviousFocusableElement($colorItem);
|
|
188
|
+
let $previousColorItem;
|
|
189
|
+
if (!this.contains($previousFocusableElement)) {
|
|
190
|
+
$previousColorItem = utilities.UiDomUtils.getLastFocusableElement(this);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
$previousColorItem = $previousFocusableElement;
|
|
194
|
+
}
|
|
195
|
+
$previousColorItem.focus();
|
|
196
|
+
this._handleColorChange($previousColorItem);
|
|
94
197
|
}
|
|
95
198
|
_toggleColorItem($colorItem) {
|
|
96
|
-
this.multiple ? this._handleColorClickedForMultipleMode($colorItem) : this.
|
|
199
|
+
this.multiple ? this._handleColorClickedForMultipleMode($colorItem) : this._handleColorChangeForSingleMode($colorItem);
|
|
97
200
|
}
|
|
98
201
|
_handleColorClickedForMultipleMode($colorItem) {
|
|
99
202
|
!this._isColorAlreadyExistInArray($colorItem)
|
|
@@ -101,17 +204,20 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
|
|
|
101
204
|
: this._removeExistingColorFromArray($colorItem);
|
|
102
205
|
this._toggleSelectedAttribute($colorItem);
|
|
103
206
|
}
|
|
104
|
-
|
|
207
|
+
_handleColorChangeForSingleMode($colorItem) {
|
|
105
208
|
const $previouslySelected = this.selectedColors[0];
|
|
106
209
|
this._toggleSelectedAttribute($colorItem);
|
|
107
|
-
if ($previouslySelected && $previouslySelected !== $colorItem)
|
|
210
|
+
if ($previouslySelected && $previouslySelected !== $colorItem) {
|
|
108
211
|
$previouslySelected.removeAttribute(color_item_constants.COLOR_ITEM_SELECTED_ATTRIBUTE);
|
|
212
|
+
$previouslySelected.setAttribute('aria-checked', 'false');
|
|
213
|
+
}
|
|
109
214
|
this.selectedColors = $previouslySelected === $colorItem ? [] : [$colorItem];
|
|
110
215
|
}
|
|
111
216
|
_toggleSelectedAttribute($colorItem) {
|
|
112
217
|
$colorItem.hasAttribute(color_item_constants.COLOR_ITEM_SELECTED_ATTRIBUTE)
|
|
113
218
|
? $colorItem.removeAttribute(color_item_constants.COLOR_ITEM_SELECTED_ATTRIBUTE)
|
|
114
219
|
: $colorItem.setAttribute(color_item_constants.COLOR_ITEM_SELECTED_ATTRIBUTE, '');
|
|
220
|
+
$colorItem.setAttribute('aria-checked', 'true');
|
|
115
221
|
}
|
|
116
222
|
_isColorAlreadyExistInArray($colorItem) {
|
|
117
223
|
return this.selectedColors.includes($colorItem);
|
|
@@ -120,6 +226,10 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
|
|
|
120
226
|
const indexOfAlreadyExistingColor = this.selectedColors.indexOf($colorItem);
|
|
121
227
|
this.selectedColors.splice(indexOfAlreadyExistingColor, 1);
|
|
122
228
|
}
|
|
229
|
+
disconnectedCallback() {
|
|
230
|
+
super.disconnectedCallback();
|
|
231
|
+
document.body.removeEventListener('keydown', this._focusOnSelectedColor);
|
|
232
|
+
}
|
|
123
233
|
render() {
|
|
124
234
|
return lit.html `
|
|
125
235
|
${this.getSlot('default')}
|
|
@@ -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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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/color_swatches/color_swatches_constants.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const colorSwatchesBaseCssClass = 'color-swatches';
|
|
6
|
-
const COLOR_SWATCHES_TAG_NAME = 'h-color-swatches';
|
|
7
6
|
const COLOR_ITEM_TAG_NAME = 'h-color-item';
|
|
8
7
|
const COLOR_SWATCHES_CSS_CLASSES = {
|
|
9
8
|
colorSwatches: colorSwatchesBaseCssClass,
|
|
@@ -20,5 +19,4 @@ exports.COLOR_ITEM_TAG_NAME = COLOR_ITEM_TAG_NAME;
|
|
|
20
19
|
exports.COLOR_SWATCHES_CSS_CLASSES = COLOR_SWATCHES_CSS_CLASSES;
|
|
21
20
|
exports.COLOR_SWATCHES_EVENT_NAMES = COLOR_SWATCHES_EVENT_NAMES;
|
|
22
21
|
exports.COLOR_SWATCHES_HIDDEN_ATTRIBUTE = COLOR_SWATCHES_HIDDEN_ATTRIBUTE;
|
|
23
|
-
exports.COLOR_SWATCHES_TAG_NAME = COLOR_SWATCHES_TAG_NAME;
|
|
24
22
|
//# sourceMappingURL=color_swatches_constants.js.map
|
package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches_constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -12,6 +12,7 @@ var litHtml = require('lit-html');
|
|
|
12
12
|
var global_constants = require('../../global_constants.js');
|
|
13
13
|
var dropdown_constants = require('./dropdown_constants.js');
|
|
14
14
|
var relative_position_controller_constants = require('../../controllers/relative_position_controller/relative_position_controller_constants.js');
|
|
15
|
+
var v4 = require('../../../../../external/uuid/dist/esm-browser/v4.js');
|
|
15
16
|
var portal_constants = require('../portal/portal_constants.js');
|
|
16
17
|
var backdrop_controller = require('../backdrop/controller/backdrop_controller.js');
|
|
17
18
|
var click_outside_controller = require('../../controllers/click_outside_controller/click_outside_controller.js');
|
|
@@ -29,6 +30,8 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
29
30
|
this.transition = 'direction';
|
|
30
31
|
this.offset = 0;
|
|
31
32
|
this.portalTarget = dropdown_constants.DEFAULT_DROPDOWN_PORTAL_NAME;
|
|
33
|
+
this.id = v4['default']();
|
|
34
|
+
this.preventFocusTrap = false;
|
|
32
35
|
this._backdropController = new backdrop_controller.BackdropController();
|
|
33
36
|
this._handleClickOutside = async (target) => {
|
|
34
37
|
var _a, _b;
|
|
@@ -45,7 +48,7 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
50
|
await this.show();
|
|
48
|
-
|
|
51
|
+
this._focusOnFirstContentElement();
|
|
49
52
|
};
|
|
50
53
|
this.show = async () => {
|
|
51
54
|
if (this.opened)
|
|
@@ -136,44 +139,32 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
136
139
|
return;
|
|
137
140
|
await this.hide();
|
|
138
141
|
};
|
|
139
|
-
this.
|
|
140
|
-
|
|
141
|
-
if (!this
|
|
142
|
+
this._keepFocusWithinDropdownForwards = (ev) => {
|
|
143
|
+
var _a, _b;
|
|
144
|
+
if (ev.shiftKey === true || !this.$dropdownContent || !this.opened)
|
|
142
145
|
return;
|
|
143
|
-
const $
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this._handleFocusOnNextElement = async (ev) => {
|
|
151
|
-
var _a;
|
|
152
|
-
ev.preventDefault();
|
|
153
|
-
const $focusableElements = utilities.UiDomUtils.getFocusableElements(document.body);
|
|
154
|
-
const indexOfDropdownToggler = $focusableElements.indexOf(this.$dropdownToggler);
|
|
155
|
-
const $nextElementToFocus = (_a = $focusableElements[indexOfDropdownToggler + 1]) !== null && _a !== void 0 ? _a : $focusableElements[0];
|
|
156
|
-
await this._hideDropdownsSequentially();
|
|
157
|
-
await this.hide();
|
|
158
|
-
this._focusOnNextElementAfterToggler($nextElementToFocus);
|
|
159
|
-
};
|
|
160
|
-
this._focusOnNextElementAfterToggler = ($elementToFocus) => {
|
|
161
|
-
var _a;
|
|
162
|
-
const isTogglerLastChildOfPreviousDropdown = ($elementToFocus === null || $elementToFocus === void 0 ? void 0 : $elementToFocus.closest(dropdown_constants.DROPDOWN_CONTENT_NAME)) === this.$dropdownContent;
|
|
163
|
-
if (isTogglerLastChildOfPreviousDropdown) {
|
|
164
|
-
(_a = this.$dropdownToggler) === null || _a === void 0 ? void 0 : _a.focus();
|
|
146
|
+
const $target = ev.target;
|
|
147
|
+
if (((_a = this.$dropdownContent) === null || _a === void 0 ? void 0 : _a.contains($target)) && this.preventFocusTrap) {
|
|
148
|
+
this._handleFocusOnNextElementAfterDropdown(ev);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if ((_b = this.$dropdownToggler) === null || _b === void 0 ? void 0 : _b.contains($target)) {
|
|
152
|
+
this._handleFocusFromTogglerForwards(ev);
|
|
165
153
|
return;
|
|
166
154
|
}
|
|
167
|
-
|
|
155
|
+
this._handleFocusFromSentinelEndForwards(ev, $target);
|
|
168
156
|
};
|
|
169
|
-
this.
|
|
170
|
-
|
|
171
|
-
const $firstFocusableElement = this.$dropdownContent && utilities.UiDomUtils.getFocusableElement(this.$dropdownContent);
|
|
172
|
-
if (document.activeElement !== $firstFocusableElement)
|
|
157
|
+
this._keepFocusWithinDropdownBackwards = (ev) => {
|
|
158
|
+
if (!this.opened || !this.$dropdownContent)
|
|
173
159
|
return;
|
|
174
|
-
ev.
|
|
175
|
-
(
|
|
176
|
-
|
|
160
|
+
const $target = ev.target;
|
|
161
|
+
if (this.preventFocusTrap) {
|
|
162
|
+
this._handleDefaultFocusFromDropdownBackwards(ev);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
this._handleFocusFromTogglerBackwards(ev, $target);
|
|
166
|
+
this._handleFocusFromSentinelStartBackwards(ev, $target);
|
|
167
|
+
}
|
|
177
168
|
};
|
|
178
169
|
this._hoverToggle = async (ev) => {
|
|
179
170
|
if (window.innerWidth < global_constants.BREAKPOINTS.xs)
|
|
@@ -185,12 +176,19 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
185
176
|
const isHoveredWithinDropdown = this._isHoveredWithinDropdown(ev.target);
|
|
186
177
|
if (isHoveredWithinDropdown && !this.opened) {
|
|
187
178
|
await this.show();
|
|
188
|
-
|
|
179
|
+
this._focusOnFirstContentElement();
|
|
189
180
|
return;
|
|
190
181
|
}
|
|
191
182
|
if (!isHoveredWithinDropdown && this.opened)
|
|
192
183
|
await this._hideDropdownsSequentially();
|
|
193
184
|
};
|
|
185
|
+
this._focusOnFirstContentElement = () => {
|
|
186
|
+
if (!this.$dropdownContent)
|
|
187
|
+
return;
|
|
188
|
+
const $firstFocusableElement = this._getTrulyFocusableElements(this.$dropdownContent)[0];
|
|
189
|
+
if ($firstFocusableElement)
|
|
190
|
+
$firstFocusableElement.focus();
|
|
191
|
+
};
|
|
194
192
|
this.isOpened = () => this.opened;
|
|
195
193
|
this._positionDropdownContent = () => {
|
|
196
194
|
if (this.contentWidth === dropdown_constants.DROPDOWN_CONTENT_WIDTH.full)
|
|
@@ -216,13 +214,14 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
216
214
|
host: this,
|
|
217
215
|
target: document.body,
|
|
218
216
|
keys: ['tab'],
|
|
219
|
-
callback: this.
|
|
217
|
+
callback: this._keepFocusWithinDropdownForwards
|
|
220
218
|
});
|
|
221
219
|
new keystrokes_controller.KeystrokesController({
|
|
222
220
|
host: this,
|
|
223
221
|
target: document.body,
|
|
224
222
|
keys: [['shift', 'tab']],
|
|
225
|
-
callback: this.
|
|
223
|
+
callback: this._keepFocusWithinDropdownBackwards,
|
|
224
|
+
containerSelectors: ['h-dropdown', 'h-dropdown-content']
|
|
226
225
|
});
|
|
227
226
|
}
|
|
228
227
|
async connectedCallback() {
|
|
@@ -298,6 +297,74 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
298
297
|
(_b = this.$dropdownContent) === null || _b === void 0 ? void 0 : _b.classList.add(global_constants.SCROLLABLE_CLASS_NAME);
|
|
299
298
|
}
|
|
300
299
|
}
|
|
300
|
+
_handleFocusOnNextElementAfterDropdown(ev) {
|
|
301
|
+
ev.preventDefault();
|
|
302
|
+
this.hide();
|
|
303
|
+
utilities.UiDomUtils.getNextFocusableElement(this.$dropdownToggler || this).focus();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
_handleFocusFromTogglerForwards(ev) {
|
|
307
|
+
if (!this.$dropdownContent)
|
|
308
|
+
return;
|
|
309
|
+
const trulyFocusableElements = this._getTrulyFocusableElements(this.$dropdownContent);
|
|
310
|
+
if (trulyFocusableElements.length === 0)
|
|
311
|
+
return;
|
|
312
|
+
ev.preventDefault();
|
|
313
|
+
trulyFocusableElements[0].focus();
|
|
314
|
+
}
|
|
315
|
+
_handleFocusFromSentinelEndForwards(ev, $target) {
|
|
316
|
+
var _a;
|
|
317
|
+
if (!this.$dropdownContent)
|
|
318
|
+
return;
|
|
319
|
+
const trulyFocusableElements = this._getTrulyFocusableElements(this.$dropdownContent);
|
|
320
|
+
const $lastFocusableElement = trulyFocusableElements.slice(-1)[0];
|
|
321
|
+
if ($target !== $lastFocusableElement)
|
|
322
|
+
return;
|
|
323
|
+
ev.preventDefault();
|
|
324
|
+
(_a = this.$dropdownToggler) === null || _a === void 0 ? void 0 : _a.focus();
|
|
325
|
+
}
|
|
326
|
+
_handleDefaultFocusFromDropdownBackwards(ev) {
|
|
327
|
+
ev.preventDefault();
|
|
328
|
+
this.hide();
|
|
329
|
+
utilities.UiDomUtils.getPreviousFocusableElement(this.$dropdownToggler || this).focus();
|
|
330
|
+
}
|
|
331
|
+
_handleFocusFromTogglerBackwards(ev, $target) {
|
|
332
|
+
var _a;
|
|
333
|
+
if ($target !== this.$dropdownToggler && !((_a = this.$dropdownToggler) === null || _a === void 0 ? void 0 : _a.contains($target)) || !this.$dropdownContent)
|
|
334
|
+
return;
|
|
335
|
+
ev.preventDefault();
|
|
336
|
+
const trulyFocusableElements = this._getTrulyFocusableElements(this.$dropdownContent);
|
|
337
|
+
if (trulyFocusableElements.length === 0)
|
|
338
|
+
return;
|
|
339
|
+
const $lastFocusableElement = trulyFocusableElements.slice(-1)[0];
|
|
340
|
+
$lastFocusableElement.focus();
|
|
341
|
+
}
|
|
342
|
+
_handleFocusFromSentinelStartBackwards(ev, $target) {
|
|
343
|
+
var _a;
|
|
344
|
+
if (!this.$dropdownContent)
|
|
345
|
+
return;
|
|
346
|
+
const $firstFocusableElement = this._getTrulyFocusableElements(this.$dropdownContent)[0];
|
|
347
|
+
if ($target !== $firstFocusableElement)
|
|
348
|
+
return;
|
|
349
|
+
ev.preventDefault();
|
|
350
|
+
(_a = this.$dropdownToggler) === null || _a === void 0 ? void 0 : _a.focus();
|
|
351
|
+
}
|
|
352
|
+
_getTrulyFocusableElements($container) {
|
|
353
|
+
const focusableElements = utilities.UiDomUtils.getFocusableElements($container);
|
|
354
|
+
return focusableElements.filter(($el) => this._isElementTrulyFocusable($el));
|
|
355
|
+
}
|
|
356
|
+
_isElementTrulyFocusable($el) {
|
|
357
|
+
const style = window.getComputedStyle($el);
|
|
358
|
+
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
if ($el.nodeName === 'H-PORTAL')
|
|
362
|
+
return true;
|
|
363
|
+
const $parent = $el.parentElement;
|
|
364
|
+
if (!$parent)
|
|
365
|
+
return true;
|
|
366
|
+
return this._isElementTrulyFocusable($parent);
|
|
367
|
+
}
|
|
301
368
|
_isHoveredWithinDropdown(element) {
|
|
302
369
|
var _a;
|
|
303
370
|
if (element === this)
|
|
@@ -321,6 +388,8 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
321
388
|
return;
|
|
322
389
|
if (!this._hasScrollableClassInitially)
|
|
323
390
|
this._hasScrollableClassInitially = this.$dropdownContent.classList.contains(global_constants.SCROLLABLE_CLASS_NAME);
|
|
391
|
+
if (!this.preventFocusTrap)
|
|
392
|
+
this.$dropdownContent.setAttribute('aria-modal', 'true');
|
|
324
393
|
}
|
|
325
394
|
_getDropdownContentWidth() {
|
|
326
395
|
const isMobileResolution = document.documentElement.clientWidth < global_constants.BREAKPOINTS.xs;
|
|
@@ -389,6 +458,14 @@ tslib_es6.__decorate([
|
|
|
389
458
|
decorators_js.property({ type: String, attribute: 'mobile-position' }),
|
|
390
459
|
tslib_es6.__metadata("design:type", String)
|
|
391
460
|
], exports.HDropdown.prototype, "mobilePosition", void 0);
|
|
461
|
+
tslib_es6.__decorate([
|
|
462
|
+
decorators_js.property({ type: String, attribute: 'id', reflect: true }),
|
|
463
|
+
tslib_es6.__metadata("design:type", Object)
|
|
464
|
+
], exports.HDropdown.prototype, "id", void 0);
|
|
465
|
+
tslib_es6.__decorate([
|
|
466
|
+
decorators_js.property({ type: Boolean, attribute: 'prevent-focus-trap' }),
|
|
467
|
+
tslib_es6.__metadata("design:type", Object)
|
|
468
|
+
], exports.HDropdown.prototype, "preventFocusTrap", void 0);
|
|
392
469
|
exports.HDropdown = HDropdown_1 = tslib_es6.__decorate([
|
|
393
470
|
phoenix_custom_element.phoenixCustomElement('h-dropdown'),
|
|
394
471
|
tslib_es6.__metadata("design:paramtypes", [])
|
|
@@ -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;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;"}
|
|
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;"}
|
|
@@ -13,6 +13,10 @@ exports.HDropdownClose = class HDropdownClose extends phoenix_light_lit_element.
|
|
|
13
13
|
constructor() {
|
|
14
14
|
super();
|
|
15
15
|
this.name = '';
|
|
16
|
+
this._closeDropdown = () => {
|
|
17
|
+
const dropdown = document.querySelector(`h-dropdown[name="${this.name}"]`);
|
|
18
|
+
dropdown === null || dropdown === void 0 ? void 0 : dropdown.hide();
|
|
19
|
+
};
|
|
16
20
|
this.className = `${dropdown_constants.DROPDOWN_CSS_CLASSES.close} ${this.className}`;
|
|
17
21
|
}
|
|
18
22
|
connectedCallback() {
|
|
@@ -20,10 +24,6 @@ exports.HDropdownClose = class HDropdownClose extends phoenix_light_lit_element.
|
|
|
20
24
|
this._btnController = new btn_controller.BtnController(this, this._closeDropdown);
|
|
21
25
|
this.addEventListener('click', this._closeDropdown);
|
|
22
26
|
}
|
|
23
|
-
async _closeDropdown() {
|
|
24
|
-
const dropdown = document.querySelector(`h-dropdown[name="${this.name}"]`);
|
|
25
|
-
await (dropdown === null || dropdown === void 0 ? void 0 : dropdown.hide());
|
|
26
|
-
}
|
|
27
27
|
};
|
|
28
28
|
tslib_es6.__decorate([
|
|
29
29
|
decorators.property({ type: String }),
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
|
|
6
|
-
var lit = require('lit');
|
|
7
6
|
var decorators = require('lit/decorators');
|
|
7
|
+
var utilities = require('@dreamcommerce/utilities');
|
|
8
8
|
var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
|
|
9
9
|
var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
|
|
10
10
|
var dropdown_constants = require('./dropdown_constants.js');
|
|
@@ -13,19 +13,22 @@ exports.HDropdownContent = class HDropdownContent extends phoenix_light_lit_elem
|
|
|
13
13
|
constructor() {
|
|
14
14
|
super();
|
|
15
15
|
this.name = '';
|
|
16
|
+
this._setupRole = () => {
|
|
17
|
+
const $focusableElements = utilities.UiDomUtils.getFocusableElements(this);
|
|
18
|
+
const role = $focusableElements.length < 2 ? 'dialog' : 'menu';
|
|
19
|
+
this.setAttribute('role', role);
|
|
20
|
+
if (role === 'menu') {
|
|
21
|
+
Array.from(this.children).forEach((element) => {
|
|
22
|
+
element.setAttribute('role', 'menuitem');
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
16
26
|
this.slot = this.hasAttribute('slot') ? this.slot : 'content';
|
|
17
27
|
}
|
|
18
28
|
connectedCallback() {
|
|
19
29
|
super.connectedCallback();
|
|
20
30
|
this.classList.add(dropdown_constants.DROPDOWN_CSS_CLASSES.content);
|
|
21
|
-
this.
|
|
22
|
-
Array.from(this.children).forEach((element) => {
|
|
23
|
-
element.setAttribute('role', 'menuitem');
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
render() {
|
|
27
|
-
super.render();
|
|
28
|
-
return lit.html ` <div role="dialog">${this.getSlot('content')}</div> `;
|
|
31
|
+
this._setupRole();
|
|
29
32
|
}
|
|
30
33
|
};
|
|
31
34
|
tslib_es6.__decorate([
|
|
@@ -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;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,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|