q2-tecton-elements 1.21.2 → 1.22.1
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 +5 -3
- 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 +2 -2
- 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 +5 -3
- 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 +6 -3
- package/dist/q2-tecton-elements/p-0766a694.entry.js +0 -1
- package/dist/q2-tecton-elements/p-5f064e1e.entry.js +0 -39
- package/dist/q2-tecton-elements/p-8d25ec52.entry.js +0 -1
- /package/dist/types/workspace/workspace/{tecton-production_release_1.21.x → tecton-production_release_1.22.x}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { o as overrideFocus, i as isEventFromElement, l as loc, n as nextPaint } from './index13.js';
|
|
3
|
+
import { d as defineCustomElement$6 } from './index4.js';
|
|
4
|
+
import { d as defineCustomElement$5 } from './index5.js';
|
|
5
|
+
import { d as defineCustomElement$4 } from './index7.js';
|
|
6
|
+
import { d as defineCustomElement$3 } from './index8.js';
|
|
7
|
+
import { d as defineCustomElement$2 } from './index9.js';
|
|
8
|
+
|
|
9
|
+
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{text-align:right;display:block}:host([hidden]){display:none}.container{display:inline-flex;column-gap:var(--tct-pagination-column-gap, var(--t-pagination-column-gap, var(--app-scale-2x, 10px)));align-items:center;height:var(--tct-pagination-height, var(--t-pagination-height, 44px))}.btn-group{display:flex;gap:var(--tct-pagination-btn-gap, var(--t-pagination-btn-gap, 0))}.description,.controls{white-space:nowrap}.controls{display:grid;grid-template-columns:auto 50px auto;align-items:center;gap:var(--tct-pagination-controls-gap, var(--t-pagination-controls-gap, var(--app-scale-1x, 5px)))}.controls[hidden]{display:none}.input-wrapper{height:var(--tct-pagination-height, var(--t-pagination-height, 44px));display:flex;align-items:center}q2-icon{--tct-icon-size:var(--tct-pagination-icon-size, var(--t-pagination-icon-size, 12px));color:var(--tct-pagination-icon-color, var(--t-pagination-icon-color, var(--t-text, #4d4d4d)))}q2-input{--tct-input-margin-top:0;--tct-input-margin-bottom:0;--tct-input-height:var(--tct-pagination-input-height, var(--t-pagination-input-height, 30px));--tct-input-min-height:var(--tct-input-height);--tct-input-align:center}";
|
|
10
|
+
|
|
11
|
+
const Q2Pagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.__registerHost();
|
|
15
|
+
this.__attachShadow();
|
|
16
|
+
this.change = createEvent(this, "change", 7);
|
|
17
|
+
this.handlePageChange = (page) => {
|
|
18
|
+
const { totalPages, inputField } = this;
|
|
19
|
+
if (page < 1) {
|
|
20
|
+
page = 1;
|
|
21
|
+
}
|
|
22
|
+
else if (page > totalPages) {
|
|
23
|
+
page = totalPages;
|
|
24
|
+
}
|
|
25
|
+
if (inputField.value !== `${page}`)
|
|
26
|
+
inputField.value = `${page}`;
|
|
27
|
+
if (!this.hostElement.onchange) {
|
|
28
|
+
this.page = page;
|
|
29
|
+
}
|
|
30
|
+
this.change.emit({ page });
|
|
31
|
+
};
|
|
32
|
+
this.recordType = undefined;
|
|
33
|
+
this.perPage = undefined;
|
|
34
|
+
this.total = undefined;
|
|
35
|
+
this.page = undefined;
|
|
36
|
+
this.pages = undefined;
|
|
37
|
+
this.recordsOnly = undefined;
|
|
38
|
+
this.pagesOnly = undefined;
|
|
39
|
+
this.isSmall = undefined;
|
|
40
|
+
}
|
|
41
|
+
////////// LIFECYCLE HOOKS ////////
|
|
42
|
+
componentDidLoad() {
|
|
43
|
+
if (this.recordsOnly || this.pagesOnly)
|
|
44
|
+
return;
|
|
45
|
+
this.containerWidth = this.containerElement.clientWidth;
|
|
46
|
+
this.resizeObserver = new ResizeObserver(() => this.checkSize());
|
|
47
|
+
this.resizeObserver.observe(this.hostElement);
|
|
48
|
+
overrideFocus(this.hostElement);
|
|
49
|
+
}
|
|
50
|
+
disconnectedCallback() {
|
|
51
|
+
var _a;
|
|
52
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
53
|
+
}
|
|
54
|
+
onHostElementFocus(event) {
|
|
55
|
+
var _a;
|
|
56
|
+
if (!isEventFromElement(event, this.hostElement))
|
|
57
|
+
return;
|
|
58
|
+
const { isFullViewHidden, containerElement, inputField } = this;
|
|
59
|
+
if (isFullViewHidden) {
|
|
60
|
+
(_a = containerElement.querySelector('q2-btn:not([disabled])')) === null || _a === void 0 ? void 0 : _a.focus();
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
inputField.focus();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
get isFullViewHidden() {
|
|
67
|
+
return this.isSmall || this.recordsOnly || this.pagesOnly;
|
|
68
|
+
}
|
|
69
|
+
get pageWithDefault() {
|
|
70
|
+
return this.page || 1;
|
|
71
|
+
}
|
|
72
|
+
get perPageWithDefault() {
|
|
73
|
+
return this.perPage || 10;
|
|
74
|
+
}
|
|
75
|
+
get totalWithDefault() {
|
|
76
|
+
return this.total || 0;
|
|
77
|
+
}
|
|
78
|
+
get recordTypeWithDefault() {
|
|
79
|
+
return this.recordType || loc('tecton.element.pagination.defaultRecordType');
|
|
80
|
+
}
|
|
81
|
+
get currentRange() {
|
|
82
|
+
const { perPageWithDefault: perPage, totalWithDefault: total, pageWithDefault: page } = this;
|
|
83
|
+
const start = (page - 1) * perPage + 1;
|
|
84
|
+
const end = Math.min(page * perPage, total);
|
|
85
|
+
return `${start} - ${end}`;
|
|
86
|
+
}
|
|
87
|
+
get totalPages() {
|
|
88
|
+
const { pagesOnly, totalWithDefault: total, perPageWithDefault: perPage, pages } = this;
|
|
89
|
+
if (pagesOnly && pages && !isNaN(parseInt(`${pages}`)))
|
|
90
|
+
return pages;
|
|
91
|
+
return Math.ceil(total / perPage);
|
|
92
|
+
}
|
|
93
|
+
checkSize() {
|
|
94
|
+
const { hostElement, containerElement } = this;
|
|
95
|
+
const isOverflowing = this.containerWidth > hostElement.clientWidth;
|
|
96
|
+
this.isSmall = isOverflowing;
|
|
97
|
+
if (isOverflowing)
|
|
98
|
+
return;
|
|
99
|
+
nextPaint(() => {
|
|
100
|
+
const containerWidthHasNotChanged = this.containerWidth === containerElement.clientWidth;
|
|
101
|
+
if (containerWidthHasNotChanged)
|
|
102
|
+
return;
|
|
103
|
+
this.containerWidth = containerElement.clientWidth;
|
|
104
|
+
this.checkSize();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
////////// OBSERVERS //////////
|
|
108
|
+
render() {
|
|
109
|
+
const { pagesOnly, isFullViewHidden, recordTypeWithDefault: recordType, totalPages, totalWithDefault: total, pageWithDefault: page, currentRange, } = this;
|
|
110
|
+
const onFirstPage = page === 1;
|
|
111
|
+
const onLastPage = page === totalPages;
|
|
112
|
+
return (h("nav", { class: "container", ref: el => (this.containerElement = el), "aria-label": loc('tecton.element.pagination.title') }, h("div", { class: "description", "test-id": "description" }, pagesOnly
|
|
113
|
+
? loc('tecton.element.pagination.pages', {
|
|
114
|
+
current: page,
|
|
115
|
+
total: totalPages,
|
|
116
|
+
})
|
|
117
|
+
: loc('tecton.element.pagination.description', {
|
|
118
|
+
range: currentRange,
|
|
119
|
+
recordType: recordType.toLowerCase(),
|
|
120
|
+
total: total.toLocaleString(),
|
|
121
|
+
})), h("div", { class: "btn-group" }, h("q2-btn", { label: loc('tecton.element.pagination.goToFirstPage'), disabled: onFirstPage, hidden: isFullViewHidden, onClick: () => this.handlePageChange(1), "test-id": "firstPageBtn", "hide-label": true }, h("q2-icon", { type: "chevron-double-left" })), h("q2-btn", { label: loc('tecton.element.pagination.goToPages', {
|
|
122
|
+
next: page - 1,
|
|
123
|
+
total: totalPages,
|
|
124
|
+
}), disabled: onFirstPage, onClick: () => this.handlePageChange(page - 1), "test-id": "prevPageBtn", "hide-label": true }, h("q2-icon", { type: "chevron-left" }))), h("div", { class: "controls", hidden: isFullViewHidden, "test-id": "controls" }, h("span", { "aria-hidden": "true" }, loc('tecton.element.pagination.page')), h("div", { class: "input-wrapper", onClick: () => this.inputField.dispatchEvent(new FocusEvent('focus')) }, h("q2-input", { type: "number", value: `${page}`, min: 1, max: this.totalPages, hideLabel: true, optional: true, label: `${loc('tecton.element.pagination.page')} (${loc('tecton.element.pagination.ofPages', [totalPages.toLocaleString()])})`, onChange: event => this.handlePageChange(event.detail.value), "test-id": "pageInput", current: "page", ref: el => (this.inputField = el) })), h("span", { "aria-hidden": "true" }, loc('tecton.element.pagination.ofPages', [totalPages.toLocaleString()]))), h("div", { class: "btn-group" }, h("q2-btn", { label: loc('tecton.element.pagination.goToPages', {
|
|
125
|
+
next: page + 1,
|
|
126
|
+
total: totalPages,
|
|
127
|
+
}), disabled: onLastPage, onClick: () => this.handlePageChange(page + 1), "test-id": "nextPageBtn", "hide-label": true }, h("q2-icon", { type: "chevron-right" })), h("q2-btn", { label: "tecton.element.pagination.goToLastPage", disabled: onLastPage, hidden: isFullViewHidden, onClick: () => this.handlePageChange(totalPages), "test-id": "lastPageBtn", "hide-label": true }, h("q2-icon", { type: "chevron-double-right" })))));
|
|
128
|
+
}
|
|
129
|
+
get hostElement() { return this; }
|
|
130
|
+
static get style() { return stylesCss; }
|
|
131
|
+
}, [1, "q2-pagination", {
|
|
132
|
+
"recordType": [1, "record-type"],
|
|
133
|
+
"perPage": [2, "per-page"],
|
|
134
|
+
"total": [514],
|
|
135
|
+
"page": [1538],
|
|
136
|
+
"pages": [1538],
|
|
137
|
+
"recordsOnly": [1540, "records-only"],
|
|
138
|
+
"pagesOnly": [1540, "pages-only"],
|
|
139
|
+
"isSmall": [32]
|
|
140
|
+
}, [[0, "focus", "onHostElementFocus"]]]);
|
|
141
|
+
function defineCustomElement$1() {
|
|
142
|
+
if (typeof customElements === "undefined") {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const components = ["q2-pagination", "q2-badge", "q2-btn", "q2-icon", "q2-input", "q2-loading"];
|
|
146
|
+
components.forEach(tagName => { switch (tagName) {
|
|
147
|
+
case "q2-pagination":
|
|
148
|
+
if (!customElements.get(tagName)) {
|
|
149
|
+
customElements.define(tagName, Q2Pagination$1);
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case "q2-badge":
|
|
153
|
+
if (!customElements.get(tagName)) {
|
|
154
|
+
defineCustomElement$6();
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
case "q2-btn":
|
|
158
|
+
if (!customElements.get(tagName)) {
|
|
159
|
+
defineCustomElement$5();
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
case "q2-icon":
|
|
163
|
+
if (!customElements.get(tagName)) {
|
|
164
|
+
defineCustomElement$4();
|
|
165
|
+
}
|
|
166
|
+
break;
|
|
167
|
+
case "q2-input":
|
|
168
|
+
if (!customElements.get(tagName)) {
|
|
169
|
+
defineCustomElement$3();
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
case "q2-loading":
|
|
173
|
+
if (!customElements.get(tagName)) {
|
|
174
|
+
defineCustomElement$2();
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
} });
|
|
178
|
+
}
|
|
179
|
+
defineCustomElement$1();
|
|
180
|
+
|
|
181
|
+
const Q2Pagination = Q2Pagination$1;
|
|
182
|
+
const defineCustomElement = defineCustomElement$1;
|
|
183
|
+
|
|
184
|
+
export { Q2Pagination, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface Q2Pill extends Components.Q2Pill, HTMLElement {}
|
|
4
|
+
export const Q2Pill: {
|
|
5
|
+
prototype: Q2Pill;
|
|
6
|
+
new (): Q2Pill;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { r as resizeIframe, o as overrideFocus, l as loc, i as isEventFromElement } from './index13.js';
|
|
3
|
+
import { d as defineCustomElement$5 } from './index2.js';
|
|
4
|
+
import { d as defineCustomElement$4 } from './index7.js';
|
|
5
|
+
import { d as defineCustomElement$3 } from './index11.js';
|
|
6
|
+
import { d as defineCustomElement$2 } from './index12.js';
|
|
7
|
+
|
|
8
|
+
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:inline-block;position:relative;line-height:0}:host(:not(:last-child)){margin-inline-end:var(--tct-pill-margin, var(--t-pill-margin, var(--app-scale-2x, 10px)))}q2-popover,.btn-wrapper{--comp-pill-min-height:var(--tct-pill-min-height, var(--t-pill-min-height, 44px));--comp-pill-btn-height:var(--tct-pill-btn-height, var(--t-pill-btn-height, 30px))}.btn-wrapper{--comp-pill-btn-border-width:var(--tct-pill-btn-border-width, var(--t-pill-btn-border-width, 2px));--comp-close-size:0px;--comp-btn-background:var(--tct-pill-btn-background, var(--t-pill-btn-background, var(--t-base, #ffffff)));--compt-hover-btn-background:var(--tct-pill-hover-btn-background, var(--t-pill-hover-btn-background, var(--t-gray-13, #e6e6e6)));--comp-btn-padding:var(--tct-pill-btn-padding-inline, var(--t-pill-btn-padding-inline, var(--app-scale-3x, 15px)));--comp-btn-color:var(--tct-pill-btn-color, var(--t-pill-btn-color, var(--t-gray-3, #262626)));--comp-active-btn-color:var(--comp-btn-background);--comp-active-btn-background:var(--tct-pill-active-btn-background, var(--t-pill-active-btn-background, var(--t-gray-7, #666666)));--comp-active-btn-border-color:var(--tct-pill-active-btn-border-color, var(--t-pill-active-btn-border-color, var(--t-gray-7, #666666)));--comp-hover-active-btn-background:var(--tct-pill-active-btn-background, var(--t-pill-active-btn-background, var(--t-gray-6, #4d4d4d)));--comp-hover-active-btn-border-color:var(--tct-pill-active-btn-background, var(--t-pill-active-btn-background, var(--t-gray-6, #4d4d4d)));position:relative}:host(:not(:empty)) .btn-wrapper,.btn-wrapper.has-icon{--comp-close-size:var(--comp-pill-btn-height)}:host([active]) .btn-wrapper{--comp-btn-color:var(--tct-pill-active-btn-color, var(--t-pill-active-btn-color, var(--t-base, #ffffff)))}:host([theme=primary]) .btn-wrapper{--comp-active-btn-background:var(--t-primary-l5, #61c4ff);--comp-active-btn-color:var(--t-primary-text, #ffffff);--comp-active-btn-border-color:var(--t-primary-l5, #61c4ff);--comp-hover-active-btn-background:var(--t-primary-l3, #21acff);--comp-hover-active-btn-border-color:var(--t-primary-l3, #21acff)}:host([theme=secondary]) .btn-wrapper{--comp-active-btn-background:var(--t-secondary-l5, #d9e1e6);--comp-active-btn-color:var(--t-secondary-text, #141414);--comp-active-btn-border-color:var(--t-secondary-l5, #d9e1e6);--comp-hover-active-btn-background:var(--t-secondary-l3, #c9d5db);--comp-hover-active-btn-border-color:var(--t-secondary-l3, #c9d5db)}:host([theme=tertiary]) .btn-wrapper{--comp-active-btn-background:var(--t-tertiary-l5, #f4fafe);--comp-active-btn-color:var(--t-tertiary-text, #141414);--comp-active-btn-border-color:var(--t-tertiary-l5, #f4fafe);--comp-hover-active-btn-background:var(--t-tertiary-l3, #eff8fd);--comp-hover-active-btn-border-color:var(--t-tertiary-l3, #eff8fd)}.btn-height-wrapper{height:var(--comp-pill-min-height);display:flex;align-items:center;cursor:pointer}.btn-height-wrapper:focus{box-shadow:none}:host([disabled]) .btn-height-wrapper{cursor:not-allowed}.btn-close,.btn-primary{cursor:pointer;height:var(--comp-pill-btn-height);border-style:solid;border-radius:var(--tct-pill-btn-border-radius, var(--t-pill-btn-border-radius, 30px));transition-property:background, color, padding, width, opacity;transition:var(--tct-pill-btn-tween, var(--t-pill-btn-tween, var(--app-tween-1, 0.2s ease)))}:host([disabled]) .btn-close,:host([disabled]) .btn-primary,:host([disabled]) q2-icon{opacity:var(--tct-pill-disabled-opacity, var(--t-pill-disabled-opacity, var(--tct-disabled-opacity, var(--app-disabled-opacity, 0.4))));cursor:not-allowed}.btn-primary{background:var(--comp-btn-background);border-width:var(--comp-pill-btn-border-width);border-color:var(--tct-pill-btn-border-color, var(--t-pill-btn-border-color, var(--t-gray-9, #999999)));padding-inline:var(--comp-btn-padding);padding-right:calc(var(--comp-btn-padding) + var(--comp-close-size));font-size:var(--tct-pill-btn-font-size, var(--t-pill-btn-font-size, var(--app-font-size, 14px)));color:var(--comp-btn-color);display:block;width:100%;text-align:start}.btn-primary:focus,.btn-primary:hover{background:var(--comp-hover-btn-background)}:host(:not(:empty)) .btn-primary,.has-icon .btn-primary{padding-right:calc(var(--tct-pill-icon-gap, var(--t-pill-icon-gap, var(--app-scale-1x, 5px))) + var(--comp-close-size))}.has-options .btn-primary{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;max-width:var(--tct-pill-max-width, var(--t-pill-max-width, 200px))}:host([active]) .btn-primary{background:var(--comp-active-btn-background);border-color:var(--comp-active-btn-border-color);color:var(--comp-active-btn-color)}:host([active]) .btn-primary:focus,:host([active]) .btn-primary:hover{background:var(--comp-hover-active-btn-background);border-color:var(--comp-hover-active-btn-border-color)}.btn-close{background:transparent;border-color:transparent;border-width:var(--comp-pill-btn-border-width);width:var(--comp-close-size);height:var(--comp-close-size);padding:0;border:0;display:inline-flex;justify-content:center;align-items:center;position:absolute;right:0;top:50%;transform:translateY(-50%);opacity:0}:host([active]) .btn-close{color:var(--comp-active-btn-color)}:host(:not(:empty)) .btn-close,.has-icon .btn-close{opacity:1}q2-icon{--t-icon-stroke-primary:currentColor;width:var(--tct-pill-icon-size, var(--t-pill-icon-size, 14px));height:var(--tct-pill-icon-size, var(--t-pill-icon-size, 14px));transition-property:transform;transition:var(--tct-pill-btn-tween, var(--t-pill-btn-tween, var(--app-tween-1, 0.2s ease)))}div.btn-close{pointer-events:none}:host([open]) div.btn-close q2-icon{transform:rotate(180deg)}:host([active]) button.btn-close:focus,:host([active]) button.btn-close:hover{background:var(--tct-pill-hover-close-btn-background, var(--t-pill-hover-close-btn-background, var(--t-top-a1, rgba(13, 13, 13, 0.35))));border-color:var(--tct-pill-hover-close-btn-border-color, var(--t-pill-hover-close-btn-border-color, var(--t-top-a1, rgba(13, 13, 13, 0.35))))}q2-popover{position:relative;top:calc((var(--comp-pill-min-height) - var(--comp-pill-btn-height)) / 2 * -1)}";
|
|
9
|
+
|
|
10
|
+
const Q2Pill$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.__registerHost();
|
|
14
|
+
this.__attachShadow();
|
|
15
|
+
this.change = createEvent(this, "change", 7);
|
|
16
|
+
this.scheduledAfterRender = [];
|
|
17
|
+
this.activateFirstOption = false;
|
|
18
|
+
/// Helpers ///
|
|
19
|
+
this.determineHasOptions = () => {
|
|
20
|
+
const hasOptions = !!this.hostElement.querySelectorAll('q2-option').length;
|
|
21
|
+
this.hasOptions = hasOptions;
|
|
22
|
+
};
|
|
23
|
+
this.clearSelectedOptions = () => {
|
|
24
|
+
this.selectedOptions = [];
|
|
25
|
+
this.active = false;
|
|
26
|
+
this.open = false;
|
|
27
|
+
this.primaryBtn.focus();
|
|
28
|
+
this.change.emit({ value: null, values: [], active: false });
|
|
29
|
+
this.scheduledAfterRender.push(resizeIframe);
|
|
30
|
+
};
|
|
31
|
+
/// Event Handlers ///
|
|
32
|
+
this.handleClick = async (event) => {
|
|
33
|
+
event.stopPropagation();
|
|
34
|
+
if (this.disabled)
|
|
35
|
+
return;
|
|
36
|
+
if (this.hasOptions) {
|
|
37
|
+
this.activateFirstOption = false;
|
|
38
|
+
await this.popoverElement.toggle();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const { value, label } = this;
|
|
42
|
+
const isActive = (this.active = !this.active);
|
|
43
|
+
const values = isActive ? [{ value, display: label }] : [];
|
|
44
|
+
this.selectedOptions = values;
|
|
45
|
+
this.change.emit({
|
|
46
|
+
value,
|
|
47
|
+
values,
|
|
48
|
+
active: isActive,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
this.handleKeydown = (event) => {
|
|
53
|
+
if (!this.hasOptions || this.disabled)
|
|
54
|
+
return;
|
|
55
|
+
this.activateFirstOption = true;
|
|
56
|
+
this.optionList.handleExternalKeydown(event);
|
|
57
|
+
};
|
|
58
|
+
this.handleChange = event => {
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
if (!this.hasOptions)
|
|
61
|
+
return;
|
|
62
|
+
const { value, values } = event.detail;
|
|
63
|
+
const isActive = !!values.length;
|
|
64
|
+
if (!this.hostElement.onchange) {
|
|
65
|
+
this.selectedOptions = values;
|
|
66
|
+
this.active = isActive;
|
|
67
|
+
}
|
|
68
|
+
this.change.emit({ value, values, active: isActive });
|
|
69
|
+
};
|
|
70
|
+
this.handleWrapperClick = () => {
|
|
71
|
+
this.primaryBtn.focus();
|
|
72
|
+
this.primaryBtn.click();
|
|
73
|
+
};
|
|
74
|
+
this.onClickElsewhere = (event) => {
|
|
75
|
+
const target = event.target;
|
|
76
|
+
if (target.localName === 'click-elsewhere') {
|
|
77
|
+
event.stopPropagation();
|
|
78
|
+
this.popoverElement.open = false;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
this.disabled = undefined;
|
|
82
|
+
this.active = undefined;
|
|
83
|
+
this.open = undefined;
|
|
84
|
+
this.multiple = undefined;
|
|
85
|
+
this.maxLength = undefined;
|
|
86
|
+
this.label = undefined;
|
|
87
|
+
this.value = undefined;
|
|
88
|
+
this.theme = undefined;
|
|
89
|
+
this.selectedOptions = [];
|
|
90
|
+
this.popoverMinHeight = 150;
|
|
91
|
+
this.popoverDirection = undefined;
|
|
92
|
+
this.hasOptions = undefined;
|
|
93
|
+
}
|
|
94
|
+
/// LifeCycle Hooks ///
|
|
95
|
+
componentWillLoad() {
|
|
96
|
+
const observer = new MutationObserver(this.determineHasOptions);
|
|
97
|
+
observer.observe(this.hostElement, { childList: true, attributes: true });
|
|
98
|
+
this.mutationObserver = observer;
|
|
99
|
+
}
|
|
100
|
+
componentDidLoad() {
|
|
101
|
+
overrideFocus(this.hostElement);
|
|
102
|
+
}
|
|
103
|
+
componentDidRender() {
|
|
104
|
+
this.scheduledAfterRender.forEach(fn => fn());
|
|
105
|
+
this.scheduledAfterRender = [];
|
|
106
|
+
}
|
|
107
|
+
disconnectedCallback() {
|
|
108
|
+
this.mutationObserver.disconnect();
|
|
109
|
+
this.mutationObserver = null;
|
|
110
|
+
}
|
|
111
|
+
/// Getters ///
|
|
112
|
+
get buttonContent() {
|
|
113
|
+
const { label, selectedOptions, hasOptions } = this;
|
|
114
|
+
if (!hasOptions || selectedOptions.length === 0)
|
|
115
|
+
return label;
|
|
116
|
+
else if (selectedOptions.length === 1)
|
|
117
|
+
return selectedOptions[0].display;
|
|
118
|
+
return loc('tecton.element.pill.activeCount', { count: selectedOptions.length });
|
|
119
|
+
}
|
|
120
|
+
get truncatedButtonContent() {
|
|
121
|
+
const { maxLength, buttonContent } = this;
|
|
122
|
+
if (maxLength)
|
|
123
|
+
return buttonContent.length > maxLength ? `${buttonContent.substring(0, maxLength)}…` : buttonContent;
|
|
124
|
+
else
|
|
125
|
+
return buttonContent;
|
|
126
|
+
}
|
|
127
|
+
/// Listeners ///
|
|
128
|
+
delegateFocus(event) {
|
|
129
|
+
if (!isEventFromElement(event, this.hostElement))
|
|
130
|
+
return;
|
|
131
|
+
this.primaryBtn.focus();
|
|
132
|
+
}
|
|
133
|
+
popoverStateHandler({ detail: { open } }) {
|
|
134
|
+
if (this.open !== open)
|
|
135
|
+
this.open = open;
|
|
136
|
+
if (open && this.activateFirstOption) {
|
|
137
|
+
this.optionList.focus();
|
|
138
|
+
this.activateFirstOption = false;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this.optionList.setActiveElement(null);
|
|
142
|
+
this.primaryBtn.focus();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/// DOM ///
|
|
146
|
+
generateIcon() {
|
|
147
|
+
const { hasOptions, active } = this;
|
|
148
|
+
const isButton = hasOptions && active;
|
|
149
|
+
const TagName = isButton ? 'button' : 'div';
|
|
150
|
+
const iconName = isButton || !hasOptions ? 'close' : 'chevron-down';
|
|
151
|
+
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 })));
|
|
152
|
+
}
|
|
153
|
+
render() {
|
|
154
|
+
const { hasOptions, active, open } = this;
|
|
155
|
+
const wrapperClassNames = ['btn-wrapper'];
|
|
156
|
+
if (hasOptions || active)
|
|
157
|
+
wrapperClassNames.push('has-icon');
|
|
158
|
+
if (hasOptions)
|
|
159
|
+
wrapperClassNames.push('has-options');
|
|
160
|
+
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, 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.primaryBtnWrapper, open: this.open, minHeight: this.popoverMinHeight, direction: this.popoverDirection }, h("q2-option-list", { ref: el => (this.optionList = el), id: "option-list", onChange: this.handleChange, multiple: this.multiple, selectedOptions: this.selectedOptions }, h("slot", null))))));
|
|
161
|
+
}
|
|
162
|
+
get hostElement() { return this; }
|
|
163
|
+
static get style() { return stylesCss; }
|
|
164
|
+
}, [1, "q2-pill", {
|
|
165
|
+
"disabled": [516],
|
|
166
|
+
"active": [1540],
|
|
167
|
+
"open": [1540],
|
|
168
|
+
"multiple": [516],
|
|
169
|
+
"maxLength": [514, "max-length"],
|
|
170
|
+
"label": [513],
|
|
171
|
+
"value": [513],
|
|
172
|
+
"theme": [513],
|
|
173
|
+
"selectedOptions": [1040],
|
|
174
|
+
"popoverMinHeight": [2, "popover-min-height"],
|
|
175
|
+
"popoverDirection": [1, "popover-direction"],
|
|
176
|
+
"hasOptions": [32]
|
|
177
|
+
}, [[0, "focus", "delegateFocus"], [0, "popoverStateChanged", "popoverStateHandler"]]]);
|
|
178
|
+
function defineCustomElement$1() {
|
|
179
|
+
if (typeof customElements === "undefined") {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const components = ["q2-pill", "click-elsewhere", "q2-icon", "q2-option-list", "q2-popover"];
|
|
183
|
+
components.forEach(tagName => { switch (tagName) {
|
|
184
|
+
case "q2-pill":
|
|
185
|
+
if (!customElements.get(tagName)) {
|
|
186
|
+
customElements.define(tagName, Q2Pill$1);
|
|
187
|
+
}
|
|
188
|
+
break;
|
|
189
|
+
case "click-elsewhere":
|
|
190
|
+
if (!customElements.get(tagName)) {
|
|
191
|
+
defineCustomElement$5();
|
|
192
|
+
}
|
|
193
|
+
break;
|
|
194
|
+
case "q2-icon":
|
|
195
|
+
if (!customElements.get(tagName)) {
|
|
196
|
+
defineCustomElement$4();
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
case "q2-option-list":
|
|
200
|
+
if (!customElements.get(tagName)) {
|
|
201
|
+
defineCustomElement$3();
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
case "q2-popover":
|
|
205
|
+
if (!customElements.get(tagName)) {
|
|
206
|
+
defineCustomElement$2();
|
|
207
|
+
}
|
|
208
|
+
break;
|
|
209
|
+
} });
|
|
210
|
+
}
|
|
211
|
+
defineCustomElement$1();
|
|
212
|
+
|
|
213
|
+
const Q2Pill = Q2Pill$1;
|
|
214
|
+
const defineCustomElement = defineCustomElement$1;
|
|
215
|
+
|
|
216
|
+
export { Q2Pill, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface Q2Popover extends Components.Q2Popover, HTMLElement {}
|
|
4
|
+
export const Q2Popover: {
|
|
5
|
+
prototype: Q2Popover;
|
|
6
|
+
new (): Q2Popover;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface Q2RadioGroup extends Components.Q2RadioGroup, HTMLElement {}
|
|
4
|
+
export const Q2RadioGroup: {
|
|
5
|
+
prototype: Q2RadioGroup;
|
|
6
|
+
new (): Q2RadioGroup;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Fragment } from '@stencil/core/internal/client';
|
|
2
|
+
import { c as createGuid, o as overrideFocus, i as isEventFromElement, l as loc } from './index13.js';
|
|
3
|
+
import { d as defineCustomElement$2 } from './index7.js';
|
|
4
|
+
|
|
5
|
+
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{margin-top:var(--tct-scale-2, var(--app-scale-2x, 10px))}fieldset{padding:0;margin:0;border:0;position:relative}.label-row{display:grid;grid-template-columns:1fr 24px;grid-template-areas:\"label icon\";gap:var(--app-scale-1x, 5px)}.label-row q2-icon{grid-area:icon;margin-top:-2px;margin-bottom:-2px}.group-legend{font-weight:600}.optional-tag{margin-left:var(--tct-input-label-optional-margin-left, var(--t-input-label-optional-margin-left, var(--tct-scale-1, var(--app-scale-1x, 5px))));color:var(--tct-input-label-optional-font-color, var(--t-input-label-optional-font-color, var(--t-textA, var(--t-a11y-gray-color, rgba(77, 77, 77, 0.77)))));font-size:var(--tct-input-label-optional-font-size, var(--t-input-label-optional-font-size, 12px));font-weight:var(--tct-input-label-optional-font-weight, var(--t-input-label-optional-font-weight, 400))}.tile-container,.tile-container .options-container{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;flex-grow:1}.options-container{--comp-default-margin:var(--app-scale-1x, 5px) 0;--comp-options-margin:var(--tct-radio-group-options-margin, var(--t-radio-group-options-margin, var(--comp-default-margin, 5px 0)));margin:var(--comp-options-margin);padding:var(--tct-radio-group-options-padding, var(--t-radio-group-options-padding, var(--app-scale-1x, 5px)));border-width:1px;border-color:transparent;border-style:solid;border-radius:var(--tct-border-radius-1, var(--app-border-radius-1, 2px))}:host([has-error]) .options-container{border-color:var(--tct-input-error-border-color, var(--const-stoplight-alert, #c30000))}:host([has-error=false]) .options-container{border-color:transparent}.tile-container.left{justify-content:start}.tile-container.right{justify-content:end}.tile-container .options-container{gap:var(--tct-radio-group-tile-gap, var(--t-radio-group-tile-gap, var(--app-scale-2x, 10px)));justify-content:inherit}";
|
|
6
|
+
|
|
7
|
+
const Q2RadioGroup$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.__registerHost();
|
|
11
|
+
this.__attachShadow();
|
|
12
|
+
this.change = createEvent(this, "change", 7);
|
|
13
|
+
this.id = `radio-group-${createGuid()}`;
|
|
14
|
+
this.onMutationObserved = () => {
|
|
15
|
+
this.valueUpdated(this.value);
|
|
16
|
+
this.nameUpdated();
|
|
17
|
+
this.disabledUpdated();
|
|
18
|
+
this.readonlyUpdated();
|
|
19
|
+
this.tileLayoutUpdated(this.tileLayout);
|
|
20
|
+
};
|
|
21
|
+
this.onInnerRadioChange = (event) => {
|
|
22
|
+
event.stopImmediatePropagation();
|
|
23
|
+
if (this.readonly)
|
|
24
|
+
return;
|
|
25
|
+
this.change.emit({ value: event.detail.value });
|
|
26
|
+
};
|
|
27
|
+
this.label = undefined;
|
|
28
|
+
this.value = undefined;
|
|
29
|
+
this.disabled = false;
|
|
30
|
+
this.name = undefined;
|
|
31
|
+
this.optional = undefined;
|
|
32
|
+
this.readonly = undefined;
|
|
33
|
+
this.tileLayout = undefined;
|
|
34
|
+
this.tileAlignment = 'center';
|
|
35
|
+
this.hasError = false;
|
|
36
|
+
this.tilelayout = undefined;
|
|
37
|
+
}
|
|
38
|
+
get radioElements() {
|
|
39
|
+
return Array.from(this.hostElement.querySelectorAll('q2-radio'));
|
|
40
|
+
}
|
|
41
|
+
/////// LIFECYCLE HOOK ///////
|
|
42
|
+
componentWillLoad() {
|
|
43
|
+
this.onMutationObserved();
|
|
44
|
+
if (this.tilelayout)
|
|
45
|
+
this.tileLayout = this.tilelayout;
|
|
46
|
+
}
|
|
47
|
+
componentDidLoad() {
|
|
48
|
+
const observer = new MutationObserver(this.onMutationObserved);
|
|
49
|
+
observer.observe(this.hostElement, { childList: true });
|
|
50
|
+
this.mutationObserver = observer;
|
|
51
|
+
overrideFocus(this.hostElement);
|
|
52
|
+
}
|
|
53
|
+
/////// OBSERVERS ///////
|
|
54
|
+
valueUpdated(newVal) {
|
|
55
|
+
this.radioElements.forEach(radio => {
|
|
56
|
+
radio.checked = newVal === radio.value;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
nameUpdated() {
|
|
60
|
+
this.radioElements.forEach(radio => {
|
|
61
|
+
radio.name = this.name || this.id;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
disabledUpdated() {
|
|
65
|
+
this.radioElements.forEach(radio => {
|
|
66
|
+
radio.groupDisabled = this.disabled;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
readonlyUpdated() {
|
|
70
|
+
const readonly = this.readonly;
|
|
71
|
+
this.radioElements.forEach(radio => (radio.groupReadonly = readonly));
|
|
72
|
+
}
|
|
73
|
+
tilelayoutUpdated(tilelayout) {
|
|
74
|
+
this.tileLayout = tilelayout;
|
|
75
|
+
}
|
|
76
|
+
tileLayoutUpdated(tileLayout) {
|
|
77
|
+
this.radioElements.forEach(radio => {
|
|
78
|
+
radio.groupTileLayout = tileLayout;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
onHostElementChange(event) {
|
|
82
|
+
if (event.target === this.hostElement) {
|
|
83
|
+
if (!this.hostElement.onchange) {
|
|
84
|
+
this.value = event.detail.value;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
delegateFocus(event) {
|
|
89
|
+
if (!isEventFromElement(event, this.hostElement))
|
|
90
|
+
return;
|
|
91
|
+
const radio = this.hostElement.querySelector('q2-radio[checked]') || this.hostElement.querySelector('q2-radio');
|
|
92
|
+
radio === null || radio === void 0 ? void 0 : radio.dispatchEvent(new FocusEvent('focus'));
|
|
93
|
+
}
|
|
94
|
+
keydownHandler(event) {
|
|
95
|
+
const currentValue = event.target.getAttribute('value') || this.value;
|
|
96
|
+
let index = this.radioElements.findIndex(el => el === event.target || el.getAttribute('value') === currentValue);
|
|
97
|
+
let sign = 0;
|
|
98
|
+
switch (event.key) {
|
|
99
|
+
case 'ArrowLeft':
|
|
100
|
+
case 'ArrowUp':
|
|
101
|
+
sign = -1;
|
|
102
|
+
break;
|
|
103
|
+
case 'ArrowRight':
|
|
104
|
+
case 'ArrowDown':
|
|
105
|
+
sign = 1;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
if (index === -1 || sign === 0) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
index += sign;
|
|
112
|
+
index = sign < 0 ? Math.max(0, index) : Math.min(this.radioElements.length - 1, index);
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
if (!this.readonly) {
|
|
115
|
+
this.value = this.radioElements[index].value;
|
|
116
|
+
}
|
|
117
|
+
this.radioElements[index].dispatchEvent(new FocusEvent('focus'));
|
|
118
|
+
}
|
|
119
|
+
labelDOM() {
|
|
120
|
+
const { label, optional, readonly } = this;
|
|
121
|
+
let helpText = '';
|
|
122
|
+
if (readonly) {
|
|
123
|
+
helpText = h("span", { class: "optional-tag" }, loc('tecton.element.input.readonly'));
|
|
124
|
+
}
|
|
125
|
+
else if (optional) {
|
|
126
|
+
helpText = h("span", { class: "optional-tag" }, loc('tecton.element.input.optional'));
|
|
127
|
+
}
|
|
128
|
+
return (h(Fragment, null, label && loc(label), !!helpText && h("span", { class: "optional-tag" }, helpText)));
|
|
129
|
+
}
|
|
130
|
+
render() {
|
|
131
|
+
const showLabel = this.label || this.optional || this.readonly;
|
|
132
|
+
const { hasError } = this;
|
|
133
|
+
const showLabelRow = showLabel || hasError;
|
|
134
|
+
return (h(Fragment, null, showLabelRow && (h("div", { class: "label-row" }, showLabel && h("div", { class: "group-legend" }, this.labelDOM()), hasError && (h("q2-icon", { type: "error", "test-id": "iconError" })))), h("fieldset", { onChange: this.onInnerRadioChange, "aria-required": `${!this.optional}`, "aria-readonly": `${this.readonly}`, "aria-invalid": `${this.hasError}` }, showLabel && h("legend", { class: "sr" }, this.labelDOM()), this.inputDom())));
|
|
135
|
+
}
|
|
136
|
+
inputDom() {
|
|
137
|
+
if (this.tileLayout) {
|
|
138
|
+
const { tileAlignment } = this;
|
|
139
|
+
const alignment = ['left', 'center', 'right'].includes(tileAlignment) ? tileAlignment : 'center';
|
|
140
|
+
return (h("div", { class: `tile-container ${alignment}` }, h("div", { class: "options-container" }, h("slot", null))));
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
return (h("div", { class: "options-container" }, h("slot", null)));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
get hostElement() { return this; }
|
|
147
|
+
static get watchers() { return {
|
|
148
|
+
"value": ["valueUpdated"],
|
|
149
|
+
"name": ["nameUpdated"],
|
|
150
|
+
"disabled": ["disabledUpdated"],
|
|
151
|
+
"readonly": ["readonlyUpdated"],
|
|
152
|
+
"tilelayout": ["tilelayoutUpdated"],
|
|
153
|
+
"tileLayout": ["tileLayoutUpdated"]
|
|
154
|
+
}; }
|
|
155
|
+
static get style() { return stylesCss; }
|
|
156
|
+
}, [1, "q2-radio-group", {
|
|
157
|
+
"label": [513],
|
|
158
|
+
"value": [1025],
|
|
159
|
+
"disabled": [516],
|
|
160
|
+
"name": [513],
|
|
161
|
+
"optional": [516],
|
|
162
|
+
"readonly": [516],
|
|
163
|
+
"tileLayout": [516, "tile-layout"],
|
|
164
|
+
"tileAlignment": [513, "tile-alignment"],
|
|
165
|
+
"hasError": [516, "has-error"],
|
|
166
|
+
"tilelayout": [516]
|
|
167
|
+
}, [[0, "change", "onHostElementChange"], [0, "focus", "delegateFocus"], [0, "keydown", "keydownHandler"]]]);
|
|
168
|
+
function defineCustomElement$1() {
|
|
169
|
+
if (typeof customElements === "undefined") {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const components = ["q2-radio-group", "q2-icon"];
|
|
173
|
+
components.forEach(tagName => { switch (tagName) {
|
|
174
|
+
case "q2-radio-group":
|
|
175
|
+
if (!customElements.get(tagName)) {
|
|
176
|
+
customElements.define(tagName, Q2RadioGroup$1);
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
case "q2-icon":
|
|
180
|
+
if (!customElements.get(tagName)) {
|
|
181
|
+
defineCustomElement$2();
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
} });
|
|
185
|
+
}
|
|
186
|
+
defineCustomElement$1();
|
|
187
|
+
|
|
188
|
+
const Q2RadioGroup = Q2RadioGroup$1;
|
|
189
|
+
const defineCustomElement = defineCustomElement$1;
|
|
190
|
+
|
|
191
|
+
export { Q2RadioGroup, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface Q2Radio extends Components.Q2Radio, HTMLElement {}
|
|
4
|
+
export const Q2Radio: {
|
|
5
|
+
prototype: Q2Radio;
|
|
6
|
+
new (): Q2Radio;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|