@vaadin/charts 24.9.6 → 24.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/charts",
3
- "version": "24.9.6",
3
+ "version": "24.9.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,16 +37,16 @@
37
37
  "dependencies": {
38
38
  "@open-wc/dedupe-mixin": "^1.3.0",
39
39
  "@polymer/polymer": "^3.0.0",
40
- "@vaadin/component-base": "~24.9.6",
41
- "@vaadin/vaadin-lumo-styles": "~24.9.6",
42
- "@vaadin/vaadin-material-styles": "~24.9.6",
43
- "@vaadin/vaadin-themable-mixin": "~24.9.6",
40
+ "@vaadin/component-base": "~24.9.8",
41
+ "@vaadin/vaadin-lumo-styles": "~24.9.8",
42
+ "@vaadin/vaadin-material-styles": "~24.9.8",
43
+ "@vaadin/vaadin-themable-mixin": "~24.9.8",
44
44
  "highcharts": "9.2.2",
45
45
  "lit": "^3.0.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@vaadin/chai-plugins": "~24.9.6",
49
- "@vaadin/test-runner-commands": "~24.9.6",
48
+ "@vaadin/chai-plugins": "~24.9.8",
49
+ "@vaadin/test-runner-commands": "~24.9.8",
50
50
  "@vaadin/testing-helpers": "^1.1.0",
51
51
  "sinon": "^18.0.0"
52
52
  },
@@ -55,5 +55,5 @@
55
55
  "web-types.json",
56
56
  "web-types.lit.json"
57
57
  ],
58
- "gitHead": "04dec563d48efd4e5ca0c0b96687302666ee5ab1"
58
+ "gitHead": "deee84906a0b74bac20b2f3ca0aa7fe02e700e23"
59
59
  }
package/src/helpers.js CHANGED
@@ -46,3 +46,54 @@ export function deepMerge(target, source) {
46
46
 
47
47
  return target;
48
48
  }
49
+
50
+ export function prepareExport(chart) {
51
+ // Guard against another print 'before print' event coming before
52
+ // the 'after print' event.
53
+ if (!chart.tempBodyStyle) {
54
+ let effectiveCss = '';
55
+
56
+ // PolymerElement uses `<style>` tags for adding styles
57
+ [...chart.shadowRoot.querySelectorAll('style')].forEach((style) => {
58
+ effectiveCss += style.textContent;
59
+ });
60
+
61
+ // LitElement uses `adoptedStyleSheets` for adding styles
62
+ if (chart.shadowRoot.adoptedStyleSheets) {
63
+ chart.shadowRoot.adoptedStyleSheets.forEach((sheet) => {
64
+ effectiveCss += [...sheet.cssRules].map((rule) => rule.cssText).join('\n');
65
+ });
66
+ }
67
+
68
+ // Strip off host selectors that target individual instances
69
+ effectiveCss = effectiveCss.replace(/:host\(.+?\)/gu, (match) => {
70
+ const selector = match.substr(6, match.length - 7);
71
+ return chart.matches(selector) ? '' : match;
72
+ });
73
+
74
+ // Zoom out a bit to avoid clipping the chart's edge on paper
75
+ effectiveCss =
76
+ `${effectiveCss}body {` +
77
+ ` -moz-transform: scale(0.9, 0.9);` + // Mozilla
78
+ ` zoom: 0.9;` + // Others
79
+ ` zoom: 90%;` + // Webkit
80
+ `}`;
81
+
82
+ chart.tempBodyStyle = document.createElement('style');
83
+ chart.tempBodyStyle.textContent = effectiveCss;
84
+ document.body.appendChild(chart.tempBodyStyle);
85
+ if (chart.__styledMode) {
86
+ document.body.toggleAttribute('styled-mode', true);
87
+ }
88
+ }
89
+ }
90
+
91
+ export function cleanupExport(chart) {
92
+ if (chart.tempBodyStyle) {
93
+ document.body.removeChild(chart.tempBodyStyle);
94
+ delete chart.tempBodyStyle;
95
+ if (chart.__styledMode) {
96
+ document.body.removeAttribute('styled-mode');
97
+ }
98
+ }
99
+ }
@@ -33,7 +33,7 @@ import Highcharts from 'highcharts/es-modules/masters/highstock.src.js';
33
33
  import { get } from '@vaadin/component-base/src/path-utils.js';
34
34
  import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
35
35
  import { SlotObserver } from '@vaadin/component-base/src/slot-observer.js';
36
- import { deepMerge, inflateFunctions } from './helpers.js';
36
+ import { cleanupExport, deepMerge, inflateFunctions, prepareExport } from './helpers.js';
37
37
 
38
38
  ['exportChart', 'exportChartLocal', 'getSVG'].forEach((methodName) => {
39
39
  /* eslint-disable @typescript-eslint/no-invalid-this, prefer-arrow-callback */
@@ -272,6 +272,11 @@ export const ChartMixin = (superClass) =>
272
272
  reflectToAttribute: true,
273
273
  sync: true,
274
274
  },
275
+
276
+ /** @private */
277
+ __styledMode: {
278
+ type: Boolean,
279
+ },
275
280
  };
276
281
  }
277
282
 
@@ -902,7 +907,7 @@ export const ChartMixin = (superClass) =>
902
907
  /** @private */
903
908
  __initChart(options) {
904
909
  this.__initEventsListeners(options);
905
- this.__updateStyledMode(options);
910
+ this.__styledMode = options.chart.styledMode;
906
911
  if (options.chart.type === 'gantt') {
907
912
  this.configuration = Highcharts.ganttChart(this.$.chart, options);
908
913
  } else if (this.timeline) {
@@ -912,12 +917,6 @@ export const ChartMixin = (superClass) =>
912
917
  }
913
918
  }
914
919
 
915
- /** @private */
916
- __updateStyledMode(options) {
917
- const styledMode = options.chart.styledMode;
918
- this.$.chart.toggleAttribute('styled-mode', !!styledMode);
919
- }
920
-
921
920
  /** @protected */
922
921
  disconnectedCallback() {
923
922
  super.disconnectedCallback();
@@ -1205,55 +1204,12 @@ export const ChartMixin = (superClass) =>
1205
1204
  // Workaround for https://github.com/vaadin/vaadin-charts/issues/389
1206
1205
  // Hook into beforePrint and beforeExport to ensure correct styling
1207
1206
  if (['beforePrint', 'beforeExport'].indexOf(event.type) >= 0) {
1208
- // Guard against another print 'before print' event coming before
1209
- // the 'after print' event.
1210
- if (!self.tempBodyStyle) {
1211
- let effectiveCss = '';
1212
-
1213
- // PolymerElement uses `<style>` tags for adding styles
1214
- [...self.shadowRoot.querySelectorAll('style')].forEach((style) => {
1215
- effectiveCss += style.textContent;
1216
- });
1217
-
1218
- // LitElement uses `adoptedStyleSheets` for adding styles
1219
- if (self.shadowRoot.adoptedStyleSheets) {
1220
- self.shadowRoot.adoptedStyleSheets.forEach((sheet) => {
1221
- effectiveCss += [...sheet.cssRules].map((rule) => rule.cssText).join('\n');
1222
- });
1223
- }
1224
-
1225
- // Strip off host selectors that target individual instances
1226
- effectiveCss = effectiveCss.replace(/:host\(.+?\)/gu, (match) => {
1227
- const selector = match.substr(6, match.length - 7);
1228
- return self.matches(selector) ? '' : match;
1229
- });
1230
-
1231
- // Zoom out a bit to avoid clipping the chart's edge on paper
1232
- effectiveCss =
1233
- `${effectiveCss}body {` +
1234
- ` -moz-transform: scale(0.9, 0.9);` + // Mozilla
1235
- ` zoom: 0.9;` + // Others
1236
- ` zoom: 90%;` + // Webkit
1237
- `}`;
1238
-
1239
- self.tempBodyStyle = document.createElement('style');
1240
- self.tempBodyStyle.textContent = effectiveCss;
1241
- document.body.appendChild(self.tempBodyStyle);
1242
- if (self.options.chart.styledMode) {
1243
- document.body.setAttribute('styled-mode', '');
1244
- }
1245
- }
1207
+ prepareExport(self);
1246
1208
  }
1247
1209
 
1248
1210
  // Hook into afterPrint and afterExport to revert changes made before
1249
1211
  if (['afterPrint', 'afterExport'].indexOf(event.type) >= 0) {
1250
- if (self.tempBodyStyle) {
1251
- document.body.removeChild(self.tempBodyStyle);
1252
- delete self.tempBodyStyle;
1253
- if (self.options.chart.styledMode) {
1254
- document.body.removeAttribute('styled-mode');
1255
- }
1256
- }
1212
+ cleanupExport(self);
1257
1213
  }
1258
1214
 
1259
1215
  self.dispatchEvent(new CustomEvent(eventList[key], customEvent));
@@ -193,7 +193,7 @@ class Chart extends ChartMixin(ThemableMixin(ElementMixin(PolymerElement))) {
193
193
  display: none !important;
194
194
  }
195
195
  </style>
196
- <div id="chart"></div>
196
+ <div id="chart" styled-mode$="[[__styledMode]]"></div>
197
197
  <slot id="slot"></slot>
198
198
  `;
199
199
  }
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/charts",
4
- "version": "24.9.6",
4
+ "version": "24.9.8",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/charts",
4
- "version": "24.9.6",
4
+ "version": "24.9.8",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {