@shoper/phoenix_design_system 1.15.5 → 1.15.6
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/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/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/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/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;"}
|
|
@@ -6,7 +6,6 @@ var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
|
|
|
6
6
|
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
|
-
var keystrokes_controller = require('../../controllers/keystrokes_controller/keystrokes_controller.js');
|
|
10
9
|
var portal_constants = require('../portal/portal_constants.js');
|
|
11
10
|
var click_outside_controller = require('../../controllers/click_outside_controller/click_outside_controller.js');
|
|
12
11
|
var relative_position_controller = require('../../controllers/relative_position_controller/relative_position_controller.js');
|
|
@@ -19,11 +18,15 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
19
18
|
this.portalTarget = base_message_constants.DEFAULT_MESSAGE_PORTAL_NAME;
|
|
20
19
|
this.direction = utilities.DIRECTIONS.topCenter;
|
|
21
20
|
this.offset = base_message_constants.DEFAULT_MESSAGE_OFFSET;
|
|
21
|
+
this.mouseonly = false;
|
|
22
|
+
this.tabindex = '-1';
|
|
22
23
|
this._setupEventListeners = () => {
|
|
23
24
|
this.addEventListener('mouseenter', this.open);
|
|
24
25
|
this.addEventListener('mouseleave', this.close);
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
if (!this.mouseonly) {
|
|
27
|
+
this.addEventListener('focusin', this.open);
|
|
28
|
+
this.addEventListener('focusout', this.close);
|
|
29
|
+
}
|
|
27
30
|
};
|
|
28
31
|
this._positionMessage = () => {
|
|
29
32
|
requestAnimationFrame(() => {
|
|
@@ -59,49 +62,11 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
59
62
|
});
|
|
60
63
|
}, this._shouldDelayClosing ? base_message_constants.MESSAGE_CLOSE_DELAY_IN_MS : 0);
|
|
61
64
|
};
|
|
62
|
-
this._handleFocusWithinMessage = (ev) => {
|
|
63
|
-
var _a;
|
|
64
|
-
if (((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.closest(`.${this._messageComponentName}`)) !== this)
|
|
65
|
-
this.close();
|
|
66
|
-
if (!document.activeElement || ev.shiftKey)
|
|
67
|
-
return;
|
|
68
|
-
const $focusableElements = utilities.UiDomUtils.getFocusableElements(this);
|
|
69
|
-
const activeElementIndex = $focusableElements.indexOf(document.activeElement);
|
|
70
|
-
const isLastFocusableChild = activeElementIndex === $focusableElements.length - 1;
|
|
71
|
-
if (!isLastFocusableChild)
|
|
72
|
-
return;
|
|
73
|
-
this.close();
|
|
74
|
-
};
|
|
75
|
-
this._handleReverseTab = () => {
|
|
76
|
-
const $focusableElements = utilities.UiDomUtils.getFocusableElements(document.body);
|
|
77
|
-
const activeElement = document.activeElement;
|
|
78
|
-
const indexOfCurrentlyFocusedElement = $focusableElements.indexOf(activeElement);
|
|
79
|
-
const $previousElement = $focusableElements[indexOfCurrentlyFocusedElement - 1];
|
|
80
|
-
const $previousElementMessageParent = $previousElement === null || $previousElement === void 0 ? void 0 : $previousElement.closest(`h-${this._messageComponentName}`);
|
|
81
|
-
if ($previousElementMessageParent === this)
|
|
82
|
-
return;
|
|
83
|
-
if ($previousElementMessageParent)
|
|
84
|
-
$previousElementMessageParent.open();
|
|
85
|
-
if (this._isBaseMessage(activeElement))
|
|
86
|
-
activeElement.close();
|
|
87
|
-
};
|
|
88
65
|
this._clickOutsideController = new click_outside_controller.ClickOutsideController({
|
|
89
66
|
host: this,
|
|
90
67
|
container: this,
|
|
91
68
|
action: this.close
|
|
92
69
|
});
|
|
93
|
-
new keystrokes_controller.KeystrokesController({
|
|
94
|
-
host: this,
|
|
95
|
-
keys: ['tab'],
|
|
96
|
-
target: this,
|
|
97
|
-
callback: this._handleFocusWithinMessage
|
|
98
|
-
});
|
|
99
|
-
new keystrokes_controller.KeystrokesController({
|
|
100
|
-
host: this,
|
|
101
|
-
keys: [['shift', 'tab']],
|
|
102
|
-
target: document.body,
|
|
103
|
-
callback: this._handleReverseTab
|
|
104
|
-
});
|
|
105
70
|
}
|
|
106
71
|
connectedCallback(messageComponentName = '') {
|
|
107
72
|
super.connectedCallback();
|
|
@@ -117,6 +82,7 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
117
82
|
elementToPosition: this._$messageContent,
|
|
118
83
|
offset: this.offset
|
|
119
84
|
});
|
|
85
|
+
this.setAttribute('tabindex', this.tabindex);
|
|
120
86
|
this._setupEventListeners();
|
|
121
87
|
}
|
|
122
88
|
static _appendMessagePortal() {
|
|
@@ -127,11 +93,6 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
127
93
|
$portalTarget.setAttribute(portal_constants.PORTAL_TARGET_NAME_PROP, base_message_constants.DEFAULT_MESSAGE_PORTAL_NAME);
|
|
128
94
|
document.body.appendChild($portalTarget);
|
|
129
95
|
}
|
|
130
|
-
_isBaseMessage($element) {
|
|
131
|
-
if (base_message_constants.MESSAGE_ELEMENTS.includes($element.localName))
|
|
132
|
-
return true;
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
96
|
}
|
|
136
97
|
tslib_es6.__decorate([
|
|
137
98
|
decorators.property({ type: Boolean, reflect: true }),
|
|
@@ -148,7 +109,15 @@ tslib_es6.__decorate([
|
|
|
148
109
|
tslib_es6.__decorate([
|
|
149
110
|
decorators.property({ type: String }),
|
|
150
111
|
tslib_es6.__metadata("design:type", Number)
|
|
151
|
-
], BaseMessage.prototype, "offset", void 0);
|
|
112
|
+
], BaseMessage.prototype, "offset", void 0);
|
|
113
|
+
tslib_es6.__decorate([
|
|
114
|
+
decorators.property({ type: Boolean }),
|
|
115
|
+
tslib_es6.__metadata("design:type", Boolean)
|
|
116
|
+
], BaseMessage.prototype, "mouseonly", void 0);
|
|
117
|
+
tslib_es6.__decorate([
|
|
118
|
+
decorators.property({ type: String }),
|
|
119
|
+
tslib_es6.__metadata("design:type", String)
|
|
120
|
+
], BaseMessage.prototype, "tabindex", void 0);
|
|
152
121
|
|
|
153
122
|
exports.BaseMessage = BaseMessage;
|
|
154
123
|
//# sourceMappingURL=base_message.js.map
|
|
@@ -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;
|
|
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;"}
|
|
@@ -9,7 +9,6 @@ const DEFAULT_MESSAGE_PORTAL_NAME = 'message-portal';
|
|
|
9
9
|
const MESSAGE_CONTENT_SLOT_NAME = 'message-content';
|
|
10
10
|
const MESSAGE_REMOVED_CLASS_NAME = `removed`;
|
|
11
11
|
const DEFAULT_MESSAGE_OFFSET = 10;
|
|
12
|
-
const MESSAGE_ELEMENTS = [tooltip_constants.TOOLTIP_ELEMENT_NAME, hint_constants.HINT_ELEMENT_NAME];
|
|
13
12
|
const MESSAGE_CONTENT_ELEMENTS = [tooltip_constants.TOOLTIP_CONTENT_ELEMENT_NAME, hint_constants.HINT_CONTENT_ELEMENT_NAME];
|
|
14
13
|
const MESSAGE_SHOW_DELAY_IN_MS = 100;
|
|
15
14
|
const MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = 500;
|
|
@@ -20,7 +19,6 @@ exports.DEFAULT_MESSAGE_PORTAL_NAME = DEFAULT_MESSAGE_PORTAL_NAME;
|
|
|
20
19
|
exports.MESSAGE_CLOSE_DELAY_IN_MS = MESSAGE_CLOSE_DELAY_IN_MS;
|
|
21
20
|
exports.MESSAGE_CONTENT_ELEMENTS = MESSAGE_CONTENT_ELEMENTS;
|
|
22
21
|
exports.MESSAGE_CONTENT_SLOT_NAME = MESSAGE_CONTENT_SLOT_NAME;
|
|
23
|
-
exports.MESSAGE_ELEMENTS = MESSAGE_ELEMENTS;
|
|
24
22
|
exports.MESSAGE_REMOVED_CLASS_NAME = MESSAGE_REMOVED_CLASS_NAME;
|
|
25
23
|
exports.MESSAGE_SHOW_DELAY_IN_MS = MESSAGE_SHOW_DELAY_IN_MS;
|
|
26
24
|
exports.MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS;
|
|
@@ -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;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;AACA;AACA;AACA;"}
|
|
@@ -76,8 +76,8 @@ var toggle_button = require('./components/groups/toggle_button_group/toggle_butt
|
|
|
76
76
|
var click_outside_controller_messages = require('./controllers/click_outside_controller/click_outside_controller_messages.js');
|
|
77
77
|
var backdrop = require('./components/backdrop/backdrop.js');
|
|
78
78
|
var color_swatches_control_constants = require('./components/form/color_swatches_control/color_swatches_control_constants.js');
|
|
79
|
-
var color_item = require('./components/color_swatches/color_item/color_item.js');
|
|
80
79
|
var color_swatches = require('./components/color_swatches/color_swatches.js');
|
|
80
|
+
var color_item = require('./components/color_swatches/color_item/color_item.js');
|
|
81
81
|
var color_swatches_control = require('./components/form/color_swatches_control/color_swatches_control.js');
|
|
82
82
|
var show_more = require('./components/color_swatches/show-more/show_more.js');
|
|
83
83
|
var visibility_controller = require('./controllers/visibility_controller/visibility_controller.js');
|
|
@@ -464,16 +464,16 @@ Object.defineProperty(exports, 'HBackdrop', {
|
|
|
464
464
|
}
|
|
465
465
|
});
|
|
466
466
|
exports.COLOR_SWATCHES_CONTROL_EVENT_NAMES = color_swatches_control_constants.COLOR_SWATCHES_CONTROL_EVENT_NAMES;
|
|
467
|
-
Object.defineProperty(exports, '
|
|
467
|
+
Object.defineProperty(exports, 'HColorSwatches', {
|
|
468
468
|
enumerable: true,
|
|
469
469
|
get: function () {
|
|
470
|
-
return
|
|
470
|
+
return color_swatches.HColorSwatches;
|
|
471
471
|
}
|
|
472
472
|
});
|
|
473
|
-
Object.defineProperty(exports, '
|
|
473
|
+
Object.defineProperty(exports, 'HColorItem', {
|
|
474
474
|
enumerable: true,
|
|
475
475
|
get: function () {
|
|
476
|
-
return
|
|
476
|
+
return color_item.HColorItem;
|
|
477
477
|
}
|
|
478
478
|
});
|
|
479
479
|
Object.defineProperty(exports, 'HColorSwatchesControl', {
|
|
@@ -8,12 +8,9 @@ export declare class HColorItem extends PhoenixLightLitElement {
|
|
|
8
8
|
selected: boolean;
|
|
9
9
|
size?: TColorItemSize;
|
|
10
10
|
unclickable: boolean;
|
|
11
|
-
private
|
|
12
|
-
constructor();
|
|
11
|
+
private _$colorSwatches;
|
|
13
12
|
connectedCallback(): void;
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
private setupEvents;
|
|
13
|
+
private _setupAriaAttributes;
|
|
14
|
+
private _setupClasses;
|
|
17
15
|
private setBgColor;
|
|
18
|
-
private _dispatchClickedEvent;
|
|
19
16
|
}
|
|
@@ -3,47 +3,40 @@ import { property } from 'lit/decorators';
|
|
|
3
3
|
import { ColorUtils } from '@dreamcommerce/utilities';
|
|
4
4
|
import { PhoenixLightLitElement } from '../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
|
|
5
5
|
import { phoenixCustomElement } from '../../../core/decorators/phoenix_custom_element.js';
|
|
6
|
-
import {
|
|
7
|
-
import { COLOR_ITEM_EVENT_NAMES, COLOR_ITEM_CSS_CLASSES, COLOR_ITEM_SELECTED_ATTRIBUTE } from './color_item_constants.js';
|
|
6
|
+
import { COLOR_ITEM_CSS_CLASSES } from './color_item_constants.js';
|
|
8
7
|
|
|
9
8
|
let HColorItem = class HColorItem extends PhoenixLightLitElement {
|
|
10
9
|
constructor() {
|
|
11
|
-
super();
|
|
10
|
+
super(...arguments);
|
|
12
11
|
this.disabled = false;
|
|
13
12
|
this.selected = false;
|
|
14
13
|
this.unclickable = false;
|
|
15
|
-
this.
|
|
16
|
-
|
|
14
|
+
this._$colorSwatches = null;
|
|
15
|
+
this._setupAriaAttributes = () => {
|
|
16
|
+
var _a;
|
|
17
|
+
this._$colorSwatches = this.closest('h-color-swatches');
|
|
18
|
+
this.setAttribute('role', ((_a = this._$colorSwatches) === null || _a === void 0 ? void 0 : _a.multiple) ? 'checkbox' : 'radio');
|
|
19
|
+
this.setAttribute('aria-label', this.label ? this.label : this.color);
|
|
20
|
+
};
|
|
21
|
+
this._setupClasses = () => {
|
|
22
|
+
this.classList.add(COLOR_ITEM_CSS_CLASSES.colorItem);
|
|
23
|
+
if (this.size)
|
|
24
|
+
this.classList.add(COLOR_ITEM_CSS_CLASSES[this.size]);
|
|
17
25
|
};
|
|
18
|
-
this._btnController = new BtnController(this, this._dispatchClickedEvent);
|
|
19
26
|
}
|
|
20
27
|
connectedCallback() {
|
|
21
28
|
super.connectedCallback();
|
|
22
|
-
this.
|
|
29
|
+
this._setupAriaAttributes();
|
|
30
|
+
this._setupClasses();
|
|
23
31
|
this.style.backgroundColor = this.setBgColor(this.disabled);
|
|
24
|
-
this.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
if (this.unclickable) {
|
|
33
|
+
this.removeAttribute('tabindex');
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.setAttribute('tabindex', '0');
|
|
37
|
+
}
|
|
28
38
|
if (!this.value)
|
|
29
39
|
this.value = this.color;
|
|
30
|
-
if (this.size)
|
|
31
|
-
this.classList.add(COLOR_ITEM_CSS_CLASSES[this.size]);
|
|
32
|
-
}
|
|
33
|
-
attributeChangedCallback(name, value, newValue) {
|
|
34
|
-
super.attributeChangedCallback(name, value, newValue);
|
|
35
|
-
switch (name) {
|
|
36
|
-
case COLOR_ITEM_SELECTED_ATTRIBUTE: {
|
|
37
|
-
this._syncAriaPressed();
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
_syncAriaPressed() {
|
|
43
|
-
this.selected ? this.setAttribute('aria-pressed', '') : this.removeAttribute('aria-pressed');
|
|
44
|
-
}
|
|
45
|
-
setupEvents() {
|
|
46
|
-
!this.unclickable && this.addEventListener('click', this._dispatchClickedEvent);
|
|
47
40
|
}
|
|
48
41
|
setBgColor(itemIsDisabled) {
|
|
49
42
|
return itemIsDisabled ? ColorUtils.hexToRgba(this.color, 0.5) : this.color;
|
|
@@ -78,8 +71,7 @@ __decorate([
|
|
|
78
71
|
__metadata("design:type", Boolean)
|
|
79
72
|
], HColorItem.prototype, "unclickable", void 0);
|
|
80
73
|
HColorItem = __decorate([
|
|
81
|
-
phoenixCustomElement('h-color-item')
|
|
82
|
-
__metadata("design:paramtypes", [])
|
|
74
|
+
phoenixCustomElement('h-color-item')
|
|
83
75
|
], HColorItem);
|
|
84
76
|
|
|
85
77
|
export { HColorItem };
|
package/build/esm/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,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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/esm/packages/phoenix/src/components/color_swatches/color_item/color_item_constants.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
const colorItemBaseCssClass = 'color-item';
|
|
2
|
-
const COLOR_ITEM_EVENT_NAMES = {
|
|
3
|
-
selected: 'colorItemSelected'
|
|
4
|
-
};
|
|
5
2
|
const COLOR_ITEM_SIZES = {
|
|
6
3
|
s: 's',
|
|
7
4
|
xs: 'xs'
|
|
@@ -13,5 +10,5 @@ const COLOR_ITEM_CSS_CLASSES = {
|
|
|
13
10
|
};
|
|
14
11
|
const COLOR_ITEM_SELECTED_ATTRIBUTE = 'selected';
|
|
15
12
|
|
|
16
|
-
export { COLOR_ITEM_CSS_CLASSES,
|
|
13
|
+
export { COLOR_ITEM_CSS_CLASSES, COLOR_ITEM_SELECTED_ATTRIBUTE, COLOR_ITEM_SIZES };
|
|
17
14
|
//# 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;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -15,13 +15,23 @@ export declare class HColorSwatches extends PhoenixLightLitElement {
|
|
|
15
15
|
private _hideItems;
|
|
16
16
|
private _showAllItemsEvent;
|
|
17
17
|
private _setupEvents;
|
|
18
|
+
private _setupCheckboxGroupEvents;
|
|
19
|
+
private _setupRadioGroupEvents;
|
|
20
|
+
private _setupColorClickEvents;
|
|
18
21
|
private _handleColorClicked;
|
|
22
|
+
private _handleTabNavigation;
|
|
23
|
+
private _handleRadioNavigation;
|
|
24
|
+
private _focusOnSelectedColor;
|
|
25
|
+
private _handleChangeToNextColorItem;
|
|
26
|
+
private _handleChangeToPreviousColorItem;
|
|
27
|
+
private _handleColorChange;
|
|
19
28
|
private _toggleColorItem;
|
|
20
29
|
private _handleColorClickedForMultipleMode;
|
|
21
|
-
private
|
|
30
|
+
private _handleColorChangeForSingleMode;
|
|
22
31
|
private _toggleSelectedAttribute;
|
|
23
32
|
private _isColorAlreadyExistInArray;
|
|
24
33
|
private _removeExistingColorFromArray;
|
|
25
34
|
private _dispatchColorChangeEvent;
|
|
35
|
+
disconnectedCallback(): void;
|
|
26
36
|
protected render(): TemplateResult;
|
|
27
37
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
|
|
2
2
|
import { html, nothing } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators';
|
|
4
|
-
import { ArrayUtils } from '@dreamcommerce/utilities';
|
|
4
|
+
import { UiDomUtils, ArrayUtils } from '@dreamcommerce/utilities';
|
|
5
5
|
import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
|
|
6
6
|
import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
|
|
7
|
+
import { KeystrokesController } from '../../controllers/keystrokes_controller/keystrokes_controller.js';
|
|
7
8
|
import 'lit-html';
|
|
8
|
-
import { COLOR_SWATCHES_EVENT_NAMES, COLOR_ITEM_TAG_NAME, COLOR_SWATCHES_CSS_CLASSES,
|
|
9
|
-
import {
|
|
9
|
+
import { COLOR_SWATCHES_EVENT_NAMES, COLOR_ITEM_TAG_NAME, COLOR_SWATCHES_CSS_CLASSES, COLOR_SWATCHES_HIDDEN_ATTRIBUTE } from './color_swatches_constants.js';
|
|
10
|
+
import { COLOR_ITEM_SELECTED_ATTRIBUTE } from './color_item/color_item_constants.js';
|
|
10
11
|
|
|
11
12
|
let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
|
|
12
13
|
constructor() {
|
|
@@ -14,8 +15,87 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
|
|
|
14
15
|
this.multiple = false;
|
|
15
16
|
this.selectedColors = [];
|
|
16
17
|
this.showMoreBtnText = 'Pokaż wszystkie kolory';
|
|
17
|
-
this.
|
|
18
|
-
|
|
18
|
+
this._setupEvents = () => {
|
|
19
|
+
if (this.getAttribute('role') === 'group') {
|
|
20
|
+
this._setupCheckboxGroupEvents();
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this._setupRadioGroupEvents();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
this._setupCheckboxGroupEvents = () => {
|
|
27
|
+
this._setupColorClickEvents();
|
|
28
|
+
};
|
|
29
|
+
this._setupRadioGroupEvents = () => {
|
|
30
|
+
document.body.addEventListener('keydown', this._focusOnSelectedColor);
|
|
31
|
+
this.addEventListener('keydown', this._handleTabNavigation);
|
|
32
|
+
this.addEventListener('keyup', this._handleRadioNavigation);
|
|
33
|
+
this._setupColorClickEvents();
|
|
34
|
+
};
|
|
35
|
+
this._setupColorClickEvents = () => {
|
|
36
|
+
if (!this._$colorSwatchesChildren)
|
|
37
|
+
return;
|
|
38
|
+
this._$colorSwatchesChildren.forEach(($colorItem) => {
|
|
39
|
+
$colorItem.addEventListener('click', this._handleColorClicked);
|
|
40
|
+
new KeystrokesController({
|
|
41
|
+
host: this,
|
|
42
|
+
keys: [' '],
|
|
43
|
+
callback: this._handleColorClicked,
|
|
44
|
+
target: $colorItem
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
this._handleColorClicked = (ev) => {
|
|
49
|
+
ev.preventDefault();
|
|
50
|
+
const $colorItem = ev.target;
|
|
51
|
+
if ($colorItem.unclickable)
|
|
52
|
+
return;
|
|
53
|
+
this._toggleColorItem($colorItem);
|
|
54
|
+
this._dispatchColorChangeEvent($colorItem);
|
|
55
|
+
};
|
|
56
|
+
this._handleTabNavigation = (ev) => {
|
|
57
|
+
if (ev.key !== 'Tab')
|
|
58
|
+
return;
|
|
59
|
+
ev.preventDefault();
|
|
60
|
+
if (ev.shiftKey) {
|
|
61
|
+
const $firstFocusableColor = UiDomUtils.getFocusableElement(this);
|
|
62
|
+
UiDomUtils.getPreviousFocusableElement($firstFocusableColor).focus();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const $LastFocusableColor = UiDomUtils.getLastFocusableElement(this);
|
|
66
|
+
UiDomUtils.getNextFocusableElement($LastFocusableColor).focus();
|
|
67
|
+
};
|
|
68
|
+
this._handleRadioNavigation = (ev) => {
|
|
69
|
+
const changeToNextKeys = ['ArrowDown', 'ArrowRight'];
|
|
70
|
+
const changeToPreviousKeys = ['ArrowUp', 'ArrowLeft'];
|
|
71
|
+
if (!changeToNextKeys.includes(ev.key) && !changeToPreviousKeys.includes(ev.key))
|
|
72
|
+
return;
|
|
73
|
+
ev.preventDefault();
|
|
74
|
+
if (changeToNextKeys.includes(ev.key)) {
|
|
75
|
+
this._handleChangeToNextColorItem(ev);
|
|
76
|
+
}
|
|
77
|
+
if (changeToPreviousKeys.includes(ev.key)) {
|
|
78
|
+
this._handleChangeToPreviousColorItem(ev);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
this._focusOnSelectedColor = (ev) => {
|
|
82
|
+
if (ev.key !== 'Tab' || this.multiple)
|
|
83
|
+
return;
|
|
84
|
+
if (ev.shiftKey) {
|
|
85
|
+
const $previousFocusableElement = UiDomUtils.getPreviousFocusableElement(document.activeElement);
|
|
86
|
+
if (this.contains($previousFocusableElement) && this.selectedColors.length > 0) {
|
|
87
|
+
ev.preventDefault();
|
|
88
|
+
this.selectedColors[0].focus();
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const $nextFocusableElement = UiDomUtils.getNextFocusableElement(document.activeElement);
|
|
93
|
+
if (this.contains($nextFocusableElement) && this.selectedColors.length > 0) {
|
|
94
|
+
ev.preventDefault();
|
|
95
|
+
this.selectedColors[0].focus();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
this._handleColorChange = ($colorItem) => {
|
|
19
99
|
this._toggleColorItem($colorItem);
|
|
20
100
|
this._dispatchColorChangeEvent($colorItem);
|
|
21
101
|
};
|
|
@@ -52,6 +132,8 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
|
|
|
52
132
|
}
|
|
53
133
|
connectedCallback() {
|
|
54
134
|
super.connectedCallback();
|
|
135
|
+
this.setAttribute('role', this.multiple ? 'group' : 'radiogroup');
|
|
136
|
+
this._$colorSwatchesChildren = [...this.children];
|
|
55
137
|
this._setupEvents();
|
|
56
138
|
this._addCssClasses();
|
|
57
139
|
this.numberOfVisibleColors && this._hideItems(this.numberOfVisibleColors);
|
|
@@ -64,11 +146,9 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
|
|
|
64
146
|
this.classList.add(COLOR_SWATCHES_CSS_CLASSES.colorSwatches);
|
|
65
147
|
}
|
|
66
148
|
_hideItems(numberOfVisibleColors) {
|
|
67
|
-
var _a;
|
|
68
|
-
this._$colorSwatchesChildren = (_a = document.querySelector(COLOR_SWATCHES_TAG_NAME)) === null || _a === void 0 ? void 0 : _a.children;
|
|
69
149
|
if (!this._$colorSwatchesChildren)
|
|
70
150
|
return;
|
|
71
|
-
|
|
151
|
+
this._$colorSwatchesChildren.forEach(($colorSwatchesChild, index) => {
|
|
72
152
|
if (index > numberOfVisibleColors - 1) {
|
|
73
153
|
$colorSwatchesChild.setAttribute(COLOR_SWATCHES_HIDDEN_ATTRIBUTE, '');
|
|
74
154
|
}
|
|
@@ -79,17 +159,40 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
|
|
|
79
159
|
var _a;
|
|
80
160
|
if (!this._$colorSwatchesChildren)
|
|
81
161
|
return;
|
|
82
|
-
|
|
162
|
+
this._$colorSwatchesChildren.forEach(($colorSwatchesChild) => {
|
|
83
163
|
$colorSwatchesChild.removeAttribute(COLOR_SWATCHES_HIDDEN_ATTRIBUTE);
|
|
84
164
|
});
|
|
85
165
|
(_a = this.querySelector('h-color-swatches-show-more')) === null || _a === void 0 ? void 0 : _a.setAttribute(COLOR_SWATCHES_HIDDEN_ATTRIBUTE, '');
|
|
86
166
|
});
|
|
87
167
|
}
|
|
88
|
-
|
|
89
|
-
|
|
168
|
+
_handleChangeToNextColorItem({ target }) {
|
|
169
|
+
const $colorItem = target;
|
|
170
|
+
const $nextFocusableElement = UiDomUtils.getNextFocusableElement($colorItem);
|
|
171
|
+
let $nextColorItem;
|
|
172
|
+
if (!this.contains($nextFocusableElement)) {
|
|
173
|
+
$nextColorItem = UiDomUtils.getFocusableElement(this);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
$nextColorItem = $nextFocusableElement;
|
|
177
|
+
}
|
|
178
|
+
$nextColorItem.focus();
|
|
179
|
+
this._handleColorChange($nextColorItem);
|
|
180
|
+
}
|
|
181
|
+
_handleChangeToPreviousColorItem({ target }) {
|
|
182
|
+
const $colorItem = target;
|
|
183
|
+
const $previousFocusableElement = UiDomUtils.getPreviousFocusableElement($colorItem);
|
|
184
|
+
let $previousColorItem;
|
|
185
|
+
if (!this.contains($previousFocusableElement)) {
|
|
186
|
+
$previousColorItem = UiDomUtils.getLastFocusableElement(this);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
$previousColorItem = $previousFocusableElement;
|
|
190
|
+
}
|
|
191
|
+
$previousColorItem.focus();
|
|
192
|
+
this._handleColorChange($previousColorItem);
|
|
90
193
|
}
|
|
91
194
|
_toggleColorItem($colorItem) {
|
|
92
|
-
this.multiple ? this._handleColorClickedForMultipleMode($colorItem) : this.
|
|
195
|
+
this.multiple ? this._handleColorClickedForMultipleMode($colorItem) : this._handleColorChangeForSingleMode($colorItem);
|
|
93
196
|
}
|
|
94
197
|
_handleColorClickedForMultipleMode($colorItem) {
|
|
95
198
|
!this._isColorAlreadyExistInArray($colorItem)
|
|
@@ -97,17 +200,20 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
|
|
|
97
200
|
: this._removeExistingColorFromArray($colorItem);
|
|
98
201
|
this._toggleSelectedAttribute($colorItem);
|
|
99
202
|
}
|
|
100
|
-
|
|
203
|
+
_handleColorChangeForSingleMode($colorItem) {
|
|
101
204
|
const $previouslySelected = this.selectedColors[0];
|
|
102
205
|
this._toggleSelectedAttribute($colorItem);
|
|
103
|
-
if ($previouslySelected && $previouslySelected !== $colorItem)
|
|
206
|
+
if ($previouslySelected && $previouslySelected !== $colorItem) {
|
|
104
207
|
$previouslySelected.removeAttribute(COLOR_ITEM_SELECTED_ATTRIBUTE);
|
|
208
|
+
$previouslySelected.setAttribute('aria-checked', 'false');
|
|
209
|
+
}
|
|
105
210
|
this.selectedColors = $previouslySelected === $colorItem ? [] : [$colorItem];
|
|
106
211
|
}
|
|
107
212
|
_toggleSelectedAttribute($colorItem) {
|
|
108
213
|
$colorItem.hasAttribute(COLOR_ITEM_SELECTED_ATTRIBUTE)
|
|
109
214
|
? $colorItem.removeAttribute(COLOR_ITEM_SELECTED_ATTRIBUTE)
|
|
110
215
|
: $colorItem.setAttribute(COLOR_ITEM_SELECTED_ATTRIBUTE, '');
|
|
216
|
+
$colorItem.setAttribute('aria-checked', 'true');
|
|
111
217
|
}
|
|
112
218
|
_isColorAlreadyExistInArray($colorItem) {
|
|
113
219
|
return this.selectedColors.includes($colorItem);
|
|
@@ -116,6 +222,10 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
|
|
|
116
222
|
const indexOfAlreadyExistingColor = this.selectedColors.indexOf($colorItem);
|
|
117
223
|
this.selectedColors.splice(indexOfAlreadyExistingColor, 1);
|
|
118
224
|
}
|
|
225
|
+
disconnectedCallback() {
|
|
226
|
+
super.disconnectedCallback();
|
|
227
|
+
document.body.removeEventListener('keydown', this._focusOnSelectedColor);
|
|
228
|
+
}
|
|
119
229
|
render() {
|
|
120
230
|
return html `
|
|
121
231
|
${this.getSlot('default')}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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/esm/packages/phoenix/src/components/color_swatches/color_swatches_constants.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const colorSwatchesBaseCssClass = 'color-swatches';
|
|
2
|
-
const COLOR_SWATCHES_TAG_NAME = 'h-color-swatches';
|
|
3
2
|
const COLOR_ITEM_TAG_NAME = 'h-color-item';
|
|
4
3
|
const COLOR_SWATCHES_CSS_CLASSES = {
|
|
5
4
|
colorSwatches: colorSwatchesBaseCssClass,
|
|
@@ -12,5 +11,5 @@ const COLOR_SWATCHES_EVENT_NAMES = {
|
|
|
12
11
|
};
|
|
13
12
|
const COLOR_SWATCHES_HIDDEN_ATTRIBUTE = 'hidden';
|
|
14
13
|
|
|
15
|
-
export { COLOR_ITEM_TAG_NAME, COLOR_SWATCHES_CSS_CLASSES, COLOR_SWATCHES_EVENT_NAMES, COLOR_SWATCHES_HIDDEN_ATTRIBUTE
|
|
14
|
+
export { COLOR_ITEM_TAG_NAME, COLOR_SWATCHES_CSS_CLASSES, COLOR_SWATCHES_EVENT_NAMES, COLOR_SWATCHES_HIDDEN_ATTRIBUTE };
|
|
16
15
|
//# sourceMappingURL=color_swatches_constants.js.map
|
package/build/esm/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;
|
|
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;"}
|
|
@@ -6,6 +6,8 @@ export declare class BaseMessage extends PhoenixLightLitElement implements IBase
|
|
|
6
6
|
portalTarget: string;
|
|
7
7
|
direction: TDirection;
|
|
8
8
|
offset: number;
|
|
9
|
+
mouseonly: boolean;
|
|
10
|
+
tabindex: string;
|
|
9
11
|
private _positionController;
|
|
10
12
|
private _clickOutsideController;
|
|
11
13
|
private _$messageContent;
|
|
@@ -21,7 +23,4 @@ export declare class BaseMessage extends PhoenixLightLitElement implements IBase
|
|
|
21
23
|
protected _positionMessage: () => void;
|
|
22
24
|
open: () => void;
|
|
23
25
|
close: () => void;
|
|
24
|
-
private _handleFocusWithinMessage;
|
|
25
|
-
private _handleReverseTab;
|
|
26
|
-
private _isBaseMessage;
|
|
27
26
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
|
|
2
2
|
import { property } from 'lit/decorators';
|
|
3
|
-
import { DIRECTIONS
|
|
3
|
+
import { DIRECTIONS } from '@dreamcommerce/utilities';
|
|
4
4
|
import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
|
|
5
|
-
import { KeystrokesController } from '../../controllers/keystrokes_controller/keystrokes_controller.js';
|
|
6
5
|
import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP, PORTAL_TARGET_ATTRIBUTE_NAME } from '../portal/portal_constants.js';
|
|
7
6
|
import { ClickOutsideController } from '../../controllers/click_outside_controller/click_outside_controller.js';
|
|
8
7
|
import { RelativePositionController } from '../../controllers/relative_position_controller/relative_position_controller.js';
|
|
9
|
-
import { DEFAULT_MESSAGE_PORTAL_NAME, DEFAULT_MESSAGE_OFFSET, MESSAGE_SHOW_DELAY_IN_MS, MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS, MESSAGE_REMOVED_CLASS_NAME, MESSAGE_CLOSE_DELAY_IN_MS, MESSAGE_CONTENT_ELEMENTS
|
|
8
|
+
import { DEFAULT_MESSAGE_PORTAL_NAME, DEFAULT_MESSAGE_OFFSET, MESSAGE_SHOW_DELAY_IN_MS, MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS, MESSAGE_REMOVED_CLASS_NAME, MESSAGE_CLOSE_DELAY_IN_MS, MESSAGE_CONTENT_ELEMENTS } from './base_message_constants.js';
|
|
10
9
|
|
|
11
10
|
class BaseMessage extends PhoenixLightLitElement {
|
|
12
11
|
constructor() {
|
|
@@ -15,11 +14,15 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
15
14
|
this.portalTarget = DEFAULT_MESSAGE_PORTAL_NAME;
|
|
16
15
|
this.direction = DIRECTIONS.topCenter;
|
|
17
16
|
this.offset = DEFAULT_MESSAGE_OFFSET;
|
|
17
|
+
this.mouseonly = false;
|
|
18
|
+
this.tabindex = '-1';
|
|
18
19
|
this._setupEventListeners = () => {
|
|
19
20
|
this.addEventListener('mouseenter', this.open);
|
|
20
21
|
this.addEventListener('mouseleave', this.close);
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
if (!this.mouseonly) {
|
|
23
|
+
this.addEventListener('focusin', this.open);
|
|
24
|
+
this.addEventListener('focusout', this.close);
|
|
25
|
+
}
|
|
23
26
|
};
|
|
24
27
|
this._positionMessage = () => {
|
|
25
28
|
requestAnimationFrame(() => {
|
|
@@ -55,49 +58,11 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
55
58
|
});
|
|
56
59
|
}, this._shouldDelayClosing ? MESSAGE_CLOSE_DELAY_IN_MS : 0);
|
|
57
60
|
};
|
|
58
|
-
this._handleFocusWithinMessage = (ev) => {
|
|
59
|
-
var _a;
|
|
60
|
-
if (((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.closest(`.${this._messageComponentName}`)) !== this)
|
|
61
|
-
this.close();
|
|
62
|
-
if (!document.activeElement || ev.shiftKey)
|
|
63
|
-
return;
|
|
64
|
-
const $focusableElements = UiDomUtils.getFocusableElements(this);
|
|
65
|
-
const activeElementIndex = $focusableElements.indexOf(document.activeElement);
|
|
66
|
-
const isLastFocusableChild = activeElementIndex === $focusableElements.length - 1;
|
|
67
|
-
if (!isLastFocusableChild)
|
|
68
|
-
return;
|
|
69
|
-
this.close();
|
|
70
|
-
};
|
|
71
|
-
this._handleReverseTab = () => {
|
|
72
|
-
const $focusableElements = UiDomUtils.getFocusableElements(document.body);
|
|
73
|
-
const activeElement = document.activeElement;
|
|
74
|
-
const indexOfCurrentlyFocusedElement = $focusableElements.indexOf(activeElement);
|
|
75
|
-
const $previousElement = $focusableElements[indexOfCurrentlyFocusedElement - 1];
|
|
76
|
-
const $previousElementMessageParent = $previousElement === null || $previousElement === void 0 ? void 0 : $previousElement.closest(`h-${this._messageComponentName}`);
|
|
77
|
-
if ($previousElementMessageParent === this)
|
|
78
|
-
return;
|
|
79
|
-
if ($previousElementMessageParent)
|
|
80
|
-
$previousElementMessageParent.open();
|
|
81
|
-
if (this._isBaseMessage(activeElement))
|
|
82
|
-
activeElement.close();
|
|
83
|
-
};
|
|
84
61
|
this._clickOutsideController = new ClickOutsideController({
|
|
85
62
|
host: this,
|
|
86
63
|
container: this,
|
|
87
64
|
action: this.close
|
|
88
65
|
});
|
|
89
|
-
new KeystrokesController({
|
|
90
|
-
host: this,
|
|
91
|
-
keys: ['tab'],
|
|
92
|
-
target: this,
|
|
93
|
-
callback: this._handleFocusWithinMessage
|
|
94
|
-
});
|
|
95
|
-
new KeystrokesController({
|
|
96
|
-
host: this,
|
|
97
|
-
keys: [['shift', 'tab']],
|
|
98
|
-
target: document.body,
|
|
99
|
-
callback: this._handleReverseTab
|
|
100
|
-
});
|
|
101
66
|
}
|
|
102
67
|
connectedCallback(messageComponentName = '') {
|
|
103
68
|
super.connectedCallback();
|
|
@@ -113,6 +78,7 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
113
78
|
elementToPosition: this._$messageContent,
|
|
114
79
|
offset: this.offset
|
|
115
80
|
});
|
|
81
|
+
this.setAttribute('tabindex', this.tabindex);
|
|
116
82
|
this._setupEventListeners();
|
|
117
83
|
}
|
|
118
84
|
static _appendMessagePortal() {
|
|
@@ -123,11 +89,6 @@ class BaseMessage extends PhoenixLightLitElement {
|
|
|
123
89
|
$portalTarget.setAttribute(PORTAL_TARGET_NAME_PROP, DEFAULT_MESSAGE_PORTAL_NAME);
|
|
124
90
|
document.body.appendChild($portalTarget);
|
|
125
91
|
}
|
|
126
|
-
_isBaseMessage($element) {
|
|
127
|
-
if (MESSAGE_ELEMENTS.includes($element.localName))
|
|
128
|
-
return true;
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
92
|
}
|
|
132
93
|
__decorate([
|
|
133
94
|
property({ type: Boolean, reflect: true }),
|
|
@@ -144,7 +105,15 @@ __decorate([
|
|
|
144
105
|
__decorate([
|
|
145
106
|
property({ type: String }),
|
|
146
107
|
__metadata("design:type", Number)
|
|
147
|
-
], BaseMessage.prototype, "offset", void 0);
|
|
108
|
+
], BaseMessage.prototype, "offset", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
property({ type: Boolean }),
|
|
111
|
+
__metadata("design:type", Boolean)
|
|
112
|
+
], BaseMessage.prototype, "mouseonly", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
property({ type: String }),
|
|
115
|
+
__metadata("design:type", String)
|
|
116
|
+
], BaseMessage.prototype, "tabindex", void 0);
|
|
148
117
|
|
|
149
118
|
export { BaseMessage };
|
|
150
119
|
//# sourceMappingURL=base_message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { HINT_CONTENT_ELEMENT_NAME } from './hints/hint_constants.js';
|
|
2
|
+
import { TOOLTIP_CONTENT_ELEMENT_NAME } from './tooltips/tooltip_constants.js';
|
|
3
3
|
|
|
4
4
|
const DEFAULT_MESSAGE_PORTAL_NAME = 'message-portal';
|
|
5
5
|
const MESSAGE_CONTENT_SLOT_NAME = 'message-content';
|
|
6
6
|
const MESSAGE_REMOVED_CLASS_NAME = `removed`;
|
|
7
7
|
const DEFAULT_MESSAGE_OFFSET = 10;
|
|
8
|
-
const MESSAGE_ELEMENTS = [TOOLTIP_ELEMENT_NAME, HINT_ELEMENT_NAME];
|
|
9
8
|
const MESSAGE_CONTENT_ELEMENTS = [TOOLTIP_CONTENT_ELEMENT_NAME, HINT_CONTENT_ELEMENT_NAME];
|
|
10
9
|
const MESSAGE_SHOW_DELAY_IN_MS = 100;
|
|
11
10
|
const MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = 500;
|
|
12
11
|
const MESSAGE_CLOSE_DELAY_IN_MS = 500;
|
|
13
12
|
|
|
14
|
-
export { DEFAULT_MESSAGE_OFFSET, DEFAULT_MESSAGE_PORTAL_NAME, MESSAGE_CLOSE_DELAY_IN_MS, MESSAGE_CONTENT_ELEMENTS, MESSAGE_CONTENT_SLOT_NAME,
|
|
13
|
+
export { DEFAULT_MESSAGE_OFFSET, DEFAULT_MESSAGE_PORTAL_NAME, MESSAGE_CLOSE_DELAY_IN_MS, MESSAGE_CONTENT_ELEMENTS, MESSAGE_CONTENT_SLOT_NAME, MESSAGE_REMOVED_CLASS_NAME, MESSAGE_SHOW_DELAY_IN_MS, MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS };
|
|
15
14
|
//# sourceMappingURL=base_message_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;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -72,8 +72,8 @@ export { HToggleButton } from './components/groups/toggle_button_group/toggle_bu
|
|
|
72
72
|
export { CLICK_OUTSIDE_CONTROLLER_MESSAGES } from './controllers/click_outside_controller/click_outside_controller_messages.js';
|
|
73
73
|
export { HBackdrop } from './components/backdrop/backdrop.js';
|
|
74
74
|
export { COLOR_SWATCHES_CONTROL_EVENT_NAMES } from './components/form/color_swatches_control/color_swatches_control_constants.js';
|
|
75
|
-
export { HColorItem } from './components/color_swatches/color_item/color_item.js';
|
|
76
75
|
export { HColorSwatches } from './components/color_swatches/color_swatches.js';
|
|
76
|
+
export { HColorItem } from './components/color_swatches/color_item/color_item.js';
|
|
77
77
|
export { HColorSwatchesControl } from './components/form/color_swatches_control/color_swatches_control.js';
|
|
78
78
|
export { HColorSwatchesShowMore } from './components/color_swatches/show-more/show_more.js';
|
|
79
79
|
export { VisibilityController } from './controllers/visibility_controller/visibility_controller.js';
|