@scania/tegel 1.23.0-value-prop.beta.1 → 1.23.0-value-prop.beta.2
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-checkbox.cjs.entry.js +2 -9
- package/dist/cjs/tds-dropdown_2.cjs.entry.js +62 -101
- package/dist/cjs/tds-slider.cjs.entry.js +7 -33
- package/dist/cjs/tegel.cjs.js +1 -1
- package/dist/collection/components/checkbox/checkbox.js +3 -19
- package/dist/collection/components/dropdown/dropdown.js +66 -103
- package/dist/collection/components/slider/slider.js +8 -34
- package/dist/components/{p-e7868876.js → p-462b77e8.js} +1 -1
- package/dist/components/{p-097af62b.js → p-4d8f8d5c.js} +63 -101
- package/dist/components/{p-d921fe75.js → p-e4d7c655.js} +3 -10
- 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-slider.js +7 -33
- 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/esm/loader.js +1 -1
- package/dist/esm/tds-checkbox.entry.js +2 -9
- package/dist/esm/tds-dropdown_2.entry.js +62 -101
- package/dist/esm/tds-slider.entry.js +8 -34
- package/dist/esm/tegel.js +1 -1
- package/dist/tegel/p-0c05887d.entry.js +1 -0
- package/dist/tegel/p-a464920f.entry.js +1 -0
- package/dist/tegel/p-f91c6e9d.entry.js +1 -0
- package/dist/tegel/tegel.esm.js +1 -1
- package/dist/types/components/checkbox/checkbox.d.ts +0 -2
- package/dist/types/components/dropdown/dropdown.d.ts +8 -5
- package/dist/types/components/slider/slider.d.ts +0 -7
- package/package.json +1 -1
- package/dist/tegel/p-2557b79b.entry.js +0 -1
- package/dist/tegel/p-6a52ed63.entry.js +0 -1
- package/dist/tegel/p-a0925278.entry.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
2
|
import generateUniqueId from "../../utils/generateUniqueId";
|
|
3
3
|
/**
|
|
4
4
|
* @slot label - Slot for the label text.
|
|
@@ -43,19 +43,12 @@ export class TdsCheckbox {
|
|
|
43
43
|
handleBlur(event) {
|
|
44
44
|
this.tdsBlur.emit(event);
|
|
45
45
|
}
|
|
46
|
-
/** Listens for a reset event inside a form */
|
|
47
|
-
handleFormReset(event) {
|
|
48
|
-
if (this.host.closest('form') === event.target) {
|
|
49
|
-
this.checked = false;
|
|
50
|
-
this.indeterminate = false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
46
|
render() {
|
|
54
|
-
return (h("div", { key: '
|
|
47
|
+
return (h("div", { key: '0efb982ab13c1d75681614675b649e010707b701', class: "tds-checkbox" }, h("input", { key: '834b29962978ea1cf7249018e6b7eea2417da5f4',
|
|
55
48
|
// eslint-disable-next-line no-return-assign
|
|
56
49
|
ref: (inputElement) => (this.inputElement = inputElement), indeterminate: this.indeterminate, "aria-checked": this.checked, "aria-required": this.required, "aria-describedby": this.host.getAttribute('aria-describedby'), "aria-labelledby": this.host.getAttribute('aria-labelledby'), required: this.required, type: "checkbox", name: this.name, value: this.value, id: this.checkboxId, checked: this.checked, disabled: this.disabled, onFocus: (event) => this.handleFocus(event), onBlur: (event) => this.handleBlur(event), onChange: () => {
|
|
57
50
|
this.handleChange();
|
|
58
|
-
} }), h("label", { key: '
|
|
51
|
+
} }), h("label", { key: '2150346b336440768beac655de035bf470f9e492', htmlFor: this.checkboxId }, h("slot", { key: 'df61654810e46b8707709d86bae7bdfd627724ee', name: "label" }))));
|
|
59
52
|
}
|
|
60
53
|
static get is() { return "tds-checkbox"; }
|
|
61
54
|
static get encapsulation() { return "scoped"; }
|
|
@@ -283,13 +276,4 @@ export class TdsCheckbox {
|
|
|
283
276
|
"methodName": "handleIndeterminateState"
|
|
284
277
|
}];
|
|
285
278
|
}
|
|
286
|
-
static get listeners() {
|
|
287
|
-
return [{
|
|
288
|
-
"name": "reset",
|
|
289
|
-
"method": "handleFormReset",
|
|
290
|
-
"target": "document",
|
|
291
|
-
"capture": false,
|
|
292
|
-
"passive": false
|
|
293
|
-
}];
|
|
294
|
-
}
|
|
295
279
|
}
|
|
@@ -7,39 +7,13 @@ 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
|
-
const children = Array.from(this.host.children).filter((element) => element.tagName === 'TDS-DROPDOWN-OPTION');
|
|
20
|
-
if (children.length === 0) {
|
|
21
|
-
console.warn('TDS DROPDOWN: No options found. Disregard if loading data asynchronously.');
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
12
|
const defaultValues = this.multiselect
|
|
25
13
|
? new Set(this.defaultValue.split(','))
|
|
26
14
|
: [this.defaultValue];
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const element = childrenMap.get(value);
|
|
30
|
-
if (element) {
|
|
31
|
-
element.setSelected(true);
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
return false;
|
|
35
|
-
});
|
|
36
|
-
if (matchedValues.length > 0) {
|
|
37
|
-
this.value = [...new Set(this.value ? [...this.value, ...matchedValues] : matchedValues)];
|
|
38
|
-
this.setValueAttribute();
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
console.warn(`TDS DROPDOWN: No matching option found for defaultValue "${this.defaultValue}"`);
|
|
42
|
-
}
|
|
15
|
+
const normalizedValues = Array.from(defaultValues);
|
|
16
|
+
this.updateDropdownState(normalizedValues);
|
|
43
17
|
}
|
|
44
18
|
};
|
|
45
19
|
this.getChildren = () => {
|
|
@@ -152,12 +126,6 @@ export class TdsDropdown {
|
|
|
152
126
|
this.handleBlur = (event) => {
|
|
153
127
|
this.tdsBlur.emit(event);
|
|
154
128
|
};
|
|
155
|
-
this.resetInput = () => {
|
|
156
|
-
const inputEl = this.host.querySelector('input');
|
|
157
|
-
if (inputEl) {
|
|
158
|
-
this.reset();
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
129
|
this.name = undefined;
|
|
162
130
|
this.disabled = false;
|
|
163
131
|
this.helper = undefined;
|
|
@@ -174,70 +142,75 @@ export class TdsDropdown {
|
|
|
174
142
|
this.normalizeText = true;
|
|
175
143
|
this.noResultText = 'No result';
|
|
176
144
|
this.defaultValue = undefined;
|
|
177
|
-
this.value =
|
|
145
|
+
this.value = null;
|
|
178
146
|
this.open = false;
|
|
179
147
|
this.internalValue = undefined;
|
|
180
148
|
this.filterResult = undefined;
|
|
181
149
|
this.filterFocus = undefined;
|
|
150
|
+
this.selectedOptions = [];
|
|
182
151
|
}
|
|
183
152
|
handleValueChange(newValue) {
|
|
184
|
-
//
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
? [this.value]
|
|
190
|
-
: [];
|
|
191
|
-
// Check if the new value is different from the current value
|
|
192
|
-
const hasChanged = newValueArray.length !== currentValueArray.length ||
|
|
193
|
-
newValueArray.some((val, index) => val !== currentValueArray[index]);
|
|
194
|
-
if (hasChanged) {
|
|
195
|
-
// Proceed with updating selections and emitting changes
|
|
196
|
-
this.updateSelections(newValueArray);
|
|
197
|
-
this.handleChange();
|
|
153
|
+
// Normalize to array
|
|
154
|
+
const normalizedValue = this.normalizeValue(newValue);
|
|
155
|
+
// Only update if actually changed
|
|
156
|
+
if (this.hasValueChanged(normalizedValue, this.selectedOptions)) {
|
|
157
|
+
this.updateDropdownState(normalizedValue);
|
|
198
158
|
}
|
|
199
159
|
}
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
160
|
+
normalizeValue(value) {
|
|
161
|
+
if (!value)
|
|
162
|
+
return [];
|
|
163
|
+
return Array.isArray(value) ? value : [value];
|
|
164
|
+
}
|
|
165
|
+
hasValueChanged(newValue, currentValue) {
|
|
166
|
+
if (newValue.length !== currentValue.length)
|
|
167
|
+
return true;
|
|
168
|
+
return newValue.some((val) => !currentValue.includes(val));
|
|
169
|
+
}
|
|
170
|
+
updateDropdownState(values) {
|
|
171
|
+
// Update internal state
|
|
172
|
+
this.selectedOptions = this.validateValues(values);
|
|
173
|
+
// Update DOM
|
|
174
|
+
this.updateOptionElements();
|
|
175
|
+
// Update display value
|
|
176
|
+
this.updateDisplayValue();
|
|
177
|
+
// Emit change event
|
|
178
|
+
this.emitChange();
|
|
179
|
+
// Update value attribute
|
|
180
|
+
this.setValueAttribute();
|
|
181
|
+
}
|
|
182
|
+
validateValues(values) {
|
|
183
|
+
return values.filter((val) => {
|
|
184
|
+
var _a;
|
|
185
|
+
const isValid = (_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.some((element) => element.value === val);
|
|
186
|
+
if (!isValid) {
|
|
187
|
+
console.warn(`Option with value "${val}" does not exist`);
|
|
227
188
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
189
|
+
return isValid;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
updateOptionElements() {
|
|
193
|
+
var _a;
|
|
194
|
+
(_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
|
|
195
|
+
element.setSelected(this.selectedOptions.includes(element.value));
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
updateDisplayValue() {
|
|
199
|
+
this.internalValue = this.getSelectedChildrenLabels().join(', ');
|
|
237
200
|
if (this.filter && this.inputElement) {
|
|
238
201
|
this.inputElement.value = this.internalValue;
|
|
239
202
|
}
|
|
240
|
-
|
|
203
|
+
}
|
|
204
|
+
emitChange() {
|
|
205
|
+
// Update the value prop to match validated state
|
|
206
|
+
this.value = this.multiselect ? this.selectedOptions : this.selectedOptions[0] || null;
|
|
207
|
+
const value = this.multiselect
|
|
208
|
+
? this.selectedOptions.join(',')
|
|
209
|
+
: this.selectedOptions[0] || null;
|
|
210
|
+
this.tdsChange.emit({
|
|
211
|
+
name: this.name,
|
|
212
|
+
value: value !== null && value !== void 0 ? value : null,
|
|
213
|
+
});
|
|
241
214
|
}
|
|
242
215
|
async setValue(value) {
|
|
243
216
|
this.value = value;
|
|
@@ -335,23 +308,11 @@ export class TdsDropdown {
|
|
|
335
308
|
this.value = value;
|
|
336
309
|
}
|
|
337
310
|
}
|
|
338
|
-
componentDidRender() {
|
|
339
|
-
const form = this.host.closest('form');
|
|
340
|
-
if (form) {
|
|
341
|
-
form.addEventListener('reset', this.resetInput);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
disconnectedCallback() {
|
|
345
|
-
const form = this.host.closest('form');
|
|
346
|
-
if (form) {
|
|
347
|
-
form.removeEventListener('reset', this.resetInput);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
311
|
render() {
|
|
351
312
|
var _a, _b, _c;
|
|
352
313
|
const valueArray = Array.isArray(this.value) ? this.value : this.value ? [this.value] : [];
|
|
353
314
|
appendHiddenInput(this.host, this.name, valueArray.map((value) => value).toString(), this.disabled);
|
|
354
|
-
return (h(Host, { key: '
|
|
315
|
+
return (h(Host, { key: 'c3a3742ba6f875aee1b9e7abb4ab2c2b2331d3fc', role: "select", class: `${this.modeVariant ? `tds-mode-variant-${this.modeVariant}` : ''}` }, this.label && this.labelPosition === 'outside' && (h("div", { key: '0b45d4e910577e1cfd350f6f60e544839f905865', class: `label-outside ${this.disabled ? 'disabled' : ''}` }, this.label)), h("div", { key: '3557975c254df99c9f97dac71a6d9e66268c09f2', class: `dropdown-select ${this.size} ${this.disabled ? 'disabled' : ''}` }, this.filter ? (h("div", { class: {
|
|
355
316
|
filter: true,
|
|
356
317
|
focus: this.filterFocus,
|
|
357
318
|
disabled: this.disabled,
|
|
@@ -393,7 +354,7 @@ export class TdsDropdown {
|
|
|
393
354
|
label-inside-as-placeholder
|
|
394
355
|
${this.size}
|
|
395
356
|
${((_b = this.value) === null || _b === void 0 ? void 0 : _b.length) ? 'selected' : ''}
|
|
396
|
-
` }, this.label)), h("div", { class: `placeholder ${this.size}` }, ((_c = this.value) === null || _c === void 0 ? void 0 : _c.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: '
|
|
357
|
+
` }, this.label)), h("div", { class: `placeholder ${this.size}` }, ((_c = this.value) === null || _c === void 0 ? void 0 : _c.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: 'bf74f7277ac93324469c9f371a1a41598366d833', ref: (element) => (this.dropdownList = element), class: {
|
|
397
358
|
'dropdown-list': true,
|
|
398
359
|
[this.size]: true,
|
|
399
360
|
[this.getOpenDirection()]: true,
|
|
@@ -402,7 +363,7 @@ export class TdsDropdown {
|
|
|
402
363
|
'closed': !this.open,
|
|
403
364
|
[`animation-enter-${this.animation}`]: this.animation !== 'none' && this.open,
|
|
404
365
|
[`animation-exit-${this.animation}`]: this.animation !== 'none' && !this.open,
|
|
405
|
-
} }, h("slot", { key: '
|
|
366
|
+
} }, h("slot", { key: '0bbfde317a9c9f757236f9a3aa45bc7549cba134', onSlotchange: () => this.handleSlotChange() }), this.filterResult === 0 && this.noResultText !== '' && (h("div", { key: '4a2d556e26c1aedc6aad4ec1031e5290d4d6e28a', class: `no-result ${this.size}` }, this.noResultText))), this.helper && (h("div", { key: '506b816ed70834aef3fd3e22acc19567761d2645', class: `helper ${this.error ? 'error' : ''} ${this.disabled ? 'disabled' : ''}` }, this.error && h("tds-icon", { key: 'f890f8df6431d6a437459a245711731091cbe4ad', name: "error", size: "16px" }), this.helper))));
|
|
406
367
|
}
|
|
407
368
|
static get is() { return "tds-dropdown"; }
|
|
408
369
|
static get encapsulation() { return "shadow"; }
|
|
@@ -715,7 +676,8 @@ export class TdsDropdown {
|
|
|
715
676
|
"text": "Value of the dropdown. For multiselect, provide array of strings. For single select, provide a string."
|
|
716
677
|
},
|
|
717
678
|
"attribute": "value",
|
|
718
|
-
"reflect": false
|
|
679
|
+
"reflect": false,
|
|
680
|
+
"defaultValue": "null"
|
|
719
681
|
}
|
|
720
682
|
};
|
|
721
683
|
}
|
|
@@ -724,7 +686,8 @@ export class TdsDropdown {
|
|
|
724
686
|
"open": {},
|
|
725
687
|
"internalValue": {},
|
|
726
688
|
"filterResult": {},
|
|
727
|
-
"filterFocus": {}
|
|
689
|
+
"filterFocus": {},
|
|
690
|
+
"selectedOptions": {}
|
|
728
691
|
};
|
|
729
692
|
}
|
|
730
693
|
static get events() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
2
|
import generateUniqueId from "../../utils/generateUniqueId";
|
|
3
3
|
export class TdsSlider {
|
|
4
4
|
constructor() {
|
|
@@ -16,11 +16,6 @@ export class TdsSlider {
|
|
|
16
16
|
this.useSnapping = false;
|
|
17
17
|
this.supposedValueSlot = -1;
|
|
18
18
|
this.resizeObserverAdded = false;
|
|
19
|
-
this.resetEventListenerAdded = false;
|
|
20
|
-
this.resetToInitialValue = () => {
|
|
21
|
-
this.forceValueUpdate(this.initialValue);
|
|
22
|
-
this.reset();
|
|
23
|
-
};
|
|
24
19
|
this.label = '';
|
|
25
20
|
this.value = '0';
|
|
26
21
|
this.min = '0';
|
|
@@ -300,46 +295,26 @@ export class TdsSlider {
|
|
|
300
295
|
}
|
|
301
296
|
this.calculateThumbLeftFromValue(this.value);
|
|
302
297
|
this.updateTrack();
|
|
303
|
-
// Only set the initial value once:
|
|
304
|
-
if (!this.initialValue) {
|
|
305
|
-
this.initialValue = this.value;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
componentDidRender() {
|
|
309
|
-
// Only add the event listener once:
|
|
310
|
-
if (!this.resetEventListenerAdded) {
|
|
311
|
-
this.formElement = this.host.closest('form');
|
|
312
|
-
if (this.formElement) {
|
|
313
|
-
this.formElement.addEventListener('reset', this.resetToInitialValue);
|
|
314
|
-
this.resetEventListenerAdded = true;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
disconnectedCallback() {
|
|
319
|
-
if (this.resetEventListenerAdded && this.formElement) {
|
|
320
|
-
this.formElement.removeEventListener('reset', this.resetToInitialValue);
|
|
321
|
-
this.resetEventListenerAdded = false;
|
|
322
|
-
}
|
|
323
298
|
}
|
|
324
299
|
render() {
|
|
325
|
-
return (h("div", { key: '
|
|
300
|
+
return (h("div", { key: 'fd7d051192c33b19e8c68cbeaa50ea43149457bb', class: {
|
|
326
301
|
'tds-slider-wrapper': true,
|
|
327
302
|
'read-only': this.readOnly,
|
|
328
|
-
} }, h("input", { key: '
|
|
303
|
+
} }, h("input", { key: 'd2fe02893f865f5791736cb5f05b5bcd2494e471', class: "tds-slider-native-element", type: "range", name: this.name, min: this.min, max: this.max, value: this.value, disabled: this.disabled }), h("div", { key: '2d436a5654cb20923cd20ed61f9449bd0705edd2', class: {
|
|
329
304
|
'tds-slider': true,
|
|
330
305
|
'disabled': this.disabled,
|
|
331
306
|
'tds-slider-small': this.useSmall,
|
|
332
307
|
}, ref: (el) => {
|
|
333
308
|
this.wrapperElement = el;
|
|
334
|
-
} }, h("label", { key: '
|
|
309
|
+
} }, h("label", { key: 'd9d444d15acabbbc23c7b7633e5312f405ff9120', class: this.showTickNumbers && 'offset' }, this.label), this.useInput && (h("div", { key: '2f0d0419138851724891e2ab04fef2f3b3e099f1', class: "tds-slider__input-values" }, h("div", { key: '7f23007c0f4a1aa6358ffa7c5aaae027d0927b63', class: "tds-slider__input-value min-value" }, this.min))), this.useControls && (h("div", { key: 'df4a00a40c541b83aa8459dfcdaf22c348e2c80a', class: "tds-slider__controls" }, h("div", { key: '96cc419d369098137895b725f97a8fa3d7d50dfc', class: "tds-slider__control tds-slider__control-minus", onClick: (event) => this.stepLeft(event) }, h("tds-icon", { key: '09ed43c9f2fe81baeada6a07e4cba18027f04ba1', name: "minus", size: "16px" })))), h("div", { key: '402647683b57076bd4ac3ce3d754585a89a48e08', class: "tds-slider-inner" }, this.tickValues.length > 0 && (h("div", { key: 'd80c648eca47c7e52725e967a32fe4a4692a5729', class: "tds-slider__value-dividers-wrapper" }, h("div", { key: '030106df49f12a55c1b32a9c1c257f449629644a', class: "tds-slider__value-dividers" }, this.tickValues.map((value) => (h("div", { class: "tds-slider__value-divider" }, this.showTickNumbers && h("span", null, value))))))), h("div", { key: 'fef7013f82a191c32bc3a4d297f5e10a4db127a1', class: "tds-slider__track", ref: (el) => {
|
|
335
310
|
this.trackElement = el;
|
|
336
|
-
}, tabindex: this.disabled ? '-1' : '0' }, h("div", { key: '
|
|
311
|
+
}, tabindex: this.disabled ? '-1' : '0' }, h("div", { key: '24a583182c45114d1e011bffef0f81f1e4f93a36', class: "tds-slider__track-fill", ref: (el) => {
|
|
337
312
|
this.trackFillElement = el;
|
|
338
|
-
} }), h("div", { key: '
|
|
313
|
+
} }), h("div", { key: '3bea53237beb92f41264386fb5ac181d1e9966a4', class: "tds-slider__thumb", ref: (el) => {
|
|
339
314
|
this.thumbElement = el;
|
|
340
|
-
}, onMouseDown: () => this.grabThumb(), onTouchStart: () => this.grabThumb() }, this.tooltip && (h("div", { key: '
|
|
315
|
+
}, onMouseDown: () => this.grabThumb(), onTouchStart: () => this.grabThumb() }, this.tooltip && (h("div", { key: '3ac44629cad3b03524602f9babe7fa4582b38660', class: "tds-slider__value" }, this.value, h("svg", { key: '5adbbcc274555d14454c5329f0eea8c072a3db2c', width: "18", height: "14", viewBox: "0 0 18 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: '248b1f8521b89be4214631e411c0ba9c7bcc07a8', d: "M8.15882 12.6915L0.990487 1.54076C0.562658 0.875246 1.0405 0 1.83167 0H16.1683C16.9595 0 17.4373 0.875246 17.0095 1.54076L9.84118 12.6915C9.44754 13.3038 8.55246 13.3038 8.15882 12.6915Z", fill: "currentColor" })))), h("div", { key: 'bc778a9ccd25a5229aa7685cc6c22ed5385b9d98', class: "tds-slider__thumb-inner", ref: (el) => {
|
|
341
316
|
this.thumbInnerElement = el;
|
|
342
|
-
} })))), this.useInput && (h("div", { key: '
|
|
317
|
+
} })))), this.useInput && (h("div", { key: '077ffffeb0986504a2c9fc4e1b08095ec689402c', class: "tds-slider__input-values" }, h("div", { key: '74a528a286e2b49a6739c5817cca8a0436b908b9', class: "tds-slider__input-value", onClick: (event) => this.stepLeft(event) }, this.max), h("div", { key: 'af2a647636c8eecba19637aa92ddda37adc52a1b', class: "tds-slider__input-field-wrapper" }, h("input", { key: '02701d15de6119994f7be13b9c9ac69ae6f2269b', size: this.calculateInputSizeFromMax(), class: "tds-slider__input-field", value: this.value, readOnly: this.readOnly, onBlur: (event) => this.updateSliderValueOnInputChange(event), onKeyDown: (event) => this.handleInputFieldEnterPress(event), type: "number", min: this.min, max: this.max })))), this.useControls && (h("div", { key: 'ef215ef613c381601674d4bb7dbea583a3ddde2a', class: "tds-slider__controls" }, h("div", { key: '4e553194348daf32529c9c8cedc32b0686ac32ff', class: "tds-slider__control tds-slider__control-plus", onClick: (event) => this.stepRight(event) }, h("tds-icon", { key: 'd5d67ea7ff64ed19d28bd078acad56ebda742f93', name: "plus", size: "16px" })))))));
|
|
343
318
|
}
|
|
344
319
|
static get is() { return "tds-slider"; }
|
|
345
320
|
static get originalStyleUrls() {
|
|
@@ -698,7 +673,6 @@ export class TdsSlider {
|
|
|
698
673
|
}
|
|
699
674
|
};
|
|
700
675
|
}
|
|
701
|
-
static get elementRef() { return "host"; }
|
|
702
676
|
static get watchers() {
|
|
703
677
|
return [{
|
|
704
678
|
"propName": "value",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { p as proxyCustomElement, H, d as createEvent, h, c as Host } from './p-28ef5186.js';
|
|
2
|
-
import { d as defineCustomElement$2 } from './p-
|
|
2
|
+
import { d as defineCustomElement$2 } from './p-e4d7c655.js';
|
|
3
3
|
import { d as defineCustomElement$1 } from './p-18c1245b.js';
|
|
4
4
|
|
|
5
5
|
const dropdownOptionCss = ":host{box-sizing:border-box;display:block;background-color:var(--tds-dropdown-option-background)}:host *{box-sizing:border-box}:host .dropdown-option{color:var(--tds-dropdown-option-color);border-bottom:1px solid var(--tds-dropdown-option-border);font:var(--tds-detail-02);letter-spacing:var(--tds-detail-02-ls);overflow-wrap:anywhere;transition:background-color var(--tds-motion-duration-fast-02) var(--tds-motion-easing-scania)}:host .dropdown-option.selected{background-color:var(--tds-dropdown-option-background-selected)}:host .dropdown-option.disabled{color:var(--tds-dropdown-option-color-disabled)}:host .dropdown-option button:focus{outline:2px solid var(--tds-blue-400);outline-offset:-2px}:host .dropdown-option button{all:unset;width:100%}:host .dropdown-option button.lg{padding:19px 0 20px}:host .dropdown-option button.md{padding:15px 0 16px}:host .dropdown-option button.sm{padding:11px 0 12px}:host .dropdown-option button.xs{padding:7px 0 8px}:host .dropdown-option button .single-select{display:flex;align-items:center;justify-content:space-between;padding:0 16px}:host .dropdown-option .multiselect{width:100%;height:100%}:host .dropdown-option .multiselect tds-checkbox{display:flex;height:100%;width:100%}:host .dropdown-option .multiselect tds-checkbox.lg{padding:15px 16px 16px}:host .dropdown-option .multiselect tds-checkbox.md{padding:11px 16px 12px}:host .dropdown-option .multiselect tds-checkbox.sm{padding:7px 16px 8px}:host .dropdown-option .multiselect tds-checkbox.xs{padding:7px 16px 8px}:host .dropdown-option:hover{background-color:var(--tds-dropdown-option-background-hover);cursor:pointer}:host .dropdown-option:hover.disabled{background-color:var(--tds-dropdown-option-background);cursor:not-allowed}:host([hidden]){display:none}";
|
|
@@ -72,39 +72,13 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
72
72
|
this.tdsBlur = createEvent(this, "tdsBlur", 6);
|
|
73
73
|
this.tdsInput = createEvent(this, "tdsInput", 6);
|
|
74
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
75
|
this.setDefaultOption = () => {
|
|
83
76
|
if (this.defaultValue) {
|
|
84
|
-
const children = Array.from(this.host.children).filter((element) => element.tagName === 'TDS-DROPDOWN-OPTION');
|
|
85
|
-
if (children.length === 0) {
|
|
86
|
-
console.warn('TDS DROPDOWN: No options found. Disregard if loading data asynchronously.');
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
77
|
const defaultValues = this.multiselect
|
|
90
78
|
? new Set(this.defaultValue.split(','))
|
|
91
79
|
: [this.defaultValue];
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const element = childrenMap.get(value);
|
|
95
|
-
if (element) {
|
|
96
|
-
element.setSelected(true);
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
return false;
|
|
100
|
-
});
|
|
101
|
-
if (matchedValues.length > 0) {
|
|
102
|
-
this.value = [...new Set(this.value ? [...this.value, ...matchedValues] : matchedValues)];
|
|
103
|
-
this.setValueAttribute();
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
console.warn(`TDS DROPDOWN: No matching option found for defaultValue "${this.defaultValue}"`);
|
|
107
|
-
}
|
|
80
|
+
const normalizedValues = Array.from(defaultValues);
|
|
81
|
+
this.updateDropdownState(normalizedValues);
|
|
108
82
|
}
|
|
109
83
|
};
|
|
110
84
|
this.getChildren = () => {
|
|
@@ -217,12 +191,6 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
217
191
|
this.handleBlur = (event) => {
|
|
218
192
|
this.tdsBlur.emit(event);
|
|
219
193
|
};
|
|
220
|
-
this.resetInput = () => {
|
|
221
|
-
const inputEl = this.host.querySelector('input');
|
|
222
|
-
if (inputEl) {
|
|
223
|
-
this.reset();
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
194
|
this.name = undefined;
|
|
227
195
|
this.disabled = false;
|
|
228
196
|
this.helper = undefined;
|
|
@@ -239,70 +207,75 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
239
207
|
this.normalizeText = true;
|
|
240
208
|
this.noResultText = 'No result';
|
|
241
209
|
this.defaultValue = undefined;
|
|
242
|
-
this.value =
|
|
210
|
+
this.value = null;
|
|
243
211
|
this.open = false;
|
|
244
212
|
this.internalValue = undefined;
|
|
245
213
|
this.filterResult = undefined;
|
|
246
214
|
this.filterFocus = undefined;
|
|
215
|
+
this.selectedOptions = [];
|
|
247
216
|
}
|
|
248
217
|
handleValueChange(newValue) {
|
|
249
|
-
//
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
? [this.value]
|
|
255
|
-
: [];
|
|
256
|
-
// Check if the new value is different from the current value
|
|
257
|
-
const hasChanged = newValueArray.length !== currentValueArray.length ||
|
|
258
|
-
newValueArray.some((val, index) => val !== currentValueArray[index]);
|
|
259
|
-
if (hasChanged) {
|
|
260
|
-
// Proceed with updating selections and emitting changes
|
|
261
|
-
this.updateSelections(newValueArray);
|
|
262
|
-
this.handleChange();
|
|
218
|
+
// Normalize to array
|
|
219
|
+
const normalizedValue = this.normalizeValue(newValue);
|
|
220
|
+
// Only update if actually changed
|
|
221
|
+
if (this.hasValueChanged(normalizedValue, this.selectedOptions)) {
|
|
222
|
+
this.updateDropdownState(normalizedValue);
|
|
263
223
|
}
|
|
264
224
|
}
|
|
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
|
-
|
|
290
|
-
|
|
291
|
-
|
|
225
|
+
normalizeValue(value) {
|
|
226
|
+
if (!value)
|
|
227
|
+
return [];
|
|
228
|
+
return Array.isArray(value) ? value : [value];
|
|
229
|
+
}
|
|
230
|
+
hasValueChanged(newValue, currentValue) {
|
|
231
|
+
if (newValue.length !== currentValue.length)
|
|
232
|
+
return true;
|
|
233
|
+
return newValue.some((val) => !currentValue.includes(val));
|
|
234
|
+
}
|
|
235
|
+
updateDropdownState(values) {
|
|
236
|
+
// Update internal state
|
|
237
|
+
this.selectedOptions = this.validateValues(values);
|
|
238
|
+
// Update DOM
|
|
239
|
+
this.updateOptionElements();
|
|
240
|
+
// Update display value
|
|
241
|
+
this.updateDisplayValue();
|
|
242
|
+
// Emit change event
|
|
243
|
+
this.emitChange();
|
|
244
|
+
// Update value attribute
|
|
245
|
+
this.setValueAttribute();
|
|
246
|
+
}
|
|
247
|
+
validateValues(values) {
|
|
248
|
+
return values.filter((val) => {
|
|
249
|
+
var _a;
|
|
250
|
+
const isValid = (_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.some((element) => element.value === val);
|
|
251
|
+
if (!isValid) {
|
|
252
|
+
console.warn(`Option with value "${val}" does not exist`);
|
|
292
253
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
254
|
+
return isValid;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
updateOptionElements() {
|
|
258
|
+
var _a;
|
|
259
|
+
(_a = this.getChildren()) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
|
|
260
|
+
element.setSelected(this.selectedOptions.includes(element.value));
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
updateDisplayValue() {
|
|
264
|
+
this.internalValue = this.getSelectedChildrenLabels().join(', ');
|
|
302
265
|
if (this.filter && this.inputElement) {
|
|
303
266
|
this.inputElement.value = this.internalValue;
|
|
304
267
|
}
|
|
305
|
-
|
|
268
|
+
}
|
|
269
|
+
emitChange() {
|
|
270
|
+
// Update the value prop to match validated state
|
|
271
|
+
this.value = this.multiselect ? this.selectedOptions : this.selectedOptions[0] || null;
|
|
272
|
+
const value = this.multiselect
|
|
273
|
+
? this.selectedOptions.join(',')
|
|
274
|
+
: this.selectedOptions[0] || null;
|
|
275
|
+
this.tdsChange.emit({
|
|
276
|
+
name: this.name,
|
|
277
|
+
value: value !== null && value !== void 0 ? value : null,
|
|
278
|
+
});
|
|
306
279
|
}
|
|
307
280
|
async setValue(value) {
|
|
308
281
|
this.value = value;
|
|
@@ -400,23 +373,11 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
400
373
|
this.value = value;
|
|
401
374
|
}
|
|
402
375
|
}
|
|
403
|
-
componentDidRender() {
|
|
404
|
-
const form = this.host.closest('form');
|
|
405
|
-
if (form) {
|
|
406
|
-
form.addEventListener('reset', this.resetInput);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
disconnectedCallback() {
|
|
410
|
-
const form = this.host.closest('form');
|
|
411
|
-
if (form) {
|
|
412
|
-
form.removeEventListener('reset', this.resetInput);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
376
|
render() {
|
|
416
377
|
var _a, _b, _c;
|
|
417
378
|
const valueArray = Array.isArray(this.value) ? this.value : this.value ? [this.value] : [];
|
|
418
379
|
appendHiddenInput(this.host, this.name, valueArray.map((value) => value).toString(), this.disabled);
|
|
419
|
-
return (h(Host, { key: '
|
|
380
|
+
return (h(Host, { key: 'c3a3742ba6f875aee1b9e7abb4ab2c2b2331d3fc', role: "select", class: `${this.modeVariant ? `tds-mode-variant-${this.modeVariant}` : ''}` }, this.label && this.labelPosition === 'outside' && (h("div", { key: '0b45d4e910577e1cfd350f6f60e544839f905865', class: `label-outside ${this.disabled ? 'disabled' : ''}` }, this.label)), h("div", { key: '3557975c254df99c9f97dac71a6d9e66268c09f2', class: `dropdown-select ${this.size} ${this.disabled ? 'disabled' : ''}` }, this.filter ? (h("div", { class: {
|
|
420
381
|
filter: true,
|
|
421
382
|
focus: this.filterFocus,
|
|
422
383
|
disabled: this.disabled,
|
|
@@ -458,7 +419,7 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
458
419
|
label-inside-as-placeholder
|
|
459
420
|
${this.size}
|
|
460
421
|
${((_b = this.value) === null || _b === void 0 ? void 0 : _b.length) ? 'selected' : ''}
|
|
461
|
-
` }, this.label)), h("div", { class: `placeholder ${this.size}` }, ((_c = this.value) === null || _c === void 0 ? void 0 : _c.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: '
|
|
422
|
+
` }, this.label)), h("div", { class: `placeholder ${this.size}` }, ((_c = this.value) === null || _c === void 0 ? void 0 : _c.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: 'bf74f7277ac93324469c9f371a1a41598366d833', ref: (element) => (this.dropdownList = element), class: {
|
|
462
423
|
'dropdown-list': true,
|
|
463
424
|
[this.size]: true,
|
|
464
425
|
[this.getOpenDirection()]: true,
|
|
@@ -467,7 +428,7 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
467
428
|
'closed': !this.open,
|
|
468
429
|
[`animation-enter-${this.animation}`]: this.animation !== 'none' && this.open,
|
|
469
430
|
[`animation-exit-${this.animation}`]: this.animation !== 'none' && !this.open,
|
|
470
|
-
} }, h("slot", { key: '
|
|
431
|
+
} }, h("slot", { key: '0bbfde317a9c9f757236f9a3aa45bc7549cba134', onSlotchange: () => this.handleSlotChange() }), this.filterResult === 0 && this.noResultText !== '' && (h("div", { key: '4a2d556e26c1aedc6aad4ec1031e5290d4d6e28a', class: `no-result ${this.size}` }, this.noResultText))), this.helper && (h("div", { key: '506b816ed70834aef3fd3e22acc19567761d2645', class: `helper ${this.error ? 'error' : ''} ${this.disabled ? 'disabled' : ''}` }, this.error && h("tds-icon", { key: 'f890f8df6431d6a437459a245711731091cbe4ad', name: "error", size: "16px" }), this.helper))));
|
|
471
432
|
}
|
|
472
433
|
get host() { return this; }
|
|
473
434
|
static get watchers() { return {
|
|
@@ -497,6 +458,7 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
|
|
|
497
458
|
"internalValue": [32],
|
|
498
459
|
"filterResult": [32],
|
|
499
460
|
"filterFocus": [32],
|
|
461
|
+
"selectedOptions": [32],
|
|
500
462
|
"setValue": [64],
|
|
501
463
|
"reset": [64],
|
|
502
464
|
"removeValue": [64],
|