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.
- package/dist/cjs/{action-sheet-4b366e9a.js → action-sheet-ab1abf24.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/q2-avatar.cjs.entry.js +1 -1
- package/dist/cjs/q2-dropdown.cjs.entry.js +1 -0
- package/dist/cjs/q2-option-list_2.cjs.entry.js +9 -7
- package/dist/cjs/q2-pill.cjs.entry.js +28 -23
- package/dist/cjs/q2-select.cjs.entry.js +6 -3
- package/dist/cjs/q2-tag.cjs.entry.js +18 -13
- package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
- package/dist/collection/components/q2-avatar/styles.css +4 -12
- package/dist/collection/components/q2-dropdown/index.js +19 -0
- package/dist/collection/components/q2-option-list/index.js +33 -27
- package/dist/collection/components/q2-pill/index.js +63 -23
- package/dist/collection/components/q2-popover/styles.css +2 -3
- package/dist/collection/components/q2-select/index.js +5 -2
- package/dist/collection/components/q2-tag/index.js +55 -14
- package/dist/collection/utils/action-sheet.js +1 -1
- package/dist/components/action-sheet.js +1 -1
- package/dist/components/index13.js +10 -8
- package/dist/components/index14.js +1 -1
- package/dist/components/index3.js +1 -1
- package/dist/components/q2-dropdown.js +2 -0
- package/dist/components/q2-pill.js +30 -23
- package/dist/components/q2-select.js +5 -2
- package/dist/components/q2-tag.js +21 -14
- package/dist/docs.json +120 -20
- package/dist/esm/{action-sheet-a9597b32.js → action-sheet-bfcbe154.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/q2-avatar.entry.js +1 -1
- package/dist/esm/q2-dropdown.entry.js +1 -0
- package/dist/esm/q2-option-list_2.entry.js +10 -8
- package/dist/esm/q2-pill.entry.js +28 -23
- package/dist/esm/q2-select.entry.js +6 -3
- package/dist/esm/q2-tag.entry.js +19 -14
- package/dist/esm/q2-tecton-elements.js +1 -1
- package/dist/q2-tecton-elements/{p-414ca427.entry.js → p-31b655b6.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-788adb51.js +1 -0
- package/dist/q2-tecton-elements/p-8fd3b580.entry.js +1 -0
- package/dist/q2-tecton-elements/p-a300d517.entry.js +1 -0
- package/dist/q2-tecton-elements/p-c1d33fd2.entry.js +1 -0
- package/dist/q2-tecton-elements/p-ceabfa93.entry.js +1 -0
- package/dist/q2-tecton-elements/p-dd1115c6.entry.js +1 -0
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
- package/dist/test/helpers.js +19 -0
- package/dist/types/components/q2-dropdown/index.d.ts +1 -0
- package/dist/types/components/q2-option-list/index.d.ts +5 -1
- package/dist/types/components/q2-pill/index.d.ts +5 -2
- package/dist/types/components/q2-select/index.d.ts +1 -1
- package/dist/types/components/q2-tag/index.d.ts +5 -2
- package/dist/types/components.d.ts +20 -2
- 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
- package/package.json +3 -3
- package/dist/q2-tecton-elements/p-04b9a7ee.entry.js +0 -1
- package/dist/q2-tecton-elements/p-521c9085.entry.js +0 -1
- package/dist/q2-tecton-elements/p-8e652d59.entry.js +0 -1
- package/dist/q2-tecton-elements/p-a1926e65.js +0 -1
- package/dist/q2-tecton-elements/p-aae8b9fc.entry.js +0 -1
- 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.
|
|
10
|
-
const
|
|
11
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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 {
|
|
106
|
-
const wrapperClassNames = ['tag
|
|
107
|
-
if (
|
|
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 },
|
|
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
|
-
"
|
|
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 {
|
|
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.
|
|
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.
|
|
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.
|
|
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 =
|
|
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}
|
|
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
|
|
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.
|
|
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.
|
|
46
|
-
const
|
|
47
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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,
|
|
158
|
-
if (!
|
|
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
|
-
:
|
|
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 {
|
|
245
|
-
const isButton =
|
|
246
|
+
const { optionCount, active } = this;
|
|
247
|
+
const isButton = optionCount && active;
|
|
246
248
|
const TagName = isButton ? 'button' : 'div';
|
|
247
|
-
const iconName = isButton || !
|
|
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 {
|
|
256
|
+
const { optionCount, active, open } = this;
|
|
252
257
|
const wrapperClassNames = ['btn-wrapper'];
|
|
253
|
-
if (
|
|
258
|
+
if (optionCount || active)
|
|
254
259
|
wrapperClassNames.push('has-icon');
|
|
255
|
-
if (
|
|
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-
|
|
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
|
-
"
|
|
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:
|
|
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.
|
|
21
|
-
const
|
|
22
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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 {
|
|
117
|
-
const wrapperClassNames = ['tag
|
|
118
|
-
if (
|
|
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 },
|
|
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
|
-
"
|
|
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") {
|