@shoper/phoenix_design_system 1.17.3-5 → 1.17.3-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.
Files changed (65) hide show
  1. package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches.js +43 -7
  2. package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches_constants.js +3 -1
  4. package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches_constants.js.map +1 -1
  5. package/build/cjs/packages/phoenix/src/components/color_swatches/show-more/show_more.js +37 -0
  6. package/build/cjs/packages/phoenix/src/components/color_swatches/show-more/show_more.js.map +1 -0
  7. package/build/cjs/packages/phoenix/src/components/color_swatches/show-more/show_more_constants.js +8 -0
  8. package/build/cjs/packages/phoenix/src/components/color_swatches/show-more/show_more_constants.js.map +1 -0
  9. package/build/cjs/packages/phoenix/src/components/messages/base_message.js +47 -0
  10. package/build/cjs/packages/phoenix/src/components/messages/base_message.js.map +1 -1
  11. package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js +6 -1
  12. package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
  13. package/build/cjs/packages/phoenix/src/components/messages/hints/hint.js +0 -10
  14. package/build/cjs/packages/phoenix/src/components/messages/hints/hint.js.map +1 -1
  15. package/build/cjs/packages/phoenix/src/components/messages/tooltips/tooltip.js +0 -10
  16. package/build/cjs/packages/phoenix/src/components/messages/tooltips/tooltip.js.map +1 -1
  17. package/build/cjs/packages/phoenix/src/components/portal/portal_constants.js +2 -0
  18. package/build/cjs/packages/phoenix/src/components/portal/portal_constants.js.map +1 -1
  19. package/build/cjs/packages/phoenix/src/index.js +7 -14
  20. package/build/cjs/packages/phoenix/src/index.js.map +1 -1
  21. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches.d.ts +6 -0
  22. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches.js +44 -8
  23. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches.js.map +1 -1
  24. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches_constants.d.ts +1 -0
  25. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches_constants.js +3 -2
  26. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches_constants.js.map +1 -1
  27. package/build/esm/packages/phoenix/src/components/color_swatches/show-more/show_more.d.ts +9 -0
  28. package/build/esm/packages/phoenix/src/components/color_swatches/show-more/show_more.js +35 -0
  29. package/build/esm/packages/phoenix/src/components/color_swatches/show-more/show_more.js.map +1 -0
  30. package/build/esm/packages/phoenix/src/components/color_swatches/show-more/show_more_constants.d.ts +1 -0
  31. package/build/esm/packages/phoenix/src/components/color_swatches/show-more/show_more_constants.js +4 -0
  32. package/build/esm/packages/phoenix/src/components/color_swatches/show-more/show_more_constants.js.map +1 -0
  33. package/build/esm/packages/phoenix/src/components/messages/base_message.d.ts +9 -0
  34. package/build/esm/packages/phoenix/src/components/messages/base_message.js +49 -2
  35. package/build/esm/packages/phoenix/src/components/messages/base_message.js.map +1 -1
  36. package/build/esm/packages/phoenix/src/components/messages/base_message_constants.d.ts +2 -0
  37. package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js +5 -2
  38. package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
  39. package/build/esm/packages/phoenix/src/components/messages/hints/hint.d.ts +0 -2
  40. package/build/esm/packages/phoenix/src/components/messages/hints/hint.js +0 -10
  41. package/build/esm/packages/phoenix/src/components/messages/hints/hint.js.map +1 -1
  42. package/build/esm/packages/phoenix/src/components/messages/tooltips/tooltip.d.ts +0 -2
  43. package/build/esm/packages/phoenix/src/components/messages/tooltips/tooltip.js +0 -10
  44. package/build/esm/packages/phoenix/src/components/messages/tooltips/tooltip.js.map +1 -1
  45. package/build/esm/packages/phoenix/src/components/portal/portal_constants.js +2 -1
  46. package/build/esm/packages/phoenix/src/components/portal/portal_constants.js.map +1 -1
  47. package/build/esm/packages/phoenix/src/index.d.ts +1 -2
  48. package/build/esm/packages/phoenix/src/index.js +1 -2
  49. package/build/esm/packages/phoenix/src/index.js.map +1 -1
  50. package/package.json +5 -5
  51. package/build/cjs/packages/phoenix/src/components/show-more/show_more.js +0 -121
  52. package/build/cjs/packages/phoenix/src/components/show-more/show_more.js.map +0 -1
  53. package/build/cjs/packages/phoenix/src/components/show-more/show_more_button.js +0 -29
  54. package/build/cjs/packages/phoenix/src/components/show-more/show_more_button.js.map +0 -1
  55. package/build/cjs/packages/phoenix/src/components/show-more/show_more_constants.js +0 -15
  56. package/build/cjs/packages/phoenix/src/components/show-more/show_more_constants.js.map +0 -1
  57. package/build/esm/packages/phoenix/src/components/show-more/show_more.d.ts +0 -22
  58. package/build/esm/packages/phoenix/src/components/show-more/show_more.js +0 -119
  59. package/build/esm/packages/phoenix/src/components/show-more/show_more.js.map +0 -1
  60. package/build/esm/packages/phoenix/src/components/show-more/show_more_button.d.ts +0 -7
  61. package/build/esm/packages/phoenix/src/components/show-more/show_more_button.js +0 -27
  62. package/build/esm/packages/phoenix/src/components/show-more/show_more_button.js.map +0 -1
  63. package/build/esm/packages/phoenix/src/components/show-more/show_more_constants.d.ts +0 -7
  64. package/build/esm/packages/phoenix/src/components/show-more/show_more_constants.js +0 -10
  65. package/build/esm/packages/phoenix/src/components/show-more/show_more_constants.js.map +0 -1
@@ -3,20 +3,22 @@
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');
6
7
  var decorators = require('lit/decorators');
7
8
  var utilities = require('@dreamcommerce/utilities');
8
9
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
9
10
  var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
10
11
  var keystrokes_controller = require('../../controllers/keystrokes_controller/keystrokes_controller.js');
12
+ require('lit-html');
11
13
  var color_swatches_constants = require('./color_swatches_constants.js');
12
14
  var color_item_constants = require('./color_item/color_item_constants.js');
13
- var color_item = require('./color_item/color_item.js');
14
15
 
15
16
  exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.PhoenixLightLitElement {
16
17
  constructor() {
17
18
  super(...arguments);
18
19
  this.multiple = false;
19
20
  this.selectedColors = [];
21
+ this.showMoreBtnText = 'Pokaż wszystkie kolory';
20
22
  this._setupEvents = () => {
21
23
  if (this.getAttribute('role') === 'group') {
22
24
  this._setupCheckboxGroupEvents();
@@ -138,6 +140,8 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
138
140
  this._$colorSwatchesChildren = [...this.children];
139
141
  this._setupEvents();
140
142
  this._addCssClasses();
143
+ this.numberOfVisibleColors && this._hideItems(this.numberOfVisibleColors);
144
+ this._showAllItemsEvent();
141
145
  this.selectedColors = [...this.querySelectorAll('h-color-item[selected]')];
142
146
  this._$colors = [...this.querySelectorAll('h-color-item')];
143
147
  }
@@ -145,6 +149,26 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
145
149
  this.querySelectorAll(color_swatches_constants.COLOR_ITEM_TAG_NAME).forEach(($colorItem) => $colorItem.classList.add(color_swatches_constants.COLOR_SWATCHES_CSS_CLASSES.colorSwatchesItem));
146
150
  this.classList.add(color_swatches_constants.COLOR_SWATCHES_CSS_CLASSES.colorSwatches);
147
151
  }
152
+ _hideItems(numberOfVisibleColors) {
153
+ if (!this._$colorSwatchesChildren)
154
+ return;
155
+ this._$colorSwatchesChildren.forEach(($colorSwatchesChild, index) => {
156
+ if (index > numberOfVisibleColors - 1) {
157
+ $colorSwatchesChild.setAttribute(color_swatches_constants.COLOR_SWATCHES_HIDDEN_ATTRIBUTE, '');
158
+ }
159
+ });
160
+ }
161
+ _showAllItemsEvent() {
162
+ this.addEventListener(color_swatches_constants.COLOR_SWATCHES_EVENT_NAMES.showMore, () => {
163
+ var _a;
164
+ if (!this._$colorSwatchesChildren)
165
+ return;
166
+ this._$colorSwatchesChildren.forEach(($colorSwatchesChild) => {
167
+ $colorSwatchesChild.removeAttribute(color_swatches_constants.COLOR_SWATCHES_HIDDEN_ATTRIBUTE);
168
+ });
169
+ (_a = this.querySelector('h-color-swatches-show-more')) === null || _a === void 0 ? void 0 : _a.setAttribute(color_swatches_constants.COLOR_SWATCHES_HIDDEN_ATTRIBUTE, '');
170
+ });
171
+ }
148
172
  _handleChangeToNextColorItem({ target }) {
149
173
  const $colorItem = target;
150
174
  const $nextFocusableElement = utilities.UiDomUtils.getNextFocusableElement($colorItem);
@@ -156,9 +180,7 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
156
180
  $nextColorItem = $nextFocusableElement;
157
181
  }
158
182
  $nextColorItem.focus();
159
- if ($nextColorItem instanceof color_item.HColorItem) {
160
- this._handleColorChange($nextColorItem);
161
- }
183
+ this._handleColorChange($nextColorItem);
162
184
  }
163
185
  _handleChangeToPreviousColorItem({ target }) {
164
186
  const $colorItem = target;
@@ -171,9 +193,7 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
171
193
  $previousColorItem = $previousFocusableElement;
172
194
  }
173
195
  $previousColorItem.focus();
174
- if ($previousColorItem instanceof color_item.HColorItem) {
175
- this._handleColorChange($previousColorItem);
176
- }
196
+ this._handleColorChange($previousColorItem);
177
197
  }
178
198
  _toggleColorItem($colorItem) {
179
199
  this.multiple ? this._handleColorClickedForMultipleMode($colorItem) : this._handleColorChangeForSingleMode($colorItem);
@@ -210,15 +230,31 @@ exports.HColorSwatches = class HColorSwatches extends phoenix_light_lit_element.
210
230
  super.disconnectedCallback();
211
231
  document.body.removeEventListener('keydown', this._focusOnSelectedColor);
212
232
  }
233
+ render() {
234
+ return lit.html `
235
+ ${this.getSlot('default')}
236
+ ${this._$colors.length > this.numberOfVisibleColors
237
+ ? lit.html `<h-color-swatches-show-more>${this.showMoreBtnText}</h-color-swatches-show-more>`
238
+ : lit.nothing}
239
+ `;
240
+ }
213
241
  };
214
242
  tslib_es6.__decorate([
215
243
  decorators.property({ type: Boolean }),
216
244
  tslib_es6.__metadata("design:type", Boolean)
217
245
  ], exports.HColorSwatches.prototype, "multiple", void 0);
246
+ tslib_es6.__decorate([
247
+ decorators.property({ type: Number, attribute: 'number-of-visible-colors' }),
248
+ tslib_es6.__metadata("design:type", Number)
249
+ ], exports.HColorSwatches.prototype, "numberOfVisibleColors", void 0);
218
250
  tslib_es6.__decorate([
219
251
  decorators.property(),
220
252
  tslib_es6.__metadata("design:type", Array)
221
253
  ], exports.HColorSwatches.prototype, "selectedColors", void 0);
254
+ tslib_es6.__decorate([
255
+ decorators.property({ type: String, attribute: 'show-more-btn-text' }),
256
+ tslib_es6.__metadata("design:type", Object)
257
+ ], exports.HColorSwatches.prototype, "showMoreBtnText", void 0);
222
258
  exports.HColorSwatches = tslib_es6.__decorate([
223
259
  phoenix_custom_element.phoenixCustomElement('h-color-swatches')
224
260
  ], exports.HColorSwatches);
@@ -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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;"}
@@ -12,9 +12,11 @@ const COLOR_SWATCHES_EVENT_NAMES = {
12
12
  change: 'change',
13
13
  markDisabledItems: 'markDisabledItems',
14
14
  showMore: 'showMore'
15
- };
15
+ };
16
+ const COLOR_SWATCHES_HIDDEN_ATTRIBUTE = 'hidden';
16
17
 
17
18
  exports.COLOR_ITEM_TAG_NAME = COLOR_ITEM_TAG_NAME;
18
19
  exports.COLOR_SWATCHES_CSS_CLASSES = COLOR_SWATCHES_CSS_CLASSES;
19
20
  exports.COLOR_SWATCHES_EVENT_NAMES = COLOR_SWATCHES_EVENT_NAMES;
21
+ exports.COLOR_SWATCHES_HIDDEN_ATTRIBUTE = COLOR_SWATCHES_HIDDEN_ATTRIBUTE;
20
22
  //# sourceMappingURL=color_swatches_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;AACA;AACA;"}
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../../../../../external/tslib/tslib.es6.js');
6
+ var phoenix_light_lit_element = require('../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
7
+ var phoenix_custom_element = require('../../../core/decorators/phoenix_custom_element.js');
8
+ var btn_controller = require('../../../controllers/btn_controller/btn_controller.js');
9
+ var color_swatches_constants = require('../color_swatches_constants.js');
10
+ var show_more_constants = require('./show_more_constants.js');
11
+
12
+ exports.HColorSwatchesShowMore = class HColorSwatchesShowMore extends phoenix_light_lit_element.PhoenixLightLitElement {
13
+ constructor() {
14
+ super();
15
+ this._dispatchClickedEvent = () => {
16
+ this.emitCustomEvent(color_swatches_constants.COLOR_SWATCHES_EVENT_NAMES.showMore);
17
+ };
18
+ this._btnController = new btn_controller.BtnController(this, this._dispatchClickedEvent);
19
+ }
20
+ connectedCallback() {
21
+ super.connectedCallback();
22
+ this.setupEvents();
23
+ this._addCssClasses();
24
+ this.classList.add(show_more_constants.SHOW_MORE_CSS_CLASS);
25
+ }
26
+ _addCssClasses() {
27
+ this.classList.add(show_more_constants.SHOW_MORE_CSS_CLASS);
28
+ }
29
+ setupEvents() {
30
+ this.addEventListener('click', this._dispatchClickedEvent);
31
+ }
32
+ };
33
+ exports.HColorSwatchesShowMore = tslib_es6.__decorate([
34
+ phoenix_custom_element.phoenixCustomElement('h-color-swatches-show-more'),
35
+ tslib_es6.__metadata("design:paramtypes", [])
36
+ ], exports.HColorSwatchesShowMore);
37
+ //# sourceMappingURL=show_more.js.map
@@ -0,0 +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;"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const SHOW_MORE_CSS_CLASS = 'color-swatches-show-more';
6
+
7
+ exports.SHOW_MORE_CSS_CLASS = SHOW_MORE_CSS_CLASS;
8
+ //# sourceMappingURL=show_more_constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -3,13 +3,16 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
+ var lit = require('lit');
6
7
  var decorators = require('lit/decorators');
7
8
  var utilities = require('@dreamcommerce/utilities');
8
9
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
10
+ var v4 = require('../../../../../external/uuid/dist/esm-browser/v4.js');
9
11
  var portal_constants = require('../portal/portal_constants.js');
10
12
  var click_outside_controller = require('../../controllers/click_outside_controller/click_outside_controller.js');
11
13
  var relative_position_controller = require('../../controllers/relative_position_controller/relative_position_controller.js');
12
14
  var base_message_constants = require('./base_message_constants.js');
15
+ var ref = require('lit/directives/ref');
13
16
 
14
17
  class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
15
18
  constructor() {
@@ -20,9 +23,22 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
20
23
  this.offset = base_message_constants.DEFAULT_MESSAGE_OFFSET;
21
24
  this.mouseonly = false;
22
25
  this.tabindex = '-1';
26
+ this._messageId = v4['default']();
27
+ this._tooltipRef = ref.createRef();
28
+ this._handleChildrenAriaAttributes = () => {
29
+ [...this.children].forEach((child) => {
30
+ if (base_message_constants.LIST_OF_MESSAGE_CHILDREN.includes(child.tagName.toLowerCase()) || this._tooltipRef.value === child)
31
+ return;
32
+ child.setAttribute('aria-describedby', `${child.getAttribute('aria-describedby') || ''} ${this._messageId}`);
33
+ });
34
+ };
23
35
  this._setupEventListeners = () => {
36
+ var _a, _b;
24
37
  this.addEventListener('mouseenter', this.open);
25
38
  this.addEventListener('mouseleave', this.close);
39
+ this.addEventListener('keydown', this._closeFromKeyboard);
40
+ (_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', this.open);
41
+ (_b = this._$baseMessageContent) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', this.close);
26
42
  if (!this.mouseonly) {
27
43
  this.addEventListener('focusin', this.open);
28
44
  this.addEventListener('focusout', this.close);
@@ -43,6 +59,13 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
43
59
  this.opened = true;
44
60
  }, base_message_constants.MESSAGE_SHOW_DELAY_IN_MS);
45
61
  };
62
+ this._closeFromKeyboard = (ev) => {
63
+ if (ev.key !== 'Escape' || !this.opened)
64
+ return;
65
+ ev.preventDefault();
66
+ ev.stopPropagation();
67
+ this.close();
68
+ };
46
69
  this.close = () => {
47
70
  this._shouldDelayClosing = Date.now() - this._tooltipOpenTime > base_message_constants.MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS;
48
71
  clearTimeout(this._openTimeout);
@@ -83,8 +106,14 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
83
106
  offset: this.offset
84
107
  });
85
108
  this.setAttribute('tabindex', this.tabindex);
109
+ if (!this._$baseMessageContent)
110
+ this._$baseMessageContent = [...this.children].find((child) => base_message_constants.MESSAGE_CONTENT_ELEMENTS.includes(child.tagName.toLowerCase()));
86
111
  this._setupEventListeners();
87
112
  }
113
+ firstUpdated(props) {
114
+ super.firstUpdated(props);
115
+ this._handleChildrenAriaAttributes();
116
+ }
88
117
  static _appendMessagePortal() {
89
118
  const $messagePortalTarget = document.querySelector(`[name="${base_message_constants.DEFAULT_MESSAGE_PORTAL_NAME}"]`);
90
119
  if ($messagePortalTarget)
@@ -93,6 +122,24 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
93
122
  $portalTarget.setAttribute(portal_constants.PORTAL_TARGET_NAME_PROP, base_message_constants.DEFAULT_MESSAGE_PORTAL_NAME);
94
123
  document.body.appendChild($portalTarget);
95
124
  }
125
+ disconnectedCallback() {
126
+ var _a, _b;
127
+ super.disconnectedCallback();
128
+ (_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', this.open);
129
+ (_b = this._$baseMessageContent) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', this.close);
130
+ }
131
+ render() {
132
+ var _a;
133
+ super.render();
134
+ return lit.html `
135
+ <span ${ref.ref(this._tooltipRef)} id="${this._messageId}" class="${base_message_constants.SCREEN_READER_ONLY_CLASS_NAME}" role="tooltip">
136
+ ${utilities.DomUtils.stripHTMLTags(((_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.innerHTML) || '')}
137
+ </span>
138
+ <h-portal ?disabled="${!this.opened}" @open="${this._positionMessage}" to="${this.portalTarget}" hidden>
139
+ ${this.getSlot(base_message_constants.MESSAGE_CONTENT_SLOT_NAME)}
140
+ </h-portal>
141
+ `;
142
+ }
96
143
  }
97
144
  tslib_es6.__decorate([
98
145
  decorators.property({ type: Boolean, reflect: true }),
@@ -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,iBAAiB,qDAAyD;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var portal_constants = require('../portal/portal_constants.js');
5
6
  var hint_constants = require('./hints/hint_constants.js');
6
7
  var tooltip_constants = require('./tooltips/tooltip_constants.js');
7
8
 
@@ -10,16 +11,20 @@ const MESSAGE_CONTENT_SLOT_NAME = 'message-content';
10
11
  const MESSAGE_REMOVED_CLASS_NAME = `removed`;
11
12
  const DEFAULT_MESSAGE_OFFSET = 10;
12
13
  const MESSAGE_CONTENT_ELEMENTS = [tooltip_constants.TOOLTIP_CONTENT_ELEMENT_NAME, hint_constants.HINT_CONTENT_ELEMENT_NAME];
14
+ const LIST_OF_MESSAGE_CHILDREN = [...MESSAGE_CONTENT_ELEMENTS, portal_constants.PORTAL_COMPONENT_NAME];
13
15
  const MESSAGE_SHOW_DELAY_IN_MS = 100;
14
16
  const MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = 500;
15
- const MESSAGE_CLOSE_DELAY_IN_MS = 500;
17
+ const MESSAGE_CLOSE_DELAY_IN_MS = 500;
18
+ const SCREEN_READER_ONLY_CLASS_NAME = 'sr-only';
16
19
 
17
20
  exports.DEFAULT_MESSAGE_OFFSET = DEFAULT_MESSAGE_OFFSET;
18
21
  exports.DEFAULT_MESSAGE_PORTAL_NAME = DEFAULT_MESSAGE_PORTAL_NAME;
22
+ exports.LIST_OF_MESSAGE_CHILDREN = LIST_OF_MESSAGE_CHILDREN;
19
23
  exports.MESSAGE_CLOSE_DELAY_IN_MS = MESSAGE_CLOSE_DELAY_IN_MS;
20
24
  exports.MESSAGE_CONTENT_ELEMENTS = MESSAGE_CONTENT_ELEMENTS;
21
25
  exports.MESSAGE_CONTENT_SLOT_NAME = MESSAGE_CONTENT_SLOT_NAME;
22
26
  exports.MESSAGE_REMOVED_CLASS_NAME = MESSAGE_REMOVED_CLASS_NAME;
23
27
  exports.MESSAGE_SHOW_DELAY_IN_MS = MESSAGE_SHOW_DELAY_IN_MS;
24
28
  exports.MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS;
29
+ exports.SCREEN_READER_ONLY_CLASS_NAME = SCREEN_READER_ONLY_CLASS_NAME;
25
30
  //# 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;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;AACA;AACA;AACA;AACA;AACA;"}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib_es6 = require('../../../../../../external/tslib/tslib.es6.js');
6
6
  var phoenix_custom_element = require('../../../core/decorators/phoenix_custom_element.js');
7
- var litHtml = require('lit-html');
8
7
  var hint_constants = require('./hint_constants.js');
9
- var base_message_constants = require('../base_message_constants.js');
10
8
  var base_message = require('../base_message.js');
11
9
 
12
10
  exports.HHint = class HHint extends base_message.BaseMessage {
@@ -18,14 +16,6 @@ exports.HHint = class HHint extends base_message.BaseMessage {
18
16
  super.connectedCallback(hint_constants.HINT_CLASS_NAME);
19
17
  this.classList.add(hint_constants.HINT_CLASS_NAME);
20
18
  }
21
- render() {
22
- super.render();
23
- return litHtml.html `
24
- <h-portal ?disabled="${!this.opened}" @open="${this._positionMessage}" to="${this.portalTarget}" hidden>
25
- ${this.getSlot(base_message_constants.MESSAGE_CONTENT_SLOT_NAME)}
26
- </h-portal>
27
- `;
28
- }
29
19
  };
30
20
  exports.HHint = tslib_es6.__decorate([
31
21
  phoenix_custom_element.phoenixCustomElement(hint_constants.HINT_ELEMENT_NAME),
@@ -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;"}
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;"}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib_es6 = require('../../../../../../external/tslib/tslib.es6.js');
6
6
  var phoenix_custom_element = require('../../../core/decorators/phoenix_custom_element.js');
7
- var litHtml = require('lit-html');
8
7
  var tooltip_constants = require('./tooltip_constants.js');
9
- var base_message_constants = require('../base_message_constants.js');
10
8
  var base_message = require('../base_message.js');
11
9
 
12
10
  exports.HTooltip = class HTooltip extends base_message.BaseMessage {
@@ -14,14 +12,6 @@ exports.HTooltip = class HTooltip extends base_message.BaseMessage {
14
12
  super.connectedCallback(tooltip_constants.TOOLTIP_CLASS_NAME);
15
13
  this.classList.add(tooltip_constants.TOOLTIP_CLASS_NAME);
16
14
  }
17
- render() {
18
- super.render();
19
- return litHtml.html `
20
- <h-portal ?disabled="${!this.opened}" @open="${this._positionMessage}" to="${this.portalTarget}" hidden>
21
- ${this.getSlot(base_message_constants.MESSAGE_CONTENT_SLOT_NAME)}
22
- </h-portal>
23
- `;
24
- }
25
15
  };
26
16
  exports.HTooltip = tslib_es6.__decorate([
27
17
  phoenix_custom_element.phoenixCustomElement(tooltip_constants.TOOLTIP_ELEMENT_NAME)
@@ -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;"}
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;"}
@@ -7,9 +7,11 @@ const PORTAL_EVENTS = {
7
7
  close: 'close'
8
8
  };
9
9
  const PORTAL_TARGET_NAME_PROP = 'name';
10
+ const PORTAL_COMPONENT_NAME = 'h-portal';
10
11
  const PORTAL_TARGET_COMPONENT_NAME = 'h-portal-target';
11
12
  const PORTAL_TARGET_ATTRIBUTE_NAME = 'portal-target';
12
13
 
14
+ exports.PORTAL_COMPONENT_NAME = PORTAL_COMPONENT_NAME;
13
15
  exports.PORTAL_EVENTS = PORTAL_EVENTS;
14
16
  exports.PORTAL_TARGET_ATTRIBUTE_NAME = PORTAL_TARGET_ATTRIBUTE_NAME;
15
17
  exports.PORTAL_TARGET_COMPONENT_NAME = PORTAL_TARGET_COMPONENT_NAME;
@@ -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;"}
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;"}
@@ -83,10 +83,10 @@ var toggle_button = require('./components/groups/toggle_button_group/toggle_butt
83
83
  var click_outside_controller_messages = require('./controllers/click_outside_controller/click_outside_controller_messages.js');
84
84
  var backdrop = require('./components/backdrop/backdrop.js');
85
85
  var color_swatches_control_constants = require('./components/form/color_swatches_control/color_swatches_control_constants.js');
86
- var show_more_button = require('./components/show-more/show_more_button.js');
87
86
  var color_swatches = require('./components/color_swatches/color_swatches.js');
88
87
  var color_item = require('./components/color_swatches/color_item/color_item.js');
89
88
  var color_swatches_control = require('./components/form/color_swatches_control/color_swatches_control.js');
89
+ var show_more = require('./components/color_swatches/show-more/show_more.js');
90
90
  var visibility_controller = require('./controllers/visibility_controller/visibility_controller.js');
91
91
  var slider = require('./components/slider/slider.js');
92
92
  var scroller = require('./components/scroller/scroller.js');
@@ -126,7 +126,6 @@ var toggle = require('./components/toggle/toggle.js');
126
126
  var toggle_button$1 = require('./components/toggle/toggle_button.js');
127
127
  var navigator_share = require('./components/navigator/navigator_share/navigator_share.js');
128
128
  var navigator_controller = require('./components/navigator/navigator_controller/navigator_controller.js');
129
- var show_more = require('./components/show-more/show_more.js');
130
129
 
131
130
 
132
131
 
@@ -511,12 +510,6 @@ Object.defineProperty(exports, 'HBackdrop', {
511
510
  }
512
511
  });
513
512
  exports.COLOR_SWATCHES_CONTROL_EVENT_NAMES = color_swatches_control_constants.COLOR_SWATCHES_CONTROL_EVENT_NAMES;
514
- Object.defineProperty(exports, 'HShowMoreButton', {
515
- enumerable: true,
516
- get: function () {
517
- return show_more_button.HShowMoreButton;
518
- }
519
- });
520
513
  Object.defineProperty(exports, 'HColorSwatches', {
521
514
  enumerable: true,
522
515
  get: function () {
@@ -535,6 +528,12 @@ Object.defineProperty(exports, 'HColorSwatchesControl', {
535
528
  return color_swatches_control.HColorSwatchesControl;
536
529
  }
537
530
  });
531
+ Object.defineProperty(exports, 'HColorSwatchesShowMore', {
532
+ enumerable: true,
533
+ get: function () {
534
+ return show_more.HColorSwatchesShowMore;
535
+ }
536
+ });
538
537
  exports.VisibilityController = visibility_controller.VisibilityController;
539
538
  Object.defineProperty(exports, 'HSlider', {
540
539
  enumerable: true,
@@ -756,10 +755,4 @@ Object.defineProperty(exports, 'NavigatorController', {
756
755
  return navigator_controller.NavigatorController;
757
756
  }
758
757
  });
759
- Object.defineProperty(exports, 'HShowMore', {
760
- enumerable: true,
761
- get: function () {
762
- return show_more.HShowMore;
763
- }
764
- });
765
758
  //# sourceMappingURL=index.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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,14 +1,19 @@
1
1
  import { HColorItem } from "./color_item/color_item";
2
2
  import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
3
+ import { TemplateResult } from 'lit-html';
3
4
  export declare class HColorSwatches extends PhoenixLightLitElement {
4
5
  multiple: boolean;
6
+ numberOfVisibleColors: number;
5
7
  selectedColors: HColorItem[];
8
+ showMoreBtnText: string;
6
9
  private _$colors;
7
10
  private _$colorSwatchesChildren;
8
11
  selectColors($colors: HColorItem[] | HColorItem): void;
9
12
  clearAllColors(): void;
10
13
  connectedCallback(): void;
11
14
  private _addCssClasses;
15
+ private _hideItems;
16
+ private _showAllItemsEvent;
12
17
  private _setupEvents;
13
18
  private _setupCheckboxGroupEvents;
14
19
  private _setupRadioGroupEvents;
@@ -28,4 +33,5 @@ export declare class HColorSwatches extends PhoenixLightLitElement {
28
33
  private _removeExistingColorFromArray;
29
34
  private _dispatchColorChangeEvent;
30
35
  disconnectedCallback(): void;
36
+ protected render(): TemplateResult;
31
37
  }
@@ -1,18 +1,20 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
+ import { html, nothing } from 'lit';
2
3
  import { property } from 'lit/decorators';
3
4
  import { UiDomUtils, ArrayUtils } from '@dreamcommerce/utilities';
4
5
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
5
6
  import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
6
7
  import { KeystrokesController } from '../../controllers/keystrokes_controller/keystrokes_controller.js';
7
- import { COLOR_SWATCHES_EVENT_NAMES, COLOR_ITEM_TAG_NAME, COLOR_SWATCHES_CSS_CLASSES } from './color_swatches_constants.js';
8
+ import 'lit-html';
9
+ import { COLOR_SWATCHES_EVENT_NAMES, COLOR_ITEM_TAG_NAME, COLOR_SWATCHES_CSS_CLASSES, COLOR_SWATCHES_HIDDEN_ATTRIBUTE } from './color_swatches_constants.js';
8
10
  import { COLOR_ITEM_SELECTED_ATTRIBUTE } from './color_item/color_item_constants.js';
9
- import { HColorItem } from './color_item/color_item.js';
10
11
 
11
12
  let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
12
13
  constructor() {
13
14
  super(...arguments);
14
15
  this.multiple = false;
15
16
  this.selectedColors = [];
17
+ this.showMoreBtnText = 'Pokaż wszystkie kolory';
16
18
  this._setupEvents = () => {
17
19
  if (this.getAttribute('role') === 'group') {
18
20
  this._setupCheckboxGroupEvents();
@@ -134,6 +136,8 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
134
136
  this._$colorSwatchesChildren = [...this.children];
135
137
  this._setupEvents();
136
138
  this._addCssClasses();
139
+ this.numberOfVisibleColors && this._hideItems(this.numberOfVisibleColors);
140
+ this._showAllItemsEvent();
137
141
  this.selectedColors = [...this.querySelectorAll('h-color-item[selected]')];
138
142
  this._$colors = [...this.querySelectorAll('h-color-item')];
139
143
  }
@@ -141,6 +145,26 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
141
145
  this.querySelectorAll(COLOR_ITEM_TAG_NAME).forEach(($colorItem) => $colorItem.classList.add(COLOR_SWATCHES_CSS_CLASSES.colorSwatchesItem));
142
146
  this.classList.add(COLOR_SWATCHES_CSS_CLASSES.colorSwatches);
143
147
  }
148
+ _hideItems(numberOfVisibleColors) {
149
+ if (!this._$colorSwatchesChildren)
150
+ return;
151
+ this._$colorSwatchesChildren.forEach(($colorSwatchesChild, index) => {
152
+ if (index > numberOfVisibleColors - 1) {
153
+ $colorSwatchesChild.setAttribute(COLOR_SWATCHES_HIDDEN_ATTRIBUTE, '');
154
+ }
155
+ });
156
+ }
157
+ _showAllItemsEvent() {
158
+ this.addEventListener(COLOR_SWATCHES_EVENT_NAMES.showMore, () => {
159
+ var _a;
160
+ if (!this._$colorSwatchesChildren)
161
+ return;
162
+ this._$colorSwatchesChildren.forEach(($colorSwatchesChild) => {
163
+ $colorSwatchesChild.removeAttribute(COLOR_SWATCHES_HIDDEN_ATTRIBUTE);
164
+ });
165
+ (_a = this.querySelector('h-color-swatches-show-more')) === null || _a === void 0 ? void 0 : _a.setAttribute(COLOR_SWATCHES_HIDDEN_ATTRIBUTE, '');
166
+ });
167
+ }
144
168
  _handleChangeToNextColorItem({ target }) {
145
169
  const $colorItem = target;
146
170
  const $nextFocusableElement = UiDomUtils.getNextFocusableElement($colorItem);
@@ -152,9 +176,7 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
152
176
  $nextColorItem = $nextFocusableElement;
153
177
  }
154
178
  $nextColorItem.focus();
155
- if ($nextColorItem instanceof HColorItem) {
156
- this._handleColorChange($nextColorItem);
157
- }
179
+ this._handleColorChange($nextColorItem);
158
180
  }
159
181
  _handleChangeToPreviousColorItem({ target }) {
160
182
  const $colorItem = target;
@@ -167,9 +189,7 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
167
189
  $previousColorItem = $previousFocusableElement;
168
190
  }
169
191
  $previousColorItem.focus();
170
- if ($previousColorItem instanceof HColorItem) {
171
- this._handleColorChange($previousColorItem);
172
- }
192
+ this._handleColorChange($previousColorItem);
173
193
  }
174
194
  _toggleColorItem($colorItem) {
175
195
  this.multiple ? this._handleColorClickedForMultipleMode($colorItem) : this._handleColorChangeForSingleMode($colorItem);
@@ -206,15 +226,31 @@ let HColorSwatches = class HColorSwatches extends PhoenixLightLitElement {
206
226
  super.disconnectedCallback();
207
227
  document.body.removeEventListener('keydown', this._focusOnSelectedColor);
208
228
  }
229
+ render() {
230
+ return html `
231
+ ${this.getSlot('default')}
232
+ ${this._$colors.length > this.numberOfVisibleColors
233
+ ? html `<h-color-swatches-show-more>${this.showMoreBtnText}</h-color-swatches-show-more>`
234
+ : nothing}
235
+ `;
236
+ }
209
237
  };
210
238
  __decorate([
211
239
  property({ type: Boolean }),
212
240
  __metadata("design:type", Boolean)
213
241
  ], HColorSwatches.prototype, "multiple", void 0);
242
+ __decorate([
243
+ property({ type: Number, attribute: 'number-of-visible-colors' }),
244
+ __metadata("design:type", Number)
245
+ ], HColorSwatches.prototype, "numberOfVisibleColors", void 0);
214
246
  __decorate([
215
247
  property(),
216
248
  __metadata("design:type", Array)
217
249
  ], HColorSwatches.prototype, "selectedColors", void 0);
250
+ __decorate([
251
+ property({ type: String, attribute: 'show-more-btn-text' }),
252
+ __metadata("design:type", Object)
253
+ ], HColorSwatches.prototype, "showMoreBtnText", void 0);
218
254
  HColorSwatches = __decorate([
219
255
  phoenixCustomElement('h-color-swatches')
220
256
  ], HColorSwatches);
@@ -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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;"}