@scania/tegel 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +3 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/tds-breadcrumb.cjs.entry.js +1 -1
  4. package/dist/cjs/tds-breadcrumbs.cjs.entry.js +3 -1
  5. package/dist/cjs/tds-button.cjs.entry.js +1 -1
  6. package/dist/cjs/tds-checkbox.cjs.entry.js +16 -3
  7. package/dist/cjs/tds-dropdown-option.cjs.entry.js +5 -3
  8. package/dist/cjs/tds-dropdown.cjs.entry.js +13 -3
  9. package/dist/cjs/tds-footer-item.cjs.entry.js +1 -1
  10. package/dist/cjs/tds-slider.cjs.entry.js +60 -104
  11. package/dist/cjs/tds-step.cjs.entry.js +12 -7
  12. package/dist/cjs/tds-table-header.cjs.entry.js +3 -1
  13. package/dist/cjs/tds-toast.cjs.entry.js +4 -1
  14. package/dist/cjs/tegel.cjs.js +1 -1
  15. package/dist/collection/collection-manifest.json +3 -3
  16. package/dist/collection/components/accordion/test/basic/accordion.e2e.js +19 -0
  17. package/dist/collection/components/accordion/test/disabled/accordion.e2e.js +19 -0
  18. package/dist/collection/components/accordion/test/expanded/accordion.e2e.js +24 -0
  19. package/dist/collection/components/accordion/test/padding-reset/accordion.e2e.js +24 -0
  20. package/dist/collection/components/badge/test/basic/badge.e2e.js +10 -0
  21. package/dist/collection/components/badge/test/value/badge.e2e.js +11 -0
  22. package/dist/collection/components/banner/test/basic/banner.e2e.js +10 -0
  23. package/dist/collection/components/breadcrumbs/breadcrumb/breadcrumb.css +4 -3
  24. package/dist/collection/components/breadcrumbs/breadcrumbs.js +3 -1
  25. package/dist/collection/components/button/button.css +0 -4
  26. package/dist/collection/components/checkbox/checkbox.css +19 -0
  27. package/dist/collection/components/checkbox/checkbox.js +39 -5
  28. package/dist/collection/components/checkbox/checkbox.stories.js +25 -12
  29. package/dist/collection/components/datetime/datetime.stories.js +2 -2
  30. package/dist/collection/components/dropdown/dropdown-option/dropdown-option.css +26 -16
  31. package/dist/collection/components/dropdown/dropdown-option/dropdown-option.js +4 -2
  32. package/dist/collection/components/dropdown/dropdown.css +28 -0
  33. package/dist/collection/components/dropdown/dropdown.js +12 -2
  34. package/dist/collection/components/footer/footer-item/footer-item.css +4 -6
  35. package/dist/collection/components/slider/slider.js +61 -105
  36. package/dist/collection/components/stepper/step/step.js +13 -8
  37. package/dist/collection/components/table/table-component-multiselect.stories.js +18 -2
  38. package/dist/collection/components/table/table-header/table-header.js +43 -3
  39. package/dist/collection/components/text-field/text-field.stories.js +1 -1
  40. package/dist/collection/components/toast/toast.js +4 -1
  41. package/dist/collection/components/toast/toast.stories.js +10 -1
  42. package/dist/collection/stories/Installation/angular.stories.js +111 -0
  43. package/dist/collection/stories/Installation/javascript.stories.js +99 -0
  44. package/dist/collection/stories/Installation/react.stories.js +117 -0
  45. package/dist/collection/stories/announcements/announce-tegel.stories.js +5 -5
  46. package/dist/collection/stories/tegel.stories.js +7 -8
  47. package/dist/components/checkbox.js +20 -4
  48. package/dist/components/tds-breadcrumb.js +1 -1
  49. package/dist/components/tds-breadcrumbs.js +3 -1
  50. package/dist/components/tds-button.js +1 -1
  51. package/dist/components/tds-dropdown-option.js +5 -3
  52. package/dist/components/tds-dropdown.js +13 -3
  53. package/dist/components/tds-footer-item.js +1 -1
  54. package/dist/components/tds-slider.js +61 -105
  55. package/dist/components/tds-step.js +13 -8
  56. package/dist/components/tds-table-header.js +5 -1
  57. package/dist/components/tds-toast.js +4 -1
  58. package/dist/esm/loader.js +1 -1
  59. package/dist/esm/tds-breadcrumb.entry.js +1 -1
  60. package/dist/esm/tds-breadcrumbs.entry.js +3 -1
  61. package/dist/esm/tds-button.entry.js +1 -1
  62. package/dist/esm/tds-checkbox.entry.js +16 -3
  63. package/dist/esm/tds-dropdown-option.entry.js +5 -3
  64. package/dist/esm/tds-dropdown.entry.js +13 -3
  65. package/dist/esm/tds-footer-item.entry.js +1 -1
  66. package/dist/esm/tds-slider.entry.js +60 -104
  67. package/dist/esm/tds-step.entry.js +12 -7
  68. package/dist/esm/tds-table-header.entry.js +3 -1
  69. package/dist/esm/tds-toast.entry.js +4 -1
  70. package/dist/esm/tegel.js +1 -1
  71. package/dist/tegel/p-1aaf365d.entry.js +1 -0
  72. package/dist/tegel/p-24f22b04.entry.js +1 -0
  73. package/dist/tegel/p-3a930215.entry.js +1 -0
  74. package/dist/tegel/p-6361ae3a.entry.js +1 -0
  75. package/dist/tegel/{p-e3c5a663.entry.js → p-952a9830.entry.js} +1 -1
  76. package/dist/tegel/p-99327b6c.entry.js +1 -0
  77. package/dist/tegel/p-abe23e76.entry.js +1 -0
  78. package/dist/tegel/p-bf32d97c.entry.js +1 -0
  79. package/dist/tegel/p-c420b0a9.entry.js +1 -0
  80. package/dist/tegel/p-d6c1d080.entry.js +1 -0
  81. package/dist/tegel/p-fbd856ca.entry.js +1 -0
  82. package/dist/tegel/tegel.css +1 -1
  83. package/dist/tegel/tegel.esm.js +1 -1
  84. package/dist/types/components/breadcrumbs/breadcrumbs.d.ts +1 -1
  85. package/dist/types/components/checkbox/checkbox.d.ts +5 -0
  86. package/dist/types/components/checkbox/checkbox.stories.d.ts +13 -0
  87. package/dist/types/components/slider/slider.d.ts +19 -22
  88. package/dist/types/components/stepper/step/step.d.ts +1 -1
  89. package/dist/types/components/table/table-component-batch-actions.stories.d.ts +1 -1
  90. package/dist/types/components/table/table-component-multiselect.stories.d.ts +16 -0
  91. package/dist/types/components/table/table-header/table-header.d.ts +5 -1
  92. package/dist/types/components/toast/toast.stories.d.ts +8 -0
  93. package/dist/types/components.d.ts +27 -2
  94. package/dist/types/stories/Installation/angular.stories.d.ts +6 -0
  95. package/dist/types/stories/Installation/{installation.stories.d.ts → javascript.stories.d.ts} +1 -1
  96. package/dist/types/stories/Installation/react.stories.d.ts +6 -0
  97. package/dist/types/stories/formatHtmlPreview.d.ts +1 -1
  98. package/package.json +7 -7
  99. package/dist/collection/components/accordion/accordion.spec.js +0 -6
  100. package/dist/collection/components/divider/divider.spec.js +0 -28
  101. package/dist/collection/components/dropdown/test/dropdown.e2e.js +0 -32
  102. package/dist/collection/components/dropdown/test/dropdown.filter.spec.js +0 -49
  103. package/dist/collection/components/dropdown/test/dropdown.multiselect.e2e.js +0 -31
  104. package/dist/collection/components/dropdown/test/dropdown.multiselect.spec.js +0 -51
  105. package/dist/collection/components/dropdown/test/dropdown.spec.js +0 -51
  106. package/dist/collection/components/table/table.filtering.spec.js +0 -23
  107. package/dist/collection/components/table/table.spec.js +0 -16
  108. package/dist/collection/stories/Installation/installation.stories.js +0 -218
  109. package/dist/tegel/p-016d07b2.entry.js +0 -1
  110. package/dist/tegel/p-1a978a31.entry.js +0 -1
  111. package/dist/tegel/p-78f42968.entry.js +0 -1
  112. package/dist/tegel/p-80b501e3.entry.js +0 -1
  113. package/dist/tegel/p-8f1a037c.entry.js +0 -1
  114. package/dist/tegel/p-a0f3086c.entry.js +0 -1
  115. package/dist/tegel/p-be7119d3.entry.js +0 -1
  116. package/dist/tegel/p-c0b7acbb.entry.js +0 -1
  117. package/dist/tegel/p-e4db065d.entry.js +0 -1
  118. package/dist/tegel/p-eda7ecf6.entry.js +0 -1
@@ -7,9 +7,6 @@ export class TdsSlider {
7
7
  this.thumbInnerElement = null;
8
8
  this.trackElement = null;
9
9
  this.trackFillElement = null;
10
- this.minusElement = null;
11
- this.plusElement = null;
12
- this.inputElement = null;
13
10
  this.thumbGrabbed = false;
14
11
  this.thumbLeft = 0;
15
12
  this.tickValues = [];
@@ -18,7 +15,6 @@ export class TdsSlider {
18
15
  this.useSmall = false;
19
16
  this.useSnapping = false;
20
17
  this.supposedValueSlot = -1;
21
- this.eventListenersAdded = false;
22
18
  this.resizeObserverAdded = false;
23
19
  this.label = '';
24
20
  this.value = '0';
@@ -39,7 +35,6 @@ export class TdsSlider {
39
35
  }
40
36
  /** Public method to re-initialise the slider if some configuration props are changed */
41
37
  async reset() {
42
- // @TODO: maybe refactor to use watch-decorators instead
43
38
  this.componentWillLoad();
44
39
  this.componentDidLoad();
45
40
  }
@@ -90,10 +85,8 @@ export class TdsSlider {
90
85
  }
91
86
  this.thumbCore(event);
92
87
  }
93
- handleValueUpdate(newVal) {
94
- this.calculateThumbLeftFromValue(newVal);
95
- this.updateValueForced(newVal);
96
- this.updateTrack();
88
+ handleValueUpdate(newValue) {
89
+ this.forceValueUpdate(newValue);
97
90
  }
98
91
  updateSupposedValueSlot(localLeft) {
99
92
  const numTicks = parseInt(this.ticks);
@@ -138,9 +131,6 @@ export class TdsSlider {
138
131
  const percentageFilled = (this.thumbLeft / trackWidth) * 100;
139
132
  this.trackFillElement.style.width = `${percentageFilled}%`;
140
133
  }
141
- dispatchChangeEvent() {
142
- this.tdsChange.emit({ value: this.value });
143
- }
144
134
  updateValue() {
145
135
  const trackWidth = this.getTrackWidth();
146
136
  const numTicks = parseInt(this.ticks);
@@ -152,20 +142,16 @@ export class TdsSlider {
152
142
  }
153
143
  else {
154
144
  const percentage = this.thumbLeft / trackWidth;
155
- this.value = `${Math.trunc(this.getMin() + percentage * (this.getMax() - this.getMin()))}`;
145
+ this.value = `${Math.trunc(parseFloat(this.min) + percentage * (parseFloat(this.max) - parseFloat(this.min)))}`;
156
146
  }
157
147
  this.updateTrack();
158
- this.dispatchChangeEvent();
159
- }
160
- updateValueForced(value) {
161
- this.value = value;
162
- this.dispatchChangeEvent();
163
- }
164
- getMin() {
165
- return parseFloat(this.min);
148
+ this.tdsChange.emit({ value: this.value });
166
149
  }
167
- getMax() {
168
- return parseFloat(this.max);
150
+ forceValueUpdate(newValue) {
151
+ this.calculateThumbLeftFromValue(newValue);
152
+ this.value = newValue;
153
+ this.tdsChange.emit({ value: this.value });
154
+ this.updateTrack();
169
155
  }
170
156
  constrainThumb(x) {
171
157
  const width = this.getTrackWidth();
@@ -184,61 +170,33 @@ export class TdsSlider {
184
170
  calculateThumbLeftFromValue(value) {
185
171
  const initValue = value;
186
172
  const trackWidth = this.getTrackWidth();
187
- const normalizedValue = initValue - this.getMin();
188
- const normalizedMax = this.getMax() - this.getMin();
173
+ const normalizedValue = initValue - parseFloat(this.min);
174
+ const normalizedMax = parseFloat(this.max) - parseFloat(this.min);
189
175
  const calculatedLeft = (normalizedValue / normalizedMax) * trackWidth;
190
176
  this.thumbLeft = calculatedLeft;
191
177
  this.updateSupposedValueSlot(this.thumbLeft);
192
178
  this.thumbElement.style.left = `${this.thumbLeft}px`;
193
179
  }
194
- componentDidLoad() {
195
- if (!this.resizeObserverAdded) {
196
- this.resizeObserverAdded = true;
197
- const resizeObserver = new ResizeObserver(( /* entries */) => {
198
- this.calculateThumbLeftFromValue(this.value);
199
- this.updateTrack();
200
- });
201
- resizeObserver.observe(this.wrapperElement);
180
+ /** Updates the slider value based on the current input value */
181
+ updateSliderValueOnInputChange(event) {
182
+ const inputElement = event.target;
183
+ let newValue = parseInt(inputElement.value);
184
+ if (newValue < parseFloat(this.min)) {
185
+ newValue = parseFloat(this.min);
202
186
  }
203
- if (!this.eventListenersAdded) {
204
- this.eventListenersAdded = true;
205
- this.thumbElement.addEventListener('mousedown', (event) => {
206
- event.preventDefault();
207
- this.grabThumb();
208
- });
209
- this.thumbElement.addEventListener('touchstart', () => {
210
- this.grabThumb();
211
- });
212
- if (this.useControls) {
213
- this.minusElement.addEventListener('click', () => {
214
- this.stepLeft();
215
- });
216
- this.plusElement.addEventListener('click', () => {
217
- this.stepRight();
218
- });
219
- }
220
- if (this.inputElement) {
221
- this.inputElement.addEventListener('keydown', (event) => {
222
- event.stopPropagation();
223
- if (event.key === 'Enter') {
224
- let newValue = parseInt(this.inputElement.value);
225
- if (newValue < this.getMin()) {
226
- newValue = this.getMin();
227
- }
228
- else if (newValue > this.getMax()) {
229
- newValue = this.getMax();
230
- }
231
- this.calculateThumbLeftFromValue(newValue);
232
- this.updateValueForced(newValue);
233
- this.updateTrack();
234
- this.inputElement.blur();
235
- this.wrapperElement.focus();
236
- }
237
- });
238
- }
187
+ else if (newValue > parseFloat(this.max)) {
188
+ newValue = parseFloat(this.max);
189
+ }
190
+ this.forceValueUpdate(String(newValue));
191
+ }
192
+ /** Updates the slider value based on the current input value when enter is pressed */
193
+ handleInputFieldEnterPress(event) {
194
+ event.stopPropagation();
195
+ if (event.key === 'Enter') {
196
+ this.updateSliderValueOnInputChange(event);
197
+ const inputElement = event.target;
198
+ inputElement.blur();
239
199
  }
240
- this.calculateThumbLeftFromValue(this.value);
241
- this.updateTrack();
242
200
  }
243
201
  grabThumb() {
244
202
  if (this.readOnly) {
@@ -270,19 +228,17 @@ export class TdsSlider {
270
228
  else {
271
229
  const trackWidth = this.getTrackWidth();
272
230
  const percentage = this.thumbLeft / trackWidth;
273
- let currentValue = this.getMin() + percentage * (this.getMax() - this.getMin());
231
+ let currentValue = parseFloat(this.min) + percentage * (parseFloat(this.max) - parseFloat(this.min));
274
232
  currentValue += delta;
275
233
  currentValue = Math.round(currentValue);
276
- if (currentValue < this.getMin()) {
277
- currentValue = this.getMin();
234
+ if (currentValue < parseFloat(this.min)) {
235
+ currentValue = parseFloat(this.min);
278
236
  }
279
- else if (currentValue > this.getMax()) {
280
- currentValue = this.getMax();
237
+ else if (currentValue > parseFloat(this.max)) {
238
+ currentValue = parseFloat(this.max);
281
239
  }
282
240
  this.value = `${currentValue}`;
283
- this.calculateThumbLeftFromValue(this.value);
284
- this.updateValueForced(currentValue);
285
- this.updateTrack();
241
+ this.forceValueUpdate(this.value);
286
242
  }
287
243
  }
288
244
  stepLeft() {
@@ -294,12 +250,12 @@ export class TdsSlider {
294
250
  componentWillLoad() {
295
251
  const numTicks = parseInt(this.ticks);
296
252
  if (numTicks > 0) {
297
- this.tickValues = [this.getMin()];
298
- const step = (this.getMax() - this.getMin()) / (numTicks + 1);
253
+ this.tickValues = [parseFloat(this.min)];
254
+ const step = (parseFloat(this.max) - parseFloat(this.min)) / (numTicks + 1);
299
255
  for (let i = 1; i < numTicks + 1; i++) {
300
- this.tickValues.push(this.getMin() + Math.round(step * i));
256
+ this.tickValues.push(parseFloat(this.min) + Math.round(step * i));
301
257
  }
302
- this.tickValues.push(this.getMax());
258
+ this.tickValues.push(parseFloat(this.max));
303
259
  }
304
260
  this.useInput = false;
305
261
  this.useControls = false;
@@ -311,44 +267,44 @@ export class TdsSlider {
311
267
  }
312
268
  this.useSmall = this.thumbSize === 'sm';
313
269
  this.useSnapping = this.snap;
314
- const min = this.getMin();
315
- const max = this.getMax();
270
+ const min = parseFloat(this.min);
271
+ const max = parseFloat(this.max);
316
272
  if (min > max) {
317
273
  console.warn('min-prop must have a higher value than max-prop for the component to work correctly.');
318
274
  this.disabled = true;
319
275
  }
320
276
  }
277
+ componentDidLoad() {
278
+ if (!this.resizeObserverAdded) {
279
+ this.resizeObserverAdded = true;
280
+ const resizeObserver = new ResizeObserver(() => {
281
+ this.calculateThumbLeftFromValue(this.value);
282
+ this.updateTrack();
283
+ });
284
+ resizeObserver.observe(this.wrapperElement);
285
+ }
286
+ this.calculateThumbLeftFromValue(this.value);
287
+ this.updateTrack();
288
+ }
321
289
  render() {
322
- return (h("div", { class: `tds-slider-wrapper ${this.readOnly ? 'read-only' : ''}` }, h("input", { class: "tds-slider-native-element", type: "range", value: this.value, name: this.name, min: this.min, max: this.max, disabled: this.disabled }), h("div", { class: {
290
+ return (h("div", { class: {
291
+ 'tds-slider-wrapper': true,
292
+ 'read-only': this.readOnly,
293
+ } }, h("input", { class: "tds-slider-native-element", type: "range", name: this.name, min: this.min, max: this.max, value: this.value, disabled: this.disabled }), h("div", { class: {
323
294
  'tds-slider': true,
324
295
  'disabled': this.disabled,
325
296
  'tds-slider-small': this.useSmall,
326
297
  }, ref: (el) => {
327
298
  this.wrapperElement = el;
328
- } }, h("label", { class: this.showTickNumbers && 'offset' }, this.label), this.useInput && (h("div", { class: "tds-slider__input-values" }, h("div", { ref: (el) => {
329
- this.minusElement = el;
330
- }, class: "tds-slider__input-value min-value" }, this.min))), this.useControls && (h("div", { class: "tds-slider__controls" }, h("div", { ref: (el) => {
331
- this.minusElement = el;
332
- }, class: "tds-slider__control tds-slider__control-minus" }, h("tds-icon", { name: "minus", size: "16px" })))), h("div", { class: "tds-slider-inner" }, this.tickValues.length > 0 && (h("div", { class: "tds-slider__value-dividers-wrapper" }, h("div", { class: "tds-slider__value-dividers" }, this.tickValues.map((value) => (h("div", { class: "tds-slider__value-divider" }, this.showTickNumbers && h("span", null, value))))))), h("div", { class: "tds-slider__track", ref: (el) => {
299
+ } }, h("label", { class: this.showTickNumbers && 'offset' }, this.label), this.useInput && (h("div", { class: "tds-slider__input-values" }, h("div", { class: "tds-slider__input-value min-value" }, this.min))), this.useControls && (h("div", { class: "tds-slider__controls" }, h("div", { class: "tds-slider__control tds-slider__control-minus", onClick: () => this.stepLeft() }, h("tds-icon", { name: "minus", size: "16px" })))), h("div", { class: "tds-slider-inner" }, this.tickValues.length > 0 && (h("div", { class: "tds-slider__value-dividers-wrapper" }, h("div", { class: "tds-slider__value-dividers" }, this.tickValues.map((value) => (h("div", { class: "tds-slider__value-divider" }, this.showTickNumbers && h("span", null, value))))))), h("div", { class: "tds-slider__track", ref: (el) => {
333
300
  this.trackElement = el;
334
301
  }, tabindex: this.disabled ? '-1' : '0' }, h("div", { class: "tds-slider__track-fill", ref: (el) => {
335
302
  this.trackFillElement = el;
336
303
  } }), h("div", { class: "tds-slider__thumb", ref: (el) => {
337
304
  this.thumbElement = el;
338
- } }, this.tooltip && (h("div", { class: "tds-slider__value" }, this.value, h("svg", { width: "18", height: "14", viewBox: "0 0 18 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { 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", { class: "tds-slider__thumb-inner", ref: (el) => {
305
+ }, onMouseDown: () => this.grabThumb(), onTouchStart: () => this.grabThumb() }, this.tooltip && (h("div", { class: "tds-slider__value" }, this.value, h("svg", { width: "18", height: "14", viewBox: "0 0 18 14", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { 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", { class: "tds-slider__thumb-inner", ref: (el) => {
339
306
  this.thumbInnerElement = el;
340
- } })))), this.useInput && (h("div", { class: "tds-slider__input-values" }, h("div", { ref: (el) => {
341
- this.minusElement = el;
342
- }, class: "tds-slider__input-value" }, this.max), h("div", { class: "tds-slider__input-field-wrapper" }, h("input", { onFocus: (e) => {
343
- if (this.readOnly) {
344
- e.preventDefault();
345
- this.inputElement.blur();
346
- }
347
- }, size: this.calculateInputSizeFromMax(), class: "tds-slider__input-field", value: this.value, ref: (el) => {
348
- this.inputElement = el;
349
- } })))), this.useControls && (h("div", { class: "tds-slider__controls" }, h("div", { ref: (el) => {
350
- this.plusElement = el;
351
- }, class: "tds-slider__control tds-slider__control-plus" }, h("tds-icon", { name: "plus", size: "16px" })))))));
307
+ } })))), this.useInput && (h("div", { class: "tds-slider__input-values" }, h("div", { class: "tds-slider__input-value", onClick: () => this.stepLeft() }, this.max), h("div", { class: "tds-slider__input-field-wrapper" }, h("input", { size: this.calculateInputSizeFromMax(), class: "tds-slider__input-field", value: this.value, readOnly: this.readOnly, onBlur: (event) => this.updateSliderValueOnInputChange(event), onKeyDown: (event) => this.handleInputFieldEnterPress(event) })))), this.useControls && (h("div", { class: "tds-slider__controls" }, h("div", { class: "tds-slider__control tds-slider__control-plus", onClick: () => this.stepRight() }, h("tds-icon", { name: "plus", size: "16px" })))))));
352
308
  }
353
309
  static get is() { return "tds-slider"; }
354
310
  static get originalStyleUrls() {
@@ -383,7 +339,7 @@ export class TdsSlider {
383
339
  },
384
340
  "value": {
385
341
  "type": "string",
386
- "mutable": false,
342
+ "mutable": true,
387
343
  "complexType": {
388
344
  "original": "string",
389
345
  "resolved": "string",
@@ -1,4 +1,10 @@
1
1
  import { Host, h } from "@stencil/core";
2
+ const propToStateMap = {
3
+ orientation: 'orientation',
4
+ labelPosition: 'labelPosition',
5
+ size: 'size',
6
+ hideLabels: 'hideLabels',
7
+ };
2
8
  /**
3
9
  * @slot label - Slot for the label text.
4
10
  */
@@ -6,7 +12,7 @@ export class TdsStep {
6
12
  constructor() {
7
13
  this.index = undefined;
8
14
  this.state = 'upcoming';
9
- this.hideLabel = undefined;
15
+ this.hideLabels = undefined;
10
16
  this.size = undefined;
11
17
  this.orientation = undefined;
12
18
  this.labelPosition = undefined;
@@ -17,24 +23,23 @@ export class TdsStep {
17
23
  this.orientation = this.stepperEl.orientation;
18
24
  this.labelPosition = this.stepperEl.labelPosition;
19
25
  this.size = this.stepperEl.size;
20
- this.hideLabel = this.stepperEl.hideLabels;
26
+ this.hideLabels = this.stepperEl.hideLabels;
21
27
  this.stepperId = this.stepperEl.stepperId;
22
28
  }
23
29
  handlePropsChange(event) {
24
30
  if (this.stepperId === event.detail.stepperId) {
25
31
  event.detail.changed.forEach((changedProp) => {
26
32
  if (typeof this[changedProp] === 'undefined') {
27
- throw new Error(`Table prop is not supported: ${changedProp}`);
33
+ throw new Error(`Stepper prop is not supported: ${changedProp}`);
28
34
  }
29
- if (this[changedProp] === this.orientation && event.detail[changedProp] === 'vertical') {
30
- this.labelPosition = 'aside';
35
+ else if (changedProp in propToStateMap) {
36
+ this[propToStateMap[changedProp]] = event.detail[changedProp];
31
37
  }
32
- this[changedProp] = event.detail[changedProp];
33
38
  });
34
39
  }
35
40
  }
36
41
  render() {
37
- return (h(Host, null, h("div", { role: "listitem", class: `${this.size} ${this.orientation} text-${this.labelPosition} ${this.hideLabel ? 'hide-labels' : ''}` }, h("div", { class: `${this.state} content-container` }, this.state === 'success' || this.state === 'error' ? (h("tds-icon", { name: this.state === 'success' ? 'tick' : 'warning', size: this.size === 'lg' ? '20px' : '16px' })) : (this.index)), !this.hideLabel && (h("div", { class: `label ${this.size} ${this.state}` }, h("slot", { name: "label" }))))));
42
+ return (h(Host, null, h("div", { role: "listitem", class: `${this.size} ${this.orientation} text-${this.labelPosition} ${this.hideLabels ? 'hide-labels' : ''}` }, h("div", { class: `${this.state} content-container` }, this.state === 'success' || this.state === 'error' ? (h("tds-icon", { name: this.state === 'success' ? 'tick' : 'warning', size: this.size === 'lg' ? '20px' : '16px' })) : (this.index)), !this.hideLabels && (h("div", { class: `label ${this.size} ${this.state}` }, h("slot", { name: "label" }))))));
38
43
  }
39
44
  static get is() { return "tds-step"; }
40
45
  static get encapsulation() { return "shadow"; }
@@ -89,7 +94,7 @@ export class TdsStep {
89
94
  }
90
95
  static get states() {
91
96
  return {
92
- "hideLabel": {},
97
+ "hideLabels": {},
93
98
  "size": {},
94
99
  "orientation": {},
95
100
  "labelPosition": {}
@@ -36,6 +36,20 @@ export default {
36
36
  defaultValue: { summary: 'Inherit from parent' },
37
37
  },
38
38
  },
39
+ allSelected: {
40
+ name: 'All selected',
41
+ description: `Controls the checked state of the "all-selected"-checkbox.`,
42
+ control: {
43
+ type: 'boolean',
44
+ },
45
+ },
46
+ allIndeterminate: {
47
+ name: 'All indeterminate',
48
+ description: `Controls the indeterminate state of the "all-selected"-checkbox.`,
49
+ control: {
50
+ type: 'boolean',
51
+ },
52
+ },
39
53
  compactDesign: {
40
54
  name: 'Compact design',
41
55
  description: 'Enables compact design of the Table, rows with less height.',
@@ -108,6 +122,8 @@ export default {
108
122
  },
109
123
  args: {
110
124
  modeVariant: 'Inherit from parent',
125
+ allSelected: false,
126
+ allIndeterminate: false,
111
127
  compactDesign: false,
112
128
  responsiveDesign: false,
113
129
  verticalDivider: false,
@@ -118,7 +134,7 @@ export default {
118
134
  column4Width: '',
119
135
  },
120
136
  };
121
- const MultiselectTemplate = ({ modeVariant, compactDesign, responsiveDesign, verticalDivider, noMinWidth, column1Width, column2Width, column3Width, column4Width, }) => formatHtmlPreview(`
137
+ const MultiselectTemplate = ({ modeVariant, allSelected, allIndeterminate, compactDesign, responsiveDesign, verticalDivider, noMinWidth, column1Width, column2Width, column3Width, column4Width, }) => formatHtmlPreview(`
122
138
  <tds-table
123
139
  table-id="multiselect-table"
124
140
  multiselect
@@ -128,7 +144,7 @@ const MultiselectTemplate = ({ modeVariant, compactDesign, responsiveDesign, ver
128
144
  ${noMinWidth ? 'no-min-width' : ''}
129
145
  ${modeVariant !== 'Inherit from parent' ? `mode-variant="${modeVariant.toLowerCase()}"` : ''}
130
146
  >
131
- <tds-table-header>
147
+ <tds-table-header ${allSelected ? 'selected' : ''} ${allIndeterminate ? 'indeterminate' : ''}>
132
148
  <tds-header-cell cell-key='truck' cell-value='Truck type' ${column1Width ? `custom-width="${column1Width}"` : ''}></tds-header-cell>
133
149
  <tds-header-cell cell-key='driver' cell-value='Driver name' ${column2Width ? `custom-width="${column2Width}"` : ''}></tds-header-cell>
134
150
  <tds-header-cell cell-key='country' cell-value='Country' ${column3Width ? `custom-width="${column3Width}"` : ''}></tds-header-cell>
@@ -12,6 +12,8 @@ const relevantTableProps = [
12
12
  export class TdsTableHeaderRow {
13
13
  constructor() {
14
14
  this.allSelected = false;
15
+ this.selected = undefined;
16
+ this.indeterminate = false;
15
17
  this.multiselect = false;
16
18
  this.expandableRows = false;
17
19
  this.mainCheckboxSelected = false;
@@ -83,7 +85,7 @@ export class TdsTableHeaderRow {
83
85
  'tds-table--compact': this.compactDesign,
84
86
  'tds-table--divider': this.verticalDividers,
85
87
  'tds-table--toolbar-available': this.enableToolbarDesign,
86
- } }, h("tr", null, this.multiselect && (h("th", { class: "tds-table__header-cell tds-table__header-cell--checkbox" }, h("div", { class: "tds-form-label tds-form-label--table" }, h("tds-checkbox", { checked: this.allSelected, onTdsChange: (event) => this.handleCheckboxChange(event) })))), this.expandableRows && (h("th", { class: "tds-table__header-cell tds-table__header-cell--checkbox" })), h("slot", null))));
88
+ } }, h("tr", null, this.multiselect && (h("th", { class: "tds-table__header-cell tds-table__header-cell--checkbox" }, h("div", { class: "tds-form-label tds-form-label--table" }, h("tds-checkbox", { checked: this.allSelected || this.selected, indeterminate: this.indeterminate, onTdsChange: (event) => this.handleCheckboxChange(event) })))), this.expandableRows && (h("th", { class: "tds-table__header-cell tds-table__header-cell--checkbox" })), h("slot", null))));
87
89
  }
88
90
  static get is() { return "tds-table-header"; }
89
91
  static get encapsulation() { return "shadow"; }
@@ -110,12 +112,50 @@ export class TdsTableHeaderRow {
110
112
  "required": false,
111
113
  "optional": false,
112
114
  "docs": {
113
- "tags": [],
114
- "text": "Prop for controling the checked/unchecked state of the \"all selected\"-checkbox."
115
+ "tags": [{
116
+ "name": "deprecated",
117
+ "text": "Deprecated, use selected instead.."
118
+ }],
119
+ "text": ""
115
120
  },
116
121
  "attribute": "all-selected",
117
122
  "reflect": true,
118
123
  "defaultValue": "false"
124
+ },
125
+ "selected": {
126
+ "type": "boolean",
127
+ "mutable": true,
128
+ "complexType": {
129
+ "original": "boolean",
130
+ "resolved": "boolean",
131
+ "references": {}
132
+ },
133
+ "required": false,
134
+ "optional": false,
135
+ "docs": {
136
+ "tags": [],
137
+ "text": "Prop for controling the checked/unchecked state of the \"All selected\"-checkbox."
138
+ },
139
+ "attribute": "selected",
140
+ "reflect": true
141
+ },
142
+ "indeterminate": {
143
+ "type": "boolean",
144
+ "mutable": false,
145
+ "complexType": {
146
+ "original": "boolean",
147
+ "resolved": "boolean",
148
+ "references": {}
149
+ },
150
+ "required": false,
151
+ "optional": false,
152
+ "docs": {
153
+ "tags": [],
154
+ "text": "Prop for controling the indeterminate state of the \"All selected\"-checkbox."
155
+ },
156
+ "attribute": "indeterminate",
157
+ "reflect": false,
158
+ "defaultValue": "false"
119
159
  }
120
160
  };
121
161
  }
@@ -204,7 +204,7 @@ const Template = ({ modeVariant, state, type, size, label, labelPosition, placeh
204
204
 
205
205
  <div class="demo-wrapper">
206
206
  <tds-text-field
207
- type="${type}"
207
+ type="${type.toLowerCase()}"
208
208
  size="${sizeLookUp[size]}"
209
209
  ${modeVariant !== 'Inherit from parent' ? `mode-variant="${modeVariant.toLowerCase()}"` : ''}
210
210
  state="${stateValue}"
@@ -57,7 +57,10 @@ export class TdsToast {
57
57
  const usesHeaderSlot = hasSlot('header', this.host);
58
58
  const usesSubheaderSlot = hasSlot('subheader', this.host);
59
59
  const usesActionsSlot = hasSlot('actions', this.host);
60
- return (h(Host, { toastRole: this.toastRole, "aria-describedby": this.host.getAttribute('aria-describedby'), class: `${this.hidden ? 'hide' : 'show'}` }, h("div", { class: `
60
+ return (h(Host, { toastRole: this.toastRole, "aria-describedby": this.host.getAttribute('aria-describedby'), class: {
61
+ hide: this.hidden,
62
+ show: !this.hidden,
63
+ } }, h("div", { class: `
61
64
  wrapper
62
65
  ${this.variant}` }, h("tds-icon", { name: this.getIconName(), size: "20px" }), h("div", { class: `content` }, h("div", { class: "header-subheader" }, this.header && h("div", { class: "header" }, this.header), usesHeaderSlot && h("slot", { name: "header" }), this.subheader && h("div", { class: "subheader" }, this.subheader), usesSubheaderSlot && h("slot", { name: "subheader" })), usesActionsSlot && (h("div", { class: `toast-bottom ${usesSubheaderSlot || this.subheader ? 'subheader' : 'no-subheader'}` }, h("slot", { name: "actions" })))), h("button", { onClick: () => {
63
66
  this.handleClose();
@@ -54,6 +54,13 @@ export default {
54
54
  type: 'text',
55
55
  },
56
56
  },
57
+ hidden: {
58
+ name: 'Hidden',
59
+ description: 'Hides the Toast.',
60
+ control: {
61
+ type: 'boolean',
62
+ },
63
+ },
57
64
  },
58
65
  args: {
59
66
  variant: 'Information',
@@ -62,12 +69,14 @@ export default {
62
69
  actions: `<tds-link slot="actions">
63
70
  <a href="https://tegel.scania.com/home" target="_blank">Tegel</a>
64
71
  </tds-link>`,
72
+ hidden: false,
65
73
  },
66
74
  };
67
- const Template = ({ variant, header, subheader, actions }) => formatHtmlPreview(`<tds-toast
75
+ const Template = ({ variant, header, subheader, actions, hidden }) => formatHtmlPreview(`<tds-toast
68
76
  variant="${variant.toLowerCase()}"
69
77
  header="${header}"
70
78
  ${subheader ? `subheader="${subheader}"` : ''}
79
+ ${hidden ? 'hidden' : ''}
71
80
  >
72
81
  ${actions || ''}
73
82
  </tds-toast>
@@ -0,0 +1,111 @@
1
+ const meta = {
2
+ title: 'Intro/Installation',
3
+ parameters: {
4
+ layout: 'fullscreen',
5
+ options: {
6
+ showPanel: false,
7
+ showToolbar: false,
8
+ },
9
+ },
10
+ };
11
+ export default meta;
12
+ export const Angular = {
13
+ render: () => `<style>
14
+ article {
15
+ box-sizing: border-box;
16
+ max-width: 688px;
17
+ padding: 32px;
18
+ margin: auto;
19
+ > * {
20
+ margin-bottom: 72px;
21
+ }
22
+ }
23
+
24
+ section > p,
25
+ section > ul,
26
+ section > tds-link {
27
+ margin-bottom: 32px;
28
+ }
29
+
30
+ tds-link {
31
+ display: inline-block;
32
+ }
33
+
34
+ .mb-72 {
35
+ margin-bottom: 72px;
36
+ }
37
+ code {
38
+ border-radius: 4px;
39
+ }
40
+ </style>
41
+ <article class="tds-u-p2 tds-body-01">
42
+ <section>
43
+ <p class="tds-body-01"><strong>Published: 2023-10-11</strong></p>
44
+ <h1 class="tds-headline-02">Using Tegel in Angular</h1>
45
+ <p>
46
+ Tegel offers Angular wrappers for all web components. While the rendered components still maintain
47
+ their core as web components, these wrappers significantly enhance the developer's experience by
48
+ providing a more intuitive API and seamless integration with Angular. You can find these wrappers
49
+ in a separate package called <code>@scania/tegel-angular</code>, which is the recommended approach for integrating
50
+ Tegel into a Angular application.
51
+ </p>
52
+ </section>
53
+ <section>
54
+ <h4 class="tds-u-mb2">Prerequisites</h4>
55
+ <ul>
56
+ <li>Node version 18+</li>
57
+ <li>Angular 14+</li>
58
+ </ul>
59
+ </section>
60
+ <section>
61
+ <h4 class="tds-u-mb2">
62
+ Installing <code>@scania/tegel-angular</<code>
63
+ </h4>
64
+ <p class="tds-body-01">Install the <code>@scania/tegel-angular</code> package via npm.</p>
65
+ <pre>
66
+ <code>
67
+ npm install @scania/tegel-angular
68
+ </code>
69
+ </pre>
70
+ <p class="tds-body-01">In your global css file import the tegel stylesheet.</p>
71
+ <pre>
72
+ <code>
73
+ @import url('@scania/tegel/dist/tegel/tegel.css');
74
+ </code>
75
+ </pre>
76
+
77
+ <p class="tds-body-01">Import the <code>TegelModule</code> in your app.module.ts.</p>
78
+ <pre>
79
+ <code>
80
+ import { NgModule } from '@angular/core';
81
+ import { BrowserModule } from '@angular/platform-browser';
82
+ import { AppComponent } from './app.component';
83
+ import { TegelModule } from '@scania/tegel-angular';
84
+
85
+ @NgModule({
86
+ declarations: [
87
+ AppComponent,
88
+ TesterComponent
89
+ ],
90
+ imports: [
91
+ BrowserModule,
92
+ TegelModule,
93
+ ],
94
+ providers: [],
95
+ bootstrap: [AppComponent]
96
+ })
97
+ export class AppModule { }
98
+ </code>
99
+ </pre>
100
+ <p class="tds-body-01">After this, all TDS components will be available in your template files. Example:</p>
101
+ <pre>
102
+ <code>
103
+ &lt;tds-button text="Click me!" variant="primary" size="sm"&gt;
104
+ &lt;tds-icon slot="icon" name="truck"&gt; &lt;/tds-icon&gt;
105
+ &lt;/tds-button&gt;
106
+ </code>
107
+ </pre>
108
+
109
+ </section>
110
+ </article> `,
111
+ };