@3t-transform/threeteeui 0.2.74 → 0.2.75

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.
@@ -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],"open":[1028],"allowOverflow":[4,"allow-overflow"],"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"],"selectedValue":[1,"selected-value"],"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],"_data":[32]}]]],["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-tabs.cjs",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["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-tag.cjs",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-toolbar.cjs",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["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);
17
+ return index.bootstrapLazy([["tttx-multiselect-box.cjs",[[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.cjs",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"open":[1028],"allowOverflow":[4,"allow-overflow"],"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"],"selectedValue":[1,"selected-value"],"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],"_data":[32]}]]],["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-tabs.cjs",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["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-tag.cjs",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-toolbar.cjs",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["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,130 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-4cfa8e25.js');
6
+ const domsanitiser_options = require('./domsanitiser.options-1dfa7205.js');
7
+ require('./_commonjsHelpers-537d719a.js');
8
+
9
+ const tttxMultiselectBoxCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}:host{display:flex;gap:4px}.label{font-size:16px;font-style:normal;font-weight:500;line-height:normal}:host(.inline) .label{padding-top:8px}:host(.block){flex-direction:column}.dropdown-container{display:grid;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{grid-row:1;align-items:center;gap:8px;padding:6px 8px 6px 16px;cursor:pointer;border:1px solid #d5d5d5}.dropdown-selector-chevron{margin-left:auto;height:24px}.dropdown-selector-chevron>tttx-icon{cursor:pointer}.dropdown-selector-html-content{display:flex;gap:8px;flex-wrap:wrap}.dropdown-body-container{grid-row:2;position:relative}.dropdown-body{position:absolute;display:flex;position:absolute;flex-direction:column;box-shadow:0px 1px 5px #1111114D;padding-bottom:8px;border:1px solid #d5d5d5;width:100%}.dropdown-options-list{display:flex;flex-direction:column;overflow-y:auto;scrollbar-gutter:stable;max-height:288px}.dropdown-option{padding:6px 8px 6px 16px;cursor:pointer;display:flex;gap:8px}.dropdown-option .checkbox-icon{height:24px}.dropdown-option .plaintext-option{line-height:24px}.dropdown-option:hover{background-color:#1111110d}.dropdown-option:active,.dropdown-option.selected{background-color:#ebfbfc}.placeholder{color:#9e9e9e}.searchbox{padding:8px 16px 8px 16px;height:52px;box-sizing:border-box}.searchbox tttx-standalone-input{margin-top:-4px}.hidden{display:none}.footer{display:flex;gap:8px;flex-direction:row-reverse;padding:8px 16px 0 16px;border-top:1px solid #d5d5d5}";
10
+
11
+ const TttxMultiselectBox = class {
12
+ constructor(hostRef) {
13
+ index.registerInstance(this, hostRef);
14
+ this.selectItemEvent = index.createEvent(this, "selectItemEvent", 7);
15
+ this.toggleOpen = index.createEvent(this, "toggleOpen", 7);
16
+ this.changesApplied = index.createEvent(this, "changesApplied", 7);
17
+ this.bodyOffset = {};
18
+ this.optionsData = null;
19
+ this.label = undefined;
20
+ this.inline = undefined;
21
+ this.placeholder = '';
22
+ this.searchEnabled = undefined;
23
+ this.htmlVisibleValue = undefined;
24
+ this.visibleValue = undefined;
25
+ this.open = false;
26
+ this.unsavedSelectedItems = undefined;
27
+ this.searchTerm = '';
28
+ }
29
+ handleCloseSelectBox() {
30
+ this.open = false;
31
+ }
32
+ handleBlur() {
33
+ this.open = false;
34
+ this.toggleOpen.emit(false);
35
+ }
36
+ /**
37
+ * We want to generally clone instances of optionsData, _optionsData and unsavedSelectedItems
38
+ * This is because they may be assigned from each other, but have different purposes
39
+ * If we don't clone them, changing one may propagate to the others
40
+ * JSON.parse/stringify will deep clone them, so the references of the array elements will also change
41
+ */
42
+ safelyCloneArray(arr) {
43
+ return JSON.parse(JSON.stringify(arr));
44
+ }
45
+ onDropdownClicked() {
46
+ this.open = !this.open;
47
+ this.searchTerm = '';
48
+ this.calculateDropdownMenuOffset();
49
+ this.toggleOpen.emit(this.open);
50
+ }
51
+ onCancel() {
52
+ this.open = false;
53
+ this.unsavedSelectedItems = this.safelyCloneArray(this._optionsData);
54
+ this.toggleOpen.emit(false);
55
+ }
56
+ applyChanges() {
57
+ this.open = false;
58
+ this.changesApplied.emit(this.safelyCloneArray(this.unsavedSelectedItems));
59
+ }
60
+ onItemSelected(option) {
61
+ const optionIndex = this.unsavedSelectedItems.findIndex((item) => item.value === option.value);
62
+ this.unsavedSelectedItems[optionIndex] = Object.assign(Object.assign({}, option), { selected: !option.selected });
63
+ this.unsavedSelectedItems = [...this.unsavedSelectedItems];
64
+ this.selectItemEvent.emit(option);
65
+ }
66
+ dropdownSelectorContent() {
67
+ if (!this._optionsData.find((item) => item.selected))
68
+ return index.h("div", { class: "placeholder" }, this.placeholder);
69
+ if (this.htmlVisibleValue) {
70
+ const sanitisedHTML = domsanitiser_options.purify.sanitize(this.visibleValue, domsanitiser_options.domSanitiserOptions);
71
+ return index.h("div", { class: "dropdown-selector-html-content", innerHTML: sanitisedHTML });
72
+ }
73
+ return index.h("div", null, this.visibleValue);
74
+ }
75
+ dropdownOption(option) {
76
+ // This is tested in e2e tests
77
+ /* istanbul ignore next */
78
+ const hideOption = this.searchEnabled && option.label.toLowerCase().indexOf(this.searchTerm.toLowerCase()) === -1;
79
+ const checkboxIcon = option.selected ? 'check_box' : 'check_box_outline_blank';
80
+ const checkboxColor = option.selected ? 'blue' : 'grey';
81
+ if (option.html) {
82
+ const sanitisedHTML = domsanitiser_options.purify.sanitize(option.html, domsanitiser_options.domSanitiserOptions);
83
+ // This is tested in e2e tests
84
+ /* istanbul ignore next */
85
+ return (index.h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${option.selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label }, index.h("tttx-icon", { icon: checkboxIcon, color: checkboxColor, class: 'checkbox-icon' }), index.h("div", { innerHTML: sanitisedHTML })));
86
+ }
87
+ // This is tested in e2e tests
88
+ /* istanbul ignore next */
89
+ return (index.h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${option.selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label }, index.h("tttx-icon", { icon: checkboxIcon, color: checkboxColor, class: 'checkbox-icon' }), index.h("div", { class: "plaintext-option" }, option.label)));
90
+ }
91
+ // This is tested in e2e tests
92
+ /* istanbul ignore next */
93
+ handleSearchInput(event) {
94
+ const target = event.target;
95
+ this.searchTerm = target.value;
96
+ }
97
+ calculateDropdownMenuOffset() {
98
+ const dropdownSelector = this.el.shadowRoot.querySelector('.dropdown-selector');
99
+ const bottomPosY = dropdownSelector.getBoundingClientRect().bottom;
100
+ // (Max list height OR 36px * number of items) + 52px for search bar + 45px for footer + 8px padding at bottom
101
+ let dropdownMenuMaxHeight = Math.min((288), 36 * this._optionsData.length) + 45 + 8;
102
+ if (this.searchEnabled)
103
+ dropdownMenuMaxHeight += 52;
104
+ if (bottomPosY + dropdownMenuMaxHeight > window.innerHeight) {
105
+ this.bodyOffset = { bottom: '16px', position: 'fixed', width: `${dropdownSelector.offsetWidth}px` };
106
+ }
107
+ else {
108
+ this.bodyOffset = {};
109
+ }
110
+ }
111
+ render() {
112
+ if (!this.optionsData)
113
+ return;
114
+ this._optionsData = typeof this.optionsData === 'string' ? JSON.parse(this.optionsData) : this.optionsData;
115
+ // initialise, if not already. After initialisation, this will be managed by internal state
116
+ // Check is performed in render in case initial render did not include optionsData
117
+ if (!this.unsavedSelectedItems)
118
+ this.unsavedSelectedItems = this.safelyCloneArray(this._optionsData);
119
+ const chevronIcon = this.open ? 'expand_less' : 'expand_more';
120
+ 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-container" }, index.h("div", { class: "dropdown-body", style: Object.assign({}, this.bodyOffset) }, this.searchEnabled &&
121
+ /* istanbul ignore next */
122
+ index.h("div", { class: "searchbox" }, index.h("tttx-standalone-input", { type: "text", label: "", required: true, showerrorbubble: false, iconleft: 'search', onInput: this.handleSearchInput.bind(this), inline: true })), index.h("div", { class: "dropdown-options-list" }, this.unsavedSelectedItems.map((option) => {
123
+ return this.dropdownOption(option);
124
+ })), index.h("div", { class: 'footer' }, index.h("tttx-button", { design: "primary", onClick: this.applyChanges.bind(this) }, "Apply"), index.h("tttx-button", { onClick: this.onCancel.bind(this) }, "Cancel"))))))));
125
+ }
126
+ get el() { return index.getElement(this); }
127
+ };
128
+ TttxMultiselectBox.style = tttxMultiselectBoxCss;
129
+
130
+ exports.tttx_multiselect_box = TttxMultiselectBox;
@@ -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],"open":[1028],"allowOverflow":[4,"allow-overflow"],"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"],"selectedValue":[1,"selected-value"],"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],"_data":[32]}]]],["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-tabs.cjs",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["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-tag.cjs",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-toolbar.cjs",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["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);
20
+ return index.bootstrapLazy([["tttx-multiselect-box.cjs",[[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.cjs",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"open":[1028],"allowOverflow":[4,"allow-overflow"],"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"],"selectedValue":[1,"selected-value"],"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],"_data":[32]}]]],["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-tabs.cjs",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["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-tag.cjs",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-toolbar.cjs",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["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;
@@ -11,6 +11,7 @@
11
11
  "./components/molecules/tttx-dialog-box/tttx-dialog-box.js",
12
12
  "./components/molecules/tttx-form/tttx-form.js",
13
13
  "./components/molecules/tttx-list/tttx-list.js",
14
+ "./components/molecules/tttx-multiselect-box/tttx-multiselect-box.js",
14
15
  "./components/molecules/tttx-select-box/tttx-select-box.js",
15
16
  "./components/molecules/tttx-sorter/tttx-sorter.js",
16
17
  "./components/molecules/tttx-tabs/tttx-tabs.js",
@@ -0,0 +1,135 @@
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
+ .label {
11
+ font-size: 16px;
12
+ font-style: normal;
13
+ font-weight: 500;
14
+ line-height: normal;
15
+ }
16
+
17
+ :host(.inline) .label {
18
+ padding-top: 8px;
19
+ }
20
+
21
+ :host(.block) {
22
+ flex-direction: column;
23
+ }
24
+
25
+ .dropdown-container {
26
+ display: grid;
27
+ position: relative;
28
+ display: flex;
29
+ flex-direction: column;
30
+ width: 100%;
31
+ }
32
+ .dropdown-container:focus-visible {
33
+ outline: none;
34
+ }
35
+ .dropdown-container:focus .dropdown-selector {
36
+ border: 1px solid #1479c6;
37
+ }
38
+
39
+ .dropdown-selector, .dropdown-body {
40
+ display: flex;
41
+ border-radius: 4px;
42
+ background-color: white;
43
+ }
44
+
45
+ .dropdown-selector {
46
+ grid-row: 1;
47
+ align-items: center;
48
+ gap: 8px;
49
+ padding: 6px 8px 6px 16px;
50
+ cursor: pointer;
51
+ border: 1px solid #d5d5d5;
52
+ }
53
+
54
+ .dropdown-selector-chevron {
55
+ margin-left: auto;
56
+ height: 24px;
57
+ }
58
+
59
+ .dropdown-selector-chevron > tttx-icon {
60
+ cursor: pointer;
61
+ }
62
+
63
+ .dropdown-selector-html-content {
64
+ display: flex;
65
+ gap: 8px;
66
+ flex-wrap: wrap;
67
+ }
68
+
69
+ .dropdown-body-container {
70
+ grid-row: 2;
71
+ position: relative;
72
+ }
73
+
74
+ .dropdown-body {
75
+ position: absolute;
76
+ display: flex;
77
+ position: absolute;
78
+ flex-direction: column;
79
+ box-shadow: 0px 1px 5px #1111114D;
80
+ padding-bottom: 8px;
81
+ border: 1px solid #d5d5d5;
82
+ width: 100%;
83
+ }
84
+
85
+ .dropdown-options-list {
86
+ display: flex;
87
+ flex-direction: column;
88
+ overflow-y: auto;
89
+ scrollbar-gutter: stable;
90
+ max-height: 288px;
91
+ }
92
+
93
+ .dropdown-option {
94
+ padding: 6px 8px 6px 16px;
95
+ cursor: pointer;
96
+ display: flex;
97
+ gap: 8px;
98
+ }
99
+ .dropdown-option .checkbox-icon {
100
+ height: 24px;
101
+ }
102
+ .dropdown-option .plaintext-option {
103
+ line-height: 24px;
104
+ }
105
+ .dropdown-option:hover {
106
+ background-color: #1111110d;
107
+ }
108
+ .dropdown-option:active, .dropdown-option.selected {
109
+ background-color: #ebfbfc;
110
+ }
111
+
112
+ .placeholder {
113
+ color: #9e9e9e;
114
+ }
115
+
116
+ .searchbox {
117
+ padding: 8px 16px 8px 16px;
118
+ height: 52px;
119
+ box-sizing: border-box;
120
+ }
121
+ .searchbox tttx-standalone-input {
122
+ margin-top: -4px;
123
+ }
124
+
125
+ .hidden {
126
+ display: none;
127
+ }
128
+
129
+ .footer {
130
+ display: flex;
131
+ gap: 8px;
132
+ flex-direction: row-reverse;
133
+ padding: 8px 16px 0 16px;
134
+ border-top: 1px solid #d5d5d5;
135
+ }
@@ -0,0 +1,339 @@
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 TttxMultiselectBox {
6
+ constructor() {
7
+ this.bodyOffset = {};
8
+ this.optionsData = null;
9
+ this.label = undefined;
10
+ this.inline = undefined;
11
+ this.placeholder = '';
12
+ this.searchEnabled = undefined;
13
+ this.htmlVisibleValue = undefined;
14
+ this.visibleValue = undefined;
15
+ this.open = false;
16
+ this.unsavedSelectedItems = undefined;
17
+ this.searchTerm = '';
18
+ }
19
+ handleCloseSelectBox() {
20
+ this.open = false;
21
+ }
22
+ handleBlur() {
23
+ this.open = false;
24
+ this.toggleOpen.emit(false);
25
+ }
26
+ /**
27
+ * We want to generally clone instances of optionsData, _optionsData and unsavedSelectedItems
28
+ * This is because they may be assigned from each other, but have different purposes
29
+ * If we don't clone them, changing one may propagate to the others
30
+ * JSON.parse/stringify will deep clone them, so the references of the array elements will also change
31
+ */
32
+ safelyCloneArray(arr) {
33
+ return JSON.parse(JSON.stringify(arr));
34
+ }
35
+ onDropdownClicked() {
36
+ this.open = !this.open;
37
+ this.searchTerm = '';
38
+ this.calculateDropdownMenuOffset();
39
+ this.toggleOpen.emit(this.open);
40
+ }
41
+ onCancel() {
42
+ this.open = false;
43
+ this.unsavedSelectedItems = this.safelyCloneArray(this._optionsData);
44
+ this.toggleOpen.emit(false);
45
+ }
46
+ applyChanges() {
47
+ this.open = false;
48
+ this.changesApplied.emit(this.safelyCloneArray(this.unsavedSelectedItems));
49
+ }
50
+ onItemSelected(option) {
51
+ const optionIndex = this.unsavedSelectedItems.findIndex((item) => item.value === option.value);
52
+ this.unsavedSelectedItems[optionIndex] = Object.assign(Object.assign({}, option), { selected: !option.selected });
53
+ this.unsavedSelectedItems = [...this.unsavedSelectedItems];
54
+ this.selectItemEvent.emit(option);
55
+ }
56
+ dropdownSelectorContent() {
57
+ if (!this._optionsData.find((item) => item.selected))
58
+ return h("div", { class: "placeholder" }, this.placeholder);
59
+ if (this.htmlVisibleValue) {
60
+ const sanitisedHTML = DOMPurify.sanitize(this.visibleValue, domSanitiserOptions);
61
+ return h("div", { class: "dropdown-selector-html-content", innerHTML: sanitisedHTML });
62
+ }
63
+ return h("div", null, this.visibleValue);
64
+ }
65
+ dropdownOption(option) {
66
+ // This is tested in e2e tests
67
+ /* istanbul ignore next */
68
+ const hideOption = this.searchEnabled && option.label.toLowerCase().indexOf(this.searchTerm.toLowerCase()) === -1;
69
+ const checkboxIcon = option.selected ? 'check_box' : 'check_box_outline_blank';
70
+ const checkboxColor = option.selected ? 'blue' : 'grey';
71
+ if (option.html) {
72
+ const sanitisedHTML = DOMPurify.sanitize(option.html, domSanitiserOptions);
73
+ // This is tested in e2e tests
74
+ /* istanbul ignore next */
75
+ return (h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${option.selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label }, h("tttx-icon", { icon: checkboxIcon, color: checkboxColor, class: 'checkbox-icon' }), h("div", { innerHTML: sanitisedHTML })));
76
+ }
77
+ // This is tested in e2e tests
78
+ /* istanbul ignore next */
79
+ return (h("div", { class: `dropdown-option ${hideOption ? 'hidden' : ''} ${option.selected ? 'selected' : ''}`, onClick: this.onItemSelected.bind(this, option), key: option.label }, h("tttx-icon", { icon: checkboxIcon, color: checkboxColor, class: 'checkbox-icon' }), h("div", { class: "plaintext-option" }, option.label)));
80
+ }
81
+ // This is tested in e2e tests
82
+ /* istanbul ignore next */
83
+ handleSearchInput(event) {
84
+ const target = event.target;
85
+ this.searchTerm = target.value;
86
+ }
87
+ calculateDropdownMenuOffset() {
88
+ const dropdownSelector = this.el.shadowRoot.querySelector('.dropdown-selector');
89
+ const bottomPosY = dropdownSelector.getBoundingClientRect().bottom;
90
+ // (Max list height OR 36px * number of items) + 52px for search bar + 45px for footer + 8px padding at bottom
91
+ let dropdownMenuMaxHeight = Math.min((288), 36 * this._optionsData.length) + 45 + 8;
92
+ if (this.searchEnabled)
93
+ dropdownMenuMaxHeight += 52;
94
+ if (bottomPosY + dropdownMenuMaxHeight > window.innerHeight) {
95
+ this.bodyOffset = { bottom: '16px', position: 'fixed', width: `${dropdownSelector.offsetWidth}px` };
96
+ }
97
+ else {
98
+ this.bodyOffset = {};
99
+ }
100
+ }
101
+ render() {
102
+ if (!this.optionsData)
103
+ return;
104
+ this._optionsData = typeof this.optionsData === 'string' ? JSON.parse(this.optionsData) : this.optionsData;
105
+ // initialise, if not already. After initialisation, this will be managed by internal state
106
+ // Check is performed in render in case initial render did not include optionsData
107
+ if (!this.unsavedSelectedItems)
108
+ this.unsavedSelectedItems = this.safelyCloneArray(this._optionsData);
109
+ const chevronIcon = this.open ? 'expand_less' : 'expand_more';
110
+ 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-container" }, h("div", { class: "dropdown-body", style: Object.assign({}, this.bodyOffset) }, this.searchEnabled &&
111
+ /* istanbul ignore next */
112
+ h("div", { class: "searchbox" }, h("tttx-standalone-input", { type: "text", label: "", required: true, showerrorbubble: false, iconleft: 'search', onInput: this.handleSearchInput.bind(this), inline: true })), h("div", { class: "dropdown-options-list" }, this.unsavedSelectedItems.map((option) => {
113
+ return this.dropdownOption(option);
114
+ })), h("div", { class: 'footer' }, h("tttx-button", { design: "primary", onClick: this.applyChanges.bind(this) }, "Apply"), h("tttx-button", { onClick: this.onCancel.bind(this) }, "Cancel"))))))));
115
+ }
116
+ static get is() { return "tttx-multiselect-box"; }
117
+ static get encapsulation() { return "shadow"; }
118
+ static get originalStyleUrls() {
119
+ return {
120
+ "$": ["tttx-multiselect-box.scss"]
121
+ };
122
+ }
123
+ static get styleUrls() {
124
+ return {
125
+ "$": ["tttx-multiselect-box.css"]
126
+ };
127
+ }
128
+ static get properties() {
129
+ return {
130
+ "optionsData": {
131
+ "type": "string",
132
+ "mutable": false,
133
+ "complexType": {
134
+ "original": "string | SelectItem[]",
135
+ "resolved": "SelectItem[] | string",
136
+ "references": {
137
+ "SelectItem": {
138
+ "location": "import",
139
+ "path": "./interfaces"
140
+ }
141
+ }
142
+ },
143
+ "required": false,
144
+ "optional": false,
145
+ "docs": {
146
+ "tags": [],
147
+ "text": ""
148
+ },
149
+ "attribute": "options-data",
150
+ "reflect": false,
151
+ "defaultValue": "null"
152
+ },
153
+ "label": {
154
+ "type": "string",
155
+ "mutable": false,
156
+ "complexType": {
157
+ "original": "string",
158
+ "resolved": "string",
159
+ "references": {}
160
+ },
161
+ "required": false,
162
+ "optional": false,
163
+ "docs": {
164
+ "tags": [],
165
+ "text": ""
166
+ },
167
+ "attribute": "label",
168
+ "reflect": false
169
+ },
170
+ "inline": {
171
+ "type": "boolean",
172
+ "mutable": false,
173
+ "complexType": {
174
+ "original": "boolean",
175
+ "resolved": "boolean",
176
+ "references": {}
177
+ },
178
+ "required": false,
179
+ "optional": false,
180
+ "docs": {
181
+ "tags": [],
182
+ "text": ""
183
+ },
184
+ "attribute": "inline",
185
+ "reflect": false
186
+ },
187
+ "placeholder": {
188
+ "type": "string",
189
+ "mutable": false,
190
+ "complexType": {
191
+ "original": "string",
192
+ "resolved": "string",
193
+ "references": {}
194
+ },
195
+ "required": false,
196
+ "optional": false,
197
+ "docs": {
198
+ "tags": [],
199
+ "text": ""
200
+ },
201
+ "attribute": "placeholder",
202
+ "reflect": false,
203
+ "defaultValue": "''"
204
+ },
205
+ "searchEnabled": {
206
+ "type": "boolean",
207
+ "mutable": false,
208
+ "complexType": {
209
+ "original": "boolean",
210
+ "resolved": "boolean",
211
+ "references": {}
212
+ },
213
+ "required": false,
214
+ "optional": false,
215
+ "docs": {
216
+ "tags": [],
217
+ "text": ""
218
+ },
219
+ "attribute": "search-enabled",
220
+ "reflect": false
221
+ },
222
+ "htmlVisibleValue": {
223
+ "type": "boolean",
224
+ "mutable": false,
225
+ "complexType": {
226
+ "original": "boolean",
227
+ "resolved": "boolean",
228
+ "references": {}
229
+ },
230
+ "required": false,
231
+ "optional": false,
232
+ "docs": {
233
+ "tags": [],
234
+ "text": ""
235
+ },
236
+ "attribute": "html-visible-value",
237
+ "reflect": false
238
+ },
239
+ "visibleValue": {
240
+ "type": "string",
241
+ "mutable": false,
242
+ "complexType": {
243
+ "original": "string",
244
+ "resolved": "string",
245
+ "references": {}
246
+ },
247
+ "required": false,
248
+ "optional": false,
249
+ "docs": {
250
+ "tags": [],
251
+ "text": ""
252
+ },
253
+ "attribute": "visible-value",
254
+ "reflect": false
255
+ }
256
+ };
257
+ }
258
+ static get states() {
259
+ return {
260
+ "open": {},
261
+ "unsavedSelectedItems": {},
262
+ "searchTerm": {}
263
+ };
264
+ }
265
+ static get events() {
266
+ return [{
267
+ "method": "selectItemEvent",
268
+ "name": "selectItemEvent",
269
+ "bubbles": true,
270
+ "cancelable": true,
271
+ "composed": true,
272
+ "docs": {
273
+ "tags": [],
274
+ "text": ""
275
+ },
276
+ "complexType": {
277
+ "original": "SelectItem",
278
+ "resolved": "SelectItem",
279
+ "references": {
280
+ "SelectItem": {
281
+ "location": "import",
282
+ "path": "./interfaces"
283
+ }
284
+ }
285
+ }
286
+ }, {
287
+ "method": "toggleOpen",
288
+ "name": "toggleOpen",
289
+ "bubbles": true,
290
+ "cancelable": true,
291
+ "composed": true,
292
+ "docs": {
293
+ "tags": [],
294
+ "text": ""
295
+ },
296
+ "complexType": {
297
+ "original": "boolean",
298
+ "resolved": "boolean",
299
+ "references": {}
300
+ }
301
+ }, {
302
+ "method": "changesApplied",
303
+ "name": "changesApplied",
304
+ "bubbles": true,
305
+ "cancelable": true,
306
+ "composed": true,
307
+ "docs": {
308
+ "tags": [],
309
+ "text": ""
310
+ },
311
+ "complexType": {
312
+ "original": "SelectItem[]",
313
+ "resolved": "SelectItem[]",
314
+ "references": {
315
+ "SelectItem": {
316
+ "location": "import",
317
+ "path": "./interfaces"
318
+ }
319
+ }
320
+ }
321
+ }];
322
+ }
323
+ static get elementRef() { return "el"; }
324
+ static get listeners() {
325
+ return [{
326
+ "name": "closeSelectBox",
327
+ "method": "handleCloseSelectBox",
328
+ "target": undefined,
329
+ "capture": false,
330
+ "passive": false
331
+ }, {
332
+ "name": "blur",
333
+ "method": "handleBlur",
334
+ "target": undefined,
335
+ "capture": false,
336
+ "passive": false
337
+ }];
338
+ }
339
+ }