@3t-transform/threeteeui 0.2.115 → 0.2.116
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/loader.cjs.js +1 -1
- package/dist/cjs/tttx-form.cjs.entry.js +42 -15
- package/dist/cjs/tttx-select-box.cjs.entry.js +17 -4
- package/dist/cjs/tttx.cjs.js +1 -1
- package/dist/collection/components/molecules/tttx-form/tttx-form.js +45 -15
- package/dist/collection/components/molecules/tttx-select-box/tttx-select-box.js +43 -4
- package/dist/components/tttx-form.js +61 -16
- package/dist/components/tttx-select-box.js +1 -155
- package/dist/components/tttx-select-box2.js +171 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tttx-form.entry.js +42 -15
- package/dist/esm/tttx-select-box.entry.js +17 -4
- package/dist/esm/tttx.js +1 -1
- package/dist/tttx/p-a144a5ec.entry.js +1 -0
- package/dist/tttx/p-e6514754.entry.js +1 -0
- package/dist/tttx/tttx.esm.js +1 -1
- package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +6 -2
- package/dist/types/components/molecules/tttx-select-box/tttx-select-box.d.ts +2 -0
- package/dist/types/components.d.ts +1 -0
- package/package.json +1 -1
- package/dist/tttx/p-64d61284.entry.js +0 -1
- package/dist/tttx/p-ae4e3fe8.entry.js +0 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
import { p as purify, d as domSanitiserOptions } from './domsanitiser.options.js';
|
|
3
|
+
import { d as defineCustomElement$4 } from './tttx-icon2.js';
|
|
4
|
+
import { d as defineCustomElement$3 } from './tttx-select-box2.js';
|
|
5
|
+
import { d as defineCustomElement$2 } from './tttx-standalone-input2.js';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* Validates the input field on focusout event by checking its validity state,
|
|
@@ -191,7 +194,7 @@ const TttxForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
191
194
|
*/
|
|
192
195
|
async setSelectOptions(fieldname, options) {
|
|
193
196
|
const select = this.fieldset.querySelector(`[name=${fieldname}]`);
|
|
194
|
-
|
|
197
|
+
const tttxSelect = this.fieldset.querySelector(`[name=overlay-${fieldname}]`);
|
|
195
198
|
const fragment = new DocumentFragment();
|
|
196
199
|
for (const option of options) {
|
|
197
200
|
const o = document.createElement('option');
|
|
@@ -199,7 +202,10 @@ const TttxForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
199
202
|
o.value = option.value;
|
|
200
203
|
fragment.appendChild(o);
|
|
201
204
|
}
|
|
202
|
-
select.
|
|
205
|
+
select.replaceChildren(fragment);
|
|
206
|
+
tttxSelect.optionsData = options;
|
|
207
|
+
//await tttxSelect.setOptionsData(options);
|
|
208
|
+
await tttxSelect.setSelectedItem(options[0].value);
|
|
203
209
|
}
|
|
204
210
|
/**
|
|
205
211
|
* Submits the form data to the server.
|
|
@@ -256,7 +262,7 @@ const TttxForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
256
262
|
* @param {boolean} [formProperties.options[].placeholder]
|
|
257
263
|
*/
|
|
258
264
|
createSelect(formKey, formProperties) {
|
|
259
|
-
var _a;
|
|
265
|
+
var _a, _b, _c, _d;
|
|
260
266
|
const select = document.createElement('select');
|
|
261
267
|
select.setAttribute('name', formKey);
|
|
262
268
|
formProperties.options.forEach(optionProperties => {
|
|
@@ -264,7 +270,22 @@ const TttxForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
264
270
|
});
|
|
265
271
|
if ((_a = this._data) === null || _a === void 0 ? void 0 : _a[formKey])
|
|
266
272
|
select.classList.remove('placeholder');
|
|
267
|
-
|
|
273
|
+
const tttxSelect = document.createElement('tttx-select-box');
|
|
274
|
+
tttxSelect.optionsData = (_b = formProperties.options) === null || _b === void 0 ? void 0 : _b.filter(o => !o.placeholder);
|
|
275
|
+
tttxSelect.placeholder = (_d = (_c = formProperties.options) === null || _c === void 0 ? void 0 : _c.filter(o => o.placeholder)[0]) === null || _d === void 0 ? void 0 : _d.label;
|
|
276
|
+
tttxSelect.inline = false;
|
|
277
|
+
tttxSelect.searchEnabled = true;
|
|
278
|
+
tttxSelect.style.width = '100%';
|
|
279
|
+
tttxSelect.style.marginTop = '6px';
|
|
280
|
+
tttxSelect.setAttribute('name', 'overlay-' + formKey);
|
|
281
|
+
const fragment = document.createDocumentFragment();
|
|
282
|
+
fragment.append(tttxSelect);
|
|
283
|
+
select.style.display = 'none';
|
|
284
|
+
tttxSelect.addEventListener('selectItemEvent', function (ev) {
|
|
285
|
+
select.value = ev.detail.value;
|
|
286
|
+
select.onblur({ target: select });
|
|
287
|
+
});
|
|
288
|
+
return { input: select, overlay: fragment };
|
|
268
289
|
}
|
|
269
290
|
/**
|
|
270
291
|
* Appends an option to a select element
|
|
@@ -492,10 +513,11 @@ const TttxForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
492
513
|
*
|
|
493
514
|
* @param {Record<string, any>} formProperties - An object containing properties for the form field, including its label text and validation rules.
|
|
494
515
|
* @param {HTMLInputElement | HTMLSelectElement} input - The input element to associate with the label.
|
|
516
|
+
* @param {never} overlay - The Child Element which will be rendered atop the standard HTML5 element
|
|
495
517
|
* @param {HTMLDivElement} errorBubble - The error bubble element to display error messages in.
|
|
496
518
|
* @return {HTMLLabelElement} - The new label element.
|
|
497
519
|
*/
|
|
498
|
-
createLabel(formProperties, input, errorBubble) {
|
|
520
|
+
createLabel(formProperties, input, overlay, errorBubble) {
|
|
499
521
|
var _a;
|
|
500
522
|
const outerContainer = document.createElement('div');
|
|
501
523
|
let outerContainerClassName = 'outer-container inputBlock';
|
|
@@ -521,6 +543,9 @@ const TttxForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
521
543
|
}
|
|
522
544
|
else {
|
|
523
545
|
// Append the input element and error bubble element to the outerContainer
|
|
546
|
+
if (overlay) {
|
|
547
|
+
outerContainer.appendChild(overlay);
|
|
548
|
+
}
|
|
524
549
|
outerContainer.appendChild(input);
|
|
525
550
|
}
|
|
526
551
|
if (formProperties.type !== 'checkbox') {
|
|
@@ -590,33 +615,33 @@ const TttxForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
590
615
|
this.template.content.append(end);
|
|
591
616
|
continue;
|
|
592
617
|
}
|
|
593
|
-
let
|
|
618
|
+
let fragments = {};
|
|
594
619
|
switch (formProperties.type) {
|
|
595
620
|
case 'select':
|
|
596
|
-
|
|
621
|
+
fragments = this.createSelect(formKey, formProperties);
|
|
597
622
|
break;
|
|
598
623
|
case 'radio':
|
|
599
|
-
input = this.createRadio(formKey, formProperties);
|
|
624
|
+
fragments.input = this.createRadio(formKey, formProperties);
|
|
600
625
|
break;
|
|
601
626
|
case 'textarea':
|
|
602
|
-
input = this.createTextArea(formKey, formProperties);
|
|
627
|
+
fragments.input = this.createTextArea(formKey, formProperties);
|
|
603
628
|
break;
|
|
604
629
|
default:
|
|
605
|
-
input = this.createInput(formKey, formProperties);
|
|
630
|
+
fragments.input = this.createInput(formKey, formProperties);
|
|
606
631
|
}
|
|
607
632
|
// If the form property has validation, apply it to the input
|
|
608
633
|
if (formProperties.validation &&
|
|
609
634
|
formProperties.type !== 'radio') {
|
|
610
|
-
this.applyValidation(input, formProperties.validation);
|
|
635
|
+
this.applyValidation(fragments.input, formProperties.validation);
|
|
611
636
|
}
|
|
612
637
|
// Create an error bubble and label element for the input
|
|
613
638
|
const errorBubble = this.createErrorBubble();
|
|
614
|
-
const label = this.createLabel(formProperties, input, errorBubble);
|
|
639
|
+
const label = this.createLabel(formProperties, fragments.input, fragments.overlay, errorBubble);
|
|
615
640
|
// If explicitly setting input as invalid, set invalid state and error message on render
|
|
616
641
|
if ((_a = formProperties.validation) === null || _a === void 0 ? void 0 : _a.invalid) {
|
|
617
642
|
const errorMessage = formProperties.validation.invalid.message;
|
|
618
|
-
input.setCustomValidity(errorMessage); // Prevents the invalid styling from resetting on blur
|
|
619
|
-
setErrorState(input, true, errorMessage);
|
|
643
|
+
fragments.input.setCustomValidity(errorMessage); // Prevents the invalid styling from resetting on blur
|
|
644
|
+
setErrorState(fragments.input, true, errorMessage);
|
|
620
645
|
}
|
|
621
646
|
// Append the label element to the form template
|
|
622
647
|
this.template.content.append(label);
|
|
@@ -637,7 +662,7 @@ const TttxForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
637
662
|
return;
|
|
638
663
|
}
|
|
639
664
|
// Clone the template's content and store it in a variable
|
|
640
|
-
const formItems = this.template.content
|
|
665
|
+
const formItems = this.template.content;
|
|
641
666
|
// Bind event listeners to form elements
|
|
642
667
|
const properties = this._formSchema.properties;
|
|
643
668
|
const propertyKeys = Object.keys(properties);
|
|
@@ -685,6 +710,11 @@ const TttxForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
685
710
|
formItem.checked = true;
|
|
686
711
|
}
|
|
687
712
|
break;
|
|
713
|
+
case 'select':
|
|
714
|
+
case 'select-one':
|
|
715
|
+
formItems.querySelector(`[name=overlay-${key}]`).selectedValue = this._data[key];
|
|
716
|
+
formItem.value = this._data[key];
|
|
717
|
+
break;
|
|
688
718
|
default:
|
|
689
719
|
formItem.value = this._data[key];
|
|
690
720
|
}
|
|
@@ -785,13 +815,28 @@ function defineCustomElement$1() {
|
|
|
785
815
|
if (typeof customElements === "undefined") {
|
|
786
816
|
return;
|
|
787
817
|
}
|
|
788
|
-
const components = ["tttx-form"];
|
|
818
|
+
const components = ["tttx-form", "tttx-icon", "tttx-select-box", "tttx-standalone-input"];
|
|
789
819
|
components.forEach(tagName => { switch (tagName) {
|
|
790
820
|
case "tttx-form":
|
|
791
821
|
if (!customElements.get(tagName)) {
|
|
792
822
|
customElements.define(tagName, TttxForm$1);
|
|
793
823
|
}
|
|
794
824
|
break;
|
|
825
|
+
case "tttx-icon":
|
|
826
|
+
if (!customElements.get(tagName)) {
|
|
827
|
+
defineCustomElement$4();
|
|
828
|
+
}
|
|
829
|
+
break;
|
|
830
|
+
case "tttx-select-box":
|
|
831
|
+
if (!customElements.get(tagName)) {
|
|
832
|
+
defineCustomElement$3();
|
|
833
|
+
}
|
|
834
|
+
break;
|
|
835
|
+
case "tttx-standalone-input":
|
|
836
|
+
if (!customElements.get(tagName)) {
|
|
837
|
+
defineCustomElement$2();
|
|
838
|
+
}
|
|
839
|
+
break;
|
|
795
840
|
} });
|
|
796
841
|
}
|
|
797
842
|
|
|
@@ -1,158 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { p as purify, d as domSanitiserOptions } from './domsanitiser.options.js';
|
|
3
|
-
import { d as defineCustomElement$3 } from './tttx-icon2.js';
|
|
4
|
-
import { d as defineCustomElement$2 } from './tttx-standalone-input2.js';
|
|
5
|
-
|
|
6
|
-
const tttxSelectBoxCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}:host{display:flex;gap:4px}.label{font-size:16px;font-weight:500;line-height:18.752px;color:#212121}:host(.inline) .label{padding-top:8px}:host(.block){flex-direction:column}.dropdown-container{position:relative;display:flex;flex-direction:column;width:100%}.dropdown-container:focus-visible{outline:none}.dropdown-container:focus .dropdown-selector{border:1px solid #1479c6}.dropdown-selector,.dropdown-body{display:flex;border-radius:4px;background-color:white}.dropdown-selector{min-height:36px;box-sizing:border-box;align-items:center;gap:8px;padding:4px 8px 4px 16px;cursor:pointer;justify-content:space-between;border:1px solid #d5d5d5;display:flex;flex-direction:row}.dropdown-selector>.left-wrapper{flex:1;min-width:0}.description{color:#757575;font-size:14px;line-height:16.408px}.description>p{margin:0}.description-dd{color:#757575;font-size:14px;line-height:16.408px}.description-dd>p{margin:0}.truncated-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#212121;font-size:16px;line-height:18.752px}.dropdown-selector-chevron{height:24px}.dropdown-selector-chevron-offset{height:24px}.dropdown-selector-chevron>tttx-icon{cursor:pointer}.dropdown-body-container{position:relative;z-index:2}.dropdown-body{position:absolute;flex-direction:column;box-shadow:0px 1px 5px #1111114D;padding-bottom:8px;border:1px solid #d5d5d5}.dropdown-options-list{display:flex;flex-direction:column;overflow-y:auto;max-height:368px}.dropdown-option{padding:6px 8px 6px 16px;cursor:pointer}.dropdown-option:hover{background-color:#1111110d}.dropdown-option:active,.dropdown-option.selected{background-color:#ebfbfc}.placeholder{color:#9e9e9e;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis}.searchbox{padding:8px 16px}.searchbox tttx-standalone-input{margin-top:-4px}.hidden{display:none}";
|
|
7
|
-
|
|
8
|
-
const TttxSelectBox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
this.__registerHost();
|
|
12
|
-
this.__attachShadow();
|
|
13
|
-
this.selectItemEvent = createEvent(this, "selectItemEvent", 3);
|
|
14
|
-
this.toggleOpen = createEvent(this, "toggleOpen", 3);
|
|
15
|
-
this.bodyOffset = {};
|
|
16
|
-
this.optionsData = null;
|
|
17
|
-
this.label = undefined;
|
|
18
|
-
this.inline = undefined;
|
|
19
|
-
this.placeholder = '';
|
|
20
|
-
this.searchEnabled = undefined;
|
|
21
|
-
this.selectedValue = undefined;
|
|
22
|
-
this.open = false;
|
|
23
|
-
this.selectedItem = undefined;
|
|
24
|
-
this.searchTerm = '';
|
|
25
|
-
}
|
|
26
|
-
async componentWillLoad() {
|
|
27
|
-
if (this.optionsData) {
|
|
28
|
-
// attempt to preselect an item if specified
|
|
29
|
-
const parsedOptionsData = (typeof this.optionsData === 'string') ? JSON.parse(this.optionsData) : this.optionsData;
|
|
30
|
-
const matchingItems = parsedOptionsData.filter((item) => { return item.value == this.selectedValue; });
|
|
31
|
-
this.selectedItem = (matchingItems.length > 0) ? matchingItems[0] : undefined;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
handleCloseSelectBox() {
|
|
35
|
-
this.open = false;
|
|
36
|
-
}
|
|
37
|
-
handleBlur() {
|
|
38
|
-
this.open = false;
|
|
39
|
-
this.toggleOpen.emit(false);
|
|
40
|
-
}
|
|
41
|
-
onDropdownClicked() {
|
|
42
|
-
this.open = !this.open;
|
|
43
|
-
this.searchTerm = '';
|
|
44
|
-
this.calculateDropdownMenuOffset();
|
|
45
|
-
this.toggleOpen.emit(this.open);
|
|
46
|
-
}
|
|
47
|
-
onItemSelected(option) {
|
|
48
|
-
this.selectedItem = option;
|
|
49
|
-
this.selectItemEvent.emit(this.selectedItem);
|
|
50
|
-
this.handleBlur();
|
|
51
|
-
}
|
|
52
|
-
dropdownSelectorContent() {
|
|
53
|
-
let title;
|
|
54
|
-
let subtitle;
|
|
55
|
-
const chevronIcon = this.open ? 'expand_less' : 'expand_more';
|
|
56
|
-
const icon = h("tttx-icon", { icon: chevronIcon, color: "black" });
|
|
57
|
-
let chevron = h("div", { class: 'dropdown-selector-chevron' }, icon);
|
|
58
|
-
if (!this.selectedItem) {
|
|
59
|
-
title = h("div", { class: "placeholder" }, this.placeholder);
|
|
60
|
-
return h(Fragment, null, title, chevron);
|
|
61
|
-
}
|
|
62
|
-
else if (this.selectedItem.html) {
|
|
63
|
-
title = h("div", { title: this.selectedItem.label, class: "truncated-text", innerHTML: this.selectedItem.html });
|
|
64
|
-
return h(Fragment, null, title, chevron);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
title = h("div", { title: this.selectedItem.label, class: "truncated-text" }, this.selectedItem.label);
|
|
68
|
-
if (this.selectedItem.description) {
|
|
69
|
-
subtitle = h("div", { class: "description" }, h("p", null, this.selectedItem.description));
|
|
70
|
-
chevron = h("div", { class: 'dropdown-selector-chevron-offset' }, icon);
|
|
71
|
-
}
|
|
72
|
-
return h(Fragment, null, h("div", { class: "left-wrapper" }, title, subtitle), chevron);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
dropdownOption(option) {
|
|
76
|
-
/* istanbul ignore next */
|
|
77
|
-
const hideOption = this.searchEnabled && option.label.toLowerCase().indexOf(this.searchTerm.toLowerCase()) === -1;
|
|
78
|
-
const selected = this.selectedItem && option.value === this.selectedItem.value;
|
|
79
|
-
if (option.html) {
|
|
80
|
-
const sanitisedHTML = purify.sanitize(option.html, domSanitiserOptions);
|
|
81
|
-
/* istanbul ignore next */
|
|
82
|
-
return (h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label, innerHTML: sanitisedHTML }));
|
|
83
|
-
}
|
|
84
|
-
else if (option.description) {
|
|
85
|
-
return (h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label }, option.label, h("div", { class: "description-dd" }, h("p", null, option.description))));
|
|
86
|
-
}
|
|
87
|
-
/* istanbul ignore next */
|
|
88
|
-
return (h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label }, option.label));
|
|
89
|
-
}
|
|
90
|
-
/* istanbul ignore next */
|
|
91
|
-
handleSearchInput(event) {
|
|
92
|
-
const target = event.target;
|
|
93
|
-
this.searchTerm = target.value;
|
|
94
|
-
}
|
|
95
|
-
calculateDropdownMenuOffset() {
|
|
96
|
-
const dropdownSelector = this.el.shadowRoot.querySelector('.dropdown-selector');
|
|
97
|
-
const bottomPosY = this.dropdownSelector.getBoundingClientRect().bottom;
|
|
98
|
-
// (Max list height OR 31px * number of items) + 52px for search bar + 8px padding at bottom
|
|
99
|
-
let dropdownMenuMaxHeight = Math.min((368), 36 * this._optionsData.length) + 8;
|
|
100
|
-
if (this.searchEnabled)
|
|
101
|
-
dropdownMenuMaxHeight += 52;
|
|
102
|
-
const clientRectangle = dropdownSelector.getBoundingClientRect();
|
|
103
|
-
if (bottomPosY + dropdownMenuMaxHeight > window.innerHeight) {
|
|
104
|
-
this.bodyOffset = { top: `${window.innerHeight - (dropdownMenuMaxHeight + 16)}px`, position: 'fixed', width: `${dropdownSelector.offsetWidth}px`, zIndex: '10' };
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
this.bodyOffset = { position: 'fixed', left: clientRectangle.left, top: clientRectangle.top, width: (clientRectangle.width - 2) + 'px', zIndex: '10' };
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
render() {
|
|
111
|
-
if (!this.optionsData)
|
|
112
|
-
return;
|
|
113
|
-
this._optionsData = typeof this.optionsData === 'string' ? JSON.parse(this.optionsData) : this.optionsData;
|
|
114
|
-
return (h(Host, { class: this.inline ? 'inline' : 'block' }, this.label && h("div", { class: "label" }, this.label), h("div", { tabindex: "0", class: "dropdown-container" }, h("div", { class: "dropdown-selector", ref: (el) => this.dropdownSelector = el, onClick: this.onDropdownClicked.bind(this) }, this.dropdownSelectorContent()), this.open && (h("div", { class: "dropdown-body-container" }, h("div", { class: "dropdown-body", style: Object.assign({ width: `${this.dropdownSelector.offsetWidth}px` }, this.bodyOffset) }, this.searchEnabled &&
|
|
115
|
-
/* istanbul ignore next */
|
|
116
|
-
h("div", { class: "searchbox" }, h("tttx-standalone-input", { type: "text", label: "", required: true, showerrorbubble: false, iconleft: 'search', onInput: this.handleSearchInput.bind(this) })), h("div", { class: "dropdown-options-list" }, this._optionsData.map((option) => {
|
|
117
|
-
return this.dropdownOption(option);
|
|
118
|
-
}))))))));
|
|
119
|
-
}
|
|
120
|
-
get el() { return this; }
|
|
121
|
-
static get style() { return tttxSelectBoxCss; }
|
|
122
|
-
}, [1, "tttx-select-box", {
|
|
123
|
-
"optionsData": [1, "options-data"],
|
|
124
|
-
"label": [1],
|
|
125
|
-
"inline": [4],
|
|
126
|
-
"placeholder": [1],
|
|
127
|
-
"searchEnabled": [4, "search-enabled"],
|
|
128
|
-
"selectedValue": [1, "selected-value"],
|
|
129
|
-
"open": [32],
|
|
130
|
-
"selectedItem": [32],
|
|
131
|
-
"searchTerm": [32]
|
|
132
|
-
}, [[0, "closeSelectBox", "handleCloseSelectBox"], [0, "blur", "handleBlur"]]]);
|
|
133
|
-
function defineCustomElement$1() {
|
|
134
|
-
if (typeof customElements === "undefined") {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const components = ["tttx-select-box", "tttx-icon", "tttx-standalone-input"];
|
|
138
|
-
components.forEach(tagName => { switch (tagName) {
|
|
139
|
-
case "tttx-select-box":
|
|
140
|
-
if (!customElements.get(tagName)) {
|
|
141
|
-
customElements.define(tagName, TttxSelectBox$1);
|
|
142
|
-
}
|
|
143
|
-
break;
|
|
144
|
-
case "tttx-icon":
|
|
145
|
-
if (!customElements.get(tagName)) {
|
|
146
|
-
defineCustomElement$3();
|
|
147
|
-
}
|
|
148
|
-
break;
|
|
149
|
-
case "tttx-standalone-input":
|
|
150
|
-
if (!customElements.get(tagName)) {
|
|
151
|
-
defineCustomElement$2();
|
|
152
|
-
}
|
|
153
|
-
break;
|
|
154
|
-
} });
|
|
155
|
-
}
|
|
1
|
+
import { T as TttxSelectBox$1, d as defineCustomElement$1 } from './tttx-select-box2.js';
|
|
156
2
|
|
|
157
3
|
const TttxSelectBox = TttxSelectBox$1;
|
|
158
4
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Fragment, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { p as purify, d as domSanitiserOptions } from './domsanitiser.options.js';
|
|
3
|
+
import { d as defineCustomElement$2 } from './tttx-icon2.js';
|
|
4
|
+
import { d as defineCustomElement$1 } from './tttx-standalone-input2.js';
|
|
5
|
+
|
|
6
|
+
const tttxSelectBoxCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}:host{display:flex;gap:4px}.label{font-size:16px;font-weight:500;line-height:18.752px;color:#212121}:host(.inline) .label{padding-top:8px}:host(.block){flex-direction:column}.dropdown-container{position:relative;display:flex;flex-direction:column;width:100%}.dropdown-container:focus-visible{outline:none}.dropdown-container:focus .dropdown-selector{border:1px solid #1479c6}.dropdown-selector,.dropdown-body{display:flex;border-radius:4px;background-color:white}.dropdown-selector{min-height:36px;box-sizing:border-box;align-items:center;gap:8px;padding:4px 8px 4px 16px;cursor:pointer;justify-content:space-between;border:1px solid #d5d5d5;display:flex;flex-direction:row}.dropdown-selector>.left-wrapper{flex:1;min-width:0}.description{color:#757575;font-size:14px;line-height:16.408px}.description>p{margin:0}.description-dd{color:#757575;font-size:14px;line-height:16.408px}.description-dd>p{margin:0}.truncated-text{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#212121;font-size:16px;line-height:18.752px}.dropdown-selector-chevron{height:24px}.dropdown-selector-chevron-offset{height:24px}.dropdown-selector-chevron>tttx-icon{cursor:pointer}.dropdown-body-container{position:relative;z-index:2}.dropdown-body{position:absolute;flex-direction:column;box-shadow:0px 1px 5px #1111114D;padding-bottom:8px;border:1px solid #d5d5d5}.dropdown-options-list{display:flex;flex-direction:column;overflow-y:auto;max-height:368px}.dropdown-option{padding:6px 8px 6px 16px;cursor:pointer}.dropdown-option:hover{background-color:#1111110d}.dropdown-option:active,.dropdown-option.selected{background-color:#ebfbfc}.placeholder{color:#9e9e9e;white-space:nowrap;overflow-x:hidden;text-overflow:ellipsis}.searchbox{padding:8px 16px}.searchbox tttx-standalone-input{margin-top:-4px}.hidden{display:none}";
|
|
7
|
+
|
|
8
|
+
const TttxSelectBox = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.__registerHost();
|
|
12
|
+
this.__attachShadow();
|
|
13
|
+
this.selectItemEvent = createEvent(this, "selectItemEvent", 3);
|
|
14
|
+
this.toggleOpen = createEvent(this, "toggleOpen", 3);
|
|
15
|
+
this.bodyOffset = {};
|
|
16
|
+
this.optionsData = null;
|
|
17
|
+
this.label = undefined;
|
|
18
|
+
this.inline = undefined;
|
|
19
|
+
this.placeholder = '';
|
|
20
|
+
this.searchEnabled = undefined;
|
|
21
|
+
this.selectedValue = undefined;
|
|
22
|
+
this.open = false;
|
|
23
|
+
this.selectedItem = undefined;
|
|
24
|
+
this.searchTerm = '';
|
|
25
|
+
}
|
|
26
|
+
async componentWillLoad() {
|
|
27
|
+
if (this.optionsData) {
|
|
28
|
+
this.setOptionsData();
|
|
29
|
+
const matchingItems = this._optionsData.filter((item) => { return item.value == this.selectedValue; });
|
|
30
|
+
this.selectedItem = (matchingItems.length > 0) ? matchingItems[0] : undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async setOptionsData() {
|
|
34
|
+
this._optionsData = typeof this.optionsData === 'string' ? JSON.parse(this.optionsData) : this.optionsData;
|
|
35
|
+
}
|
|
36
|
+
async setSelectedItem(value) {
|
|
37
|
+
if (!value)
|
|
38
|
+
return;
|
|
39
|
+
const item = this._optionsData.find(x => x.value.toLowerCase() === value.toLowerCase());
|
|
40
|
+
if (!item)
|
|
41
|
+
return;
|
|
42
|
+
this.selectedValue = item.value;
|
|
43
|
+
this.selectedItem = item;
|
|
44
|
+
}
|
|
45
|
+
handleCloseSelectBox() {
|
|
46
|
+
this.open = false;
|
|
47
|
+
}
|
|
48
|
+
handleBlur() {
|
|
49
|
+
this.open = false;
|
|
50
|
+
this.toggleOpen.emit(false);
|
|
51
|
+
}
|
|
52
|
+
onDropdownClicked() {
|
|
53
|
+
this.open = !this.open;
|
|
54
|
+
this.searchTerm = '';
|
|
55
|
+
this.calculateDropdownMenuOffset();
|
|
56
|
+
this.toggleOpen.emit(this.open);
|
|
57
|
+
}
|
|
58
|
+
onItemSelected(option) {
|
|
59
|
+
this.selectedItem = option;
|
|
60
|
+
this.selectItemEvent.emit(this.selectedItem);
|
|
61
|
+
this.handleBlur();
|
|
62
|
+
}
|
|
63
|
+
dropdownSelectorContent() {
|
|
64
|
+
let title;
|
|
65
|
+
let subtitle;
|
|
66
|
+
const chevronIcon = this.open ? 'expand_less' : 'expand_more';
|
|
67
|
+
const icon = h("tttx-icon", { icon: chevronIcon, color: "black" });
|
|
68
|
+
let chevron = h("div", { class: 'dropdown-selector-chevron' }, icon);
|
|
69
|
+
if (!this.selectedItem) {
|
|
70
|
+
title = h("div", { class: "placeholder" }, this.placeholder);
|
|
71
|
+
return h(Fragment, null, title, chevron);
|
|
72
|
+
}
|
|
73
|
+
else if (this.selectedItem.html) {
|
|
74
|
+
title = h("div", { title: this.selectedItem.label, class: "truncated-text", innerHTML: this.selectedItem.html });
|
|
75
|
+
return h(Fragment, null, title, chevron);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
title = h("div", { title: this.selectedItem.label, class: "truncated-text" }, this.selectedItem.label);
|
|
79
|
+
if (this.selectedItem.description) {
|
|
80
|
+
subtitle = h("div", { class: "description" }, h("p", null, this.selectedItem.description));
|
|
81
|
+
chevron = h("div", { class: 'dropdown-selector-chevron-offset' }, icon);
|
|
82
|
+
}
|
|
83
|
+
return h(Fragment, null, h("div", { class: "left-wrapper" }, title, subtitle), chevron);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
dropdownOption(option) {
|
|
87
|
+
/* istanbul ignore next */
|
|
88
|
+
const hideOption = this.searchEnabled && option.label.toLowerCase().indexOf(this.searchTerm.toLowerCase()) === -1;
|
|
89
|
+
const selected = this.selectedItem && option.value === this.selectedItem.value;
|
|
90
|
+
if (option.html) {
|
|
91
|
+
const sanitisedHTML = purify.sanitize(option.html, domSanitiserOptions);
|
|
92
|
+
/* istanbul ignore next */
|
|
93
|
+
return (h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label, innerHTML: sanitisedHTML }));
|
|
94
|
+
}
|
|
95
|
+
else if (option.description) {
|
|
96
|
+
return (h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label }, option.label, h("div", { class: "description-dd" }, h("p", null, option.description))));
|
|
97
|
+
}
|
|
98
|
+
/* istanbul ignore next */
|
|
99
|
+
return (h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label }, option.label));
|
|
100
|
+
}
|
|
101
|
+
/* istanbul ignore next */
|
|
102
|
+
handleSearchInput(event) {
|
|
103
|
+
const target = event.target;
|
|
104
|
+
this.searchTerm = target.value;
|
|
105
|
+
}
|
|
106
|
+
calculateDropdownMenuOffset() {
|
|
107
|
+
const dropdownSelector = this.el.shadowRoot.querySelector('.dropdown-selector');
|
|
108
|
+
const bottomPosY = this.dropdownSelector.getBoundingClientRect().bottom;
|
|
109
|
+
// (Max list height OR 31px * number of items) + 52px for search bar + 8px padding at bottom
|
|
110
|
+
let dropdownMenuMaxHeight = Math.min((368), 36 * this._optionsData.length) + 8;
|
|
111
|
+
if (this.searchEnabled)
|
|
112
|
+
dropdownMenuMaxHeight += 52;
|
|
113
|
+
const clientRectangle = dropdownSelector.getBoundingClientRect();
|
|
114
|
+
if (bottomPosY + dropdownMenuMaxHeight > window.innerHeight) {
|
|
115
|
+
this.bodyOffset = { top: `${window.innerHeight - (dropdownMenuMaxHeight + 16)}px`, position: 'fixed', width: `${dropdownSelector.offsetWidth}px`, zIndex: '10' };
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
this.bodyOffset = { position: 'fixed', left: clientRectangle.left, top: clientRectangle.top, width: (clientRectangle.width - 2) + 'px', zIndex: '10' };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
render() {
|
|
122
|
+
if (!this.optionsData)
|
|
123
|
+
return;
|
|
124
|
+
return (h(Host, { class: this.inline ? 'inline' : 'block' }, this.label && h("div", { class: "label" }, this.label), h("div", { tabindex: "0", class: "dropdown-container" }, h("div", { class: "dropdown-selector", ref: (el) => this.dropdownSelector = el, onClick: this.onDropdownClicked.bind(this) }, this.dropdownSelectorContent()), this.open && (h("div", { class: "dropdown-body-container" }, h("div", { class: "dropdown-body", style: Object.assign({ width: `${this.dropdownSelector.offsetWidth}px` }, this.bodyOffset) }, this.searchEnabled &&
|
|
125
|
+
/* istanbul ignore next */
|
|
126
|
+
h("div", { class: "searchbox" }, h("tttx-standalone-input", { type: "text", label: "", required: true, showerrorbubble: false, iconleft: 'search', onInput: this.handleSearchInput.bind(this) })), h("div", { class: "dropdown-options-list" }, this._optionsData.map((option) => {
|
|
127
|
+
return this.dropdownOption(option);
|
|
128
|
+
}))))))));
|
|
129
|
+
}
|
|
130
|
+
get el() { return this; }
|
|
131
|
+
static get watchers() { return {
|
|
132
|
+
"optionsData": ["setOptionsData"]
|
|
133
|
+
}; }
|
|
134
|
+
static get style() { return tttxSelectBoxCss; }
|
|
135
|
+
}, [1, "tttx-select-box", {
|
|
136
|
+
"optionsData": [1, "options-data"],
|
|
137
|
+
"label": [1],
|
|
138
|
+
"inline": [4],
|
|
139
|
+
"placeholder": [1],
|
|
140
|
+
"searchEnabled": [4, "search-enabled"],
|
|
141
|
+
"selectedValue": [1, "selected-value"],
|
|
142
|
+
"open": [32],
|
|
143
|
+
"selectedItem": [32],
|
|
144
|
+
"searchTerm": [32],
|
|
145
|
+
"setSelectedItem": [64]
|
|
146
|
+
}, [[0, "closeSelectBox", "handleCloseSelectBox"], [0, "blur", "handleBlur"]]]);
|
|
147
|
+
function defineCustomElement() {
|
|
148
|
+
if (typeof customElements === "undefined") {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const components = ["tttx-select-box", "tttx-icon", "tttx-standalone-input"];
|
|
152
|
+
components.forEach(tagName => { switch (tagName) {
|
|
153
|
+
case "tttx-select-box":
|
|
154
|
+
if (!customElements.get(tagName)) {
|
|
155
|
+
customElements.define(tagName, TttxSelectBox);
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case "tttx-icon":
|
|
159
|
+
if (!customElements.get(tagName)) {
|
|
160
|
+
defineCustomElement$2();
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case "tttx-standalone-input":
|
|
164
|
+
if (!customElements.get(tagName)) {
|
|
165
|
+
defineCustomElement$1();
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
} });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export { TttxSelectBox as T, defineCustomElement as d };
|
package/dist/esm/loader.js
CHANGED
|
@@ -11,7 +11,7 @@ const patchEsm = () => {
|
|
|
11
11
|
const defineCustomElements = (win, options) => {
|
|
12
12
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
13
13
|
return patchEsm().then(() => {
|
|
14
|
-
return bootstrapLazy([["tttx-data-pattern",[[1,"tttx-data-pattern",{"data":[1],"sorteroptions":[1],"filteroptions":[1],"filterheader":[1]}]]],["tttx-multiselect-box",[[1,"tttx-multiselect-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"htmlVisibleValue":[4,"html-visible-value"],"visibleValue":[1,"visible-value"],"open":[32],"unsavedSelectedItems":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-dialog-box",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"open":[1028],"allowOverflow":[4,"allow-overflow"],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-
|
|
14
|
+
return bootstrapLazy([["tttx-data-pattern",[[1,"tttx-data-pattern",{"data":[1],"sorteroptions":[1],"filteroptions":[1],"filterheader":[1]}]]],["tttx-form",[[1,"tttx-form",{"formschema":[1025],"data":[1032],"submit":[64],"setSelectOptions":[64]}]]],["tttx-multiselect-box",[[1,"tttx-multiselect-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"htmlVisibleValue":[4,"html-visible-value"],"visibleValue":[1,"visible-value"],"open":[32],"unsavedSelectedItems":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-dialog-box",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"open":[1028],"allowOverflow":[4,"allow-overflow"],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-tree-view",[[1,"tttx-tree-view",{"data":[1040],"firstSelected":[1028,"first-selected"],"treeData":[32],"selectedId":[32]}]]],["tttx-checkbox",[[0,"tttx-checkbox",{"checkboxId":[1,"checkbox-id"],"label":[1],"inline":[4],"indeterminate":[4],"checked":[4]}]]],["tttx-dialog",[[1,"tttx-dialog",{"header":[1],"type":[1],"size":[1],"open":[4],"allowOverflow":[4,"allow-overflow"],"closeEnabled":[4,"close-enabled"],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-expander",[[1,"tttx-expander",{"name":[1],"open":[4],"lefticon":[1],"lefticoncolor":[1],"isExpanded":[32]}]]],["tttx-tabs",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["tttx-checkbox-group",[[1,"tttx-checkbox-group"]]],["tttx-checkbox-group-caption",[[4,"tttx-checkbox-group-caption"]]],["tttx-checkbox-group-heading",[[4,"tttx-checkbox-group-heading"]]],["tttx-keyvalue-block",[[1,"tttx-keyvalue-block",{"keyvalues":[1],"horizontal":[4],"spacedout":[4],"_elements":[32]}]]],["tttx-loading-spinner",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-percentage-bar",[[2,"tttx-percentage-bar",{"percentage":[8],"thresholds":[1],"color":[1],"min":[1],"labelid":[1],"_percentage":[32],"_ranges":[32],"_min":[32]}]]],["tttx-qrcode",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-tag",[[1,"tttx-tag",{"text":[1],"color":[1],"textColor":[1,"text-color"]}]]],["tttx-textarea",[[2,"tttx-textarea",{"label":[1],"secondarylabel":[1],"showerrormsg":[4],"showerrorbubble":[4],"errormsg":[1],"rows":[2],"textareaautofocus":[4],"inputkeyhint":[1],"inputindex":[8],"inputtitle":[1],"disabled":[4],"maxlength":[8],"name":[1],"placeholder":[1],"readonly":[8],"required":[4],"value":[1032]}]]],["tttx-icon",[[1,"tttx-icon",{"icon":[1],"color":[1]}]]],["tttx-select-box",[[1,"tttx-select-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"selectedValue":[1,"selected-value"],"open":[32],"selectedItem":[32],"searchTerm":[32],"setSelectedItem":[64]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-filter_4",[[1,"tttx-filter",{"filterKey":[1,"filter-key"],"filterOptions":[1,"filter-options"],"showSelectAll":[4,"show-select-all"],"showSearchField":[4,"show-search-field"],"showOptionIcons":[4,"show-option-icons"],"filterButtonStyle":[1,"filter-button-style"],"filterHeader":[1,"filter-header"],"defaultFilterOptions":[1,"default-filter-options"],"popoverWidth":[1,"popover-width"],"showPopover":[32],"displayedFilterSettings":[32],"selectedFilters":[32],"filterSearchTerm":[32],"allSelected":[32]},[[0,"closeFilter","handleCloseFilter"]]],[1,"tttx-list",{"data":[1025],"name":[1],"_data":[32]}],[1,"tttx-sorter",{"sorterKey":[1,"sorter-key"],"defaultSortDirection":[1,"default-sort-direction"],"fieldOptionsData":[1,"field-options-data"],"defaultOption":[1,"default-option"],"selectedField":[32],"sortDirection":[32],"dropdownExpand":[32],"dropdownOptions":[32]},[[0,"closeSorter","handleCloseSorter"]]],[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-button",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]],["tttx-standalone-input",[[2,"tttx-standalone-input",{"label":[1],"secondarylabel":[1],"showerrormsg":[4],"showerrorbubble":[4],"errormsg":[1],"iconleft":[1],"iconleftcolor":[1],"iconright":[1],"iconrightcolor":[1],"inputicon":[1],"inputiconcolor":[1],"inline":[4],"inputautocapitalize":[1],"inputautofocus":[4],"inputkeyhint":[1],"inputindex":[8],"inputtitle":[1],"autocomplete":[1],"checked":[4],"disabled":[4],"max":[8],"maxlength":[8],"min":[8],"minlength":[8],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[8],"required":[4],"step":[8],"type":[1],"value":[1032]}]]]], options);
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
|