@scania/tegel 1.23.0-value-prop-beta.0 → 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.
Files changed (34) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/tds-checkbox.cjs.entry.js +2 -9
  3. package/dist/cjs/tds-dropdown_2.cjs.entry.js +62 -82
  4. package/dist/cjs/tds-slider.cjs.entry.js +7 -33
  5. package/dist/cjs/tegel.cjs.js +1 -1
  6. package/dist/collection/components/checkbox/checkbox.js +3 -19
  7. package/dist/collection/components/dropdown/dropdown.js +66 -84
  8. package/dist/collection/components/slider/slider.js +8 -34
  9. package/dist/components/{p-e7868876.js → p-462b77e8.js} +1 -1
  10. package/dist/components/{p-ca4b945d.js → p-4d8f8d5c.js} +63 -82
  11. package/dist/components/{p-d921fe75.js → p-e4d7c655.js} +3 -10
  12. package/dist/components/tds-checkbox.js +1 -1
  13. package/dist/components/tds-dropdown-option.js +1 -1
  14. package/dist/components/tds-dropdown.js +1 -1
  15. package/dist/components/tds-slider.js +7 -33
  16. package/dist/components/tds-table-body-row.js +1 -1
  17. package/dist/components/tds-table-footer.js +3 -3
  18. package/dist/components/tds-table-header.js +1 -1
  19. package/dist/esm/loader.js +1 -1
  20. package/dist/esm/tds-checkbox.entry.js +2 -9
  21. package/dist/esm/tds-dropdown_2.entry.js +62 -82
  22. package/dist/esm/tds-slider.entry.js +8 -34
  23. package/dist/esm/tegel.js +1 -1
  24. package/dist/tegel/p-0c05887d.entry.js +1 -0
  25. package/dist/tegel/p-a464920f.entry.js +1 -0
  26. package/dist/tegel/p-f91c6e9d.entry.js +1 -0
  27. package/dist/tegel/tegel.esm.js +1 -1
  28. package/dist/types/components/checkbox/checkbox.d.ts +0 -2
  29. package/dist/types/components/dropdown/dropdown.d.ts +8 -2
  30. package/dist/types/components/slider/slider.d.ts +0 -7
  31. package/package.json +1 -1
  32. package/dist/tegel/p-2557b79b.entry.js +0 -1
  33. package/dist/tegel/p-6a52ed63.entry.js +0 -1
  34. package/dist/tegel/p-e252ba6e.entry.js +0 -1
@@ -1,4 +1,4 @@
1
- import { h, } from "@stencil/core";
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: '068b73081ab2b1b24d58fd2afd70f2b0e4308745', class: "tds-checkbox" }, h("input", { key: '97bd225b10dea56b8166ce3d5c2e4569a7dc76f9',
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: '9cfe0411c9b26d12229de7fdb9421b333da0199c', htmlFor: this.checkboxId }, h("slot", { key: '17d2e45ddf05aa409926f3df82caab7a4f110b72', name: "label" }))));
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 childrenMap = new Map(children.map((element) => [element.value, element]));
28
- const matchedValues = Array.from(defaultValues).filter((value) => {
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 = () => {
@@ -168,69 +142,75 @@ export class TdsDropdown {
168
142
  this.normalizeText = true;
169
143
  this.noResultText = 'No result';
170
144
  this.defaultValue = undefined;
171
- this.value = undefined;
145
+ this.value = null;
172
146
  this.open = false;
173
147
  this.internalValue = undefined;
174
148
  this.filterResult = undefined;
175
149
  this.filterFocus = undefined;
150
+ this.selectedOptions = [];
176
151
  }
177
152
  handleValueChange(newValue) {
178
- if (newValue === undefined)
179
- return;
180
- // Ensure consistent internal array representation
181
- const valueArray = Array.isArray(newValue) ? newValue : newValue ? [newValue] : null;
182
- // Handle multiselect validation
183
- if (!this.multiselect && Array.isArray(valueArray) && valueArray.length > 1) {
184
- console.warn('Tried to select multiple items, but multiselect is not enabled.');
185
- // Coerce to single value for non-multiselect
186
- this.value = valueArray[0];
187
- return;
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);
188
158
  }
189
- // Ensure value is always array internally for backward compatibility
190
- this.updateSelections(valueArray);
191
- this.handleChange();
192
159
  }
193
- updateSelections(valueArray) {
194
- // Reset current selections
195
- this.getChildren().forEach((element) => {
196
- element.setSelected(false);
197
- });
198
- if (valueArray) {
199
- // Validate and filter values
200
- const validValues = valueArray.filter((val) => {
201
- const optionExists = this.getChildren().some((element) => element.value === val);
202
- if (!optionExists) {
203
- console.warn(`Option with value "${val}" does not exist`);
204
- }
205
- return optionExists;
206
- });
207
- // Update internal state and selections
208
- this.internalValue = validValues.join(', ');
209
- this.getChildren().forEach((element) => {
210
- if (validValues.includes(element.value)) {
211
- element.setSelected(true);
212
- }
213
- });
214
- // Update value prop with validated values
215
- if (this.multiselect) {
216
- this.value = validValues;
217
- }
218
- else {
219
- this.value = validValues[0] || null;
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`);
220
188
  }
221
- }
222
- else {
223
- // Handle null/undefined case
224
- this.internalValue = '';
225
- this.value = this.multiselect ? [] : null;
226
- }
227
- // Emit change events
228
- this.handleChange();
229
- // Update filter input if present
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(', ');
230
200
  if (this.filter && this.inputElement) {
231
201
  this.inputElement.value = this.internalValue;
232
202
  }
233
- this.setValueAttribute();
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
+ });
234
214
  }
235
215
  async setValue(value) {
236
216
  this.value = value;
@@ -332,7 +312,7 @@ export class TdsDropdown {
332
312
  var _a, _b, _c;
333
313
  const valueArray = Array.isArray(this.value) ? this.value : this.value ? [this.value] : [];
334
314
  appendHiddenInput(this.host, this.name, valueArray.map((value) => value).toString(), this.disabled);
335
- return (h(Host, { key: '2d1d0d7551c4f5a3197538a21b245b06abb95a5b', role: "select", class: `${this.modeVariant ? `tds-mode-variant-${this.modeVariant}` : ''}` }, this.label && this.labelPosition === 'outside' && (h("div", { key: '44bf815fc834febcf5bf90aeabeb4ff75ca74e0b', class: `label-outside ${this.disabled ? 'disabled' : ''}` }, this.label)), h("div", { key: 'fe8bddaad6f52c6860a8a3b02db796d927553c64', class: `dropdown-select ${this.size} ${this.disabled ? 'disabled' : ''}` }, this.filter ? (h("div", { class: {
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: {
336
316
  filter: true,
337
317
  focus: this.filterFocus,
338
318
  disabled: this.disabled,
@@ -374,7 +354,7 @@ export class TdsDropdown {
374
354
  label-inside-as-placeholder
375
355
  ${this.size}
376
356
  ${((_b = this.value) === null || _b === void 0 ? void 0 : _b.length) ? 'selected' : ''}
377
- ` }, 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: '5a725e0e42ada175ff588849debe814f4558f907', ref: (element) => (this.dropdownList = element), class: {
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: {
378
358
  'dropdown-list': true,
379
359
  [this.size]: true,
380
360
  [this.getOpenDirection()]: true,
@@ -383,7 +363,7 @@ export class TdsDropdown {
383
363
  'closed': !this.open,
384
364
  [`animation-enter-${this.animation}`]: this.animation !== 'none' && this.open,
385
365
  [`animation-exit-${this.animation}`]: this.animation !== 'none' && !this.open,
386
- } }, h("slot", { key: '7cece8ee2247cf1249719673734408216b1b9ad6', onSlotchange: () => this.handleSlotChange() }), this.filterResult === 0 && this.noResultText !== '' && (h("div", { key: 'c8e1bfb413f6247710b34707e6e86e454b04739c', class: `no-result ${this.size}` }, this.noResultText))), this.helper && (h("div", { key: '90dcb3ed5268866c95f88bb53a9a066451ebc505', class: `helper ${this.error ? 'error' : ''} ${this.disabled ? 'disabled' : ''}` }, this.error && h("tds-icon", { key: 'a216d63de9d7d6011c4bce0ee0b64f6ea90fa4e4', name: "error", size: "16px" }), this.helper))));
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))));
387
367
  }
388
368
  static get is() { return "tds-dropdown"; }
389
369
  static get encapsulation() { return "shadow"; }
@@ -696,7 +676,8 @@ export class TdsDropdown {
696
676
  "text": "Value of the dropdown. For multiselect, provide array of strings. For single select, provide a string."
697
677
  },
698
678
  "attribute": "value",
699
- "reflect": false
679
+ "reflect": false,
680
+ "defaultValue": "null"
700
681
  }
701
682
  };
702
683
  }
@@ -705,7 +686,8 @@ export class TdsDropdown {
705
686
  "open": {},
706
687
  "internalValue": {},
707
688
  "filterResult": {},
708
- "filterFocus": {}
689
+ "filterFocus": {},
690
+ "selectedOptions": {}
709
691
  };
710
692
  }
711
693
  static get events() {
@@ -1,4 +1,4 @@
1
- import { h, } from "@stencil/core";
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: 'ed4c71d1701e0711d8b01c015f137f6a3f10457e', class: {
300
+ return (h("div", { key: 'fd7d051192c33b19e8c68cbeaa50ea43149457bb', class: {
326
301
  'tds-slider-wrapper': true,
327
302
  'read-only': this.readOnly,
328
- } }, h("input", { key: '7d85ba109ec41e45a4ced646cfe092832b2013a7', 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: '7c32efe653a6437068026e0b612bd1cdb0fd580d', class: {
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: '5561410214fda42ddb4553084f312de9943f825b', class: this.showTickNumbers && 'offset' }, this.label), this.useInput && (h("div", { key: '37340de05febbca285f031bd8df7d9c2588e315d', class: "tds-slider__input-values" }, h("div", { key: 'e973831529eb93eb0b0da6c5f92bd838dfb9bcdb', class: "tds-slider__input-value min-value" }, this.min))), this.useControls && (h("div", { key: '1a710d2d1ffac7533f9bae2908d4341d3b40e2f0', class: "tds-slider__controls" }, h("div", { key: '0a741834782d8e69a7d55e6cd87a3fdf4938d744', class: "tds-slider__control tds-slider__control-minus", onClick: (event) => this.stepLeft(event) }, h("tds-icon", { key: '8c67943ac2e15d742726e76c2b4c029d15c20f32', name: "minus", size: "16px" })))), h("div", { key: '96c4229007fbe882e106bcc3deb34f504c9604e3', class: "tds-slider-inner" }, this.tickValues.length > 0 && (h("div", { key: '905fc1a02070f5419f76ec5d60d8f55d89d4650b', class: "tds-slider__value-dividers-wrapper" }, h("div", { key: 'd2ccbea1b6e26ab1855c81e71730bebea0da37d8', 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: '30c9b4bb6f59631d443345ee6d1edf1973a83d0b', class: "tds-slider__track", ref: (el) => {
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: '7acbccae98c481c4cfaeb2dc66d67a2e19575b93', class: "tds-slider__track-fill", ref: (el) => {
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: '46a5c3135c5f765d5fb0845372dc3854586fa44d', class: "tds-slider__thumb", ref: (el) => {
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: 'd39cd29d1e6302f8bd4a3d827797f8822e24b84d', class: "tds-slider__value" }, this.value, h("svg", { key: '5946f90b70b2afb2efc7f3a3bc5817a82ac3ca4a', width: "18", height: "14", viewBox: "0 0 18 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { key: '9456df642aca39b94b17bb529ca02e2d6a2fde6c', 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: 'b4ca73a085f837d7e87e3334b8e58e5638125118', class: "tds-slider__thumb-inner", ref: (el) => {
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: '6574286ac7764807fd1e18875d6fa39ab7f7b304', class: "tds-slider__input-values" }, h("div", { key: '57a92adf59551f551c4ae06355c276a69b34028a', class: "tds-slider__input-value", onClick: (event) => this.stepLeft(event) }, this.max), h("div", { key: '0e1632ca8c9510177d349147749e3162aa46f219', class: "tds-slider__input-field-wrapper" }, h("input", { key: '094d194bce54d1073a5d657f7bc3f30107f5fe41', 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: '207398a3fd02e11f09c70ebbb8b293d6c16afd1f', class: "tds-slider__controls" }, h("div", { key: 'ca93ce9a55d0db25a3eaefd6e4dbc53106afc895', class: "tds-slider__control tds-slider__control-plus", onClick: (event) => this.stepRight(event) }, h("tds-icon", { key: '6ab123f8701fdd93580a61c500ae6da658b547fd', name: "plus", size: "16px" })))))));
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-d921fe75.js';
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 childrenMap = new Map(children.map((element) => [element.value, element]));
93
- const matchedValues = Array.from(defaultValues).filter((value) => {
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 = () => {
@@ -233,69 +207,75 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
233
207
  this.normalizeText = true;
234
208
  this.noResultText = 'No result';
235
209
  this.defaultValue = undefined;
236
- this.value = undefined;
210
+ this.value = null;
237
211
  this.open = false;
238
212
  this.internalValue = undefined;
239
213
  this.filterResult = undefined;
240
214
  this.filterFocus = undefined;
215
+ this.selectedOptions = [];
241
216
  }
242
217
  handleValueChange(newValue) {
243
- if (newValue === undefined)
244
- return;
245
- // Ensure consistent internal array representation
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;
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);
253
223
  }
254
- // Ensure value is always array internally for backward compatibility
255
- this.updateSelections(valueArray);
256
- this.handleChange();
257
224
  }
258
- updateSelections(valueArray) {
259
- // Reset current selections
260
- this.getChildren().forEach((element) => {
261
- element.setSelected(false);
262
- });
263
- if (valueArray) {
264
- // Validate and filter values
265
- const validValues = valueArray.filter((val) => {
266
- const optionExists = this.getChildren().some((element) => element.value === val);
267
- if (!optionExists) {
268
- console.warn(`Option with value "${val}" does not exist`);
269
- }
270
- return optionExists;
271
- });
272
- // Update internal state and selections
273
- this.internalValue = validValues.join(', ');
274
- this.getChildren().forEach((element) => {
275
- if (validValues.includes(element.value)) {
276
- element.setSelected(true);
277
- }
278
- });
279
- // Update value prop with validated values
280
- if (this.multiselect) {
281
- this.value = validValues;
282
- }
283
- else {
284
- this.value = validValues[0] || null;
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`);
285
253
  }
286
- }
287
- else {
288
- // Handle null/undefined case
289
- this.internalValue = '';
290
- this.value = this.multiselect ? [] : null;
291
- }
292
- // Emit change events
293
- this.handleChange();
294
- // Update filter input if present
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(', ');
295
265
  if (this.filter && this.inputElement) {
296
266
  this.inputElement.value = this.internalValue;
297
267
  }
298
- this.setValueAttribute();
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
+ });
299
279
  }
300
280
  async setValue(value) {
301
281
  this.value = value;
@@ -397,7 +377,7 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
397
377
  var _a, _b, _c;
398
378
  const valueArray = Array.isArray(this.value) ? this.value : this.value ? [this.value] : [];
399
379
  appendHiddenInput(this.host, this.name, valueArray.map((value) => value).toString(), this.disabled);
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: {
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: {
401
381
  filter: true,
402
382
  focus: this.filterFocus,
403
383
  disabled: this.disabled,
@@ -439,7 +419,7 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
439
419
  label-inside-as-placeholder
440
420
  ${this.size}
441
421
  ${((_b = this.value) === null || _b === void 0 ? void 0 : _b.length) ? 'selected' : ''}
442
- ` }, 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: '5a725e0e42ada175ff588849debe814f4558f907', ref: (element) => (this.dropdownList = element), class: {
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: {
443
423
  'dropdown-list': true,
444
424
  [this.size]: true,
445
425
  [this.getOpenDirection()]: true,
@@ -448,7 +428,7 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
448
428
  'closed': !this.open,
449
429
  [`animation-enter-${this.animation}`]: this.animation !== 'none' && this.open,
450
430
  [`animation-exit-${this.animation}`]: this.animation !== 'none' && !this.open,
451
- } }, h("slot", { key: '7cece8ee2247cf1249719673734408216b1b9ad6', onSlotchange: () => this.handleSlotChange() }), this.filterResult === 0 && this.noResultText !== '' && (h("div", { key: 'c8e1bfb413f6247710b34707e6e86e454b04739c', class: `no-result ${this.size}` }, this.noResultText))), this.helper && (h("div", { key: '90dcb3ed5268866c95f88bb53a9a066451ebc505', class: `helper ${this.error ? 'error' : ''} ${this.disabled ? 'disabled' : ''}` }, this.error && h("tds-icon", { key: 'a216d63de9d7d6011c4bce0ee0b64f6ea90fa4e4', name: "error", size: "16px" }), this.helper))));
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))));
452
432
  }
453
433
  get host() { return this; }
454
434
  static get watchers() { return {
@@ -478,6 +458,7 @@ const TdsDropdown = /*@__PURE__*/ proxyCustomElement(class TdsDropdown extends H
478
458
  "internalValue": [32],
479
459
  "filterResult": [32],
480
460
  "filterFocus": [32],
461
+ "selectedOptions": [32],
481
462
  "setValue": [64],
482
463
  "reset": [64],
483
464
  "removeValue": [64],
@@ -49,19 +49,12 @@ const TdsCheckbox = /*@__PURE__*/ proxyCustomElement(class TdsCheckbox extends H
49
49
  handleBlur(event) {
50
50
  this.tdsBlur.emit(event);
51
51
  }
52
- /** Listens for a reset event inside a form */
53
- handleFormReset(event) {
54
- if (this.host.closest('form') === event.target) {
55
- this.checked = false;
56
- this.indeterminate = false;
57
- }
58
- }
59
52
  render() {
60
- return (h("div", { key: '068b73081ab2b1b24d58fd2afd70f2b0e4308745', class: "tds-checkbox" }, h("input", { key: '97bd225b10dea56b8166ce3d5c2e4569a7dc76f9',
53
+ return (h("div", { key: '0efb982ab13c1d75681614675b649e010707b701', class: "tds-checkbox" }, h("input", { key: '834b29962978ea1cf7249018e6b7eea2417da5f4',
61
54
  // eslint-disable-next-line no-return-assign
62
55
  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: () => {
63
56
  this.handleChange();
64
- } }), h("label", { key: '9cfe0411c9b26d12229de7fdb9421b333da0199c', htmlFor: this.checkboxId }, h("slot", { key: '17d2e45ddf05aa409926f3df82caab7a4f110b72', name: "label" }))));
57
+ } }), h("label", { key: '2150346b336440768beac655de035bf470f9e492', htmlFor: this.checkboxId }, h("slot", { key: 'df61654810e46b8707709d86bae7bdfd627724ee', name: "label" }))));
65
58
  }
66
59
  get host() { return this; }
67
60
  static get watchers() { return {
@@ -77,7 +70,7 @@ const TdsCheckbox = /*@__PURE__*/ proxyCustomElement(class TdsCheckbox extends H
77
70
  "indeterminate": [1028],
78
71
  "value": [1],
79
72
  "toggleCheckbox": [64]
80
- }, [[4, "reset", "handleFormReset"]], {
73
+ }, undefined, {
81
74
  "indeterminate": ["handleIndeterminateState"]
82
75
  }]);
83
76
  function defineCustomElement() {
@@ -1,4 +1,4 @@
1
- import { T as TdsCheckbox$1, d as defineCustomElement$1 } from './p-d921fe75.js';
1
+ import { T as TdsCheckbox$1, d as defineCustomElement$1 } from './p-e4d7c655.js';
2
2
 
3
3
  const TdsCheckbox = TdsCheckbox$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,4 +1,4 @@
1
- import { T as TdsDropdownOption$1, d as defineCustomElement$1 } from './p-e7868876.js';
1
+ import { T as TdsDropdownOption$1, d as defineCustomElement$1 } from './p-462b77e8.js';
2
2
 
3
3
  const TdsDropdownOption = TdsDropdownOption$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,4 +1,4 @@
1
- import { T as TdsDropdown$1, d as defineCustomElement$1 } from './p-ca4b945d.js';
1
+ import { T as TdsDropdown$1, d as defineCustomElement$1 } from './p-4d8f8d5c.js';
2
2
 
3
3
  const TdsDropdown = TdsDropdown$1;
4
4
  const defineCustomElement = defineCustomElement$1;