q2-tecton-elements 1.21.1 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/installCanvasRenderer-b4d10c92.js +38433 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/q2-badge_2.cjs.entry.js +6 -4
- package/dist/cjs/q2-calendar.cjs.entry.js +75 -55
- package/dist/cjs/q2-carousel.cjs.entry.js +3 -3
- package/dist/cjs/q2-chart-bar.cjs.entry.js +4679 -0
- package/dist/cjs/q2-chart-donut.cjs.entry.js +357 -35592
- package/dist/cjs/q2-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/q2-editable-field.cjs.entry.js +1 -1
- package/dist/cjs/q2-radio.cjs.entry.js +1 -1
- package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/q2-calendar/index.js +43 -2
- package/dist/collection/components/q2-chart-bar/index.js +466 -0
- package/dist/collection/components/q2-chart-bar/styles.css +85 -0
- package/dist/collection/components/q2-chart-donut/index.js +3 -3
- package/dist/collection/components/q2-checkbox/styles.css +5 -1
- package/dist/collection/components/q2-editable-field/styles.css +1 -1
- package/dist/collection/components/q2-input/formatting/phone.js +3 -3
- package/dist/collection/components/q2-input/index.js +21 -0
- package/dist/collection/components/q2-input/styles.css +2 -2
- package/dist/collection/components/q2-radio/styles.css +1 -1
- package/dist/collection/utils/charting.js +182 -0
- package/dist/components/click-elsewhere.d.ts +11 -0
- package/dist/components/click-elsewhere.js +6 -0
- package/dist/components/index.d.ts +62 -0
- package/dist/components/index.js +42 -0
- package/dist/components/index10.js +84 -0
- package/dist/components/index11.js +383 -0
- package/dist/components/index12.js +125 -0
- package/dist/components/index13.js +602 -0
- package/dist/components/index2.js +100 -0
- package/dist/components/index3.js +90 -0
- package/dist/components/index4.js +62 -0
- package/dist/components/index5.js +146 -0
- package/dist/components/index6.js +145 -0
- package/dist/components/index7.js +2960 -0
- package/dist/components/index8.js +3356 -0
- package/dist/components/index9.js +101 -0
- package/dist/components/installCanvasRenderer.js +38282 -0
- package/dist/components/q2-avatar.d.ts +11 -0
- package/dist/components/q2-avatar.js +6 -0
- package/dist/components/q2-badge.d.ts +11 -0
- package/dist/components/q2-badge.js +6 -0
- package/dist/components/q2-btn.d.ts +11 -0
- package/dist/components/q2-btn.js +6 -0
- package/dist/components/q2-calendar.d.ts +11 -0
- package/dist/components/q2-calendar.js +3755 -0
- package/dist/components/q2-card.d.ts +11 -0
- package/dist/components/q2-card.js +187 -0
- package/dist/components/q2-carousel-pane.d.ts +11 -0
- package/dist/components/q2-carousel-pane.js +97 -0
- package/dist/components/q2-carousel.d.ts +11 -0
- package/dist/components/q2-carousel.js +5379 -0
- package/dist/components/q2-chart-bar.d.ts +11 -0
- package/dist/components/q2-chart-bar.js +4710 -0
- package/dist/components/q2-chart-donut.d.ts +11 -0
- package/dist/components/q2-chart-donut.js +4887 -0
- package/dist/components/q2-checkbox-group.d.ts +11 -0
- package/dist/components/q2-checkbox-group.js +114 -0
- package/dist/components/q2-checkbox.d.ts +11 -0
- package/dist/components/q2-checkbox.js +138 -0
- package/dist/components/q2-dropdown-item.d.ts +11 -0
- package/dist/components/q2-dropdown-item.js +6 -0
- package/dist/components/q2-dropdown.d.ts +11 -0
- package/dist/components/q2-dropdown.js +345 -0
- package/dist/components/q2-editable-field.d.ts +11 -0
- package/dist/components/q2-editable-field.js +220 -0
- package/dist/components/q2-icon.d.ts +11 -0
- package/dist/components/q2-icon.js +6 -0
- package/dist/components/q2-input.d.ts +11 -0
- package/dist/components/q2-input.js +6 -0
- package/dist/components/q2-loading-element.d.ts +11 -0
- package/dist/components/q2-loading-element.js +52 -0
- package/dist/components/q2-loading.d.ts +11 -0
- package/dist/components/q2-loading.js +6 -0
- package/dist/components/q2-loc.d.ts +11 -0
- package/dist/components/q2-loc.js +40 -0
- package/dist/components/q2-message.d.ts +11 -0
- package/dist/components/q2-message.js +6 -0
- package/dist/components/q2-month-picker.d.ts +11 -0
- package/dist/components/q2-month-picker.js +189 -0
- package/dist/components/q2-optgroup.d.ts +11 -0
- package/dist/components/q2-optgroup.js +75 -0
- package/dist/components/q2-option-list.d.ts +11 -0
- package/dist/components/q2-option-list.js +6 -0
- package/dist/components/q2-option.d.ts +11 -0
- package/dist/components/q2-option.js +81 -0
- package/dist/components/q2-pagination.d.ts +11 -0
- package/dist/components/q2-pagination.js +184 -0
- package/dist/components/q2-pill.d.ts +11 -0
- package/dist/components/q2-pill.js +216 -0
- package/dist/components/q2-popover.d.ts +11 -0
- package/dist/components/q2-popover.js +6 -0
- package/dist/components/q2-radio-group.d.ts +11 -0
- package/dist/components/q2-radio-group.js +191 -0
- package/dist/components/q2-radio.d.ts +11 -0
- package/dist/components/q2-radio.js +105 -0
- package/dist/components/q2-section.d.ts +11 -0
- package/dist/components/q2-section.js +218 -0
- package/dist/components/q2-select.d.ts +11 -0
- package/dist/components/q2-select.js +817 -0
- package/dist/components/q2-stepper-pane.d.ts +11 -0
- package/dist/components/q2-stepper-pane.js +92 -0
- package/dist/components/q2-stepper-vertical.d.ts +11 -0
- package/dist/components/q2-stepper-vertical.js +311 -0
- package/dist/components/q2-stepper.d.ts +11 -0
- package/dist/components/q2-stepper.js +252 -0
- package/dist/components/q2-tab-container.d.ts +11 -0
- package/dist/components/q2-tab-container.js +288 -0
- package/dist/components/q2-tab-pane.d.ts +11 -0
- package/dist/components/q2-tab-pane.js +58 -0
- package/dist/components/q2-tag.d.ts +11 -0
- package/dist/components/q2-tag.js +156 -0
- package/dist/components/q2-textarea.d.ts +11 -0
- package/dist/components/q2-textarea.js +265 -0
- package/dist/components/q2-tooltip.d.ts +11 -0
- package/dist/components/q2-tooltip.js +112 -0
- package/dist/components/shapes.js +91 -0
- package/dist/components/tecton-tab-pane.d.ts +11 -0
- package/dist/components/tecton-tab-pane.js +111 -0
- package/dist/esm/installCanvasRenderer-0143b52d.js +38282 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/q2-badge_2.entry.js +6 -4
- package/dist/esm/q2-calendar.entry.js +75 -55
- package/dist/esm/q2-carousel.entry.js +3 -3
- package/dist/esm/q2-chart-bar.entry.js +4675 -0
- package/dist/esm/q2-chart-donut.entry.js +171 -35406
- package/dist/esm/q2-checkbox.entry.js +1 -1
- package/dist/esm/q2-editable-field.entry.js +1 -1
- package/dist/esm/q2-radio.entry.js +1 -1
- package/dist/esm/q2-tecton-elements.js +1 -1
- package/dist/q2-tecton-elements/p-1f85cced.js +39 -0
- package/dist/q2-tecton-elements/{p-89608314.entry.js → p-4625184b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-9772b15f.entry.js → p-520c40f6.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-6b52a262.entry.js +1 -0
- package/dist/q2-tecton-elements/p-c4640b55.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-7e8f43d1.entry.js → p-cf41970f.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-e4dc9ac0.entry.js +1 -0
- package/dist/q2-tecton-elements/p-f35bf6a3.entry.js +1 -0
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
- package/dist/types/components/q2-calendar/index.d.ts +3 -0
- package/dist/types/components/q2-chart-bar/index.d.ts +40 -0
- package/dist/types/components/q2-chart-donut/index.d.ts +7 -10
- package/dist/types/components/q2-input/index.d.ts +1 -0
- package/dist/types/components.d.ts +50 -3
- package/dist/types/utils/charting.d.ts +14 -0
- package/package.json +5 -2
- package/dist/q2-tecton-elements/p-0766a694.entry.js +0 -1
- package/dist/q2-tecton-elements/p-35177f6c.entry.js +0 -1
- package/dist/q2-tecton-elements/p-5f064e1e.entry.js +0 -39
- /package/dist/types/workspace/workspace/{tecton-production_release_1.21.x → Tecton_tecton-production_master}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +0 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { o as overrideFocus, i as isEventFromElement } from './index13.js';
|
|
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{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
|
+
|
|
6
|
+
const Q2OptionList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.__registerHost();
|
|
10
|
+
this.__attachShadow();
|
|
11
|
+
this.change = createEvent(this, "change", 7);
|
|
12
|
+
this.popoverState = createEvent(this, "popoverState", 7);
|
|
13
|
+
this.scheduledAfterRender = [];
|
|
14
|
+
/// Event Handlers ///
|
|
15
|
+
/* tslint:disable:cyclomatic-complexity */
|
|
16
|
+
this.keydownHandler = (event, ignoreSelectionEvents) => {
|
|
17
|
+
event.stopPropagation();
|
|
18
|
+
const { activeIndex, customSearch, allOptions } = this;
|
|
19
|
+
const { key, shiftKey } = event;
|
|
20
|
+
let newOption;
|
|
21
|
+
switch (key) {
|
|
22
|
+
case ' ':
|
|
23
|
+
case 'Enter':
|
|
24
|
+
if (ignoreSelectionEvents) {
|
|
25
|
+
this.setDefaultActiveElement();
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
newOption = allOptions.find(element => element.active);
|
|
30
|
+
if (!newOption || newOption.disabled)
|
|
31
|
+
break;
|
|
32
|
+
this.selectOption(newOption.value);
|
|
33
|
+
break;
|
|
34
|
+
case 'ArrowUp':
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
const isFirstOption = activeIndex === 0;
|
|
37
|
+
if (isFirstOption)
|
|
38
|
+
break;
|
|
39
|
+
if (activeIndex === undefined) {
|
|
40
|
+
this.setDefaultActiveElement();
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const nextIndex = this.getNextVisibleIndex(-1);
|
|
44
|
+
if (nextIndex === -1)
|
|
45
|
+
break;
|
|
46
|
+
this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
case 'ArrowDown':
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
const isLastOption = activeIndex === allOptions.length - 1;
|
|
52
|
+
if (isLastOption)
|
|
53
|
+
break;
|
|
54
|
+
if (activeIndex === undefined) {
|
|
55
|
+
this.setDefaultActiveElement();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const nextIndex = this.getNextVisibleIndex(1);
|
|
59
|
+
if (nextIndex === -1)
|
|
60
|
+
break;
|
|
61
|
+
this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case 'Home':
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
this.openDropdownWithActiveElement(0);
|
|
67
|
+
break;
|
|
68
|
+
case 'End':
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
this.openDropdownWithActiveElement(allOptions.length - 1);
|
|
71
|
+
break;
|
|
72
|
+
case 'PageUp':
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
this.openDropdownWithActiveElement(Math.max(activeIndex - 10, 0));
|
|
75
|
+
break;
|
|
76
|
+
case 'PageDown':
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
this.openDropdownWithActiveElement(Math.min(activeIndex + 10, allOptions.length - 1));
|
|
79
|
+
break;
|
|
80
|
+
case 'Tab':
|
|
81
|
+
if (ignoreSelectionEvents)
|
|
82
|
+
break;
|
|
83
|
+
if (shiftKey)
|
|
84
|
+
break;
|
|
85
|
+
newOption = allOptions.find(element => element.active);
|
|
86
|
+
if (!newOption || newOption.disabled)
|
|
87
|
+
return;
|
|
88
|
+
this.selectOption(newOption.value);
|
|
89
|
+
break;
|
|
90
|
+
case 'Esc':
|
|
91
|
+
case 'Escape':
|
|
92
|
+
if (this.noSelect)
|
|
93
|
+
this.setActiveElement(null);
|
|
94
|
+
this.popoverState.emit({ open: false });
|
|
95
|
+
break;
|
|
96
|
+
default:
|
|
97
|
+
if (customSearch)
|
|
98
|
+
break;
|
|
99
|
+
if (!key.match(/^[A-Za-z0-9]$/))
|
|
100
|
+
break;
|
|
101
|
+
// search in non-searchable select: alpha-numeric only
|
|
102
|
+
this.searchAndFocus(key);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
/* tslint:enable:cyclomatic-complexity */
|
|
107
|
+
this.focusoutHandler = (event) => {
|
|
108
|
+
const { relatedTarget } = event;
|
|
109
|
+
const isInDropdown = this.allOptions.includes(relatedTarget);
|
|
110
|
+
const isInLightDom = !isInDropdown && this.hostElement.contains(relatedTarget);
|
|
111
|
+
if (isInDropdown || isInLightDom) {
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
this.clickHandler = (event) => {
|
|
116
|
+
const target = event.target;
|
|
117
|
+
if (target.localName !== 'q2-option' || target.disabled) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.selectOption(target.value);
|
|
121
|
+
};
|
|
122
|
+
this.role = 'listbox';
|
|
123
|
+
this.direction = 'down';
|
|
124
|
+
this.customSearch = undefined;
|
|
125
|
+
this.noSelect = undefined;
|
|
126
|
+
this.align = undefined;
|
|
127
|
+
this.selectedOptions = [];
|
|
128
|
+
this.multiple = undefined;
|
|
129
|
+
this.disabled = undefined;
|
|
130
|
+
this.type = undefined;
|
|
131
|
+
this.hasOptions = undefined;
|
|
132
|
+
}
|
|
133
|
+
/// LifeCycle Hooks ///
|
|
134
|
+
componentWillLoad() {
|
|
135
|
+
this.hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
|
|
136
|
+
}
|
|
137
|
+
componentDidLoad() {
|
|
138
|
+
overrideFocus(this.hostElement);
|
|
139
|
+
this.checkOptions();
|
|
140
|
+
this.selectedOptionsUpdated();
|
|
141
|
+
}
|
|
142
|
+
componentDidRender() {
|
|
143
|
+
this.scheduledAfterRender.forEach(fn => fn());
|
|
144
|
+
this.scheduledAfterRender = [];
|
|
145
|
+
}
|
|
146
|
+
/// Getters ///
|
|
147
|
+
get allOptions() {
|
|
148
|
+
return this.getRootSlot(this.hostElement);
|
|
149
|
+
}
|
|
150
|
+
/// Helpers ///
|
|
151
|
+
checkOptions() {
|
|
152
|
+
const { noSelect, type, allOptions } = this;
|
|
153
|
+
if (!noSelect && !type)
|
|
154
|
+
return;
|
|
155
|
+
const optionRole = type === 'menu' ? 'menuitem' : 'option';
|
|
156
|
+
allOptions.forEach(option => {
|
|
157
|
+
if (noSelect)
|
|
158
|
+
option.noSelect = true;
|
|
159
|
+
if (type)
|
|
160
|
+
option.role = optionRole;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
getRootSlot(element) {
|
|
164
|
+
var _a;
|
|
165
|
+
const slot = element.querySelector('slot');
|
|
166
|
+
const assignedElements = (_a = slot === null || slot === void 0 ? void 0 : slot.assignedElements()) !== null && _a !== void 0 ? _a : Array.from(element.children);
|
|
167
|
+
const hasAnotherSlot = !!assignedElements.length && assignedElements[0].tagName === 'SLOT';
|
|
168
|
+
if (hasAnotherSlot) {
|
|
169
|
+
return this.getRootSlot(assignedElements[0]);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
return assignedElements;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
scrollToActiveOption() {
|
|
176
|
+
const activeOption = this.allOptions[this.activeIndex];
|
|
177
|
+
activeOption === null || activeOption === void 0 ? void 0 : activeOption.scrollIntoView({ block: 'nearest' });
|
|
178
|
+
}
|
|
179
|
+
resizeIframe() {
|
|
180
|
+
var _a, _b;
|
|
181
|
+
return (_b = (_a = window.TectonElements) === null || _a === void 0 ? void 0 : _a.resizeIframe) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
182
|
+
}
|
|
183
|
+
openDropdownWithActiveElement(activeIndex) {
|
|
184
|
+
if (this.disabled)
|
|
185
|
+
return;
|
|
186
|
+
this.activeIndex = activeIndex;
|
|
187
|
+
this.popoverState.emit({ open: true });
|
|
188
|
+
this.setActiveOption();
|
|
189
|
+
this.setFocusedOption();
|
|
190
|
+
this.scheduledAfterRender.push(() => {
|
|
191
|
+
this.scrollToActiveOption();
|
|
192
|
+
this.resizeIframe();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
getDefaultActiveIndex() {
|
|
196
|
+
const { allOptions } = this;
|
|
197
|
+
const firstSelected = allOptions.findIndex(element => element.selected);
|
|
198
|
+
if (firstSelected > -1)
|
|
199
|
+
return firstSelected;
|
|
200
|
+
const firstEnabled = allOptions.findIndex(element => !element.hidden);
|
|
201
|
+
if (firstEnabled > -1)
|
|
202
|
+
return firstEnabled;
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
updateSingleOptionAttrs() {
|
|
206
|
+
var _a, _b;
|
|
207
|
+
const { allOptions, selectedOptions } = this;
|
|
208
|
+
const singleValue = (_b = (_a = selectedOptions[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : undefined;
|
|
209
|
+
allOptions.forEach(element => {
|
|
210
|
+
element.selected = element.value === singleValue;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
updateMultipleOptionAttrs() {
|
|
214
|
+
const { allOptions, selectedOptions } = this;
|
|
215
|
+
const selectedValues = selectedOptions.map(option => option.value);
|
|
216
|
+
allOptions.forEach(element => {
|
|
217
|
+
element.selected = selectedValues.includes(element.value);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
setActiveOption() {
|
|
221
|
+
const activeIndex = this.activeIndex;
|
|
222
|
+
this.allOptions.forEach((element, elementIndex) => {
|
|
223
|
+
element.active = activeIndex === elementIndex;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
setFocusedOption() {
|
|
227
|
+
const option = this.allOptions[this.activeIndex];
|
|
228
|
+
if (!option)
|
|
229
|
+
return;
|
|
230
|
+
setTimeout(() => {
|
|
231
|
+
option.focus();
|
|
232
|
+
}, 25);
|
|
233
|
+
}
|
|
234
|
+
getNextVisibleIndex(direction) {
|
|
235
|
+
let index = this.activeIndex + direction;
|
|
236
|
+
while (index >= 0 && index <= this.allOptions.length - 1) {
|
|
237
|
+
const { display, visibility } = window.getComputedStyle(this.allOptions[index]);
|
|
238
|
+
if (display !== 'none' && visibility !== 'hidden') {
|
|
239
|
+
return index;
|
|
240
|
+
}
|
|
241
|
+
index = index + direction;
|
|
242
|
+
}
|
|
243
|
+
return -1;
|
|
244
|
+
}
|
|
245
|
+
selectOption(selectedValue) {
|
|
246
|
+
const option = this.allOptions.find(({ value }) => value === selectedValue);
|
|
247
|
+
const valueObject = {
|
|
248
|
+
value: selectedValue,
|
|
249
|
+
display: option.display || option.innerText.trim(),
|
|
250
|
+
};
|
|
251
|
+
const { multiple, noSelect } = this;
|
|
252
|
+
let values;
|
|
253
|
+
if (multiple) {
|
|
254
|
+
const { selectedOptions = [] } = this;
|
|
255
|
+
const isAlreadySelected = !!selectedOptions.find(({ value }) => value === selectedValue);
|
|
256
|
+
if (isAlreadySelected) {
|
|
257
|
+
values = selectedOptions.filter(({ value }) => value !== selectedValue);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
values = [...selectedOptions, valueObject];
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
values = [valueObject];
|
|
265
|
+
}
|
|
266
|
+
if (noSelect)
|
|
267
|
+
this.setActiveElement(null);
|
|
268
|
+
else
|
|
269
|
+
this.selectedOptions = values;
|
|
270
|
+
this.change.emit({ value: selectedValue, values });
|
|
271
|
+
if (multiple)
|
|
272
|
+
return;
|
|
273
|
+
this.popoverState.emit({ open: false });
|
|
274
|
+
}
|
|
275
|
+
adjustActiveOptionAndScroll(numToAdd) {
|
|
276
|
+
this.activeIndex += numToAdd;
|
|
277
|
+
this.setActiveOption();
|
|
278
|
+
this.setFocusedOption();
|
|
279
|
+
this.scrollToActiveOption();
|
|
280
|
+
}
|
|
281
|
+
resetTimer() {
|
|
282
|
+
if (this.searchStringTimer) {
|
|
283
|
+
clearTimeout(this.searchStringTimer);
|
|
284
|
+
}
|
|
285
|
+
this.searchStringTimer = window.setTimeout(() => {
|
|
286
|
+
this.searchString = null;
|
|
287
|
+
}, 2000);
|
|
288
|
+
}
|
|
289
|
+
searchAndFocus(key) {
|
|
290
|
+
this.resetTimer();
|
|
291
|
+
let searchString = this.searchString ? `${this.searchString}${key}` : key;
|
|
292
|
+
searchString = searchString.replace(/[^0-9a-z]/gi, '');
|
|
293
|
+
this.searchString = searchString;
|
|
294
|
+
const searchRegEx = new RegExp(searchString, 'i');
|
|
295
|
+
const foundIndex = this.allOptions.findIndex(option => option.value === searchString || option.textContent.match(searchRegEx));
|
|
296
|
+
if (foundIndex === -1)
|
|
297
|
+
return;
|
|
298
|
+
this.setActiveElement(foundIndex);
|
|
299
|
+
}
|
|
300
|
+
/// Watchers ///
|
|
301
|
+
selectedOptionsUpdated() {
|
|
302
|
+
if (this.multiple) {
|
|
303
|
+
this.updateMultipleOptionAttrs();
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
this.updateSingleOptionAttrs();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/// Listeners ///
|
|
310
|
+
delegateFocus(event) {
|
|
311
|
+
if (!isEventFromElement(event, this.hostElement))
|
|
312
|
+
return;
|
|
313
|
+
this.popoverState.emit({ open: true });
|
|
314
|
+
this.setDefaultActiveElement();
|
|
315
|
+
}
|
|
316
|
+
handleClick(event) {
|
|
317
|
+
event.stopPropagation();
|
|
318
|
+
}
|
|
319
|
+
/// Public Methods ///
|
|
320
|
+
async setDefaultActiveElement() {
|
|
321
|
+
this.activeIndex = this.getDefaultActiveIndex();
|
|
322
|
+
this.setActiveOption();
|
|
323
|
+
this.setFocusedOption();
|
|
324
|
+
}
|
|
325
|
+
async setActiveElement(index) {
|
|
326
|
+
this.activeIndex = index;
|
|
327
|
+
this.setActiveOption();
|
|
328
|
+
this.setFocusedOption();
|
|
329
|
+
}
|
|
330
|
+
async handleExternalKeydown(event) {
|
|
331
|
+
const keysThatTriggerOpen = ['ArrowDown', 'ArrowUp', 'PageDown', 'PageUp', 'Home', 'End'];
|
|
332
|
+
if (keysThatTriggerOpen.includes(event.key)) {
|
|
333
|
+
this.popoverState.emit({ open: true });
|
|
334
|
+
}
|
|
335
|
+
const keysThatTriggerDefault = ['ArrowDown', 'ArrowUp'];
|
|
336
|
+
if (keysThatTriggerDefault.includes(event.key)) {
|
|
337
|
+
event.preventDefault();
|
|
338
|
+
this.setDefaultActiveElement();
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
this.keydownHandler(event, true);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/// DOM ///
|
|
345
|
+
render() {
|
|
346
|
+
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.keydownHandler, onClick: this.clickHandler }, h("slot", null)))));
|
|
347
|
+
}
|
|
348
|
+
get hostElement() { return this; }
|
|
349
|
+
static get watchers() { return {
|
|
350
|
+
"selectedOptions": ["selectedOptionsUpdated"]
|
|
351
|
+
}; }
|
|
352
|
+
static get style() { return stylesCss; }
|
|
353
|
+
}, [1, "q2-option-list", {
|
|
354
|
+
"role": [513],
|
|
355
|
+
"direction": [513],
|
|
356
|
+
"customSearch": [516, "custom-search"],
|
|
357
|
+
"noSelect": [516, "no-select"],
|
|
358
|
+
"align": [513],
|
|
359
|
+
"selectedOptions": [1040],
|
|
360
|
+
"multiple": [516],
|
|
361
|
+
"disabled": [516],
|
|
362
|
+
"type": [1],
|
|
363
|
+
"hasOptions": [32],
|
|
364
|
+
"setDefaultActiveElement": [64],
|
|
365
|
+
"setActiveElement": [64],
|
|
366
|
+
"handleExternalKeydown": [64]
|
|
367
|
+
}, [[0, "focus", "delegateFocus"], [0, "click", "handleClick"]]]);
|
|
368
|
+
function defineCustomElement() {
|
|
369
|
+
if (typeof customElements === "undefined") {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
const components = ["q2-option-list"];
|
|
373
|
+
components.forEach(tagName => { switch (tagName) {
|
|
374
|
+
case "q2-option-list":
|
|
375
|
+
if (!customElements.get(tagName)) {
|
|
376
|
+
customElements.define(tagName, Q2OptionList);
|
|
377
|
+
}
|
|
378
|
+
break;
|
|
379
|
+
} });
|
|
380
|
+
}
|
|
381
|
+
defineCustomElement();
|
|
382
|
+
|
|
383
|
+
export { Q2OptionList as Q, defineCustomElement as d };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
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}*{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:inline-flex;width:100%}.container{display:block;overflow:hidden;opacity:0;height:0;position:absolute;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);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%}:host([align=right]) .container{right:0;text-align:end;left:unset}:host([open]) .container{display:block;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
|
+
|
|
5
|
+
const Q2Popover = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.__registerHost();
|
|
9
|
+
this.__attachShadow();
|
|
10
|
+
this.popoverStateChanged = createEvent(this, "popoverStateChanged", 7);
|
|
11
|
+
this.privateDirection = 'down';
|
|
12
|
+
this.direction = undefined;
|
|
13
|
+
this.align = undefined;
|
|
14
|
+
this.open = undefined;
|
|
15
|
+
this.block = undefined;
|
|
16
|
+
this.minHeight = undefined;
|
|
17
|
+
this.controlElement = undefined;
|
|
18
|
+
}
|
|
19
|
+
/// Lifecycle hooks ///
|
|
20
|
+
componentDidLoad() {
|
|
21
|
+
if (this.open)
|
|
22
|
+
this.determinePopDirection();
|
|
23
|
+
}
|
|
24
|
+
componentWillRender() {
|
|
25
|
+
if (this.containerElement && this.containerElement && this.open)
|
|
26
|
+
this.determinePopDirection();
|
|
27
|
+
}
|
|
28
|
+
/// Methods ///
|
|
29
|
+
async toggle() {
|
|
30
|
+
this.open = !this.open;
|
|
31
|
+
}
|
|
32
|
+
/// Watchers ///
|
|
33
|
+
openChanged(open) {
|
|
34
|
+
this.popoverStateChanged.emit({ open });
|
|
35
|
+
}
|
|
36
|
+
/// Listeners ///
|
|
37
|
+
popoverStateHandler(event) {
|
|
38
|
+
const { detail: { open }, } = event;
|
|
39
|
+
if (open === this.open)
|
|
40
|
+
return;
|
|
41
|
+
this.open = open;
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
}
|
|
44
|
+
/// Helpers ///
|
|
45
|
+
determinePopDirection() {
|
|
46
|
+
var _a;
|
|
47
|
+
const { containerElement, contentElement, direction, controlElement } = this;
|
|
48
|
+
if (containerElement)
|
|
49
|
+
containerElement.style.maxHeight = null;
|
|
50
|
+
if (direction) {
|
|
51
|
+
return (this.privateDirection = direction);
|
|
52
|
+
}
|
|
53
|
+
const contentHeight = contentElement.clientHeight;
|
|
54
|
+
const { top: topOffset, height } = (_a = controlElement === null || controlElement === void 0 ? void 0 : controlElement.getBoundingClientRect()) !== null && _a !== void 0 ? _a : {
|
|
55
|
+
top: 0,
|
|
56
|
+
height: 0,
|
|
57
|
+
};
|
|
58
|
+
const bottomOffset = window.innerHeight - topOffset - height;
|
|
59
|
+
const canShowFullSizeBelow = bottomOffset > contentHeight;
|
|
60
|
+
const canShowFullSizeAbove = contentHeight <= topOffset;
|
|
61
|
+
// Prefer full size above or below
|
|
62
|
+
if (canShowFullSizeBelow) {
|
|
63
|
+
return (this.privateDirection = 'down');
|
|
64
|
+
}
|
|
65
|
+
else if (canShowFullSizeAbove || !this.minHeight) {
|
|
66
|
+
this.determinePopOffset();
|
|
67
|
+
return (this.privateDirection = 'up');
|
|
68
|
+
}
|
|
69
|
+
// If full size will not fit and minHeight is set, then make as tall as possible
|
|
70
|
+
const { minHeight = 150 } = this;
|
|
71
|
+
const displayBuffer = 5;
|
|
72
|
+
const canShowSmallBelow = bottomOffset >= minHeight + displayBuffer;
|
|
73
|
+
if (canShowSmallBelow) {
|
|
74
|
+
const maxBelowHeight = Math.max(bottomOffset - displayBuffer, minHeight);
|
|
75
|
+
containerElement.style.setProperty('--comp-pop-max-height', `${maxBelowHeight}px`);
|
|
76
|
+
return (this.privateDirection = 'down');
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const maxAboveHeight = Math.max(topOffset, minHeight);
|
|
80
|
+
containerElement.style.setProperty('--comp-pop-max-height', `${maxAboveHeight}px`);
|
|
81
|
+
this.determinePopOffset();
|
|
82
|
+
return (this.privateDirection = 'up');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
determinePopOffset() {
|
|
86
|
+
var _a;
|
|
87
|
+
const { controlElement, containerElement } = this;
|
|
88
|
+
const dropdownHeight = (_a = controlElement === null || controlElement === void 0 ? void 0 : controlElement.getBoundingClientRect().height) !== null && _a !== void 0 ? _a : 0;
|
|
89
|
+
containerElement.style.setProperty('--comp-pop-offset', `${dropdownHeight}px`);
|
|
90
|
+
}
|
|
91
|
+
/// DOM ///
|
|
92
|
+
render() {
|
|
93
|
+
const containerClasses = ['container', this.privateDirection];
|
|
94
|
+
return (h("div", { ref: el => (this.containerElement = el), class: containerClasses.join(' '), role: "menu" }, h("div", { ref: el => (this.contentElement = el), class: "content" }, h("slot", null))));
|
|
95
|
+
}
|
|
96
|
+
get hostElement() { return this; }
|
|
97
|
+
static get watchers() { return {
|
|
98
|
+
"open": ["openChanged"]
|
|
99
|
+
}; }
|
|
100
|
+
static get style() { return stylesCss; }
|
|
101
|
+
}, [1, "q2-popover", {
|
|
102
|
+
"direction": [513],
|
|
103
|
+
"align": [513],
|
|
104
|
+
"open": [1540],
|
|
105
|
+
"block": [516],
|
|
106
|
+
"minHeight": [2, "min-height"],
|
|
107
|
+
"controlElement": [16],
|
|
108
|
+
"toggle": [64]
|
|
109
|
+
}, [[0, "popoverState", "popoverStateHandler"]]]);
|
|
110
|
+
function defineCustomElement() {
|
|
111
|
+
if (typeof customElements === "undefined") {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const components = ["q2-popover"];
|
|
115
|
+
components.forEach(tagName => { switch (tagName) {
|
|
116
|
+
case "q2-popover":
|
|
117
|
+
if (!customElements.get(tagName)) {
|
|
118
|
+
customElements.define(tagName, Q2Popover);
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
} });
|
|
122
|
+
}
|
|
123
|
+
defineCustomElement();
|
|
124
|
+
|
|
125
|
+
export { Q2Popover as Q, defineCustomElement as d };
|