diff --git a/src/Chartjs/Resources/assets/dist/controller.js b/src/Chartjs/Resources/assets/dist/controller.js index 6e5ef6fd7c4..b41fd601a91 100644 --- a/src/Chartjs/Resources/assets/dist/controller.js +++ b/src/Chartjs/Resources/assets/dist/controller.js @@ -1,6 +1,7 @@ import { Controller } from '@hotwired/stimulus'; -import Chart from 'chart.js/auto'; +import { Chart, registerables } from 'chart.js'; +Chart.register(...registerables); class default_1 extends Controller { connect() { if (!(this.element instanceof HTMLCanvasElement)) { diff --git a/src/Chartjs/Resources/assets/src/controller.ts b/src/Chartjs/Resources/assets/src/controller.ts index 44d4a9e1c1c..8fed04b1f50 100644 --- a/src/Chartjs/Resources/assets/src/controller.ts +++ b/src/Chartjs/Resources/assets/src/controller.ts @@ -10,7 +10,8 @@ 'use strict'; import { Controller } from '@hotwired/stimulus'; -import Chart from 'chart.js/auto'; +import { Chart, registerables } from 'chart.js'; +Chart.register(...registerables); export default class extends Controller { readonly viewValue: any; diff --git a/src/LiveComponent/assets/dist/live_controller.js b/src/LiveComponent/assets/dist/live_controller.js index d75ccabbe7a..8585ee15105 100644 --- a/src/LiveComponent/assets/dist/live_controller.js +++ b/src/LiveComponent/assets/dist/live_controller.js @@ -1084,8 +1084,8 @@ function getModelDirectiveFromInput(element, throwOnMissing = true) { } if (element.getAttribute('name')) { const formElement = element.closest('form'); - if (formElement && formElement.dataset.model) { - const directives = parseDirectives(formElement.dataset.model); + if (formElement && ('model' in formElement.dataset)) { + const directives = parseDirectives(formElement.dataset.model || '*'); const directive = directives[0]; if (directive.args.length > 0 || directive.named.length > 0) { throw new Error(`The data-model="${formElement.dataset.model}" format is invalid: it does not support passing arguments to the model.`); @@ -1222,9 +1222,7 @@ class default_1 extends Controller { if (!(this.element instanceof HTMLElement)) { throw new Error('Invalid Element Type'); } - if (this.element.dataset.poll !== undefined) { - this._initiatePolling(this.element.dataset.poll); - } + this._initiatePolling(); window.addEventListener('beforeunload', this.markAsWindowUnloaded); this._startAttributesMutationObserver(); this.element.addEventListener('live:update-model', this.handleUpdateModelEvent); @@ -1234,9 +1232,7 @@ class default_1 extends Controller { this._dispatchEvent('live:connect', { controller: this }); } disconnect() { - this.pollingIntervals.forEach((interval) => { - clearInterval(interval); - }); + this._stopAllPolling(); window.removeEventListener('beforeunload', this.markAsWindowUnloaded); this.element.removeEventListener('live:update-model', this.handleUpdateModelEvent); this.element.removeEventListener('input', this.handleInputEvent); @@ -1665,7 +1661,12 @@ class default_1 extends Controller { } this._updateModelFromElement(target, 'change'); } - _initiatePolling(rawPollConfig) { + _initiatePolling() { + this._stopAllPolling(); + if (this.element.dataset.poll === undefined) { + return; + } + const rawPollConfig = this.element.dataset.poll; const directives = parseDirectives(rawPollConfig || '$render'); directives.forEach((directive) => { let duration = 2000; @@ -1790,9 +1791,12 @@ class default_1 extends Controller { const element = this.element; this.mutationObserver = new MutationObserver((mutations) => { mutations.forEach((mutation) => { - if (mutation.type === 'attributes' && !element.dataset.originalData) { - this.originalDataJSON = this.valueStore.asJson(); - this._exposeOriginalData(); + if (mutation.type === 'attributes') { + if (!element.dataset.originalData) { + this.originalDataJSON = this.valueStore.asJson(); + this._exposeOriginalData(); + } + this._initiatePolling(); } }); }); @@ -1803,6 +1807,11 @@ class default_1 extends Controller { getDefaultDebounce() { return this.hasDebounceValue ? this.debounceValue : DEFAULT_DEBOUNCE; } + _stopAllPolling() { + this.pollingIntervals.forEach((interval) => { + clearInterval(interval); + }); + } } default_1.values = { url: String,