@designsystem-se/af 39.2.1 → 39.2.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 (126) hide show
  1. package/components/digi-bar-chart.js +67 -17
  2. package/components/digi-calendar-datepicker.js +1 -1
  3. package/components/digi-calendar-week-view.js +51 -6
  4. package/components/digi-calendar.js +1 -1
  5. package/components/digi-chart-line.js +57 -14
  6. package/components/digi-navigation-vertical-menu.js +27 -13
  7. package/components/digi-tablist.js +36 -13
  8. package/components/{p-CrUxQ9d0.js → p-C5A2t93y.js} +1 -1
  9. package/dist/cjs/{calendar-week-view-heading-level.enum-NEkm5SUq.js → calendar-week-view-heading-level.enum-BI2f9bbk.js} +7 -0
  10. package/dist/cjs/digi-arbetsformedlingen.cjs.js +1 -1
  11. package/dist/cjs/{digi-button_5.cjs.entry.js → digi-badge-notification_8.cjs.entry.js} +436 -7
  12. package/dist/cjs/digi-bar-chart.cjs.entry.js +67 -17
  13. package/dist/cjs/digi-calendar-datepicker.cjs.entry.js +1 -2
  14. package/dist/cjs/digi-calendar_2.cjs.entry.js +1 -1
  15. package/dist/cjs/digi-chart-line.cjs.entry.js +57 -14
  16. package/dist/cjs/digi-code-block_3.cjs.entry.js +1 -2
  17. package/dist/cjs/digi-dialog.cjs.entry.js +1 -2
  18. package/dist/cjs/digi-footer.cjs.entry.js +1 -2
  19. package/dist/cjs/digi-form-error-list.cjs.entry.js +1 -2
  20. package/dist/cjs/digi-form-receipt.cjs.entry.js +1 -2
  21. package/dist/cjs/digi-form-select-filter.cjs.entry.js +1 -2
  22. package/dist/cjs/digi-header-navigation.cjs.entry.js +1 -2
  23. package/dist/cjs/digi-header.cjs.entry.js +1 -2
  24. package/dist/cjs/digi-navigation-pagination.cjs.entry.js +1 -2
  25. package/dist/cjs/digi-navigation-vertical-menu.cjs.entry.js +27 -13
  26. package/dist/cjs/digi-notification-alert.cjs.entry.js +1 -2
  27. package/dist/cjs/digi-notification-error-page.cjs.entry.js +1 -2
  28. package/dist/cjs/digi-title-logo.cjs.entry.js +1 -2
  29. package/dist/cjs/digi-tools-feedback.cjs.entry.js +1 -2
  30. package/dist/cjs/index-Cn1hHaSy.js +2 -14
  31. package/dist/cjs/index.cjs.js +6 -7
  32. package/dist/cjs/loader.cjs.js +1 -1
  33. package/dist/collection/components/_calendar/calendar/calendar.css +5 -6
  34. package/dist/collection/components/_calendar/week-view/calendar-week-view.js +53 -8
  35. package/dist/collection/components/_chart/bar-chart/bar-chart.css +1 -1
  36. package/dist/collection/components/_chart/bar-chart/bar-chart.js +66 -16
  37. package/dist/collection/components/_chart/chart-line/chart-line.js +57 -14
  38. package/dist/collection/components/_navigation/navigation-tablist/navigation-tablist.js +36 -13
  39. package/dist/collection/components/_navigation/navigation-vertical-menu/navigation-vertical-menu.js +27 -13
  40. package/dist/collection/design-tokens/components/_logo.variables.scss +2 -0
  41. package/dist/digi-arbetsformedlingen/digi-arbetsformedlingen.esm.js +1 -1
  42. package/dist/digi-arbetsformedlingen/index.esm.js +1 -1
  43. package/dist/digi-arbetsformedlingen/p-0f7e995a.entry.js +1 -0
  44. package/dist/digi-arbetsformedlingen/p-26f6a310.entry.js +1 -0
  45. package/dist/digi-arbetsformedlingen/p-3b42582a.entry.js +1 -0
  46. package/dist/digi-arbetsformedlingen/p-4384644b.entry.js +1 -0
  47. package/dist/digi-arbetsformedlingen/p-47513f97.entry.js +1 -0
  48. package/dist/digi-arbetsformedlingen/p-569c628c.entry.js +1 -0
  49. package/dist/digi-arbetsformedlingen/p-668d38d9.entry.js +1 -0
  50. package/dist/digi-arbetsformedlingen/p-66f34ca5.entry.js +1 -0
  51. package/dist/digi-arbetsformedlingen/p-6cb1c6ea.entry.js +1 -0
  52. package/dist/digi-arbetsformedlingen/p-6e256f0c.entry.js +1 -0
  53. package/dist/digi-arbetsformedlingen/p-71a8478d.entry.js +1 -0
  54. package/dist/digi-arbetsformedlingen/p-9df345c4.entry.js +1 -0
  55. package/dist/digi-arbetsformedlingen/p-BBOpiDGx.js +1 -0
  56. package/dist/digi-arbetsformedlingen/p-a1deddb1.entry.js +1 -0
  57. package/dist/digi-arbetsformedlingen/p-beebbc90.entry.js +1 -0
  58. package/dist/digi-arbetsformedlingen/{p-ee58a938.entry.js → p-c7ade486.entry.js} +1 -1
  59. package/dist/digi-arbetsformedlingen/p-d065e751.entry.js +1 -0
  60. package/dist/digi-arbetsformedlingen/p-d150094c.entry.js +1 -0
  61. package/dist/digi-arbetsformedlingen/p-df8efa59.entry.js +1 -0
  62. package/dist/digi-arbetsformedlingen/p-e2b0b070.entry.js +1 -0
  63. package/dist/esm/{calendar-week-view-heading-level.enum-DH_-wpLB.js → calendar-week-view-heading-level.enum-BBOpiDGx.js} +8 -1
  64. package/dist/esm/digi-arbetsformedlingen.js +1 -1
  65. package/dist/esm/{digi-button_5.entry.js → digi-badge-notification_8.entry.js} +435 -9
  66. package/dist/esm/digi-bar-chart.entry.js +67 -17
  67. package/dist/esm/digi-calendar-datepicker.entry.js +1 -2
  68. package/dist/esm/digi-calendar_2.entry.js +1 -1
  69. package/dist/esm/digi-chart-line.entry.js +57 -14
  70. package/dist/esm/digi-code-block_3.entry.js +1 -2
  71. package/dist/esm/digi-dialog.entry.js +1 -2
  72. package/dist/esm/digi-footer.entry.js +1 -2
  73. package/dist/esm/digi-form-error-list.entry.js +1 -2
  74. package/dist/esm/digi-form-receipt.entry.js +1 -2
  75. package/dist/esm/digi-form-select-filter.entry.js +1 -2
  76. package/dist/esm/digi-header-navigation.entry.js +1 -2
  77. package/dist/esm/digi-header.entry.js +1 -2
  78. package/dist/esm/digi-navigation-pagination.entry.js +1 -2
  79. package/dist/esm/digi-navigation-vertical-menu.entry.js +27 -13
  80. package/dist/esm/digi-notification-alert.entry.js +1 -2
  81. package/dist/esm/digi-notification-error-page.entry.js +1 -2
  82. package/dist/esm/digi-title-logo.entry.js +1 -2
  83. package/dist/esm/digi-tools-feedback.entry.js +1 -2
  84. package/dist/esm/index-BnKuq1L7.js +2 -14
  85. package/dist/esm/index.js +1 -2
  86. package/dist/esm/loader.js +1 -1
  87. package/dist/types/components/_calendar/week-view/calendar-week-view.d.ts +4 -2
  88. package/dist/types/components/_chart/bar-chart/bar-chart.d.ts +4 -2
  89. package/dist/types/components/_chart/chart-line/chart-line.d.ts +3 -1
  90. package/dist/types/components/_navigation/navigation-tablist/navigation-tablist.d.ts +4 -2
  91. package/dist/types/components/_navigation/navigation-vertical-menu/navigation-vertical-menu.d.ts +7 -2
  92. package/dist/types/components.d.ts +3 -3
  93. package/hydrate/index.js +236 -64
  94. package/hydrate/index.mjs +236 -64
  95. package/package.json +1 -1
  96. package/dist/cjs/badge-notification-shape.enum-CEyEo2G5.js +0 -8
  97. package/dist/cjs/digi-badge-notification.cjs.entry.js +0 -65
  98. package/dist/cjs/digi-tablist-panel.cjs.entry.js +0 -20
  99. package/dist/cjs/digi-tablist.cjs.entry.js +0 -289
  100. package/dist/digi-arbetsformedlingen/p-0394e694.entry.js +0 -1
  101. package/dist/digi-arbetsformedlingen/p-09b52191.entry.js +0 -1
  102. package/dist/digi-arbetsformedlingen/p-0c88f210.entry.js +0 -1
  103. package/dist/digi-arbetsformedlingen/p-151248bf.entry.js +0 -1
  104. package/dist/digi-arbetsformedlingen/p-26099889.entry.js +0 -1
  105. package/dist/digi-arbetsformedlingen/p-52a27991.entry.js +0 -1
  106. package/dist/digi-arbetsformedlingen/p-5ee5766d.entry.js +0 -1
  107. package/dist/digi-arbetsformedlingen/p-626c1bf5.entry.js +0 -1
  108. package/dist/digi-arbetsformedlingen/p-674a7a94.entry.js +0 -1
  109. package/dist/digi-arbetsformedlingen/p-6c1fd994.entry.js +0 -1
  110. package/dist/digi-arbetsformedlingen/p-7682ad6f.entry.js +0 -1
  111. package/dist/digi-arbetsformedlingen/p-7f180ce2.entry.js +0 -1
  112. package/dist/digi-arbetsformedlingen/p-88bec555.entry.js +0 -1
  113. package/dist/digi-arbetsformedlingen/p-CKoZU0-H.js +0 -1
  114. package/dist/digi-arbetsformedlingen/p-DH_-wpLB.js +0 -1
  115. package/dist/digi-arbetsformedlingen/p-a556608d.entry.js +0 -1
  116. package/dist/digi-arbetsformedlingen/p-b3410fbd.entry.js +0 -1
  117. package/dist/digi-arbetsformedlingen/p-e002ceb8.entry.js +0 -1
  118. package/dist/digi-arbetsformedlingen/p-e6ee5a17.entry.js +0 -1
  119. package/dist/digi-arbetsformedlingen/p-ec6dd177.entry.js +0 -1
  120. package/dist/digi-arbetsformedlingen/p-eee1b91f.entry.js +0 -1
  121. package/dist/digi-arbetsformedlingen/p-fea63204.entry.js +0 -1
  122. package/dist/digi-arbetsformedlingen/p-ff73fa2f.entry.js +0 -1
  123. package/dist/esm/badge-notification-shape.enum-CKoZU0-H.js +0 -8
  124. package/dist/esm/digi-badge-notification.entry.js +0 -63
  125. package/dist/esm/digi-tablist-panel.entry.js +0 -18
  126. package/dist/esm/digi-tablist.entry.js +0 -287
@@ -97,17 +97,13 @@ License: none (public domain)
97
97
  border-radius: 4px 0 0 0;
98
98
  }
99
99
  :host .digi-calendar__header--month-step .digi-calendar__month-select-button:focus-visible:not(.digi-calendar__date--not-selectable), :host .digi-calendar__header--month-step .digi-calendar__month-select-button:active:not(.digi-calendar__date--not-selectable) {
100
- --digi--calendar--header--button--background: var(
101
- --digi--calendar--header--button--background--hover
102
- );
100
+ --digi--calendar--header--button--background: var(--digi--calendar--header--button--background--hover);
103
101
  text-decoration: underline;
104
102
  cursor: pointer;
105
103
  }
106
104
  @media (any-hover: hover) {
107
105
  :host .digi-calendar__header--month-step .digi-calendar__month-select-button:hover:not(.digi-calendar__date--not-selectable) {
108
- --digi--calendar--header--button--background: var(
109
- --digi--calendar--header--button--background--hover
110
- );
106
+ --digi--calendar--header--button--background: var(--digi--calendar--header--button--background--hover);
111
107
  text-decoration: underline;
112
108
  cursor: pointer;
113
109
  }
@@ -124,6 +120,9 @@ License: none (public domain)
124
120
  table-layout: fixed;
125
121
  margin-bottom: var(--digi--margin--medium);
126
122
  }
123
+ :host .digi-calendar__table th {
124
+ text-align: center;
125
+ }
127
126
  :host .digi-calendar__table-header-week {
128
127
  font-style: italic;
129
128
  padding: var(--digi--calendar--table-header--padding);
@@ -3,6 +3,7 @@ import { h } from "@stencil/core";
3
3
  import { format, getISOWeek, addDays, subDays, setDay } from "date-fns";
4
4
  import svlocale from "date-fns/locale/sv";
5
5
  import { randomIdGenerator } from "../../../global/utils/randomIdGenerator";
6
+ import { logger } from "../../../global/utils/logger";
6
7
  import { ButtonVariation } from "../../_button/button/button-variation.enum";
7
8
  import { CalendarWeekViewHeadingLevel } from "./calendar-week-view-heading-level.enum";
8
9
  /**
@@ -51,7 +52,30 @@ export class CalendarWeekView {
51
52
  this.weekDays = [...newDates];
52
53
  }
53
54
  afDatesUpdate() {
54
- const dateList = [...JSON.parse(this.afDates)];
55
+ // Angular/React can connect the element before afDates is set.
56
+ if (this.afDates == null || this.afDates === '') {
57
+ return;
58
+ }
59
+ const hadDates = this.dates.length > 0;
60
+ let dateList;
61
+ try {
62
+ if (Array.isArray(this.afDates)) {
63
+ dateList = [...this.afDates];
64
+ }
65
+ else if (typeof this.afDates === 'string') {
66
+ dateList = JSON.parse(this.afDates);
67
+ }
68
+ else {
69
+ return;
70
+ }
71
+ }
72
+ catch (_a) {
73
+ logger.warn(`Invalid JSON in "af-dates" attribute`, this.hostElement);
74
+ return;
75
+ }
76
+ if (!Array.isArray(dateList)) {
77
+ return;
78
+ }
55
79
  this.dates = [
56
80
  ...dateList.sort((a, b) => {
57
81
  const c = new Date(a);
@@ -59,6 +83,9 @@ export class CalendarWeekView {
59
83
  return this.getTime(c) - this.getTime(d);
60
84
  })
61
85
  ];
86
+ if (!hadDates && this.dates.length > 0) {
87
+ this.initDates();
88
+ }
62
89
  }
63
90
  /**
64
91
  * Kan användas för att manuellt sätta om det aktiva datumet. Formatet måste vara 'yyyy-MM-dd'.
@@ -82,6 +109,9 @@ export class CalendarWeekView {
82
109
  this.afOnWeekChange.emit('next');
83
110
  }
84
111
  initDates() {
112
+ if (this.dates.length === 0) {
113
+ return;
114
+ }
85
115
  this.minDate = new Date(this.dates[0]);
86
116
  this.maxDate = new Date(this.dates[this.dates.length - 1]);
87
117
  this.selectedDate = format(new Date(this.dates[0]), 'yyyy-MM-dd', {
@@ -93,9 +123,23 @@ export class CalendarWeekView {
93
123
  }
94
124
  componentWillLoad() {
95
125
  this.afDatesUpdate();
96
- this.initDates();
126
+ // Angular attaches the host first and binds `[afDates]` on the next frame
127
+ // (Stencil 4.36+). @Watch skips that first assignment, so if dates are not
128
+ // here yet, wait one frame. React/vanilla that already set the prop skip
129
+ // the delay.
130
+ if (this.dates.length === 0) {
131
+ return new Promise((resolve) => {
132
+ requestAnimationFrame(() => {
133
+ this.afDatesUpdate();
134
+ resolve();
135
+ });
136
+ });
137
+ }
97
138
  }
98
139
  componentDidLoad() {
140
+ if (this.dates.length === 0) {
141
+ this.afDatesUpdate();
142
+ }
99
143
  this.afOnReady.emit();
100
144
  }
101
145
  get prevWeekText() {
@@ -119,7 +163,7 @@ export class CalendarWeekView {
119
163
  format(new Date(lastDate), 'MMMM yyyy', { locale: svlocale });
120
164
  }
121
165
  render() {
122
- return (h("div", { key: '967ccb9710018973a960ae36d52157ba85dacfed', class: "digi-calendar-week-view" }, h("nav", { key: '6a9137d8f8a8e652d26d099ae652cb76e5665b51', class: "digi-calendar-week-view__timepicker" }, h("div", { key: 'a2b8aaeaa93e391e65847b2ea8f9b455e86474f1', class: "digi-calendar-week-view__dates" }, h("div", { key: '0cc675c0cd67d042e5e27a38a6665ab30e516cea', class: "digi-calendar-week-view__flex" }, h("digi-typography", { key: 'd47f59955354cb435dc80895059c6e4fd6eefa8a' }, h(this.afHeadingLevel, { key: 'f01725e82afff23b8ae357b30af909b325d85279', role: "status", class: "digi-calendar-week-view__heading" }, h("span", { key: 'bbfab19eec8776e640ed235654c0fd960faf5722', class: "digi-calendar-week-view__month" }, this.currentMonth), h("span", { key: 'a3a52801083cd83351056d474e01df926d8b0117', class: "digi-calendar-week-view__week" }, ' ', "v.", this.currentWeek))), h("ul", { key: 'a3f3703318fa5400cd32ee5d3af896900a032acd', class: "digi-calendar-week-view__date-list" }, this.weekDays.map((dateItem) => {
166
+ return (h("div", { key: '44d49828a7f43a1f3943aaf0af4139f402844bf0', class: "digi-calendar-week-view" }, h("nav", { key: '44ba98a7c433077c2c11c55b150a5cc2f1d38ac2', class: "digi-calendar-week-view__timepicker" }, h("div", { key: '160ce73dc293abd69193c2b1750c9fd7400b8804', class: "digi-calendar-week-view__dates" }, h("div", { key: '2d60245978d9c7615f3ff5ec7b9d8d628e16f843', class: "digi-calendar-week-view__flex" }, h("digi-typography", { key: '23a1c94d0575061951f67f46782144de52e5e662' }, h(this.afHeadingLevel, { key: 'a183705a035f4d3d57ced74920221f40bbe6019f', role: "status", class: "digi-calendar-week-view__heading" }, h("span", { key: '147910745991716f3557491c6e6aa702f479e8c7', class: "digi-calendar-week-view__month" }, this.currentMonth), h("span", { key: '0d91367cd6066a2b35349edd0ff93e20b5326f04', class: "digi-calendar-week-view__week" }, ' ', "v.", this.currentWeek))), h("ul", { key: 'fdff670cf241e05920e19e0ce6e601b62ae9a3f0', class: "digi-calendar-week-view__date-list" }, this.weekDays.map((dateItem) => {
123
167
  const date = format(new Date(dateItem), 'd', {
124
168
  locale: svlocale
125
169
  });
@@ -139,15 +183,15 @@ export class CalendarWeekView {
139
183
  } }, day), h("span", { class: "digi-calendar-week-view__date-button-date" }, date), h("span", { "aria-hidden": "true", class: {
140
184
  'digi-calendar-week-view__date-button-circle': dateItem === this.todaysDate
141
185
  } })))));
142
- })))), h("digi-button", { key: '2edb685459c4cbf8a0120ab340672b17d0ea3f9f', onClick: () => this.prevWeek(), class: {
186
+ })))), h("digi-button", { key: 'dbae5227d0316a5a67febc7de83b1c4c5cfc1044', onClick: () => this.prevWeek(), class: {
143
187
  'digi-calendar-week-view__week-button digi-calendar-week-view__week-button--previous': true,
144
188
  'digi-calendar-week-view__week-button--keep-left': this.currentWeek == getISOWeek(this.maxDate),
145
189
  'digi-calendar-week-view__week-button--hidden': !(this.currentWeek > getISOWeek(this.minDate))
146
- }, "af-variation": "secondary" }, h("digi-icon-chevron-left", { key: '8948b12a1654f9ef46728ea8de3b1df5f40addcd', slot: "icon" }), this.prevWeekText), h("digi-button", { key: '729ed8eebce68168b66c5365588a52b1279eec3f', onClick: () => this.nextWeek(), class: {
190
+ }, "af-variation": "secondary" }, h("digi-icon-chevron-left", { key: '65d0f656a0d35911d39f9b8e9ade224be54d4371', slot: "icon" }), this.prevWeekText), h("digi-button", { key: '68d9b3d6c929d0185f412add980a542b3c86fbb2', onClick: () => this.nextWeek(), class: {
147
191
  'digi-calendar-week-view__week-button digi-calendar-week-view__week-button--next': true,
148
192
  'digi-calendar-week-view__week-button--keep-right': this.currentWeek == getISOWeek(this.minDate),
149
193
  'digi-calendar-week-view__week-button--hidden': !(this.currentWeek < getISOWeek(this.maxDate))
150
- }, "af-variation": "secondary" }, h("digi-icon-chevron-right", { key: '75bf1669a5d9dd3f618661c79202dc8e69f6c8ea', slot: "icon-secondary" }), this.nextWeekText)), h("div", { key: 'c7379a321936f28783d2f7a4e1e94d0b119de471', role: "status", "aria-live": "assertive", class: "digi-calendar-week-view__result", id: `${this.afId}-result` }, h("digi-typography", { key: 'f7e55435a94c5bff18a3b4b7bfa5d397291f7e8c' }, h("slot", { key: '7c59e144a47c721f5f4a454b9776c708f6d2f15c' })))));
194
+ }, "af-variation": "secondary" }, h("digi-icon-chevron-right", { key: 'a9e688f815a5053aa709cfeb9359131f73df21c0', slot: "icon-secondary" }), this.nextWeekText)), h("div", { key: '7d1073f6cd1982fda2ce7dcb60532c94bd1d0634', role: "status", "aria-live": "assertive", class: "digi-calendar-week-view__result", id: `${this.afId}-result` }, h("digi-typography", { key: 'db7ce0ca80485df1e4ae67200f2cd90cc80938d5' }, h("slot", { key: 'f08f447ae89612dfcea56c638024220bc29e7914' })))));
151
195
  }
152
196
  static get is() { return "digi-calendar-week-view"; }
153
197
  static get encapsulation() { return "scoped"; }
@@ -205,8 +249,8 @@ export class CalendarWeekView {
205
249
  "type": "string",
206
250
  "mutable": true,
207
251
  "complexType": {
208
- "original": "string",
209
- "resolved": "string",
252
+ "original": "string | string[]",
253
+ "resolved": "string | string[]",
210
254
  "references": {}
211
255
  },
212
256
  "required": false,
@@ -373,6 +417,7 @@ export class CalendarWeekView {
373
417
  }
374
418
  };
375
419
  }
420
+ static get elementRef() { return "hostElement"; }
376
421
  static get watchers() {
377
422
  return [{
378
423
  "propName": "selectedDate",
@@ -1,7 +1,7 @@
1
1
  /** Do not touch! Autogenerated
2
2
  */
3
3
  :host {
4
- width: 100%;
4
+ height: 100%;
5
5
  display: flex;
6
6
  flex-direction: column;
7
7
  min-width: 0;
@@ -3,6 +3,7 @@ import { h, Host } from "@stencil/core";
3
3
  import * as d3 from "d3";
4
4
  import { _t } from "../../../text";
5
5
  import { randomIdGenerator } from "../../../global/utils/randomIdGenerator";
6
+ import { logger } from "../../../global/utils/logger";
6
7
  import { BarChartVariation } from "./bar-chart-variation.enum";
7
8
  /**
8
9
  *
@@ -177,6 +178,8 @@ export class barChart {
177
178
  };
178
179
  // Resizing chart while loading
179
180
  this.loadingResize = () => {
181
+ if (!this.barSelection || !this.xScale)
182
+ return;
180
183
  const newHeight = this.setDims();
181
184
  this.barChartContainer.attr('transform', `translate(${this.margin.left + this.tickPadding + this.yTickSize},0)`);
182
185
  this.margin.right =
@@ -442,6 +445,8 @@ export class barChart {
442
445
  return toReturn;
443
446
  };
444
447
  this.adjustBarSize = () => {
448
+ if (!this.barSelection)
449
+ return;
445
450
  this.barSelection
446
451
  .selectAll('.bar')
447
452
  .attr('x', this.xFunction)
@@ -874,13 +879,13 @@ export class barChart {
874
879
  this.initBarText();
875
880
  };
876
881
  // Removes resize observer for chart and inits table
877
- this.activateTable = (event) => {
882
+ this.activateTable = () => {
878
883
  this.closeTooltip();
879
884
  this.barChartObserver.disconnect();
880
885
  this.status.innerHTML = '<p>Visas som tabell</p>';
881
886
  d3.select(this.host).select('.tableButton').style('display', 'none');
882
887
  d3.select(this.host).select('.chartButton').style('display', null);
883
- event.target.nextSibling.lastChild.focus();
888
+ this.focusHostButton('.chartButton');
884
889
  const duration = 150;
885
890
  this.svg
886
891
  .attr('opacity', 1)
@@ -911,11 +916,11 @@ export class barChart {
911
916
  .style('opacity', 0);
912
917
  };
913
918
  // Removes observer and calls init functions for line chart
914
- this.reInitChart = (event) => {
919
+ this.reInitChart = () => {
915
920
  this.status.innerHTML = '<p>Visas som diagram</p>';
916
921
  d3.select(this.host).select('.tableButton').style('display', null);
917
922
  d3.select(this.host).select('.chartButton').style('display', 'none');
918
- event.target.previousSibling.lastChild.focus();
923
+ this.focusHostButton('.tableButton');
919
924
  const table = d3.select(this.tableDiv);
920
925
  const duration = 150;
921
926
  table
@@ -941,14 +946,33 @@ export class barChart {
941
946
  });
942
947
  };
943
948
  }
944
- afChartDataUpdate(data) {
945
- if ((typeof data === 'string' && Object.keys(JSON.parse(data)).length > 0) ||
946
- (typeof data !== 'string' && Object.keys(data).length > 0)) {
947
- if (typeof data != 'string')
948
- this.chartData = data;
949
- else
950
- this.chartData = JSON.parse(data);
951
- this.series = this.chartData.data.series.map((serie) => serie.title);
949
+ afChartDataUpdate() {
950
+ const data = this.afChartData;
951
+ // Angular/React can connect the element before afChartData is set.
952
+ if (data == null || data === '') {
953
+ this.mappedData = this.reshapeData();
954
+ return;
955
+ }
956
+ try {
957
+ let parsed;
958
+ if (typeof data === 'string') {
959
+ parsed = JSON.parse(data);
960
+ }
961
+ else if (typeof data === 'object') {
962
+ parsed = data;
963
+ }
964
+ else {
965
+ this.mappedData = this.reshapeData();
966
+ return;
967
+ }
968
+ if (parsed && Object.keys(parsed).length > 0) {
969
+ this.chartData = parsed;
970
+ this.series = this.chartData.data.series.map((serie) => serie.title);
971
+ }
972
+ }
973
+ catch (_a) {
974
+ logger.warn(`Invalid JSON in "af-chart-data" attribute`, this.hostElement);
975
+ return;
952
976
  }
953
977
  this.mappedData = this.reshapeData();
954
978
  // checking for width of each tick
@@ -959,6 +983,17 @@ export class barChart {
959
983
  if (this.dataWidth > 1)
960
984
  this.barGap = 1;
961
985
  }
986
+ hasChartData() {
987
+ return !!this.chartData && Object.keys(this.chartData).length > 0;
988
+ }
989
+ focusHostButton(selector) {
990
+ var _a, _b;
991
+ const host = this.host;
992
+ const button = (_b = (_a = host === null || host === void 0 ? void 0 : host.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.querySelector('button')) !== null && _b !== void 0 ? _b : host === null || host === void 0 ? void 0 : host.querySelector(selector);
993
+ if (button && typeof button.focus === 'function') {
994
+ button.focus();
995
+ }
996
+ }
962
997
  initSvg() {
963
998
  var _a, _b, _c, _d, _e, _f, _g;
964
999
  // Fetch number formatting
@@ -1526,10 +1561,25 @@ export class barChart {
1526
1561
  Math.min(255, Math.max(0, parseInt(color, 16) + amount)).toString(16)).substr(-2)));
1527
1562
  }
1528
1563
  componentWillLoad() {
1529
- this.afChartDataUpdate(this.afChartData);
1564
+ this.afChartDataUpdate();
1565
+ // Angular attaches the host first and binds `[afChartData]` on the next
1566
+ // frame (Stencil 4.36+). @Watch skips that first assignment, so if chart
1567
+ // data is not here yet, wait one frame. React/vanilla that already set
1568
+ // the prop skip the delay.
1569
+ if (!this.hasChartData()) {
1570
+ return new Promise((resolve) => {
1571
+ requestAnimationFrame(() => {
1572
+ this.afChartDataUpdate();
1573
+ resolve();
1574
+ });
1575
+ });
1576
+ }
1530
1577
  }
1531
1578
  componentDidLoad() {
1532
- if (!this.chartData || Object.keys(this.chartData).length === 0) {
1579
+ if (!this.hasChartData()) {
1580
+ this.afChartDataUpdate();
1581
+ }
1582
+ if (!this.hasChartData()) {
1533
1583
  this.loading = true;
1534
1584
  return this.initEmpty();
1535
1585
  }
@@ -1548,7 +1598,7 @@ export class barChart {
1548
1598
  }
1549
1599
  componentDidUpdate() {
1550
1600
  if (this.tableDiv.style['display'] != 'block' &&
1551
- Object.keys(this.chartData).length === 0) {
1601
+ !this.hasChartData()) {
1552
1602
  // Disconnect old barchartobserver while doing resizing
1553
1603
  this.barChartObserver.disconnect();
1554
1604
  return this.loadingState();
@@ -1628,7 +1678,7 @@ export class barChart {
1628
1678
  if (this.chartData.infoText)
1629
1679
  heading = `${heading}<span style="display:block;margin-top:0.25rem;font-size:0.875rem;color:var(--digi--global--color--neutral--grayscale--darkest-3)">${this.chartData.infoText}</span>`;
1630
1680
  }
1631
- return (h(Host, { key: 'cb70095467051cf1142891bc63694623e707d92f', ref: (el) => (this.host = el) }, h("svg", { key: 'c040fe2f27d9a5e3de1471fe7e4d853757f6a754', xmlns: "http://www.w3.org/2000/svg", width: "0", height: "0" }, h("defs", { key: '17fd52f2cac5a3225e097aee80e8dc1a99909840' }, h("pattern", { key: '2940e729359dad1acc4635363cd5a8f3ee4d8ea1', id: "prognosis", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("rect", { key: '4b47d41ea9f4699a4bcc7b0f04d00b8bbd124946', width: "8", height: "8", fill: "white" }), h("line", { key: 'd5c3a32fb715a5271a784771d9812ea599390fc3', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar(this.colorPalettes[0]), "stroke-width": "8" })), h("pattern", { key: '8038bb4d62fd87a118e0bcf4e750165eed48f789', id: "prognosisInactive", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("rect", { key: 'b1247b7d27e73836c7b5a05fb77a872e89853d3b', width: "8", height: "8", fill: "white" }), h("line", { key: '14265bcba469f08b890654315a86d6278271d64d', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar('--digi--color--background--secondary-accent'), "stroke-width": "8" })), h("pattern", { key: '4069999fd742795379f093c83c00cca488b6139c', id: "prognosisHighlight", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("rect", { key: 'c525ae39e05acf3e7522f1b92feffdfe5221e528', width: "8", height: "8", fill: "white" }), h("line", { key: 'fa183e0678f6f3794e094b97975fe96955b49e0a', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.adjustColor(this.colorFunction(0), 50), "stroke-width": "8" })))), h("div", { key: 'b6e46d7f4701775a177b02a98f46ca40308e9938', class: "topWrapper", ref: (el) => (this.titleDiv = el) }, h("digi-typography", { key: '88d49833d43776a2bc23d7f73bb8cc9442350634', class: "chartTitle", innerHTML: heading }), h("digi-button", { key: '75e2ef09c3f9f91a08b3596d02ad308b244586bb', class: "buttonWrapper tableButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.activateTable, afAriaLabel: `Visa tabell ${((_a = this.chartData) === null || _a === void 0 ? void 0 : _a.title) ? (_b = this.chartData) === null || _b === void 0 ? void 0 : _b.title.toLowerCase() : ''}` }, h("digi-icon-table", { key: '7712b56f991bb5214aa3bebb9e380221156b6bbf', slot: "icon" }), "Visa tabell"), h("digi-button", { key: 'b9d442ea0b62303c2bf1018651ce3206063f3b35', style: { display: 'none' }, class: "buttonWrapper chartButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.reInitChart, afAriaLabel: `Visa diagram ${((_c = this.chartData) === null || _c === void 0 ? void 0 : _c.title) ? (_d = this.chartData) === null || _d === void 0 ? void 0 : _d.title.toLowerCase() : ''}` }, h("digi-icon-chart", { key: '260c432d04f8ea00216cd485b5ec3a29df4b4db1', slot: "icon" }), "Visa diagram"), h("div", { key: 'a7fd6276b5738e9cf040f0e9b99e983b27ec25cf', class: "scChartStatus", role: "status", ref: (el) => (this.status = el) })), h("div", { key: '705ec9e3931b91009ff565bbd8f4ba300bd8dbd7', class: "svgWrap", ref: (el) => (this.chartDiv = el) }, h("div", { key: '242fd5b7afba36df00aa7fb256bd8578712d25e7', class: "chartTooltip", id: this.afId }, h("div", { key: '6417cc30962396164fe4840ecfef62c4ef7591d6', class: "tooltipHead" }, h("digi-icon-x", { key: 'dc4edb442bfb342fbdb64b06e70f1e19ccc5ffb1', class: "tooltipClose" })), h("div", { key: 'da625c879d4c0eebffa02193dc36d794c755b768', class: "tooltipBody" }), this.afVariation === BarChartVariation.Horizontal ? (h("digi-icon-caret-up", { class: "caret" })) : (h("digi-icon-caret-down", { class: "caret" })))), h("div", { key: 'a003a616c2ee8b848d402b38009261539ebf0c50', class: "legendWrap", ref: (el) => (this.legendDiv = el) }, h("div", { key: '44a6db8daa836ccf910aafd6fd996f153c337bf4', class: "legend" })), h("div", { key: 'a872281035f2799fe8aa9128a953d0c5d9f6b2cc', class: "table", ref: (el) => (this.tableDiv = el) }, ' ')));
1681
+ return (h(Host, { key: '003845ddc03e2027721d5e75c82816faae5bde63', ref: (el) => (this.host = el) }, h("svg", { key: '054049009c8618211f9009961d238992c3d03c0e', xmlns: "http://www.w3.org/2000/svg", width: "0", height: "0" }, h("defs", { key: '16f32628ffd79e24b66e749666eccd6ae283a5b8' }, h("pattern", { key: '8aa5e0923086f740eeb02d71690ed16086205b0a', id: "prognosis", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("rect", { key: '237569e79095a4a7c084aa91fd637dfbe385ca8b', width: "8", height: "8", fill: "white" }), h("line", { key: '6edeac6a60cef51561c8fd803b2e277b19b740bf', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar(this.colorPalettes[0]), "stroke-width": "8" })), h("pattern", { key: 'bd40402b6fd33d50fc4dca709380108fe054f74c', id: "prognosisInactive", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("rect", { key: 'a5dcf48112b024982f3410bc51eb05002c8c8dcc', width: "8", height: "8", fill: "white" }), h("line", { key: 'b76b6ae15b8a0ee9c37c28bf3f66613c9df1e9b8', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.evalColorVar('--digi--color--background--secondary-accent'), "stroke-width": "8" })), h("pattern", { key: 'ef4782b914f2599424d5f3e6715cb69c4f0e4728', id: "prognosisHighlight", patternUnits: "userSpaceOnUse", width: "8", height: "8", patternTransform: "rotate(45)" }, h("rect", { key: '6501ba8a46f53b6c3309486d0795d348a8ec1fff', width: "8", height: "8", fill: "white" }), h("line", { key: 'b184212878587e1e15ebf40a472333851270b287', x1: "0", y: "0", x2: "0", y2: "12", stroke: this.adjustColor(this.colorFunction(0), 50), "stroke-width": "8" })))), h("div", { key: '02b5c9c63c327995f9603ffc84ab0455137ff43d', class: "topWrapper", ref: (el) => (this.titleDiv = el) }, h("digi-typography", { key: 'd8944066ab1a86ed71af7de4a018ef422cea75e9', class: "chartTitle", innerHTML: heading }), h("digi-button", { key: '6bc1e5870432720980fc8dad25abc5f2cb474daf', class: "buttonWrapper tableButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.activateTable, afAriaLabel: `Visa tabell ${((_a = this.chartData) === null || _a === void 0 ? void 0 : _a.title) ? (_b = this.chartData) === null || _b === void 0 ? void 0 : _b.title.toLowerCase() : ''}` }, h("digi-icon-table", { key: '5a8b44b3a201b4866b89fc4328ff0b46ac47c6e1', slot: "icon" }), "Visa tabell"), h("digi-button", { key: 'cd0d60a025d5fa0e62cb5f6a322cf3f97c0bd02e', style: { display: 'none' }, class: "buttonWrapper chartButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.reInitChart, afAriaLabel: `Visa diagram ${((_c = this.chartData) === null || _c === void 0 ? void 0 : _c.title) ? (_d = this.chartData) === null || _d === void 0 ? void 0 : _d.title.toLowerCase() : ''}` }, h("digi-icon-chart", { key: '8f4e4f1bdabffd7ffd1532453b534a823ef65006', slot: "icon" }), "Visa diagram"), h("div", { key: '22535e8bfb69f96152e61295019d463cb69b70c3', class: "scChartStatus", role: "status", ref: (el) => (this.status = el) })), h("div", { key: '55e25140585469497ec501cd133cfc710bb88b43', class: "svgWrap", ref: (el) => (this.chartDiv = el) }, h("div", { key: '4d8cd2eb832770f94fdff5eec2f084e4ba5c96b8', class: "chartTooltip", id: this.afId }, h("div", { key: 'b805b20b746ce940ae5c20ef34898c3409cffecd', class: "tooltipHead" }, h("digi-icon-x", { key: 'c162d2b1e6e7aafddf0ac194705b436a5b02b392', class: "tooltipClose" })), h("div", { key: 'cdc876d4c88f50c7d95c22f4d0f683c2a5564235', class: "tooltipBody" }), this.afVariation === BarChartVariation.Horizontal ? (h("digi-icon-caret-up", { class: "caret" })) : (h("digi-icon-caret-down", { class: "caret" })))), h("div", { key: '8cb986f7466fdb42f6dc840c1371b25978ae4c66', class: "legendWrap", ref: (el) => (this.legendDiv = el) }, h("div", { key: '6761a567c03c8ade4206fb89cf9e7bd792c36e71', class: "legend" })), h("div", { key: 'ac251b6078602f9319447cfaa6444f0129e46c0f', class: "table", ref: (el) => (this.tableDiv = el) }, ' ')));
1632
1682
  }
1633
1683
  static get is() { return "digi-bar-chart"; }
1634
1684
  static get encapsulation() { return "scoped"; }
@@ -3,6 +3,7 @@ import { _t } from "../../../text";
3
3
  import { h } from "@stencil/core";
4
4
  import * as d3 from "d3";
5
5
  import { randomIdGenerator } from "../../../global/utils/randomIdGenerator";
6
+ import { logger } from "../../../global/utils/logger";
6
7
  /**
7
8
  *
8
9
  * @enums myEnum - chart-line-myEnum.enum.ts
@@ -891,14 +892,14 @@ export class ChartLine {
891
892
  });
892
893
  };
893
894
  // Removes resize observer for chart and inits table
894
- this.activateTable = (event) => {
895
+ this.activateTable = () => {
895
896
  this.closeTooltip();
896
897
  this.lineChartObserver.disconnect();
897
898
  this.tableObserver.observe(this._chartDiv);
898
899
  this._status.innerHTML = '<p>Visas som tabell</p>';
899
900
  d3.select(this._host).select('.tableButton').style('display', 'none');
900
901
  d3.select(this._host).select('.chartButton').style('display', null);
901
- event.target.nextSibling.lastChild.focus();
902
+ this.focusHostButton('.chartButton');
902
903
  const duration = 150;
903
904
  this._svg
904
905
  .attr('opacity', 1)
@@ -929,12 +930,12 @@ export class ChartLine {
929
930
  this.setTableDimensions();
930
931
  };
931
932
  // Removes observer and calls init functions for line chart
932
- this.reInitChart = (event) => {
933
+ this.reInitChart = () => {
933
934
  this.tableObserver.disconnect();
934
935
  this._status.innerHTML = '<p>Visas som diagram</p>';
935
936
  d3.select(this._host).select('.tableButton').style('display', null);
936
937
  d3.select(this._host).select('.chartButton').style('display', 'none');
937
- event.target.previousSibling.lastChild.focus();
938
+ this.focusHostButton('.tableButton');
938
939
  const table = d3.select(this._tableDiv);
939
940
  table
940
941
  .style('opacity', 1)
@@ -961,15 +962,40 @@ export class ChartLine {
961
962
  }
962
963
  afChartDataUpdate() {
963
964
  const data = this.afChartData;
964
- if (typeof data === 'object') {
965
- this._chartData = Object.assign({}, data);
965
+ // Angular/React can connect the element before afChartData is set.
966
+ if (data == null || data === '') {
967
+ return;
968
+ }
969
+ try {
970
+ if (typeof data === 'object') {
971
+ this._chartData = Object.assign({}, data);
972
+ }
973
+ else if (typeof data === 'string') {
974
+ this._chartData = JSON.parse(data);
975
+ }
976
+ else {
977
+ return;
978
+ }
979
+ }
980
+ catch (_a) {
981
+ logger.warn(`Invalid JSON in "af-chart-data" attribute`, this.element);
966
982
  return;
967
983
  }
968
- this._chartData = JSON.parse(data);
969
984
  // Making deep copy of this
970
985
  if (this._chartData.data)
971
986
  this._coreSeries = JSON.parse(JSON.stringify(this._chartData.data.series));
972
987
  }
988
+ hasChartData() {
989
+ return !!this._chartData && Object.keys(this._chartData).length > 0;
990
+ }
991
+ focusHostButton(selector) {
992
+ var _a, _b;
993
+ const host = this._host;
994
+ const button = (_b = (_a = host === null || host === void 0 ? void 0 : host.querySelector(selector)) === null || _a === void 0 ? void 0 : _a.querySelector('button')) !== null && _b !== void 0 ? _b : host === null || host === void 0 ? void 0 : host.querySelector(selector);
995
+ if (button && typeof button.focus === 'function') {
996
+ button.focus();
997
+ }
998
+ }
973
999
  initSvg() {
974
1000
  this.margin.bottom =
975
1001
  Number(window
@@ -1439,9 +1465,24 @@ export class ChartLine {
1439
1465
  }
1440
1466
  componentWillLoad() {
1441
1467
  this.afChartDataUpdate();
1468
+ // Angular attaches the host first and binds `[afChartData]` on the next
1469
+ // frame (Stencil 4.36+). @Watch skips that first assignment, so if chart
1470
+ // data is not here yet, wait one frame. React/vanilla that already set
1471
+ // the prop skip the delay.
1472
+ if (!this.hasChartData()) {
1473
+ return new Promise((resolve) => {
1474
+ requestAnimationFrame(() => {
1475
+ this.afChartDataUpdate();
1476
+ resolve();
1477
+ });
1478
+ });
1479
+ }
1442
1480
  }
1443
1481
  componentDidLoad() {
1444
- if (Object.keys(this._chartData).length === 0)
1482
+ if (!this.hasChartData()) {
1483
+ this.afChartDataUpdate();
1484
+ }
1485
+ if (!this.hasChartData())
1445
1486
  return this.initEmpty();
1446
1487
  // clearing selection
1447
1488
  this._selectedLines = [];
@@ -1457,7 +1498,7 @@ export class ChartLine {
1457
1498
  this._prevHeight = d3.select(this._titleDiv).style('height');
1458
1499
  }
1459
1500
  componentDidUpdate() {
1460
- if (Object.keys(this._chartData).length === 0)
1501
+ if (!this.hasChartData())
1461
1502
  return this.loadingState();
1462
1503
  // clearing selection
1463
1504
  this._selectedLines = [];
@@ -1614,11 +1655,13 @@ export class ChartLine {
1614
1655
  }
1615
1656
  render() {
1616
1657
  let heading = '';
1617
- if (!this._chartData.subTitle)
1618
- heading = `<${this.afHeadingLevel}>${this._chartData.title}</${this.afHeadingLevel}>`;
1619
- else
1620
- heading = `<${this.afHeadingLevel}>${this._chartData.title}</${this.afHeadingLevel}><p>${this._chartData.subTitle}</p>`;
1621
- return (h("host", { key: 'a21c09ee91ccabf90f91d2344d301d26710f9a60', ref: (el) => (this._host = el) }, h("div", { key: 'c97af6a0bbc28675a19c843a3c355b35397e5804', class: "topWrapper", ref: (el) => (this._titleDiv = el) }, h("digi-typography", { key: '76085c6924fd317d4a281e93ca4623b85f0fb867', class: "chartTitle", innerHTML: heading }), h("digi-button", { key: '241e30b3094e8eea86c7c24bb2a90f67ea04ef6f', class: "buttonWrapper tableButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.activateTable, afAriaLabel: `Visa tabell ${this._chartData.title ? this._chartData.title.toLowerCase() : ''}` }, h("digi-icon-table", { key: '5cc0d03d40d076481d14d0478390b131cdaa61f7', slot: "icon" }), "Visa tabell"), h("digi-button", { key: '241d3e97b9a21f556b3e46cebc63c77ce106d26c', style: { display: 'none' }, class: "buttonWrapper chartButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.reInitChart, afAriaLabel: `Visa diagram ${this._chartData.title ? this._chartData.title.toLowerCase() : ''}` }, h("digi-icon-chart", { key: 'f0a5c78bc5e04db994559f2ce1a13c0e7285c36d', slot: "icon" }), "Visa diagram"), h("div", { key: 'f7ebab0f90d1a9f9a306470c93ccaaaf0461a9a7', class: "scChartStatus", role: "status", ref: (el) => (this._status = el) })), h("div", { key: '75672c02d61a14741348dc183782df71f3a4db19', class: "chartTooltip", id: this.afId }, h("div", { key: 'b4e03381d825d68af2bdbf859458896c639b6559', class: "tooltipHead" }, h("digi-icon-x", { key: '1301ab00ff3818e0940e69f17aa09b296c04a86c', class: "close" }), ' '), h("div", { key: 'eb01d362db4495c0a3d4396ad4c71c2a952114ad', class: "tooltipBody" })), h("div", { key: 'accd6776d3db14c662ff84b2e826f6cf713ff38d', class: "chart", ref: (el) => (this._chartDiv = el) }), h("div", { key: '507dfba00c88d5b371fd8304053b9b7762506d25', class: "legend", ref: (el) => (this._legendDiv = el) }), h("div", { key: 'cb3fc091c6a557bfd62e8f7d59863e973da0ee53', class: "table", ref: (el) => (this._tableDiv = el) }, ' ')));
1658
+ if (this._chartData) {
1659
+ if (!this._chartData.subTitle)
1660
+ heading = `<${this.afHeadingLevel}>${this._chartData.title}</${this.afHeadingLevel}>`;
1661
+ else
1662
+ heading = `<${this.afHeadingLevel}>${this._chartData.title}</${this.afHeadingLevel}><p>${this._chartData.subTitle}</p>`;
1663
+ }
1664
+ return (h("host", { key: '93603df9b78fcce8b5735b4a874f879cf7b2326e', ref: (el) => (this._host = el) }, h("div", { key: '094a790864b72bbb9a802b461db06ce312c627c8', class: "topWrapper", ref: (el) => (this._titleDiv = el) }, h("digi-typography", { key: '5f4bd51fdfef816b0e127d1177c60f8310952173', class: "chartTitle", innerHTML: heading }), h("digi-button", { key: '8ae72950c5cf052ed71c2ba4e91b254b8d36cfd0', class: "buttonWrapper tableButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.activateTable, afAriaLabel: `Visa tabell ${this._chartData.title ? this._chartData.title.toLowerCase() : ''}` }, h("digi-icon-table", { key: '750f1b621eb0a1a54ec810aa63624237bd98f9ea', slot: "icon" }), "Visa tabell"), h("digi-button", { key: '1cf33daaaa8adf9c5352286d6172d7c258098c29', style: { display: 'none' }, class: "buttonWrapper chartButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.reInitChart, afAriaLabel: `Visa diagram ${this._chartData.title ? this._chartData.title.toLowerCase() : ''}` }, h("digi-icon-chart", { key: '9dce5df1a96d4b818597854f7ee238fefda2c686', slot: "icon" }), "Visa diagram"), h("div", { key: '204f5824b2f34b3a1a1401ed4434e1fcb16a2549', class: "scChartStatus", role: "status", ref: (el) => (this._status = el) })), h("div", { key: 'b164f59f1c741db5493af57510eab2987cabefc6', class: "chartTooltip", id: this.afId }, h("div", { key: 'e84bf8a85a745977006d50f296d1afee2ee35698', class: "tooltipHead" }, h("digi-icon-x", { key: '77bcd0342c828dbcbe020a9ffefe4ae6f3086572', class: "close" }), ' '), h("div", { key: '330f69a58082f72b528095ef49a2371fc8b0d8e5', class: "tooltipBody" })), h("div", { key: '62eb27ac8f184476d50332344711ca381e8adf59', class: "chart", ref: (el) => (this._chartDiv = el) }), h("div", { key: 'ad70790d3a2fd5851c4351e41f2436a34169a819', class: "legend", ref: (el) => (this._legendDiv = el) }), h("div", { key: '30d4791a9b808555f03d1830aaec0221c1bc3b37', class: "table", ref: (el) => (this._tableDiv = el) }, ' ')));
1622
1665
  }
1623
1666
  static get is() { return "digi-chart-line"; }
1624
1667
  static get encapsulation() { return "scoped"; }
@@ -98,14 +98,10 @@ export class NavigationTablist {
98
98
  }
99
99
  }
100
100
  syncPanels() {
101
- // side-effect
102
- if (this.panelsRef != null) {
103
- const panels = this.panelsRef.querySelectorAll(':scope>digi-tablist-panel');
104
- for (let i = 0; i < panels.length; i++) {
105
- const panel = panels[i];
106
- const showPanel = panel.tab === this.tabs[this.activeTab].id;
107
- panel.isVisible = showPanel;
108
- }
101
+ var _a;
102
+ const activeId = (_a = this.tabs[this.activeTab]) === null || _a === void 0 ? void 0 : _a.id;
103
+ for (const panel of this.getSlottedPanels()) {
104
+ panel.isVisible = panel.tab === activeId;
109
105
  }
110
106
  }
111
107
  handleTabPropChange(tabId) {
@@ -136,6 +132,11 @@ export class NavigationTablist {
136
132
  this.windowTab = tabIdx;
137
133
  }
138
134
  setupTabs(tabs) {
135
+ // Angular/React can connect the element before afTabs is set.
136
+ if (tabs == null || tabs === '') {
137
+ return;
138
+ }
139
+ const hadTabs = this.tabs.length > 0;
139
140
  if (typeof tabs === 'string') {
140
141
  this.tabs = JSON.parse(tabs);
141
142
  }
@@ -145,6 +146,13 @@ export class NavigationTablist {
145
146
  else {
146
147
  throw new Error('Invalid format or no tabs supplied');
147
148
  }
149
+ if (!hadTabs) {
150
+ this.setupInitialTab();
151
+ }
152
+ this.syncPanels();
153
+ }
154
+ getSlottedPanels() {
155
+ return Array.from(this.hostElement.querySelectorAll('digi-tablist-panel')).filter((panel) => panel.closest('digi-tablist') === this.hostElement);
148
156
  }
149
157
  setActiveTabById(id) {
150
158
  const tabIdx = this.tabs.findIndex((tab) => tab.id === id);
@@ -212,9 +220,23 @@ export class NavigationTablist {
212
220
  componentWillLoad() {
213
221
  this.setupTabs(this.afTabs);
214
222
  this.setupInitialTab();
223
+ // Angular attaches the host first and binds `[afTabs]` on the next frame
224
+ // (Stencil 4.36+). @Watch skips that first assignment, so if tabs are not
225
+ // here yet, wait one frame. React/vanilla that already set the prop skip
226
+ // the delay.
227
+ if (this.tabs.length === 0) {
228
+ return new Promise((resolve) => {
229
+ requestAnimationFrame(() => {
230
+ this.setupTabs(this.afTabs);
231
+ this.setupInitialTab();
232
+ resolve();
233
+ });
234
+ });
235
+ }
215
236
  }
216
237
  componentDidLoad() {
217
238
  var _a, _b, _c;
239
+ this.setupTabs(this.afTabs);
218
240
  // Also listen to window resize for viewport zoom changes
219
241
  if (window) {
220
242
  window.addEventListener('resize', this.handleResize, { passive: true });
@@ -236,14 +258,14 @@ export class NavigationTablist {
236
258
  cancelAnimationFrame(this._requestAnimationFrame);
237
259
  }
238
260
  render() {
239
- return (h(Host, { key: '8bdab05cd034b9940aefcb9f38b16d09b6f0b0c7' }, h("div", { key: '2d2266a9600dcc5817130ed4ece38868779e0b69', class: {
261
+ return (h(Host, { key: 'b2d71ff4b3f2c2fa22feffbc298360c1b3202b1d' }, h("div", { key: 'df48ffc9fdabfca380675c7232af5fef80c445b9', class: {
240
262
  'digi-tablist': true,
241
263
  'digi-tablist--overflow-scroll': this.afOverflowMode === OverflowMode.Scroll,
242
264
  'digi-tablist--overflow-controls': this.afOverflowMode === OverflowMode.Controls
243
- } }, h("div", { key: 'a96cd5d9a2eec5b2b52f0d1a00b2810c28e8d4bd', class: "control-wrapper", style: {
265
+ } }, h("div", { key: '797f70a00aa1e3dd8a3b54d43808b9515259723c', class: "control-wrapper", style: {
244
266
  left: '0',
245
267
  visibility: this.showPrev ? 'visible' : 'hidden'
246
- } }, h("button", { key: '7a9810781c300bd44aa7ce3f3f76f651b1799023', tabIndex: -1, type: "button", "aria-hidden": "true", class: { 'tab-control-button': true }, onClick: () => this.handleTabControl(Direction.Previous) }, h("digi-icon-chevron-left", { key: '8f65c019aa2a60f8d10025c147ad2448d30cdf1d' }))), h("div", { key: '7be08fe744f17f71fab7358d63d010f17e5c977d', role: "tablist", ref: (ref) => (this.tablistRef = ref), "aria-labelledby": this.afAriaLabelledby, "aria-label": this.afAriaLabel }, this.tabs.map((tab) => {
268
+ } }, h("button", { key: '415237740bc65dd5cfdb0e57eb44307c9d838670', tabIndex: -1, type: "button", "aria-hidden": "true", class: { 'tab-control-button': true }, onClick: () => this.handleTabControl(Direction.Previous) }, h("digi-icon-chevron-left", { key: '59f2d43ba38c7d4ebdd85a575b2e89c0fec62381' }))), h("div", { key: '01602338cbd7a63f48cdcf541629e76bac46dd4c', role: "tablist", ref: (ref) => (this.tablistRef = ref), "aria-labelledby": this.afAriaLabelledby, "aria-label": this.afAriaLabel }, this.tabs.map((tab) => {
247
269
  const focusable = tab.id === this.tabs[this.selectedTab].id;
248
270
  const isActive = tab.id === this.tabs[this.activeTab].id;
249
271
  const Icon = `digi-icon-${tab.icon}`;
@@ -252,10 +274,10 @@ export class NavigationTablist {
252
274
  'digi-tab': true,
253
275
  'is-active': isActive
254
276
  }, id: `tab-${tab.id}`, role: "tab", type: "button", tabindex: focusable ? '0' : '-1', "aria-label": tab.ariaLabel, "aria-selected": isActive.toString(), "aria-controls": `tabpanel-${tab.id}`, onClick: () => this.handleTabChange(tab) }, h("div", { class: "content-wrapper" }, h("span", { class: "tablist-content" }, tab.icon && h(Icon, { "aria-hidden": "true" }), h("span", { class: "title", "data-text": tab.title }, tab.title), tab.badgeValue && (h("digi-badge-notification", { afValue: badgeValue, "aria-hidden": "true" }))), h("div", { class: "indicator" }))));
255
- })), h("div", { key: 'b79ea56eb945fe5c4b2e34529d8b1985018ac46c', class: "control-wrapper", style: {
277
+ })), h("div", { key: 'db28ea61c349d7aaf057e84b607c4f851b3f6712', class: "control-wrapper", style: {
256
278
  right: '0',
257
279
  visibility: this.showNext ? 'visible' : 'hidden'
258
- } }, h("button", { key: '3d581fe07f9591f21fef85e700259d3b44332631', tabIndex: -1, type: "button", "aria-hidden": "true", class: { 'tab-control-button': true }, onClick: () => this.handleTabControl(Direction.Next) }, h("digi-icon-chevron-right", { key: '1f3a564d4eff7851ad13901c492e663c5c43d384' })))), h("div", { key: '2cd9aa7d409b36395febee9dfd26eb6e82b02f35', ref: (ref) => (this.panelsRef = ref), role: "presentation" }, h("slot", { key: 'b9f82031b00032dfb1df2358546a8a35934033a0' }))));
280
+ } }, h("button", { key: '83513f2d64cc0578155d305f21dfb1ca4a412cc6', tabIndex: -1, type: "button", "aria-hidden": "true", class: { 'tab-control-button': true }, onClick: () => this.handleTabControl(Direction.Next) }, h("digi-icon-chevron-right", { key: '9263e864c21ea5358f301214fbadda6ed7d3c74a' })))), h("div", { key: '205efbbb3aab40f51f9f85f8d74a4026970c7144', role: "presentation" }, h("slot", { key: 'e753d718f852072745f5c2a49f6189fb62f3645b', onSlotchange: () => this.syncPanels() }))));
259
281
  }
260
282
  static get is() { return "digi-tablist"; }
261
283
  static get encapsulation() { return "scoped"; }
@@ -485,6 +507,7 @@ export class NavigationTablist {
485
507
  }
486
508
  }];
487
509
  }
510
+ static get elementRef() { return "hostElement"; }
488
511
  static get watchers() {
489
512
  return [{
490
513
  "propName": "activeTab",