@scania/tegel 1.23.0-beta.0 → 1.23.0-block-nesting-beta.0
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/tds-block.cjs.entry.js +1 -1
- package/dist/cjs/tds-checkbox.cjs.entry.js +9 -2
- package/dist/cjs/tds-dropdown_2.cjs.entry.js +159 -128
- package/dist/cjs/tds-popover-core.cjs.entry.js +1 -1
- package/dist/cjs/tegel.cjs.js +1 -1
- package/dist/collection/components/block/block.css +1 -3
- package/dist/collection/components/checkbox/checkbox.js +19 -3
- package/dist/collection/components/dropdown/dropdown.js +209 -200
- package/dist/collection/components/popover-core/tds-popover-core.css +6 -16
- package/dist/components/{p-ca4b945d.js → p-2523819c.js} +164 -135
- package/dist/components/{p-e02b091c.js → p-3a32c37c.js} +1 -1
- package/dist/components/{p-dcfecf4d.js → p-50179eca.js} +1 -1
- package/dist/components/{p-e4d7c655.js → p-d921fe75.js} +10 -3
- package/dist/components/{p-462b77e8.js → p-e7868876.js} +1 -1
- package/dist/components/tds-block.js +1 -1
- package/dist/components/tds-checkbox.js +1 -1
- package/dist/components/tds-dropdown-option.js +1 -1
- package/dist/components/tds-dropdown.js +1 -1
- package/dist/components/tds-header-dropdown.js +2 -2
- package/dist/components/tds-header-launcher.js +2 -2
- package/dist/components/tds-popover-canvas.js +1 -1
- package/dist/components/tds-popover-core.js +1 -1
- package/dist/components/tds-popover-menu.js +1 -1
- package/dist/components/tds-table-body-row.js +1 -1
- package/dist/components/tds-table-footer.js +3 -3
- package/dist/components/tds-table-header.js +1 -1
- package/dist/components/tds-tooltip.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tds-block.entry.js +1 -1
- package/dist/esm/tds-checkbox.entry.js +9 -2
- package/dist/esm/tds-dropdown_2.entry.js +159 -128
- package/dist/esm/tds-popover-core.entry.js +1 -1
- package/dist/esm/tegel.js +1 -1
- package/dist/tegel/{p-590b5f55.entry.js → p-2a2756ac.entry.js} +1 -1
- package/dist/tegel/p-6a52ed63.entry.js +1 -0
- package/dist/tegel/p-979f5255.entry.js +1 -0
- package/dist/tegel/p-9dba483c.entry.js +1 -0
- package/dist/tegel/tegel.css +1 -1
- package/dist/tegel/tegel.esm.js +1 -1
- package/dist/types/components/checkbox/checkbox.d.ts +2 -0
- package/dist/types/components/dropdown/dropdown.d.ts +36 -20
- package/dist/types/components.d.ts +11 -21
- package/package.json +1 -1
- package/dist/tegel/p-a464920f.entry.js +0 -1
- package/dist/tegel/p-db00f607.entry.js +0 -1
- package/dist/tegel/p-e252ba6e.entry.js +0 -1
|
@@ -7,13 +7,6 @@ import appendHiddenInput from "../../utils/appendHiddenInput";
|
|
|
7
7
|
*/
|
|
8
8
|
export class TdsDropdown {
|
|
9
9
|
constructor() {
|
|
10
|
-
this.handleChange = () => {
|
|
11
|
-
const value = Array.isArray(this.value) ? this.value.join(',') : this.value;
|
|
12
|
-
this.tdsChange.emit({
|
|
13
|
-
name: this.name,
|
|
14
|
-
value: value !== null && value !== void 0 ? value : null,
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
10
|
this.setDefaultOption = () => {
|
|
18
11
|
if (this.defaultValue) {
|
|
19
12
|
const children = Array.from(this.host.children).filter((element) => element.tagName === 'TDS-DROPDOWN-OPTION');
|
|
@@ -42,6 +35,7 @@ export class TdsDropdown {
|
|
|
42
35
|
}
|
|
43
36
|
}
|
|
44
37
|
};
|
|
38
|
+
/* Returns a list of all children that are tds-dropdown-option elements */
|
|
45
39
|
this.getChildren = () => {
|
|
46
40
|
const tdsDropdownOptions = Array.from(this.host.children).filter((element) => element.tagName === 'TDS-DROPDOWN-OPTION');
|
|
47
41
|
if (tdsDropdownOptions.length === 0) {
|
|
@@ -50,38 +44,6 @@ export class TdsDropdown {
|
|
|
50
44
|
else
|
|
51
45
|
return tdsDropdownOptions;
|
|
52
46
|
};
|
|
53
|
-
this.getSelectedChildren = () => {
|
|
54
|
-
if (!this.value)
|
|
55
|
-
return [];
|
|
56
|
-
const valueArray = Array.isArray(this.value) ? this.value : [this.value];
|
|
57
|
-
return valueArray
|
|
58
|
-
.map((stringValue) => {
|
|
59
|
-
const matchingElement = this.getChildren().find((element) => element.value === stringValue);
|
|
60
|
-
return matchingElement;
|
|
61
|
-
})
|
|
62
|
-
.filter(Boolean);
|
|
63
|
-
};
|
|
64
|
-
this.getSelectedChildrenLabels = () => {
|
|
65
|
-
var _a;
|
|
66
|
-
return (_a = this.getSelectedChildren()) === null || _a === void 0 ? void 0 : _a.map((element) => element.textContent.trim());
|
|
67
|
-
};
|
|
68
|
-
this.getValue = () => {
|
|
69
|
-
const labels = this.getSelectedChildrenLabels();
|
|
70
|
-
if (!labels) {
|
|
71
|
-
return '';
|
|
72
|
-
}
|
|
73
|
-
return labels === null || labels === void 0 ? void 0 : labels.join(', ');
|
|
74
|
-
};
|
|
75
|
-
this.setValueAttribute = () => {
|
|
76
|
-
var _a;
|
|
77
|
-
if (!this.value || ((_a = this.value) === null || _a === void 0 ? void 0 : _a.toString()) === '') {
|
|
78
|
-
this.host.removeAttribute('value');
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
const valueArray = Array.isArray(this.value) ? this.value : [this.value];
|
|
82
|
-
this.host.setAttribute('value', valueArray.map((val) => val).toString());
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
47
|
this.getOpenDirection = () => {
|
|
86
48
|
var _a, _b, _c, _d, _e;
|
|
87
49
|
if (this.openDirection === 'auto' || !this.openDirection) {
|
|
@@ -95,6 +57,7 @@ export class TdsDropdown {
|
|
|
95
57
|
}
|
|
96
58
|
return this.openDirection;
|
|
97
59
|
};
|
|
60
|
+
/* Toggles the open state of the Dropdown and sets focus to the input element */
|
|
98
61
|
this.handleToggleOpen = () => {
|
|
99
62
|
if (!this.disabled) {
|
|
100
63
|
this.open = !this.open;
|
|
@@ -103,10 +66,38 @@ export class TdsDropdown {
|
|
|
103
66
|
}
|
|
104
67
|
}
|
|
105
68
|
};
|
|
69
|
+
/* Focuses the input element in the Dropdown, if the reference is present. */
|
|
106
70
|
this.focusInputElement = () => {
|
|
107
71
|
if (this.inputElement)
|
|
108
72
|
this.inputElement.focus();
|
|
109
73
|
};
|
|
74
|
+
this.getSelectedChildren = () => {
|
|
75
|
+
var _a;
|
|
76
|
+
return (_a = this.value) === null || _a === void 0 ? void 0 : _a.map((stringValue) => {
|
|
77
|
+
const matchingElement = this.getChildren().find((element) => element.value === stringValue);
|
|
78
|
+
return matchingElement;
|
|
79
|
+
}).filter(Boolean);
|
|
80
|
+
};
|
|
81
|
+
this.getSelectedChildrenLabels = () => {
|
|
82
|
+
var _a;
|
|
83
|
+
return (_a = this.getSelectedChildren()) === null || _a === void 0 ? void 0 : _a.map((element) => element.textContent.trim());
|
|
84
|
+
};
|
|
85
|
+
this.getValue = () => {
|
|
86
|
+
const labels = this.getSelectedChildrenLabels();
|
|
87
|
+
if (!labels) {
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
return labels === null || labels === void 0 ? void 0 : labels.join(', ');
|
|
91
|
+
};
|
|
92
|
+
this.setValueAttribute = () => {
|
|
93
|
+
var _a;
|
|
94
|
+
if (!this.value || ((_a = this.value) === null || _a === void 0 ? void 0 : _a.toString()) === '') {
|
|
95
|
+
this.host.removeAttribute('value');
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.host.setAttribute('value', this.value.map((val) => val).toString());
|
|
99
|
+
}
|
|
100
|
+
};
|
|
110
101
|
this.handleFilter = (event) => {
|
|
111
102
|
this.tdsInput.emit(event);
|
|
112
103
|
const query = event.target.value.toLowerCase();
|
|
@@ -152,6 +143,13 @@ export class TdsDropdown {
|
|
|
152
143
|
this.handleBlur = (event) => {
|
|
153
144
|
this.tdsBlur.emit(event);
|
|
154
145
|
};
|
|
146
|
+
this.handleChange = () => {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
this.tdsChange.emit({
|
|
149
|
+
name: this.name,
|
|
150
|
+
value: (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.map((value) => value).toString()) !== null && _b !== void 0 ? _b : null,
|
|
151
|
+
});
|
|
152
|
+
};
|
|
155
153
|
this.name = undefined;
|
|
156
154
|
this.disabled = false;
|
|
157
155
|
this.helper = undefined;
|
|
@@ -168,92 +166,107 @@ export class TdsDropdown {
|
|
|
168
166
|
this.normalizeText = true;
|
|
169
167
|
this.noResultText = 'No result';
|
|
170
168
|
this.defaultValue = undefined;
|
|
171
|
-
this.value = undefined;
|
|
172
169
|
this.open = false;
|
|
173
|
-
this.
|
|
170
|
+
this.value = undefined;
|
|
174
171
|
this.filterResult = undefined;
|
|
175
172
|
this.filterFocus = undefined;
|
|
176
173
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const valueArray = Array.isArray(newValue) ? newValue : newValue ? [newValue] : null;
|
|
182
|
-
// Handle multiselect validation
|
|
183
|
-
if (!this.multiselect && Array.isArray(valueArray) && valueArray.length > 1) {
|
|
184
|
-
console.warn('Tried to select multiple items, but multiselect is not enabled.');
|
|
185
|
-
// Coerce to single value for non-multiselect
|
|
186
|
-
this.value = valueArray[0];
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
// Ensure value is always array internally for backward compatibility
|
|
190
|
-
this.updateSelections(valueArray);
|
|
174
|
+
/** Method that resets the Dropdown, marks all children as non-selected and resets the value to null. */
|
|
175
|
+
async reset() {
|
|
176
|
+
this.dropdownList.scrollTop = 0;
|
|
177
|
+
this.internalReset();
|
|
191
178
|
this.handleChange();
|
|
192
179
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
this.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
this.internalValue = '';
|
|
225
|
-
this.value = this.multiselect ? [] : null;
|
|
180
|
+
/** Method that forces focus on the input element. */
|
|
181
|
+
async focusElement() {
|
|
182
|
+
this.focusInputElement();
|
|
183
|
+
this.handleFocus({});
|
|
184
|
+
}
|
|
185
|
+
/** Method for setting the value of the Dropdown.
|
|
186
|
+
*
|
|
187
|
+
* Single selection example:
|
|
188
|
+
*
|
|
189
|
+
* <code>
|
|
190
|
+
* dropdown.setValue('option-1', 'Option 1');
|
|
191
|
+
* </code>
|
|
192
|
+
*
|
|
193
|
+
* Multiselect example:
|
|
194
|
+
*
|
|
195
|
+
* <code>
|
|
196
|
+
* dropdown.setValue(['option-1', 'option-2']);
|
|
197
|
+
* </code>
|
|
198
|
+
*/
|
|
199
|
+
// The label is optional here ONLY to not break the API. Should be removed for 2.0.
|
|
200
|
+
// @ts-ignore
|
|
201
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
202
|
+
async setValue(value, label) {
|
|
203
|
+
let nextValue;
|
|
204
|
+
if (typeof value === 'string')
|
|
205
|
+
nextValue = [value];
|
|
206
|
+
else
|
|
207
|
+
nextValue = value;
|
|
208
|
+
if (!this.multiselect && nextValue.length > 1) {
|
|
209
|
+
console.warn('Tried to select multiple items, but multiselect is not enabled.');
|
|
210
|
+
nextValue = [nextValue[0]];
|
|
226
211
|
}
|
|
227
|
-
|
|
228
|
-
this.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
212
|
+
nextValue = [...new Set(nextValue)];
|
|
213
|
+
this.internalReset();
|
|
214
|
+
for (let i = 0; i < nextValue.length; i++) {
|
|
215
|
+
const optionExist = this.getChildren().some((element) => element.value === nextValue[i]);
|
|
216
|
+
if (!optionExist) {
|
|
217
|
+
nextValue.splice(i, 1);
|
|
218
|
+
}
|
|
232
219
|
}
|
|
220
|
+
this.value = nextValue;
|
|
233
221
|
this.setValueAttribute();
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
222
|
+
this.selectChildrenAsSelectedBasedOnSelectionProp();
|
|
223
|
+
this.handleChange();
|
|
224
|
+
/* This returns an array of object with a value and label pair. This is ONLY to not break the API. Should be removed for 2.0. */
|
|
225
|
+
/* https://tegel.atlassian.net/browse/CDEP-2703 */
|
|
226
|
+
const selection = this.getSelectedChildren().map((element) => ({
|
|
238
227
|
value: element.value,
|
|
239
228
|
label: element.textContent.trim(),
|
|
240
229
|
}));
|
|
230
|
+
// Update inputElement value and placeholder text
|
|
231
|
+
if (this.filter) {
|
|
232
|
+
this.inputElement.value = this.getValue();
|
|
233
|
+
}
|
|
234
|
+
return selection;
|
|
241
235
|
}
|
|
242
|
-
|
|
243
|
-
|
|
236
|
+
/**
|
|
237
|
+
* @internal
|
|
238
|
+
*/
|
|
239
|
+
async appendValue(value) {
|
|
240
|
+
if (this.multiselect && this.value) {
|
|
241
|
+
this.setValue([...this.value, value]);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
this.setValue(value);
|
|
245
|
+
}
|
|
244
246
|
}
|
|
247
|
+
/** Method for removing a selected value in the Dropdown. */
|
|
245
248
|
async removeValue(oldValue) {
|
|
246
|
-
|
|
247
|
-
|
|
249
|
+
var _a, _b;
|
|
250
|
+
let label;
|
|
251
|
+
if (this.multiselect) {
|
|
252
|
+
(_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
|
|
253
|
+
var _a;
|
|
254
|
+
if (element.value === oldValue) {
|
|
255
|
+
this.value = (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter((value) => value !== element.value);
|
|
256
|
+
label = element.textContent.trim();
|
|
257
|
+
element.setSelected(false);
|
|
258
|
+
}
|
|
259
|
+
return element;
|
|
260
|
+
});
|
|
248
261
|
}
|
|
249
262
|
else {
|
|
250
|
-
this.
|
|
263
|
+
this.reset();
|
|
251
264
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
this.
|
|
265
|
+
this.handleChange();
|
|
266
|
+
this.setValueAttribute();
|
|
267
|
+
/* This returns an array of object with a value and label pair. This is ONLY to not break the API. Should be removed for 2.0. */
|
|
268
|
+
/* https://tegel.atlassian.net/browse/CDEP-2703 */
|
|
269
|
+
return (_b = this.value) === null || _b === void 0 ? void 0 : _b.map((value) => ({ value, label }));
|
|
257
270
|
}
|
|
258
271
|
/** Method for closing the Dropdown. */
|
|
259
272
|
async close() {
|
|
@@ -307,9 +320,6 @@ export class TdsDropdown {
|
|
|
307
320
|
}
|
|
308
321
|
}
|
|
309
322
|
componentWillLoad() {
|
|
310
|
-
if (this.defaultValue && !this.value) {
|
|
311
|
-
this.value = this.defaultValue;
|
|
312
|
-
}
|
|
313
323
|
this.setDefaultOption();
|
|
314
324
|
}
|
|
315
325
|
/** Method to handle slot changes */
|
|
@@ -320,19 +330,34 @@ export class TdsDropdown {
|
|
|
320
330
|
normalizeString(text) {
|
|
321
331
|
return this.normalizeText ? text.normalize('NFD').replace(/\p{Diacritic}/gu, '') : text;
|
|
322
332
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
333
|
+
/** Method that resets the dropdown without emitting an event. */
|
|
334
|
+
internalReset() {
|
|
335
|
+
this.getChildren().forEach((element) => {
|
|
336
|
+
element.setSelected(false);
|
|
337
|
+
return element;
|
|
338
|
+
});
|
|
339
|
+
this.value = null;
|
|
340
|
+
this.setValueAttribute();
|
|
341
|
+
}
|
|
342
|
+
selectChildrenAsSelectedBasedOnSelectionProp() {
|
|
343
|
+
this.getChildren().forEach((element) => {
|
|
344
|
+
this.value.forEach((selection) => {
|
|
345
|
+
if (element.value !== selection) {
|
|
346
|
+
// If not multiselect, we need to unselect all other options.
|
|
347
|
+
if (!this.multiselect) {
|
|
348
|
+
element.setSelected(false);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
element.setSelected(true);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
});
|
|
330
356
|
}
|
|
331
357
|
render() {
|
|
332
|
-
var _a, _b, _c;
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
return (h(Host, { key: '2d1d0d7551c4f5a3197538a21b245b06abb95a5b', role: "select", class: `${this.modeVariant ? `tds-mode-variant-${this.modeVariant}` : ''}` }, this.label && this.labelPosition === 'outside' && (h("div", { key: '44bf815fc834febcf5bf90aeabeb4ff75ca74e0b', class: `label-outside ${this.disabled ? 'disabled' : ''}` }, this.label)), h("div", { key: 'fe8bddaad6f52c6860a8a3b02db796d927553c64', class: `dropdown-select ${this.size} ${this.disabled ? 'disabled' : ''}` }, this.filter ? (h("div", { class: {
|
|
358
|
+
var _a, _b, _c, _d;
|
|
359
|
+
appendHiddenInput(this.host, this.name, (_a = this.value) === null || _a === void 0 ? void 0 : _a.map((value) => value).toString(), this.disabled);
|
|
360
|
+
return (h(Host, { key: '1c4995be9b1e47e254ec9976b334c4d74a44263b', role: "select", class: `${this.modeVariant ? `tds-mode-variant-${this.modeVariant}` : ''}` }, this.label && this.labelPosition === 'outside' && (h("div", { key: 'ad423934dedc56ff39d06bf7746e47d011bed002', class: `label-outside ${this.disabled ? 'disabled' : ''}` }, this.label)), h("div", { key: '99c87c0add1152f47533bf6ef5e6794cffdbb18c', class: `dropdown-select ${this.size} ${this.disabled ? 'disabled' : ''}` }, this.filter ? (h("div", { class: {
|
|
336
361
|
filter: true,
|
|
337
362
|
focus: this.filterFocus,
|
|
338
363
|
disabled: this.disabled,
|
|
@@ -340,7 +365,7 @@ export class TdsDropdown {
|
|
|
340
365
|
} }, h("div", { class: "value-wrapper" }, this.label && this.labelPosition === 'inside' && this.placeholder && (h("div", { class: `label-inside ${this.size}` }, this.label)), this.label && this.labelPosition === 'inside' && !this.placeholder && (h("div", { class: `
|
|
341
366
|
label-inside-as-placeholder
|
|
342
367
|
${this.size}
|
|
343
|
-
${((
|
|
368
|
+
${((_b = this.value) === null || _b === void 0 ? void 0 : _b.length) ? 'selected' : ''}
|
|
344
369
|
` }, this.label)), h("input", {
|
|
345
370
|
// eslint-disable-next-line no-return-assign
|
|
346
371
|
ref: (inputEl) => (this.inputElement = inputEl), class: `${this.labelPosition === 'inside' ? 'placeholder' : ''}`, type: "text", placeholder: this.filterFocus ? '' : this.placeholder, value: this.multiselect && this.filterFocus ? '' : this.getValue(), disabled: this.disabled, onInput: (event) => this.handleFilter(event), onBlur: (event) => {
|
|
@@ -349,7 +374,15 @@ export class TdsDropdown {
|
|
|
349
374
|
this.inputElement.value = this.getValue();
|
|
350
375
|
}
|
|
351
376
|
this.handleBlur(event);
|
|
352
|
-
}, onFocus: (event) =>
|
|
377
|
+
}, onFocus: (event) => {
|
|
378
|
+
this.open = true;
|
|
379
|
+
this.filterFocus = true;
|
|
380
|
+
if (this.multiselect) {
|
|
381
|
+
this.inputElement.value = '';
|
|
382
|
+
}
|
|
383
|
+
this.handleFocus(event);
|
|
384
|
+
this.handleFilter({ target: { value: '' } });
|
|
385
|
+
}, onKeyDown: (event) => {
|
|
353
386
|
if (event.key === 'Escape') {
|
|
354
387
|
this.open = false;
|
|
355
388
|
}
|
|
@@ -373,8 +406,8 @@ export class TdsDropdown {
|
|
|
373
406
|
`, disabled: this.disabled }, h("div", { class: `value-wrapper ${this.size}` }, this.label && this.labelPosition === 'inside' && this.placeholder && (h("div", { class: `label-inside ${this.size}` }, this.label)), this.label && this.labelPosition === 'inside' && !this.placeholder && (h("div", { class: `
|
|
374
407
|
label-inside-as-placeholder
|
|
375
408
|
${this.size}
|
|
376
|
-
${((
|
|
377
|
-
` }, this.label)), h("div", { class: `placeholder ${this.size}` }, ((
|
|
409
|
+
${((_c = this.value) === null || _c === void 0 ? void 0 : _c.length) ? 'selected' : ''}
|
|
410
|
+
` }, this.label)), h("div", { class: `placeholder ${this.size}` }, ((_d = this.value) === null || _d === void 0 ? void 0 : _d.length) ? this.getValue() : this.placeholder), h("tds-icon", { "aria-label": "Open/Close dropdown", svgTitle: "Open/Close dropdown", class: `menu-icon ${this.open ? 'open' : 'closed'}`, name: "chevron_down", size: "16px" }))))), h("div", { key: 'dd850ac34b473f9cac51ad5bdc8417d994b7946a', ref: (element) => (this.dropdownList = element), class: {
|
|
378
411
|
'dropdown-list': true,
|
|
379
412
|
[this.size]: true,
|
|
380
413
|
[this.getOpenDirection()]: true,
|
|
@@ -383,7 +416,7 @@ export class TdsDropdown {
|
|
|
383
416
|
'closed': !this.open,
|
|
384
417
|
[`animation-enter-${this.animation}`]: this.animation !== 'none' && this.open,
|
|
385
418
|
[`animation-exit-${this.animation}`]: this.animation !== 'none' && !this.open,
|
|
386
|
-
} }, h("slot", { key: '
|
|
419
|
+
} }, h("slot", { key: '790885487da46ec88e05ad98272cbd43eb6fc7ac', onSlotchange: () => this.handleSlotChange() }), this.filterResult === 0 && this.noResultText !== '' && (h("div", { key: '7d9c9f695c5dc2c734fa51a746c6c1c3547d5dec', class: `no-result ${this.size}` }, this.noResultText))), this.helper && (h("div", { key: 'b044b0d4dd3e39000fa0262a838aa860451e5986', class: `helper ${this.error ? 'error' : ''} ${this.disabled ? 'disabled' : ''}` }, this.error && h("tds-icon", { key: '506204fd3f113c6a903b616372660902295d0886', name: "error", size: "16px" }), this.helper))));
|
|
387
420
|
}
|
|
388
421
|
static get is() { return "tds-dropdown"; }
|
|
389
422
|
static get encapsulation() { return "shadow"; }
|
|
@@ -680,30 +713,13 @@ export class TdsDropdown {
|
|
|
680
713
|
},
|
|
681
714
|
"attribute": "default-value",
|
|
682
715
|
"reflect": false
|
|
683
|
-
},
|
|
684
|
-
"value": {
|
|
685
|
-
"type": "string",
|
|
686
|
-
"mutable": true,
|
|
687
|
-
"complexType": {
|
|
688
|
-
"original": "string | string[]",
|
|
689
|
-
"resolved": "string | string[]",
|
|
690
|
-
"references": {}
|
|
691
|
-
},
|
|
692
|
-
"required": false,
|
|
693
|
-
"optional": false,
|
|
694
|
-
"docs": {
|
|
695
|
-
"tags": [],
|
|
696
|
-
"text": "Value of the dropdown. For multiselect, provide array of strings. For single select, provide a string."
|
|
697
|
-
},
|
|
698
|
-
"attribute": "value",
|
|
699
|
-
"reflect": false
|
|
700
716
|
}
|
|
701
717
|
};
|
|
702
718
|
}
|
|
703
719
|
static get states() {
|
|
704
720
|
return {
|
|
705
721
|
"open": {},
|
|
706
|
-
"
|
|
722
|
+
"value": {},
|
|
707
723
|
"filterResult": {},
|
|
708
724
|
"filterFocus": {}
|
|
709
725
|
};
|
|
@@ -784,51 +800,28 @@ export class TdsDropdown {
|
|
|
784
800
|
}
|
|
785
801
|
}
|
|
786
802
|
}
|
|
787
|
-
}, {
|
|
788
|
-
"method": "tdsValueChange",
|
|
789
|
-
"name": "tdsValueChange",
|
|
790
|
-
"bubbles": true,
|
|
791
|
-
"cancelable": false,
|
|
792
|
-
"composed": true,
|
|
793
|
-
"docs": {
|
|
794
|
-
"tags": [],
|
|
795
|
-
"text": "Value change event for the Dropdown."
|
|
796
|
-
},
|
|
797
|
-
"complexType": {
|
|
798
|
-
"original": "{\n name: string;\n value: string;\n }",
|
|
799
|
-
"resolved": "{ name: string; value: string; }",
|
|
800
|
-
"references": {}
|
|
801
|
-
}
|
|
802
803
|
}];
|
|
803
804
|
}
|
|
804
805
|
static get methods() {
|
|
805
806
|
return {
|
|
806
|
-
"
|
|
807
|
+
"reset": {
|
|
807
808
|
"complexType": {
|
|
808
|
-
"signature": "(
|
|
809
|
-
"parameters": [
|
|
810
|
-
"name": "value",
|
|
811
|
-
"type": "string | string[]",
|
|
812
|
-
"docs": ""
|
|
813
|
-
}],
|
|
809
|
+
"signature": "() => Promise<void>",
|
|
810
|
+
"parameters": [],
|
|
814
811
|
"references": {
|
|
815
812
|
"Promise": {
|
|
816
813
|
"location": "global",
|
|
817
814
|
"id": "global::Promise"
|
|
818
|
-
},
|
|
819
|
-
"HTMLTdsDropdownOptionElement": {
|
|
820
|
-
"location": "global",
|
|
821
|
-
"id": "global::HTMLTdsDropdownOptionElement"
|
|
822
815
|
}
|
|
823
816
|
},
|
|
824
|
-
"return": "Promise<
|
|
817
|
+
"return": "Promise<void>"
|
|
825
818
|
},
|
|
826
819
|
"docs": {
|
|
827
|
-
"text": "",
|
|
820
|
+
"text": "Method that resets the Dropdown, marks all children as non-selected and resets the value to null.",
|
|
828
821
|
"tags": []
|
|
829
822
|
}
|
|
830
823
|
},
|
|
831
|
-
"
|
|
824
|
+
"focusElement": {
|
|
832
825
|
"complexType": {
|
|
833
826
|
"signature": "() => Promise<void>",
|
|
834
827
|
"parameters": [],
|
|
@@ -841,15 +834,19 @@ export class TdsDropdown {
|
|
|
841
834
|
"return": "Promise<void>"
|
|
842
835
|
},
|
|
843
836
|
"docs": {
|
|
844
|
-
"text": "",
|
|
837
|
+
"text": "Method that forces focus on the input element.",
|
|
845
838
|
"tags": []
|
|
846
839
|
}
|
|
847
840
|
},
|
|
848
|
-
"
|
|
841
|
+
"setValue": {
|
|
849
842
|
"complexType": {
|
|
850
|
-
"signature": "(
|
|
843
|
+
"signature": "(value: string | string[], label?: string) => Promise<{ value: string; label: string; }[]>",
|
|
851
844
|
"parameters": [{
|
|
852
|
-
"name": "
|
|
845
|
+
"name": "value",
|
|
846
|
+
"type": "string | string[]",
|
|
847
|
+
"docs": ""
|
|
848
|
+
}, {
|
|
849
|
+
"name": "label",
|
|
853
850
|
"type": "string",
|
|
854
851
|
"docs": ""
|
|
855
852
|
}],
|
|
@@ -857,19 +854,27 @@ export class TdsDropdown {
|
|
|
857
854
|
"Promise": {
|
|
858
855
|
"location": "global",
|
|
859
856
|
"id": "global::Promise"
|
|
857
|
+
},
|
|
858
|
+
"HTMLTdsDropdownOptionElement": {
|
|
859
|
+
"location": "global",
|
|
860
|
+
"id": "global::HTMLTdsDropdownOptionElement"
|
|
860
861
|
}
|
|
861
862
|
},
|
|
862
|
-
"return": "Promise<
|
|
863
|
+
"return": "Promise<{ value: string; label: string; }[]>"
|
|
863
864
|
},
|
|
864
865
|
"docs": {
|
|
865
|
-
"text": "",
|
|
866
|
+
"text": "Method for setting the value of the Dropdown.\n\nSingle selection example:\n\n<code>\ndropdown.setValue('option-1', 'Option 1');\n</code>\n\nMultiselect example:\n\n<code>\ndropdown.setValue(['option-1', 'option-2']);\n</code>",
|
|
866
867
|
"tags": []
|
|
867
868
|
}
|
|
868
869
|
},
|
|
869
|
-
"
|
|
870
|
+
"appendValue": {
|
|
870
871
|
"complexType": {
|
|
871
|
-
"signature": "() => Promise<void>",
|
|
872
|
-
"parameters": [
|
|
872
|
+
"signature": "(value: string) => Promise<void>",
|
|
873
|
+
"parameters": [{
|
|
874
|
+
"name": "value",
|
|
875
|
+
"type": "string",
|
|
876
|
+
"docs": ""
|
|
877
|
+
}],
|
|
873
878
|
"references": {
|
|
874
879
|
"Promise": {
|
|
875
880
|
"location": "global",
|
|
@@ -879,35 +884,42 @@ export class TdsDropdown {
|
|
|
879
884
|
"return": "Promise<void>"
|
|
880
885
|
},
|
|
881
886
|
"docs": {
|
|
882
|
-
"text": "
|
|
883
|
-
"tags": [
|
|
887
|
+
"text": "",
|
|
888
|
+
"tags": [{
|
|
889
|
+
"name": "internal",
|
|
890
|
+
"text": undefined
|
|
891
|
+
}]
|
|
884
892
|
}
|
|
885
893
|
},
|
|
886
|
-
"
|
|
894
|
+
"removeValue": {
|
|
887
895
|
"complexType": {
|
|
888
|
-
"signature": "() => Promise<
|
|
889
|
-
"parameters": [
|
|
896
|
+
"signature": "(oldValue: string) => Promise<{ value: string; label: string; }[]>",
|
|
897
|
+
"parameters": [{
|
|
898
|
+
"name": "oldValue",
|
|
899
|
+
"type": "string",
|
|
900
|
+
"docs": ""
|
|
901
|
+
}],
|
|
890
902
|
"references": {
|
|
891
903
|
"Promise": {
|
|
892
904
|
"location": "global",
|
|
893
905
|
"id": "global::Promise"
|
|
906
|
+
},
|
|
907
|
+
"HTMLTdsDropdownOptionElement": {
|
|
908
|
+
"location": "global",
|
|
909
|
+
"id": "global::HTMLTdsDropdownOptionElement"
|
|
894
910
|
}
|
|
895
911
|
},
|
|
896
|
-
"return": "Promise<
|
|
912
|
+
"return": "Promise<{ value: string; label: string; }[]>"
|
|
897
913
|
},
|
|
898
914
|
"docs": {
|
|
899
|
-
"text": "Method for
|
|
915
|
+
"text": "Method for removing a selected value in the Dropdown.",
|
|
900
916
|
"tags": []
|
|
901
917
|
}
|
|
902
918
|
},
|
|
903
|
-
"
|
|
919
|
+
"close": {
|
|
904
920
|
"complexType": {
|
|
905
|
-
"signature": "(
|
|
906
|
-
"parameters": [
|
|
907
|
-
"name": "value",
|
|
908
|
-
"type": "string",
|
|
909
|
-
"docs": ""
|
|
910
|
-
}],
|
|
921
|
+
"signature": "() => Promise<void>",
|
|
922
|
+
"parameters": [],
|
|
911
923
|
"references": {
|
|
912
924
|
"Promise": {
|
|
913
925
|
"location": "global",
|
|
@@ -917,7 +929,7 @@ export class TdsDropdown {
|
|
|
917
929
|
"return": "Promise<void>"
|
|
918
930
|
},
|
|
919
931
|
"docs": {
|
|
920
|
-
"text": "",
|
|
932
|
+
"text": "Method for closing the Dropdown.",
|
|
921
933
|
"tags": []
|
|
922
934
|
}
|
|
923
935
|
}
|
|
@@ -926,9 +938,6 @@ export class TdsDropdown {
|
|
|
926
938
|
static get elementRef() { return "host"; }
|
|
927
939
|
static get watchers() {
|
|
928
940
|
return [{
|
|
929
|
-
"propName": "value",
|
|
930
|
-
"methodName": "handleValueChange"
|
|
931
|
-
}, {
|
|
932
941
|
"propName": "open",
|
|
933
942
|
"methodName": "handleOpenState"
|
|
934
943
|
}];
|