@smartnet360/svelte-components 0.0.19 → 0.0.20
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/core/Charts/editor/ChartLayoutEditor.svelte +8 -0
- package/dist/core/Charts/editor/ChartLayoutEditor.svelte.d.ts +5 -1
- package/dist/core/Charts/editor/KPIPicker.svelte +13 -3
- package/dist/core/Charts/editor/KPIPicker.svelte.d.ts +2 -0
- package/dist/core/Charts/editor/exampleKPIs.d.ts +38 -0
- package/dist/core/Charts/editor/exampleKPIs.js +66 -0
- package/dist/core/Charts/index.d.ts +1 -0
- package/dist/core/Charts/index.js +1 -0
- package/package.json +1 -1
@@ -6,6 +6,13 @@
|
|
6
6
|
import GridPreview from './GridPreview.svelte';
|
7
7
|
import PropertiesPanel from './PropertiesPanel.svelte';
|
8
8
|
import KPIPicker from './KPIPicker.svelte';
|
9
|
+
import type { KPI } from '../charts.model.js';
|
10
|
+
|
11
|
+
interface Props {
|
12
|
+
availableKPIs: KPI[];
|
13
|
+
}
|
14
|
+
|
15
|
+
let { availableKPIs }: Props = $props();
|
9
16
|
|
10
17
|
let showKPIPicker = $state(false);
|
11
18
|
let showLibrary = $state(false);
|
@@ -180,6 +187,7 @@
|
|
180
187
|
{#if showKPIPicker}
|
181
188
|
<KPIPicker
|
182
189
|
show={showKPIPicker}
|
190
|
+
{availableKPIs}
|
183
191
|
on:select={handleKPISelected}
|
184
192
|
on:close={() => { showKPIPicker = false; kpiPickerContext = null; }}
|
185
193
|
/>
|
@@ -1,3 +1,7 @@
|
|
1
|
-
|
1
|
+
import type { KPI } from '../charts.model.js';
|
2
|
+
interface Props {
|
3
|
+
availableKPIs: KPI[];
|
4
|
+
}
|
5
|
+
declare const ChartLayoutEditor: import("svelte").Component<Props, {}, "">;
|
2
6
|
type ChartLayoutEditor = ReturnType<typeof ChartLayoutEditor>;
|
3
7
|
export default ChartLayoutEditor;
|
@@ -2,22 +2,32 @@
|
|
2
2
|
|
3
3
|
<script lang="ts">
|
4
4
|
import { createEventDispatcher } from 'svelte';
|
5
|
-
import { availableKPIs, searchKPIs } from '../../../../routes/charts/schemas/available-kpis.js';
|
6
5
|
import type { KPI } from '../charts.model.js';
|
7
6
|
|
8
7
|
interface Props {
|
9
8
|
show: boolean;
|
9
|
+
availableKPIs: KPI[];
|
10
10
|
}
|
11
11
|
|
12
|
-
let { show }: Props = $props();
|
12
|
+
let { show, availableKPIs }: Props = $props();
|
13
13
|
|
14
14
|
const dispatch = createEventDispatcher();
|
15
15
|
|
16
16
|
let searchQuery = $state('');
|
17
17
|
let selectedKPI = $state<KPI | null>(null);
|
18
18
|
|
19
|
+
// Local search function
|
20
|
+
function searchKPIs(query: string, kpis: KPI[]): KPI[] {
|
21
|
+
const lowerQuery = query.toLowerCase();
|
22
|
+
return kpis.filter(
|
23
|
+
kpi =>
|
24
|
+
kpi.name.toLowerCase().includes(lowerQuery) ||
|
25
|
+
kpi.rawName.toLowerCase().includes(lowerQuery)
|
26
|
+
);
|
27
|
+
}
|
28
|
+
|
19
29
|
let filteredKPIs = $derived(
|
20
|
-
searchQuery ? searchKPIs(searchQuery) : availableKPIs
|
30
|
+
searchQuery ? searchKPIs(searchQuery, availableKPIs) : availableKPIs
|
21
31
|
);
|
22
32
|
|
23
33
|
function handleSelect(kpi: KPI) {
|
@@ -1,5 +1,7 @@
|
|
1
|
+
import type { KPI } from '../charts.model.js';
|
1
2
|
interface Props {
|
2
3
|
show: boolean;
|
4
|
+
availableKPIs: KPI[];
|
3
5
|
}
|
4
6
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
5
7
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* Example KPI Configuration
|
3
|
+
*
|
4
|
+
* This is a reference example showing the structure for availableKPIs.
|
5
|
+
* In your application, you should:
|
6
|
+
* 1. Load KPIs from your backend API
|
7
|
+
* 2. Store in a JSON file specific to your domain
|
8
|
+
* 3. Generate dynamically based on your data schema
|
9
|
+
*/
|
10
|
+
import type { KPI } from '../charts.model.js';
|
11
|
+
/**
|
12
|
+
* Example KPI list structure
|
13
|
+
* Each KPI must have: rawName, name, scale, unit, and optional color
|
14
|
+
*/
|
15
|
+
export declare const exampleKPIs: KPI[];
|
16
|
+
/**
|
17
|
+
* KPI Interface Reference:
|
18
|
+
*
|
19
|
+
* interface KPI {
|
20
|
+
* rawName: string; // Column name in your data source
|
21
|
+
* name: string; // Display name shown in UI
|
22
|
+
* scale: 'percent' | 'absolute'; // Data type
|
23
|
+
* unit: string; // Unit of measurement (%, GB, users, etc.)
|
24
|
+
* color?: string; // Optional hex color for chart line
|
25
|
+
* }
|
26
|
+
*/
|
27
|
+
/**
|
28
|
+
* Usage Example:
|
29
|
+
*
|
30
|
+
* <script>
|
31
|
+
* import { ChartLayoutEditor } from '..';
|
32
|
+
* import { exampleKPIs } from './exampleKPIs';
|
33
|
+
* // OR load from API:
|
34
|
+
* // const myKPIs = await fetch('/api/kpis').then(r => r.json());
|
35
|
+
* </script>
|
36
|
+
*
|
37
|
+
* <ChartLayoutEditor availableKPIs={exampleKPIs} />
|
38
|
+
*/
|
@@ -0,0 +1,66 @@
|
|
1
|
+
/**
|
2
|
+
* Example KPI Configuration
|
3
|
+
*
|
4
|
+
* This is a reference example showing the structure for availableKPIs.
|
5
|
+
* In your application, you should:
|
6
|
+
* 1. Load KPIs from your backend API
|
7
|
+
* 2. Store in a JSON file specific to your domain
|
8
|
+
* 3. Generate dynamically based on your data schema
|
9
|
+
*/
|
10
|
+
/**
|
11
|
+
* Example KPI list structure
|
12
|
+
* Each KPI must have: rawName, name, scale, unit, and optional color
|
13
|
+
*/
|
14
|
+
export const exampleKPIs = [
|
15
|
+
{
|
16
|
+
rawName: 'CCSR_PC',
|
17
|
+
name: 'CCSR Success Rate',
|
18
|
+
scale: 'percent',
|
19
|
+
unit: '%',
|
20
|
+
color: '#2ca02c' // Optional: hex color for the trace
|
21
|
+
},
|
22
|
+
{
|
23
|
+
rawName: 'DL_GBYTES',
|
24
|
+
name: 'Downlink Traffic',
|
25
|
+
scale: 'absolute',
|
26
|
+
unit: 'GB',
|
27
|
+
color: '#06B6D4'
|
28
|
+
},
|
29
|
+
{
|
30
|
+
rawName: 'UL_GBYTES',
|
31
|
+
name: 'Uplink Traffic',
|
32
|
+
scale: 'absolute',
|
33
|
+
unit: 'GB',
|
34
|
+
color: '#84CC16'
|
35
|
+
},
|
36
|
+
{
|
37
|
+
rawName: 'AVG_USERS',
|
38
|
+
name: 'Average Connected Users',
|
39
|
+
scale: 'absolute',
|
40
|
+
unit: 'users',
|
41
|
+
color: '#EF4444'
|
42
|
+
}
|
43
|
+
];
|
44
|
+
/**
|
45
|
+
* KPI Interface Reference:
|
46
|
+
*
|
47
|
+
* interface KPI {
|
48
|
+
* rawName: string; // Column name in your data source
|
49
|
+
* name: string; // Display name shown in UI
|
50
|
+
* scale: 'percent' | 'absolute'; // Data type
|
51
|
+
* unit: string; // Unit of measurement (%, GB, users, etc.)
|
52
|
+
* color?: string; // Optional hex color for chart line
|
53
|
+
* }
|
54
|
+
*/
|
55
|
+
/**
|
56
|
+
* Usage Example:
|
57
|
+
*
|
58
|
+
* <script>
|
59
|
+
* import { ChartLayoutEditor } from '..';
|
60
|
+
* import { exampleKPIs } from './exampleKPIs';
|
61
|
+
* // OR load from API:
|
62
|
+
* // const myKPIs = await fetch('/api/kpis').then(r => r.json());
|
63
|
+
* </script>
|
64
|
+
*
|
65
|
+
* <ChartLayoutEditor availableKPIs={exampleKPIs} />
|
66
|
+
*/
|
@@ -7,3 +7,4 @@ export type { ContainerSize, ChartInfo, AdaptationConfig } from './adapt.js';
|
|
7
7
|
export { default as ChartLayoutEditor } from './editor/ChartLayoutEditor.svelte';
|
8
8
|
export { editorStore, currentLayout, savedLayouts, selection, isDirty, selectedItem } from './editor/editorState.js';
|
9
9
|
export type { Selection, SelectionType, EditorState } from './editor/editorState.js';
|
10
|
+
export { exampleKPIs } from './editor/exampleKPIs.js';
|
@@ -5,3 +5,4 @@ export { adaptPlotlyLayout, getSizeCategory, createMarkerShapes, createMarkerAnn
|
|
5
5
|
// Editor exports
|
6
6
|
export { default as ChartLayoutEditor } from './editor/ChartLayoutEditor.svelte';
|
7
7
|
export { editorStore, currentLayout, savedLayouts, selection, isDirty, selectedItem } from './editor/editorState.js';
|
8
|
+
export { exampleKPIs } from './editor/exampleKPIs.js';
|