@quicdata/analytics 0.0.4 → 0.0.5
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/analytics.css +69 -0
- package/filters/widget-toolbar.d.ts.map +1 -1
- package/filters/widget-toolbar.js +8 -5
- package/package.json +21 -2
- package/widgets/base-chart.d.ts +4 -6
- package/widgets/base-chart.d.ts.map +1 -1
- package/widgets/base-chart.js +14 -25
- package/widgets/table.d.ts +3 -8
- package/widgets/table.d.ts.map +1 -1
- package/widgets/table.js +27 -46
- package/index.d.ts.map +0 -1
- package/workers/widget-transform.worker.d.ts +0 -21
- package/workers/widget-transform.worker.d.ts.map +0 -1
- package/workers/widget-transform.worker.js +0 -30
package/analytics.css
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @quicdata/analytics – default CSS variables
|
|
3
|
+
*
|
|
4
|
+
* Import this file once in your app (e.g. in your root layout or main entry):
|
|
5
|
+
* import '@quicdata/analytics/analytics.css';
|
|
6
|
+
*
|
|
7
|
+
* Override any variable in your own CSS by redefining it on :root or a
|
|
8
|
+
* container that wraps the analytics components.
|
|
9
|
+
*/
|
|
10
|
+
:root {
|
|
11
|
+
/* ----- Filter bar (dashboard & widget toolbar) ----- */
|
|
12
|
+
--analytics-filter-bar-bg: transparent;
|
|
13
|
+
--analytics-filter-bar-border: #e2e8f0;
|
|
14
|
+
--analytics-filter-bar-label-color: #475569;
|
|
15
|
+
--analytics-filter-bar-input-bg: #fff;
|
|
16
|
+
--analytics-filter-bar-input-border: #cbd5e1;
|
|
17
|
+
--analytics-filter-bar-input-color: inherit;
|
|
18
|
+
--analytics-filter-bar-close-color: #64748b;
|
|
19
|
+
--analytics-filter-bar-close-hover-bg: #f1f5f9;
|
|
20
|
+
--analytics-filter-bar-close-hover-color: #334155;
|
|
21
|
+
|
|
22
|
+
/* ----- Report (analytics-report) ----- */
|
|
23
|
+
--analytics-report-border: #e2e8f0;
|
|
24
|
+
--analytics-report-header-bg: #f8fafc;
|
|
25
|
+
--analytics-report-title-color: #1e293b;
|
|
26
|
+
--analytics-report-btn-border: #cbd5e1;
|
|
27
|
+
--analytics-report-btn-bg: #fff;
|
|
28
|
+
--analytics-report-btn-color: #334155;
|
|
29
|
+
--analytics-report-btn-hover-bg: #f1f5f9;
|
|
30
|
+
--analytics-report-btn-hover-color: #0f172a;
|
|
31
|
+
|
|
32
|
+
/* ----- Table widget ----- */
|
|
33
|
+
--table-font-size: 0.875rem;
|
|
34
|
+
--analytics-table-font-size: 0.875rem;
|
|
35
|
+
--analytics-table-border-color: #e5e7eb;
|
|
36
|
+
--analytics-table-header-bg: #f9fafb;
|
|
37
|
+
--analytics-table-header-color: #374151;
|
|
38
|
+
--analytics-table-row-hover-bg: #f9fafb;
|
|
39
|
+
--analytics-table-totals-bg: #f3f4f6;
|
|
40
|
+
--analytics-table-totals-border: #e5e7eb;
|
|
41
|
+
--analytics-table-error-color: #c00;
|
|
42
|
+
--analytics-table-empty-color: #6b7280;
|
|
43
|
+
--analytics-table-placeholder-color: #9ca3af;
|
|
44
|
+
--analytics-table-loading-overlay-bg: rgba(255, 255, 255, 0.65);
|
|
45
|
+
--analytics-table-spinner-border: #e5e7eb;
|
|
46
|
+
--analytics-table-spinner-accent: #3b82f6;
|
|
47
|
+
|
|
48
|
+
/* ----- Charts (base-chart, bar, line, pie) ----- */
|
|
49
|
+
--analytics-chart-title-color: #374151;
|
|
50
|
+
--analytics-chart-error-color: #c00;
|
|
51
|
+
--analytics-chart-loading-overlay-bg: rgba(255, 255, 255, 0.65);
|
|
52
|
+
--analytics-chart-spinner-border: #e5e7eb;
|
|
53
|
+
--analytics-chart-spinner-accent: #3b82f6;
|
|
54
|
+
|
|
55
|
+
/* ----- Widget toolbar (floating filter button + overlay) ----- */
|
|
56
|
+
--analytics-widget-toolbar-z-index: 20;
|
|
57
|
+
--analytics-widget-toolbar-bg: rgba(0, 0, 0, 0.55);
|
|
58
|
+
--analytics-widget-toolbar-border: rgba(255, 255, 255, 0.1);
|
|
59
|
+
--analytics-widget-toolbar-color: rgba(255, 255, 255, 0.9);
|
|
60
|
+
--analytics-widget-toolbar-hover-bg: rgba(255, 255, 255, 0.15);
|
|
61
|
+
--analytics-widget-toolbar-badge-bg: #3b82f6;
|
|
62
|
+
--analytics-widget-toolbar-badge-color: #fff;
|
|
63
|
+
/* Overlay (filter dialog backdrop) */
|
|
64
|
+
--analytics-widget-toolbar-overlay-z-index: 1000;
|
|
65
|
+
--analytics-widget-toolbar-overlay-bg: rgba(0, 0, 0, 0.35);
|
|
66
|
+
--analytics-widget-toolbar-overlay-backdrop-filter: blur(2px);
|
|
67
|
+
/* Dialog (filter panel) */
|
|
68
|
+
--analytics-widget-toolbar-dialog-z-index: 1;
|
|
69
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-toolbar.d.ts","sourceRoot":"","sources":["../../../../libs/analytics/src/filters/widget-toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD;;;GAGG;AACH,qBACa,sBAAuB,SAAQ,UAAU;IACpD,OAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"widget-toolbar.d.ts","sourceRoot":"","sources":["../../../../libs/analytics/src/filters/widget-toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD;;;GAGG;AACH,qBACa,sBAAuB,SAAQ,UAAU;IACpD,OAAgB,MAAM,0BAyHpB;IAEyB,OAAO,EAAE,gBAAgB,EAAE,CAAM;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAM;IACvD,WAAW,SAAK;IAEnC,OAAO,CAAC,WAAW,CAAS;IAErC,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,iBAAiB;IAIhB,MAAM;CA8ChB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,0BAA0B,EAAE,sBAAsB,CAAC;KACpD;CACF"}
|
|
@@ -19,7 +19,7 @@ let AnalyticsWidgetToolbar = class AnalyticsWidgetToolbar extends LitElement {
|
|
|
19
19
|
position: absolute;
|
|
20
20
|
top: 0.5rem;
|
|
21
21
|
right: 0.5rem;
|
|
22
|
-
z-index: 20;
|
|
22
|
+
z-index: var(--analytics-widget-toolbar-z-index, 20);
|
|
23
23
|
opacity: 0;
|
|
24
24
|
transition: opacity 0.2s ease;
|
|
25
25
|
pointer-events: none;
|
|
@@ -79,9 +79,10 @@ let AnalyticsWidgetToolbar = class AnalyticsWidgetToolbar extends LitElement {
|
|
|
79
79
|
.overlay {
|
|
80
80
|
position: fixed;
|
|
81
81
|
inset: 0;
|
|
82
|
-
z-index: 1000;
|
|
83
|
-
background: rgba(0, 0, 0, 0.35);
|
|
84
|
-
backdrop-filter: blur(2px);
|
|
82
|
+
z-index: var(--analytics-widget-toolbar-overlay-z-index, 1000);
|
|
83
|
+
background: var(--analytics-widget-toolbar-overlay-bg, rgba(0, 0, 0, 0.35));
|
|
84
|
+
backdrop-filter: var(--analytics-widget-toolbar-overlay-backdrop-filter, blur(2px));
|
|
85
|
+
-webkit-backdrop-filter: var(--analytics-widget-toolbar-overlay-backdrop-filter, blur(2px));
|
|
85
86
|
display: flex;
|
|
86
87
|
align-items: flex-start;
|
|
87
88
|
justify-content: center;
|
|
@@ -90,6 +91,7 @@ let AnalyticsWidgetToolbar = class AnalyticsWidgetToolbar extends LitElement {
|
|
|
90
91
|
}
|
|
91
92
|
.dialog {
|
|
92
93
|
position: relative;
|
|
94
|
+
z-index: var(--analytics-widget-toolbar-dialog-z-index, 1);
|
|
93
95
|
background: #fff;
|
|
94
96
|
border-radius: 12px;
|
|
95
97
|
border: 1px solid #e2e8f0;
|
|
@@ -114,7 +116,7 @@ let AnalyticsWidgetToolbar = class AnalyticsWidgetToolbar extends LitElement {
|
|
|
114
116
|
border: none;
|
|
115
117
|
border-radius: 6px;
|
|
116
118
|
cursor: pointer;
|
|
117
|
-
z-index: 1;
|
|
119
|
+
z-index: calc(var(--analytics-widget-toolbar-dialog-z-index, 1) + 1);
|
|
118
120
|
}
|
|
119
121
|
.dialog-close:hover {
|
|
120
122
|
background: #f1f5f9;
|
|
@@ -142,6 +144,7 @@ let AnalyticsWidgetToolbar = class AnalyticsWidgetToolbar extends LitElement {
|
|
|
142
144
|
this.dispatchEvent(new CustomEvent(EVENT_FILTER_CLOSE, { bubbles: true, composed: true }));
|
|
143
145
|
}
|
|
144
146
|
_onFilterChange(e) {
|
|
147
|
+
e.stopPropagation();
|
|
145
148
|
this.dispatchEvent(new CustomEvent(EVENT_FILTER_CHANGE, {
|
|
146
149
|
bubbles: true,
|
|
147
150
|
composed: true,
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quicdata/analytics",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
8
|
+
"style": "analytics.css",
|
|
8
9
|
"exports": {
|
|
9
10
|
"./package.json": "./package.json",
|
|
11
|
+
"./analytics.css": "./analytics.css",
|
|
10
12
|
".": {
|
|
11
13
|
"types": "./index.d.ts",
|
|
12
14
|
"import": "./index.js",
|
|
@@ -39,6 +41,16 @@
|
|
|
39
41
|
"lit": "^3.3.0",
|
|
40
42
|
"tslib": "^2.3.0"
|
|
41
43
|
},
|
|
44
|
+
"files": [
|
|
45
|
+
"*.js",
|
|
46
|
+
"*.d.ts",
|
|
47
|
+
"*.css",
|
|
48
|
+
"core",
|
|
49
|
+
"widgets",
|
|
50
|
+
"dashboard",
|
|
51
|
+
"designer",
|
|
52
|
+
"filters"
|
|
53
|
+
],
|
|
42
54
|
"nx": {
|
|
43
55
|
"targets": {
|
|
44
56
|
"build": {
|
|
@@ -47,7 +59,14 @@
|
|
|
47
59
|
"main": "libs/analytics/src/index.ts",
|
|
48
60
|
"outputPath": "dist/libs/analytics",
|
|
49
61
|
"tsConfig": "libs/analytics/tsconfig.lib.json",
|
|
50
|
-
"rootDir": "libs/analytics/src"
|
|
62
|
+
"rootDir": "libs/analytics/src",
|
|
63
|
+
"assets": [
|
|
64
|
+
{
|
|
65
|
+
"input": "libs/analytics/src",
|
|
66
|
+
"glob": "analytics.css",
|
|
67
|
+
"output": "."
|
|
68
|
+
}
|
|
69
|
+
]
|
|
51
70
|
}
|
|
52
71
|
}
|
|
53
72
|
}
|
package/widgets/base-chart.d.ts
CHANGED
|
@@ -50,14 +50,12 @@ export declare abstract class BaseChartWidget extends LitElement {
|
|
|
50
50
|
private _hideFilter;
|
|
51
51
|
private _widgetData;
|
|
52
52
|
private _chart;
|
|
53
|
-
private _resizeObserver;
|
|
54
|
-
private _resizeDelayId;
|
|
55
|
-
private _resizeDebounceId;
|
|
56
53
|
private _dashboardEl;
|
|
57
|
-
|
|
54
|
+
private _resizeObserver;
|
|
55
|
+
/** Single debounce: each resize cancels previous, then we wait and call chart.resize() once. */
|
|
56
|
+
private _resizeTimeoutId;
|
|
57
|
+
/** Delay (ms) after last resize event before calling chart.resize(). */
|
|
58
58
|
private static readonly _RESIZE_DELAY_MS;
|
|
59
|
-
/** Debounce (ms) after delay; resize runs only when no signal for this long. */
|
|
60
|
-
private static readonly _RESIZE_DEBOUNCE_MS;
|
|
61
59
|
private _viewportVisible;
|
|
62
60
|
/** Title from widget definition (API). Optional `title` attribute overrides this. */
|
|
63
61
|
private _definitionTitle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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I,IAAI;IAoC7B,OAAO,CAAC,oBAAoB;IAO5B,gFAAgF;IAChF,OAAO,KAAK,eAAe,GAE1B;IAED,6FAA6F;IAC7F,OAAO,CAAC,MAAM;IAQd,OAAO,CAAC,mBAAmB;YA2Bb,SAAS;IAiFvB,OAAO,CAAC,YAAY;IAuBpB;;;;OAIG;IACH,WAAW,CACT,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EACxC,WAAW,CAAC,EAAE,OAAO,GACpB,aAAa;IAShB,OAAO,CAAC,qBAAqB;IAIpB,MAAM;CAiChB"}
|
package/widgets/base-chart.js
CHANGED
|
@@ -101,20 +101,18 @@ export class BaseChartWidget extends LitElement {
|
|
|
101
101
|
min-height: 100px;
|
|
102
102
|
}
|
|
103
103
|
`; }
|
|
104
|
-
/**
|
|
104
|
+
/** Delay (ms) after last resize event before calling chart.resize(). */
|
|
105
105
|
static { this._RESIZE_DELAY_MS = 300; }
|
|
106
|
-
/** Debounce (ms) after delay; resize runs only when no signal for this long. */
|
|
107
|
-
static { this._RESIZE_DEBOUNCE_MS = 300; }
|
|
108
106
|
constructor() {
|
|
109
107
|
super();
|
|
110
108
|
this._loadGeneration = 0;
|
|
111
109
|
this._loadDataScheduled = false;
|
|
112
110
|
this._ignoreNextFilterChange = false;
|
|
113
111
|
this._chart = null;
|
|
114
|
-
this._resizeObserver = null;
|
|
115
|
-
this._resizeDelayId = null;
|
|
116
|
-
this._resizeDebounceId = null;
|
|
117
112
|
this._dashboardEl = null;
|
|
113
|
+
this._resizeObserver = null;
|
|
114
|
+
/** Single debounce: each resize cancels previous, then we wait and call chart.resize() once. */
|
|
115
|
+
this._resizeTimeoutId = null;
|
|
118
116
|
this._hasLoadedOnce = false;
|
|
119
117
|
this._viewportUnobserve = null;
|
|
120
118
|
this._boundOnDashboardFilterChange = (e) => {
|
|
@@ -157,9 +155,9 @@ export class BaseChartWidget extends LitElement {
|
|
|
157
155
|
this._viewportUnobserve?.();
|
|
158
156
|
this._viewportUnobserve = null;
|
|
159
157
|
this._detachDashboard();
|
|
160
|
-
if (this.
|
|
161
|
-
clearTimeout(this.
|
|
162
|
-
this.
|
|
158
|
+
if (this._resizeTimeoutId != null) {
|
|
159
|
+
clearTimeout(this._resizeTimeoutId);
|
|
160
|
+
this._resizeTimeoutId = null;
|
|
163
161
|
}
|
|
164
162
|
this._resizeObserver?.disconnect();
|
|
165
163
|
this._chart?.dispose();
|
|
@@ -227,16 +225,13 @@ export class BaseChartWidget extends LitElement {
|
|
|
227
225
|
const container = this.renderRoot.querySelector('.chart');
|
|
228
226
|
if (container) {
|
|
229
227
|
this._resizeObserver = new ResizeObserver(() => {
|
|
230
|
-
if (this.
|
|
231
|
-
clearTimeout(this.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.
|
|
235
|
-
this.
|
|
236
|
-
this.
|
|
237
|
-
this._resizeDebounceId = null;
|
|
238
|
-
this._chart?.resize();
|
|
239
|
-
}, BaseChartWidget._RESIZE_DEBOUNCE_MS);
|
|
228
|
+
if (this._resizeTimeoutId != null) {
|
|
229
|
+
clearTimeout(this._resizeTimeoutId);
|
|
230
|
+
this._resizeTimeoutId = null;
|
|
231
|
+
}
|
|
232
|
+
this._resizeTimeoutId = setTimeout(() => {
|
|
233
|
+
this._resizeTimeoutId = null;
|
|
234
|
+
this._chart?.resize();
|
|
240
235
|
}, BaseChartWidget._RESIZE_DELAY_MS);
|
|
241
236
|
});
|
|
242
237
|
this._resizeObserver.observe(container);
|
|
@@ -307,12 +302,6 @@ export class BaseChartWidget extends LitElement {
|
|
|
307
302
|
async _loadData() {
|
|
308
303
|
if (this.lazy && !this._viewportVisible)
|
|
309
304
|
return;
|
|
310
|
-
if (this.data != null && !this.widgetId) {
|
|
311
|
-
this._error = null;
|
|
312
|
-
this._loading = false;
|
|
313
|
-
this._renderChart();
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
305
|
const dataUrl = this._getEffectiveDataUrl();
|
|
317
306
|
if (!dataUrl) {
|
|
318
307
|
this._error = null;
|
package/widgets/table.d.ts
CHANGED
|
@@ -42,25 +42,20 @@ export declare class TableWidget extends LitElement {
|
|
|
42
42
|
private _error;
|
|
43
43
|
private _loadGeneration;
|
|
44
44
|
private _loadDataDebounceId;
|
|
45
|
+
private _loadDataScheduled;
|
|
45
46
|
private _loadDataInFlight;
|
|
46
|
-
private
|
|
47
|
+
private _loadDataPendingRefresh;
|
|
47
48
|
private _dashboardParams;
|
|
48
49
|
private _widgetFilters;
|
|
49
50
|
private _widgetFilterParams;
|
|
50
51
|
private _hideFilter;
|
|
51
52
|
private _dashboardEl;
|
|
53
|
+
private _ignoreNextFilterChange;
|
|
52
54
|
private _viewportVisible;
|
|
53
55
|
/** Title from widget definition (API). Optional `title` attribute overrides this. */
|
|
54
56
|
private _definitionTitle;
|
|
55
57
|
private _hasLoadedOnce;
|
|
56
58
|
private _viewportUnobserve;
|
|
57
|
-
private _resizeObserver;
|
|
58
|
-
private _resizeDelayId;
|
|
59
|
-
private _resizeDebounceId;
|
|
60
|
-
/** Initial delay (ms) before entering debounce; each new resize signal cancels and restarts. */
|
|
61
|
-
private static readonly _RESIZE_DELAY_MS;
|
|
62
|
-
/** Debounce (ms) after delay; resize runs only when no signal for this long. */
|
|
63
|
-
private static readonly _RESIZE_DEBOUNCE_MS;
|
|
64
59
|
constructor();
|
|
65
60
|
private _boundOnDashboardFilterChange;
|
|
66
61
|
private _boundOnDashboardRefresh;
|
package/widgets/table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../libs/analytics/src/widgets/table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAGrD,OAAO,KAAK,EAA0B,sBAAsB,EAAE,MAAM,uBAAuB,CAA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AC,WAAW;IASnB,oEAAoE;IACpE,OAAO,CAAC,QAAQ;IAMhB,2FAA2F;IAC3F,OAAO,CAAC,eAAe;IASvB,sEAAsE;IACtE,OAAO,CAAC,eAAe;IASvB,kFAAkF;IAClF,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,YAAY;IAIX,MAAM;IAsEf,OAAO,CAAC,YAAY;IA0BpB,OAAO,CAAC,cAAc;IAmCtB,OAAO,CAAC,WAAW;CAKpB"}
|
package/widgets/table.js
CHANGED
|
@@ -142,22 +142,17 @@ let TableWidget = class TableWidget extends LitElement {
|
|
|
142
142
|
box-sizing: border-box;
|
|
143
143
|
}
|
|
144
144
|
`; }
|
|
145
|
-
/** Initial delay (ms) before entering debounce; each new resize signal cancels and restarts. */
|
|
146
|
-
static { this._RESIZE_DELAY_MS = 300; }
|
|
147
|
-
/** Debounce (ms) after delay; resize runs only when no signal for this long. */
|
|
148
|
-
static { this._RESIZE_DEBOUNCE_MS = 300; }
|
|
149
145
|
constructor() {
|
|
150
146
|
super();
|
|
151
147
|
this._loadGeneration = 0;
|
|
152
148
|
this._loadDataDebounceId = null;
|
|
149
|
+
this._loadDataScheduled = false;
|
|
153
150
|
this._loadDataInFlight = false;
|
|
154
|
-
this.
|
|
151
|
+
this._loadDataPendingRefresh = false;
|
|
155
152
|
this._dashboardEl = null;
|
|
153
|
+
this._ignoreNextFilterChange = false;
|
|
156
154
|
this._hasLoadedOnce = false;
|
|
157
155
|
this._viewportUnobserve = null;
|
|
158
|
-
this._resizeObserver = null;
|
|
159
|
-
this._resizeDelayId = null;
|
|
160
|
-
this._resizeDebounceId = null;
|
|
161
156
|
this._boundOnDashboardFilterChange = (e) => {
|
|
162
157
|
const ce = e;
|
|
163
158
|
this._dashboardParams = { ...(ce.detail?.params ?? {}) };
|
|
@@ -200,16 +195,6 @@ let TableWidget = class TableWidget extends LitElement {
|
|
|
200
195
|
clearTimeout(this._loadDataDebounceId);
|
|
201
196
|
this._loadDataDebounceId = null;
|
|
202
197
|
}
|
|
203
|
-
if (this._resizeDelayId != null) {
|
|
204
|
-
clearTimeout(this._resizeDelayId);
|
|
205
|
-
this._resizeDelayId = null;
|
|
206
|
-
}
|
|
207
|
-
if (this._resizeDebounceId != null) {
|
|
208
|
-
clearTimeout(this._resizeDebounceId);
|
|
209
|
-
this._resizeDebounceId = null;
|
|
210
|
-
}
|
|
211
|
-
this._resizeObserver?.disconnect();
|
|
212
|
-
this._resizeObserver = null;
|
|
213
198
|
this._detachDashboard();
|
|
214
199
|
super.disconnectedCallback();
|
|
215
200
|
}
|
|
@@ -231,15 +216,19 @@ let TableWidget = class TableWidget extends LitElement {
|
|
|
231
216
|
!changed.has('apiUrl') &&
|
|
232
217
|
!changed.has('_dashboardParams');
|
|
233
218
|
if (onlyFilterState && this._ignoreNextFilterChange) {
|
|
234
|
-
this._ignoreNextFilterChange
|
|
219
|
+
// Skip scheduling: this update is from programmatic filter state (e.g. first load merge). Do not clear _ignoreNextFilterChange here; only _onWidgetFilterChange (user manual change) clears it.
|
|
235
220
|
}
|
|
236
221
|
else if (changed.has('dataUrl') ||
|
|
237
222
|
changed.has('dataParams') ||
|
|
238
223
|
changed.has('widgetId') ||
|
|
239
|
-
changed.has('apiUrl')
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
224
|
+
changed.has('apiUrl')) {
|
|
225
|
+
if (this._getEffectiveDataUrl() && !this._loadDataScheduled) {
|
|
226
|
+
this._loadDataScheduled = true;
|
|
227
|
+
queueMicrotask(() => {
|
|
228
|
+
this._loadDataScheduled = false;
|
|
229
|
+
this._loadData();
|
|
230
|
+
});
|
|
231
|
+
}
|
|
243
232
|
}
|
|
244
233
|
if (changed.has('lazy')) {
|
|
245
234
|
this._viewportVisible = !this.lazy;
|
|
@@ -264,23 +253,6 @@ let TableWidget = class TableWidget extends LitElement {
|
|
|
264
253
|
this._dashboardParams = {};
|
|
265
254
|
}
|
|
266
255
|
firstUpdated() {
|
|
267
|
-
const body = this.renderRoot.querySelector('.widget-body');
|
|
268
|
-
if (body && typeof ResizeObserver !== 'undefined') {
|
|
269
|
-
this._resizeObserver = new ResizeObserver(() => {
|
|
270
|
-
if (this._resizeDelayId != null)
|
|
271
|
-
clearTimeout(this._resizeDelayId);
|
|
272
|
-
if (this._resizeDebounceId != null)
|
|
273
|
-
clearTimeout(this._resizeDebounceId);
|
|
274
|
-
this._resizeDelayId = setTimeout(() => {
|
|
275
|
-
this._resizeDelayId = null;
|
|
276
|
-
this._resizeDebounceId = setTimeout(() => {
|
|
277
|
-
this._resizeDebounceId = null;
|
|
278
|
-
this.requestUpdate();
|
|
279
|
-
}, TableWidget_1._RESIZE_DEBOUNCE_MS);
|
|
280
|
-
}, TableWidget_1._RESIZE_DELAY_MS);
|
|
281
|
-
});
|
|
282
|
-
this._resizeObserver.observe(body);
|
|
283
|
-
}
|
|
284
256
|
if (this.lazy) {
|
|
285
257
|
this._viewportVisible = false;
|
|
286
258
|
this._viewportUnobserve = observeViewport(this, {
|
|
@@ -363,12 +335,6 @@ let TableWidget = class TableWidget extends LitElement {
|
|
|
363
335
|
async _loadData() {
|
|
364
336
|
if (this.lazy && !this._viewportVisible)
|
|
365
337
|
return;
|
|
366
|
-
// Skip fetch only when using pure inline data (no dataUrl). When we have dataUrl we must refetch when params change (e.g. report filters).
|
|
367
|
-
if (this.data != null && !this.dataUrl) {
|
|
368
|
-
this._error = null;
|
|
369
|
-
this._loading = false;
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
338
|
const dataUrl = this._getEffectiveDataUrl();
|
|
373
339
|
if (!dataUrl) {
|
|
374
340
|
this._error = null;
|
|
@@ -376,6 +342,7 @@ let TableWidget = class TableWidget extends LitElement {
|
|
|
376
342
|
return;
|
|
377
343
|
}
|
|
378
344
|
if (this._loadDataInFlight) {
|
|
345
|
+
this._loadDataPendingRefresh = true;
|
|
379
346
|
return;
|
|
380
347
|
}
|
|
381
348
|
const gen = ++this._loadGeneration;
|
|
@@ -442,6 +409,10 @@ let TableWidget = class TableWidget extends LitElement {
|
|
|
442
409
|
if (hideFilter !== undefined)
|
|
443
410
|
this._hideFilter = hideFilter;
|
|
444
411
|
this._loading = false;
|
|
412
|
+
if (this._loadDataPendingRefresh) {
|
|
413
|
+
this._loadDataPendingRefresh = false;
|
|
414
|
+
this._scheduleLoadData();
|
|
415
|
+
}
|
|
445
416
|
});
|
|
446
417
|
}
|
|
447
418
|
else {
|
|
@@ -481,6 +452,10 @@ let TableWidget = class TableWidget extends LitElement {
|
|
|
481
452
|
if (hideFilter !== undefined)
|
|
482
453
|
this._hideFilter = hideFilter;
|
|
483
454
|
this._loading = false;
|
|
455
|
+
if (this._loadDataPendingRefresh) {
|
|
456
|
+
this._loadDataPendingRefresh = false;
|
|
457
|
+
this._scheduleLoadData();
|
|
458
|
+
}
|
|
484
459
|
});
|
|
485
460
|
}
|
|
486
461
|
}
|
|
@@ -494,11 +469,17 @@ let TableWidget = class TableWidget extends LitElement {
|
|
|
494
469
|
this.data = [];
|
|
495
470
|
this._widgetData = null;
|
|
496
471
|
this._loading = false;
|
|
472
|
+
if (this._loadDataPendingRefresh) {
|
|
473
|
+
this._loadDataPendingRefresh = false;
|
|
474
|
+
this._scheduleLoadData();
|
|
475
|
+
}
|
|
497
476
|
});
|
|
498
477
|
}
|
|
499
478
|
}
|
|
500
479
|
_onWidgetFilterChange(e) {
|
|
480
|
+
this._ignoreNextFilterChange = false;
|
|
501
481
|
this._widgetFilterParams = { ...(e.detail?.params ?? {}) };
|
|
482
|
+
this._scheduleLoadData();
|
|
502
483
|
}
|
|
503
484
|
/** Column keys in display order. From widgetData when present, else derived from data/meta. */
|
|
504
485
|
_getColumns() {
|
package/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../libs/analytics/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,EACT,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,6BAA6B,EAC7B,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACvG,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web Worker for widget data transforms (pivot, aggregation, header normalization).
|
|
3
|
-
* Message protocol: { type: 'transform', id, widgetDefinition, data } -> { type: 'result', id, widgetData } | { type: 'error', id, error }.
|
|
4
|
-
*/
|
|
5
|
-
export interface WorkerTransformInput {
|
|
6
|
-
type: 'transform';
|
|
7
|
-
id: number;
|
|
8
|
-
widgetDefinition: Record<string, unknown>;
|
|
9
|
-
data: Record<string, unknown>[];
|
|
10
|
-
}
|
|
11
|
-
export interface WorkerTransformResult {
|
|
12
|
-
type: 'result';
|
|
13
|
-
id: number;
|
|
14
|
-
widgetData: unknown;
|
|
15
|
-
}
|
|
16
|
-
export interface WorkerTransformError {
|
|
17
|
-
type: 'error';
|
|
18
|
-
id: number;
|
|
19
|
-
error: string;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=widget-transform.worker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"widget-transform.worker.d.ts","sourceRoot":"","sources":["../../../../libs/analytics/src/workers/widget-transform.worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,WAAW,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web Worker for widget data transforms (pivot, aggregation, header normalization).
|
|
3
|
-
* Message protocol: { type: 'transform', id, widgetDefinition, data } -> { type: 'result', id, widgetData } | { type: 'error', id, error }.
|
|
4
|
-
*/
|
|
5
|
-
/** Minimal client-side transform: normalize columns from first row, pass rows through. Extend for pivot/aggregation. */
|
|
6
|
-
function transformInWorker(_widgetDefinition, data) {
|
|
7
|
-
if (!Array.isArray(data) || data.length === 0) {
|
|
8
|
-
return { chartType: 'Table', columns: [], rows: [] };
|
|
9
|
-
}
|
|
10
|
-
const columns = Object.keys(data[0]);
|
|
11
|
-
return { chartType: 'Table', columns, rows: data };
|
|
12
|
-
}
|
|
13
|
-
function handleMessage(e) {
|
|
14
|
-
const msg = e.data;
|
|
15
|
-
if (msg?.type !== 'transform' || typeof msg.id !== 'number')
|
|
16
|
-
return;
|
|
17
|
-
try {
|
|
18
|
-
const widgetData = transformInWorker(msg.widgetDefinition ?? {}, msg.data ?? []);
|
|
19
|
-
postMessage({ type: 'result', id: msg.id, widgetData });
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
postMessage({
|
|
23
|
-
type: 'error',
|
|
24
|
-
id: msg.id,
|
|
25
|
-
error: err instanceof Error ? err.message : String(err),
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
self.onmessage = handleMessage;
|
|
30
|
-
export {};
|