@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
@@ -2,6 +2,7 @@ import { p as proxyCustomElement, H, h, c as Host, t as transformTag } from './p
2
2
  import { o as ordinal, i as initRange, r as range, s as select, a as axisLeft, l as linear, b as axisBottom, m as max, p as polyInOut, c as min, d as linear$1 } from './p-lPbx4RHH.js';
3
3
  import { _ as _t } from './p-DsO1BTml.js';
4
4
  import { r as randomIdGenerator } from './p-BGaIliX6.js';
5
+ import { l as logger } from './p-DdB9j8uV.js';
5
6
  import { B as BarChartVariation } from './p-DPeoHh1J.js';
6
7
  import { d as defineCustomElement$8 } from './p-BxG1tqmk.js';
7
8
  import { d as defineCustomElement$7 } from './p-1kIXcBRD.js';
@@ -91,7 +92,7 @@ function band() {
91
92
  return initRange.apply(rescale(), arguments);
92
93
  }
93
94
 
94
- const barChartCss = () => `.sc-digi-bar-chart-h{width:100%;display:flex;flex-direction:column;min-width:0}.sc-digi-bar-chart-h .digi-bar-chart.sc-digi-bar-chart{font-family:var(--digi--global--typography--font-family--default)}.sc-digi-bar-chart-h .svgWrap.sc-digi-bar-chart{position:relative;display:flex;min-height:20px;min-width:20px;width:100%;height:100%}.sc-digi-bar-chart-h .topWrapper.sc-digi-bar-chart,.sc-digi-bar-chart-h .chartTitle.sc-digi-bar-chart .digi-typography.sc-digi-bar-chart{display:flex;flex-direction:column;gap:0.75rem}.sc-digi-bar-chart-h .topWrapper.sc-digi-bar-chart{margin-bottom:0.75rem}.sc-digi-bar-chart-h .chartTitle.sc-digi-bar-chart{--MARGIN--HEADING-2:0;--MARGIN--HEADING-3:0;--MARGIN--HEADING-4:0;--MARGIN--HEADING-5:0;--MARGIN--HEADING-6:0;--MARGIN--BODY:0}.sc-digi-bar-chart-h .buttonWrapper.sc-digi-bar-chart{--digi--button--padding--medium:0 0 0.75rem 0}.sc-digi-bar-chart-h .chartTooltip.sc-digi-bar-chart{top:-5px;position:absolute;background-color:var(--digi--color--background--primary);color:black;padding:5px 10px;padding-right:5px;border-radius:4px;display:block;width:max-content;white-space:nowrap;filter:drop-shadow(rgba(0, 0, 0, 0.8) 0px 0px 1px);font-size:0.875rem}.sc-digi-bar-chart-h .tooltipBody.sc-digi-bar-chart{display:inline-block}.sc-digi-bar-chart-h .tooltipHead.sc-digi-bar-chart{display:flex;flex-direction:row;justify-content:space-between}.sc-digi-bar-chart-h .tooltipClose.sc-digi-bar-chart{display:inline-block;vertical-align:top;--digi--color--icon--primary:#333;cursor:pointer}.sc-digi-bar-chart-h .tooltipClose.sc-digi-bar-chart:hover{--digi--color--icon--primary:gray}.sc-digi-bar-chart-h .legendWrap.sc-digi-bar-chart{display:grid}.sc-digi-bar-chart-h .legend.sc-digi-bar-chart{display:flex;flex-direction:row;gap:1rem;min-width:0;overflow-x:auto;scrollbar-gutter:stable}.sc-digi-bar-chart-h .caret.sc-digi-bar-chart{--digi--icon--color:var(--digi--color--background--primary)}.sc-digi-bar-chart-h .scChartStatus.sc-digi-bar-chart{border:0;clip:rect(1px, 1px, 1px, 1px);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sc-digi-bar-chart-h .table.sc-digi-bar-chart{display:none;overflow-y:auto;height:auto;border-radius:4px;background:linear-gradient(white 30%, rgba(255, 255, 255, 0)) center top, linear-gradient(rgba(255, 255, 255, 0), white 70%) center bottom, radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) center top, radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) center bottom;background-repeat:no-repeat;background-size:100% 40px, 100% 40px, 100% 14px, 100% 14px;background-attachment:local, local, scroll, scroll}`;
95
+ const barChartCss = () => `.sc-digi-bar-chart-h{height:100%;display:flex;flex-direction:column;min-width:0}.sc-digi-bar-chart-h .digi-bar-chart.sc-digi-bar-chart{font-family:var(--digi--global--typography--font-family--default)}.sc-digi-bar-chart-h .svgWrap.sc-digi-bar-chart{position:relative;display:flex;min-height:20px;min-width:20px;width:100%;height:100%}.sc-digi-bar-chart-h .topWrapper.sc-digi-bar-chart,.sc-digi-bar-chart-h .chartTitle.sc-digi-bar-chart .digi-typography.sc-digi-bar-chart{display:flex;flex-direction:column;gap:0.75rem}.sc-digi-bar-chart-h .topWrapper.sc-digi-bar-chart{margin-bottom:0.75rem}.sc-digi-bar-chart-h .chartTitle.sc-digi-bar-chart{--MARGIN--HEADING-2:0;--MARGIN--HEADING-3:0;--MARGIN--HEADING-4:0;--MARGIN--HEADING-5:0;--MARGIN--HEADING-6:0;--MARGIN--BODY:0}.sc-digi-bar-chart-h .buttonWrapper.sc-digi-bar-chart{--digi--button--padding--medium:0 0 0.75rem 0}.sc-digi-bar-chart-h .chartTooltip.sc-digi-bar-chart{top:-5px;position:absolute;background-color:var(--digi--color--background--primary);color:black;padding:5px 10px;padding-right:5px;border-radius:4px;display:block;width:max-content;white-space:nowrap;filter:drop-shadow(rgba(0, 0, 0, 0.8) 0px 0px 1px);font-size:0.875rem}.sc-digi-bar-chart-h .tooltipBody.sc-digi-bar-chart{display:inline-block}.sc-digi-bar-chart-h .tooltipHead.sc-digi-bar-chart{display:flex;flex-direction:row;justify-content:space-between}.sc-digi-bar-chart-h .tooltipClose.sc-digi-bar-chart{display:inline-block;vertical-align:top;--digi--color--icon--primary:#333;cursor:pointer}.sc-digi-bar-chart-h .tooltipClose.sc-digi-bar-chart:hover{--digi--color--icon--primary:gray}.sc-digi-bar-chart-h .legendWrap.sc-digi-bar-chart{display:grid}.sc-digi-bar-chart-h .legend.sc-digi-bar-chart{display:flex;flex-direction:row;gap:1rem;min-width:0;overflow-x:auto;scrollbar-gutter:stable}.sc-digi-bar-chart-h .caret.sc-digi-bar-chart{--digi--icon--color:var(--digi--color--background--primary)}.sc-digi-bar-chart-h .scChartStatus.sc-digi-bar-chart{border:0;clip:rect(1px, 1px, 1px, 1px);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sc-digi-bar-chart-h .table.sc-digi-bar-chart{display:none;overflow-y:auto;height:auto;border-radius:4px;background:linear-gradient(white 30%, rgba(255, 255, 255, 0)) center top, linear-gradient(rgba(255, 255, 255, 0), white 70%) center bottom, radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) center top, radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) center bottom;background-repeat:no-repeat;background-size:100% 40px, 100% 40px, 100% 14px, 100% 14px;background-attachment:local, local, scroll, scroll}`;
95
96
 
96
97
  const barChart = /*@__PURE__*/ proxyCustomElement(class barChart extends H {
97
98
  constructor(registerHost) {
@@ -264,6 +265,8 @@ const barChart = /*@__PURE__*/ proxyCustomElement(class barChart extends H {
264
265
  };
265
266
  // Resizing chart while loading
266
267
  this.loadingResize = () => {
268
+ if (!this.barSelection || !this.xScale)
269
+ return;
267
270
  const newHeight = this.setDims();
268
271
  this.barChartContainer.attr('transform', `translate(${this.margin.left + this.tickPadding + this.yTickSize},0)`);
269
272
  this.margin.right =
@@ -525,6 +528,8 @@ const barChart = /*@__PURE__*/ proxyCustomElement(class barChart extends H {
525
528
  return toReturn;
526
529
  };
527
530
  this.adjustBarSize = () => {
531
+ if (!this.barSelection)
532
+ return;
528
533
  this.barSelection
529
534
  .selectAll('.bar')
530
535
  .attr('x', this.xFunction)
@@ -957,13 +962,13 @@ const barChart = /*@__PURE__*/ proxyCustomElement(class barChart extends H {
957
962
  this.initBarText();
958
963
  };
959
964
  // Removes resize observer for chart and inits table
960
- this.activateTable = (event) => {
965
+ this.activateTable = () => {
961
966
  this.closeTooltip();
962
967
  this.barChartObserver.disconnect();
963
968
  this.status.innerHTML = '<p>Visas som tabell</p>';
964
969
  select(this.host).select('.tableButton').style('display', 'none');
965
970
  select(this.host).select('.chartButton').style('display', null);
966
- event.target.nextSibling.lastChild.focus();
971
+ this.focusHostButton('.chartButton');
967
972
  const duration = 150;
968
973
  this.svg
969
974
  .attr('opacity', 1)
@@ -994,11 +999,11 @@ const barChart = /*@__PURE__*/ proxyCustomElement(class barChart extends H {
994
999
  .style('opacity', 0);
995
1000
  };
996
1001
  // Removes observer and calls init functions for line chart
997
- this.reInitChart = (event) => {
1002
+ this.reInitChart = () => {
998
1003
  this.status.innerHTML = '<p>Visas som diagram</p>';
999
1004
  select(this.host).select('.tableButton').style('display', null);
1000
1005
  select(this.host).select('.chartButton').style('display', 'none');
1001
- event.target.previousSibling.lastChild.focus();
1006
+ this.focusHostButton('.tableButton');
1002
1007
  const table = select(this.tableDiv);
1003
1008
  const duration = 150;
1004
1009
  table
@@ -1024,14 +1029,33 @@ const barChart = /*@__PURE__*/ proxyCustomElement(class barChart extends H {
1024
1029
  });
1025
1030
  };
1026
1031
  }
1027
- afChartDataUpdate(data) {
1028
- if ((typeof data === 'string' && Object.keys(JSON.parse(data)).length > 0) ||
1029
- (typeof data !== 'string' && Object.keys(data).length > 0)) {
1030
- if (typeof data != 'string')
1031
- this.chartData = data;
1032
- else
1033
- this.chartData = JSON.parse(data);
1034
- this.series = this.chartData.data.series.map((serie) => serie.title);
1032
+ afChartDataUpdate() {
1033
+ const data = this.afChartData;
1034
+ // Angular/React can connect the element before afChartData is set.
1035
+ if (data == null || data === '') {
1036
+ this.mappedData = this.reshapeData();
1037
+ return;
1038
+ }
1039
+ try {
1040
+ let parsed;
1041
+ if (typeof data === 'string') {
1042
+ parsed = JSON.parse(data);
1043
+ }
1044
+ else if (typeof data === 'object') {
1045
+ parsed = data;
1046
+ }
1047
+ else {
1048
+ this.mappedData = this.reshapeData();
1049
+ return;
1050
+ }
1051
+ if (parsed && Object.keys(parsed).length > 0) {
1052
+ this.chartData = parsed;
1053
+ this.series = this.chartData.data.series.map((serie) => serie.title);
1054
+ }
1055
+ }
1056
+ catch (_a) {
1057
+ logger.warn(`Invalid JSON in "af-chart-data" attribute`, this.hostElement);
1058
+ return;
1035
1059
  }
1036
1060
  this.mappedData = this.reshapeData();
1037
1061
  // checking for width of each tick
@@ -1042,6 +1066,17 @@ const barChart = /*@__PURE__*/ proxyCustomElement(class barChart extends H {
1042
1066
  if (this.dataWidth > 1)
1043
1067
  this.barGap = 1;
1044
1068
  }
1069
+ hasChartData() {
1070
+ return !!this.chartData && Object.keys(this.chartData).length > 0;
1071
+ }
1072
+ focusHostButton(selector) {
1073
+ var _a, _b;
1074
+ const host = this.host;
1075
+ 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);
1076
+ if (button && typeof button.focus === 'function') {
1077
+ button.focus();
1078
+ }
1079
+ }
1045
1080
  initSvg() {
1046
1081
  var _a, _b, _c, _d, _e, _f, _g;
1047
1082
  // Fetch number formatting
@@ -1603,10 +1638,25 @@ const barChart = /*@__PURE__*/ proxyCustomElement(class barChart extends H {
1603
1638
  Math.min(255, Math.max(0, parseInt(color, 16) + amount)).toString(16)).substr(-2)));
1604
1639
  }
1605
1640
  componentWillLoad() {
1606
- this.afChartDataUpdate(this.afChartData);
1641
+ this.afChartDataUpdate();
1642
+ // Angular attaches the host first and binds `[afChartData]` on the next
1643
+ // frame (Stencil 4.36+). @Watch skips that first assignment, so if chart
1644
+ // data is not here yet, wait one frame. React/vanilla that already set
1645
+ // the prop skip the delay.
1646
+ if (!this.hasChartData()) {
1647
+ return new Promise((resolve) => {
1648
+ requestAnimationFrame(() => {
1649
+ this.afChartDataUpdate();
1650
+ resolve();
1651
+ });
1652
+ });
1653
+ }
1607
1654
  }
1608
1655
  componentDidLoad() {
1609
- if (!this.chartData || Object.keys(this.chartData).length === 0) {
1656
+ if (!this.hasChartData()) {
1657
+ this.afChartDataUpdate();
1658
+ }
1659
+ if (!this.hasChartData()) {
1610
1660
  this.loading = true;
1611
1661
  return this.initEmpty();
1612
1662
  }
@@ -1625,7 +1675,7 @@ const barChart = /*@__PURE__*/ proxyCustomElement(class barChart extends H {
1625
1675
  }
1626
1676
  componentDidUpdate() {
1627
1677
  if (this.tableDiv.style['display'] != 'block' &&
1628
- Object.keys(this.chartData).length === 0) {
1678
+ !this.hasChartData()) {
1629
1679
  // Disconnect old barchartobserver while doing resizing
1630
1680
  this.barChartObserver.disconnect();
1631
1681
  return this.loadingState();
@@ -1705,7 +1755,7 @@ const barChart = /*@__PURE__*/ proxyCustomElement(class barChart extends H {
1705
1755
  if (this.chartData.infoText)
1706
1756
  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>`;
1707
1757
  }
1708
- 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) }, ' ')));
1758
+ 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) }, ' ')));
1709
1759
  }
1710
1760
  get hostElement() { return this; }
1711
1761
  static get watchers() { return {
@@ -52,7 +52,7 @@ import './p-rhVqmQwC.js';
52
52
  import './p-DPq588Q4.js';
53
53
  import { r as randomIdGenerator } from './p-BGaIliX6.js';
54
54
  import { d as detectClickOutside } from './p-CZrDWyoh.js';
55
- import { i as isBefore, a as isAfter, d as defineCustomElement$e } from './p-CrUxQ9d0.js';
55
+ import { i as isBefore, a as isAfter, d as defineCustomElement$e } from './p-C5A2t93y.js';
56
56
  import { d as defineCustomElement$d } from './p-DdUXwmS6.js';
57
57
  import { d as defineCustomElement$c } from './p-CAW-ueZH.js';
58
58
  import { d as defineCustomElement$b } from './p-CBCmbVA7.js';
@@ -2,6 +2,7 @@ import { p as proxyCustomElement, H, d as createEvent, h, t as transformTag } fr
2
2
  import { _ as _t } from './p-DsO1BTml.js';
3
3
  import { t as toInteger, g as getUTCISOWeek, a as getUTCWeek, k as getUTCISOWeekYear, c as getUTCWeekYear, l as locale$1, j as getTimezoneOffsetInMilliseconds, h as subMilliseconds, d as longFormatters, i as isProtectedWeekYearToken, e as throwProtectedError, f as isProtectedDayOfYearToken, m as buildFormatLongFn, n as buildLocalizeFn, o as buildMatchFn, p as buildMatchPatternFn } from './p-DbBOgLZR.js';
4
4
  import { r as randomIdGenerator } from './p-BGaIliX6.js';
5
+ import { l as logger } from './p-DdB9j8uV.js';
5
6
  import { b as ButtonVariation } from './p-DNHRmpND.js';
6
7
  import { C as CalendarWeekViewHeadingLevel } from './p-DH_-wpLB.js';
7
8
  import { d as defineCustomElement$5 } from './p-BxG1tqmk.js';
@@ -2169,7 +2170,30 @@ const CalendarWeekView = /*@__PURE__*/ proxyCustomElement(class CalendarWeekView
2169
2170
  this.weekDays = [...newDates];
2170
2171
  }
2171
2172
  afDatesUpdate() {
2172
- const dateList = [...JSON.parse(this.afDates)];
2173
+ // Angular/React can connect the element before afDates is set.
2174
+ if (this.afDates == null || this.afDates === '') {
2175
+ return;
2176
+ }
2177
+ const hadDates = this.dates.length > 0;
2178
+ let dateList;
2179
+ try {
2180
+ if (Array.isArray(this.afDates)) {
2181
+ dateList = [...this.afDates];
2182
+ }
2183
+ else if (typeof this.afDates === 'string') {
2184
+ dateList = JSON.parse(this.afDates);
2185
+ }
2186
+ else {
2187
+ return;
2188
+ }
2189
+ }
2190
+ catch (_a) {
2191
+ logger.warn(`Invalid JSON in "af-dates" attribute`, this.hostElement);
2192
+ return;
2193
+ }
2194
+ if (!Array.isArray(dateList)) {
2195
+ return;
2196
+ }
2173
2197
  this.dates = [
2174
2198
  ...dateList.sort((a, b) => {
2175
2199
  const c = new Date(a);
@@ -2177,6 +2201,9 @@ const CalendarWeekView = /*@__PURE__*/ proxyCustomElement(class CalendarWeekView
2177
2201
  return this.getTime(c) - this.getTime(d);
2178
2202
  })
2179
2203
  ];
2204
+ if (!hadDates && this.dates.length > 0) {
2205
+ this.initDates();
2206
+ }
2180
2207
  }
2181
2208
  /**
2182
2209
  * Kan användas för att manuellt sätta om det aktiva datumet. Formatet måste vara 'yyyy-MM-dd'.
@@ -2200,6 +2227,9 @@ const CalendarWeekView = /*@__PURE__*/ proxyCustomElement(class CalendarWeekView
2200
2227
  this.afOnWeekChange.emit('next');
2201
2228
  }
2202
2229
  initDates() {
2230
+ if (this.dates.length === 0) {
2231
+ return;
2232
+ }
2203
2233
  this.minDate = new Date(this.dates[0]);
2204
2234
  this.maxDate = new Date(this.dates[this.dates.length - 1]);
2205
2235
  this.selectedDate = format(new Date(this.dates[0]), 'yyyy-MM-dd', {
@@ -2211,9 +2241,23 @@ const CalendarWeekView = /*@__PURE__*/ proxyCustomElement(class CalendarWeekView
2211
2241
  }
2212
2242
  componentWillLoad() {
2213
2243
  this.afDatesUpdate();
2214
- this.initDates();
2244
+ // Angular attaches the host first and binds `[afDates]` on the next frame
2245
+ // (Stencil 4.36+). @Watch skips that first assignment, so if dates are not
2246
+ // here yet, wait one frame. React/vanilla that already set the prop skip
2247
+ // the delay.
2248
+ if (this.dates.length === 0) {
2249
+ return new Promise((resolve) => {
2250
+ requestAnimationFrame(() => {
2251
+ this.afDatesUpdate();
2252
+ resolve();
2253
+ });
2254
+ });
2255
+ }
2215
2256
  }
2216
2257
  componentDidLoad() {
2258
+ if (this.dates.length === 0) {
2259
+ this.afDatesUpdate();
2260
+ }
2217
2261
  this.afOnReady.emit();
2218
2262
  }
2219
2263
  get prevWeekText() {
@@ -2237,7 +2281,7 @@ const CalendarWeekView = /*@__PURE__*/ proxyCustomElement(class CalendarWeekView
2237
2281
  format(new Date(lastDate), 'MMMM yyyy', { locale: locale });
2238
2282
  }
2239
2283
  render() {
2240
- 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) => {
2284
+ 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) => {
2241
2285
  const date = format(new Date(dateItem), 'd', {
2242
2286
  locale: locale
2243
2287
  });
@@ -2257,16 +2301,17 @@ const CalendarWeekView = /*@__PURE__*/ proxyCustomElement(class CalendarWeekView
2257
2301
  } }, day), h("span", { class: "digi-calendar-week-view__date-button-date" }, date), h("span", { "aria-hidden": "true", class: {
2258
2302
  'digi-calendar-week-view__date-button-circle': dateItem === this.todaysDate
2259
2303
  } })))));
2260
- })))), h("digi-button", { key: '2edb685459c4cbf8a0120ab340672b17d0ea3f9f', onClick: () => this.prevWeek(), class: {
2304
+ })))), h("digi-button", { key: 'dbae5227d0316a5a67febc7de83b1c4c5cfc1044', onClick: () => this.prevWeek(), class: {
2261
2305
  'digi-calendar-week-view__week-button digi-calendar-week-view__week-button--previous': true,
2262
2306
  'digi-calendar-week-view__week-button--keep-left': this.currentWeek == getISOWeek(this.maxDate),
2263
2307
  'digi-calendar-week-view__week-button--hidden': !(this.currentWeek > getISOWeek(this.minDate))
2264
- }, "af-variation": "secondary" }, h("digi-icon-chevron-left", { key: '8948b12a1654f9ef46728ea8de3b1df5f40addcd', slot: "icon" }), this.prevWeekText), h("digi-button", { key: '729ed8eebce68168b66c5365588a52b1279eec3f', onClick: () => this.nextWeek(), class: {
2308
+ }, "af-variation": "secondary" }, h("digi-icon-chevron-left", { key: '65d0f656a0d35911d39f9b8e9ade224be54d4371', slot: "icon" }), this.prevWeekText), h("digi-button", { key: '68d9b3d6c929d0185f412add980a542b3c86fbb2', onClick: () => this.nextWeek(), class: {
2265
2309
  'digi-calendar-week-view__week-button digi-calendar-week-view__week-button--next': true,
2266
2310
  'digi-calendar-week-view__week-button--keep-right': this.currentWeek == getISOWeek(this.minDate),
2267
2311
  'digi-calendar-week-view__week-button--hidden': !(this.currentWeek < getISOWeek(this.maxDate))
2268
- }, "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' })))));
2312
+ }, "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' })))));
2269
2313
  }
2314
+ get hostElement() { return this; }
2270
2315
  static get watchers() { return {
2271
2316
  "selectedDate": [{
2272
2317
  "selectedDateChangeHandler": 0
@@ -1,4 +1,4 @@
1
- import { C as Calendar, d as defineCustomElement$1 } from './p-CrUxQ9d0.js';
1
+ import { C as Calendar, d as defineCustomElement$1 } from './p-C5A2t93y.js';
2
2
 
3
3
  const DigiCalendar = Calendar;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -2,6 +2,7 @@ import { p as proxyCustomElement, H, h, t as transformTag } from './p-0pTevzmo.j
2
2
  import { _ as _t } from './p-DsO1BTml.js';
3
3
  import { s as select, e as dispatch, r as range, a as axisLeft, f as formatLocale, p as polyInOut, b as axisBottom, l as linear, m as max, c as min, o as ordinal, g as interpolate, d as linear$1 } from './p-lPbx4RHH.js';
4
4
  import { r as randomIdGenerator } from './p-BGaIliX6.js';
5
+ import { l as logger } from './p-DdB9j8uV.js';
5
6
  import { d as defineCustomElement$6 } from './p-BxG1tqmk.js';
6
7
  import { d as defineCustomElement$5 } from './p-Br3uVgA1.js';
7
8
  import { d as defineCustomElement$4 } from './p-C2LUp3Td.js';
@@ -1589,14 +1590,14 @@ const ChartLine = /*@__PURE__*/ proxyCustomElement(class ChartLine extends H {
1589
1590
  });
1590
1591
  };
1591
1592
  // Removes resize observer for chart and inits table
1592
- this.activateTable = (event) => {
1593
+ this.activateTable = () => {
1593
1594
  this.closeTooltip();
1594
1595
  this.lineChartObserver.disconnect();
1595
1596
  this.tableObserver.observe(this._chartDiv);
1596
1597
  this._status.innerHTML = '<p>Visas som tabell</p>';
1597
1598
  select(this._host).select('.tableButton').style('display', 'none');
1598
1599
  select(this._host).select('.chartButton').style('display', null);
1599
- event.target.nextSibling.lastChild.focus();
1600
+ this.focusHostButton('.chartButton');
1600
1601
  const duration = 150;
1601
1602
  this._svg
1602
1603
  .attr('opacity', 1)
@@ -1627,12 +1628,12 @@ const ChartLine = /*@__PURE__*/ proxyCustomElement(class ChartLine extends H {
1627
1628
  this.setTableDimensions();
1628
1629
  };
1629
1630
  // Removes observer and calls init functions for line chart
1630
- this.reInitChart = (event) => {
1631
+ this.reInitChart = () => {
1631
1632
  this.tableObserver.disconnect();
1632
1633
  this._status.innerHTML = '<p>Visas som diagram</p>';
1633
1634
  select(this._host).select('.tableButton').style('display', null);
1634
1635
  select(this._host).select('.chartButton').style('display', 'none');
1635
- event.target.previousSibling.lastChild.focus();
1636
+ this.focusHostButton('.tableButton');
1636
1637
  const table = select(this._tableDiv);
1637
1638
  table
1638
1639
  .style('opacity', 1)
@@ -1659,15 +1660,40 @@ const ChartLine = /*@__PURE__*/ proxyCustomElement(class ChartLine extends H {
1659
1660
  }
1660
1661
  afChartDataUpdate() {
1661
1662
  const data = this.afChartData;
1662
- if (typeof data === 'object') {
1663
- this._chartData = Object.assign({}, data);
1663
+ // Angular/React can connect the element before afChartData is set.
1664
+ if (data == null || data === '') {
1665
+ return;
1666
+ }
1667
+ try {
1668
+ if (typeof data === 'object') {
1669
+ this._chartData = Object.assign({}, data);
1670
+ }
1671
+ else if (typeof data === 'string') {
1672
+ this._chartData = JSON.parse(data);
1673
+ }
1674
+ else {
1675
+ return;
1676
+ }
1677
+ }
1678
+ catch (_a) {
1679
+ logger.warn(`Invalid JSON in "af-chart-data" attribute`, this.element);
1664
1680
  return;
1665
1681
  }
1666
- this._chartData = JSON.parse(data);
1667
1682
  // Making deep copy of this
1668
1683
  if (this._chartData.data)
1669
1684
  this._coreSeries = JSON.parse(JSON.stringify(this._chartData.data.series));
1670
1685
  }
1686
+ hasChartData() {
1687
+ return !!this._chartData && Object.keys(this._chartData).length > 0;
1688
+ }
1689
+ focusHostButton(selector) {
1690
+ var _a, _b;
1691
+ const host = this._host;
1692
+ 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);
1693
+ if (button && typeof button.focus === 'function') {
1694
+ button.focus();
1695
+ }
1696
+ }
1671
1697
  initSvg() {
1672
1698
  this.margin.bottom =
1673
1699
  Number(window
@@ -2131,9 +2157,24 @@ const ChartLine = /*@__PURE__*/ proxyCustomElement(class ChartLine extends H {
2131
2157
  }
2132
2158
  componentWillLoad() {
2133
2159
  this.afChartDataUpdate();
2160
+ // Angular attaches the host first and binds `[afChartData]` on the next
2161
+ // frame (Stencil 4.36+). @Watch skips that first assignment, so if chart
2162
+ // data is not here yet, wait one frame. React/vanilla that already set
2163
+ // the prop skip the delay.
2164
+ if (!this.hasChartData()) {
2165
+ return new Promise((resolve) => {
2166
+ requestAnimationFrame(() => {
2167
+ this.afChartDataUpdate();
2168
+ resolve();
2169
+ });
2170
+ });
2171
+ }
2134
2172
  }
2135
2173
  componentDidLoad() {
2136
- if (Object.keys(this._chartData).length === 0)
2174
+ if (!this.hasChartData()) {
2175
+ this.afChartDataUpdate();
2176
+ }
2177
+ if (!this.hasChartData())
2137
2178
  return this.initEmpty();
2138
2179
  // clearing selection
2139
2180
  this._selectedLines = [];
@@ -2149,7 +2190,7 @@ const ChartLine = /*@__PURE__*/ proxyCustomElement(class ChartLine extends H {
2149
2190
  this._prevHeight = select(this._titleDiv).style('height');
2150
2191
  }
2151
2192
  componentDidUpdate() {
2152
- if (Object.keys(this._chartData).length === 0)
2193
+ if (!this.hasChartData())
2153
2194
  return this.loadingState();
2154
2195
  // clearing selection
2155
2196
  this._selectedLines = [];
@@ -2306,11 +2347,13 @@ const ChartLine = /*@__PURE__*/ proxyCustomElement(class ChartLine extends H {
2306
2347
  }
2307
2348
  render() {
2308
2349
  let heading = '';
2309
- if (!this._chartData.subTitle)
2310
- heading = `<${this.afHeadingLevel}>${this._chartData.title}</${this.afHeadingLevel}>`;
2311
- else
2312
- heading = `<${this.afHeadingLevel}>${this._chartData.title}</${this.afHeadingLevel}><p>${this._chartData.subTitle}</p>`;
2313
- 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) }, ' ')));
2350
+ if (this._chartData) {
2351
+ if (!this._chartData.subTitle)
2352
+ heading = `<${this.afHeadingLevel}>${this._chartData.title}</${this.afHeadingLevel}>`;
2353
+ else
2354
+ heading = `<${this.afHeadingLevel}>${this._chartData.title}</${this.afHeadingLevel}><p>${this._chartData.subTitle}</p>`;
2355
+ }
2356
+ 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) }, ' ')));
2314
2357
  }
2315
2358
  get element() { return this; }
2316
2359
  static get watchers() { return {
@@ -79,16 +79,28 @@ const NavigationVerticalMenu = /*@__PURE__*/ proxyCustomElement(class Navigation
79
79
  }
80
80
  }
81
81
  componentWillLoad() {
82
- this.getListItems();
83
- this.initNav();
84
- this.setLevelClass();
82
+ this.syncNav();
83
+ // Angular attaches the host first and slots children on the next frame
84
+ // (Stencil 4.36+). React/vanilla that already have slotted nodes skip
85
+ // the delay. Do not warn here — Angular/React may still be projecting.
86
+ if (!this.hostElement.children.length) {
87
+ return new Promise((resolve) => {
88
+ requestAnimationFrame(() => {
89
+ this.syncNav();
90
+ resolve();
91
+ });
92
+ });
93
+ }
85
94
  }
86
95
  componentDidLoad() {
87
96
  this.initCurrentActiveLevel();
88
97
  this.afOnReady.emit();
89
98
  }
90
99
  componentWillUpdate() {
91
- this.getListItems();
100
+ this.syncNav();
101
+ }
102
+ syncNav(options) {
103
+ this.getListItems(options);
92
104
  this.initNav();
93
105
  this.setLevelClass();
94
106
  }
@@ -138,12 +150,12 @@ const NavigationVerticalMenu = /*@__PURE__*/ proxyCustomElement(class Navigation
138
150
  }
139
151
  }
140
152
  setLevelClass() {
141
- this.hostElement
142
- .querySelector('ul')
143
- .classList.remove('primary', 'secondary');
144
- this.hostElement
145
- .querySelector('ul')
146
- .classList.add('digi-navigation-vertical-menu__list--root', this.afVariation);
153
+ const rootList = this.hostElement.querySelector('ul');
154
+ if (!rootList) {
155
+ return;
156
+ }
157
+ rootList.classList.remove('primary', 'secondary');
158
+ rootList.classList.add('digi-navigation-vertical-menu__list--root', this.afVariation);
147
159
  }
148
160
  initNav() {
149
161
  const $ul = this.hostElement.querySelectorAll('ul');
@@ -156,10 +168,12 @@ const NavigationVerticalMenu = /*@__PURE__*/ proxyCustomElement(class Navigation
156
168
  this.initNav();
157
169
  this.setClasses(e);
158
170
  }
159
- getListItems() {
171
+ getListItems(options) {
160
172
  const menuItems = this.hostElement.children;
161
173
  if (!menuItems || menuItems.length <= 0) {
162
- logger.warn(`The slot contains no children elements.`, this.hostElement);
174
+ if (options === null || options === void 0 ? void 0 : options.warnIfEmpty) {
175
+ logger.warn(`The slot contains no children elements.`, this.hostElement);
176
+ }
163
177
  return;
164
178
  }
165
179
  this.listItems = [...Array.from(menuItems)].map((filter) => {
@@ -178,7 +192,7 @@ const NavigationVerticalMenu = /*@__PURE__*/ proxyCustomElement(class Navigation
178
192
  };
179
193
  }
180
194
  render() {
181
- return (h("nav", { key: '0c7b96501a70d813b8d8f5b8014dc420d472f4a9', class: Object.assign({ 'digi-navigation-vertical-menu': true }, this.cssModifiers), id: this.afId, "aria-label": this.afAriaLabel }, h("slot", { key: '2b5d92cada1cde5bb5155257be77a584c2e708ec' })));
195
+ return (h("nav", { key: 'df2239de80363247c33eadf6995331a74a40966f', class: Object.assign({ 'digi-navigation-vertical-menu': true }, this.cssModifiers), id: this.afId, "aria-label": this.afAriaLabel }, h("slot", { key: 'dc2e22c2cfd00786964855ea3bc2b7271879510c', onSlotchange: () => this.syncNav() })));
182
196
  }
183
197
  get hostElement() { return this; }
184
198
  static get style() { return navigationVerticalMenuCss(); }