@3t-transform/threeteeui 0.2.74 → 0.2.76
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-button.cjs.entry.js +2 -2
- package/dist/cjs/tttx-form.cjs.entry.js +78 -49
- package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +17 -14
- package/dist/cjs/tttx-list.cjs.entry.js +1 -1
- package/dist/cjs/tttx-multiselect-box.cjs.entry.js +130 -0
- package/dist/cjs/tttx-standalone-input.cjs.entry.js +8 -3
- package/dist/cjs/tttx-tag.cjs.entry.js +1 -1
- package/dist/cjs/tttx.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/atoms/tttx-button/tttx-button.css +1 -1
- package/dist/collection/components/atoms/tttx-button/tttx-button.js +1 -2
- package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +1 -1
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +0 -1
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.css +14 -5
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +46 -18
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +85 -29
- package/dist/collection/components/atoms/tttx-tag/tttx-tag.css +1 -1
- package/dist/collection/components/atoms/tttx-tag/tttx-tag.js +0 -1
- package/dist/collection/components/atoms/tttx-tag/tttx-tag.stories.js +1 -1
- package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +14 -3
- package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +15 -13
- package/dist/collection/components/molecules/tttx-form/tttx-form.css +107 -177
- package/dist/collection/components/molecules/tttx-form/tttx-form.js +56 -36
- package/dist/collection/components/molecules/tttx-list/tttx-list.css +1 -1
- package/dist/collection/components/molecules/tttx-multiselect-box/tttx-multiselect-box.css +135 -0
- package/dist/collection/components/molecules/tttx-multiselect-box/tttx-multiselect-box.js +339 -0
- package/dist/collection/components/molecules/tttx-multiselect-box/tttx-multiselect-box.stories.js +201 -0
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.css +102 -198
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +7 -2
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +23 -5
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/tttx-button2.js +2 -2
- package/dist/components/tttx-form.js +79 -50
- package/dist/components/tttx-keyvalue-block.js +21 -16
- package/dist/components/tttx-list.js +1 -1
- package/dist/components/tttx-multiselect-box.d.ts +11 -0
- package/dist/components/tttx-multiselect-box.js +172 -0
- package/dist/components/tttx-standalone-input2.js +8 -3
- package/dist/components/tttx-tag.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tttx-button.entry.js +2 -2
- package/dist/esm/tttx-form.entry.js +78 -49
- package/dist/esm/tttx-keyvalue-block.entry.js +17 -14
- package/dist/esm/tttx-list.entry.js +1 -1
- package/dist/esm/tttx-multiselect-box.entry.js +126 -0
- package/dist/esm/tttx-standalone-input.entry.js +8 -3
- package/dist/esm/tttx-tag.entry.js +1 -1
- package/dist/esm/tttx.js +1 -1
- package/dist/tttx/p-09b92178.entry.js +1 -0
- package/dist/tttx/{p-750cf31b.entry.js → p-129df5a2.entry.js} +1 -1
- package/dist/tttx/{p-a6582ab0.entry.js → p-25acdd4c.entry.js} +1 -1
- package/dist/tttx/{p-5b7b8539.entry.js → p-4ade2866.entry.js} +1 -1
- package/dist/tttx/p-77fed2a6.entry.js +1 -0
- package/dist/tttx/p-b30a1025.entry.js +1 -0
- package/dist/tttx/p-d1ff1456.entry.js +1 -0
- package/dist/tttx/tttx.esm.js +1 -1
- package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -1
- package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +6 -4
- package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +3 -2
- package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +5 -7
- package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +74 -29
- package/dist/types/components/molecules/tttx-multiselect-box/interfaces.d.ts +6 -0
- package/dist/types/components/molecules/tttx-multiselect-box/tttx-multiselect-box.d.ts +38 -0
- package/dist/types/components/molecules/tttx-multiselect-box/tttx-multiselect-box.stories.d.ts +15 -0
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +7 -0
- package/dist/types/components.d.ts +46 -8
- package/package.json +1 -1
- package/dist/tttx/p-6fe0af4e.entry.js +0 -1
- package/dist/tttx/p-818574fe.entry.js +0 -1
- package/dist/tttx/p-895526aa.entry.js +0 -1
|
@@ -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
|
+
}
|
package/dist/collection/components/molecules/tttx-multiselect-box/tttx-multiselect-box.stories.js
ADDED
|
@@ -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
|
+
};
|