@symfony/ux-chartjs 2.32.0 → 2.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,9 +6,10 @@ JavaScript assets of the [symfony/ux-chartjs](https://packagist.org/packages/sym
6
6
 
7
7
  This npm package is **reserved for advanced users** who want to decouple their JavaScript dependencies from their PHP dependencies (e.g., when building Docker images, running JavaScript-only pipelines, etc.).
8
8
 
9
- We **strongly recommend not installing this package directly**, but instead install the PHP package [symfony/ux-chartjs](https://packagist.org/packages/symfony/ux-chartjs) in your Symfony application with [Flex](https://github.com/symfony/flex) enabled.
9
+ We **strongly recommend not installing this package directly**, but instead install the PHP package [symfony/ux-chartjs](https://packagist.org/packages/symfony/ux-chartjs) in your Symfony application with [Flex](https://github.com/symfony/flex) enabled.
10
10
 
11
11
  If you still want to install this package directly, please make sure its version exactly matches [symfony/ux-chartjs](https://packagist.org/packages/symfony/ux-chartjs) PHP package version:
12
+
12
13
  ```shell
13
14
  composer require symfony/ux-chartjs:2.23.0
14
15
  npm add @symfony/ux-chartjs@2.23.0
@@ -18,7 +19,7 @@ npm add @symfony/ux-chartjs@2.23.0
18
19
 
19
20
  ## Resources
20
21
 
21
- - [Documentation](https://symfony.com/bundles/ux-chartjs/current/index.html)
22
- - [Report issues](https://github.com/symfony/ux/issues) and
23
- [send Pull Requests](https://github.com/symfony/ux/pulls)
24
- in the [main Symfony UX repository](https://github.com/symfony/ux)
22
+ - [Documentation](https://symfony.com/bundles/ux-chartjs/current/index.html)
23
+ - [Report issues](https://github.com/symfony/ux/issues) and
24
+ [send Pull Requests](https://github.com/symfony/ux/pulls)
25
+ in the [main Symfony UX repository](https://github.com/symfony/ux)
@@ -1,15 +1,13 @@
1
- import { Controller } from '@hotwired/stimulus';
2
-
1
+ import { Controller } from "@hotwired/stimulus";
3
2
  declare class export_default extends Controller {
4
- readonly viewValue: any;
5
- static values: {
6
- view: ObjectConstructor;
7
- };
8
- private chart;
9
- connect(): void;
10
- disconnect(): void;
11
- viewValueChanged(): void;
12
- private dispatchEvent;
3
+ readonly viewValue: any;
4
+ static values: {
5
+ view: ObjectConstructor;
6
+ };
7
+ private chart;
8
+ connect(): void;
9
+ disconnect(): void;
10
+ viewValueChanged(): void;
11
+ private dispatchEvent;
13
12
  }
14
-
15
- export { export_default as default };
13
+ export { export_default as default };
@@ -1,77 +1,63 @@
1
- // src/controller.ts
2
1
  import { Controller } from "@hotwired/stimulus";
3
2
  import { Chart, registerables } from "chart.js";
4
- if (registerables) {
5
- Chart.register(...registerables);
6
- }
7
- var isChartInitialized = false;
8
- var controller_default = class extends Controller {
9
- constructor() {
10
- super(...arguments);
11
- this.chart = null;
12
- }
13
- connect() {
14
- if (!isChartInitialized) {
15
- isChartInitialized = true;
16
- this.dispatchEvent("init", {
17
- Chart
18
- });
19
- }
20
- if (!(this.element instanceof HTMLCanvasElement)) {
21
- throw new Error("Invalid element");
22
- }
23
- const payload = this.viewValue;
24
- if (Array.isArray(payload.options) && 0 === payload.options.length) {
25
- payload.options = {};
26
- }
27
- this.dispatchEvent("pre-connect", {
28
- options: payload.options,
29
- config: payload
30
- });
31
- const canvasContext = this.element.getContext("2d");
32
- if (!canvasContext) {
33
- throw new Error("Could not getContext() from Element");
34
- }
35
- this.chart = new Chart(canvasContext, payload);
36
- this.dispatchEvent("connect", { chart: this.chart });
37
- }
38
- disconnect() {
39
- this.dispatchEvent("disconnect", { chart: this.chart });
40
- if (this.chart) {
41
- this.chart.destroy();
42
- this.chart = null;
43
- }
44
- }
45
- /**
46
- * If the underlying data or options change, let's update the chart!
47
- */
48
- viewValueChanged() {
49
- if (this.chart) {
50
- const viewValue = { data: this.viewValue.data, options: this.viewValue.options };
51
- if (Array.isArray(viewValue.options) && 0 === viewValue.options.length) {
52
- viewValue.options = {};
53
- }
54
- this.dispatchEvent("view-value-change", viewValue);
55
- this.chart.data = viewValue.data;
56
- this.chart.options = viewValue.options;
57
- this.chart.update();
58
- const parentElement = this.element.parentElement;
59
- if (parentElement && this.chart.options.responsive) {
60
- const originalWidth = parentElement.style.width;
61
- parentElement.style.width = `${parentElement.offsetWidth + 1}px`;
62
- setTimeout(() => {
63
- parentElement.style.width = originalWidth;
64
- }, 0);
65
- }
66
- }
67
- }
68
- dispatchEvent(name, payload) {
69
- this.dispatch(name, { detail: payload, prefix: "chartjs" });
70
- }
71
- };
72
- controller_default.values = {
73
- view: Object
74
- };
75
- export {
76
- controller_default as default
3
+ if (registerables) Chart.register(...registerables);
4
+ let isChartInitialized = false;
5
+ var _Class = class extends Controller {
6
+ constructor(..._args) {
7
+ super(..._args);
8
+ this.chart = null;
9
+ }
10
+ connect() {
11
+ if (!isChartInitialized) {
12
+ isChartInitialized = true;
13
+ this.dispatchEvent("init", { Chart });
14
+ }
15
+ if (!(this.element instanceof HTMLCanvasElement)) throw new Error("Invalid element");
16
+ const payload = this.viewValue;
17
+ if (Array.isArray(payload.options) && 0 === payload.options.length) payload.options = {};
18
+ this.dispatchEvent("pre-connect", {
19
+ options: payload.options,
20
+ config: payload
21
+ });
22
+ const canvasContext = this.element.getContext("2d");
23
+ if (!canvasContext) throw new Error("Could not getContext() from Element");
24
+ this.chart = new Chart(canvasContext, payload);
25
+ this.dispatchEvent("connect", { chart: this.chart });
26
+ }
27
+ disconnect() {
28
+ this.dispatchEvent("disconnect", { chart: this.chart });
29
+ if (this.chart) {
30
+ this.chart.destroy();
31
+ this.chart = null;
32
+ }
33
+ }
34
+ viewValueChanged() {
35
+ if (this.chart) {
36
+ const viewValue = {
37
+ data: this.viewValue.data,
38
+ options: this.viewValue.options
39
+ };
40
+ if (Array.isArray(viewValue.options) && 0 === viewValue.options.length) viewValue.options = {};
41
+ this.dispatchEvent("view-value-change", viewValue);
42
+ this.chart.data = viewValue.data;
43
+ this.chart.options = viewValue.options;
44
+ this.chart.update();
45
+ const parentElement = this.element.parentElement;
46
+ if (parentElement && this.chart.options.responsive) {
47
+ const originalWidth = parentElement.style.width;
48
+ parentElement.style.width = `${parentElement.offsetWidth + 1}px`;
49
+ setTimeout(() => {
50
+ parentElement.style.width = originalWidth;
51
+ }, 0);
52
+ }
53
+ }
54
+ }
55
+ dispatchEvent(name, payload) {
56
+ this.dispatch(name, {
57
+ detail: payload,
58
+ prefix: "chartjs"
59
+ });
60
+ }
77
61
  };
62
+ _Class.values = { view: Object };
63
+ export { _Class as default };
package/package.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "name": "@symfony/ux-chartjs",
3
3
  "description": "Chart.js integration for Symfony",
4
4
  "license": "MIT",
5
- "version": "2.32.0",
5
+ "version": "2.34.0",
6
6
  "keywords": [
7
7
  "symfony-ux"
8
8
  ],
9
9
  "homepage": "https://ux.symfony.com/chartjs",
10
- "repository": "https://github.com/symfony/ux-chartjs",
10
+ "repository": "https://github.com/symfony/ux",
11
11
  "type": "module",
12
12
  "files": [
13
13
  "dist"
@@ -41,19 +41,16 @@
41
41
  "jsdom": "^26.1.0",
42
42
  "resize-observer-polyfill": "^1.5.1",
43
43
  "tslib": "^2.8.1",
44
- "tsx": "^4.20.3",
45
44
  "typescript": "^5.8.3",
46
- "vitest": "^3.2.4",
45
+ "vitest": "^4.1.0",
47
46
  "vitest-canvas-mock": "^0.3.3"
48
47
  },
49
48
  "scripts": {
50
- "build": "tsx ../../../bin/build_package.ts .",
51
- "watch": "tsx ../../../bin/build_package.ts . --watch",
49
+ "build": "node ../../../bin/build_package.ts .",
50
+ "watch": "node ../../../bin/build_package.ts . --watch",
52
51
  "test": "pnpm run test:unit && pnpm run test:browser",
53
52
  "test:unit": "../../../bin/unit_test_package.sh .",
54
53
  "test:browser": "playwright test",
55
- "test:browser:ui": "playwright test --ui",
56
- "check": "biome check",
57
- "ci": "biome ci"
54
+ "test:browser:ui": "playwright test --ui"
58
55
  }
59
56
  }