@3t-transform/threeteeui 0.1.60 → 0.1.61
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-select-box.cjs.entry.js +79 -0
- package/dist/cjs/tttx.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/molecules/tttx-select-box/tttx-select-box.css +89 -0
- package/dist/collection/components/molecules/tttx-select-box/tttx-select-box.js +235 -0
- package/dist/collection/components/molecules/tttx-select-box/tttx-select-box.stories.js +69 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/tttx-select-box.d.ts +11 -0
- package/dist/components/tttx-select-box.js +113 -0
- package/dist/components/tttx-standalone-input.js +1 -136
- package/dist/components/tttx-standalone-input2.js +138 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tttx-select-box.entry.js +75 -0
- package/dist/esm/tttx.js +1 -1
- package/dist/tttx/p-f94b26dc.entry.js +1 -0
- package/dist/tttx/tttx.esm.js +1 -1
- package/dist/types/components/molecules/tttx-select-box/interfaces.d.ts +5 -0
- package/dist/types/components/molecules/tttx-select-box/tttx-select-box.d.ts +23 -0
- package/dist/types/components/molecules/tttx-select-box/tttx-select-box.stories.d.ts +7 -0
- package/dist/types/components.d.ts +30 -0
- package/package.json +1 -1
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["tttx-dialog-box.cjs",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-tree-view.cjs",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32]}]]],["tttx-filter.cjs",[[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"]]]]],["tttx-list.cjs",[[1,"tttx-list",{"data":[1025],"name":[1]}]]],["tttx-sorter.cjs",[[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"]]]]],["tttx-
|
|
17
|
+
return index.bootstrapLazy([["tttx-dialog-box.cjs",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-select-box.cjs",[[1,"tttx-select-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"open":[32],"selectedItem":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-tree-view.cjs",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32]}]]],["tttx-filter.cjs",[[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"]]]]],["tttx-list.cjs",[[1,"tttx-list",{"data":[1025],"name":[1]}]]],["tttx-sorter.cjs",[[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"]]]]],["tttx-form.cjs",[[1,"tttx-form",{"formschema":[1032],"data":[1032],"submit":[64]}]]],["tttx-keyvalue-block.cjs",[[1,"tttx-keyvalue-block",{"keyvalues":[8],"horizontal":[4]}]]],["tttx-loading-spinner.cjs",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-qrcode.cjs",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-toolbar.cjs",[[1,"tttx-toolbar",{"border":[4]}]]],["tttx-icon.cjs",[[1,"tttx-icon",{"icon":[1],"color":[1]}]]],["tttx-standalone-input.cjs",[[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]}]]],["tttx-button.cjs",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-43af0e62.js');
|
|
6
|
+
const domsanitiser_options = require('./domsanitiser.options-1dfa7205.js');
|
|
7
|
+
require('./_commonjsHelpers-537d719a.js');
|
|
8
|
+
|
|
9
|
+
const tttxSelectBoxCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}:host{display:flex;gap:4px}:host(.inline) .label{padding-top:8px}:host(.block){flex-direction:column}.dropdown-container{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:1px solid #d5d5d5;border-radius:4px}.dropdown-selector{align-items:center;gap:8px;padding:8px 8px 8px 16px;cursor:pointer}.dropdown-selector-chevron{margin-left:auto;height:24px}.dropdown-body{display:flex;flex-direction:column;box-shadow:0px 1px 5px #1111114D;padding-bottom:8px}.dropdown-body.search{max-height:410px}.dropdown-options-list{display:flex;flex-direction:column;overflow-y:auto;max-height:368px}.dropdown-option{padding:8px 8px 8px 16px;cursor:pointer}.dropdown-option:hover{background-color:#1111110D}.dropdown-option:active,.dropdown-option.selected{background-color:#ebfbfc}.placeholder{color:#9e9e9e}.searchbox{padding:8px 16px 0 16px}.searchbox tttx-standalone-input{margin-top:-4px}.hidden{display:none}";
|
|
10
|
+
|
|
11
|
+
const TttxSelectBox = class {
|
|
12
|
+
constructor(hostRef) {
|
|
13
|
+
index.registerInstance(this, hostRef);
|
|
14
|
+
this.selectItemEvent = index.createEvent(this, "selectItemEvent", 3);
|
|
15
|
+
this.toggleOpen = index.createEvent(this, "toggleOpen", 3);
|
|
16
|
+
this.optionsData = null;
|
|
17
|
+
this.label = undefined;
|
|
18
|
+
this.inline = undefined;
|
|
19
|
+
this.placeholder = '';
|
|
20
|
+
this.searchEnabled = undefined;
|
|
21
|
+
this.open = false;
|
|
22
|
+
this.selectedItem = undefined;
|
|
23
|
+
this.searchTerm = '';
|
|
24
|
+
}
|
|
25
|
+
handleCloseSelectBox() {
|
|
26
|
+
this.open = false;
|
|
27
|
+
}
|
|
28
|
+
handleBlur() {
|
|
29
|
+
this.open = false;
|
|
30
|
+
this.toggleOpen.emit(false);
|
|
31
|
+
}
|
|
32
|
+
onDropdownClicked() {
|
|
33
|
+
this.open = !this.open;
|
|
34
|
+
this.searchTerm = '';
|
|
35
|
+
this.toggleOpen.emit(this.open);
|
|
36
|
+
}
|
|
37
|
+
onItemSelected(option) {
|
|
38
|
+
this.selectedItem = option;
|
|
39
|
+
this.selectItemEvent.emit(this.selectedItem);
|
|
40
|
+
this.el.blur();
|
|
41
|
+
}
|
|
42
|
+
dropdownSelectorContent() {
|
|
43
|
+
if (!this.selectedItem)
|
|
44
|
+
return index.h("div", { class: "placeholder" }, this.placeholder);
|
|
45
|
+
return index.h("div", null, this.selectedItem.label);
|
|
46
|
+
}
|
|
47
|
+
dropdownOption(option) {
|
|
48
|
+
/* istanbul ignore next */
|
|
49
|
+
const hideOption = this.searchEnabled && option.label.toLowerCase().indexOf(this.searchTerm.toLowerCase()) === -1;
|
|
50
|
+
const selected = this.selectedItem && option.value === this.selectedItem.value;
|
|
51
|
+
if (option.html) {
|
|
52
|
+
const sanitisedHTML = domsanitiser_options.purify.sanitize(option.html, domsanitiser_options.domSanitiserOptions);
|
|
53
|
+
/* istanbul ignore next */
|
|
54
|
+
return (index.h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label, innerHTML: sanitisedHTML }));
|
|
55
|
+
}
|
|
56
|
+
/* istanbul ignore next */
|
|
57
|
+
return (index.h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label }, option.label));
|
|
58
|
+
}
|
|
59
|
+
/* istanbul ignore next */
|
|
60
|
+
handleSearchInput(event) {
|
|
61
|
+
const target = event.target;
|
|
62
|
+
this.searchTerm = target.value;
|
|
63
|
+
}
|
|
64
|
+
render() {
|
|
65
|
+
if (!this.optionsData)
|
|
66
|
+
return;
|
|
67
|
+
const parsedOptionsData = typeof this.optionsData === 'string' ? JSON.parse(this.optionsData) : this.optionsData;
|
|
68
|
+
const chevronIcon = this.open ? 'expand_less' : 'expand_more';
|
|
69
|
+
return (index.h(index.Host, { class: this.inline ? 'inline' : 'block' }, this.label && index.h("div", { class: "label" }, this.label), index.h("div", { tabindex: "0", class: "dropdown-container" }, index.h("div", { class: "dropdown-selector", onClick: this.onDropdownClicked.bind(this) }, this.dropdownSelectorContent(), index.h("div", { class: "dropdown-selector-chevron" }, index.h("tttx-icon", { icon: chevronIcon, color: "black" }))), this.open && (index.h("div", { class: "dropdown-body" }, this.searchEnabled &&
|
|
70
|
+
/* istanbul ignore next */
|
|
71
|
+
index.h("div", { class: "searchbox" }, index.h("tttx-standalone-input", { type: "text", label: "", required: true, showerrorbubble: false, iconleft: 'search', onInput: this.handleSearchInput.bind(this) })), index.h("div", { class: "dropdown-options-list" }, parsedOptionsData.map((option) => {
|
|
72
|
+
return this.dropdownOption(option);
|
|
73
|
+
})))))));
|
|
74
|
+
}
|
|
75
|
+
get el() { return index.getElement(this); }
|
|
76
|
+
};
|
|
77
|
+
TttxSelectBox.style = tttxSelectBoxCss;
|
|
78
|
+
|
|
79
|
+
exports.tttx_select_box = TttxSelectBox;
|
package/dist/cjs/tttx.cjs.js
CHANGED
|
@@ -17,7 +17,7 @@ const patchBrowser = () => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(options => {
|
|
20
|
-
return index.bootstrapLazy([["tttx-dialog-box.cjs",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-tree-view.cjs",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32]}]]],["tttx-filter.cjs",[[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"]]]]],["tttx-list.cjs",[[1,"tttx-list",{"data":[1025],"name":[1]}]]],["tttx-sorter.cjs",[[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"]]]]],["tttx-
|
|
20
|
+
return index.bootstrapLazy([["tttx-dialog-box.cjs",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-select-box.cjs",[[1,"tttx-select-box",{"optionsData":[1,"options-data"],"label":[1],"inline":[4],"placeholder":[1],"searchEnabled":[4,"search-enabled"],"open":[32],"selectedItem":[32],"searchTerm":[32]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-tree-view.cjs",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32]}]]],["tttx-filter.cjs",[[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"]]]]],["tttx-list.cjs",[[1,"tttx-list",{"data":[1025],"name":[1]}]]],["tttx-sorter.cjs",[[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"]]]]],["tttx-form.cjs",[[1,"tttx-form",{"formschema":[1032],"data":[1032],"submit":[64]}]]],["tttx-keyvalue-block.cjs",[[1,"tttx-keyvalue-block",{"keyvalues":[8],"horizontal":[4]}]]],["tttx-loading-spinner.cjs",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-qrcode.cjs",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-toolbar.cjs",[[1,"tttx-toolbar",{"border":[4]}]]],["tttx-icon.cjs",[[1,"tttx-icon",{"icon":[1],"color":[1]}]]],["tttx-standalone-input.cjs",[[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]}]]],["tttx-button.cjs",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]]], options);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
exports.setNonce = index.setNonce;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"./components/molecules/tttx-dialog-box/tttx-dialog-box.js",
|
|
11
11
|
"./components/molecules/tttx-form/tttx-form.js",
|
|
12
12
|
"./components/molecules/tttx-list/tttx-list.js",
|
|
13
|
+
"./components/molecules/tttx-select-box/tttx-select-box.js",
|
|
13
14
|
"./components/molecules/tttx-sorter/tttx-sorter.js",
|
|
14
15
|
"./components/molecules/tttx-toolbar/tttx-toolbar.js",
|
|
15
16
|
"./components/molecules/tttx-tree-view/tttx-tree-view.js"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
.material-symbols-rounded {
|
|
2
|
+
font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: flex;
|
|
7
|
+
gap: 4px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:host(.inline) .label {
|
|
11
|
+
padding-top: 8px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host(.block) {
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.dropdown-container {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
width: 100%;
|
|
22
|
+
}
|
|
23
|
+
.dropdown-container:focus-visible {
|
|
24
|
+
outline: none;
|
|
25
|
+
}
|
|
26
|
+
.dropdown-container:focus .dropdown-selector {
|
|
27
|
+
border: 1px solid #1479c6;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.dropdown-selector, .dropdown-body {
|
|
31
|
+
display: flex;
|
|
32
|
+
border: 1px solid #d5d5d5;
|
|
33
|
+
border-radius: 4px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.dropdown-selector {
|
|
37
|
+
align-items: center;
|
|
38
|
+
gap: 8px;
|
|
39
|
+
padding: 8px 8px 8px 16px;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.dropdown-selector-chevron {
|
|
44
|
+
margin-left: auto;
|
|
45
|
+
height: 24px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.dropdown-body {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
box-shadow: 0px 1px 5px #1111114D;
|
|
52
|
+
padding-bottom: 8px;
|
|
53
|
+
}
|
|
54
|
+
.dropdown-body.search {
|
|
55
|
+
max-height: 410px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.dropdown-options-list {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
overflow-y: auto;
|
|
62
|
+
max-height: 368px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.dropdown-option {
|
|
66
|
+
padding: 8px 8px 8px 16px;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
}
|
|
69
|
+
.dropdown-option:hover {
|
|
70
|
+
background-color: #1111110D;
|
|
71
|
+
}
|
|
72
|
+
.dropdown-option:active, .dropdown-option.selected {
|
|
73
|
+
background-color: #ebfbfc;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.placeholder {
|
|
77
|
+
color: #9e9e9e;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.searchbox {
|
|
81
|
+
padding: 8px 16px 0 16px;
|
|
82
|
+
}
|
|
83
|
+
.searchbox tttx-standalone-input {
|
|
84
|
+
margin-top: -4px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.hidden {
|
|
88
|
+
display: none;
|
|
89
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import { h, Host } from '@stencil/core';
|
|
3
|
+
import * as DOMPurify from 'dompurify';
|
|
4
|
+
import domSanitiserOptions from '../../../shared/domsanitiser.options';
|
|
5
|
+
export class TttxSelectBox {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.optionsData = null;
|
|
8
|
+
this.label = undefined;
|
|
9
|
+
this.inline = undefined;
|
|
10
|
+
this.placeholder = '';
|
|
11
|
+
this.searchEnabled = undefined;
|
|
12
|
+
this.open = false;
|
|
13
|
+
this.selectedItem = undefined;
|
|
14
|
+
this.searchTerm = '';
|
|
15
|
+
}
|
|
16
|
+
handleCloseSelectBox() {
|
|
17
|
+
this.open = false;
|
|
18
|
+
}
|
|
19
|
+
handleBlur() {
|
|
20
|
+
this.open = false;
|
|
21
|
+
this.toggleOpen.emit(false);
|
|
22
|
+
}
|
|
23
|
+
onDropdownClicked() {
|
|
24
|
+
this.open = !this.open;
|
|
25
|
+
this.searchTerm = '';
|
|
26
|
+
this.toggleOpen.emit(this.open);
|
|
27
|
+
}
|
|
28
|
+
onItemSelected(option) {
|
|
29
|
+
this.selectedItem = option;
|
|
30
|
+
this.selectItemEvent.emit(this.selectedItem);
|
|
31
|
+
this.el.blur();
|
|
32
|
+
}
|
|
33
|
+
dropdownSelectorContent() {
|
|
34
|
+
if (!this.selectedItem)
|
|
35
|
+
return h("div", { class: "placeholder" }, this.placeholder);
|
|
36
|
+
return h("div", null, this.selectedItem.label);
|
|
37
|
+
}
|
|
38
|
+
dropdownOption(option) {
|
|
39
|
+
/* istanbul ignore next */
|
|
40
|
+
const hideOption = this.searchEnabled && option.label.toLowerCase().indexOf(this.searchTerm.toLowerCase()) === -1;
|
|
41
|
+
const selected = this.selectedItem && option.value === this.selectedItem.value;
|
|
42
|
+
if (option.html) {
|
|
43
|
+
const sanitisedHTML = DOMPurify.sanitize(option.html, domSanitiserOptions);
|
|
44
|
+
/* istanbul ignore next */
|
|
45
|
+
return (h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label, innerHTML: sanitisedHTML }));
|
|
46
|
+
}
|
|
47
|
+
/* istanbul ignore next */
|
|
48
|
+
return (h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label }, option.label));
|
|
49
|
+
}
|
|
50
|
+
/* istanbul ignore next */
|
|
51
|
+
handleSearchInput(event) {
|
|
52
|
+
const target = event.target;
|
|
53
|
+
this.searchTerm = target.value;
|
|
54
|
+
}
|
|
55
|
+
render() {
|
|
56
|
+
if (!this.optionsData)
|
|
57
|
+
return;
|
|
58
|
+
const parsedOptionsData = typeof this.optionsData === 'string' ? JSON.parse(this.optionsData) : this.optionsData;
|
|
59
|
+
const chevronIcon = this.open ? 'expand_less' : 'expand_more';
|
|
60
|
+
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", onClick: this.onDropdownClicked.bind(this) }, this.dropdownSelectorContent(), h("div", { class: "dropdown-selector-chevron" }, h("tttx-icon", { icon: chevronIcon, color: "black" }))), this.open && (h("div", { class: "dropdown-body" }, this.searchEnabled &&
|
|
61
|
+
/* istanbul ignore next */
|
|
62
|
+
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" }, parsedOptionsData.map((option) => {
|
|
63
|
+
return this.dropdownOption(option);
|
|
64
|
+
})))))));
|
|
65
|
+
}
|
|
66
|
+
static get is() { return "tttx-select-box"; }
|
|
67
|
+
static get encapsulation() { return "shadow"; }
|
|
68
|
+
static get originalStyleUrls() {
|
|
69
|
+
return {
|
|
70
|
+
"$": ["tttx-select-box.scss"]
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
static get styleUrls() {
|
|
74
|
+
return {
|
|
75
|
+
"$": ["tttx-select-box.css"]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
static get properties() {
|
|
79
|
+
return {
|
|
80
|
+
"optionsData": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"mutable": false,
|
|
83
|
+
"complexType": {
|
|
84
|
+
"original": "string | SelectItem[]",
|
|
85
|
+
"resolved": "SelectItem[] | string",
|
|
86
|
+
"references": {
|
|
87
|
+
"SelectItem": {
|
|
88
|
+
"location": "import",
|
|
89
|
+
"path": "./interfaces"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"required": false,
|
|
94
|
+
"optional": false,
|
|
95
|
+
"docs": {
|
|
96
|
+
"tags": [],
|
|
97
|
+
"text": ""
|
|
98
|
+
},
|
|
99
|
+
"attribute": "options-data",
|
|
100
|
+
"reflect": false,
|
|
101
|
+
"defaultValue": "null"
|
|
102
|
+
},
|
|
103
|
+
"label": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"mutable": false,
|
|
106
|
+
"complexType": {
|
|
107
|
+
"original": "string",
|
|
108
|
+
"resolved": "string",
|
|
109
|
+
"references": {}
|
|
110
|
+
},
|
|
111
|
+
"required": false,
|
|
112
|
+
"optional": false,
|
|
113
|
+
"docs": {
|
|
114
|
+
"tags": [],
|
|
115
|
+
"text": ""
|
|
116
|
+
},
|
|
117
|
+
"attribute": "label",
|
|
118
|
+
"reflect": false
|
|
119
|
+
},
|
|
120
|
+
"inline": {
|
|
121
|
+
"type": "boolean",
|
|
122
|
+
"mutable": false,
|
|
123
|
+
"complexType": {
|
|
124
|
+
"original": "boolean",
|
|
125
|
+
"resolved": "boolean",
|
|
126
|
+
"references": {}
|
|
127
|
+
},
|
|
128
|
+
"required": false,
|
|
129
|
+
"optional": false,
|
|
130
|
+
"docs": {
|
|
131
|
+
"tags": [],
|
|
132
|
+
"text": ""
|
|
133
|
+
},
|
|
134
|
+
"attribute": "inline",
|
|
135
|
+
"reflect": false
|
|
136
|
+
},
|
|
137
|
+
"placeholder": {
|
|
138
|
+
"type": "string",
|
|
139
|
+
"mutable": false,
|
|
140
|
+
"complexType": {
|
|
141
|
+
"original": "string",
|
|
142
|
+
"resolved": "string",
|
|
143
|
+
"references": {}
|
|
144
|
+
},
|
|
145
|
+
"required": false,
|
|
146
|
+
"optional": false,
|
|
147
|
+
"docs": {
|
|
148
|
+
"tags": [],
|
|
149
|
+
"text": ""
|
|
150
|
+
},
|
|
151
|
+
"attribute": "placeholder",
|
|
152
|
+
"reflect": false,
|
|
153
|
+
"defaultValue": "''"
|
|
154
|
+
},
|
|
155
|
+
"searchEnabled": {
|
|
156
|
+
"type": "boolean",
|
|
157
|
+
"mutable": false,
|
|
158
|
+
"complexType": {
|
|
159
|
+
"original": "boolean",
|
|
160
|
+
"resolved": "boolean",
|
|
161
|
+
"references": {}
|
|
162
|
+
},
|
|
163
|
+
"required": false,
|
|
164
|
+
"optional": false,
|
|
165
|
+
"docs": {
|
|
166
|
+
"tags": [],
|
|
167
|
+
"text": ""
|
|
168
|
+
},
|
|
169
|
+
"attribute": "search-enabled",
|
|
170
|
+
"reflect": false
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
static get states() {
|
|
175
|
+
return {
|
|
176
|
+
"open": {},
|
|
177
|
+
"selectedItem": {},
|
|
178
|
+
"searchTerm": {}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
static get events() {
|
|
182
|
+
return [{
|
|
183
|
+
"method": "selectItemEvent",
|
|
184
|
+
"name": "selectItemEvent",
|
|
185
|
+
"bubbles": false,
|
|
186
|
+
"cancelable": true,
|
|
187
|
+
"composed": true,
|
|
188
|
+
"docs": {
|
|
189
|
+
"tags": [],
|
|
190
|
+
"text": ""
|
|
191
|
+
},
|
|
192
|
+
"complexType": {
|
|
193
|
+
"original": "SelectItem",
|
|
194
|
+
"resolved": "SelectItem",
|
|
195
|
+
"references": {
|
|
196
|
+
"SelectItem": {
|
|
197
|
+
"location": "import",
|
|
198
|
+
"path": "./interfaces"
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}, {
|
|
203
|
+
"method": "toggleOpen",
|
|
204
|
+
"name": "toggleOpen",
|
|
205
|
+
"bubbles": false,
|
|
206
|
+
"cancelable": true,
|
|
207
|
+
"composed": true,
|
|
208
|
+
"docs": {
|
|
209
|
+
"tags": [],
|
|
210
|
+
"text": ""
|
|
211
|
+
},
|
|
212
|
+
"complexType": {
|
|
213
|
+
"original": "boolean",
|
|
214
|
+
"resolved": "boolean",
|
|
215
|
+
"references": {}
|
|
216
|
+
}
|
|
217
|
+
}];
|
|
218
|
+
}
|
|
219
|
+
static get elementRef() { return "el"; }
|
|
220
|
+
static get listeners() {
|
|
221
|
+
return [{
|
|
222
|
+
"name": "closeSelectBox",
|
|
223
|
+
"method": "handleCloseSelectBox",
|
|
224
|
+
"target": undefined,
|
|
225
|
+
"capture": false,
|
|
226
|
+
"passive": false
|
|
227
|
+
}, {
|
|
228
|
+
"name": "blur",
|
|
229
|
+
"method": "handleBlur",
|
|
230
|
+
"target": undefined,
|
|
231
|
+
"capture": false,
|
|
232
|
+
"passive": false
|
|
233
|
+
}];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
title: 'molecules/Select Box',
|
|
3
|
+
component: 'tttx-select-box',
|
|
4
|
+
};
|
|
5
|
+
const options = [
|
|
6
|
+
{ value: 'Bonnie', label: 'Steuber' },
|
|
7
|
+
{ value: 'Priscilla', label: 'Lowe' },
|
|
8
|
+
{ value: 'Andy', label: 'Thompson-Keebler', html: '<span style="color: red">Thompson-Keebler</span>' },
|
|
9
|
+
{ value: 'egg', label: 'egg', html: '<tttx-icon icon="egg" />' },
|
|
10
|
+
{ value: 'Terence', label: 'Hyatt' },
|
|
11
|
+
{ value: 'Ruben', label: 'Toy' },
|
|
12
|
+
{ value: 'Rhiannon', label: 'Hills' },
|
|
13
|
+
{ value: 'Trent', label: 'Mueller' },
|
|
14
|
+
{ value: 'Penelope', label: 'Mann' },
|
|
15
|
+
{ value: 'Oswaldo', label: 'Klocko' },
|
|
16
|
+
{ value: 'Jorge', label: 'Lockman' },
|
|
17
|
+
{ value: 'Conner', label: 'Feeney' },
|
|
18
|
+
{ value: 'Dorian', label: 'Fay' },
|
|
19
|
+
{ value: 'Estrella', label: 'Predovic' },
|
|
20
|
+
{ value: 'Heidi', label: 'McClure' },
|
|
21
|
+
{ value: 'Ronaldo', label: 'Mann' },
|
|
22
|
+
];
|
|
23
|
+
const TemplateHTMLSelectBox = args => `
|
|
24
|
+
<tttx-select-box
|
|
25
|
+
id="htmlSelectBox"
|
|
26
|
+
options-data='${JSON.stringify(args.optionsData)}'
|
|
27
|
+
label='${args.label}'
|
|
28
|
+
placeholder='${args.placeholder}'
|
|
29
|
+
search-enabled='${args.searchEnabled}'
|
|
30
|
+
inline='${args.inline}'
|
|
31
|
+
></tttx-select-box>
|
|
32
|
+
<script>
|
|
33
|
+
// Handle case where storybook renders this story twice
|
|
34
|
+
if (!htmlSelectBox.length) {
|
|
35
|
+
htmlSelectBox.addEventListener('toggleOpen', (ev) => { console.log(ev) })
|
|
36
|
+
htmlSelectBox.addEventListener('selectItemEvent', (ev) => { console.log(ev) })
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
`;
|
|
40
|
+
export const BasicHTMLSelectBox = TemplateHTMLSelectBox.bind({});
|
|
41
|
+
BasicHTMLSelectBox.args = {
|
|
42
|
+
optionsData: options,
|
|
43
|
+
label: 'Label',
|
|
44
|
+
placeholder: 'Placeholder',
|
|
45
|
+
searchEnabled: true,
|
|
46
|
+
inline: false
|
|
47
|
+
};
|
|
48
|
+
const TemplateJSXSelectBox = args => `
|
|
49
|
+
<tttx-select-box
|
|
50
|
+
id='objectSelectBox'
|
|
51
|
+
label='${args.label}'
|
|
52
|
+
placeholder='${args.placeholder}'
|
|
53
|
+
search-enabled='${args.searchEnabled}'
|
|
54
|
+
inline='${args.inline}'
|
|
55
|
+
></tttx-select-box>
|
|
56
|
+
<script>
|
|
57
|
+
objectSelectBox.optionsData = ${JSON.stringify(args.optionsData)}
|
|
58
|
+
objectSelectBox.addEventListener('toggleOpen', (ev) => { console.log(ev) })
|
|
59
|
+
objectSelectBox.addEventListener('selectItemEvent', (ev) => { console.log(ev) })
|
|
60
|
+
</script>
|
|
61
|
+
`;
|
|
62
|
+
export const BasicJSXSelectBox = TemplateJSXSelectBox.bind({});
|
|
63
|
+
BasicJSXSelectBox.args = {
|
|
64
|
+
optionsData: options,
|
|
65
|
+
label: 'Label',
|
|
66
|
+
placeholder: 'Placeholder',
|
|
67
|
+
searchEnabled: true,
|
|
68
|
+
inline: false
|
|
69
|
+
};
|
|
@@ -8,6 +8,7 @@ export { TttxKeyvalueBlock as TttxKeyvalueBlock } from '../types/components/atom
|
|
|
8
8
|
export { TttxList as TttxList } from '../types/components/molecules/tttx-list/tttx-list';
|
|
9
9
|
export { TttxLoadingSpinner as TttxLoadingSpinner } from '../types/components/atoms/tttx-loading-spinner/tttx-loading-spinner';
|
|
10
10
|
export { TttxQrCode as TttxQrcode } from '../types/components/atoms/tttx-qrcode/tttx-qrcode';
|
|
11
|
+
export { TttxSelectBox as TttxSelectBox } from '../types/components/molecules/tttx-select-box/tttx-select-box';
|
|
11
12
|
export { TttxSorter as TttxSorter } from '../types/components/molecules/tttx-sorter/tttx-sorter';
|
|
12
13
|
export { TttxInput as TttxStandaloneInput } from '../types/components/molecules/tttx-standalone-input/tttx-standalone-input';
|
|
13
14
|
export { TttxToolbar as TttxToolbar } from '../types/components/molecules/tttx-toolbar/tttx-toolbar';
|
package/dist/components/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { TttxKeyvalueBlock, defineCustomElement as defineCustomElementTttxKeyval
|
|
|
8
8
|
export { TttxList, defineCustomElement as defineCustomElementTttxList } from './tttx-list.js';
|
|
9
9
|
export { TttxLoadingSpinner, defineCustomElement as defineCustomElementTttxLoadingSpinner } from './tttx-loading-spinner.js';
|
|
10
10
|
export { TttxQrcode, defineCustomElement as defineCustomElementTttxQrcode } from './tttx-qrcode.js';
|
|
11
|
+
export { TttxSelectBox, defineCustomElement as defineCustomElementTttxSelectBox } from './tttx-select-box.js';
|
|
11
12
|
export { TttxSorter, defineCustomElement as defineCustomElementTttxSorter } from './tttx-sorter.js';
|
|
12
13
|
export { TttxStandaloneInput, defineCustomElement as defineCustomElementTttxStandaloneInput } from './tttx-standalone-input.js';
|
|
13
14
|
export { TttxToolbar, defineCustomElement as defineCustomElementTttxToolbar } from './tttx-toolbar.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface TttxSelectBox extends Components.TttxSelectBox, HTMLElement {}
|
|
4
|
+
export const TttxSelectBox: {
|
|
5
|
+
prototype: TttxSelectBox;
|
|
6
|
+
new (): TttxSelectBox;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|