@shoper/phoenix_design_system 1.15.5 → 1.15.6-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/build/cjs/packages/phoenix/src/components/color_swatches/color_item/color_item.js +21 -29
  2. package/build/cjs/packages/phoenix/src/components/color_swatches/color_item/color_item.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/components/color_swatches/color_item/color_item_constants.js +0 -4
  4. package/build/cjs/packages/phoenix/src/components/color_swatches/color_item/color_item_constants.js.map +1 -1
  5. package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches.js +121 -11
  6. package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches.js.map +1 -1
  7. package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches_constants.js +0 -2
  8. package/build/cjs/packages/phoenix/src/components/color_swatches/color_swatches_constants.js.map +1 -1
  9. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js +9 -2
  10. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  11. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js +6 -1
  12. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
  13. package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js +30 -0
  14. package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js.map +1 -1
  15. package/build/cjs/packages/phoenix/src/components/form/select/components/select_options.js +1 -2
  16. package/build/cjs/packages/phoenix/src/components/form/select/components/select_options.js.map +1 -1
  17. package/build/cjs/packages/phoenix/src/components/form/select/select.js +41 -8
  18. package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
  19. package/build/cjs/packages/phoenix/src/components/messages/base_message.js +16 -47
  20. package/build/cjs/packages/phoenix/src/components/messages/base_message.js.map +1 -1
  21. package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js +0 -2
  22. package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
  23. package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +62 -15
  24. package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
  25. package/build/cjs/packages/phoenix/src/index.js +5 -5
  26. package/build/esm/packages/phoenix/src/components/color_swatches/color_item/color_item.d.ts +3 -6
  27. package/build/esm/packages/phoenix/src/components/color_swatches/color_item/color_item.js +22 -30
  28. package/build/esm/packages/phoenix/src/components/color_swatches/color_item/color_item.js.map +1 -1
  29. package/build/esm/packages/phoenix/src/components/color_swatches/color_item/color_item_constants.js +1 -4
  30. package/build/esm/packages/phoenix/src/components/color_swatches/color_item/color_item_constants.js.map +1 -1
  31. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches.d.ts +11 -1
  32. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches.js +124 -14
  33. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches.js.map +1 -1
  34. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches_constants.js +1 -2
  35. package/build/esm/packages/phoenix/src/components/color_swatches/color_swatches_constants.js.map +1 -1
  36. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.d.ts +1 -0
  37. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +9 -2
  38. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  39. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.d.ts +1 -0
  40. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js +6 -1
  41. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
  42. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.d.ts +4 -0
  43. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js +30 -0
  44. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js.map +1 -1
  45. package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js +1 -2
  46. package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js.map +1 -1
  47. package/build/esm/packages/phoenix/src/components/form/select/select.d.ts +6 -2
  48. package/build/esm/packages/phoenix/src/components/form/select/select.js +41 -8
  49. package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
  50. package/build/esm/packages/phoenix/src/components/messages/base_message.d.ts +2 -3
  51. package/build/esm/packages/phoenix/src/components/messages/base_message.js +18 -49
  52. package/build/esm/packages/phoenix/src/components/messages/base_message.js.map +1 -1
  53. package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js +3 -4
  54. package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
  55. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.d.ts +6 -2
  56. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js +1 -0
  57. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js.map +1 -1
  58. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.d.ts +7 -3
  59. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +62 -15
  60. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
  61. package/build/esm/packages/phoenix/src/index.js +1 -1
  62. package/package.json +1 -1
@@ -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
- this.addEventListener('focusin', this.open);
26
- this.addEventListener('focusout', this.close);
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;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;"}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
6
  require('lit');
7
7
  var utilities = require('@dreamcommerce/utilities');
8
- var keystrokes_controller = require('../keystrokes_controller/keystrokes_controller.js');
9
8
  var list_box_controller_constants = require('./list_box_controller_constants.js');
10
9
 
11
10
  var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController_currentOptionIndex, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
@@ -17,25 +16,54 @@ class ListBoxKeyboardController {
17
16
  _ListBoxKeyboardController__$options.set(this, void 0);
18
17
  _ListBoxKeyboardController_listItemSelector.set(this, void 0);
19
18
  _ListBoxKeyboardController_keys.set(this, void 0);
19
+ this._handleKeyboardNavigation = (ev) => {
20
+ if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f").find((key) => key === ev.key)) {
21
+ this._handleArrowNavigation(ev);
22
+ return;
23
+ }
24
+ this._handleWriteableCharacter(ev);
25
+ };
20
26
  this._handleArrowNavigation = (event) => {
21
27
  event.preventDefault();
22
28
  const { key } = event;
23
- const prevOptionIndex = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
29
+ const $availableOptions = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
30
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
31
+ });
32
+ const prevOptionIndex = this._findCurrentIndex();
24
33
  let newOptionIndex = key === 'ArrowDown' || key === 'ArrowRight' ? this._getNextOptionIndex() : this._getPrevOptionIndex();
25
34
  if (newOptionIndex === undefined) {
26
- const selectedOptionIndex = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
27
- newOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
35
+ newOptionIndex = this._findCurrentIndex();
28
36
  }
29
37
  if (newOptionIndex === tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f"))
30
38
  return;
31
39
  if (prevOptionIndex !== undefined) {
32
40
  const $prevOption = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[prevOptionIndex];
33
- utilities.UiDomUtils.makeUnnavigable($prevOption);
41
+ $prevOption && utilities.UiDomUtils.makeUnnavigable($prevOption);
34
42
  }
35
43
  tslib_es6.__classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, newOptionIndex, "f");
36
- const $focusedOption = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[newOptionIndex];
37
- utilities.UiDomUtils.makeNavigable($focusedOption);
38
- $focusedOption.focus();
44
+ const $focusedOption = $availableOptions[newOptionIndex];
45
+ if ($focusedOption) {
46
+ utilities.UiDomUtils.makeNavigable($focusedOption);
47
+ $focusedOption.focus();
48
+ }
49
+ };
50
+ this._findCurrentIndex = () => {
51
+ const $availableOptions = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
52
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
53
+ });
54
+ const selectedOptionIndex = $availableOptions.findIndex(($option) => $option.selected);
55
+ return selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
56
+ };
57
+ this._handleWriteableCharacter = (ev) => {
58
+ var _a;
59
+ const $searchInput = (_a = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
60
+ if (!$searchInput)
61
+ return;
62
+ $searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
63
+ };
64
+ this.calculateSelectedOptionIndex = () => {
65
+ const selectedOptionIndex = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
66
+ tslib_es6.__classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, selectedOptionIndex !== -1 ? selectedOptionIndex : 0, "f");
39
67
  };
40
68
  tslib_es6.__classPrivateFieldSet(this, _ListBoxKeyboardController_host, host, "f");
41
69
  tslib_es6.__classPrivateFieldSet(this, _ListBoxKeyboardController__$list, $list, "f");
@@ -45,12 +73,7 @@ class ListBoxKeyboardController {
45
73
  tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").addController(this);
46
74
  }
47
75
  hostConnected() {
48
- new keystrokes_controller.KeystrokesController({
49
- host: tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f"),
50
- keys: tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f"),
51
- callback: this._handleArrowNavigation,
52
- target: tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f")
53
- });
76
+ tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('keydown', this._handleKeyboardNavigation);
54
77
  utilities.UiDomUtils.makeNavigable(tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"));
55
78
  tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('focusin', (event) => {
56
79
  if (event.target !== tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"))
@@ -68,15 +91,39 @@ class ListBoxKeyboardController {
68
91
  return undefined;
69
92
  if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") <= 0)
70
93
  return tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
94
+ if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") <= 0)
95
+ return tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
96
+ const $availableOptions = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
97
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
98
+ });
99
+ if (!!$availableOptions[tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1])
100
+ return tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1;
101
+ // bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
102
+ const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
103
+ if (newIndexOfCurrentlySelectedOption)
104
+ return newIndexOfCurrentlySelectedOption - 1;
71
105
  return tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1;
72
106
  }
73
107
  _getNextOptionIndex() {
74
108
  if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
75
109
  return undefined;
76
- if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") >= tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").length - 1)
110
+ const $availableOptions = tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
111
+ return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
112
+ });
113
+ if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === $availableOptions.length - 1)
77
114
  return tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
115
+ if (tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") > $availableOptions.length - 1) {
116
+ // bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
117
+ const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
118
+ if (newIndexOfCurrentlySelectedOption)
119
+ return newIndexOfCurrentlySelectedOption + 1;
120
+ return 0;
121
+ }
78
122
  return tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") + 1;
79
123
  }
124
+ hostDisconnected() {
125
+ tslib_es6.__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
126
+ }
80
127
  }
81
128
  _ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController_currentOptionIndex = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
82
129
 
@@ -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;"}
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;"}
@@ -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, 'HColorItem', {
467
+ Object.defineProperty(exports, 'HColorSwatches', {
468
468
  enumerable: true,
469
469
  get: function () {
470
- return color_item.HColorItem;
470
+ return color_swatches.HColorSwatches;
471
471
  }
472
472
  });
473
- Object.defineProperty(exports, 'HColorSwatches', {
473
+ Object.defineProperty(exports, 'HColorItem', {
474
474
  enumerable: true,
475
475
  get: function () {
476
- return color_swatches.HColorSwatches;
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 _btnController;
12
- constructor();
11
+ private _$colorSwatches;
13
12
  connectedCallback(): void;
14
- attributeChangedCallback(name: string, value: string | null, newValue: string | null): void;
15
- private _syncAriaPressed;
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 { BtnController } from '../../../controllers/btn_controller/btn_controller.js';
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._dispatchClickedEvent = () => {
16
- this.emitEvent(COLOR_ITEM_EVENT_NAMES.selected);
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.setupEvents();
29
+ this._setupAriaAttributes();
30
+ this._setupClasses();
23
31
  this.style.backgroundColor = this.setBgColor(this.disabled);
24
- this._syncAriaPressed();
25
- this.setAttribute('aria-label', this.label ? this.label : this.color);
26
- this.unclickable && this.removeAttribute('tabindex');
27
- this.classList.add(COLOR_ITEM_CSS_CLASSES.colorItem);
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 };
@@ -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;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;"}
@@ -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, COLOR_ITEM_EVENT_NAMES, COLOR_ITEM_SELECTED_ATTRIBUTE, COLOR_ITEM_SIZES };
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;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 _handleColorClickedForSingleMode;
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
  }