@aquera/nile-visualization 2.9.27 → 2.9.29

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 (128) hide show
  1. package/README.md +8 -0
  2. package/dist/src/index.d.ts +5 -0
  3. package/dist/src/index.js +4 -0
  4. package/dist/src/internal/chart-events.d.ts +92 -0
  5. package/dist/src/internal/chart-events.js +291 -0
  6. package/dist/src/internal/chart-runtime.d.ts +41 -0
  7. package/dist/src/internal/chart-runtime.js +30 -0
  8. package/dist/src/internal/dashboard-adapters.d.ts +4 -0
  9. package/dist/src/internal/dashboard-adapters.js +9 -3
  10. package/dist/src/internal/highcharts-provider.js +3 -0
  11. package/dist/src/internal/nile-chart-base.d.ts +43 -0
  12. package/dist/src/internal/nile-chart-base.js +67 -0
  13. package/dist/src/internal/resolve-widget-kind.d.ts +10 -0
  14. package/dist/src/internal/resolve-widget-kind.js +16 -0
  15. package/dist/src/internal/responsive-defaults.d.ts +32 -0
  16. package/dist/src/internal/responsive-defaults.js +255 -0
  17. package/dist/src/internal/types/highcharts-passthrough.type.d.ts +80 -0
  18. package/dist/src/internal/types/highcharts-passthrough.type.js +24 -0
  19. package/dist/src/internal/types/index.d.ts +2 -0
  20. package/dist/src/internal/types/index.js +1 -1
  21. package/dist/src/internal/types/widget-config.type.d.ts +14 -3
  22. package/dist/src/nile-anomaly-chart/nile-anomaly-chart.d.ts +2 -0
  23. package/dist/src/nile-anomaly-chart/nile-anomaly-chart.js +8 -1
  24. package/dist/src/nile-area-chart/nile-area-chart.d.ts +1 -0
  25. package/dist/src/nile-area-chart/nile-area-chart.js +7 -1
  26. package/dist/src/nile-area-negative-chart/nile-area-negative-chart.d.ts +1 -0
  27. package/dist/src/nile-area-negative-chart/nile-area-negative-chart.js +7 -1
  28. package/dist/src/nile-area-range-chart/nile-area-range-chart.d.ts +1 -0
  29. package/dist/src/nile-area-range-chart/nile-area-range-chart.js +7 -1
  30. package/dist/src/nile-area-spline-chart/nile-area-spline-chart.d.ts +1 -0
  31. package/dist/src/nile-area-spline-chart/nile-area-spline-chart.js +7 -1
  32. package/dist/src/nile-bar-chart/nile-bar-chart.d.ts +2 -0
  33. package/dist/src/nile-bar-chart/nile-bar-chart.js +8 -1
  34. package/dist/src/nile-bellcurve-chart/nile-bellcurve-chart.d.ts +1 -0
  35. package/dist/src/nile-bellcurve-chart/nile-bellcurve-chart.js +7 -1
  36. package/dist/src/nile-boxplot-chart/nile-boxplot-chart.d.ts +1 -0
  37. package/dist/src/nile-boxplot-chart/nile-boxplot-chart.js +7 -1
  38. package/dist/src/nile-bubble-chart/nile-bubble-chart.d.ts +1 -0
  39. package/dist/src/nile-bubble-chart/nile-bubble-chart.js +7 -1
  40. package/dist/src/nile-chart/nile-chart-config.d.ts +2 -2
  41. package/dist/src/nile-chart/nile-chart.css.js +7 -1
  42. package/dist/src/nile-chart/nile-chart.d.ts +59 -0
  43. package/dist/src/nile-chart/nile-chart.js +176 -3
  44. package/dist/src/nile-cluster-chart/nile-cluster-chart.d.ts +1 -0
  45. package/dist/src/nile-cluster-chart/nile-cluster-chart.js +7 -1
  46. package/dist/src/nile-column-chart/nile-column-chart.d.ts +1 -0
  47. package/dist/src/nile-column-chart/nile-column-chart.js +7 -1
  48. package/dist/src/nile-column-drilldown-chart/nile-column-drilldown-chart.d.ts +1 -0
  49. package/dist/src/nile-column-drilldown-chart/nile-column-drilldown-chart.js +8 -1
  50. package/dist/src/nile-column-pyramid-chart/nile-column-pyramid-chart.d.ts +1 -0
  51. package/dist/src/nile-column-pyramid-chart/nile-column-pyramid-chart.js +7 -1
  52. package/dist/src/nile-column-range-chart/nile-column-range-chart.d.ts +1 -0
  53. package/dist/src/nile-column-range-chart/nile-column-range-chart.js +7 -1
  54. package/dist/src/nile-dashboard-builder/gridstack-css.d.ts +1 -0
  55. package/dist/src/nile-dashboard-builder/gridstack-css.js +6 -0
  56. package/dist/src/nile-dashboard-builder/index.d.ts +1 -0
  57. package/dist/src/nile-dashboard-builder/index.js +2 -0
  58. package/dist/src/nile-dashboard-builder/nile-dashboard-builder.css.d.ts +1 -0
  59. package/dist/src/nile-dashboard-builder/nile-dashboard-builder.css.js +96 -0
  60. package/dist/src/nile-dashboard-builder/nile-dashboard-builder.d.ts +177 -0
  61. package/dist/src/nile-dashboard-builder/nile-dashboard-builder.js +499 -0
  62. package/dist/src/nile-donut-chart/nile-donut-chart.d.ts +1 -0
  63. package/dist/src/nile-donut-chart/nile-donut-chart.js +7 -1
  64. package/dist/src/nile-dumbbell-chart/nile-dumbbell-chart.d.ts +1 -0
  65. package/dist/src/nile-dumbbell-chart/nile-dumbbell-chart.js +7 -1
  66. package/dist/src/nile-dumbbell-lower-chart/nile-dumbbell-lower-chart.d.ts +1 -0
  67. package/dist/src/nile-dumbbell-lower-chart/nile-dumbbell-lower-chart.js +7 -1
  68. package/dist/src/nile-dumbbell-upper-chart/nile-dumbbell-upper-chart.d.ts +1 -0
  69. package/dist/src/nile-dumbbell-upper-chart/nile-dumbbell-upper-chart.js +7 -1
  70. package/dist/src/nile-euler-chart/nile-euler-chart.d.ts +1 -0
  71. package/dist/src/nile-euler-chart/nile-euler-chart.js +7 -1
  72. package/dist/src/nile-fan-chart/nile-fan-chart.d.ts +1 -0
  73. package/dist/src/nile-fan-chart/nile-fan-chart.js +7 -1
  74. package/dist/src/nile-flame-chart/nile-flame-chart.d.ts +1 -0
  75. package/dist/src/nile-flame-chart/nile-flame-chart.js +7 -1
  76. package/dist/src/nile-funnel-chart/nile-funnel-chart.d.ts +1 -0
  77. package/dist/src/nile-funnel-chart/nile-funnel-chart.js +7 -1
  78. package/dist/src/nile-gauge-chart/nile-gauge-chart.d.ts +20 -0
  79. package/dist/src/nile-gauge-chart/nile-gauge-chart.js +80 -4
  80. package/dist/src/nile-heatmap-chart/nile-heatmap-chart.d.ts +1 -0
  81. package/dist/src/nile-heatmap-chart/nile-heatmap-chart.js +7 -1
  82. package/dist/src/nile-histogram-chart/nile-histogram-chart.d.ts +1 -0
  83. package/dist/src/nile-histogram-chart/nile-histogram-chart.js +7 -1
  84. package/dist/src/nile-inverted-area-chart/nile-inverted-area-chart.d.ts +1 -0
  85. package/dist/src/nile-inverted-area-chart/nile-inverted-area-chart.js +7 -1
  86. package/dist/src/nile-line-chart/nile-line-chart.d.ts +1 -0
  87. package/dist/src/nile-line-chart/nile-line-chart.js +7 -1
  88. package/dist/src/nile-line-column-chart/nile-line-column-chart.d.ts +1 -0
  89. package/dist/src/nile-line-column-chart/nile-line-column-chart.js +7 -1
  90. package/dist/src/nile-lollipop-chart/nile-lollipop-chart.d.ts +1 -0
  91. package/dist/src/nile-lollipop-chart/nile-lollipop-chart.js +7 -1
  92. package/dist/src/nile-map-chart/nile-map-chart.d.ts +23 -3
  93. package/dist/src/nile-map-chart/nile-map-chart.js +52 -12
  94. package/dist/src/nile-master-detail-chart/nile-master-detail-chart.css.js +13 -1
  95. package/dist/src/nile-master-detail-chart/nile-master-detail-chart.d.ts +1 -0
  96. package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +48 -4
  97. package/dist/src/nile-organization-chart/nile-organization-chart.d.ts +1 -0
  98. package/dist/src/nile-organization-chart/nile-organization-chart.js +7 -1
  99. package/dist/src/nile-pie-chart/nile-pie-chart.d.ts +2 -0
  100. package/dist/src/nile-pie-chart/nile-pie-chart.js +8 -1
  101. package/dist/src/nile-polygon-chart/nile-polygon-chart.d.ts +1 -0
  102. package/dist/src/nile-polygon-chart/nile-polygon-chart.js +7 -1
  103. package/dist/src/nile-radar-chart/nile-radar-chart.d.ts +1 -0
  104. package/dist/src/nile-radar-chart/nile-radar-chart.js +7 -1
  105. package/dist/src/nile-radial-bar-chart/nile-radial-bar-chart.d.ts +1 -0
  106. package/dist/src/nile-radial-bar-chart/nile-radial-bar-chart.js +7 -1
  107. package/dist/src/nile-scatter-chart/nile-scatter-chart.d.ts +1 -0
  108. package/dist/src/nile-scatter-chart/nile-scatter-chart.js +7 -1
  109. package/dist/src/nile-spiderweb-chart/nile-spiderweb-chart.d.ts +1 -0
  110. package/dist/src/nile-spiderweb-chart/nile-spiderweb-chart.js +7 -1
  111. package/dist/src/nile-spline-chart/nile-spline-chart.d.ts +1 -0
  112. package/dist/src/nile-spline-chart/nile-spline-chart.js +7 -1
  113. package/dist/src/nile-stacked-chart/nile-stacked-chart.d.ts +1 -0
  114. package/dist/src/nile-stacked-chart/nile-stacked-chart.js +7 -1
  115. package/dist/src/nile-timeline-chart/nile-timeline-chart.d.ts +1 -0
  116. package/dist/src/nile-timeline-chart/nile-timeline-chart.js +7 -1
  117. package/dist/src/nile-trendline-chart/nile-trendline-chart.d.ts +2 -0
  118. package/dist/src/nile-trendline-chart/nile-trendline-chart.js +8 -1
  119. package/dist/src/nile-variable-pie-chart/nile-variable-pie-chart.d.ts +1 -0
  120. package/dist/src/nile-variable-pie-chart/nile-variable-pie-chart.js +7 -1
  121. package/dist/src/nile-vector-chart/nile-vector-chart.d.ts +1 -0
  122. package/dist/src/nile-vector-chart/nile-vector-chart.js +7 -1
  123. package/dist/src/nile-waterfall-chart/nile-waterfall-chart.d.ts +1 -0
  124. package/dist/src/nile-waterfall-chart/nile-waterfall-chart.js +7 -1
  125. package/dist/src/nile-widget-viewer/nile-widget-viewer.js +6 -6
  126. package/dist/src/nile-xrange-chart/nile-xrange-chart.d.ts +1 -0
  127. package/dist/src/nile-xrange-chart/nile-xrange-chart.js +7 -1
  128. package/package.json +7 -6
@@ -0,0 +1,177 @@
1
+ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
2
+ import type { Responsive } from 'gridstack';
3
+ import NileElement from '../internal/nile-element.js';
4
+ import type { NileDashboardConfig } from '../internal/types/dashboard-config.type.js';
5
+ import '../nile-widget-viewer/index.js';
6
+ /** When the per-widget remove control (✕) is shown. */
7
+ export type RemoveVisibility = 'hover' | 'always';
8
+ export declare class NileDashboardBuilder extends NileElement {
9
+ static styles: CSSResultGroup;
10
+ /** Dashboard configuration. Widgets without an `id` are assigned one. */
11
+ config: NileDashboardConfig | null;
12
+ /** Number of grid columns. Default: 12. */
13
+ columns: number;
14
+ /** Row height in pixels. Default: 72 (matches gridster `fixedRowHeight`). */
15
+ cellHeight: number;
16
+ /** Gap between cells in pixels. Default: 8. */
17
+ gap: number;
18
+ /**
19
+ * Minimum number of rows the grid keeps, so an empty or sparsely-filled
20
+ * dashboard still presents a drop target instead of collapsing. Set `0` to
21
+ * let the grid shrink to its content. Default: 4.
22
+ */
23
+ minRows: number;
24
+ /** Minimum widget width in columns (gridster `minItemCols`). Default: 2. */
25
+ minW: number;
26
+ /** Minimum widget height in rows (gridster `minItemRows`). Default: 2. */
27
+ minH: number;
28
+ /**
29
+ * Comma-separated list of edges and corners a widget can be resized from,
30
+ * passed straight to gridstack's `resizable.handles`.
31
+ *
32
+ * The default is seven of the eight positions: `ne` is left out because the
33
+ * remove control (✕) sits in that corner and would compete with the handle
34
+ * for the same few pixels. Add it back if you set `remove-visibility` such
35
+ * that the corner is free.
36
+ *
37
+ * Default: `'n,e,s,w,se,sw,nw'`.
38
+ */
39
+ resizeHandles: string;
40
+ /**
41
+ * Whether widgets stay where they are dropped rather than being pulled up to
42
+ * close vertical gaps (gridstack's float mode). `false` compacts the grid
43
+ * upward after every change. Default: `true`.
44
+ */
45
+ float: boolean;
46
+ /**
47
+ * Whether the dashboard can be modified. `false` makes the grid static — no
48
+ * dragging or resizing — and hides every remove control regardless of
49
+ * `remove-visibility`. Reflected, so it can be styled via `:host([editable])`.
50
+ * Default: `true`.
51
+ */
52
+ editable: boolean;
53
+ /**
54
+ * Whether to paint the cell-boundary overlay behind the widgets, which makes
55
+ * the drop targets legible while arranging. Reflected as the `gridlines`
56
+ * attribute. Default: `true`.
57
+ */
58
+ gridLines: boolean;
59
+ /**
60
+ * Overrides the grid-line color with any CSS color. Empty means fall back to
61
+ * the `--nile-dashboard-builder-grid-line` custom property, and then to
62
+ * `--ng-color-blue-200`. Only has a visible effect while `gridLines` is on.
63
+ * Default: `''`.
64
+ */
65
+ gridLineColor: string;
66
+ /**
67
+ * When the per-widget remove control (✕) is shown.
68
+ *
69
+ * - `'hover'` (default) — revealed when the pointer enters the widget, keeping
70
+ * the tiles clean at rest. It also appears on keyboard focus, and stays
71
+ * permanently visible on touch devices, which cannot hover.
72
+ * - `'always'` — always visible.
73
+ *
74
+ * Orthogonal to `editable`: a non-editable builder never shows the control,
75
+ * whatever this is set to.
76
+ */
77
+ removeVisibility: RemoveVisibility;
78
+ /**
79
+ * Maximum number of rows the grid will accept, capping how tall a dashboard
80
+ * can grow. `0` means unlimited, which is the default — widgets can be placed
81
+ * or dragged arbitrarily far down. Default: 0.
82
+ */
83
+ maxRow: number;
84
+ /**
85
+ * Responsive column behaviour: pick the column count from the available width
86
+ * instead of pinning it to `columns`. Either give a `columnWidth` to target,
87
+ * or explicit `breakpoints`.
88
+ *
89
+ * Note that gridstack requires matching CSS for column counts other than the
90
+ * default, so this needs styling support to be useful.
91
+ *
92
+ * Supplying only a `columnWidth` is safe here — the missing `breakpoints`
93
+ * array is filled in before it reaches gridstack, which would otherwise
94
+ * throw on that combination.
95
+ *
96
+ * Applied at initialization only — changing it later has no effect.
97
+ */
98
+ columnOpts: Responsive | null;
99
+ /**
100
+ * Only render widgets once they scroll into view. Worth turning on for
101
+ * dashboards with many widgets, since every widget otherwise mounts a live
102
+ * chart up front.
103
+ *
104
+ * Applied at initialization only — changing it later has no effect.
105
+ * Default: `false`.
106
+ */
107
+ lazyLoad: boolean;
108
+ /**
109
+ * Stops widgets animating to their new position when the layout reflows.
110
+ *
111
+ * Named for what it turns off rather than on, because `animate` is already
112
+ * `HTMLElement.prototype.animate` and cannot be shadowed by a property.
113
+ * Default: `false`.
114
+ */
115
+ disableAnimation: boolean;
116
+ /**
117
+ * Prevents widgets from being dragged while still allowing resize. Finer
118
+ * grained than `editable`, which disables both at once; when `editable` is
119
+ * `false` nothing is draggable regardless of this. Default: `false`.
120
+ */
121
+ disableDrag: boolean;
122
+ /**
123
+ * Prevents widgets from being resized while still allowing drag. Finer
124
+ * grained than `editable`, which disables both at once; when `editable` is
125
+ * `false` nothing is resizable regardless of this. Default: `false`.
126
+ */
127
+ disableResize: boolean;
128
+ /**
129
+ * Keeps resize handles permanently visible rather than revealing them on
130
+ * hover. Useful on touch devices, which cannot hover.
131
+ *
132
+ * Applied at initialization only — changing it later has no effect.
133
+ * Default: `false`.
134
+ */
135
+ alwaysShowResizeHandle: boolean;
136
+ private gridEl;
137
+ private grid?;
138
+ /** id -> the `.grid-stack-item` element hosting that widget. */
139
+ private itemEls;
140
+ /** id -> the latest widget config (used to rebuild config on layout change). */
141
+ private widgetById;
142
+ /** Guards against re-emitting while we apply config programmatically. */
143
+ private applying;
144
+ /** Signature of the last layout we applied/emitted, to suppress echoes. */
145
+ private lastSig;
146
+ private idCounter;
147
+ /** True when a config change came from a component method and should be emitted. */
148
+ private internalChange;
149
+ firstUpdated(): void;
150
+ updated(changed: PropertyValues<this>): void;
151
+ disconnectedCallback(): void;
152
+ /**
153
+ * Applies the current `config` to the grid (add/remove/update items). When the
154
+ * change originated from a component method (`internalChange`), emits the
155
+ * resulting config *after* the grid is updated — this avoids a race where
156
+ * emitting before the grid mutation would discard the add/remove.
157
+ */
158
+ private reconcile;
159
+ /** Builds a `.grid-stack-item` hosting the widget viewer plus a remove control. */
160
+ private createItem;
161
+ /** Adds a starter chart or KPI widget at the bottom of the grid. */
162
+ addWidget(type: 'chart' | 'kpi'): void;
163
+ removeWidget(id: string): void;
164
+ requestRemoveWidget(id: string): boolean;
165
+ /** Reads the true layout back from gridstack and emits the updated config. */
166
+ private emitFromGrid;
167
+ /** Ensures every widget has a stable id (assigned in place if missing). */
168
+ private normalizeWidgets;
169
+ /** Order-independent signature of the current layout + content. */
170
+ private signature;
171
+ render(): TemplateResult;
172
+ }
173
+ declare global {
174
+ interface HTMLElementTagNameMap {
175
+ 'nile-dashboard-builder': NileDashboardBuilder;
176
+ }
177
+ }
@@ -0,0 +1,499 @@
1
+ import { __decorate } from "tslib";
2
+ import { customElement, property, query } from 'lit/decorators.js';
3
+ import { html } from 'lit';
4
+ import { GridStack } from 'gridstack';
5
+ import NileElement from '../internal/nile-element.js';
6
+ import { styles } from './nile-dashboard-builder.css.js';
7
+ import { gridstackCss } from './gridstack-css.js';
8
+ import { resolveWidgetKind } from '../internal/resolve-widget-kind.js';
9
+ import '../nile-widget-viewer/index.js';
10
+ let NileDashboardBuilder = class NileDashboardBuilder extends NileElement {
11
+ constructor() {
12
+ super(...arguments);
13
+ /** Dashboard configuration. Widgets without an `id` are assigned one. */
14
+ this.config = null;
15
+ /** Number of grid columns. Default: 12. */
16
+ this.columns = 12;
17
+ /** Row height in pixels. Default: 72 (matches gridster `fixedRowHeight`). */
18
+ this.cellHeight = 72;
19
+ /** Gap between cells in pixels. Default: 8. */
20
+ this.gap = 8;
21
+ /**
22
+ * Minimum number of rows the grid keeps, so an empty or sparsely-filled
23
+ * dashboard still presents a drop target instead of collapsing. Set `0` to
24
+ * let the grid shrink to its content. Default: 4.
25
+ */
26
+ this.minRows = 4;
27
+ /** Minimum widget width in columns (gridster `minItemCols`). Default: 2. */
28
+ this.minW = 2;
29
+ /** Minimum widget height in rows (gridster `minItemRows`). Default: 2. */
30
+ this.minH = 2;
31
+ /**
32
+ * Comma-separated list of edges and corners a widget can be resized from,
33
+ * passed straight to gridstack's `resizable.handles`.
34
+ *
35
+ * The default is seven of the eight positions: `ne` is left out because the
36
+ * remove control (✕) sits in that corner and would compete with the handle
37
+ * for the same few pixels. Add it back if you set `remove-visibility` such
38
+ * that the corner is free.
39
+ *
40
+ * Default: `'n,e,s,w,se,sw,nw'`.
41
+ */
42
+ this.resizeHandles = 'n,e,s,w,se,sw,nw';
43
+ /**
44
+ * Whether widgets stay where they are dropped rather than being pulled up to
45
+ * close vertical gaps (gridstack's float mode). `false` compacts the grid
46
+ * upward after every change. Default: `true`.
47
+ */
48
+ this.float = true;
49
+ /**
50
+ * Whether the dashboard can be modified. `false` makes the grid static — no
51
+ * dragging or resizing — and hides every remove control regardless of
52
+ * `remove-visibility`. Reflected, so it can be styled via `:host([editable])`.
53
+ * Default: `true`.
54
+ */
55
+ this.editable = true;
56
+ /**
57
+ * Whether to paint the cell-boundary overlay behind the widgets, which makes
58
+ * the drop targets legible while arranging. Reflected as the `gridlines`
59
+ * attribute. Default: `true`.
60
+ */
61
+ this.gridLines = true;
62
+ /**
63
+ * Overrides the grid-line color with any CSS color. Empty means fall back to
64
+ * the `--nile-dashboard-builder-grid-line` custom property, and then to
65
+ * `--ng-color-blue-200`. Only has a visible effect while `gridLines` is on.
66
+ * Default: `''`.
67
+ */
68
+ this.gridLineColor = '';
69
+ /**
70
+ * When the per-widget remove control (✕) is shown.
71
+ *
72
+ * - `'hover'` (default) — revealed when the pointer enters the widget, keeping
73
+ * the tiles clean at rest. It also appears on keyboard focus, and stays
74
+ * permanently visible on touch devices, which cannot hover.
75
+ * - `'always'` — always visible.
76
+ *
77
+ * Orthogonal to `editable`: a non-editable builder never shows the control,
78
+ * whatever this is set to.
79
+ */
80
+ this.removeVisibility = 'hover';
81
+ /**
82
+ * Maximum number of rows the grid will accept, capping how tall a dashboard
83
+ * can grow. `0` means unlimited, which is the default — widgets can be placed
84
+ * or dragged arbitrarily far down. Default: 0.
85
+ */
86
+ this.maxRow = 0;
87
+ /**
88
+ * Responsive column behaviour: pick the column count from the available width
89
+ * instead of pinning it to `columns`. Either give a `columnWidth` to target,
90
+ * or explicit `breakpoints`.
91
+ *
92
+ * Note that gridstack requires matching CSS for column counts other than the
93
+ * default, so this needs styling support to be useful.
94
+ *
95
+ * Supplying only a `columnWidth` is safe here — the missing `breakpoints`
96
+ * array is filled in before it reaches gridstack, which would otherwise
97
+ * throw on that combination.
98
+ *
99
+ * Applied at initialization only — changing it later has no effect.
100
+ */
101
+ this.columnOpts = null;
102
+ /**
103
+ * Only render widgets once they scroll into view. Worth turning on for
104
+ * dashboards with many widgets, since every widget otherwise mounts a live
105
+ * chart up front.
106
+ *
107
+ * Applied at initialization only — changing it later has no effect.
108
+ * Default: `false`.
109
+ */
110
+ this.lazyLoad = false;
111
+ /**
112
+ * Stops widgets animating to their new position when the layout reflows.
113
+ *
114
+ * Named for what it turns off rather than on, because `animate` is already
115
+ * `HTMLElement.prototype.animate` and cannot be shadowed by a property.
116
+ * Default: `false`.
117
+ */
118
+ this.disableAnimation = false;
119
+ /**
120
+ * Prevents widgets from being dragged while still allowing resize. Finer
121
+ * grained than `editable`, which disables both at once; when `editable` is
122
+ * `false` nothing is draggable regardless of this. Default: `false`.
123
+ */
124
+ this.disableDrag = false;
125
+ /**
126
+ * Prevents widgets from being resized while still allowing drag. Finer
127
+ * grained than `editable`, which disables both at once; when `editable` is
128
+ * `false` nothing is resizable regardless of this. Default: `false`.
129
+ */
130
+ this.disableResize = false;
131
+ /**
132
+ * Keeps resize handles permanently visible rather than revealing them on
133
+ * hover. Useful on touch devices, which cannot hover.
134
+ *
135
+ * Applied at initialization only — changing it later has no effect.
136
+ * Default: `false`.
137
+ */
138
+ this.alwaysShowResizeHandle = false;
139
+ /** id -> the `.grid-stack-item` element hosting that widget. */
140
+ this.itemEls = new Map();
141
+ /** id -> the latest widget config (used to rebuild config on layout change). */
142
+ this.widgetById = new Map();
143
+ /** Guards against re-emitting while we apply config programmatically. */
144
+ this.applying = false;
145
+ /** Signature of the last layout we applied/emitted, to suppress echoes. */
146
+ this.lastSig = '';
147
+ this.idCounter = 0;
148
+ /** True when a config change came from a component method and should be emitted. */
149
+ this.internalChange = false;
150
+ }
151
+ firstUpdated() {
152
+ this.grid = GridStack.init({
153
+ column: this.columns,
154
+ cellHeight: this.cellHeight,
155
+ margin: this.gap,
156
+ float: this.float,
157
+ staticGrid: !this.editable,
158
+ minRow: this.minRows || undefined,
159
+ // 0 means "no cap" to us; gridstack wants the key absent for that.
160
+ maxRow: this.maxRow || undefined,
161
+ lazyLoad: this.lazyLoad,
162
+ animate: !this.disableAnimation,
163
+ disableDrag: this.disableDrag,
164
+ disableResize: this.disableResize,
165
+ alwaysShowResizeHandle: this.alwaysShowResizeHandle,
166
+ // Only forwarded when set — passing `columnOpts: undefined` would
167
+ // override gridstack's own default handling.
168
+ //
169
+ // `breakpoints` is always supplied, even empty: gridstack 13.0.0 tests
170
+ // `!columnWidth && !breakpoints?.length` but then reads
171
+ // `breakpoints.length` unguarded in the else branch, so a columnOpts
172
+ // carrying only a columnWidth — which its own docs call valid — throws
173
+ // inside the GridStack constructor.
174
+ ...(this.columnOpts
175
+ ? { columnOpts: { breakpoints: [], ...this.columnOpts } }
176
+ : {}),
177
+ // Resize handles (configurable via `resize-handles`); the default covers
178
+ // seven of the eight positions, omitting `ne` where the remove control
179
+ // sits. See the `resizeHandles` docs.
180
+ resizable: { handles: this.resizeHandles },
181
+ }, this.gridEl);
182
+ this.grid.on('change', () => {
183
+ if (!this.applying)
184
+ this.emitFromGrid();
185
+ });
186
+ // Nudge chart libraries (Highcharts) that reflow on window resize.
187
+ this.grid.on('resizestop', () => window.dispatchEvent(new Event('resize')));
188
+ void this.reconcile();
189
+ }
190
+ updated(changed) {
191
+ if (this.grid) {
192
+ if (changed.has('columns'))
193
+ this.grid.column(this.columns);
194
+ if (changed.has('cellHeight'))
195
+ this.grid.cellHeight(this.cellHeight);
196
+ if (changed.has('gap'))
197
+ this.grid.margin(this.gap);
198
+ if (changed.has('float'))
199
+ this.grid.float(this.float);
200
+ if (changed.has('editable'))
201
+ this.grid.setStatic(!this.editable);
202
+ if (changed.has('disableAnimation'))
203
+ this.grid.setAnimation(!this.disableAnimation);
204
+ if (changed.has('maxRow')) {
205
+ // gridstack exposes no setter for this, and the engine keeps its own
206
+ // copy, so both have to be updated to take effect live.
207
+ this.grid.opts.maxRow = this.maxRow || undefined;
208
+ this.grid.engine.maxRow = this.maxRow || 0;
209
+ }
210
+ // These run after `editable` on purpose: setStatic() re-enables move and
211
+ // resize wholesale, so it would otherwise clobber the finer-grained flags.
212
+ if (changed.has('disableDrag') || changed.has('editable')) {
213
+ this.grid.enableMove(this.editable && !this.disableDrag);
214
+ }
215
+ if (changed.has('disableResize') || changed.has('editable')) {
216
+ this.grid.enableResize(this.editable && !this.disableResize);
217
+ }
218
+ }
219
+ if (changed.has('gridLineColor')) {
220
+ if (this.gridLineColor) {
221
+ this.gridEl.style.setProperty('--nile-dashboard-builder-grid-line', this.gridLineColor);
222
+ }
223
+ else {
224
+ this.gridEl.style.removeProperty('--nile-dashboard-builder-grid-line');
225
+ }
226
+ }
227
+ if (changed.has('config'))
228
+ void this.reconcile();
229
+ }
230
+ disconnectedCallback() {
231
+ super.disconnectedCallback();
232
+ this.grid?.destroy(false);
233
+ this.grid = undefined;
234
+ }
235
+ /**
236
+ * Applies the current `config` to the grid (add/remove/update items). When the
237
+ * change originated from a component method (`internalChange`), emits the
238
+ * resulting config *after* the grid is updated — this avoids a race where
239
+ * emitting before the grid mutation would discard the add/remove.
240
+ */
241
+ async reconcile() {
242
+ await this.updateComplete;
243
+ const grid = this.grid;
244
+ if (!grid)
245
+ return;
246
+ const widgets = this.normalizeWidgets(this.config);
247
+ const sig = this.signature(widgets);
248
+ if (sig === this.lastSig) {
249
+ this.internalChange = false;
250
+ return; // no change / our own echo
251
+ }
252
+ this.lastSig = sig;
253
+ const desiredIds = new Set(widgets.map((w) => w.id));
254
+ this.applying = true;
255
+ grid.batchUpdate(true);
256
+ try {
257
+ // Remove widgets that are gone.
258
+ for (const [id, el] of [...this.itemEls]) {
259
+ if (!desiredIds.has(id)) {
260
+ grid.removeWidget(el);
261
+ this.itemEls.delete(id);
262
+ this.widgetById.delete(id);
263
+ }
264
+ }
265
+ // Add new widgets / update existing ones in place.
266
+ for (const w of widgets) {
267
+ const id = w.id;
268
+ this.widgetById.set(id, w);
269
+ const existing = this.itemEls.get(id);
270
+ if (existing) {
271
+ grid.update(existing, {
272
+ x: w.layout.x,
273
+ y: w.layout.y,
274
+ w: w.layout.w,
275
+ h: w.layout.h,
276
+ minW: this.minW,
277
+ minH: this.minH,
278
+ });
279
+ const viewer = existing.querySelector('nile-widget-viewer');
280
+ if (viewer)
281
+ viewer.config = w;
282
+ }
283
+ else {
284
+ const el = this.createItem(w);
285
+ this.gridEl.appendChild(el);
286
+ grid.makeWidget(el, {
287
+ x: w.layout.x,
288
+ y: w.layout.y,
289
+ w: w.layout.w,
290
+ h: w.layout.h,
291
+ minW: this.minW,
292
+ minH: this.minH,
293
+ id,
294
+ });
295
+ this.itemEls.set(id, el);
296
+ }
297
+ }
298
+ }
299
+ finally {
300
+ grid.batchUpdate(false);
301
+ this.applying = false;
302
+ }
303
+ if (this.internalChange) {
304
+ this.internalChange = false;
305
+ this.emitFromGrid();
306
+ }
307
+ }
308
+ /** Builds a `.grid-stack-item` hosting the widget viewer plus a remove control. */
309
+ createItem(widget) {
310
+ const item = document.createElement('div');
311
+ item.className = 'grid-stack-item';
312
+ const content = document.createElement('div');
313
+ content.className = 'grid-stack-item-content';
314
+ item.appendChild(content);
315
+ const wrapper = document.createElement('div');
316
+ wrapper.className = 'nile-builder-cell';
317
+ content.appendChild(wrapper);
318
+ const viewer = document.createElement('nile-widget-viewer');
319
+ viewer.config = widget;
320
+ wrapper.appendChild(viewer);
321
+ const remove = document.createElement('button');
322
+ remove.className = 'nile-builder-remove';
323
+ remove.type = 'button';
324
+ remove.setAttribute('aria-label', 'Remove widget');
325
+ remove.title = 'Remove widget';
326
+ // The ✕ is the nile-glyph "close" icon (registered by the host app, as with
327
+ // the other nile-glyph usages in this package).
328
+ const removeIcon = document.createElement('nile-glyph');
329
+ removeIcon.setAttribute('name', 'close');
330
+ removeIcon.setAttribute('size', '16');
331
+ remove.appendChild(removeIcon);
332
+ remove.addEventListener('click', (e) => {
333
+ e.stopPropagation();
334
+ this.requestRemoveWidget(widget.id);
335
+ });
336
+ wrapper.appendChild(remove);
337
+ return item;
338
+ }
339
+ /** Adds a starter chart or KPI widget at the bottom of the grid. */
340
+ addWidget(type) {
341
+ const widgets = this.normalizeWidgets(this.config);
342
+ const maxY = widgets.reduce((m, w) => Math.max(m, w.layout.y + w.layout.h), 0);
343
+ const id = `nile-w-${++this.idCounter}`;
344
+ // The widget kind is carried by `nileConfig.chart.type` and inferred by the
345
+ // viewer (see `resolveWidgetKind`), so no top-level `type` is written here.
346
+ const widget = type === 'kpi'
347
+ ? {
348
+ id,
349
+ layout: { x: 0, y: maxY, w: 3, h: 2 },
350
+ nileConfig: { chart: { type: 'kpi', variant: 'card', label: 'New KPI', value: '0' } },
351
+ }
352
+ : {
353
+ id,
354
+ layout: { x: 0, y: maxY, w: 6, h: 3 },
355
+ nileConfig: {
356
+ chart: {
357
+ type: 'bar',
358
+ data: [{ name: 'Series 1', data: [5, 3, 8, 6] }],
359
+ categories: ['A', 'B', 'C', 'D'],
360
+ },
361
+ aq: { chartTitle: 'New chart' },
362
+ },
363
+ };
364
+ this.internalChange = true;
365
+ this.config = { ...(this.config ?? {}), widgets: [...widgets, widget] };
366
+ }
367
+ removeWidget(id) {
368
+ const widgets = this.normalizeWidgets(this.config).filter((w) => w.id !== id);
369
+ this.internalChange = true;
370
+ this.config = { ...(this.config ?? {}), widgets };
371
+ }
372
+ requestRemoveWidget(id) {
373
+ const widget = this.widgetById.get(id) ??
374
+ this.normalizeWidgets(this.config).find((w) => w.id === id) ??
375
+ null;
376
+ const ev = this.emit('nile-widget-remove', { id, widget }, undefined, undefined, true);
377
+ if (ev.defaultPrevented)
378
+ return false;
379
+ this.removeWidget(id);
380
+ return true;
381
+ }
382
+ /** Reads the true layout back from gridstack and emits the updated config. */
383
+ emitFromGrid() {
384
+ const grid = this.grid;
385
+ if (!grid)
386
+ return;
387
+ const layout = grid.save(false);
388
+ const widgets = [];
389
+ for (const node of layout) {
390
+ const base = this.widgetById.get(String(node.id));
391
+ if (!base)
392
+ continue;
393
+ widgets.push({
394
+ ...base,
395
+ id: String(node.id),
396
+ layout: { x: node.x ?? 0, y: node.y ?? 0, w: node.w ?? 1, h: node.h ?? 1 },
397
+ });
398
+ }
399
+ const config = { ...(this.config ?? {}), widgets };
400
+ this.lastSig = this.signature(widgets); // prevent this emit from re-applying
401
+ this.config = config;
402
+ this.emit('nile-dashboard-change', { config });
403
+ }
404
+ /** Ensures every widget has a stable id (assigned in place if missing). */
405
+ normalizeWidgets(cfg) {
406
+ const widgets = cfg?.widgets ?? [];
407
+ for (const w of widgets) {
408
+ if (!w.id)
409
+ w.id = `nile-w-${++this.idCounter}`;
410
+ }
411
+ return widgets;
412
+ }
413
+ /** Order-independent signature of the current layout + content. */
414
+ signature(widgets) {
415
+ return JSON.stringify([...widgets]
416
+ .sort((a, b) => a.id.localeCompare(b.id))
417
+ .map((w) => [
418
+ w.id,
419
+ resolveWidgetKind(w),
420
+ w.layout.x,
421
+ w.layout.y,
422
+ w.layout.w,
423
+ w.layout.h,
424
+ w.nileConfig,
425
+ ]));
426
+ }
427
+ render() {
428
+ return html `<div class="grid-stack"></div>`;
429
+ }
430
+ };
431
+ NileDashboardBuilder.styles = [gridstackCss, styles];
432
+ __decorate([
433
+ property({ type: Object })
434
+ ], NileDashboardBuilder.prototype, "config", void 0);
435
+ __decorate([
436
+ property({ type: Number })
437
+ ], NileDashboardBuilder.prototype, "columns", void 0);
438
+ __decorate([
439
+ property({ type: Number, attribute: 'cell-height' })
440
+ ], NileDashboardBuilder.prototype, "cellHeight", void 0);
441
+ __decorate([
442
+ property({ type: Number })
443
+ ], NileDashboardBuilder.prototype, "gap", void 0);
444
+ __decorate([
445
+ property({ type: Number, attribute: 'min-rows' })
446
+ ], NileDashboardBuilder.prototype, "minRows", void 0);
447
+ __decorate([
448
+ property({ type: Number, attribute: 'min-w' })
449
+ ], NileDashboardBuilder.prototype, "minW", void 0);
450
+ __decorate([
451
+ property({ type: Number, attribute: 'min-h' })
452
+ ], NileDashboardBuilder.prototype, "minH", void 0);
453
+ __decorate([
454
+ property({ attribute: 'resize-handles' })
455
+ ], NileDashboardBuilder.prototype, "resizeHandles", void 0);
456
+ __decorate([
457
+ property({ type: Boolean })
458
+ ], NileDashboardBuilder.prototype, "float", void 0);
459
+ __decorate([
460
+ property({ type: Boolean, reflect: true })
461
+ ], NileDashboardBuilder.prototype, "editable", void 0);
462
+ __decorate([
463
+ property({ type: Boolean, reflect: true })
464
+ ], NileDashboardBuilder.prototype, "gridLines", void 0);
465
+ __decorate([
466
+ property({ attribute: 'grid-line-color' })
467
+ ], NileDashboardBuilder.prototype, "gridLineColor", void 0);
468
+ __decorate([
469
+ property({ type: String, reflect: true, attribute: 'remove-visibility' })
470
+ ], NileDashboardBuilder.prototype, "removeVisibility", void 0);
471
+ __decorate([
472
+ property({ type: Number, attribute: 'max-row' })
473
+ ], NileDashboardBuilder.prototype, "maxRow", void 0);
474
+ __decorate([
475
+ property({ type: Object, attribute: 'column-opts' })
476
+ ], NileDashboardBuilder.prototype, "columnOpts", void 0);
477
+ __decorate([
478
+ property({ type: Boolean, attribute: 'lazy-load' })
479
+ ], NileDashboardBuilder.prototype, "lazyLoad", void 0);
480
+ __decorate([
481
+ property({ type: Boolean, attribute: 'disable-animation' })
482
+ ], NileDashboardBuilder.prototype, "disableAnimation", void 0);
483
+ __decorate([
484
+ property({ type: Boolean, attribute: 'disable-drag' })
485
+ ], NileDashboardBuilder.prototype, "disableDrag", void 0);
486
+ __decorate([
487
+ property({ type: Boolean, attribute: 'disable-resize' })
488
+ ], NileDashboardBuilder.prototype, "disableResize", void 0);
489
+ __decorate([
490
+ property({ type: Boolean, attribute: 'always-show-resize-handle' })
491
+ ], NileDashboardBuilder.prototype, "alwaysShowResizeHandle", void 0);
492
+ __decorate([
493
+ query('.grid-stack')
494
+ ], NileDashboardBuilder.prototype, "gridEl", void 0);
495
+ NileDashboardBuilder = __decorate([
496
+ customElement('nile-dashboard-builder')
497
+ ], NileDashboardBuilder);
498
+ export { NileDashboardBuilder };
499
+ //# sourceMappingURL=nile-dashboard-builder.js.map
@@ -25,6 +25,7 @@ export declare class NileDonutChart extends NileElement {
25
25
  /** Renders a 180° arc (semi-circle) suitable for KPI-style gauges. */
26
26
  semiCircle: boolean;
27
27
  options: Highcharts.Options;
28
+ noResponsive: boolean;
28
29
  loading: boolean;
29
30
  height: string;
30
31
  showDataLabels: boolean;