@shoper/phoenix_design_system 1.15.11-3 → 1.15.11-30

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 (70) hide show
  1. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js +2 -9
  2. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js +1 -6
  4. package/build/cjs/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
  5. package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js +0 -30
  6. package/build/cjs/packages/phoenix/src/components/form/select/components/search/select_search.js.map +1 -1
  7. package/build/cjs/packages/phoenix/src/components/form/select/components/select_options.js +2 -1
  8. package/build/cjs/packages/phoenix/src/components/form/select/components/select_options.js.map +1 -1
  9. package/build/cjs/packages/phoenix/src/components/form/select/select.js +11 -61
  10. package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
  11. package/build/cjs/packages/phoenix/src/components/messages/base_message.js +51 -5
  12. package/build/cjs/packages/phoenix/src/components/messages/base_message.js.map +1 -1
  13. package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js +6 -1
  14. package/build/cjs/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
  15. package/build/cjs/packages/phoenix/src/components/messages/base_message_content.js +0 -1
  16. package/build/cjs/packages/phoenix/src/components/messages/base_message_content.js.map +1 -1
  17. package/build/cjs/packages/phoenix/src/components/messages/hints/hint.js +0 -10
  18. package/build/cjs/packages/phoenix/src/components/messages/hints/hint.js.map +1 -1
  19. package/build/cjs/packages/phoenix/src/components/messages/tooltips/tooltip.js +0 -10
  20. package/build/cjs/packages/phoenix/src/components/messages/tooltips/tooltip.js.map +1 -1
  21. package/build/cjs/packages/phoenix/src/components/portal/portal_constants.js +2 -0
  22. package/build/cjs/packages/phoenix/src/components/portal/portal_constants.js.map +1 -1
  23. package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +30 -76
  24. package/build/cjs/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
  25. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.d.ts +0 -1
  26. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +2 -9
  27. package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js.map +1 -1
  28. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.d.ts +0 -1
  29. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js +1 -6
  30. package/build/esm/packages/phoenix/src/components/dropdown/dropdown_toggler.js.map +1 -1
  31. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.d.ts +0 -4
  32. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js +0 -30
  33. package/build/esm/packages/phoenix/src/components/form/select/components/search/select_search.js.map +1 -1
  34. package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js +2 -1
  35. package/build/esm/packages/phoenix/src/components/form/select/components/select_options.js.map +1 -1
  36. package/build/esm/packages/phoenix/src/components/form/select/select.d.ts +3 -10
  37. package/build/esm/packages/phoenix/src/components/form/select/select.js +11 -61
  38. package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
  39. package/build/esm/packages/phoenix/src/components/messages/base_message.d.ts +10 -1
  40. package/build/esm/packages/phoenix/src/components/messages/base_message.js +53 -7
  41. package/build/esm/packages/phoenix/src/components/messages/base_message.js.map +1 -1
  42. package/build/esm/packages/phoenix/src/components/messages/base_message_constants.d.ts +2 -0
  43. package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js +5 -2
  44. package/build/esm/packages/phoenix/src/components/messages/base_message_constants.js.map +1 -1
  45. package/build/esm/packages/phoenix/src/components/messages/base_message_content.js +0 -1
  46. package/build/esm/packages/phoenix/src/components/messages/base_message_content.js.map +1 -1
  47. package/build/esm/packages/phoenix/src/components/messages/base_message_types.d.ts +1 -1
  48. package/build/esm/packages/phoenix/src/components/messages/hints/hint.d.ts +0 -2
  49. package/build/esm/packages/phoenix/src/components/messages/hints/hint.js +0 -10
  50. package/build/esm/packages/phoenix/src/components/messages/hints/hint.js.map +1 -1
  51. package/build/esm/packages/phoenix/src/components/messages/tooltips/tooltip.d.ts +0 -2
  52. package/build/esm/packages/phoenix/src/components/messages/tooltips/tooltip.js +0 -10
  53. package/build/esm/packages/phoenix/src/components/messages/tooltips/tooltip.js.map +1 -1
  54. package/build/esm/packages/phoenix/src/components/portal/portal_constants.js +2 -1
  55. package/build/esm/packages/phoenix/src/components/portal/portal_constants.js.map +1 -1
  56. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.d.ts +2 -6
  57. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js +0 -1
  58. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_controller_types.js.map +1 -1
  59. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.d.ts +3 -8
  60. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js +30 -76
  61. package/build/esm/packages/phoenix/src/controllers/list_box_controller/list_box_keyboard_controller.js.map +1 -1
  62. package/package.json +3 -3
  63. package/build/cjs/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +0 -96
  64. package/build/cjs/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js.map +0 -1
  65. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.d.ts +0 -15
  66. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js +0 -92
  67. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller.js.map +0 -1
  68. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.d.ts +0 -8
  69. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.js +0 -3
  70. package/build/esm/packages/phoenix/src/components/form/select/controllers/select_toggler_keyboard_controller/select_toggler_keyboard_controller_types.js.map +0 -1
@@ -1,11 +1,13 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
+ import { html } from 'lit';
2
3
  import { property } from 'lit/decorators';
3
- import { DIRECTIONS } from '@dreamcommerce/utilities';
4
+ import { DIRECTIONS, DomUtils } from '@dreamcommerce/utilities';
4
5
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
6
+ import v4 from '../../../../../external/uuid/dist/esm-browser/v4.js';
5
7
  import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP, PORTAL_TARGET_ATTRIBUTE_NAME } from '../portal/portal_constants.js';
6
8
  import { ClickOutsideController } from '../../controllers/click_outside_controller/click_outside_controller.js';
7
9
  import { RelativePositionController } from '../../controllers/relative_position_controller/relative_position_controller.js';
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
+ import { DEFAULT_MESSAGE_PORTAL_NAME, DEFAULT_MESSAGE_OFFSET, LIST_OF_MESSAGE_CHILDREN, MESSAGE_SHOW_DELAY_IN_MS, MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS, MESSAGE_REMOVED_CLASS_NAME, MESSAGE_CLOSE_DELAY_IN_MS, MESSAGE_CONTENT_ELEMENTS, LIST_OF_MESSAGE_CONTENT_ELEMENTS, MESSAGE_CONTENT_SLOT_NAME } from './base_message_constants.js';
9
11
 
10
12
  class BaseMessage extends PhoenixLightLitElement {
11
13
  constructor() {
@@ -16,12 +18,24 @@ class BaseMessage extends PhoenixLightLitElement {
16
18
  this.offset = DEFAULT_MESSAGE_OFFSET;
17
19
  this.mouseonly = false;
18
20
  this.tabindex = '-1';
21
+ this._messageId = v4();
22
+ this._handleChildrenAriaAttributes = () => {
23
+ [...this.children].forEach((child) => {
24
+ if (LIST_OF_MESSAGE_CHILDREN.includes(child.tagName.toLowerCase()))
25
+ return;
26
+ child.setAttribute('aria-describedby', `${child.getAttribute('aria-describedby') || ''} ${this._messageId}`);
27
+ });
28
+ };
19
29
  this._setupEventListeners = () => {
30
+ var _a, _b;
20
31
  this.addEventListener('mouseenter', this.open);
21
- this.addEventListener('mouseleave', this.close);
32
+ this.addEventListener('mouseleave', this._handleClose);
33
+ this.addEventListener('keydown', this._closeFromKeyboard);
34
+ (_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', this.open);
35
+ (_b = this._$baseMessageContent) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', this._handleClose);
22
36
  if (!this.mouseonly) {
23
37
  this.addEventListener('focusin', this.open);
24
- this.addEventListener('focusout', this.close);
38
+ this.addEventListener('focusout', this._handleClose);
25
39
  }
26
40
  };
27
41
  this._positionMessage = () => {
@@ -39,8 +53,18 @@ class BaseMessage extends PhoenixLightLitElement {
39
53
  this.opened = true;
40
54
  }, MESSAGE_SHOW_DELAY_IN_MS);
41
55
  };
42
- this.close = () => {
43
- this._shouldDelayClosing = Date.now() - this._tooltipOpenTime > MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS;
56
+ this._closeFromKeyboard = (ev) => {
57
+ if (ev.key !== 'Escape' || !this.opened)
58
+ return;
59
+ ev.preventDefault();
60
+ ev.stopPropagation();
61
+ this.close(true);
62
+ };
63
+ this._handleClose = () => {
64
+ this.close();
65
+ };
66
+ this.close = (shouldCloseImmediately = false) => {
67
+ this._shouldDelayClosing = !shouldCloseImmediately && Date.now() - this._tooltipOpenTime > MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS;
44
68
  clearTimeout(this._openTimeout);
45
69
  if (!this.opened)
46
70
  return;
@@ -61,7 +85,7 @@ class BaseMessage extends PhoenixLightLitElement {
61
85
  this._clickOutsideController = new ClickOutsideController({
62
86
  host: this,
63
87
  container: this,
64
- action: this.close
88
+ action: this._handleClose
65
89
  });
66
90
  }
67
91
  connectedCallback(messageComponentName = '') {
@@ -79,8 +103,14 @@ class BaseMessage extends PhoenixLightLitElement {
79
103
  offset: this.offset
80
104
  });
81
105
  this.setAttribute('tabindex', this.tabindex);
106
+ if (!this._$baseMessageContent)
107
+ this._$baseMessageContent = [...this.children].find((child) => LIST_OF_MESSAGE_CONTENT_ELEMENTS.includes(child.tagName.toLowerCase()));
82
108
  this._setupEventListeners();
83
109
  }
110
+ firstUpdated(props) {
111
+ super.firstUpdated(props);
112
+ this._handleChildrenAriaAttributes();
113
+ }
84
114
  static _appendMessagePortal() {
85
115
  const $messagePortalTarget = document.querySelector(`[name="${DEFAULT_MESSAGE_PORTAL_NAME}"]`);
86
116
  if ($messagePortalTarget)
@@ -89,6 +119,22 @@ class BaseMessage extends PhoenixLightLitElement {
89
119
  $portalTarget.setAttribute(PORTAL_TARGET_NAME_PROP, DEFAULT_MESSAGE_PORTAL_NAME);
90
120
  document.body.appendChild($portalTarget);
91
121
  }
122
+ disconnectedCallback() {
123
+ var _a, _b;
124
+ super.disconnectedCallback();
125
+ (_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', this.open);
126
+ (_b = this._$baseMessageContent) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', this._handleClose);
127
+ }
128
+ render() {
129
+ var _a;
130
+ super.render();
131
+ return html `
132
+ <span class="sr-only" id="${this._messageId}">${DomUtils.stripHTMLTags(((_a = this._$baseMessageContent) === null || _a === void 0 ? void 0 : _a.innerHTML) || '')}</span>
133
+ <h-portal ?disabled="${!this.opened}" @open="${this._positionMessage}" to="${this.portalTarget}" hidden>
134
+ ${this.getSlot(MESSAGE_CONTENT_SLOT_NAME)}
135
+ </h-portal>
136
+ `;
137
+ }
92
138
  }
93
139
  __decorate([
94
140
  property({ type: Boolean, reflect: true }),
@@ -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,eAAe,qDAAyD;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;"}
@@ -7,3 +7,5 @@ export declare const MESSAGE_CONTENT_ELEMENTS: string[];
7
7
  export declare const MESSAGE_SHOW_DELAY_IN_MS = 100;
8
8
  export declare const MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = 500;
9
9
  export declare const MESSAGE_CLOSE_DELAY_IN_MS = 500;
10
+ export declare const LIST_OF_MESSAGE_CONTENT_ELEMENTS: string[];
11
+ export declare const LIST_OF_MESSAGE_CHILDREN: string[];
@@ -1,3 +1,4 @@
1
+ import { PORTAL_COMPONENT_NAME } from '../portal/portal_constants.js';
1
2
  import { HINT_CONTENT_ELEMENT_NAME } from './hints/hint_constants.js';
2
3
  import { TOOLTIP_CONTENT_ELEMENT_NAME } from './tooltips/tooltip_constants.js';
3
4
 
@@ -8,7 +9,9 @@ const DEFAULT_MESSAGE_OFFSET = 10;
8
9
  const MESSAGE_CONTENT_ELEMENTS = [TOOLTIP_CONTENT_ELEMENT_NAME, HINT_CONTENT_ELEMENT_NAME];
9
10
  const MESSAGE_SHOW_DELAY_IN_MS = 100;
10
11
  const MESSAGE_TIME_TO_DELAY_CLOSING_IN_MS = 500;
11
- const MESSAGE_CLOSE_DELAY_IN_MS = 500;
12
+ const MESSAGE_CLOSE_DELAY_IN_MS = 500;
13
+ const LIST_OF_MESSAGE_CONTENT_ELEMENTS = [TOOLTIP_CONTENT_ELEMENT_NAME, HINT_CONTENT_ELEMENT_NAME];
14
+ const LIST_OF_MESSAGE_CHILDREN = [...LIST_OF_MESSAGE_CONTENT_ELEMENTS, PORTAL_COMPONENT_NAME];
12
15
 
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 };
16
+ export { DEFAULT_MESSAGE_OFFSET, DEFAULT_MESSAGE_PORTAL_NAME, LIST_OF_MESSAGE_CHILDREN, LIST_OF_MESSAGE_CONTENT_ELEMENTS, 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 };
14
17
  //# 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;AACA;AACA;AACA;"}
@@ -16,7 +16,6 @@ class BaseMessageContent extends PhoenixLightLitElement {
16
16
  }
17
17
  _setupAriaAttributes() {
18
18
  this.setAttribute('role', 'tooltip');
19
- this.setAttribute('inert', '');
20
19
  }
21
20
  }
22
21
  __decorate([
@@ -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;"}
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;"}
@@ -1,4 +1,4 @@
1
1
  export interface IBaseMessage {
2
2
  open: () => void;
3
- close: () => void;
3
+ close: (shouldCloseImmediately?: boolean) => void;
4
4
  }
@@ -1,7 +1,5 @@
1
- import { TemplateResult } from 'lit-html';
2
1
  import { BaseMessage } from '../base_message';
3
2
  export declare class HHint extends BaseMessage {
4
3
  constructor();
5
4
  connectedCallback(): void;
6
- protected render(): TemplateResult;
7
5
  }
@@ -1,8 +1,6 @@
1
1
  import { __decorate, __metadata } from '../../../../../../external/tslib/tslib.es6.js';
2
2
  import { phoenixCustomElement } from '../../../core/decorators/phoenix_custom_element.js';
3
- import { html } from 'lit-html';
4
3
  import { HINT_DEFAULT_OFFSET, HINT_CLASS_NAME, HINT_ELEMENT_NAME } from './hint_constants.js';
5
- import { MESSAGE_CONTENT_SLOT_NAME } from '../base_message_constants.js';
6
4
  import { BaseMessage } from '../base_message.js';
7
5
 
8
6
  let HHint = class HHint extends BaseMessage {
@@ -14,14 +12,6 @@ let HHint = class HHint extends BaseMessage {
14
12
  super.connectedCallback(HINT_CLASS_NAME);
15
13
  this.classList.add(HINT_CLASS_NAME);
16
14
  }
17
- render() {
18
- super.render();
19
- return html `
20
- <h-portal ?disabled="${!this.opened}" @open="${this._positionMessage}" to="${this.portalTarget}" hidden>
21
- ${this.getSlot(MESSAGE_CONTENT_SLOT_NAME)}
22
- </h-portal>
23
- `;
24
- }
25
15
  };
26
16
  HHint = __decorate([
27
17
  phoenixCustomElement(HINT_ELEMENT_NAME),
@@ -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;"}
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;"}
@@ -1,6 +1,4 @@
1
- import { TemplateResult } from 'lit-html';
2
1
  import { BaseMessage } from '../base_message';
3
2
  export declare class HTooltip extends BaseMessage {
4
3
  connectedCallback(): void;
5
- protected render(): TemplateResult;
6
4
  }
@@ -1,8 +1,6 @@
1
1
  import { __decorate } from '../../../../../../external/tslib/tslib.es6.js';
2
2
  import { phoenixCustomElement } from '../../../core/decorators/phoenix_custom_element.js';
3
- import { html } from 'lit-html';
4
3
  import { TOOLTIP_CLASS_NAME, TOOLTIP_ELEMENT_NAME } from './tooltip_constants.js';
5
- import { MESSAGE_CONTENT_SLOT_NAME } from '../base_message_constants.js';
6
4
  import { BaseMessage } from '../base_message.js';
7
5
 
8
6
  let HTooltip = class HTooltip extends BaseMessage {
@@ -10,14 +8,6 @@ let HTooltip = class HTooltip extends BaseMessage {
10
8
  super.connectedCallback(TOOLTIP_CLASS_NAME);
11
9
  this.classList.add(TOOLTIP_CLASS_NAME);
12
10
  }
13
- render() {
14
- super.render();
15
- return html `
16
- <h-portal ?disabled="${!this.opened}" @open="${this._positionMessage}" to="${this.portalTarget}" hidden>
17
- ${this.getSlot(MESSAGE_CONTENT_SLOT_NAME)}
18
- </h-portal>
19
- `;
20
- }
21
11
  };
22
12
  HTooltip = __decorate([
23
13
  phoenixCustomElement(TOOLTIP_ELEMENT_NAME)
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,2BAA2B,+CAAmD;AAC9E;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,2BAA2B,+CAAmD;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -3,8 +3,9 @@ const PORTAL_EVENTS = {
3
3
  close: 'close'
4
4
  };
5
5
  const PORTAL_TARGET_NAME_PROP = 'name';
6
+ const PORTAL_COMPONENT_NAME = 'h-portal';
6
7
  const PORTAL_TARGET_COMPONENT_NAME = 'h-portal-target';
7
8
  const PORTAL_TARGET_ATTRIBUTE_NAME = 'portal-target';
8
9
 
9
- export { PORTAL_EVENTS, PORTAL_TARGET_ATTRIBUTE_NAME, PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP };
10
+ export { PORTAL_COMPONENT_NAME, PORTAL_EVENTS, PORTAL_TARGET_ATTRIBUTE_NAME, PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP };
10
11
  //# sourceMappingURL=portal_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;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,14 +1,10 @@
1
1
  import { Any } from 'ts-toolbelt';
2
- import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ import { ReactiveControllerHost } from 'lit';
3
3
  import { LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS } from "./list_box_controller_constants";
4
- import { HSelect } from "../../components/form/select/select";
5
4
  export declare type TListBoxKeyboardNavigationDirection = Any.Keys<typeof LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS>;
6
5
  export declare type TListBoxKeyboardControllerConstructorOptions = {
7
- host: ReactiveControllerHost & HSelect;
6
+ host: ReactiveControllerHost & HTMLElement;
8
7
  $list: HTMLElement;
9
8
  listItemSelector?: string;
10
9
  orientation?: TListBoxKeyboardNavigationDirection;
11
10
  };
12
- export interface IListboxController extends ReactiveController {
13
- calculateSelectedOptionIndex(): void;
14
- }
@@ -1,5 +1,4 @@
1
1
  import 'ts-toolbelt';
2
2
  import 'lit';
3
3
  import '@phoenixRoot/controllers/list_box_controller/list_box_controller_constants';
4
- import '@phoenixRoot/components/form/select/select';
5
4
  //# sourceMappingURL=list_box_controller_types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"list_box_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/list_box_controller/list_box_controller_types.ts"],"names":[],"mappings":"AAAA,OAAoB,aAAa,CAAC;AAClC,OAA2D,KAAK,CAAC;AACjE,OAAwD,4EAA4E,CAAC;AACrI,OAAwB,4CAA4C,CAAC"}
1
+ {"version":3,"file":"list_box_controller_types.js","sourceRoot":"","sources":["../../../../../../../src/controllers/list_box_controller/list_box_controller_types.ts"],"names":[],"mappings":"AAAA,OAAoB,aAAa,CAAC;AAClC,OAAuC,KAAK,CAAC;AAC7C,OAAwD,4EAA4E,CAAC"}
@@ -1,15 +1,10 @@
1
- import { IListboxController, TListBoxKeyboardControllerConstructorOptions } from "./list_box_controller_types";
2
- export declare class ListBoxKeyboardController implements IListboxController {
1
+ import { ReactiveController } from 'lit';
2
+ import { TListBoxKeyboardControllerConstructorOptions } from "./list_box_controller_types";
3
+ export declare class ListBoxKeyboardController implements ReactiveController {
3
4
  #private;
4
- currentOptionIndex: number | undefined;
5
5
  constructor({ host, $list, listItemSelector, orientation }: TListBoxKeyboardControllerConstructorOptions);
6
6
  hostConnected(): void;
7
- private _handleKeyboardNavigation;
8
7
  private _handleArrowNavigation;
9
- private _findCurrentIndex;
10
- private _handleWriteableCharacter;
11
- calculateSelectedOptionIndex: () => void;
12
8
  private _getPrevOptionIndex;
13
9
  private _getNextOptionIndex;
14
- hostDisconnected(): void;
15
10
  }
@@ -1,64 +1,37 @@
1
1
  import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../../../external/tslib/tslib.es6.js';
2
2
  import 'lit';
3
3
  import { UiDomUtils } from '@dreamcommerce/utilities';
4
+ import { KeystrokesController } from '../keystrokes_controller/keystrokes_controller.js';
4
5
  import { LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS } from './list_box_controller_constants.js';
5
6
 
6
- var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
7
+ var _ListBoxKeyboardController_host, _ListBoxKeyboardController__$list, _ListBoxKeyboardController_currentOptionIndex, _ListBoxKeyboardController__$options, _ListBoxKeyboardController_listItemSelector, _ListBoxKeyboardController_keys;
7
8
  class ListBoxKeyboardController {
8
9
  constructor({ host, $list, listItemSelector = '[role="option"]', orientation = LIST_BOX_KEYBOARD_NAVIGATION_DIRECTIONS.vertical }) {
9
10
  _ListBoxKeyboardController_host.set(this, void 0);
10
11
  _ListBoxKeyboardController__$list.set(this, void 0);
12
+ _ListBoxKeyboardController_currentOptionIndex.set(this, void 0);
11
13
  _ListBoxKeyboardController__$options.set(this, void 0);
12
14
  _ListBoxKeyboardController_listItemSelector.set(this, void 0);
13
15
  _ListBoxKeyboardController_keys.set(this, void 0);
14
- this._handleKeyboardNavigation = (ev) => {
15
- if (__classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f").find((key) => key === ev.key)) {
16
- this._handleArrowNavigation(ev);
17
- return;
18
- }
19
- this._handleWriteableCharacter(ev);
20
- };
21
16
  this._handleArrowNavigation = (event) => {
22
17
  event.preventDefault();
23
18
  const { key } = event;
24
- const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
25
- return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
26
- });
27
- const prevOptionIndex = this._findCurrentIndex();
19
+ const prevOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
28
20
  let newOptionIndex = key === 'ArrowDown' || key === 'ArrowRight' ? this._getNextOptionIndex() : this._getPrevOptionIndex();
29
21
  if (newOptionIndex === undefined) {
30
- newOptionIndex = this._findCurrentIndex();
22
+ const selectedOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
23
+ newOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
31
24
  }
32
- if (newOptionIndex === this.currentOptionIndex)
25
+ if (newOptionIndex === __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f"))
33
26
  return;
34
27
  if (prevOptionIndex !== undefined) {
35
28
  const $prevOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[prevOptionIndex];
36
- $prevOption && UiDomUtils.makeUnnavigable($prevOption);
29
+ UiDomUtils.makeUnnavigable($prevOption);
37
30
  }
38
- this.currentOptionIndex = newOptionIndex;
39
- const $focusedOption = $availableOptions[newOptionIndex];
40
- if ($focusedOption) {
41
- UiDomUtils.makeNavigable($focusedOption);
42
- $focusedOption.focus();
43
- }
44
- };
45
- this._findCurrentIndex = () => {
46
- const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
47
- return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
48
- });
49
- const selectedOptionIndex = $availableOptions.findIndex(($option) => $option.selected);
50
- return selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
51
- };
52
- this._handleWriteableCharacter = (ev) => {
53
- var _a;
54
- const $searchInput = (_a = __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").$search.value) === null || _a === void 0 ? void 0 : _a.querySelector('[role="search"]');
55
- if (!$searchInput)
56
- return;
57
- $searchInput === null || $searchInput === void 0 ? void 0 : $searchInput.focus();
58
- };
59
- this.calculateSelectedOptionIndex = () => {
60
- const selectedOptionIndex = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").findIndex(($option) => $option.selected);
61
- this.currentOptionIndex = selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
31
+ __classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, newOptionIndex, "f");
32
+ const $focusedOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[newOptionIndex];
33
+ UiDomUtils.makeNavigable($focusedOption);
34
+ $focusedOption.focus();
62
35
  };
63
36
  __classPrivateFieldSet(this, _ListBoxKeyboardController_host, host, "f");
64
37
  __classPrivateFieldSet(this, _ListBoxKeyboardController__$list, $list, "f");
@@ -68,59 +41,40 @@ class ListBoxKeyboardController {
68
41
  __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f").addController(this);
69
42
  }
70
43
  hostConnected() {
71
- __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('keydown', this._handleKeyboardNavigation);
44
+ new KeystrokesController({
45
+ host: __classPrivateFieldGet(this, _ListBoxKeyboardController_host, "f"),
46
+ keys: __classPrivateFieldGet(this, _ListBoxKeyboardController_keys, "f"),
47
+ callback: this._handleArrowNavigation,
48
+ target: __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f")
49
+ });
72
50
  UiDomUtils.makeNavigable(__classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"));
73
51
  __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").addEventListener('focusin', (event) => {
74
52
  if (event.target !== __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f"))
75
53
  return;
76
- if (this.currentOptionIndex === undefined)
54
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
77
55
  return;
78
- const $prevOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[this.currentOptionIndex];
56
+ const $prevOption = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f")[__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f")];
79
57
  UiDomUtils.makeUnnavigable($prevOption);
80
- this.currentOptionIndex = undefined;
58
+ __classPrivateFieldSet(this, _ListBoxKeyboardController_currentOptionIndex, undefined, "f");
81
59
  });
82
60
  __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").forEach(($option) => UiDomUtils.makeUnnavigable($option));
83
61
  }
84
62
  _getPrevOptionIndex() {
85
- if (this.currentOptionIndex === undefined)
63
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
86
64
  return undefined;
87
- if (this.currentOptionIndex <= 0)
88
- return this.currentOptionIndex;
89
- if (this.currentOptionIndex <= 0)
90
- return this.currentOptionIndex;
91
- const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
92
- return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
93
- });
94
- if (!!$availableOptions[this.currentOptionIndex - 1])
95
- return this.currentOptionIndex - 1;
96
- // bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
97
- const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
98
- if (newIndexOfCurrentlySelectedOption)
99
- return newIndexOfCurrentlySelectedOption - 1;
100
- return this.currentOptionIndex - 1;
65
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") <= 0)
66
+ return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
67
+ return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") - 1;
101
68
  }
102
69
  _getNextOptionIndex() {
103
- if (this.currentOptionIndex === undefined)
70
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") === undefined)
104
71
  return undefined;
105
- const $availableOptions = __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").filter(($option) => {
106
- return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
107
- });
108
- if (this.currentOptionIndex === $availableOptions.length - 1)
109
- return this.currentOptionIndex;
110
- if (this.currentOptionIndex > $availableOptions.length - 1) {
111
- // bo ktoś wpisał coś w searcha i index obecnie wybranej opcji jest inny
112
- const newIndexOfCurrentlySelectedOption = $availableOptions.findIndex(($option) => $option.selected);
113
- if (newIndexOfCurrentlySelectedOption)
114
- return newIndexOfCurrentlySelectedOption + 1;
115
- return 0;
116
- }
117
- return this.currentOptionIndex + 1;
118
- }
119
- hostDisconnected() {
120
- __classPrivateFieldGet(this, _ListBoxKeyboardController__$list, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
72
+ if (__classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") >= __classPrivateFieldGet(this, _ListBoxKeyboardController__$options, "f").length - 1)
73
+ return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f");
74
+ return __classPrivateFieldGet(this, _ListBoxKeyboardController_currentOptionIndex, "f") + 1;
121
75
  }
122
76
  }
123
- _ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
77
+ _ListBoxKeyboardController_host = new WeakMap(), _ListBoxKeyboardController__$list = new WeakMap(), _ListBoxKeyboardController_currentOptionIndex = new WeakMap(), _ListBoxKeyboardController__$options = new WeakMap(), _ListBoxKeyboardController_listItemSelector = new WeakMap(), _ListBoxKeyboardController_keys = new WeakMap();
124
78
 
125
79
  export { ListBoxKeyboardController };
126
80
  //# sourceMappingURL=list_box_keyboard_controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,+DAA+D,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@shoper/phoenix_design_system",
3
3
  "packageManager": "yarn@3.2.0",
4
4
  "sideEffects": false,
5
- "version": "1.15.11-3",
5
+ "version": "1.15.11-30",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",
@@ -22,7 +22,7 @@
22
22
  "storybook": "NODE_OPTIONS=--openssl-legacy-provider && start-storybook --no-open --port 6007",
23
23
  "build": "rimraf ./build/ && tsc --project tsconfig.build.json && rollup --config rollup.config.js",
24
24
  "watch": "rollup --config rollup.config.js --watch",
25
- "tests:unit": "jest --max-workers=1 -c .config/jest/jest.config.js",
25
+ "tests:unit": "jest --max-workers=1 -c .config/jest/jest.config.js -- hint",
26
26
  "watch:tests:unit": "jest --watch -c .config/jest/jest.config.js"
27
27
  },
28
28
  "peerDependencies": {
@@ -30,7 +30,7 @@
30
30
  "@splidejs/splide": "^4.0.7"
31
31
  },
32
32
  "devDependencies": {
33
- "@dreamcommerce/utilities": "^1.20.1",
33
+ "@dreamcommerce/utilities": "^1.20.1-2",
34
34
  "@shoper/jest_config": "^0.0.0",
35
35
  "@shoper/tsconfig": "^0.0.0",
36
36
  "@splidejs/splide": "4.0.7",
@@ -1,96 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var tslib_es6 = require('../../../../../../../../external/tslib/tslib.es6.js');
6
- require('lit');
7
- var utilities = require('@dreamcommerce/utilities');
8
-
9
- var _SelectTogglerKeyboardController_host, _SelectTogglerKeyboardController__$toggler, _SelectTogglerKeyboardController_currentOptionIndex, _SelectTogglerKeyboardController__$options;
10
- class SelectTogglerKeyboardController {
11
- constructor({ host, $toggler, $list, listItemSelector = '[role="option"]', }) {
12
- _SelectTogglerKeyboardController_host.set(this, void 0);
13
- _SelectTogglerKeyboardController__$toggler.set(this, void 0);
14
- _SelectTogglerKeyboardController_currentOptionIndex.set(this, void 0);
15
- _SelectTogglerKeyboardController__$options.set(this, void 0);
16
- this._handleKeyboardNavigation = (ev) => {
17
- const arrowKeys = ['ArrowUp', 'ArrowDown'];
18
- if (arrowKeys.includes(ev.key)) {
19
- this._openSelect(ev);
20
- return;
21
- }
22
- if (ev.key === 'Home') {
23
- this._openSelectAndGoToFirstElement(ev);
24
- return;
25
- }
26
- if (ev.key === 'End') {
27
- this._openSelectAndGoToLastElement(ev);
28
- return;
29
- }
30
- const isAWriteableCharacter = ev.key.length === 1;
31
- if (isAWriteableCharacter)
32
- this._openSelectAndGoToMatchedElement(ev);
33
- };
34
- this._openSelect = (event) => {
35
- var _a;
36
- event.preventDefault();
37
- (_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show();
38
- };
39
- this._openSelectAndGoToFirstElement = async (event) => {
40
- var _a;
41
- event.preventDefault();
42
- await ((_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
43
- const $firstOption = this._getAvailableOptions()[0];
44
- if ($firstOption)
45
- this._navigate($firstOption);
46
- };
47
- this._openSelectAndGoToLastElement = async (event) => {
48
- var _a;
49
- event.preventDefault();
50
- await ((_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
51
- const $availableOptions = this._getAvailableOptions();
52
- const $lastOption = $availableOptions[$availableOptions.length - 1];
53
- if ($lastOption)
54
- this._navigate($lastOption);
55
- };
56
- this._openSelectAndGoToMatchedElement = async (event) => {
57
- var _a;
58
- event.preventDefault();
59
- await ((_a = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").$dropdown.value) === null || _a === void 0 ? void 0 : _a.show());
60
- const $matchedOption = this._getAvailableOptions().find(($option) => { var _a; return (_a = $option.innerText) === null || _a === void 0 ? void 0 : _a.toLowerCase().startsWith(event.key.toLowerCase()); });
61
- if ($matchedOption)
62
- this._navigate($matchedOption);
63
- };
64
- this._getAvailableOptions = () => {
65
- return tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$options, "f").filter(($option) => {
66
- return !$option.getAttribute('inactive') && !$option.getAttribute('disabled') && !$option.hidden;
67
- });
68
- };
69
- this._findSelectedIndex = () => {
70
- const selectedOptionIndex = this._getAvailableOptions().findIndex(($option) => $option.selected);
71
- return selectedOptionIndex !== -1 ? selectedOptionIndex : 0;
72
- };
73
- this._navigate = ($newOption) => {
74
- const $selectedOption = tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$options, "f")[this._findSelectedIndex()];
75
- utilities.UiDomUtils.makeUnnavigable($selectedOption);
76
- const newOptionIndex = this._getAvailableOptions().findIndex(($option) => $newOption.value === $option.value);
77
- tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").listBoxController.currentOptionIndex = newOptionIndex;
78
- utilities.UiDomUtils.makeNavigable($newOption);
79
- $newOption.focus();
80
- };
81
- tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController_host, host, "f");
82
- tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$toggler, $toggler, "f");
83
- tslib_es6.__classPrivateFieldSet(this, _SelectTogglerKeyboardController__$options, Array.from($list.querySelectorAll(listItemSelector)), "f");
84
- tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController_host, "f").addController(this);
85
- }
86
- hostConnected() {
87
- tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").addEventListener('keydown', this._handleKeyboardNavigation);
88
- }
89
- hostDisconnected() {
90
- tslib_es6.__classPrivateFieldGet(this, _SelectTogglerKeyboardController__$toggler, "f").removeEventListener('keydown', this._handleKeyboardNavigation);
91
- }
92
- }
93
- _SelectTogglerKeyboardController_host = new WeakMap(), _SelectTogglerKeyboardController__$toggler = new WeakMap(), _SelectTogglerKeyboardController_currentOptionIndex = new WeakMap(), _SelectTogglerKeyboardController__$options = new WeakMap();
94
-
95
- exports.SelectTogglerKeyboardController = SelectTogglerKeyboardController;
96
- //# sourceMappingURL=select_toggler_keyboard_controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,qDAAyD;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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 +0,0 @@
1
- import { TSelectTogglerKeyboardControllerConstructorOptions } from './select_toggler_keyboard_controller_types';
2
- export declare class SelectTogglerKeyboardController {
3
- #private;
4
- constructor({ host, $toggler, $list, listItemSelector, }: TSelectTogglerKeyboardControllerConstructorOptions);
5
- hostConnected(): void;
6
- private _handleKeyboardNavigation;
7
- private _openSelect;
8
- private _openSelectAndGoToFirstElement;
9
- private _openSelectAndGoToLastElement;
10
- private _openSelectAndGoToMatchedElement;
11
- private _getAvailableOptions;
12
- private _findSelectedIndex;
13
- private _navigate;
14
- hostDisconnected(): void;
15
- }