q2-tecton-elements 1.27.0 → 1.27.2

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 (58) hide show
  1. package/dist/cjs/{action-sheet-4b366e9a.js → action-sheet-ab1abf24.js} +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/q2-avatar.cjs.entry.js +1 -1
  4. package/dist/cjs/q2-dropdown.cjs.entry.js +1 -0
  5. package/dist/cjs/q2-option-list_2.cjs.entry.js +9 -7
  6. package/dist/cjs/q2-pill.cjs.entry.js +28 -23
  7. package/dist/cjs/q2-select.cjs.entry.js +6 -3
  8. package/dist/cjs/q2-tag.cjs.entry.js +18 -13
  9. package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
  10. package/dist/collection/components/q2-avatar/styles.css +4 -12
  11. package/dist/collection/components/q2-dropdown/index.js +19 -0
  12. package/dist/collection/components/q2-option-list/index.js +33 -27
  13. package/dist/collection/components/q2-pill/index.js +63 -23
  14. package/dist/collection/components/q2-popover/styles.css +2 -3
  15. package/dist/collection/components/q2-select/index.js +5 -2
  16. package/dist/collection/components/q2-tag/index.js +55 -14
  17. package/dist/collection/utils/action-sheet.js +1 -1
  18. package/dist/components/action-sheet.js +1 -1
  19. package/dist/components/index13.js +10 -8
  20. package/dist/components/index14.js +1 -1
  21. package/dist/components/index3.js +1 -1
  22. package/dist/components/q2-dropdown.js +2 -0
  23. package/dist/components/q2-pill.js +30 -23
  24. package/dist/components/q2-select.js +5 -2
  25. package/dist/components/q2-tag.js +21 -14
  26. package/dist/docs.json +120 -20
  27. package/dist/esm/{action-sheet-a9597b32.js → action-sheet-bfcbe154.js} +1 -1
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/esm/q2-avatar.entry.js +1 -1
  30. package/dist/esm/q2-dropdown.entry.js +1 -0
  31. package/dist/esm/q2-option-list_2.entry.js +10 -8
  32. package/dist/esm/q2-pill.entry.js +28 -23
  33. package/dist/esm/q2-select.entry.js +6 -3
  34. package/dist/esm/q2-tag.entry.js +19 -14
  35. package/dist/esm/q2-tecton-elements.js +1 -1
  36. package/dist/q2-tecton-elements/{p-414ca427.entry.js → p-31b655b6.entry.js} +1 -1
  37. package/dist/q2-tecton-elements/p-788adb51.js +1 -0
  38. package/dist/q2-tecton-elements/p-8fd3b580.entry.js +1 -0
  39. package/dist/q2-tecton-elements/p-a300d517.entry.js +1 -0
  40. package/dist/q2-tecton-elements/p-c1d33fd2.entry.js +1 -0
  41. package/dist/q2-tecton-elements/p-ceabfa93.entry.js +1 -0
  42. package/dist/q2-tecton-elements/p-dd1115c6.entry.js +1 -0
  43. package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
  44. package/dist/test/helpers.js +19 -0
  45. package/dist/types/components/q2-dropdown/index.d.ts +1 -0
  46. package/dist/types/components/q2-option-list/index.d.ts +5 -1
  47. package/dist/types/components/q2-pill/index.d.ts +5 -2
  48. package/dist/types/components/q2-select/index.d.ts +1 -1
  49. package/dist/types/components/q2-tag/index.d.ts +5 -2
  50. package/dist/types/components.d.ts +20 -2
  51. package/dist/types/workspace/workspace/{Tecton_tecton-production_master → tecton-production_release_1.27.x}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +1 -0
  52. package/package.json +3 -3
  53. package/dist/q2-tecton-elements/p-04b9a7ee.entry.js +0 -1
  54. package/dist/q2-tecton-elements/p-521c9085.entry.js +0 -1
  55. package/dist/q2-tecton-elements/p-8e652d59.entry.js +0 -1
  56. package/dist/q2-tecton-elements/p-a1926e65.js +0 -1
  57. package/dist/q2-tecton-elements/p-aae8b9fc.entry.js +0 -1
  58. package/dist/q2-tecton-elements/p-ce67d77a.entry.js +0 -1
@@ -1,4 +1,4 @@
1
- import { h, Host, } from '@stencil/core';
1
+ import { h, Host, Fragment, } from '@stencil/core';
2
2
  import { isEventFromElement, loc, overrideFocus } from 'src/utils';
3
3
  import { shouldShowActionSheet, showActionSheetList } from 'src/utils/action-sheet';
4
4
  export class Q2Tag {
@@ -6,9 +6,9 @@ export class Q2Tag {
6
6
  var _a;
7
7
  /// Getters ///
8
8
  /// Helpers
9
- this.determineHasOptions = () => {
10
- const hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
11
- this.hasOptions = hasOptions;
9
+ this.determineOptionCount = () => {
10
+ const numberOfOptions = this.hostElement.querySelectorAll('q2-option').length;
11
+ this.optionCount = numberOfOptions;
12
12
  };
13
13
  /// Event Handlers ///
14
14
  this.onClickElsewhere = (event) => {
@@ -23,7 +23,7 @@ export class Q2Tag {
23
23
  };
24
24
  this.handleChange = event => {
25
25
  event.stopPropagation();
26
- if (!this.hasOptions)
26
+ if (!this.optionCount)
27
27
  return;
28
28
  const { value } = event.detail;
29
29
  this.click.emit({ value });
@@ -36,7 +36,7 @@ export class Q2Tag {
36
36
  this.click.emit({ value });
37
37
  }
38
38
  else {
39
- this.popoverElement.toggle();
39
+ await this.popoverElement.toggle();
40
40
  }
41
41
  };
42
42
  this.handleKeydown = async (event) => {
@@ -70,11 +70,13 @@ export class Q2Tag {
70
70
  this.theme = undefined;
71
71
  this.popoverMinHeight = 150;
72
72
  this.popoverDirection = undefined;
73
- this.hasOptions = undefined;
73
+ this.popoverAlignment = 'right';
74
+ this.optionListLabel = 'options';
75
+ this.optionCount = undefined;
74
76
  }
75
77
  /// LifeCycle Hooks ///
76
78
  componentWillLoad() {
77
- const observer = new MutationObserver(this.determineHasOptions);
79
+ const observer = new MutationObserver(this.determineOptionCount);
78
80
  observer.observe(this.hostElement, { childList: true, attributes: true });
79
81
  this.mutationObserver = observer;
80
82
  }
@@ -89,7 +91,7 @@ export class Q2Tag {
89
91
  delegateFocus(event) {
90
92
  if (!isEventFromElement(event, this.hostElement))
91
93
  return;
92
- if (!this.hasOptions)
94
+ if (!this.optionCount)
93
95
  return;
94
96
  this.dropdownBtn.focus();
95
97
  }
@@ -101,12 +103,15 @@ export class Q2Tag {
101
103
  this.optionList.setActiveElement(null);
102
104
  }
103
105
  /// DOM ///
106
+ generateHiddenElement() {
107
+ return (h("div", { id: "option-description", class: "sr", "aria-hidden": "true" }, loc('tecton.element.optionList.optionCount', [this.optionCount])));
108
+ }
104
109
  render() {
105
- const { hasOptions, open } = this;
106
- const wrapperClassNames = ['tag-wrapper'];
107
- if (hasOptions)
110
+ const { optionCount, open } = this;
111
+ const wrapperClassNames = ['tag'];
112
+ if (optionCount)
108
113
  wrapperClassNames.push('has-options');
109
- return (h(Host, { role: "listitem" }, h("click-elsewhere", { onChange: this.onClickElsewhere }, h("div", { class: wrapperClassNames.join(' '), onClick: e => e.stopPropagation() }, h("div", { class: "tag" }, this.label), this.hasOptions && (h("div", { class: "btn-wrapper", onClick: this.handleWrapperClick }, h("button", { ref: el => (this.dropdownBtn = el), "test-id": "btn-control", onClick: this.handleClick, onKeyDown: this.handleKeydown, onFocusout: this.handleButtonFocusout, "aria-controls": "option-list", "aria-haspopup": "true", "aria-expanded": open ? 'true' : 'false', "aria-label": loc('tecton.element.tag.viewOptions') }, h("q2-icon", { type: "options" }))))), this.hasOptions && (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.dropdownBtn, open: this.open, minHeight: this.popoverMinHeight, direction: this.popoverDirection, align: "right" }, h("q2-option-list", { id: "option-list", role: "menu", ref: el => (this.optionList = el), onChange: this.handleChange, align: "right", type: "menu", "no-select": true }, h("slot", null)))))));
114
+ return (h(Host, { role: "listitem" }, h("click-elsewhere", { onChange: this.onClickElsewhere }, this.optionCount ? (h(Fragment, null, h("div", { class: "btn-wrapper", onClick: this.handleWrapperClick }, h("button", { class: "tag-wrapper", ref: el => (this.dropdownBtn = el), "test-id": "btn-control", type: "button", role: "combobox", onClick: this.handleClick, onKeyDown: this.handleKeydown, onFocusout: this.handleButtonFocusout, "aria-controls": "option-list", "aria-expanded": open ? 'true' : 'false', "aria-describedby": "option-description" }, h("div", { class: wrapperClassNames.join(' ') }, this.label), h("q2-icon", { type: "options" }))), this.generateHiddenElement())) : (h("div", { class: "tag-wrapper", onClick: e => e.stopPropagation() }, h("div", { class: wrapperClassNames.join(' ') }, this.label))), this.optionCount && (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.dropdownBtn, open: this.open, minHeight: this.popoverMinHeight, direction: this.popoverDirection, align: "right" }, h("q2-option-list", { id: "option-list", ref: el => (this.optionList = el), onChange: this.handleChange, type: "menu", align: "right", label: loc('tecton.element.optionList.label', [this.optionListLabel]), "no-select": true }, h("slot", null)))))));
110
115
  }
111
116
  static get is() { return "q2-tag"; }
112
117
  static get encapsulation() { return "shadow"; }
@@ -225,12 +230,48 @@ export class Q2Tag {
225
230
  },
226
231
  "attribute": "popover-direction",
227
232
  "reflect": false
233
+ },
234
+ "popoverAlignment": {
235
+ "type": "string",
236
+ "mutable": true,
237
+ "complexType": {
238
+ "original": "'left' | 'right'",
239
+ "resolved": "\"left\" | \"right\"",
240
+ "references": {}
241
+ },
242
+ "required": false,
243
+ "optional": false,
244
+ "docs": {
245
+ "tags": [],
246
+ "text": ""
247
+ },
248
+ "attribute": "popover-alignment",
249
+ "reflect": false,
250
+ "defaultValue": "'right'"
251
+ },
252
+ "optionListLabel": {
253
+ "type": "string",
254
+ "mutable": false,
255
+ "complexType": {
256
+ "original": "string",
257
+ "resolved": "string",
258
+ "references": {}
259
+ },
260
+ "required": false,
261
+ "optional": false,
262
+ "docs": {
263
+ "tags": [],
264
+ "text": ""
265
+ },
266
+ "attribute": "option-list-label",
267
+ "reflect": false,
268
+ "defaultValue": "'options'"
228
269
  }
229
270
  };
230
271
  }
231
272
  static get states() {
232
273
  return {
233
- "hasOptions": {}
274
+ "optionCount": {}
234
275
  };
235
276
  }
236
277
  static get events() {
@@ -6,7 +6,7 @@ export const shouldShowActionSheet = (component, event) => {
6
6
  const canShowActionSheet = !!((_a = window.TectonElements) === null || _a === void 0 ? void 0 : _a.showActionSheet);
7
7
  if (!canShowActionSheet)
8
8
  return false;
9
- const keysThatTriggerOpen = ['ArrowDown', 'ArrowUp', 'PageDown', 'PageUp', 'Home', 'End'];
9
+ const keysThatTriggerOpen = ['ArrowDown', 'ArrowUp', 'PageDown', 'PageUp', 'Home', 'End', 'Enter', ' '];
10
10
  if (event) {
11
11
  const eventIsKeyboardEvent = event instanceof KeyboardEvent;
12
12
  const eventIsMouseEvent = event instanceof MouseEvent;
@@ -6,7 +6,7 @@ const shouldShowActionSheet = (component, event) => {
6
6
  const canShowActionSheet = !!((_a = window.TectonElements) === null || _a === void 0 ? void 0 : _a.showActionSheet);
7
7
  if (!canShowActionSheet)
8
8
  return false;
9
- const keysThatTriggerOpen = ['ArrowDown', 'ArrowUp', 'PageDown', 'PageUp', 'Home', 'End'];
9
+ const keysThatTriggerOpen = ['ArrowDown', 'ArrowUp', 'PageDown', 'PageUp', 'Home', 'End', 'Enter', ' '];
10
10
  if (event) {
11
11
  const eventIsKeyboardEvent = event instanceof KeyboardEvent;
12
12
  const eventIsMouseEvent = event instanceof MouseEvent;
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { o as overrideFocus, w as waitForNextPaint, n as nextPaint, a as isEventFromElement } from './index15.js';
2
+ import { n as nextPaint, l as loc, o as overrideFocus, w as waitForNextPaint, a as isEventFromElement } from './index15.js';
3
3
 
4
4
  const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-double-focus-ring, 0 0 0 2px #ffffff, 0 0 0 4px #33b4ff #06C)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit;font-stretch:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}:host{position:relative;width:100%;display:block;line-height:var(--tct-option-list-line-height, var(--t-option-list-line-height, var(--app-line-height, 1.428571429em)))}.content{text-align:start}:host([is-sizeable]) .content{display:block;height:auto}";
5
5
 
@@ -77,21 +77,23 @@ const Q2OptionList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
77
77
  this.searchOptions(key, true);
78
78
  break;
79
79
  }
80
- else if (this.role === 'menu') {
80
+ else if (this.type === 'menu') {
81
81
  this.activeIndex = 0;
82
82
  this.openDropdownWithActiveElement(0);
83
83
  }
84
84
  else {
85
85
  this.setDefaultActiveElement();
86
+ nextPaint(() => this.popoverState.emit({ open: true, action: 'open' }));
86
87
  }
87
88
  break;
88
89
  case 'Enter':
89
- if (this.role === 'menu') {
90
+ if (this.type === 'menu') {
90
91
  this.activeIndex = 0;
91
92
  this.openDropdownWithActiveElement(0);
92
93
  }
93
94
  else {
94
95
  this.setDefaultActiveElement();
96
+ nextPaint(() => this.popoverState.emit({ open: true, action: 'open' }));
95
97
  }
96
98
  break;
97
99
  case 'ArrowUp':
@@ -221,7 +223,7 @@ const Q2OptionList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
221
223
  case 'Tab':
222
224
  if (shiftKey)
223
225
  break;
224
- if (this.multiple && this.role === 'listbox')
226
+ if (this.multiple && this.type === 'listbox')
225
227
  break;
226
228
  newOption = allOptions.find(element => element.active);
227
229
  if (!newOption || newOption.disabled)
@@ -257,7 +259,6 @@ const Q2OptionList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
257
259
  const option = target.closest('q2-option');
258
260
  this.selectOption(option);
259
261
  };
260
- this.role = 'listbox';
261
262
  this.customSearch = undefined;
262
263
  this.noSelect = undefined;
263
264
  this.align = undefined;
@@ -265,7 +266,8 @@ const Q2OptionList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
265
266
  this.multiple = undefined;
266
267
  this.disabled = undefined;
267
268
  this.showSelected = undefined;
268
- this.type = undefined;
269
+ this.type = 'listbox';
270
+ this.label = loc('tecton.element.optionList.label');
269
271
  this.hasOptions = undefined;
270
272
  }
271
273
  /// LifeCycle Hooks ///
@@ -527,7 +529,7 @@ const Q2OptionList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
527
529
  }
528
530
  /// DOM ///
529
531
  render() {
530
- return (h(Host, null, h("div", { class: "content", ref: el => (this.contentElement = el), onFocusout: this.focusoutHandler }, h("div", { class: "options", role: this.type || 'listbox', onKeyDown: this.internalKeydownHandler, onClick: this.clickHandler }, h("slot", null)))));
532
+ return (h(Host, null, h("div", { class: "content", ref: el => (this.contentElement = el), onFocusout: this.focusoutHandler }, h("div", { class: "options", "aria-label": loc('tecton.element.optionList.label', [this.label]), role: this.type || 'listbox', onKeyDown: this.internalKeydownHandler, onClick: this.clickHandler }, h("slot", null)))));
531
533
  }
532
534
  get hostElement() { return this; }
533
535
  static get watchers() { return {
@@ -536,7 +538,6 @@ const Q2OptionList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
536
538
  }; }
537
539
  static get style() { return stylesCss; }
538
540
  }, [1, "q2-option-list", {
539
- "role": [513],
540
541
  "customSearch": [516, "custom-search"],
541
542
  "noSelect": [516, "no-select"],
542
543
  "align": [513],
@@ -545,6 +546,7 @@ const Q2OptionList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
545
546
  "disabled": [516],
546
547
  "showSelected": [1540, "show-selected"],
547
548
  "type": [1],
549
+ "label": [1],
548
550
  "hasOptions": [32],
549
551
  "setDefaultActiveElement": [64],
550
552
  "setActiveElement": [64],
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { r as resizeIframe, w as waitForNextPaint } from './index15.js';
3
3
 
4
- const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-double-focus-ring, 0 0 0 2px #ffffff, 0 0 0 4px #33b4ff #06C)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit;font-stretch:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}:host{display:block;width:100%}:host([align=right]){display:block;position:absolute;right:0;text-align:end;left:unset}.container{display:none;overflow:hidden;opacity:0;height:0;position:absolute;top:var(--tct-popover-top, var(--t-popover-top, initial));visibility:hidden;background-color:var(--tct-popover-background-color, var(--t-popover-background-color, var(--app-white, #ffffff)));color:var(--tct-popover-text-color, var(--t-popover-text-color, var(--t-text, #4d4d4d)));z-index:var(--tct-popover-z-index, var(--t-popover-z-index, 100));width:max-content;min-width:var(--tct-popover-min-width, var(--t-popover-min-width, 135px));box-shadow:var(--tct-popover-box-shadow, var(--t-popover-box-shadow, var(--app-shadow-1, 0 2px 4px rgba(0, 0, 0, 0.3))));text-align:start;left:0;transition:opacity var(--app-tween-1, 0.2s ease), max-height var(--app-tween-1, 0.2s ease);border-radius:var(--tct-popover-border-radius, var(--t-popover-border-radius, 0));max-height:var(--comp-pop-max-height);--comp-scrollbar-size:var(--tct-scrollbar-size, var(--t-scrollbar-size, var(--app-scale-1x, 5px)));--comp-scrollbar-border-radius:var(--tct-scrollbar-border-radius, var(--t-scrollbar-border-radius, var(--app-border-radius-1, 3px)));--comp-scrollbar-color:var(--tct-scrollbar-color, var(--t-scrollbar-color, var(--t-a11y-gray-color, #747474)));scrollbar-width:thin;scrollbar-color:var(--comp-scrollbar-color) transparent}.container::-webkit-scrollbar{width:var(--comp-scrollbar-size);height:var(--comp-scrollbar-size);margin:5px}.container::-webkit-scrollbar-thumb{background:var(--comp-scrollbar-color);border-radius:var(--comp-scrollbar-border-radius)}.container::-webkit-scrollbar-track{background:transparent;border-radius:var(--comp-scrollbar-border-radius)}:host([block]) .container{left:unset;right:unset;width:100%;min-width:unset}:host([align=right]) .container{right:0;text-align:end;left:unset}.container :host([open]){display:block}:host([open]) .container.show{height:auto;overflow:auto;opacity:1;visibility:visible}.container.up{bottom:var(--comp-pop-offset)}click-elsewhere{position:relative;display:block}.content{height:auto}";
4
+ const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-double-focus-ring, 0 0 0 2px #ffffff, 0 0 0 4px #33b4ff #06C)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit;font-stretch:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}:host{display:block;width:100%}:host([align=right]){display:block;position:absolute;right:0;text-align:end;left:unset}.container{display:none;overflow:hidden;opacity:0;height:0;position:absolute;top:var(--tct-popover-top, var(--t-popover-top, initial));visibility:hidden;background-color:var(--tct-popover-background-color, var(--t-popover-background-color, var(--app-white, #ffffff)));color:var(--tct-popover-text-color, var(--t-popover-text-color, var(--t-text, #4d4d4d)));z-index:var(--tct-popover-z-index, var(--t-popover-z-index, 100));width:max-content;min-width:var(--tct-popover-min-width, var(--t-popover-min-width, 135px));box-shadow:var(--tct-popover-box-shadow, var(--t-popover-box-shadow, var(--app-shadow-1, 0 2px 4px rgba(0, 0, 0, 0.3))));text-align:start;left:0;transition:opacity var(--app-tween-1, 0.2s ease), max-height var(--app-tween-1, 0.2s ease);border-radius:var(--tct-popover-border-radius, var(--t-popover-border-radius, 0));max-height:var(--comp-pop-max-height);--comp-scrollbar-size:var(--tct-scrollbar-size, var(--t-scrollbar-size, var(--app-scale-1x, 5px)));--comp-scrollbar-border-radius:var(--tct-scrollbar-border-radius, var(--t-scrollbar-border-radius, var(--app-border-radius-1, 3px)));--comp-scrollbar-color:var(--tct-scrollbar-color, var(--t-scrollbar-color, var(--t-a11y-gray-color, #747474)));scrollbar-width:thin;scrollbar-color:var(--comp-scrollbar-color) transparent}.container::-webkit-scrollbar{width:var(--comp-scrollbar-size);height:var(--comp-scrollbar-size);margin:5px}.container::-webkit-scrollbar-thumb{background:var(--comp-scrollbar-color);border-radius:var(--comp-scrollbar-border-radius)}.container::-webkit-scrollbar-track{background:transparent;border-radius:var(--comp-scrollbar-border-radius)}:host([block]) .container{left:unset;right:unset;width:100%;min-width:unset}:host([align=right]) .container{right:0;text-align:end;left:unset}:host([open]) .container{visibility:visible}:host([open]) .container.show{height:auto;overflow:auto;opacity:1}.container.up{bottom:var(--comp-pop-offset)}click-elsewhere{position:relative;display:block}.content{height:auto}";
5
5
 
6
6
  const Q2Popover = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
7
  constructor() {
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
2
  import { i as icons, d as defineCustomElement$1 } from './index7.js';
3
3
 
4
- const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-double-focus-ring, 0 0 0 2px #ffffff, 0 0 0 4px #33b4ff #06C)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit;font-stretch:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}.avatar-img{object-fit:cover;height:var(--tct-avatar-img-height, var(--tct-avatar-height, 44px));width:var(--tct-avatar-img-width, var(--tct-avatar-width, 44px));border-radius:var(--tct-avatar-img-border-radius, --tct-avatar-img-br, --tct-avatar-border-radius, 50%);background-color:unset}.avatar-img-default{object-fit:cover;height:var(--tct-avatar-img-height, var(--tct-avatar-height, 44px));width:var(--tct-avatar-img-width, var(--tct-avatar-width, 44px));border-radius:var(--tct-avatar-img-border-radius, var(--tct-avatar-img-br, var(--tct-avatar-border-radius, 50%)));background:var(--tct-avatar-background, var(--tct-avatar-bg, #9e9e9e))}.avatar-initials{height:var(--tct-avatar-height, 44px);width:var(--tct-avatar-width, 44px);background:var(--tct-avatar-background, var(--tct-avatar-bg, var(--t-gray-8, #9e9e9e)));border-radius:var(--tct-avatar-br, 50%)}.size-1{--tct-avatar-font-size:var(--tct-avatar-size-1, 60px)}.size-2{--tct-avatar-font-size:var(--tct-avatar-size-2, 50px)}.size-3{--tct-avatar-font-size:var(--tct-avatar-size-3, 40px)}.size-4{--tct-avatar-font-size:var(--tct-avatar-size-4, 30px)}text{fill:var(--tct-avatar-text-color, var(--tct-avatar-color, #ffffff));font-weight:var(--tct-avatar-font-weight, 200);font-size:var(--tct-avatar-font-size, 40px)}.fallback{height:var(--tct-avatar-fallback-height, var(--tct-avatar-height, 44px));width:var(--tct-avatar-fallback-width, var(--tct-avatar-width, 44px));border-radius:var(--tct-avatar-fallback-border-radius, var(--tct-avatar-fallback-br, var(--tct-avatar-img-border-radius, var(--tct-avatar-img-br, 50%))));background:var(--tct-avatar-fallback-background, var(--tct-avatar-fallback-bg, var(--tct-avatar-background, var(--tct-avatar-bg, #9e9e9e))));display:flex;align-items:center;justify-content:center}q2-icon{--t-icon-size:var-list(--tct-avatar-icon-size, --tct-avatar-fallback-icon-size, 65%);--t-icon-fill:var-list(--tct-avatar-icon-fill, --tct-avatar-fallback-fill, transparent);--t-icon-stroke-primary:var-list(\n --tct-avatar-icon-stroke-primary,\n --tct-avatar-fallback-stroke-primary,\n currentcolor\n );--t-icon-stroke-secondary:var-list(\n --tct-avatar-icon-stroke-secondary,\n --tct-avatar-fallback-stroke-secondary,\n currentcolor\n );color:var(--tct-avatar-icon-color, var(--tct-avatar-fallback-color, var(--tct-avatar-color, var(--t-base, #ffffff))));width:var(--tct-avatar-icon-size, var(--t-icon-size));height:var(--tct-avatar-icon-size, var(--t-icon-size))}";
4
+ const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-double-focus-ring, 0 0 0 2px #ffffff, 0 0 0 4px #33b4ff #06C)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit;font-stretch:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}.avatar-img{object-fit:cover;height:var(--tct-avatar-img-height, var(--tct-avatar-height, 44px));width:var(--tct-avatar-img-width, var(--tct-avatar-width, 44px));border-radius:var(--tct-avatar-img-border-radius, --tct-avatar-img-br, --tct-avatar-border-radius, 50%);background-color:unset}.avatar-img-default{object-fit:cover;height:var(--tct-avatar-img-height, var(--tct-avatar-height, 44px));width:var(--tct-avatar-img-width, var(--tct-avatar-width, 44px));border-radius:var(--tct-avatar-img-border-radius, var(--tct-avatar-img-br, var(--tct-avatar-border-radius, 50%)));background:var(--tct-avatar-background, var(--tct-avatar-bg, #9e9e9e))}.avatar-initials{height:var(--tct-avatar-height, 44px);width:var(--tct-avatar-width, 44px);background:var(--tct-avatar-background, var(--tct-avatar-bg, var(--t-gray-8, #9e9e9e)));border-radius:var(--tct-avatar-br, 50%)}.size-1{--tct-avatar-font-size:var(--tct-avatar-size-1, 60px)}.size-2{--tct-avatar-font-size:var(--tct-avatar-size-2, 50px)}.size-3{--tct-avatar-font-size:var(--tct-avatar-size-3, 40px)}.size-4{--tct-avatar-font-size:var(--tct-avatar-size-4, 30px)}text{fill:var(--tct-avatar-text-color, var(--tct-avatar-color, #ffffff));font-weight:var(--tct-avatar-font-weight, 200);font-size:var(--tct-avatar-font-size, 40px)}.fallback{height:var(--tct-avatar-fallback-height, var(--tct-avatar-height, 44px));width:var(--tct-avatar-fallback-width, var(--tct-avatar-width, 44px));border-radius:var(--tct-avatar-fallback-border-radius, var(--tct-avatar-fallback-br, var(--tct-avatar-img-border-radius, var(--tct-avatar-img-br, 50%))));background:var(--tct-avatar-fallback-background, var(--tct-avatar-fallback-bg, var(--tct-avatar-background, var(--tct-avatar-bg, #9e9e9e))));display:flex;align-items:center;justify-content:center}q2-icon{--t-icon-size:var(--tct-avatar-icon-size, var(--tct-avatar-fallback-icon-size, 65%));--t-icon-fill:var(--tct-avatar-icon-fill, var(--tct-avatar-fallback-fill, transparent));--t-icon-stroke-primary:var(--tct-avatar-icon-stroke-primary, var(--tct-avatar-fallback-stroke-primary, currentcolor));--t-icon-stroke-secondary:var(--tct-avatar-icon-stroke-secondary, var(--tct-avatar-fallback-stroke-secondary, currentcolor));color:var(--tct-avatar-icon-color, var(--tct-avatar-fallback-color, var(--tct-avatar-color, var(--t-base, #ffffff))));width:var(--tct-avatar-icon-size, var(--t-icon-size));height:var(--tct-avatar-icon-size, var(--t-icon-size))}";
5
5
 
6
6
  const Q2Avatar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
7
  constructor() {
@@ -108,6 +108,7 @@ const Q2Dropdown$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
108
108
  this.hideLabel = undefined;
109
109
  this.disabled = undefined;
110
110
  this.popDirection = undefined;
111
+ this.alignment = 'left';
111
112
  this.name = undefined;
112
113
  this.context = undefined;
113
114
  this.contextValue = undefined;
@@ -291,6 +292,7 @@ const Q2Dropdown$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
291
292
  "hideLabel": [1540, "hide-label"],
292
293
  "disabled": [516],
293
294
  "popDirection": [513, "pop-direction"],
295
+ "alignment": [513],
294
296
  "name": [513],
295
297
  "context": [513],
296
298
  "contextValue": [513, "context-value"],
@@ -35,16 +35,16 @@ const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
35
35
  };
36
36
  this.updateSelectedOptionElements = async () => {
37
37
  var _a;
38
- const { selectedOptions } = this;
38
+ const { selectedOptions = [] } = this;
39
39
  const selectedValues = selectedOptions.map(option => option.value);
40
40
  const options = await ((_a = this.optionList) === null || _a === void 0 ? void 0 : _a.getOptions());
41
- if (this.hasOptions)
41
+ if (this.optionCount)
42
42
  this.active = !!selectedValues.length;
43
43
  this.selectedOptionElements = (options === null || options === void 0 ? void 0 : options.filter(option => selectedValues.includes(option.value))) || [];
44
44
  };
45
- this.determineHasOptions = () => {
46
- const hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
47
- this.hasOptions = hasOptions;
45
+ this.determineOptionCount = () => {
46
+ const numberOfOptions = this.hostElement.querySelectorAll('q2-option').length;
47
+ this.optionCount = numberOfOptions;
48
48
  };
49
49
  this.clearSelectedOptions = () => {
50
50
  this.selectedOptions = [];
@@ -60,7 +60,7 @@ const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
60
60
  event.stopPropagation();
61
61
  if (this.disabled)
62
62
  return;
63
- if (this.hasOptions) {
63
+ if (this.optionCount) {
64
64
  if (shouldShowActionSheet(this)) {
65
65
  this.executeActionSheet(event);
66
66
  }
@@ -82,7 +82,7 @@ const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
82
82
  };
83
83
  this.handleKeydown = async (event) => {
84
84
  const isTabMetaOrCtrl = event.metaKey || event.ctrlKey || event.key === 'Tab';
85
- if (!this.hasOptions || this.disabled || isTabMetaOrCtrl)
85
+ if (!this.optionCount || this.disabled || isTabMetaOrCtrl)
86
86
  return;
87
87
  event.preventDefault();
88
88
  if (shouldShowActionSheet(this, event)) {
@@ -101,7 +101,7 @@ const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
101
101
  };
102
102
  this.handleChange = event => {
103
103
  event.stopPropagation();
104
- if (!this.hasOptions)
104
+ if (!this.optionCount)
105
105
  return;
106
106
  this.handleSelectionChanges(event.detail);
107
107
  };
@@ -131,12 +131,14 @@ const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
131
131
  this.selectedOptions = [];
132
132
  this.popoverMinHeight = 150;
133
133
  this.popoverDirection = undefined;
134
- this.hasOptions = undefined;
134
+ this.popoverAlignment = 'right';
135
+ this.optionListLabel = undefined;
136
+ this.optionCount = undefined;
135
137
  this.selectedOptionElements = [];
136
138
  }
137
139
  /// LifeCycle Hooks ///
138
140
  componentWillLoad() {
139
- const observer = new MutationObserver(this.determineHasOptions);
141
+ const observer = new MutationObserver(this.determineOptionCount);
140
142
  observer.observe(this.hostElement, { childList: true, attributes: true });
141
143
  this.mutationObserver = observer;
142
144
  }
@@ -154,8 +156,8 @@ const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
154
156
  }
155
157
  /// Getters ///
156
158
  get buttonContent() {
157
- const { label, selectedOptions, selectedOptionElements, hasOptions } = this;
158
- if (!hasOptions || selectedOptionElements.length === 0)
159
+ const { label, selectedOptions, selectedOptionElements, optionCount } = this;
160
+ if (!optionCount || selectedOptionElements.length === 0)
159
161
  return label;
160
162
  else if (selectedOptionElements.length === 1)
161
163
  return selectedOptionElements[0].display;
@@ -185,8 +187,8 @@ const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
185
187
  const selectedOption = await this.getOption(value);
186
188
  this.selectedOptions = selectedOption
187
189
  ? [{ value: selectedOption.value, display: selectedOption.display }]
188
- : undefined;
189
- this.value = selectedOption.value || undefined;
190
+ : [];
191
+ this.value = (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || undefined;
190
192
  }
191
193
  }
192
194
  this.change.emit({
@@ -207,7 +209,7 @@ const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
207
209
  else {
208
210
  const selectedOption = await this.getOption(newValue);
209
211
  const { value, display } = selectedOption || { value: newValue, display: null };
210
- this.selectedOptions = [{ value, display }];
212
+ this.selectedOptions = value ? [{ value, display }] : [];
211
213
  }
212
214
  }
213
215
  selectedOptionsChanged(newValue) {
@@ -241,20 +243,23 @@ const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
241
243
  }
242
244
  /// DOM ///
243
245
  generateIcon() {
244
- const { hasOptions, active } = this;
245
- const isButton = hasOptions && active;
246
+ const { optionCount, active } = this;
247
+ const isButton = optionCount && active;
246
248
  const TagName = isButton ? 'button' : 'div';
247
- const iconName = isButton || !hasOptions ? 'close' : 'chevron-down';
249
+ const iconName = isButton || !optionCount ? 'close' : 'chevron-down';
248
250
  return (h(TagName, { class: "btn-close", onClick: isButton && this.clearSelectedOptions, disabled: isButton && this.disabled, "aria-label": isButton && loc('tecton.element.pill.clearSelection'), type: isButton && 'button' }, h("q2-icon", { type: iconName })));
249
251
  }
252
+ generateHiddenElement() {
253
+ return (h("div", { id: "option-description", class: "sr", "aria-hidden": "true" }, loc('tecton.element.optionList.optionCount', [this.optionCount])));
254
+ }
250
255
  render() {
251
- const { hasOptions, active, open } = this;
256
+ const { optionCount, active, open } = this;
252
257
  const wrapperClassNames = ['btn-wrapper'];
253
- if (hasOptions || active)
258
+ if (optionCount || active)
254
259
  wrapperClassNames.push('has-icon');
255
- if (hasOptions)
260
+ if (optionCount)
256
261
  wrapperClassNames.push('has-options');
257
- return (h("click-elsewhere", { onChange: this.onClickElsewhere }, h("div", { class: wrapperClassNames.join(' ') }, h("div", { class: "btn-height-wrapper", ref: el => (this.primaryBtnWrapper = el), onClick: this.handleWrapperClick, tabIndex: -1 }, h("button", { class: "btn-primary", "test-id": "btn-control", type: "button", ref: el => (this.primaryBtn = el), onClick: this.handleClick, onKeyDown: this.handleKeydown, onFocusout: this.handleButtonFocusout, disabled: this.disabled, "aria-selected": !hasOptions && active ? 'true' : 'false', "aria-roledescription": !hasOptions && 'filter', "aria-controls": hasOptions && 'option-list', "aria-haspopup": hasOptions && 'true', "aria-expanded": (hasOptions && `${!!open}`) || undefined, "aria-label": this.maxLength && this.buttonContent }, this.truncatedButtonContent, !hasOptions && active && h("span", { class: "sr" }, "(", loc('tecton.element.pill.active'), ")"))), this.generateIcon()), this.hasOptions && (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.primaryBtn, open: this.open, minHeight: this.popoverMinHeight, direction: this.popoverDirection, align: "right" }, h("q2-option-list", { role: "menu", ref: el => (this.optionList = el), id: "option-list", onChange: this.handleChange, multiple: this.multiple, selectedOptions: this.selectedOptions, onReady: () => this.updateSelectedOptionElements() }, h("slot", null))))));
262
+ return (h("click-elsewhere", { onChange: this.onClickElsewhere }, h("div", { class: wrapperClassNames.join(' ') }, h("div", { class: "btn-height-wrapper", ref: el => (this.primaryBtnWrapper = el), onClick: this.handleWrapperClick, tabIndex: -1 }, h("button", { class: "btn-primary", "test-id": "btn-control", type: "button", role: "combobox", ref: el => (this.primaryBtn = el), onClick: this.handleClick, onKeyDown: this.handleKeydown, onFocusout: this.handleButtonFocusout, disabled: this.disabled, "aria-roledescription": !optionCount && 'filter', "aria-controls": optionCount && 'option-list', "aria-expanded": (optionCount && `${!!open}`) || undefined, "aria-label": this.maxLength && this.buttonContent, "aria-describedby": (optionCount && 'option-description') || undefined }, this.truncatedButtonContent, !optionCount && active && h("span", { class: "sr" }, "(", loc('tecton.element.pill.active'), ")"))), this.generateIcon(), this.generateHiddenElement()), this.optionCount && (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.primaryBtn, open: this.open, minHeight: this.popoverMinHeight, direction: this.popoverDirection, align: "right" }, h("q2-option-list", { type: "listbox", ref: el => (this.optionList = el), id: "option-list", onChange: this.handleChange, multiple: this.multiple, selectedOptions: this.selectedOptions, onReady: () => this.updateSelectedOptionElements(), label: loc('tecton.element.optionList.label', [this.optionListLabel]) }, h("slot", null))))));
258
263
  }
259
264
  get hostElement() { return this; }
260
265
  static get watchers() { return {
@@ -275,7 +280,9 @@ const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
275
280
  "selectedOptions": [1040],
276
281
  "popoverMinHeight": [2, "popover-min-height"],
277
282
  "popoverDirection": [1, "popover-direction"],
278
- "hasOptions": [32],
283
+ "popoverAlignment": [1025, "popover-alignment"],
284
+ "optionListLabel": [1, "option-list-label"],
285
+ "optionCount": [32],
279
286
  "selectedOptionElements": [32]
280
287
  }, [[0, "focus", "delegateFocus"], [0, "popoverStateChanged", "popoverStateHandler"]]]);
281
288
  function defineCustomElement$1() {
@@ -74,6 +74,9 @@ const Q2Select$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
74
74
  return;
75
75
  if (this.shouldClearSearchText(event))
76
76
  this.clearSearchText();
77
+ // Prevent click event from firing when spacebar is pressed
78
+ if (event.key === ' ')
79
+ event.preventDefault();
77
80
  this.optionList.handleExternalKeydown(event);
78
81
  };
79
82
  this.visibilityToggleKeyDown = (event) => {
@@ -473,10 +476,10 @@ const Q2Select$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
473
476
  this.errors.length > 0 &&
474
477
  this.errors.map(error => loc(error))) ||
475
478
  (this.invalid && ['tecton.element.select.invalid']) ||
476
- [], disabled: this.disabled, optional: this.optional, readonly: this.readonly, placeholder: this.placeholder || undefined, hideLabel: this.hideLabel, ariaExpanded: `${this.open}`, ariaControls: "option-list", ariaHaspopup: "listbox", role: this.searchable ? 'combobox' : null, pseudo: showAsPseudo, "test-id": "toggleDropdown", "hide-messages": true, iconRight: "chevron-down", onClick: this.inputClickHandler, onInput: this.inputInputHandler, onKeyDown: this.inputKeydownHandler, onFocus: this.inputFocusHandler, onBlur: this.inputBlurHandler, onChange: this.inputChangeHandler, badgeValue: this.badgeValue, badgeTheme: this.inputFocused ? 'primary' : undefined }, this.renderCustomDisplay()), h("div", { class: "custom-display-content", hidden: !this.hasCustomDisplay || !!this.searchText, onClick: this.onCustomDisplayClick }, h("slot", { name: "q2-select-display" })), this.optionsDropdown()));
479
+ [], disabled: this.disabled, optional: this.optional, readonly: this.readonly, placeholder: this.placeholder || undefined, hideLabel: this.hideLabel, ariaExpanded: `${this.open}`, ariaControls: "option-list", ariaHaspopup: "listbox", role: "combobox", pseudo: showAsPseudo, "test-id": "toggleDropdown", "hide-messages": true, iconRight: "chevron-down", onClick: this.inputClickHandler, onInput: this.inputInputHandler, onKeyDown: this.inputKeydownHandler, onFocus: this.inputFocusHandler, onBlur: this.inputBlurHandler, onChange: this.inputChangeHandler, badgeValue: this.badgeValue, badgeTheme: this.inputFocused ? 'primary' : undefined }, this.renderCustomDisplay()), h("div", { class: "custom-display-content", hidden: !this.hasCustomDisplay || !!this.searchText, onClick: this.onCustomDisplayClick }, h("slot", { name: "q2-select-display" })), this.optionsDropdown()));
477
480
  }
478
481
  optionsDropdown() {
479
- return (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.innerInputField, open: this.open, minHeight: this.popoverMinHeight, direction: this.popDirection, onPopoverStateChanged: this.popoverStateChanged, block: true }, h("div", { class: "popover-content", tabindex: "-1" }, h("q2-option-list", { ref: el => (this.optionList = el), id: "option-list", "show-selected": this.showSelected, "aria-label": this.listLabel, multiple: this.multiple, selectedOptions: this.structuredSelectedOptions, onChange: this.onOptionListChange }, h("slot", null)), this.multiple && this.visibilityToggle())));
482
+ return (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.innerInputField, open: this.open, minHeight: this.popoverMinHeight, direction: this.popDirection, onPopoverStateChanged: this.popoverStateChanged, block: true }, h("div", { class: "popover-content", tabindex: "-1" }, h("q2-option-list", { ref: el => (this.optionList = el), type: "listbox", id: "option-list", "show-selected": this.showSelected, "aria-label": this.listLabel, multiple: this.multiple, selectedOptions: this.structuredSelectedOptions, onChange: this.onOptionListChange }, h("slot", null)), this.multiple && this.visibilityToggle())));
480
483
  }
481
484
  visibilityToggle() {
482
485
  var _a, _b;
@@ -1,4 +1,4 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host, Fragment } from '@stencil/core/internal/client';
2
2
  import { o as overrideFocus, a as isEventFromElement, l as loc } from './index15.js';
3
3
  import { s as shouldShowActionSheet, a as showActionSheetList } from './action-sheet.js';
4
4
  import { d as defineCustomElement$5 } from './index2.js';
@@ -17,9 +17,9 @@ const Q2Tag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
17
17
  var _a;
18
18
  /// Getters ///
19
19
  /// Helpers
20
- this.determineHasOptions = () => {
21
- const hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
22
- this.hasOptions = hasOptions;
20
+ this.determineOptionCount = () => {
21
+ const numberOfOptions = this.hostElement.querySelectorAll('q2-option').length;
22
+ this.optionCount = numberOfOptions;
23
23
  };
24
24
  /// Event Handlers ///
25
25
  this.onClickElsewhere = (event) => {
@@ -34,7 +34,7 @@ const Q2Tag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
34
34
  };
35
35
  this.handleChange = event => {
36
36
  event.stopPropagation();
37
- if (!this.hasOptions)
37
+ if (!this.optionCount)
38
38
  return;
39
39
  const { value } = event.detail;
40
40
  this.click.emit({ value });
@@ -47,7 +47,7 @@ const Q2Tag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
47
47
  this.click.emit({ value });
48
48
  }
49
49
  else {
50
- this.popoverElement.toggle();
50
+ await this.popoverElement.toggle();
51
51
  }
52
52
  };
53
53
  this.handleKeydown = async (event) => {
@@ -81,11 +81,13 @@ const Q2Tag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
81
81
  this.theme = undefined;
82
82
  this.popoverMinHeight = 150;
83
83
  this.popoverDirection = undefined;
84
- this.hasOptions = undefined;
84
+ this.popoverAlignment = 'right';
85
+ this.optionListLabel = 'options';
86
+ this.optionCount = undefined;
85
87
  }
86
88
  /// LifeCycle Hooks ///
87
89
  componentWillLoad() {
88
- const observer = new MutationObserver(this.determineHasOptions);
90
+ const observer = new MutationObserver(this.determineOptionCount);
89
91
  observer.observe(this.hostElement, { childList: true, attributes: true });
90
92
  this.mutationObserver = observer;
91
93
  }
@@ -100,7 +102,7 @@ const Q2Tag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
100
102
  delegateFocus(event) {
101
103
  if (!isEventFromElement(event, this.hostElement))
102
104
  return;
103
- if (!this.hasOptions)
105
+ if (!this.optionCount)
104
106
  return;
105
107
  this.dropdownBtn.focus();
106
108
  }
@@ -112,12 +114,15 @@ const Q2Tag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
112
114
  this.optionList.setActiveElement(null);
113
115
  }
114
116
  /// DOM ///
117
+ generateHiddenElement() {
118
+ return (h("div", { id: "option-description", class: "sr", "aria-hidden": "true" }, loc('tecton.element.optionList.optionCount', [this.optionCount])));
119
+ }
115
120
  render() {
116
- const { hasOptions, open } = this;
117
- const wrapperClassNames = ['tag-wrapper'];
118
- if (hasOptions)
121
+ const { optionCount, open } = this;
122
+ const wrapperClassNames = ['tag'];
123
+ if (optionCount)
119
124
  wrapperClassNames.push('has-options');
120
- return (h(Host, { role: "listitem" }, h("click-elsewhere", { onChange: this.onClickElsewhere }, h("div", { class: wrapperClassNames.join(' '), onClick: e => e.stopPropagation() }, h("div", { class: "tag" }, this.label), this.hasOptions && (h("div", { class: "btn-wrapper", onClick: this.handleWrapperClick }, h("button", { ref: el => (this.dropdownBtn = el), "test-id": "btn-control", onClick: this.handleClick, onKeyDown: this.handleKeydown, onFocusout: this.handleButtonFocusout, "aria-controls": "option-list", "aria-haspopup": "true", "aria-expanded": open ? 'true' : 'false', "aria-label": loc('tecton.element.tag.viewOptions') }, h("q2-icon", { type: "options" }))))), this.hasOptions && (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.dropdownBtn, open: this.open, minHeight: this.popoverMinHeight, direction: this.popoverDirection, align: "right" }, h("q2-option-list", { id: "option-list", role: "menu", ref: el => (this.optionList = el), onChange: this.handleChange, align: "right", type: "menu", "no-select": true }, h("slot", null)))))));
125
+ return (h(Host, { role: "listitem" }, h("click-elsewhere", { onChange: this.onClickElsewhere }, this.optionCount ? (h(Fragment, null, h("div", { class: "btn-wrapper", onClick: this.handleWrapperClick }, h("button", { class: "tag-wrapper", ref: el => (this.dropdownBtn = el), "test-id": "btn-control", type: "button", role: "combobox", onClick: this.handleClick, onKeyDown: this.handleKeydown, onFocusout: this.handleButtonFocusout, "aria-controls": "option-list", "aria-expanded": open ? 'true' : 'false', "aria-describedby": "option-description" }, h("div", { class: wrapperClassNames.join(' ') }, this.label), h("q2-icon", { type: "options" }))), this.generateHiddenElement())) : (h("div", { class: "tag-wrapper", onClick: e => e.stopPropagation() }, h("div", { class: wrapperClassNames.join(' ') }, this.label))), this.optionCount && (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.dropdownBtn, open: this.open, minHeight: this.popoverMinHeight, direction: this.popoverDirection, align: "right" }, h("q2-option-list", { id: "option-list", ref: el => (this.optionList = el), onChange: this.handleChange, type: "menu", align: "right", label: loc('tecton.element.optionList.label', [this.optionListLabel]), "no-select": true }, h("slot", null)))))));
121
126
  }
122
127
  get hostElement() { return this; }
123
128
  static get style() { return stylesCss; }
@@ -128,7 +133,9 @@ const Q2Tag$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
128
133
  "theme": [513],
129
134
  "popoverMinHeight": [2, "popover-min-height"],
130
135
  "popoverDirection": [1, "popover-direction"],
131
- "hasOptions": [32]
136
+ "popoverAlignment": [1025, "popover-alignment"],
137
+ "optionListLabel": [1, "option-list-label"],
138
+ "optionCount": [32]
132
139
  }, [[0, "focus", "delegateFocus"], [0, "popoverStateChanged", "popoverStateHandler"]]]);
133
140
  function defineCustomElement$1() {
134
141
  if (typeof customElements === "undefined") {