@scania/tegel 1.23.0-value-prop.beta.5 → 1.24.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-dropdown_2.cjs.entry.js +188 -136
- package/dist/cjs/tegel.cjs.js +1 -1
- package/dist/collection/components/dropdown/dropdown.js +239 -211
- package/dist/components/{p-98a2c82d.js → p-4f1aa84f.js} +193 -144
- package/dist/components/tds-dropdown.js +1 -1
- package/dist/components/tds-table-footer.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/tds-dropdown_2.entry.js +188 -136
- package/dist/esm/tegel.js +1 -1
- package/dist/tegel/{p-2dd309cb.entry.js → p-14f12f43.entry.js} +1 -1
- package/dist/tegel/tegel.esm.js +1 -1
- package/dist/types/components/dropdown/dropdown.d.ts +36 -26
- package/dist/types/components.d.ts +11 -21
- package/package.json +1 -1
|
@@ -9,13 +9,33 @@ export class TdsDropdown {
|
|
|
9
9
|
constructor() {
|
|
10
10
|
this.setDefaultOption = () => {
|
|
11
11
|
if (this.defaultValue) {
|
|
12
|
+
const children = Array.from(this.host.children).filter((element) => element.tagName === 'TDS-DROPDOWN-OPTION');
|
|
13
|
+
if (children.length === 0) {
|
|
14
|
+
console.warn('TDS DROPDOWN: No options found. Disregard if loading data asynchronously.');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
12
17
|
const defaultValues = this.multiselect
|
|
13
18
|
? new Set(this.defaultValue.split(','))
|
|
14
19
|
: [this.defaultValue];
|
|
15
|
-
const
|
|
16
|
-
|
|
20
|
+
const childrenMap = new Map(children.map((element) => [element.value, element]));
|
|
21
|
+
const matchedValues = Array.from(defaultValues).filter((value) => {
|
|
22
|
+
const element = childrenMap.get(value);
|
|
23
|
+
if (element) {
|
|
24
|
+
element.setSelected(true);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
});
|
|
29
|
+
if (matchedValues.length > 0) {
|
|
30
|
+
this.value = [...new Set(this.value ? [...this.value, ...matchedValues] : matchedValues)];
|
|
31
|
+
this.setValueAttribute();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.warn(`TDS DROPDOWN: No matching option found for defaultValue "${this.defaultValue}"`);
|
|
35
|
+
}
|
|
17
36
|
}
|
|
18
37
|
};
|
|
38
|
+
/* Returns a list of all children that are tds-dropdown-option elements */
|
|
19
39
|
this.getChildren = () => {
|
|
20
40
|
const tdsDropdownOptions = Array.from(this.host.children).filter((element) => element.tagName === 'TDS-DROPDOWN-OPTION');
|
|
21
41
|
if (tdsDropdownOptions.length === 0) {
|
|
@@ -24,36 +44,6 @@ export class TdsDropdown {
|
|
|
24
44
|
else
|
|
25
45
|
return tdsDropdownOptions;
|
|
26
46
|
};
|
|
27
|
-
this.getSelectedChildren = () => {
|
|
28
|
-
if (this.selectedOptions.length === 0)
|
|
29
|
-
return [];
|
|
30
|
-
return this.selectedOptions
|
|
31
|
-
.map((stringValue) => {
|
|
32
|
-
var _a;
|
|
33
|
-
const matchingElement = (_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.find((element) => element.value === stringValue);
|
|
34
|
-
return matchingElement;
|
|
35
|
-
})
|
|
36
|
-
.filter(Boolean);
|
|
37
|
-
};
|
|
38
|
-
this.getSelectedChildrenLabels = () => {
|
|
39
|
-
var _a;
|
|
40
|
-
return (_a = this.getSelectedChildren()) === null || _a === void 0 ? void 0 : _a.map((element) => element.textContent.trim());
|
|
41
|
-
};
|
|
42
|
-
this.getValue = () => {
|
|
43
|
-
const labels = this.getSelectedChildrenLabels();
|
|
44
|
-
if (!labels) {
|
|
45
|
-
return '';
|
|
46
|
-
}
|
|
47
|
-
return labels === null || labels === void 0 ? void 0 : labels.join(', ');
|
|
48
|
-
};
|
|
49
|
-
this.setValueAttribute = () => {
|
|
50
|
-
if (this.selectedOptions.length === 0) {
|
|
51
|
-
this.host.removeAttribute('value');
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
this.host.setAttribute('value', this.selectedOptions.join(','));
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
47
|
this.getOpenDirection = () => {
|
|
58
48
|
var _a, _b, _c, _d, _e;
|
|
59
49
|
if (this.openDirection === 'auto' || !this.openDirection) {
|
|
@@ -67,6 +57,7 @@ export class TdsDropdown {
|
|
|
67
57
|
}
|
|
68
58
|
return this.openDirection;
|
|
69
59
|
};
|
|
60
|
+
/* Toggles the open state of the Dropdown and sets focus to the input element */
|
|
70
61
|
this.handleToggleOpen = () => {
|
|
71
62
|
if (!this.disabled) {
|
|
72
63
|
this.open = !this.open;
|
|
@@ -75,10 +66,38 @@ export class TdsDropdown {
|
|
|
75
66
|
}
|
|
76
67
|
}
|
|
77
68
|
};
|
|
69
|
+
/* Focuses the input element in the Dropdown, if the reference is present. */
|
|
78
70
|
this.focusInputElement = () => {
|
|
79
71
|
if (this.inputElement)
|
|
80
72
|
this.inputElement.focus();
|
|
81
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
|
+
};
|
|
82
101
|
this.handleFilter = (event) => {
|
|
83
102
|
this.tdsInput.emit(event);
|
|
84
103
|
const query = event.target.value.toLowerCase();
|
|
@@ -109,10 +128,8 @@ export class TdsDropdown {
|
|
|
109
128
|
this.handleFilterReset = () => {
|
|
110
129
|
this.reset();
|
|
111
130
|
this.inputElement.value = '';
|
|
112
|
-
this.handleFilter({ target: { value:
|
|
131
|
+
this.handleFilter({ target: { value: this.inputElement.value } });
|
|
113
132
|
this.inputElement.focus();
|
|
114
|
-
// Add this line to ensure internal value is cleared
|
|
115
|
-
this.internalValue = '';
|
|
116
133
|
};
|
|
117
134
|
this.handleFocus = (event) => {
|
|
118
135
|
this.open = true;
|
|
@@ -126,6 +143,13 @@ export class TdsDropdown {
|
|
|
126
143
|
this.handleBlur = (event) => {
|
|
127
144
|
this.tdsBlur.emit(event);
|
|
128
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
|
+
};
|
|
129
153
|
this.resetInput = () => {
|
|
130
154
|
const inputEl = this.host.querySelector('input');
|
|
131
155
|
if (inputEl) {
|
|
@@ -148,99 +172,107 @@ export class TdsDropdown {
|
|
|
148
172
|
this.normalizeText = true;
|
|
149
173
|
this.noResultText = 'No result';
|
|
150
174
|
this.defaultValue = undefined;
|
|
151
|
-
this.value = null;
|
|
152
175
|
this.open = false;
|
|
153
|
-
this.
|
|
176
|
+
this.value = undefined;
|
|
154
177
|
this.filterResult = undefined;
|
|
155
178
|
this.filterFocus = undefined;
|
|
156
|
-
this.selectedOptions = [];
|
|
157
|
-
}
|
|
158
|
-
handleValueChange(newValue) {
|
|
159
|
-
// Normalize to array
|
|
160
|
-
const normalizedValue = this.normalizeValue(newValue);
|
|
161
|
-
// Only update if actually changed
|
|
162
|
-
if (this.hasValueChanged(normalizedValue, this.selectedOptions)) {
|
|
163
|
-
this.updateDropdownState(normalizedValue);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
normalizeValue(value) {
|
|
167
|
-
if (!value || value === '')
|
|
168
|
-
return []; // Handle both null and empty string
|
|
169
|
-
// For multiselect, keep array. For single select, wrap in array
|
|
170
|
-
if (this.multiselect) {
|
|
171
|
-
return Array.isArray(value) ? value : value.split(',').filter((v) => v !== '');
|
|
172
|
-
}
|
|
173
|
-
return Array.isArray(value) ? value : [value];
|
|
174
179
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
/** Method that resets the Dropdown, marks all children as non-selected and resets the value to null. */
|
|
181
|
+
async reset() {
|
|
182
|
+
this.dropdownList.scrollTop = 0;
|
|
183
|
+
this.internalReset();
|
|
184
|
+
this.handleChange();
|
|
179
185
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this.
|
|
183
|
-
|
|
184
|
-
this.value = this.multiselect ? this.selectedOptions : this.selectedOptions[0] || null;
|
|
185
|
-
// Update DOM
|
|
186
|
-
this.updateOptionElements();
|
|
187
|
-
// Update display value
|
|
188
|
-
this.updateDisplayValue();
|
|
189
|
-
// Emit change event
|
|
190
|
-
this.emitChange();
|
|
191
|
-
// Update value attribute
|
|
192
|
-
this.setValueAttribute();
|
|
186
|
+
/** Method that forces focus on the input element. */
|
|
187
|
+
async focusElement() {
|
|
188
|
+
this.focusInputElement();
|
|
189
|
+
this.handleFocus({});
|
|
193
190
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
/** Method for setting the value of the Dropdown.
|
|
192
|
+
*
|
|
193
|
+
* Single selection example:
|
|
194
|
+
*
|
|
195
|
+
* <code>
|
|
196
|
+
* dropdown.setValue('option-1', 'Option 1');
|
|
197
|
+
* </code>
|
|
198
|
+
*
|
|
199
|
+
* Multiselect example:
|
|
200
|
+
*
|
|
201
|
+
* <code>
|
|
202
|
+
* dropdown.setValue(['option-1', 'option-2']);
|
|
203
|
+
* </code>
|
|
204
|
+
*/
|
|
205
|
+
// The label is optional here ONLY to not break the API. Should be removed for 2.0.
|
|
206
|
+
// @ts-ignore
|
|
207
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
208
|
+
async setValue(value, label) {
|
|
209
|
+
let nextValue;
|
|
210
|
+
if (typeof value === 'string')
|
|
211
|
+
nextValue = [value];
|
|
212
|
+
else
|
|
213
|
+
nextValue = value;
|
|
214
|
+
if (!this.multiselect && nextValue.length > 1) {
|
|
215
|
+
console.warn('Tried to select multiple items, but multiselect is not enabled.');
|
|
216
|
+
nextValue = [nextValue[0]];
|
|
217
|
+
}
|
|
218
|
+
nextValue = [...new Set(nextValue)];
|
|
219
|
+
this.internalReset();
|
|
220
|
+
for (let i = 0; i < nextValue.length; i++) {
|
|
221
|
+
const optionExist = this.getChildren().some((element) => element.value === nextValue[i]);
|
|
222
|
+
if (!optionExist) {
|
|
223
|
+
nextValue.splice(i, 1);
|
|
200
224
|
}
|
|
201
|
-
return isValid;
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
updateOptionElements() {
|
|
205
|
-
var _a;
|
|
206
|
-
(_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
|
|
207
|
-
element.setSelected(this.selectedOptions.includes(element.value));
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
updateDisplayValue() {
|
|
211
|
-
this.internalValue = this.getSelectedChildrenLabels().join(', ');
|
|
212
|
-
if (this.filter && this.inputElement) {
|
|
213
|
-
this.inputElement.value = this.internalValue;
|
|
214
225
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
value: value !== null && value !== void 0 ? value : null,
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
async setValue(value) {
|
|
226
|
-
const normalizedValue = this.normalizeValue(value);
|
|
227
|
-
this.updateDropdownState(normalizedValue);
|
|
228
|
-
return this.getSelectedChildren().map((element) => ({
|
|
226
|
+
this.value = nextValue;
|
|
227
|
+
this.setValueAttribute();
|
|
228
|
+
this.selectChildrenAsSelectedBasedOnSelectionProp();
|
|
229
|
+
this.handleChange();
|
|
230
|
+
/* 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. */
|
|
231
|
+
/* https://tegel.atlassian.net/browse/CDEP-2703 */
|
|
232
|
+
const selection = this.getSelectedChildren().map((element) => ({
|
|
229
233
|
value: element.value,
|
|
230
234
|
label: element.textContent.trim(),
|
|
231
235
|
}));
|
|
236
|
+
// Update inputElement value and placeholder text
|
|
237
|
+
if (this.filter) {
|
|
238
|
+
this.inputElement.value = this.getValue();
|
|
239
|
+
}
|
|
240
|
+
return selection;
|
|
232
241
|
}
|
|
233
|
-
|
|
234
|
-
|
|
242
|
+
/**
|
|
243
|
+
* @internal
|
|
244
|
+
*/
|
|
245
|
+
async appendValue(value) {
|
|
246
|
+
if (this.multiselect && this.value) {
|
|
247
|
+
this.setValue([...this.value, value]);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this.setValue(value);
|
|
251
|
+
}
|
|
235
252
|
}
|
|
253
|
+
/** Method for removing a selected value in the Dropdown. */
|
|
236
254
|
async removeValue(oldValue) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
255
|
+
var _a, _b;
|
|
256
|
+
let label;
|
|
257
|
+
if (this.multiselect) {
|
|
258
|
+
(_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
|
|
259
|
+
var _a;
|
|
260
|
+
if (element.value === oldValue) {
|
|
261
|
+
this.value = (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter((value) => value !== element.value);
|
|
262
|
+
label = element.textContent.trim();
|
|
263
|
+
element.setSelected(false);
|
|
264
|
+
}
|
|
265
|
+
return element;
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
this.reset();
|
|
270
|
+
}
|
|
271
|
+
this.handleChange();
|
|
272
|
+
this.setValueAttribute();
|
|
273
|
+
/* 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. */
|
|
274
|
+
/* https://tegel.atlassian.net/browse/CDEP-2703 */
|
|
275
|
+
return (_b = this.value) === null || _b === void 0 ? void 0 : _b.map((value) => ({ value, label }));
|
|
244
276
|
}
|
|
245
277
|
/** Method for closing the Dropdown. */
|
|
246
278
|
async close() {
|
|
@@ -289,15 +321,12 @@ export class TdsDropdown {
|
|
|
289
321
|
handleOpenState() {
|
|
290
322
|
if (this.filter && this.multiselect) {
|
|
291
323
|
if (!this.open) {
|
|
292
|
-
this.inputElement.value = this.
|
|
324
|
+
this.inputElement.value = this.getValue();
|
|
293
325
|
}
|
|
294
326
|
}
|
|
295
327
|
}
|
|
296
328
|
componentWillLoad() {
|
|
297
|
-
|
|
298
|
-
const initialValue = this.multiselect ? this.defaultValue.split(',') : [this.defaultValue];
|
|
299
|
-
this.updateDropdownState(initialValue);
|
|
300
|
-
}
|
|
329
|
+
this.setDefaultOption();
|
|
301
330
|
}
|
|
302
331
|
/** Method to handle slot changes */
|
|
303
332
|
handleSlotChange() {
|
|
@@ -307,13 +336,29 @@ export class TdsDropdown {
|
|
|
307
336
|
normalizeString(text) {
|
|
308
337
|
return this.normalizeText ? text.normalize('NFD').replace(/\p{Diacritic}/gu, '') : text;
|
|
309
338
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
339
|
+
/** Method that resets the dropdown without emitting an event. */
|
|
340
|
+
internalReset() {
|
|
341
|
+
this.getChildren().forEach((element) => {
|
|
342
|
+
element.setSelected(false);
|
|
343
|
+
return element;
|
|
344
|
+
});
|
|
345
|
+
this.value = null;
|
|
346
|
+
this.setValueAttribute();
|
|
347
|
+
}
|
|
348
|
+
selectChildrenAsSelectedBasedOnSelectionProp() {
|
|
349
|
+
this.getChildren().forEach((element) => {
|
|
350
|
+
this.value.forEach((selection) => {
|
|
351
|
+
if (element.value !== selection) {
|
|
352
|
+
// If not multiselect, we need to unselect all other options.
|
|
353
|
+
if (!this.multiselect) {
|
|
354
|
+
element.setSelected(false);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
element.setSelected(true);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
317
362
|
}
|
|
318
363
|
componentDidRender() {
|
|
319
364
|
const form = this.host.closest('form');
|
|
@@ -328,8 +373,9 @@ export class TdsDropdown {
|
|
|
328
373
|
}
|
|
329
374
|
}
|
|
330
375
|
render() {
|
|
331
|
-
|
|
332
|
-
|
|
376
|
+
var _a, _b, _c, _d;
|
|
377
|
+
appendHiddenInput(this.host, this.name, (_a = this.value) === null || _a === void 0 ? void 0 : _a.map((value) => value).toString(), this.disabled);
|
|
378
|
+
return (h(Host, { key: 'b452aebe0997ce114fff5c7527d7305e97bf6462', role: "select", class: `${this.modeVariant ? `tds-mode-variant-${this.modeVariant}` : ''}` }, this.label && this.labelPosition === 'outside' && (h("div", { key: '356273d3065daebba4d72a7f30f745dab1eb803e', class: `label-outside ${this.disabled ? 'disabled' : ''}` }, this.label)), h("div", { key: 'c8b617da62a01e0432fee90c243723edde5fecca', class: `dropdown-select ${this.size} ${this.disabled ? 'disabled' : ''}` }, this.filter ? (h("div", { class: {
|
|
333
379
|
filter: true,
|
|
334
380
|
focus: this.filterFocus,
|
|
335
381
|
disabled: this.disabled,
|
|
@@ -337,7 +383,7 @@ export class TdsDropdown {
|
|
|
337
383
|
} }, 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: `
|
|
338
384
|
label-inside-as-placeholder
|
|
339
385
|
${this.size}
|
|
340
|
-
${this.
|
|
386
|
+
${((_b = this.value) === null || _b === void 0 ? void 0 : _b.length) ? 'selected' : ''}
|
|
341
387
|
` }, this.label)), h("input", {
|
|
342
388
|
// eslint-disable-next-line no-return-assign
|
|
343
389
|
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) => {
|
|
@@ -346,7 +392,15 @@ export class TdsDropdown {
|
|
|
346
392
|
this.inputElement.value = this.getValue();
|
|
347
393
|
}
|
|
348
394
|
this.handleBlur(event);
|
|
349
|
-
}, onFocus: (event) =>
|
|
395
|
+
}, onFocus: (event) => {
|
|
396
|
+
this.open = true;
|
|
397
|
+
this.filterFocus = true;
|
|
398
|
+
if (this.multiselect) {
|
|
399
|
+
this.inputElement.value = '';
|
|
400
|
+
}
|
|
401
|
+
this.handleFocus(event);
|
|
402
|
+
this.handleFilter({ target: { value: '' } });
|
|
403
|
+
}, onKeyDown: (event) => {
|
|
350
404
|
if (event.key === 'Escape') {
|
|
351
405
|
this.open = false;
|
|
352
406
|
}
|
|
@@ -364,14 +418,14 @@ export class TdsDropdown {
|
|
|
364
418
|
this.open = false;
|
|
365
419
|
}
|
|
366
420
|
}, class: `
|
|
367
|
-
${this.
|
|
421
|
+
${this.value ? 'value' : 'placeholder'}
|
|
368
422
|
${this.open ? 'open' : 'closed'}
|
|
369
423
|
${this.error ? 'error' : ''}
|
|
370
424
|
`, 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: `
|
|
371
425
|
label-inside-as-placeholder
|
|
372
426
|
${this.size}
|
|
373
|
-
${this.
|
|
374
|
-
` }, this.label)), h("div", { class: `placeholder ${this.size}` }, this.
|
|
427
|
+
${((_c = this.value) === null || _c === void 0 ? void 0 : _c.length) ? 'selected' : ''}
|
|
428
|
+
` }, 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: 'bd702f67929bfd42350b11a9680e007dd74e4bad', ref: (element) => (this.dropdownList = element), class: {
|
|
375
429
|
'dropdown-list': true,
|
|
376
430
|
[this.size]: true,
|
|
377
431
|
[this.getOpenDirection()]: true,
|
|
@@ -380,7 +434,7 @@ export class TdsDropdown {
|
|
|
380
434
|
'closed': !this.open,
|
|
381
435
|
[`animation-enter-${this.animation}`]: this.animation !== 'none' && this.open,
|
|
382
436
|
[`animation-exit-${this.animation}`]: this.animation !== 'none' && !this.open,
|
|
383
|
-
} }, h("slot", { key: '
|
|
437
|
+
} }, h("slot", { key: '64c67c8aa6aa68089c59de1fdedb915ea4beb3af', onSlotchange: () => this.handleSlotChange() }), this.filterResult === 0 && this.noResultText !== '' && (h("div", { key: '2152a99732579e2c2f7e82d450743e67d8b9f263', class: `no-result ${this.size}` }, this.noResultText))), this.helper && (h("div", { key: 'fbc4ebc39a4ca4fc49a77ea1160042ad1de005ec', class: `helper ${this.error ? 'error' : ''} ${this.disabled ? 'disabled' : ''}` }, this.error && h("tds-icon", { key: '318107cbe939b82250bb97bfbceae4017e438ba1', name: "error", size: "16px" }), this.helper))));
|
|
384
438
|
}
|
|
385
439
|
static get is() { return "tds-dropdown"; }
|
|
386
440
|
static get encapsulation() { return "shadow"; }
|
|
@@ -677,34 +731,15 @@ export class TdsDropdown {
|
|
|
677
731
|
},
|
|
678
732
|
"attribute": "default-value",
|
|
679
733
|
"reflect": false
|
|
680
|
-
},
|
|
681
|
-
"value": {
|
|
682
|
-
"type": "string",
|
|
683
|
-
"mutable": true,
|
|
684
|
-
"complexType": {
|
|
685
|
-
"original": "string | string[]",
|
|
686
|
-
"resolved": "string | string[]",
|
|
687
|
-
"references": {}
|
|
688
|
-
},
|
|
689
|
-
"required": false,
|
|
690
|
-
"optional": false,
|
|
691
|
-
"docs": {
|
|
692
|
-
"tags": [],
|
|
693
|
-
"text": "Value of the dropdown. For multiselect, provide array of strings. For single select, provide a string."
|
|
694
|
-
},
|
|
695
|
-
"attribute": "value",
|
|
696
|
-
"reflect": false,
|
|
697
|
-
"defaultValue": "null"
|
|
698
734
|
}
|
|
699
735
|
};
|
|
700
736
|
}
|
|
701
737
|
static get states() {
|
|
702
738
|
return {
|
|
703
739
|
"open": {},
|
|
704
|
-
"
|
|
740
|
+
"value": {},
|
|
705
741
|
"filterResult": {},
|
|
706
|
-
"filterFocus": {}
|
|
707
|
-
"selectedOptions": {}
|
|
742
|
+
"filterFocus": {}
|
|
708
743
|
};
|
|
709
744
|
}
|
|
710
745
|
static get events() {
|
|
@@ -783,51 +818,28 @@ export class TdsDropdown {
|
|
|
783
818
|
}
|
|
784
819
|
}
|
|
785
820
|
}
|
|
786
|
-
}, {
|
|
787
|
-
"method": "tdsValueChange",
|
|
788
|
-
"name": "tdsValueChange",
|
|
789
|
-
"bubbles": true,
|
|
790
|
-
"cancelable": false,
|
|
791
|
-
"composed": true,
|
|
792
|
-
"docs": {
|
|
793
|
-
"tags": [],
|
|
794
|
-
"text": "Value change event for the Dropdown."
|
|
795
|
-
},
|
|
796
|
-
"complexType": {
|
|
797
|
-
"original": "{\n name: string;\n value: string;\n }",
|
|
798
|
-
"resolved": "{ name: string; value: string; }",
|
|
799
|
-
"references": {}
|
|
800
|
-
}
|
|
801
821
|
}];
|
|
802
822
|
}
|
|
803
823
|
static get methods() {
|
|
804
824
|
return {
|
|
805
|
-
"
|
|
825
|
+
"reset": {
|
|
806
826
|
"complexType": {
|
|
807
|
-
"signature": "(
|
|
808
|
-
"parameters": [
|
|
809
|
-
"name": "value",
|
|
810
|
-
"type": "string | string[]",
|
|
811
|
-
"docs": ""
|
|
812
|
-
}],
|
|
827
|
+
"signature": "() => Promise<void>",
|
|
828
|
+
"parameters": [],
|
|
813
829
|
"references": {
|
|
814
830
|
"Promise": {
|
|
815
831
|
"location": "global",
|
|
816
832
|
"id": "global::Promise"
|
|
817
|
-
},
|
|
818
|
-
"HTMLTdsDropdownOptionElement": {
|
|
819
|
-
"location": "global",
|
|
820
|
-
"id": "global::HTMLTdsDropdownOptionElement"
|
|
821
833
|
}
|
|
822
834
|
},
|
|
823
|
-
"return": "Promise<
|
|
835
|
+
"return": "Promise<void>"
|
|
824
836
|
},
|
|
825
837
|
"docs": {
|
|
826
|
-
"text": "",
|
|
838
|
+
"text": "Method that resets the Dropdown, marks all children as non-selected and resets the value to null.",
|
|
827
839
|
"tags": []
|
|
828
840
|
}
|
|
829
841
|
},
|
|
830
|
-
"
|
|
842
|
+
"focusElement": {
|
|
831
843
|
"complexType": {
|
|
832
844
|
"signature": "() => Promise<void>",
|
|
833
845
|
"parameters": [],
|
|
@@ -840,15 +852,19 @@ export class TdsDropdown {
|
|
|
840
852
|
"return": "Promise<void>"
|
|
841
853
|
},
|
|
842
854
|
"docs": {
|
|
843
|
-
"text": "",
|
|
855
|
+
"text": "Method that forces focus on the input element.",
|
|
844
856
|
"tags": []
|
|
845
857
|
}
|
|
846
858
|
},
|
|
847
|
-
"
|
|
859
|
+
"setValue": {
|
|
848
860
|
"complexType": {
|
|
849
|
-
"signature": "(
|
|
861
|
+
"signature": "(value: string | string[], label?: string) => Promise<{ value: string; label: string; }[]>",
|
|
850
862
|
"parameters": [{
|
|
851
|
-
"name": "
|
|
863
|
+
"name": "value",
|
|
864
|
+
"type": "string | string[]",
|
|
865
|
+
"docs": ""
|
|
866
|
+
}, {
|
|
867
|
+
"name": "label",
|
|
852
868
|
"type": "string",
|
|
853
869
|
"docs": ""
|
|
854
870
|
}],
|
|
@@ -856,19 +872,27 @@ export class TdsDropdown {
|
|
|
856
872
|
"Promise": {
|
|
857
873
|
"location": "global",
|
|
858
874
|
"id": "global::Promise"
|
|
875
|
+
},
|
|
876
|
+
"HTMLTdsDropdownOptionElement": {
|
|
877
|
+
"location": "global",
|
|
878
|
+
"id": "global::HTMLTdsDropdownOptionElement"
|
|
859
879
|
}
|
|
860
880
|
},
|
|
861
|
-
"return": "Promise<
|
|
881
|
+
"return": "Promise<{ value: string; label: string; }[]>"
|
|
862
882
|
},
|
|
863
883
|
"docs": {
|
|
864
|
-
"text": "",
|
|
884
|
+
"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>",
|
|
865
885
|
"tags": []
|
|
866
886
|
}
|
|
867
887
|
},
|
|
868
|
-
"
|
|
888
|
+
"appendValue": {
|
|
869
889
|
"complexType": {
|
|
870
|
-
"signature": "() => Promise<void>",
|
|
871
|
-
"parameters": [
|
|
890
|
+
"signature": "(value: string) => Promise<void>",
|
|
891
|
+
"parameters": [{
|
|
892
|
+
"name": "value",
|
|
893
|
+
"type": "string",
|
|
894
|
+
"docs": ""
|
|
895
|
+
}],
|
|
872
896
|
"references": {
|
|
873
897
|
"Promise": {
|
|
874
898
|
"location": "global",
|
|
@@ -878,35 +902,42 @@ export class TdsDropdown {
|
|
|
878
902
|
"return": "Promise<void>"
|
|
879
903
|
},
|
|
880
904
|
"docs": {
|
|
881
|
-
"text": "
|
|
882
|
-
"tags": [
|
|
905
|
+
"text": "",
|
|
906
|
+
"tags": [{
|
|
907
|
+
"name": "internal",
|
|
908
|
+
"text": undefined
|
|
909
|
+
}]
|
|
883
910
|
}
|
|
884
911
|
},
|
|
885
|
-
"
|
|
912
|
+
"removeValue": {
|
|
886
913
|
"complexType": {
|
|
887
|
-
"signature": "() => Promise<
|
|
888
|
-
"parameters": [
|
|
914
|
+
"signature": "(oldValue: string) => Promise<{ value: string; label: string; }[]>",
|
|
915
|
+
"parameters": [{
|
|
916
|
+
"name": "oldValue",
|
|
917
|
+
"type": "string",
|
|
918
|
+
"docs": ""
|
|
919
|
+
}],
|
|
889
920
|
"references": {
|
|
890
921
|
"Promise": {
|
|
891
922
|
"location": "global",
|
|
892
923
|
"id": "global::Promise"
|
|
924
|
+
},
|
|
925
|
+
"HTMLTdsDropdownOptionElement": {
|
|
926
|
+
"location": "global",
|
|
927
|
+
"id": "global::HTMLTdsDropdownOptionElement"
|
|
893
928
|
}
|
|
894
929
|
},
|
|
895
|
-
"return": "Promise<
|
|
930
|
+
"return": "Promise<{ value: string; label: string; }[]>"
|
|
896
931
|
},
|
|
897
932
|
"docs": {
|
|
898
|
-
"text": "Method for
|
|
933
|
+
"text": "Method for removing a selected value in the Dropdown.",
|
|
899
934
|
"tags": []
|
|
900
935
|
}
|
|
901
936
|
},
|
|
902
|
-
"
|
|
937
|
+
"close": {
|
|
903
938
|
"complexType": {
|
|
904
|
-
"signature": "(
|
|
905
|
-
"parameters": [
|
|
906
|
-
"name": "value",
|
|
907
|
-
"type": "string",
|
|
908
|
-
"docs": ""
|
|
909
|
-
}],
|
|
939
|
+
"signature": "() => Promise<void>",
|
|
940
|
+
"parameters": [],
|
|
910
941
|
"references": {
|
|
911
942
|
"Promise": {
|
|
912
943
|
"location": "global",
|
|
@@ -916,7 +947,7 @@ export class TdsDropdown {
|
|
|
916
947
|
"return": "Promise<void>"
|
|
917
948
|
},
|
|
918
949
|
"docs": {
|
|
919
|
-
"text": "",
|
|
950
|
+
"text": "Method for closing the Dropdown.",
|
|
920
951
|
"tags": []
|
|
921
952
|
}
|
|
922
953
|
}
|
|
@@ -925,9 +956,6 @@ export class TdsDropdown {
|
|
|
925
956
|
static get elementRef() { return "host"; }
|
|
926
957
|
static get watchers() {
|
|
927
958
|
return [{
|
|
928
|
-
"propName": "value",
|
|
929
|
-
"methodName": "handleValueChange"
|
|
930
|
-
}, {
|
|
931
959
|
"propName": "open",
|
|
932
960
|
"methodName": "handleOpenState"
|
|
933
961
|
}];
|