@smartnet360/svelte-components 0.0.49 → 0.0.51
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/dist/apps/site-check/SiteCheck.svelte +7 -1
- package/dist/apps/site-check/SiteCheck.svelte.d.ts +1 -0
- package/dist/apps/site-check/helper.js +6 -2
- package/dist/core/Charts/ChartComponent.svelte +3 -1
- package/dist/core/Charts/ChartComponent.svelte.d.ts +1 -0
- package/dist/core/Charts/GlobalControls.svelte +63 -16
- package/dist/core/Charts/GlobalControls.svelte.d.ts +1 -0
- package/dist/core/Charts/data-utils.js +8 -1
- package/package.json +1 -1
|
@@ -22,9 +22,13 @@
|
|
|
22
22
|
showGroupingSelector?: boolean; // Show/hide the grouping dropdown (default: true)
|
|
23
23
|
onSearch?: (searchTerm: string) => void; // Optional: Search callback (if provided, shows search box)
|
|
24
24
|
searchPlaceholder?: string; // Optional: Search box placeholder text (default: "Search...")
|
|
25
|
+
plotlyLayout?: Record<string, any>; // Optional Plotly layout configuration
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
let { rawData, multiCellLayout, singleLteLayout,
|
|
28
|
+
let { rawData, multiCellLayout, singleLteLayout,
|
|
29
|
+
singleNrLayout, baseMetrics, mode = "scrollspy", markers = [],
|
|
30
|
+
cellStyling = defaultCellStyling, initialGrouping = defaultTreeGrouping,
|
|
31
|
+
showGroupingSelector = true, onSearch, searchPlaceholder = "Search...", plotlyLayout }: Props = $props();
|
|
28
32
|
|
|
29
33
|
// Search state
|
|
30
34
|
let searchTerm = $state('');
|
|
@@ -319,6 +323,8 @@
|
|
|
319
323
|
markers={markers}
|
|
320
324
|
showGlobalControls={true}
|
|
321
325
|
enableAdaptation={true}
|
|
326
|
+
plotlyLayout={plotlyLayout}
|
|
327
|
+
persistSettings={true}
|
|
322
328
|
/>
|
|
323
329
|
{:else}
|
|
324
330
|
<div class="d-flex align-items-center justify-content-center h-100">
|
|
@@ -14,6 +14,7 @@ interface Props {
|
|
|
14
14
|
showGroupingSelector?: boolean;
|
|
15
15
|
onSearch?: (searchTerm: string) => void;
|
|
16
16
|
searchPlaceholder?: string;
|
|
17
|
+
plotlyLayout?: Record<string, any>;
|
|
17
18
|
}
|
|
18
19
|
declare const SiteCheck: import("svelte").Component<Props, {}, "">;
|
|
19
20
|
type SiteCheck = ReturnType<typeof SiteCheck>;
|
|
@@ -63,14 +63,18 @@ function expandKPIs(baseKPIs, cells, stylingConfig, stackGroupMode = 'none') {
|
|
|
63
63
|
if (stylingConfig) {
|
|
64
64
|
// Apply custom styling (band colors, sector line styles)
|
|
65
65
|
const styledKPI = createStyledKPI(baseKPI.rawName, record, baseKPI.unit, stylingConfig);
|
|
66
|
-
expandedKPIs.push(
|
|
66
|
+
expandedKPIs.push({
|
|
67
|
+
...styledKPI,
|
|
68
|
+
stackGroup: undefined // Initialize for treeshake-safe property assignment
|
|
69
|
+
});
|
|
67
70
|
}
|
|
68
71
|
else {
|
|
69
72
|
// Use Chart component default behavior: keep base KPI name
|
|
70
73
|
// Just update rawName to reference the pivoted column
|
|
71
74
|
expandedKPIs.push({
|
|
72
75
|
...baseKPI,
|
|
73
|
-
rawName: `${baseKPI.rawName}_${cellName}
|
|
76
|
+
rawName: `${baseKPI.rawName}_${cellName}`,
|
|
77
|
+
stackGroup: undefined // Initialize for treeshake-safe property assignment
|
|
74
78
|
});
|
|
75
79
|
}
|
|
76
80
|
});
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
plotlyLayout?: any; // Optional custom Plotly layout
|
|
17
17
|
enableAdaptation?: boolean; // Enable size-based adaptations
|
|
18
18
|
showGlobalControls?: boolean; // Show/hide global controls section (default: true)
|
|
19
|
+
persistSettings?: boolean; // Enable localStorage persistence for global controls (default: false)
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const GRID_DIMENSIONS: Record<ChartGrid, { rows: number; columns: number }> = {
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
section: Section;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
let { layout, data, mode, markers, plotlyLayout, enableAdaptation = true, showGlobalControls = true }: Props = $props();
|
|
58
|
+
let { layout, data, mode, markers, plotlyLayout, enableAdaptation = true, showGlobalControls = true, persistSettings = false }: Props = $props();
|
|
58
59
|
|
|
59
60
|
// Log component initialization
|
|
60
61
|
$effect(() => {
|
|
@@ -353,6 +354,7 @@
|
|
|
353
354
|
onUpdate={handleControlsUpdate}
|
|
354
355
|
isExpanded={showControlsPanel}
|
|
355
356
|
onToggle={() => showControlsPanel = !showControlsPanel}
|
|
357
|
+
persistSettings={persistSettings}
|
|
356
358
|
/>
|
|
357
359
|
{/if}
|
|
358
360
|
|
|
@@ -7,6 +7,7 @@ interface Props {
|
|
|
7
7
|
plotlyLayout?: any;
|
|
8
8
|
enableAdaptation?: boolean;
|
|
9
9
|
showGlobalControls?: boolean;
|
|
10
|
+
persistSettings?: boolean;
|
|
10
11
|
}
|
|
11
12
|
declare const ChartComponent: import("svelte").Component<Props, {}, "">;
|
|
12
13
|
type ChartComponent = ReturnType<typeof ChartComponent>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<svelte:options runes={true} />
|
|
2
2
|
|
|
3
3
|
<script lang="ts">
|
|
4
|
+
import { onMount } from 'svelte';
|
|
4
5
|
import type { GlobalChartControls, HoverMode } from './charts.model.js';
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
@@ -8,55 +9,98 @@
|
|
|
8
9
|
onUpdate: (controls: GlobalChartControls) => void;
|
|
9
10
|
isExpanded?: boolean;
|
|
10
11
|
onToggle?: () => void;
|
|
12
|
+
persistSettings?: boolean; // Optional: enable localStorage persistence
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
let { controls, onUpdate, isExpanded = false, onToggle }: Props = $props();
|
|
15
|
+
let { controls, onUpdate, isExpanded = false, onToggle, persistSettings = false }: Props = $props();
|
|
16
|
+
|
|
17
|
+
const STORAGE_KEY = 'chart-global-controls';
|
|
18
|
+
|
|
19
|
+
// Load saved settings on mount
|
|
20
|
+
onMount(() => {
|
|
21
|
+
if (persistSettings && typeof window !== 'undefined') {
|
|
22
|
+
try {
|
|
23
|
+
const saved = localStorage.getItem(STORAGE_KEY);
|
|
24
|
+
if (saved) {
|
|
25
|
+
const savedControls = JSON.parse(saved) as GlobalChartControls;
|
|
26
|
+
onUpdate(savedControls);
|
|
27
|
+
}
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.warn('Failed to load chart controls from localStorage:', error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Save settings to localStorage
|
|
35
|
+
function saveSettings(updatedControls: GlobalChartControls) {
|
|
36
|
+
if (persistSettings && typeof window !== 'undefined') {
|
|
37
|
+
try {
|
|
38
|
+
console.log('💾 Saving chart controls to localStorage:', updatedControls);
|
|
39
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(updatedControls));
|
|
40
|
+
console.log('✅ Saved successfully');
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.warn('Failed to save chart controls to localStorage:', error);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
console.log('⚠️ Not saving: persistSettings =', persistSettings);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
14
48
|
|
|
15
49
|
function updateControls(updates: Partial<GlobalChartControls>) {
|
|
16
|
-
|
|
50
|
+
const newControls = {
|
|
17
51
|
...controls,
|
|
18
52
|
...updates
|
|
19
|
-
}
|
|
53
|
+
};
|
|
54
|
+
onUpdate(newControls);
|
|
55
|
+
saveSettings(newControls);
|
|
20
56
|
}
|
|
21
57
|
|
|
22
58
|
function updateMovingAverage(updates: Partial<NonNullable<GlobalChartControls['movingAverage']>>) {
|
|
23
|
-
|
|
59
|
+
const newControls = {
|
|
24
60
|
...controls,
|
|
25
61
|
movingAverage: {
|
|
26
62
|
...controls.movingAverage!,
|
|
27
63
|
...updates
|
|
28
64
|
}
|
|
29
|
-
}
|
|
65
|
+
};
|
|
66
|
+
onUpdate(newControls);
|
|
67
|
+
saveSettings(newControls);
|
|
30
68
|
}
|
|
31
69
|
|
|
32
70
|
function updateMarkers(updates: Partial<NonNullable<GlobalChartControls['markers']>>) {
|
|
33
|
-
|
|
71
|
+
const newControls = {
|
|
34
72
|
...controls,
|
|
35
73
|
markers: {
|
|
36
74
|
...controls.markers!,
|
|
37
75
|
...updates
|
|
38
76
|
}
|
|
39
|
-
}
|
|
77
|
+
};
|
|
78
|
+
onUpdate(newControls);
|
|
79
|
+
saveSettings(newControls);
|
|
40
80
|
}
|
|
41
81
|
|
|
42
82
|
function updateLegend(updates: Partial<NonNullable<GlobalChartControls['legend']>>) {
|
|
43
|
-
|
|
83
|
+
const newControls = {
|
|
44
84
|
...controls,
|
|
45
85
|
legend: {
|
|
46
86
|
...controls.legend!,
|
|
47
87
|
...updates
|
|
48
88
|
}
|
|
49
|
-
}
|
|
89
|
+
};
|
|
90
|
+
onUpdate(newControls);
|
|
91
|
+
saveSettings(newControls);
|
|
50
92
|
}
|
|
51
93
|
|
|
52
94
|
function updateHoverMode(updates: Partial<NonNullable<GlobalChartControls['hoverMode']>>) {
|
|
53
|
-
|
|
95
|
+
const newControls = {
|
|
54
96
|
...controls,
|
|
55
97
|
hoverMode: {
|
|
56
98
|
...controls.hoverMode!,
|
|
57
99
|
...updates
|
|
58
100
|
}
|
|
59
|
-
}
|
|
101
|
+
};
|
|
102
|
+
onUpdate(newControls);
|
|
103
|
+
saveSettings(newControls);
|
|
60
104
|
}
|
|
61
105
|
</script>
|
|
62
106
|
|
|
@@ -435,17 +479,20 @@
|
|
|
435
479
|
}
|
|
436
480
|
|
|
437
481
|
.floating-controls-panel :global(.btn-outline-primary) {
|
|
438
|
-
|
|
482
|
+
color: var(--bs-primary, #0d6efd);
|
|
483
|
+
border-color: color-mix(in srgb, var(--bs-primary, #0d6efd) 30%, transparent);
|
|
439
484
|
}
|
|
440
485
|
|
|
441
486
|
.floating-controls-panel :global(.btn-outline-primary:hover) {
|
|
442
|
-
|
|
443
|
-
|
|
487
|
+
color: var(--bs-btn-hover-color, #fff);
|
|
488
|
+
background-color: color-mix(in srgb, var(--bs-primary, #0d6efd) 10%, transparent);
|
|
489
|
+
border-color: color-mix(in srgb, var(--bs-primary, #0d6efd) 50%, transparent);
|
|
444
490
|
}
|
|
445
491
|
|
|
446
492
|
.floating-controls-panel :global(.btn-check:checked + .btn-outline-primary) {
|
|
447
|
-
|
|
448
|
-
|
|
493
|
+
color: var(--bs-btn-active-color, #fff);
|
|
494
|
+
background-color: var(--bs-primary, #0d6efd);
|
|
495
|
+
border-color: var(--bs-primary, #0d6efd);
|
|
449
496
|
}
|
|
450
497
|
|
|
451
498
|
.floating-controls-panel :global(.btn-group) {
|
|
@@ -4,6 +4,7 @@ interface Props {
|
|
|
4
4
|
onUpdate: (controls: GlobalChartControls) => void;
|
|
5
5
|
isExpanded?: boolean;
|
|
6
6
|
onToggle?: () => void;
|
|
7
|
+
persistSettings?: boolean;
|
|
7
8
|
}
|
|
8
9
|
declare const GlobalControls: import("svelte").Component<Props, {}, "">;
|
|
9
10
|
type GlobalControls = ReturnType<typeof GlobalControls>;
|
|
@@ -302,7 +302,14 @@ export function createDefaultPlotlyLayout(title, hoverMode, coloredHover = true)
|
|
|
302
302
|
showgrid: true,
|
|
303
303
|
gridcolor: '#ecf0f1',
|
|
304
304
|
linecolor: '#bdc3c7',
|
|
305
|
-
tickfont: { size: 11 }
|
|
305
|
+
tickfont: { size: 11 },
|
|
306
|
+
// Show Y-axis marker with line when in 'closest' hover mode
|
|
307
|
+
// showspikes: hoverMode === 'closest',
|
|
308
|
+
// spikemode: 'marker', // Line to axis + triangle marker
|
|
309
|
+
// spikesnap: 'cursor', // Snap to cursor position
|
|
310
|
+
// spikethickness: 1, // Line thickness
|
|
311
|
+
// spikecolor: '#000000ff', // Primary blue color
|
|
312
|
+
// spikedash: 'dot' // Dotted line
|
|
306
313
|
},
|
|
307
314
|
margin: { l: 60, r: 60, t: 60, b: 50 },
|
|
308
315
|
paper_bgcolor: 'rgba(0,0,0,0)',
|