@scania/tegel 1.24.0-fix-CDEP-264-button-allow-boolean-props-beta.0 → 1.24.0-value-prop.beta.6

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.
@@ -9,33 +9,13 @@ 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
- }
17
12
  const defaultValues = this.multiselect
18
13
  ? new Set(this.defaultValue.split(','))
19
14
  : [this.defaultValue];
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
- }
15
+ const normalizedValues = Array.from(defaultValues);
16
+ this.updateDropdownState(normalizedValues);
36
17
  }
37
18
  };
38
- /* Returns a list of all children that are tds-dropdown-option elements */
39
19
  this.getChildren = () => {
40
20
  const tdsDropdownOptions = Array.from(this.host.children).filter((element) => element.tagName === 'TDS-DROPDOWN-OPTION');
41
21
  if (tdsDropdownOptions.length === 0) {
@@ -44,6 +24,36 @@ export class TdsDropdown {
44
24
  else
45
25
  return tdsDropdownOptions;
46
26
  };
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
+ };
47
57
  this.getOpenDirection = () => {
48
58
  var _a, _b, _c, _d, _e;
49
59
  if (this.openDirection === 'auto' || !this.openDirection) {
@@ -57,7 +67,6 @@ export class TdsDropdown {
57
67
  }
58
68
  return this.openDirection;
59
69
  };
60
- /* Toggles the open state of the Dropdown and sets focus to the input element */
61
70
  this.handleToggleOpen = () => {
62
71
  if (!this.disabled) {
63
72
  this.open = !this.open;
@@ -66,38 +75,10 @@ export class TdsDropdown {
66
75
  }
67
76
  }
68
77
  };
69
- /* Focuses the input element in the Dropdown, if the reference is present. */
70
78
  this.focusInputElement = () => {
71
79
  if (this.inputElement)
72
80
  this.inputElement.focus();
73
81
  };
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
- };
101
82
  this.handleFilter = (event) => {
102
83
  this.tdsInput.emit(event);
103
84
  const query = event.target.value.toLowerCase();
@@ -128,8 +109,10 @@ export class TdsDropdown {
128
109
  this.handleFilterReset = () => {
129
110
  this.reset();
130
111
  this.inputElement.value = '';
131
- this.handleFilter({ target: { value: this.inputElement.value } });
112
+ this.handleFilter({ target: { value: '' } });
132
113
  this.inputElement.focus();
114
+ // Add this line to ensure internal value is cleared
115
+ this.internalValue = '';
133
116
  };
134
117
  this.handleFocus = (event) => {
135
118
  this.open = true;
@@ -143,13 +126,6 @@ export class TdsDropdown {
143
126
  this.handleBlur = (event) => {
144
127
  this.tdsBlur.emit(event);
145
128
  };
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
- };
153
129
  this.resetInput = () => {
154
130
  const inputEl = this.host.querySelector('input');
155
131
  if (inputEl) {
@@ -172,107 +148,101 @@ export class TdsDropdown {
172
148
  this.normalizeText = true;
173
149
  this.noResultText = 'No result';
174
150
  this.defaultValue = undefined;
151
+ this.value = null;
175
152
  this.open = false;
176
- this.value = undefined;
153
+ this.internalValue = undefined;
177
154
  this.filterResult = undefined;
178
155
  this.filterFocus = undefined;
156
+ this.selectedOptions = [];
179
157
  }
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();
185
- }
186
- /** Method that forces focus on the input element. */
187
- async focusElement() {
188
- this.focusInputElement();
189
- this.handleFocus({});
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
+ }
190
165
  }
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]];
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 !== '');
217
172
  }
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);
173
+ return Array.isArray(value) ? value : [value];
174
+ }
175
+ hasValueChanged(newValue, currentValue) {
176
+ if (newValue.length !== currentValue.length)
177
+ return true;
178
+ return newValue.some((val) => !currentValue.includes(val));
179
+ }
180
+ updateDropdownState(values) {
181
+ // Update internal state
182
+ this.selectedOptions = [...this.validateValues(values)]; // Force new array reference
183
+ // Then update the value prop to match
184
+ this.value = this.multiselect ? this.selectedOptions : this.selectedOptions[0] || null;
185
+ // Force update of internal value
186
+ this.internalValue = this.getValue();
187
+ // Update DOM
188
+ this.updateOptionElements();
189
+ // Update display value
190
+ this.updateDisplayValue();
191
+ // Emit change event
192
+ this.emitChange();
193
+ // Update value attribute
194
+ this.setValueAttribute();
195
+ }
196
+ validateValues(values) {
197
+ return values.filter((val) => {
198
+ var _a;
199
+ const isValid = (_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.some((element) => element.value === val);
200
+ if (!isValid) {
201
+ console.warn(`Option with value "${val}" does not exist`);
224
202
  }
203
+ return isValid;
204
+ });
205
+ }
206
+ updateOptionElements() {
207
+ var _a;
208
+ (_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
209
+ element.setSelected(this.selectedOptions.includes(element.value));
210
+ });
211
+ }
212
+ updateDisplayValue() {
213
+ this.internalValue = this.getSelectedChildrenLabels().join(', ');
214
+ if (this.filter && this.inputElement) {
215
+ this.inputElement.value = this.internalValue;
225
216
  }
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) => ({
217
+ }
218
+ emitChange() {
219
+ const value = this.multiselect
220
+ ? this.selectedOptions.join(',')
221
+ : this.selectedOptions[0] || null;
222
+ this.tdsChange.emit({
223
+ name: this.name,
224
+ value: value !== null && value !== void 0 ? value : null,
225
+ });
226
+ }
227
+ async setValue(value) {
228
+ const normalizedValue = this.normalizeValue(value);
229
+ this.updateDropdownState(normalizedValue);
230
+ return this.getSelectedChildren().map((element) => ({
233
231
  value: element.value,
234
232
  label: element.textContent.trim(),
235
233
  }));
236
- // Update inputElement value and placeholder text
237
- if (this.filter) {
238
- this.inputElement.value = this.getValue();
239
- }
240
- return selection;
241
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
+ async reset() {
236
+ this.updateDropdownState([]);
252
237
  }
253
- /** Method for removing a selected value in the Dropdown. */
254
238
  async removeValue(oldValue) {
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 }));
239
+ const newValues = this.selectedOptions.filter((v) => v !== oldValue);
240
+ this.updateDropdownState(newValues);
241
+ }
242
+ /** Method that forces focus on the input element. */
243
+ async focusElement() {
244
+ this.focusInputElement();
245
+ this.handleFocus({});
276
246
  }
277
247
  /** Method for closing the Dropdown. */
278
248
  async close() {
@@ -321,12 +291,15 @@ export class TdsDropdown {
321
291
  handleOpenState() {
322
292
  if (this.filter && this.multiselect) {
323
293
  if (!this.open) {
324
- this.inputElement.value = this.getValue();
294
+ this.inputElement.value = this.selectedOptions.length ? this.getValue() : '';
325
295
  }
326
296
  }
327
297
  }
328
298
  componentWillLoad() {
329
- this.setDefaultOption();
299
+ if (this.defaultValue && !this.value) {
300
+ const initialValue = this.multiselect ? this.defaultValue.split(',') : [this.defaultValue];
301
+ this.updateDropdownState(initialValue);
302
+ }
330
303
  }
331
304
  /** Method to handle slot changes */
332
305
  handleSlotChange() {
@@ -336,29 +309,13 @@ export class TdsDropdown {
336
309
  normalizeString(text) {
337
310
  return this.normalizeText ? text.normalize('NFD').replace(/\p{Diacritic}/gu, '') : text;
338
311
  }
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
- });
312
+ async appendValue(value) {
313
+ if (this.multiselect) {
314
+ this.updateDropdownState([...this.selectedOptions, value]);
315
+ }
316
+ else {
317
+ this.updateDropdownState([value]);
318
+ }
362
319
  }
363
320
  componentDidRender() {
364
321
  const form = this.host.closest('form');
@@ -373,9 +330,8 @@ export class TdsDropdown {
373
330
  }
374
331
  }
375
332
  render() {
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
+ appendHiddenInput(this.host, this.name, this.selectedOptions.join(','), this.disabled);
334
+ return (h(Host, { key: 'e61969b03dc211a0007166d7319285cc50207910', role: "select", class: `${this.modeVariant ? `tds-mode-variant-${this.modeVariant}` : ''}` }, this.label && this.labelPosition === 'outside' && (h("div", { key: 'd97ce5d02635b30698564226be8c55b477f42de5', class: `label-outside ${this.disabled ? 'disabled' : ''}` }, this.label)), h("div", { key: '29099efd6d106a5c6013ac83a545c290bb1d0af7', class: `dropdown-select ${this.size} ${this.disabled ? 'disabled' : ''}` }, this.filter ? (h("div", { class: {
379
335
  filter: true,
380
336
  focus: this.filterFocus,
381
337
  disabled: this.disabled,
@@ -383,7 +339,7 @@ export class TdsDropdown {
383
339
  } }, 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: `
384
340
  label-inside-as-placeholder
385
341
  ${this.size}
386
- ${((_b = this.value) === null || _b === void 0 ? void 0 : _b.length) ? 'selected' : ''}
342
+ ${this.selectedOptions.length ? 'selected' : ''}
387
343
  ` }, this.label)), h("input", {
388
344
  // eslint-disable-next-line no-return-assign
389
345
  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) => {
@@ -392,15 +348,7 @@ export class TdsDropdown {
392
348
  this.inputElement.value = this.getValue();
393
349
  }
394
350
  this.handleBlur(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) => {
351
+ }, onFocus: (event) => this.handleFocus(event), onKeyDown: (event) => {
404
352
  if (event.key === 'Escape') {
405
353
  this.open = false;
406
354
  }
@@ -418,14 +366,14 @@ export class TdsDropdown {
418
366
  this.open = false;
419
367
  }
420
368
  }, class: `
421
- ${this.value ? 'value' : 'placeholder'}
369
+ ${this.selectedOptions.length ? 'value' : 'placeholder'}
422
370
  ${this.open ? 'open' : 'closed'}
423
371
  ${this.error ? 'error' : ''}
424
372
  `, 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: `
425
373
  label-inside-as-placeholder
426
374
  ${this.size}
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
+ ${this.selectedOptions.length ? 'selected' : ''}
376
+ ` }, this.label)), h("div", { class: `placeholder ${this.size}` }, this.selectedOptions.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: '04cf1b3b829f482b189a59fb5fd8f9c3932b4982', ref: (element) => (this.dropdownList = element), class: {
429
377
  'dropdown-list': true,
430
378
  [this.size]: true,
431
379
  [this.getOpenDirection()]: true,
@@ -434,7 +382,7 @@ export class TdsDropdown {
434
382
  'closed': !this.open,
435
383
  [`animation-enter-${this.animation}`]: this.animation !== 'none' && this.open,
436
384
  [`animation-exit-${this.animation}`]: this.animation !== 'none' && !this.open,
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))));
385
+ } }, h("slot", { key: '3dce31c592336d9b5c2e8e5fa25a0a8ff23694d3', onSlotchange: () => this.handleSlotChange() }), this.filterResult === 0 && this.noResultText !== '' && (h("div", { key: '7f1e8b0d7fff2f09412f389507ff7c2f2430a70b', class: `no-result ${this.size}` }, this.noResultText))), this.helper && (h("div", { key: '0c728acc0d233f674ad7bc394176aa89b01ee66d', class: `helper ${this.error ? 'error' : ''} ${this.disabled ? 'disabled' : ''}` }, this.error && h("tds-icon", { key: '65691c3c11f4b6c908028475c03d1f4b6f35ce74', name: "error", size: "16px" }), this.helper))));
438
386
  }
439
387
  static get is() { return "tds-dropdown"; }
440
388
  static get encapsulation() { return "shadow"; }
@@ -731,15 +679,34 @@ export class TdsDropdown {
731
679
  },
732
680
  "attribute": "default-value",
733
681
  "reflect": false
682
+ },
683
+ "value": {
684
+ "type": "string",
685
+ "mutable": true,
686
+ "complexType": {
687
+ "original": "string | string[]",
688
+ "resolved": "string | string[]",
689
+ "references": {}
690
+ },
691
+ "required": false,
692
+ "optional": false,
693
+ "docs": {
694
+ "tags": [],
695
+ "text": "Value of the dropdown. For multiselect, provide array of strings. For single select, provide a string."
696
+ },
697
+ "attribute": "value",
698
+ "reflect": false,
699
+ "defaultValue": "null"
734
700
  }
735
701
  };
736
702
  }
737
703
  static get states() {
738
704
  return {
739
705
  "open": {},
740
- "value": {},
706
+ "internalValue": {},
741
707
  "filterResult": {},
742
- "filterFocus": {}
708
+ "filterFocus": {},
709
+ "selectedOptions": {}
743
710
  };
744
711
  }
745
712
  static get events() {
@@ -818,28 +785,51 @@ export class TdsDropdown {
818
785
  }
819
786
  }
820
787
  }
788
+ }, {
789
+ "method": "tdsValueChange",
790
+ "name": "tdsValueChange",
791
+ "bubbles": true,
792
+ "cancelable": false,
793
+ "composed": true,
794
+ "docs": {
795
+ "tags": [],
796
+ "text": "Value change event for the Dropdown."
797
+ },
798
+ "complexType": {
799
+ "original": "{\n name: string;\n value: string;\n }",
800
+ "resolved": "{ name: string; value: string; }",
801
+ "references": {}
802
+ }
821
803
  }];
822
804
  }
823
805
  static get methods() {
824
806
  return {
825
- "reset": {
807
+ "setValue": {
826
808
  "complexType": {
827
- "signature": "() => Promise<void>",
828
- "parameters": [],
809
+ "signature": "(value: string | string[]) => Promise<{ value: string; label: string; }[]>",
810
+ "parameters": [{
811
+ "name": "value",
812
+ "type": "string | string[]",
813
+ "docs": ""
814
+ }],
829
815
  "references": {
830
816
  "Promise": {
831
817
  "location": "global",
832
818
  "id": "global::Promise"
819
+ },
820
+ "HTMLTdsDropdownOptionElement": {
821
+ "location": "global",
822
+ "id": "global::HTMLTdsDropdownOptionElement"
833
823
  }
834
824
  },
835
- "return": "Promise<void>"
825
+ "return": "Promise<{ value: string; label: string; }[]>"
836
826
  },
837
827
  "docs": {
838
- "text": "Method that resets the Dropdown, marks all children as non-selected and resets the value to null.",
828
+ "text": "",
839
829
  "tags": []
840
830
  }
841
831
  },
842
- "focusElement": {
832
+ "reset": {
843
833
  "complexType": {
844
834
  "signature": "() => Promise<void>",
845
835
  "parameters": [],
@@ -852,19 +842,15 @@ export class TdsDropdown {
852
842
  "return": "Promise<void>"
853
843
  },
854
844
  "docs": {
855
- "text": "Method that forces focus on the input element.",
845
+ "text": "",
856
846
  "tags": []
857
847
  }
858
848
  },
859
- "setValue": {
849
+ "removeValue": {
860
850
  "complexType": {
861
- "signature": "(value: string | string[], label?: string) => Promise<{ value: string; label: string; }[]>",
851
+ "signature": "(oldValue: string) => Promise<void>",
862
852
  "parameters": [{
863
- "name": "value",
864
- "type": "string | string[]",
865
- "docs": ""
866
- }, {
867
- "name": "label",
853
+ "name": "oldValue",
868
854
  "type": "string",
869
855
  "docs": ""
870
856
  }],
@@ -872,27 +858,19 @@ export class TdsDropdown {
872
858
  "Promise": {
873
859
  "location": "global",
874
860
  "id": "global::Promise"
875
- },
876
- "HTMLTdsDropdownOptionElement": {
877
- "location": "global",
878
- "id": "global::HTMLTdsDropdownOptionElement"
879
861
  }
880
862
  },
881
- "return": "Promise<{ value: string; label: string; }[]>"
863
+ "return": "Promise<void>"
882
864
  },
883
865
  "docs": {
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>",
866
+ "text": "",
885
867
  "tags": []
886
868
  }
887
869
  },
888
- "appendValue": {
870
+ "focusElement": {
889
871
  "complexType": {
890
- "signature": "(value: string) => Promise<void>",
891
- "parameters": [{
892
- "name": "value",
893
- "type": "string",
894
- "docs": ""
895
- }],
872
+ "signature": "() => Promise<void>",
873
+ "parameters": [],
896
874
  "references": {
897
875
  "Promise": {
898
876
  "location": "global",
@@ -902,42 +880,35 @@ export class TdsDropdown {
902
880
  "return": "Promise<void>"
903
881
  },
904
882
  "docs": {
905
- "text": "",
906
- "tags": [{
907
- "name": "internal",
908
- "text": undefined
909
- }]
883
+ "text": "Method that forces focus on the input element.",
884
+ "tags": []
910
885
  }
911
886
  },
912
- "removeValue": {
887
+ "close": {
913
888
  "complexType": {
914
- "signature": "(oldValue: string) => Promise<{ value: string; label: string; }[]>",
915
- "parameters": [{
916
- "name": "oldValue",
917
- "type": "string",
918
- "docs": ""
919
- }],
889
+ "signature": "() => Promise<void>",
890
+ "parameters": [],
920
891
  "references": {
921
892
  "Promise": {
922
893
  "location": "global",
923
894
  "id": "global::Promise"
924
- },
925
- "HTMLTdsDropdownOptionElement": {
926
- "location": "global",
927
- "id": "global::HTMLTdsDropdownOptionElement"
928
895
  }
929
896
  },
930
- "return": "Promise<{ value: string; label: string; }[]>"
897
+ "return": "Promise<void>"
931
898
  },
932
899
  "docs": {
933
- "text": "Method for removing a selected value in the Dropdown.",
900
+ "text": "Method for closing the Dropdown.",
934
901
  "tags": []
935
902
  }
936
903
  },
937
- "close": {
904
+ "appendValue": {
938
905
  "complexType": {
939
- "signature": "() => Promise<void>",
940
- "parameters": [],
906
+ "signature": "(value: string) => Promise<void>",
907
+ "parameters": [{
908
+ "name": "value",
909
+ "type": "string",
910
+ "docs": ""
911
+ }],
941
912
  "references": {
942
913
  "Promise": {
943
914
  "location": "global",
@@ -947,7 +918,7 @@ export class TdsDropdown {
947
918
  "return": "Promise<void>"
948
919
  },
949
920
  "docs": {
950
- "text": "Method for closing the Dropdown.",
921
+ "text": "",
951
922
  "tags": []
952
923
  }
953
924
  }
@@ -956,6 +927,9 @@ export class TdsDropdown {
956
927
  static get elementRef() { return "host"; }
957
928
  static get watchers() {
958
929
  return [{
930
+ "propName": "value",
931
+ "methodName": "handleValueChange"
932
+ }, {
959
933
  "propName": "open",
960
934
  "methodName": "handleOpenState"
961
935
  }];