@scania/tegel 1.23.0-beta.0 → 1.23.0-block-nesting-beta.1
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 +17 -13
- 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 +11 -5
- package/dist/collection/components/block/block.js +16 -12
- 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 +17 -13
- 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 +17 -13
- 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-fe3cc93e.entry.js +1 -0
- package/dist/tegel/tegel.css +1 -1
- package/dist/tegel/tegel.esm.js +1 -1
- package/dist/types/components/block/block.d.ts +1 -2
- 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
|
@@ -5150,40 +5150,30 @@ html {
|
|
|
5150
5150
|
:root,
|
|
5151
5151
|
.tds-mode-light {
|
|
5152
5152
|
--tds-block-color: var(--tds-grey-985);
|
|
5153
|
+
--tds-block-background: var(--tds-grey-50);
|
|
5153
5154
|
--tds-block-background-primary: var(--tds-grey-50);
|
|
5154
|
-
--tds-block-background-nested-primary: var(--tds-white);
|
|
5155
5155
|
--tds-block-background-secondary: var(--tds-white);
|
|
5156
|
-
--tds-block-background-nested-secondary: var(--tds-grey-50);
|
|
5157
|
-
--tds-block-background: var(--tds-block-background-primary);
|
|
5158
|
-
--tds-block-background-nested: var(--tds-block-background-nested-primary);
|
|
5159
5156
|
}
|
|
5160
5157
|
:root .tds-mode-variant-primary,
|
|
5161
5158
|
.tds-mode-light .tds-mode-variant-primary {
|
|
5162
|
-
--tds-block-background: var(--tds-
|
|
5163
|
-
--tds-block-background-nested: var(--tds-block-background-nested-primary);
|
|
5159
|
+
--tds-block-background: var(--tds-grey-50);
|
|
5164
5160
|
}
|
|
5165
5161
|
:root .tds-mode-variant-secondary,
|
|
5166
5162
|
.tds-mode-light .tds-mode-variant-secondary {
|
|
5167
|
-
--tds-block-background: var(--tds-
|
|
5168
|
-
--tds-block-background-nested: var(--tds-block-background-nested-secondary);
|
|
5163
|
+
--tds-block-background: var(--tds-white);
|
|
5169
5164
|
}
|
|
5170
5165
|
|
|
5171
5166
|
.tds-mode-dark {
|
|
5172
5167
|
--tds-block-color: var(--tds-grey-50);
|
|
5168
|
+
--tds-block-background: var(--tds-grey-900);
|
|
5173
5169
|
--tds-block-background-primary: var(--tds-grey-900);
|
|
5174
|
-
--tds-block-background-nested-primary: var(--tds-grey-868);
|
|
5175
5170
|
--tds-block-background-secondary: var(--tds-grey-868);
|
|
5176
|
-
--tds-block-background-nested-secondary: var(--tds-grey-900);
|
|
5177
|
-
--tds-block-background: var(--tds-block-background-primary);
|
|
5178
|
-
--tds-block-background-nested: var(--tds-block-background-nested-primary);
|
|
5179
5171
|
}
|
|
5180
5172
|
.tds-mode-dark .tds-mode-variant-primary {
|
|
5181
|
-
--tds-block-background: var(--tds-
|
|
5182
|
-
--tds-block-background-nested: var(--tds-block-background-nested-primary);
|
|
5173
|
+
--tds-block-background: var(--tds-grey-900);
|
|
5183
5174
|
}
|
|
5184
5175
|
.tds-mode-dark .tds-mode-variant-secondary {
|
|
5185
|
-
--tds-block-background: var(--tds-
|
|
5186
|
-
--tds-block-background-nested: var(--tds-block-background-nested-secondary);
|
|
5176
|
+
--tds-block-background: var(--tds-grey-868);
|
|
5187
5177
|
}
|
|
5188
5178
|
|
|
5189
5179
|
:root,
|
|
@@ -71,14 +71,6 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
71
71
|
this.tdsFocus = createEvent(this, "tdsFocus", 6);
|
|
72
72
|
this.tdsBlur = createEvent(this, "tdsBlur", 6);
|
|
73
73
|
this.tdsInput = createEvent(this, "tdsInput", 6);
|
|
74
|
-
this.tdsValueChange = createEvent(this, "tdsValueChange", 6);
|
|
75
|
-
this.handleChange = () => {
|
|
76
|
-
const value = Array.isArray(this.value) ? this.value.join(',') : this.value;
|
|
77
|
-
this.tdsChange.emit({
|
|
78
|
-
name: this.name,
|
|
79
|
-
value: value !== null && value !== void 0 ? value : null,
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
74
|
this.setDefaultOption = () => {
|
|
83
75
|
if (this.defaultValue) {
|
|
84
76
|
const children = Array.from(this.host.children).filter((element) => element.tagName === 'TDS-DROPDOWN-OPTION');
|
|
@@ -107,6 +99,7 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
107
99
|
}
|
|
108
100
|
}
|
|
109
101
|
};
|
|
102
|
+
/* Returns a list of all children that are tds-dropdown-option elements */
|
|
110
103
|
this.getChildren = () => {
|
|
111
104
|
const tdsDropdownOptions = Array.from(this.host.children).filter((element) => element.tagName === 'TDS-DROPDOWN-OPTION');
|
|
112
105
|
if (tdsDropdownOptions.length === 0) {
|
|
@@ -115,38 +108,6 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
115
108
|
else
|
|
116
109
|
return tdsDropdownOptions;
|
|
117
110
|
};
|
|
118
|
-
this.getSelectedChildren = () => {
|
|
119
|
-
if (!this.value)
|
|
120
|
-
return [];
|
|
121
|
-
const valueArray = Array.isArray(this.value) ? this.value : [this.value];
|
|
122
|
-
return valueArray
|
|
123
|
-
.map((stringValue) => {
|
|
124
|
-
const matchingElement = this.getChildren().find((element) => element.value === stringValue);
|
|
125
|
-
return matchingElement;
|
|
126
|
-
})
|
|
127
|
-
.filter(Boolean);
|
|
128
|
-
};
|
|
129
|
-
this.getSelectedChildrenLabels = () => {
|
|
130
|
-
var _a;
|
|
131
|
-
return (_a = this.getSelectedChildren()) === null || _a === void 0 ? void 0 : _a.map((element) => element.textContent.trim());
|
|
132
|
-
};
|
|
133
|
-
this.getValue = () => {
|
|
134
|
-
const labels = this.getSelectedChildrenLabels();
|
|
135
|
-
if (!labels) {
|
|
136
|
-
return '';
|
|
137
|
-
}
|
|
138
|
-
return labels === null || labels === void 0 ? void 0 : labels.join(', ');
|
|
139
|
-
};
|
|
140
|
-
this.setValueAttribute = () => {
|
|
141
|
-
var _a;
|
|
142
|
-
if (!this.value || ((_a = this.value) === null || _a === void 0 ? void 0 : _a.toString()) === '') {
|
|
143
|
-
this.host.removeAttribute('value');
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
const valueArray = Array.isArray(this.value) ? this.value : [this.value];
|
|
147
|
-
this.host.setAttribute('value', valueArray.map((val) => val).toString());
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
111
|
this.getOpenDirection = () => {
|
|
151
112
|
var _a, _b, _c, _d, _e;
|
|
152
113
|
if (this.openDirection === 'auto' || !this.openDirection) {
|
|
@@ -160,6 +121,7 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
160
121
|
}
|
|
161
122
|
return this.openDirection;
|
|
162
123
|
};
|
|
124
|
+
/* Toggles the open state of the Dropdown and sets focus to the input element */
|
|
163
125
|
this.handleToggleOpen = () => {
|
|
164
126
|
if (!this.disabled) {
|
|
165
127
|
this.open = !this.open;
|
|
@@ -168,10 +130,38 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
168
130
|
}
|
|
169
131
|
}
|
|
170
132
|
};
|
|
133
|
+
/* Focuses the input element in the Dropdown, if the reference is present. */
|
|
171
134
|
this.focusInputElement = () => {
|
|
172
135
|
if (this.inputElement)
|
|
173
136
|
this.inputElement.focus();
|
|
174
137
|
};
|
|
138
|
+
this.getSelectedChildren = () => {
|
|
139
|
+
var _a;
|
|
140
|
+
return (_a = this.value) === null || _a === void 0 ? void 0 : _a.map((stringValue) => {
|
|
141
|
+
const matchingElement = this.getChildren().find((element) => element.value === stringValue);
|
|
142
|
+
return matchingElement;
|
|
143
|
+
}).filter(Boolean);
|
|
144
|
+
};
|
|
145
|
+
this.getSelectedChildrenLabels = () => {
|
|
146
|
+
var _a;
|
|
147
|
+
return (_a = this.getSelectedChildren()) === null || _a === void 0 ? void 0 : _a.map((element) => element.textContent.trim());
|
|
148
|
+
};
|
|
149
|
+
this.getValue = () => {
|
|
150
|
+
const labels = this.getSelectedChildrenLabels();
|
|
151
|
+
if (!labels) {
|
|
152
|
+
return '';
|
|
153
|
+
}
|
|
154
|
+
return labels === null || labels === void 0 ? void 0 : labels.join(', ');
|
|
155
|
+
};
|
|
156
|
+
this.setValueAttribute = () => {
|
|
157
|
+
var _a;
|
|
158
|
+
if (!this.value || ((_a = this.value) === null || _a === void 0 ? void 0 : _a.toString()) === '') {
|
|
159
|
+
this.host.removeAttribute('value');
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.host.setAttribute('value', this.value.map((val) => val).toString());
|
|
163
|
+
}
|
|
164
|
+
};
|
|
175
165
|
this.handleFilter = (event) => {
|
|
176
166
|
this.tdsInput.emit(event);
|
|
177
167
|
const query = event.target.value.toLowerCase();
|
|
@@ -217,6 +207,13 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
217
207
|
this.handleBlur = (event) => {
|
|
218
208
|
this.tdsBlur.emit(event);
|
|
219
209
|
};
|
|
210
|
+
this.handleChange = () => {
|
|
211
|
+
var _a, _b;
|
|
212
|
+
this.tdsChange.emit({
|
|
213
|
+
name: this.name,
|
|
214
|
+
value: (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.map((value) => value).toString()) !== null && _b !== void 0 ? _b : null,
|
|
215
|
+
});
|
|
216
|
+
};
|
|
220
217
|
this.name = undefined;
|
|
221
218
|
this.disabled = false;
|
|
222
219
|
this.helper = undefined;
|
|
@@ -233,92 +230,107 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
233
230
|
this.normalizeText = true;
|
|
234
231
|
this.noResultText = 'No result';
|
|
235
232
|
this.defaultValue = undefined;
|
|
236
|
-
this.value = undefined;
|
|
237
233
|
this.open = false;
|
|
238
|
-
this.
|
|
234
|
+
this.value = undefined;
|
|
239
235
|
this.filterResult = undefined;
|
|
240
236
|
this.filterFocus = undefined;
|
|
241
237
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const valueArray = Array.isArray(newValue) ? newValue : newValue ? [newValue] : null;
|
|
247
|
-
// Handle multiselect validation
|
|
248
|
-
if (!this.multiselect && Array.isArray(valueArray) && valueArray.length > 1) {
|
|
249
|
-
console.warn('Tried to select multiple items, but multiselect is not enabled.');
|
|
250
|
-
// Coerce to single value for non-multiselect
|
|
251
|
-
this.value = valueArray[0];
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
// Ensure value is always array internally for backward compatibility
|
|
255
|
-
this.updateSelections(valueArray);
|
|
238
|
+
/** Method that resets the Dropdown, marks all children as non-selected and resets the value to null. */
|
|
239
|
+
async reset() {
|
|
240
|
+
this.dropdownList.scrollTop = 0;
|
|
241
|
+
this.internalReset();
|
|
256
242
|
this.handleChange();
|
|
257
243
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
this.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
this.internalValue = '';
|
|
290
|
-
this.value = this.multiselect ? [] : null;
|
|
244
|
+
/** Method that forces focus on the input element. */
|
|
245
|
+
async focusElement() {
|
|
246
|
+
this.focusInputElement();
|
|
247
|
+
this.handleFocus({});
|
|
248
|
+
}
|
|
249
|
+
/** Method for setting the value of the Dropdown.
|
|
250
|
+
*
|
|
251
|
+
* Single selection example:
|
|
252
|
+
*
|
|
253
|
+
* <code>
|
|
254
|
+
* dropdown.setValue('option-1', 'Option 1');
|
|
255
|
+
* </code>
|
|
256
|
+
*
|
|
257
|
+
* Multiselect example:
|
|
258
|
+
*
|
|
259
|
+
* <code>
|
|
260
|
+
* dropdown.setValue(['option-1', 'option-2']);
|
|
261
|
+
* </code>
|
|
262
|
+
*/
|
|
263
|
+
// The label is optional here ONLY to not break the API. Should be removed for 2.0.
|
|
264
|
+
// @ts-ignore
|
|
265
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
266
|
+
async setValue(value, label) {
|
|
267
|
+
let nextValue;
|
|
268
|
+
if (typeof value === 'string')
|
|
269
|
+
nextValue = [value];
|
|
270
|
+
else
|
|
271
|
+
nextValue = value;
|
|
272
|
+
if (!this.multiselect && nextValue.length > 1) {
|
|
273
|
+
console.warn('Tried to select multiple items, but multiselect is not enabled.');
|
|
274
|
+
nextValue = [nextValue[0]];
|
|
291
275
|
}
|
|
292
|
-
|
|
293
|
-
this.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
276
|
+
nextValue = [...new Set(nextValue)];
|
|
277
|
+
this.internalReset();
|
|
278
|
+
for (let i = 0; i < nextValue.length; i++) {
|
|
279
|
+
const optionExist = this.getChildren().some((element) => element.value === nextValue[i]);
|
|
280
|
+
if (!optionExist) {
|
|
281
|
+
nextValue.splice(i, 1);
|
|
282
|
+
}
|
|
297
283
|
}
|
|
284
|
+
this.value = nextValue;
|
|
298
285
|
this.setValueAttribute();
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
286
|
+
this.selectChildrenAsSelectedBasedOnSelectionProp();
|
|
287
|
+
this.handleChange();
|
|
288
|
+
/* 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. */
|
|
289
|
+
/* https://tegel.atlassian.net/browse/CDEP-2703 */
|
|
290
|
+
const selection = this.getSelectedChildren().map((element) => ({
|
|
303
291
|
value: element.value,
|
|
304
292
|
label: element.textContent.trim(),
|
|
305
293
|
}));
|
|
294
|
+
// Update inputElement value and placeholder text
|
|
295
|
+
if (this.filter) {
|
|
296
|
+
this.inputElement.value = this.getValue();
|
|
297
|
+
}
|
|
298
|
+
return selection;
|
|
306
299
|
}
|
|
307
|
-
|
|
308
|
-
|
|
300
|
+
/**
|
|
301
|
+
* @internal
|
|
302
|
+
*/
|
|
303
|
+
async appendValue(value) {
|
|
304
|
+
if (this.multiselect && this.value) {
|
|
305
|
+
this.setValue([...this.value, value]);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
this.setValue(value);
|
|
309
|
+
}
|
|
309
310
|
}
|
|
311
|
+
/** Method for removing a selected value in the Dropdown. */
|
|
310
312
|
async removeValue(oldValue) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
+
var _a, _b;
|
|
314
|
+
let label;
|
|
315
|
+
if (this.multiselect) {
|
|
316
|
+
(_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
|
|
317
|
+
var _a;
|
|
318
|
+
if (element.value === oldValue) {
|
|
319
|
+
this.value = (_a = this.value) === null || _a === void 0 ? void 0 : _a.filter((value) => value !== element.value);
|
|
320
|
+
label = element.textContent.trim();
|
|
321
|
+
element.setSelected(false);
|
|
322
|
+
}
|
|
323
|
+
return element;
|
|
324
|
+
});
|
|
313
325
|
}
|
|
314
326
|
else {
|
|
315
|
-
this.
|
|
327
|
+
this.reset();
|
|
316
328
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
this.
|
|
329
|
+
this.handleChange();
|
|
330
|
+
this.setValueAttribute();
|
|
331
|
+
/* 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. */
|
|
332
|
+
/* https://tegel.atlassian.net/browse/CDEP-2703 */
|
|
333
|
+
return (_b = this.value) === null || _b === void 0 ? void 0 : _b.map((value) => ({ value, label }));
|
|
322
334
|
}
|
|
323
335
|
/** Method for closing the Dropdown. */
|
|
324
336
|
async close() {
|
|
@@ -372,9 +384,6 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
372
384
|
}
|
|
373
385
|
}
|
|
374
386
|
componentWillLoad() {
|
|
375
|
-
if (this.defaultValue && !this.value) {
|
|
376
|
-
this.value = this.defaultValue;
|
|
377
|
-
}
|
|
378
387
|
this.setDefaultOption();
|
|
379
388
|
}
|
|
380
389
|
/** Method to handle slot changes */
|
|
@@ -385,19 +394,34 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
385
394
|
normalizeString(text) {
|
|
386
395
|
return this.normalizeText ? text.normalize('NFD').replace(/\p{Diacritic}/gu, '') : text;
|
|
387
396
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
397
|
+
/** Method that resets the dropdown without emitting an event. */
|
|
398
|
+
internalReset() {
|
|
399
|
+
this.getChildren().forEach((element) => {
|
|
400
|
+
element.setSelected(false);
|
|
401
|
+
return element;
|
|
402
|
+
});
|
|
403
|
+
this.value = null;
|
|
404
|
+
this.setValueAttribute();
|
|
405
|
+
}
|
|
406
|
+
selectChildrenAsSelectedBasedOnSelectionProp() {
|
|
407
|
+
this.getChildren().forEach((element) => {
|
|
408
|
+
this.value.forEach((selection) => {
|
|
409
|
+
if (element.value !== selection) {
|
|
410
|
+
// If not multiselect, we need to unselect all other options.
|
|
411
|
+
if (!this.multiselect) {
|
|
412
|
+
element.setSelected(false);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
element.setSelected(true);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
});
|
|
395
420
|
}
|
|
396
421
|
render() {
|
|
397
|
-
var _a, _b, _c;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
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: {
|
|
422
|
+
var _a, _b, _c, _d;
|
|
423
|
+
appendHiddenInput(this.host, this.name, (_a = this.value) === null || _a === void 0 ? void 0 : _a.map((value) => value).toString(), this.disabled);
|
|
424
|
+
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: {
|
|
401
425
|
filter: true,
|
|
402
426
|
focus: this.filterFocus,
|
|
403
427
|
disabled: this.disabled,
|
|
@@ -405,7 +429,7 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
405
429
|
} }, 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: `
|
|
406
430
|
label-inside-as-placeholder
|
|
407
431
|
${this.size}
|
|
408
|
-
${((
|
|
432
|
+
${((_b = this.value) === null || _b === void 0 ? void 0 : _b.length) ? 'selected' : ''}
|
|
409
433
|
` }, this.label)), h("input", {
|
|
410
434
|
// eslint-disable-next-line no-return-assign
|
|
411
435
|
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) => {
|
|
@@ -414,7 +438,15 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
414
438
|
this.inputElement.value = this.getValue();
|
|
415
439
|
}
|
|
416
440
|
this.handleBlur(event);
|
|
417
|
-
}, onFocus: (event) =>
|
|
441
|
+
}, onFocus: (event) => {
|
|
442
|
+
this.open = true;
|
|
443
|
+
this.filterFocus = true;
|
|
444
|
+
if (this.multiselect) {
|
|
445
|
+
this.inputElement.value = '';
|
|
446
|
+
}
|
|
447
|
+
this.handleFocus(event);
|
|
448
|
+
this.handleFilter({ target: { value: '' } });
|
|
449
|
+
}, onKeyDown: (event) => {
|
|
418
450
|
if (event.key === 'Escape') {
|
|
419
451
|
this.open = false;
|
|
420
452
|
}
|
|
@@ -438,8 +470,8 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
438
470
|
`, 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: `
|
|
439
471
|
label-inside-as-placeholder
|
|
440
472
|
${this.size}
|
|
441
|
-
${((
|
|
442
|
-
` }, this.label)), h("div", { class: `placeholder ${this.size}` }, ((
|
|
473
|
+
${((_c = this.value) === null || _c === void 0 ? void 0 : _c.length) ? 'selected' : ''}
|
|
474
|
+
` }, 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: {
|
|
443
475
|
'dropdown-list': true,
|
|
444
476
|
[this.size]: true,
|
|
445
477
|
[this.getOpenDirection()]: true,
|
|
@@ -448,11 +480,10 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
448
480
|
'closed': !this.open,
|
|
449
481
|
[`animation-enter-${this.animation}`]: this.animation !== 'none' && this.open,
|
|
450
482
|
[`animation-exit-${this.animation}`]: this.animation !== 'none' && !this.open,
|
|
451
|
-
} }, h("slot", { key: '
|
|
483
|
+
} }, 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))));
|
|
452
484
|
}
|
|
453
485
|
get host() { return this; }
|
|
454
486
|
static get watchers() { return {
|
|
455
|
-
"value": ["handleValueChange"],
|
|
456
487
|
"open": ["handleOpenState"]
|
|
457
488
|
}; }
|
|
458
489
|
static get style() { return TdsDropdownStyle0; }
|
|
@@ -473,19 +504,17 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
473
504
|
"normalizeText": [4, "normalize-text"],
|
|
474
505
|
"noResultText": [1, "no-result-text"],
|
|
475
506
|
"defaultValue": [1, "default-value"],
|
|
476
|
-
"value": [1025],
|
|
477
507
|
"open": [32],
|
|
478
|
-
"
|
|
508
|
+
"value": [32],
|
|
479
509
|
"filterResult": [32],
|
|
480
510
|
"filterFocus": [32],
|
|
481
|
-
"setValue": [64],
|
|
482
511
|
"reset": [64],
|
|
483
|
-
"removeValue": [64],
|
|
484
512
|
"focusElement": [64],
|
|
485
|
-
"
|
|
486
|
-
"appendValue": [64]
|
|
513
|
+
"setValue": [64],
|
|
514
|
+
"appendValue": [64],
|
|
515
|
+
"removeValue": [64],
|
|
516
|
+
"close": [64]
|
|
487
517
|
}, [[9, "mousedown", "onAnyClick"], [0, "keydown", "onKeyDown"]], {
|
|
488
|
-
"value": ["handleValueChange"],
|
|
489
518
|
"open": ["handleOpenState"]
|
|
490
519
|
}]);
|
|
491
520
|
function defineCustomElement() {
|