@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.
@@ -0,0 +1,201 @@
1
+ import { withActions } from '@storybook/addon-actions/decorator';
2
+ export default {
3
+ title: 'molecules/Multiselect Box',
4
+ component: 'tttx-multiselect-box',
5
+ parameters: {
6
+ actions: {
7
+ handles: ['toggleOpen', 'changesApplied'],
8
+ },
9
+ },
10
+ decorators: [withActions],
11
+ };
12
+ const options = [
13
+ { value: 'Bonnie', label: 'Steuber' },
14
+ { value: 'Priscilla', label: 'Lowe' },
15
+ { value: 'Andy', label: 'Thompson-Keebler', html: '<span style="color: red">Thompson-Keebler</span>' },
16
+ { value: 'egg', label: 'egg', html: '<tttx-icon icon="egg" />' },
17
+ { value: 'Terence', label: 'Hyatt' },
18
+ { value: 'Ruben', label: 'Toy' },
19
+ { value: 'Rhiannon', label: 'Hills' },
20
+ { value: 'Trent', label: 'Mueller' },
21
+ { value: 'Penelope', label: 'Mann' },
22
+ { value: 'Oswaldo', label: 'Klocko' },
23
+ { value: 'Jorge', label: 'Lockman' },
24
+ { value: 'Conner', label: 'Feeney' },
25
+ { value: 'Dorian', label: 'Fay' },
26
+ { value: 'Estrella', label: 'Predovic' },
27
+ { value: 'Heidi', label: 'McClure' },
28
+ { value: 'Ronaldo', label: 'Mann' },
29
+ ];
30
+ const TemplateMultiselectBox = args => `
31
+ <tttx-multiselect-box
32
+ id="multiselectBox"
33
+ options-data='${JSON.stringify(args.optionsData)}'
34
+ label='${args.label}'
35
+ placeholder='${args.placeholder}'
36
+ search-enabled='${args.searchEnabled}'
37
+ inline='${args.inline}'
38
+ html-visible-value: true,
39
+ ></tttx-multiselect-box>
40
+
41
+ <script>
42
+ // Handle case where storybook renders this story twice
43
+ if(!multiselectBox.length) {
44
+ multiselectBox.addEventListener('changesApplied', (event) => {
45
+ multiselectBox.optionsData = event.detail;
46
+ multiselectBox.visibleValue = event.detail.filter((option) => option.selected).map((option) => option.label).join(', ')
47
+ })
48
+ }
49
+ </script>
50
+ `;
51
+ export const BasicMultiselectBox = TemplateMultiselectBox.bind({});
52
+ BasicMultiselectBox.args = {
53
+ optionsData: options,
54
+ label: 'Label',
55
+ placeholder: 'Placeholder',
56
+ searchEnabled: true,
57
+ inline: false,
58
+ };
59
+ const htmlOptions = [
60
+ { value: '1', label: 'Client', html: '<tttx-tag text="Client" color="#f2bebe"></tttx-tag>', selected: true },
61
+ { value: '2', label: 'Job Role', html: '<tttx-tag text="Job Role" color="#f9e1be"></tttx-tag>' },
62
+ { value: '3', label: 'Foo', html: '<tttx-tag text="Foo" color="#e4ebc9"></tttx-tag>', selected: true },
63
+ { value: '4', label: 'Bar', html: '<tttx-tag text="Bar" color="#f2bebe"></tttx-tag>', selected: true },
64
+ { value: '5', label: 'Baz', html: '<tttx-tag text="Baz" color="#f9e1be"></tttx-tag>' },
65
+ { value: '6', label: 'Mill', html: '<tttx-tag text="Mill" color="#e4ebc9"></tttx-tag>', selected: true },
66
+ { value: '7', label: 'Hill', html: '<tttx-tag text="Hill" color="#f2bebe"></tttx-tag>', selected: true },
67
+ { value: '8', label: 'Fill', html: '<tttx-tag text="Fill" color="#f9e1be"></tttx-tag>' },
68
+ { value: '9', label: 'Supercalifragilisticexpialidocious', html: '<tttx-tag text="Supercalifragilisticexpialidocious" color="#e4ebc9"></tttx-tag>', selected: true },
69
+ ];
70
+ const TemplateHtmlVisibleValueWrap = args => `
71
+ <div style="height: 400px; width: 50px"></div>
72
+ <div style="width: 300px">
73
+ <tttx-multiselect-box
74
+ id="multiselectBoxVisibleValueWrap"
75
+ options-data='${JSON.stringify(args.optionsData)}'
76
+ label='${args.label}'
77
+ placeholder='${args.placeholder}'
78
+ search-enabled='${args.searchEnabled}'
79
+ inline='${args.inline}'
80
+ html-visible-value='true'
81
+ visible-value='<tttx-tag text="Client" color="#f2bebe"></tttx-tag><tttx-tag text="Foo" color="#e4ebc9"></tttx-tag><tttx-tag text="Bar" color="#f2bebe"></tttx-tag><tttx-tag text="Mill" color="#e4ebc9"></tttx-tag><tttx-tag text="Hill" color="#f2bebe"></tttx-tag><tttx-tag text="Supercalifragilisticexpialidocious" color="#e4ebc9"></tttx-tag>'
82
+ ></tttx-multiselect-box>
83
+ </div>
84
+
85
+ <script>
86
+ // Handle case where storybook renders this story twice
87
+ if(!multiselectBoxVisibleValueWrap.length) {
88
+ multiselectBoxVisibleValueWrap.addEventListener('changesApplied', (event) => {
89
+ multiselectBoxVisibleValueWrap.optionsData = event.detail;
90
+ multiselectBoxVisibleValueWrap.visibleValue = event.detail.filter((option) => option.selected).map((option) => option.html).join('')
91
+ })
92
+ }
93
+ </script>
94
+ `;
95
+ export const HtmlVisibleValueWrap = TemplateHtmlVisibleValueWrap.bind({});
96
+ HtmlVisibleValueWrap.args = {
97
+ optionsData: htmlOptions,
98
+ label: 'Label',
99
+ placeholder: 'Placeholder',
100
+ searchEnabled: true,
101
+ inline: false,
102
+ };
103
+ const htmlOptionsShort = [
104
+ { value: '1', label: 'Client', html: '<tttx-tag text="Client" color="#f2bebe"></tttx-tag>', selected: true },
105
+ { value: '2', label: 'Job Role', html: '<tttx-tag text="Job Role" color="#f9e1be"></tttx-tag>' },
106
+ { value: '3', label: 'Foo', html: '<tttx-tag text="Foo" color="#e4ebc9"></tttx-tag>', selected: true },
107
+ ];
108
+ const TemplateHtmlVisibleValue = args => `
109
+ <tttx-multiselect-box
110
+ id="multiselectBox"
111
+ options-data='${JSON.stringify(args.optionsData)}'
112
+ label='${args.label}'
113
+ placeholder='${args.placeholder}'
114
+ search-enabled='${args.searchEnabled}'
115
+ inline='${args.inline}'
116
+ html-visible-value='true'
117
+ ></tttx-multiselect-box>
118
+
119
+ <script>
120
+ // Handle case where storybook renders this story twice
121
+ if(!multiselectBox.length) {
122
+ multiselectBox.addEventListener('changesApplied', (event) => {
123
+ multiselectBox.optionsData = event.detail;
124
+ multiselectBox.visibleValue = '<span>' + event.detail.filter((option) => option.selected).map((option) => option.html).join(', ') + '</span>'
125
+ })
126
+ }
127
+ </script>
128
+ `;
129
+ export const HtmlVisibleValue = TemplateHtmlVisibleValue.bind({});
130
+ HtmlVisibleValue.args = {
131
+ optionsData: htmlOptionsShort,
132
+ label: 'Label',
133
+ placeholder: 'Placeholder',
134
+ searchEnabled: true,
135
+ inline: false,
136
+ };
137
+ const tagOptions = [
138
+ { value: '1', label: 'Client', html: '<tttx-tag text="Client" color="#f2bebe"></tttx-tag>', selected: true },
139
+ { value: '2', label: 'Job Role', html: '<tttx-tag text="Job Role" color="#f9e1be"></tttx-tag>' },
140
+ { value: '3', label: 'Foo', html: '<tttx-tag text="Foo" color="#e4ebc9"></tttx-tag>', selected: true },
141
+ { value: '4', label: 'Bar', html: '<tttx-tag text="Bar" color="#f2bebe"></tttx-tag>', selected: true },
142
+ { value: '5', label: 'Baz', html: '<tttx-tag text="Baz" color="#f9e1be"></tttx-tag>' },
143
+ { value: '6', label: 'Mill', html: '<tttx-tag text="Mill" color="#e4ebc9"></tttx-tag>', selected: true },
144
+ { value: '7', label: 'Hill', html: '<tttx-tag text="Hill" color="#f2bebe"></tttx-tag>', selected: true },
145
+ { value: '8', label: 'Fill', html: '<tttx-tag text="Fill" color="#f9e1be"></tttx-tag>' },
146
+ { value: '9', label: 'Supercalifragilisticexpialidocious', html: '<tttx-tag text="Supercalifragilisticexpialidocious" color="#e4ebc9"></tttx-tag>', selected: true },
147
+ ];
148
+ const TttxDialogBoxStory = ({ data }) => `
149
+ <button onclick="openDialog()">Open</button>
150
+ <tttx-dialog-box
151
+ id='dialogBox'
152
+ allow-overflow='true'
153
+ ></tttx-dialog-box>
154
+ <script>
155
+ if(!dialogBox) {
156
+ const dialogBox = document.getElementById('dialogBox');
157
+ }
158
+ if(!openDialog) {
159
+ function openDialog() {
160
+ const dialogBox = document.getElementById('dialogBox');
161
+ dialogBox.open = true;
162
+ }
163
+ }
164
+
165
+ dialogBox.data = ${JSON.stringify(data)};
166
+ </script>
167
+ `;
168
+ export const DialogBoxWithDropdown = TttxDialogBoxStory.bind({});
169
+ DialogBoxWithDropdown.args = {
170
+ data: {
171
+ header: {
172
+ title: 'Dialog Title',
173
+ hasIcon: false,
174
+ hasClose: true,
175
+ },
176
+ body: {
177
+ isCustomHtml: true,
178
+ customHtml: `
179
+ <div style="padding: 5px;">
180
+ <tttx-multiselect-box
181
+ id="dropdownSelectBox"
182
+ options-data='${JSON.stringify(tagOptions)}'
183
+ label='Label'
184
+ placeholder='Placeholder'
185
+ search-enabled='${true}'
186
+ inline='${false}'
187
+ visible-value='${tagOptions[0].html} ${tagOptions[2].html}'
188
+ html-visible-value='true'
189
+ ></tttx-multiselect-box>
190
+ </div>
191
+ `,
192
+ },
193
+ footer: {
194
+ buttons: [
195
+ { name: 'primary', type: 'primary' },
196
+ { name: 'default', type: 'default' },
197
+ { name: 'No border', type: 'borderless' },
198
+ ],
199
+ },
200
+ },
201
+ };
@@ -7,6 +7,7 @@ export { TttxIcon as TttxIcon } from '../types/components/atoms/tttx-icon/tttx-i
7
7
  export { TttxKeyvalueBlock as TttxKeyvalueBlock } from '../types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block';
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
+ export { TttxMultiselectBox as TttxMultiselectBox } from '../types/components/molecules/tttx-multiselect-box/tttx-multiselect-box';
10
11
  export { TttxQrCode as TttxQrcode } from '../types/components/atoms/tttx-qrcode/tttx-qrcode';
11
12
  export { TttxSelectBox as TttxSelectBox } from '../types/components/molecules/tttx-select-box/tttx-select-box';
12
13
  export { TttxSorter as TttxSorter } from '../types/components/molecules/tttx-sorter/tttx-sorter';
@@ -7,6 +7,7 @@ export { TttxIcon, defineCustomElement as defineCustomElementTttxIcon } from './
7
7
  export { TttxKeyvalueBlock, defineCustomElement as defineCustomElementTttxKeyvalueBlock } from './tttx-keyvalue-block.js';
8
8
  export { TttxList, defineCustomElement as defineCustomElementTttxList } from './tttx-list.js';
9
9
  export { TttxLoadingSpinner, defineCustomElement as defineCustomElementTttxLoadingSpinner } from './tttx-loading-spinner.js';
10
+ export { TttxMultiselectBox, defineCustomElement as defineCustomElementTttxMultiselectBox } from './tttx-multiselect-box.js';
10
11
  export { TttxQrcode, defineCustomElement as defineCustomElementTttxQrcode } from './tttx-qrcode.js';
11
12
  export { TttxSelectBox, defineCustomElement as defineCustomElementTttxSelectBox } from './tttx-select-box.js';
12
13
  export { TttxSorter, defineCustomElement as defineCustomElementTttxSorter } from './tttx-sorter.js';
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface TttxMultiselectBox extends Components.TttxMultiselectBox, HTMLElement {}
4
+ export const TttxMultiselectBox: {
5
+ prototype: TttxMultiselectBox;
6
+ new (): TttxMultiselectBox;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,172 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { p as purify, d as domSanitiserOptions } from './domsanitiser.options.js';
3
+ import { d as defineCustomElement$4 } from './tttx-button2.js';
4
+ import { d as defineCustomElement$3 } from './tttx-icon2.js';
5
+ import { d as defineCustomElement$2 } from './tttx-standalone-input2.js';
6
+
7
+ 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}";
8
+
9
+ const TttxMultiselectBox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
10
+ constructor() {
11
+ super();
12
+ this.__registerHost();
13
+ this.__attachShadow();
14
+ this.selectItemEvent = createEvent(this, "selectItemEvent", 7);
15
+ this.toggleOpen = createEvent(this, "toggleOpen", 7);
16
+ this.changesApplied = 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 h("div", { class: "placeholder" }, this.placeholder);
69
+ if (this.htmlVisibleValue) {
70
+ const sanitisedHTML = purify.sanitize(this.visibleValue, domSanitiserOptions);
71
+ return h("div", { class: "dropdown-selector-html-content", innerHTML: sanitisedHTML });
72
+ }
73
+ return 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 = purify.sanitize(option.html, domSanitiserOptions);
83
+ // This is tested in e2e tests
84
+ /* istanbul ignore next */
85
+ 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 })));
86
+ }
87
+ // This is tested in e2e tests
88
+ /* istanbul ignore next */
89
+ 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)));
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 (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 &&
121
+ /* istanbul ignore next */
122
+ 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) => {
123
+ return this.dropdownOption(option);
124
+ })), h("div", { class: 'footer' }, h("tttx-button", { design: "primary", onClick: this.applyChanges.bind(this) }, "Apply"), h("tttx-button", { onClick: this.onCancel.bind(this) }, "Cancel"))))))));
125
+ }
126
+ get el() { return this; }
127
+ static get style() { return tttxMultiselectBoxCss; }
128
+ }, [1, "tttx-multiselect-box", {
129
+ "optionsData": [1, "options-data"],
130
+ "label": [1],
131
+ "inline": [4],
132
+ "placeholder": [1],
133
+ "searchEnabled": [4, "search-enabled"],
134
+ "htmlVisibleValue": [4, "html-visible-value"],
135
+ "visibleValue": [1, "visible-value"],
136
+ "open": [32],
137
+ "unsavedSelectedItems": [32],
138
+ "searchTerm": [32]
139
+ }, [[0, "closeSelectBox", "handleCloseSelectBox"], [0, "blur", "handleBlur"]]]);
140
+ function defineCustomElement$1() {
141
+ if (typeof customElements === "undefined") {
142
+ return;
143
+ }
144
+ const components = ["tttx-multiselect-box", "tttx-button", "tttx-icon", "tttx-standalone-input"];
145
+ components.forEach(tagName => { switch (tagName) {
146
+ case "tttx-multiselect-box":
147
+ if (!customElements.get(tagName)) {
148
+ customElements.define(tagName, TttxMultiselectBox$1);
149
+ }
150
+ break;
151
+ case "tttx-button":
152
+ if (!customElements.get(tagName)) {
153
+ defineCustomElement$4();
154
+ }
155
+ break;
156
+ case "tttx-icon":
157
+ if (!customElements.get(tagName)) {
158
+ defineCustomElement$3();
159
+ }
160
+ break;
161
+ case "tttx-standalone-input":
162
+ if (!customElements.get(tagName)) {
163
+ defineCustomElement$2();
164
+ }
165
+ break;
166
+ } });
167
+ }
168
+
169
+ const TttxMultiselectBox = TttxMultiselectBox$1;
170
+ const defineCustomElement = defineCustomElement$1;
171
+
172
+ export { TttxMultiselectBox, defineCustomElement };
@@ -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-dialog-box",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"open":[1028],"allowOverflow":[4,"allow-overflow"],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["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]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-tree-view",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32]}]]],["tttx-filter",[[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",[[1,"tttx-list",{"data":[1025],"name":[1],"_data":[32]}]]],["tttx-sorter",[[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",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["tttx-form",[[1,"tttx-form",{"formschema":[1032],"data":[1032],"submit":[64]}]]],["tttx-keyvalue-block",[[1,"tttx-keyvalue-block",{"keyvalues":[8],"horizontal":[4]}]]],["tttx-loading-spinner",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-qrcode",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-tag",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-toolbar",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-icon",[[1,"tttx-icon",{"icon":[1],"color":[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]}]]],["tttx-button",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]]], options);
14
+ return bootstrapLazy([["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-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]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-tree-view",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32]}]]],["tttx-filter",[[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",[[1,"tttx-list",{"data":[1025],"name":[1],"_data":[32]}]]],["tttx-sorter",[[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",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["tttx-form",[[1,"tttx-form",{"formschema":[1032],"data":[1032],"submit":[64]}]]],["tttx-keyvalue-block",[[1,"tttx-keyvalue-block",{"keyvalues":[8],"horizontal":[4]}]]],["tttx-loading-spinner",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-qrcode",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-tag",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-toolbar",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-icon",[[1,"tttx-icon",{"icon":[1],"color":[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]}]]],["tttx-button",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]]], options);
15
15
  });
16
16
  };
17
17
 
@@ -0,0 +1,126 @@
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-6a372ea6.js';
2
+ import { p as purify, d as domSanitiserOptions } from './domsanitiser.options-97a33389.js';
3
+ import './_commonjsHelpers-9943807e.js';
4
+
5
+ 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}";
6
+
7
+ const TttxMultiselectBox = class {
8
+ constructor(hostRef) {
9
+ registerInstance(this, hostRef);
10
+ this.selectItemEvent = createEvent(this, "selectItemEvent", 7);
11
+ this.toggleOpen = createEvent(this, "toggleOpen", 7);
12
+ this.changesApplied = createEvent(this, "changesApplied", 7);
13
+ this.bodyOffset = {};
14
+ this.optionsData = null;
15
+ this.label = undefined;
16
+ this.inline = undefined;
17
+ this.placeholder = '';
18
+ this.searchEnabled = undefined;
19
+ this.htmlVisibleValue = undefined;
20
+ this.visibleValue = undefined;
21
+ this.open = false;
22
+ this.unsavedSelectedItems = 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
+ /**
33
+ * We want to generally clone instances of optionsData, _optionsData and unsavedSelectedItems
34
+ * This is because they may be assigned from each other, but have different purposes
35
+ * If we don't clone them, changing one may propagate to the others
36
+ * JSON.parse/stringify will deep clone them, so the references of the array elements will also change
37
+ */
38
+ safelyCloneArray(arr) {
39
+ return JSON.parse(JSON.stringify(arr));
40
+ }
41
+ onDropdownClicked() {
42
+ this.open = !this.open;
43
+ this.searchTerm = '';
44
+ this.calculateDropdownMenuOffset();
45
+ this.toggleOpen.emit(this.open);
46
+ }
47
+ onCancel() {
48
+ this.open = false;
49
+ this.unsavedSelectedItems = this.safelyCloneArray(this._optionsData);
50
+ this.toggleOpen.emit(false);
51
+ }
52
+ applyChanges() {
53
+ this.open = false;
54
+ this.changesApplied.emit(this.safelyCloneArray(this.unsavedSelectedItems));
55
+ }
56
+ onItemSelected(option) {
57
+ const optionIndex = this.unsavedSelectedItems.findIndex((item) => item.value === option.value);
58
+ this.unsavedSelectedItems[optionIndex] = Object.assign(Object.assign({}, option), { selected: !option.selected });
59
+ this.unsavedSelectedItems = [...this.unsavedSelectedItems];
60
+ this.selectItemEvent.emit(option);
61
+ }
62
+ dropdownSelectorContent() {
63
+ if (!this._optionsData.find((item) => item.selected))
64
+ return h("div", { class: "placeholder" }, this.placeholder);
65
+ if (this.htmlVisibleValue) {
66
+ const sanitisedHTML = purify.sanitize(this.visibleValue, domSanitiserOptions);
67
+ return h("div", { class: "dropdown-selector-html-content", innerHTML: sanitisedHTML });
68
+ }
69
+ return h("div", null, this.visibleValue);
70
+ }
71
+ dropdownOption(option) {
72
+ // This is tested in e2e tests
73
+ /* istanbul ignore next */
74
+ const hideOption = this.searchEnabled && option.label.toLowerCase().indexOf(this.searchTerm.toLowerCase()) === -1;
75
+ const checkboxIcon = option.selected ? 'check_box' : 'check_box_outline_blank';
76
+ const checkboxColor = option.selected ? 'blue' : 'grey';
77
+ if (option.html) {
78
+ const sanitisedHTML = purify.sanitize(option.html, domSanitiserOptions);
79
+ // This is tested in e2e tests
80
+ /* istanbul ignore next */
81
+ 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 })));
82
+ }
83
+ // This is tested in e2e tests
84
+ /* istanbul ignore next */
85
+ 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)));
86
+ }
87
+ // This is tested in e2e tests
88
+ /* istanbul ignore next */
89
+ handleSearchInput(event) {
90
+ const target = event.target;
91
+ this.searchTerm = target.value;
92
+ }
93
+ calculateDropdownMenuOffset() {
94
+ const dropdownSelector = this.el.shadowRoot.querySelector('.dropdown-selector');
95
+ const bottomPosY = dropdownSelector.getBoundingClientRect().bottom;
96
+ // (Max list height OR 36px * number of items) + 52px for search bar + 45px for footer + 8px padding at bottom
97
+ let dropdownMenuMaxHeight = Math.min((288), 36 * this._optionsData.length) + 45 + 8;
98
+ if (this.searchEnabled)
99
+ dropdownMenuMaxHeight += 52;
100
+ if (bottomPosY + dropdownMenuMaxHeight > window.innerHeight) {
101
+ this.bodyOffset = { bottom: '16px', position: 'fixed', width: `${dropdownSelector.offsetWidth}px` };
102
+ }
103
+ else {
104
+ this.bodyOffset = {};
105
+ }
106
+ }
107
+ render() {
108
+ if (!this.optionsData)
109
+ return;
110
+ this._optionsData = typeof this.optionsData === 'string' ? JSON.parse(this.optionsData) : this.optionsData;
111
+ // initialise, if not already. After initialisation, this will be managed by internal state
112
+ // Check is performed in render in case initial render did not include optionsData
113
+ if (!this.unsavedSelectedItems)
114
+ this.unsavedSelectedItems = this.safelyCloneArray(this._optionsData);
115
+ const chevronIcon = this.open ? 'expand_less' : 'expand_more';
116
+ 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 &&
117
+ /* istanbul ignore next */
118
+ 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) => {
119
+ return this.dropdownOption(option);
120
+ })), h("div", { class: 'footer' }, h("tttx-button", { design: "primary", onClick: this.applyChanges.bind(this) }, "Apply"), h("tttx-button", { onClick: this.onCancel.bind(this) }, "Cancel"))))))));
121
+ }
122
+ get el() { return getElement(this); }
123
+ };
124
+ TttxMultiselectBox.style = tttxMultiselectBoxCss;
125
+
126
+ export { TttxMultiselectBox as tttx_multiselect_box };
package/dist/esm/tttx.js CHANGED
@@ -14,5 +14,5 @@ const patchBrowser = () => {
14
14
  };
15
15
 
16
16
  patchBrowser().then(options => {
17
- return bootstrapLazy([["tttx-dialog-box",[[1,"tttx-dialog-box",{"data":[1025],"size":[1],"open":[1028],"allowOverflow":[4,"allow-overflow"],"elementSize":[32]},[[9,"resize","handleResize"]]]]],["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]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-tree-view",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32]}]]],["tttx-filter",[[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",[[1,"tttx-list",{"data":[1025],"name":[1],"_data":[32]}]]],["tttx-sorter",[[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",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["tttx-form",[[1,"tttx-form",{"formschema":[1032],"data":[1032],"submit":[64]}]]],["tttx-keyvalue-block",[[1,"tttx-keyvalue-block",{"keyvalues":[8],"horizontal":[4]}]]],["tttx-loading-spinner",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-qrcode",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-tag",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-toolbar",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-icon",[[1,"tttx-icon",{"icon":[1],"color":[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]}]]],["tttx-button",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]]], options);
17
+ return bootstrapLazy([["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-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]},[[0,"closeSelectBox","handleCloseSelectBox"],[0,"blur","handleBlur"]]]]],["tttx-tree-view",[[1,"tttx-tree-view",{"data":[1040],"treeData":[32]}]]],["tttx-filter",[[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",[[1,"tttx-list",{"data":[1025],"name":[1],"_data":[32]}]]],["tttx-sorter",[[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",[[2,"tttx-tabs",{"tabsName":[1,"tabs-name"],"navigation":[4],"wide":[4],"tabs":[1],"_tabs":[32]},[[0,"keydown","handleKeyDown"]]]]],["tttx-form",[[1,"tttx-form",{"formschema":[1032],"data":[1032],"submit":[64]}]]],["tttx-keyvalue-block",[[1,"tttx-keyvalue-block",{"keyvalues":[8],"horizontal":[4]}]]],["tttx-loading-spinner",[[1,"tttx-loading-spinner",{"loadingMessage":[1028,"loading-message"],"size":[1025]}]]],["tttx-qrcode",[[1,"tttx-qrcode",{"link":[1025],"size":[1026]}]]],["tttx-tag",[[1,"tttx-tag",{"text":[1],"color":[1]}]]],["tttx-toolbar",[[1,"tttx-toolbar",{"border":[4],"viewSize":[32]},[[9,"resize","handleResize"]]]]],["tttx-icon",[[1,"tttx-icon",{"icon":[1],"color":[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]}]]],["tttx-button",[[1,"tttx-button",{"notext":[4],"icon":[1],"iconposition":[1],"iconcolor":[1025],"design":[1]}]]]], options);
18
18
  });
@@ -0,0 +1 @@
1
+ import{r as o,c as t,h as i,H as s,g as e}from"./p-3f1b6013.js";import{p as n,d}from"./p-5ed38d61.js";import"./p-112455b1.js";const r=class{constructor(i){o(this,i),this.selectItemEvent=t(this,"selectItemEvent",7),this.toggleOpen=t(this,"toggleOpen",7),this.changesApplied=t(this,"changesApplied",7),this.bodyOffset={},this.optionsData=null,this.label=void 0,this.inline=void 0,this.placeholder="",this.searchEnabled=void 0,this.htmlVisibleValue=void 0,this.visibleValue=void 0,this.open=!1,this.unsavedSelectedItems=void 0,this.searchTerm=""}handleCloseSelectBox(){this.open=!1}handleBlur(){this.open=!1,this.toggleOpen.emit(!1)}safelyCloneArray(o){return JSON.parse(JSON.stringify(o))}onDropdownClicked(){this.open=!this.open,this.searchTerm="",this.calculateDropdownMenuOffset(),this.toggleOpen.emit(this.open)}onCancel(){this.open=!1,this.unsavedSelectedItems=this.safelyCloneArray(this._optionsData),this.toggleOpen.emit(!1)}applyChanges(){this.open=!1,this.changesApplied.emit(this.safelyCloneArray(this.unsavedSelectedItems))}onItemSelected(o){const t=this.unsavedSelectedItems.findIndex((t=>t.value===o.value));this.unsavedSelectedItems[t]=Object.assign(Object.assign({},o),{selected:!o.selected}),this.unsavedSelectedItems=[...this.unsavedSelectedItems],this.selectItemEvent.emit(o)}dropdownSelectorContent(){if(!this._optionsData.find((o=>o.selected)))return i("div",{class:"placeholder"},this.placeholder);if(this.htmlVisibleValue){const o=n.sanitize(this.visibleValue,d);return i("div",{class:"dropdown-selector-html-content",innerHTML:o})}return i("div",null,this.visibleValue)}dropdownOption(o){const t=this.searchEnabled&&-1===o.label.toLowerCase().indexOf(this.searchTerm.toLowerCase()),s=o.selected?"check_box":"check_box_outline_blank",e=o.selected?"blue":"grey";if(o.html){const r=n.sanitize(o.html,d);return i("div",{class:`dropdown-option ${t?"hidden":""} ${o.selected?"selected":""}`,onClick:this.onItemSelected.bind(this,o),key:o.label},i("tttx-icon",{icon:s,color:e,class:"checkbox-icon"}),i("div",{innerHTML:r}))}return i("div",{class:`dropdown-option ${t?"hidden":""} ${o.selected?"selected":""}`,onClick:this.onItemSelected.bind(this,o),key:o.label},i("tttx-icon",{icon:s,color:e,class:"checkbox-icon"}),i("div",{class:"plaintext-option"},o.label))}handleSearchInput(o){this.searchTerm=o.target.value}calculateDropdownMenuOffset(){const o=this.el.shadowRoot.querySelector(".dropdown-selector"),t=o.getBoundingClientRect().bottom;let i=Math.min(288,36*this._optionsData.length)+45+8;this.searchEnabled&&(i+=52),this.bodyOffset=t+i>window.innerHeight?{bottom:"16px",position:"fixed",width:`${o.offsetWidth}px`}:{}}render(){if(!this.optionsData)return;this._optionsData="string"==typeof this.optionsData?JSON.parse(this.optionsData):this.optionsData,this.unsavedSelectedItems||(this.unsavedSelectedItems=this.safelyCloneArray(this._optionsData));const o=this.open?"expand_less":"expand_more";return i(s,{class:this.inline?"inline":"block"},this.label&&i("div",{class:"label"},this.label),i("div",{tabindex:"0",class:"dropdown-container"},i("div",{class:"dropdown-selector",onClick:this.onDropdownClicked.bind(this)},this.dropdownSelectorContent(),i("div",{class:"dropdown-selector-chevron"},i("tttx-icon",{icon:o,color:"black"}))),this.open&&i("div",{class:"dropdown-body-container"},i("div",{class:"dropdown-body",style:Object.assign({},this.bodyOffset)},this.searchEnabled&&i("div",{class:"searchbox"},i("tttx-standalone-input",{type:"text",label:"",required:!0,showerrorbubble:!1,iconleft:"search",onInput:this.handleSearchInput.bind(this),inline:!0})),i("div",{class:"dropdown-options-list"},this.unsavedSelectedItems.map((o=>this.dropdownOption(o)))),i("div",{class:"footer"},i("tttx-button",{design:"primary",onClick:this.applyChanges.bind(this)},"Apply"),i("tttx-button",{onClick:this.onCancel.bind(this)},"Cancel"))))))}get el(){return e(this)}};r.style='.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}';export{r as tttx_multiselect_box}
@@ -1 +1 @@
1
- import{p as e,b as t}from"./p-3f1b6013.js";export{s as setNonce}from"./p-3f1b6013.js";(()=>{const t=import.meta.url,o={};return""!==t&&(o.resourcesUrl=new URL(".",t).href),e(o)})().then((e=>t([["p-f34bface",[[1,"tttx-dialog-box",{data:[1025],size:[1],open:[1028],allowOverflow:[4,"allow-overflow"],elementSize:[32]},[[9,"resize","handleResize"]]]]],["p-887f56cb",[[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"]]]]],["p-75c31e23",[[1,"tttx-tree-view",{data:[1040],treeData:[32]}]]],["p-c714f7c0",[[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"]]]]],["p-750cf31b",[[1,"tttx-list",{data:[1025],name:[1],_data:[32]}]]],["p-5290db99",[[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"]]]]],["p-67c342d7",[[2,"tttx-tabs",{tabsName:[1,"tabs-name"],navigation:[4],wide:[4],tabs:[1],_tabs:[32]},[[0,"keydown","handleKeyDown"]]]]],["p-895526aa",[[1,"tttx-form",{formschema:[1032],data:[1032],submit:[64]}]]],["p-6fe0af4e",[[1,"tttx-keyvalue-block",{keyvalues:[8],horizontal:[4]}]]],["p-e55a967b",[[1,"tttx-loading-spinner",{loadingMessage:[1028,"loading-message"],size:[1025]}]]],["p-50cdce65",[[1,"tttx-qrcode",{link:[1025],size:[1026]}]]],["p-a6582ab0",[[1,"tttx-tag",{text:[1],color:[1]}]]],["p-c0c022cd",[[1,"tttx-toolbar",{border:[4],viewSize:[32]},[[9,"resize","handleResize"]]]]],["p-e89b053f",[[1,"tttx-icon",{icon:[1],color:[1]}]]],["p-818574fe",[[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]}]]],["p-5b7b8539",[[1,"tttx-button",{notext:[4],icon:[1],iconposition:[1],iconcolor:[1025],design:[1]}]]]],e)));
1
+ import{p as e,b as t}from"./p-3f1b6013.js";export{s as setNonce}from"./p-3f1b6013.js";(()=>{const t=import.meta.url,o={};return""!==t&&(o.resourcesUrl=new URL(".",t).href),e(o)})().then((e=>t([["p-77fed2a6",[[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"]]]]],["p-f34bface",[[1,"tttx-dialog-box",{data:[1025],size:[1],open:[1028],allowOverflow:[4,"allow-overflow"],elementSize:[32]},[[9,"resize","handleResize"]]]]],["p-887f56cb",[[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"]]]]],["p-75c31e23",[[1,"tttx-tree-view",{data:[1040],treeData:[32]}]]],["p-c714f7c0",[[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"]]]]],["p-750cf31b",[[1,"tttx-list",{data:[1025],name:[1],_data:[32]}]]],["p-5290db99",[[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"]]]]],["p-67c342d7",[[2,"tttx-tabs",{tabsName:[1,"tabs-name"],navigation:[4],wide:[4],tabs:[1],_tabs:[32]},[[0,"keydown","handleKeyDown"]]]]],["p-895526aa",[[1,"tttx-form",{formschema:[1032],data:[1032],submit:[64]}]]],["p-6fe0af4e",[[1,"tttx-keyvalue-block",{keyvalues:[8],horizontal:[4]}]]],["p-e55a967b",[[1,"tttx-loading-spinner",{loadingMessage:[1028,"loading-message"],size:[1025]}]]],["p-50cdce65",[[1,"tttx-qrcode",{link:[1025],size:[1026]}]]],["p-a6582ab0",[[1,"tttx-tag",{text:[1],color:[1]}]]],["p-c0c022cd",[[1,"tttx-toolbar",{border:[4],viewSize:[32]},[[9,"resize","handleResize"]]]]],["p-e89b053f",[[1,"tttx-icon",{icon:[1],color:[1]}]]],["p-818574fe",[[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]}]]],["p-5b7b8539",[[1,"tttx-button",{notext:[4],icon:[1],iconposition:[1],iconcolor:[1025],design:[1]}]]]],e)));
@@ -0,0 +1,6 @@
1
+ export interface SelectItem {
2
+ value: string;
3
+ label: string;
4
+ html?: string;
5
+ selected: boolean;
6
+ }