@smartnet360/svelte-components 0.0.40 → 0.0.42
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/antenna-pattern/components/AntennaDiagrams.svelte +0 -5
- package/dist/apps/antenna-pattern/components/DbNotification.svelte +1 -1
- package/dist/apps/antenna-pattern/components/chart-engines/PolarBarChart.svelte +2 -0
- package/dist/apps/antenna-pattern/components/chart-engines/PolarBarChart.svelte.d.ts +1 -0
- package/dist/apps/site-check/helper.js +3 -0
- package/dist/core/Charts/ChartCard.svelte +9 -12
- package/dist/core/Charts/ChartCard.svelte.d.ts +5 -21
- package/dist/core/Charts/ChartComponent.svelte +2 -2
- package/dist/core/Charts/editor/ChartLayoutEditor.svelte +8 -8
- package/dist/core/Charts/editor/GridPreview.svelte +0 -3
- package/dist/core/Charts/editor/KPIPicker.svelte +6 -7
- package/dist/core/Charts/editor/KPIPicker.svelte.d.ts +4 -20
- package/dist/core/Charts/editor/PropertiesPanel.svelte +6 -3
- package/dist/core/Charts/editor/PropertiesPanel.svelte.d.ts +8 -18
- package/dist/core/Map/Map.svelte +312 -0
- package/dist/core/Map/Map.svelte.d.ts +230 -0
- package/dist/core/Map/index.d.ts +9 -0
- package/dist/core/Map/index.js +9 -0
- package/dist/core/Map/mapSettings.d.ts +147 -0
- package/dist/core/Map/mapSettings.js +226 -0
- package/dist/core/Map/mapStore.d.ts +73 -0
- package/dist/core/Map/mapStore.js +136 -0
- package/dist/core/Map/types.d.ts +72 -0
- package/dist/core/Map/types.js +32 -0
- package/dist/core/Settings/FieldRenderer.svelte +19 -15
- package/dist/core/Settings/FieldRenderer.svelte.d.ts +12 -25
- package/dist/core/Settings/Settings.svelte +48 -29
- package/dist/core/Settings/Settings.svelte.d.ts +26 -20
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +2 -0
- package/package.json +12 -9
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map Store
|
|
3
|
+
*
|
|
4
|
+
* Centralized store for map instance and state management.
|
|
5
|
+
* Allows components to access map instance and react to state changes.
|
|
6
|
+
*/
|
|
7
|
+
import { writable, derived, get } from 'svelte/store';
|
|
8
|
+
/**
|
|
9
|
+
* Create a map store instance
|
|
10
|
+
* Each map component should create its own store instance
|
|
11
|
+
*/
|
|
12
|
+
export function createMapStore() {
|
|
13
|
+
const initialState = {
|
|
14
|
+
map: null,
|
|
15
|
+
overlay: null,
|
|
16
|
+
layers: [],
|
|
17
|
+
isLoaded: false,
|
|
18
|
+
center: [-74.5, 40],
|
|
19
|
+
zoom: 9,
|
|
20
|
+
pitch: 0,
|
|
21
|
+
bearing: 0
|
|
22
|
+
};
|
|
23
|
+
const store = writable(initialState);
|
|
24
|
+
return {
|
|
25
|
+
subscribe: store.subscribe,
|
|
26
|
+
/**
|
|
27
|
+
* Set the map instance after initialization
|
|
28
|
+
*/
|
|
29
|
+
setMap(map) {
|
|
30
|
+
store.update(state => ({ ...state, map }));
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Set the Deck.GL overlay instance
|
|
34
|
+
*/
|
|
35
|
+
setOverlay(overlay) {
|
|
36
|
+
store.update(state => ({ ...state, overlay }));
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Update Deck.GL layers
|
|
40
|
+
*/
|
|
41
|
+
setLayers(layers) {
|
|
42
|
+
const state = get(store);
|
|
43
|
+
if (state.overlay) {
|
|
44
|
+
state.overlay.setProps({ layers });
|
|
45
|
+
}
|
|
46
|
+
store.update(s => ({ ...s, layers }));
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Add a layer to the existing layers
|
|
50
|
+
*/
|
|
51
|
+
addLayer(layer) {
|
|
52
|
+
const state = get(store);
|
|
53
|
+
const newLayers = [...state.layers, layer];
|
|
54
|
+
if (state.overlay) {
|
|
55
|
+
state.overlay.setProps({ layers: newLayers });
|
|
56
|
+
}
|
|
57
|
+
store.update(s => ({ ...s, layers: newLayers }));
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Remove a layer by id
|
|
61
|
+
*/
|
|
62
|
+
removeLayer(layerId) {
|
|
63
|
+
const state = get(store);
|
|
64
|
+
const newLayers = state.layers.filter(l => l.id !== layerId);
|
|
65
|
+
if (state.overlay) {
|
|
66
|
+
state.overlay.setProps({ layers: newLayers });
|
|
67
|
+
}
|
|
68
|
+
store.update(s => ({ ...s, layers: newLayers }));
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Mark map as loaded
|
|
72
|
+
*/
|
|
73
|
+
setLoaded(isLoaded) {
|
|
74
|
+
store.update(state => ({ ...state, isLoaded }));
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* Update map view state
|
|
78
|
+
*/
|
|
79
|
+
updateViewState(updates) {
|
|
80
|
+
store.update(state => ({ ...state, ...updates }));
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Fly to a location
|
|
84
|
+
*/
|
|
85
|
+
flyTo(center, zoom, options) {
|
|
86
|
+
const state = get(store);
|
|
87
|
+
if (state.map) {
|
|
88
|
+
state.map.flyTo({
|
|
89
|
+
center,
|
|
90
|
+
zoom: zoom ?? state.zoom,
|
|
91
|
+
duration: options?.duration ?? 1000
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* Fit map to bounds
|
|
97
|
+
*/
|
|
98
|
+
fitBounds(bounds, padding) {
|
|
99
|
+
const state = get(store);
|
|
100
|
+
if (state.map) {
|
|
101
|
+
state.map.fitBounds(bounds, {
|
|
102
|
+
padding: padding ?? 50,
|
|
103
|
+
duration: 1000
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* Reset to initial state
|
|
109
|
+
*/
|
|
110
|
+
reset() {
|
|
111
|
+
store.set(initialState);
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* Clean up map resources
|
|
115
|
+
*/
|
|
116
|
+
destroy() {
|
|
117
|
+
const state = get(store);
|
|
118
|
+
if (state.map) {
|
|
119
|
+
state.map.remove();
|
|
120
|
+
}
|
|
121
|
+
this.reset();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Derived store: Check if map is ready to use
|
|
127
|
+
*/
|
|
128
|
+
export function isMapReady(mapStore) {
|
|
129
|
+
return derived(mapStore, $store => $store.map !== null && $store.overlay !== null && $store.isLoaded);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Derived store: Get current map instance (null-safe)
|
|
133
|
+
*/
|
|
134
|
+
export function getMapInstance(mapStore) {
|
|
135
|
+
return derived(mapStore, $store => $store.map);
|
|
136
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map Component Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines types for Mapbox GL + Deck.GL integration
|
|
5
|
+
*/
|
|
6
|
+
import type { Map as MapboxMap } from 'mapbox-gl';
|
|
7
|
+
import type { MapboxOverlay } from '@deck.gl/mapbox';
|
|
8
|
+
import type { Layer } from '@deck.gl/core';
|
|
9
|
+
/**
|
|
10
|
+
* Map initialization options
|
|
11
|
+
*/
|
|
12
|
+
export interface MapOptions {
|
|
13
|
+
/** Mapbox access token (required) */
|
|
14
|
+
accessToken: string;
|
|
15
|
+
/** Initial map style */
|
|
16
|
+
style?: string;
|
|
17
|
+
/** Initial center coordinates [lng, lat] */
|
|
18
|
+
center?: [number, number];
|
|
19
|
+
/** Initial zoom level */
|
|
20
|
+
zoom?: number;
|
|
21
|
+
/** Initial pitch (tilt) in degrees */
|
|
22
|
+
pitch?: number;
|
|
23
|
+
/** Initial bearing (rotation) in degrees */
|
|
24
|
+
bearing?: number;
|
|
25
|
+
/** Minimum zoom level */
|
|
26
|
+
minZoom?: number;
|
|
27
|
+
/** Maximum zoom level */
|
|
28
|
+
maxZoom?: number;
|
|
29
|
+
/** Whether to show navigation controls */
|
|
30
|
+
showControls?: boolean;
|
|
31
|
+
/** Whether to show scale control */
|
|
32
|
+
showScale?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Map state (stored in mapStore)
|
|
36
|
+
*/
|
|
37
|
+
export interface MapState {
|
|
38
|
+
/** The Mapbox GL instance */
|
|
39
|
+
map: MapboxMap | null;
|
|
40
|
+
/** The Deck.GL overlay instance */
|
|
41
|
+
overlay: MapboxOverlay | null;
|
|
42
|
+
/** Current Deck.GL layers */
|
|
43
|
+
layers: Layer[];
|
|
44
|
+
/** Whether the map is loaded and ready */
|
|
45
|
+
isLoaded: boolean;
|
|
46
|
+
/** Current map center */
|
|
47
|
+
center: [number, number];
|
|
48
|
+
/** Current zoom level */
|
|
49
|
+
zoom: number;
|
|
50
|
+
/** Current pitch */
|
|
51
|
+
pitch: number;
|
|
52
|
+
/** Current bearing */
|
|
53
|
+
bearing: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Map style presets
|
|
57
|
+
*/
|
|
58
|
+
export declare const MAP_STYLES: {
|
|
59
|
+
readonly streets: "mapbox://styles/mapbox/streets-v12";
|
|
60
|
+
readonly satellite: "mapbox://styles/mapbox/satellite-v9";
|
|
61
|
+
readonly satelliteStreets: "mapbox://styles/mapbox/satellite-streets-v12";
|
|
62
|
+
readonly light: "mapbox://styles/mapbox/light-v11";
|
|
63
|
+
readonly dark: "mapbox://styles/mapbox/dark-v11";
|
|
64
|
+
readonly outdoors: "mapbox://styles/mapbox/outdoors-v12";
|
|
65
|
+
readonly navigationDay: "mapbox://styles/mapbox/navigation-day-v1";
|
|
66
|
+
readonly navigationNight: "mapbox://styles/mapbox/navigation-night-v1";
|
|
67
|
+
};
|
|
68
|
+
export type MapStyleName = keyof typeof MAP_STYLES;
|
|
69
|
+
/**
|
|
70
|
+
* Default map options
|
|
71
|
+
*/
|
|
72
|
+
export declare const DEFAULT_MAP_OPTIONS: Partial<MapOptions>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map Component Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines types for Mapbox GL + Deck.GL integration
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Map style presets
|
|
8
|
+
*/
|
|
9
|
+
export const MAP_STYLES = {
|
|
10
|
+
streets: 'mapbox://styles/mapbox/streets-v12',
|
|
11
|
+
satellite: 'mapbox://styles/mapbox/satellite-v9',
|
|
12
|
+
satelliteStreets: 'mapbox://styles/mapbox/satellite-streets-v12',
|
|
13
|
+
light: 'mapbox://styles/mapbox/light-v11',
|
|
14
|
+
dark: 'mapbox://styles/mapbox/dark-v11',
|
|
15
|
+
outdoors: 'mapbox://styles/mapbox/outdoors-v12',
|
|
16
|
+
navigationDay: 'mapbox://styles/mapbox/navigation-day-v1',
|
|
17
|
+
navigationNight: 'mapbox://styles/mapbox/navigation-night-v1'
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Default map options
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_MAP_OPTIONS = {
|
|
23
|
+
style: MAP_STYLES.streets,
|
|
24
|
+
center: [-74.5, 40],
|
|
25
|
+
zoom: 9,
|
|
26
|
+
pitch: 0,
|
|
27
|
+
bearing: 0,
|
|
28
|
+
minZoom: 0,
|
|
29
|
+
maxZoom: 22,
|
|
30
|
+
showControls: true,
|
|
31
|
+
showScale: true
|
|
32
|
+
};
|
|
@@ -9,10 +9,14 @@
|
|
|
9
9
|
* Works with hierarchical store structure.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
interface Props {
|
|
13
|
+
field: FieldDefinition;
|
|
14
|
+
segmentId: string;
|
|
15
|
+
store: any; // The hierarchical settings store
|
|
16
|
+
value: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let { field, segmentId, store, value }: Props = $props();
|
|
16
20
|
|
|
17
21
|
// Generate unique ID for form elements
|
|
18
22
|
const inputId = `field-${segmentId}-${field.id}`;
|
|
@@ -32,7 +36,7 @@
|
|
|
32
36
|
class="form-check-input"
|
|
33
37
|
checked={value}
|
|
34
38
|
disabled={field.disabled}
|
|
35
|
-
|
|
39
|
+
onchange={(e) => handleChange(e.currentTarget.checked)}
|
|
36
40
|
/>
|
|
37
41
|
<label class="form-check-label" for={inputId}>
|
|
38
42
|
{field.label}
|
|
@@ -57,7 +61,7 @@
|
|
|
57
61
|
maxlength={field.maxLength}
|
|
58
62
|
pattern={field.pattern}
|
|
59
63
|
disabled={field.disabled}
|
|
60
|
-
|
|
64
|
+
oninput={(e) => handleChange(e.currentTarget.value)}
|
|
61
65
|
/>
|
|
62
66
|
{#if field.description}
|
|
63
67
|
<div class="form-text">{field.description}</div>
|
|
@@ -79,7 +83,7 @@
|
|
|
79
83
|
max={field.max}
|
|
80
84
|
step={field.step}
|
|
81
85
|
disabled={field.disabled}
|
|
82
|
-
|
|
86
|
+
oninput={(e) => handleChange(parseFloat(e.currentTarget.value))}
|
|
83
87
|
/>
|
|
84
88
|
{#if field.unit}
|
|
85
89
|
<span class="input-group-text">{field.unit}</span>
|
|
@@ -107,7 +111,7 @@
|
|
|
107
111
|
max={field.max}
|
|
108
112
|
step={field.step || 1}
|
|
109
113
|
disabled={field.disabled}
|
|
110
|
-
|
|
114
|
+
oninput={(e) => handleChange(parseFloat(e.currentTarget.value))}
|
|
111
115
|
/>
|
|
112
116
|
{#if field.description}
|
|
113
117
|
<div class="form-text">{field.description}</div>
|
|
@@ -126,14 +130,14 @@
|
|
|
126
130
|
class="form-control form-control-color"
|
|
127
131
|
value={value}
|
|
128
132
|
disabled={field.disabled}
|
|
129
|
-
|
|
133
|
+
oninput={(e) => handleChange(e.currentTarget.value)}
|
|
130
134
|
/>
|
|
131
135
|
<input
|
|
132
136
|
type="text"
|
|
133
137
|
class="form-control"
|
|
134
138
|
value={value}
|
|
135
139
|
disabled={field.disabled}
|
|
136
|
-
|
|
140
|
+
oninput={(e) => handleChange(e.currentTarget.value)}
|
|
137
141
|
/>
|
|
138
142
|
</div>
|
|
139
143
|
{#if field.description}
|
|
@@ -151,7 +155,7 @@
|
|
|
151
155
|
class="form-select"
|
|
152
156
|
value={value}
|
|
153
157
|
disabled={field.disabled}
|
|
154
|
-
|
|
158
|
+
onchange={(e) => handleChange(e.currentTarget.value)}
|
|
155
159
|
>
|
|
156
160
|
{#each field.options as option}
|
|
157
161
|
<option value={option.value}>
|
|
@@ -179,7 +183,7 @@
|
|
|
179
183
|
value={option.value}
|
|
180
184
|
checked={value === option.value}
|
|
181
185
|
disabled={field.disabled}
|
|
182
|
-
|
|
186
|
+
onchange={() => handleChange(option.value)}
|
|
183
187
|
/>
|
|
184
188
|
<label class="form-check-label" for={`${inputId}-${index}`}>
|
|
185
189
|
{option.label}
|
|
@@ -199,11 +203,11 @@
|
|
|
199
203
|
<span class="text-muted" title={field.tooltip}>ⓘ</span>
|
|
200
204
|
{/if}
|
|
201
205
|
</label>
|
|
202
|
-
|
|
203
|
-
|
|
206
|
+
{@const Component = field.component}
|
|
207
|
+
<Component
|
|
204
208
|
{value}
|
|
205
209
|
disabled={field.disabled}
|
|
206
|
-
|
|
210
|
+
onchange={(e: CustomEvent) => handleChange(e.detail)}
|
|
207
211
|
{...field.componentProps}
|
|
208
212
|
/>
|
|
209
213
|
{#if field.description}
|
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
import type { FieldDefinition } from './types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
$on?: any;
|
|
12
|
-
};
|
|
13
|
-
z_$$bindings?: Bindings;
|
|
14
|
-
}
|
|
15
|
-
declare const FieldRenderer: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
-
/**
|
|
17
|
-
* Generic Field Renderer
|
|
18
|
-
*
|
|
19
|
-
* Renders a form field based on its type definition.
|
|
20
|
-
* Uses Bootstrap form components for styling.
|
|
21
|
-
* Works with hierarchical store structure.
|
|
22
|
-
*/ field: FieldDefinition;
|
|
2
|
+
/**
|
|
3
|
+
* Generic Field Renderer
|
|
4
|
+
*
|
|
5
|
+
* Renders a form field based on its type definition.
|
|
6
|
+
* Uses Bootstrap form components for styling.
|
|
7
|
+
* Works with hierarchical store structure.
|
|
8
|
+
*/
|
|
9
|
+
interface Props {
|
|
10
|
+
field: FieldDefinition;
|
|
23
11
|
segmentId: string;
|
|
24
12
|
store: any;
|
|
25
13
|
value: any;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
type FieldRenderer = InstanceType<typeof FieldRenderer>;
|
|
14
|
+
}
|
|
15
|
+
declare const FieldRenderer: import("svelte").Component<Props, {}, "">;
|
|
16
|
+
type FieldRenderer = ReturnType<typeof FieldRenderer>;
|
|
30
17
|
export default FieldRenderer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
3
|
import type { SettingsSchema } from './types';
|
|
4
4
|
import { createSettingsStore } from './store';
|
|
5
5
|
import FieldRenderer from './FieldRenderer.svelte';
|
|
@@ -22,42 +22,61 @@
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
interface Props {
|
|
26
|
+
/** The settings schema defining all segments and fields */
|
|
27
|
+
schema: SettingsSchema;
|
|
28
|
+
/** The settings store instance (create externally for access in parent) */
|
|
29
|
+
settings: ReturnType<typeof createSettingsStore>;
|
|
30
|
+
/** Optional: Callback when settings change */
|
|
31
|
+
onChange?: ((values: any) => void) | undefined;
|
|
32
|
+
}
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
export let onChange: ((values: any) => void) | undefined = undefined;
|
|
34
|
+
let { schema, settings, onChange }: Props = $props();
|
|
33
35
|
|
|
34
36
|
// Current values (hierarchical structure: { segment: { field: value } })
|
|
35
|
-
let currentValues
|
|
37
|
+
let currentValues = $state<Record<string, Record<string, any>>>({});
|
|
36
38
|
|
|
37
|
-
// Track collapsed state of segments
|
|
38
|
-
let collapsedSegments =
|
|
39
|
+
// Track collapsed state of segments - using a plain object for better reactivity
|
|
40
|
+
let collapsedSegments = $state<Record<string, boolean>>({});
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
// Initialize collapsed states from schema (derived, not in effect)
|
|
43
|
+
let initialCollapsedStates = $derived.by(() => {
|
|
44
|
+
const states: Record<string, boolean> = {};
|
|
42
45
|
schema.segments.forEach((segment) => {
|
|
43
|
-
|
|
46
|
+
states[segment.id] = segment.collapsed || false;
|
|
44
47
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
return states;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// One-time initialization of collapsed segments
|
|
52
|
+
$effect(() => {
|
|
53
|
+
// Use untrack to prevent this from re-running when collapsedSegments changes
|
|
54
|
+
untrack(() => {
|
|
55
|
+
if (Object.keys(collapsedSegments).length === 0) {
|
|
56
|
+
collapsedSegments = { ...initialCollapsedStates };
|
|
51
57
|
}
|
|
52
58
|
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Subscribe to store changes - this is necessary for external store integration
|
|
62
|
+
$effect(() => {
|
|
63
|
+
const unsubscribe = settings.subscribe((values) => {
|
|
64
|
+
// Using untrack to avoid circular dependencies
|
|
65
|
+
untrack(() => {
|
|
66
|
+
currentValues = values;
|
|
67
|
+
});
|
|
68
|
+
// Call onChange outside untrack so it can access reactive state if needed
|
|
69
|
+
onChange?.(values);
|
|
70
|
+
});
|
|
53
71
|
|
|
54
72
|
return unsubscribe;
|
|
55
73
|
});
|
|
56
74
|
|
|
57
75
|
function toggleSegment(segmentId: string) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
76
|
+
collapsedSegments = {
|
|
77
|
+
...collapsedSegments,
|
|
78
|
+
[segmentId]: !collapsedSegments[segmentId]
|
|
79
|
+
};
|
|
61
80
|
}
|
|
62
81
|
|
|
63
82
|
function resetSegmentHandler(segmentId: string) {
|
|
@@ -90,7 +109,7 @@
|
|
|
90
109
|
<small class="text-muted">Schema v{schema.version}</small>
|
|
91
110
|
{/if}
|
|
92
111
|
</div>
|
|
93
|
-
<button class="btn btn-outline-secondary btn-sm"
|
|
112
|
+
<button class="btn btn-outline-secondary btn-sm" onclick={resetAll}>
|
|
94
113
|
Reset All
|
|
95
114
|
</button>
|
|
96
115
|
</div>
|
|
@@ -117,24 +136,24 @@
|
|
|
117
136
|
<div class="d-flex gap-2">
|
|
118
137
|
<button
|
|
119
138
|
class="btn btn-sm btn-link text-decoration-none p-0"
|
|
120
|
-
|
|
139
|
+
onclick={() => resetSegmentHandler(segment.id)}
|
|
121
140
|
title="Reset to defaults"
|
|
122
141
|
>
|
|
123
142
|
↺
|
|
124
143
|
</button>
|
|
125
144
|
<button
|
|
126
145
|
class="btn btn-sm btn-link text-decoration-none p-0"
|
|
127
|
-
|
|
128
|
-
title={collapsedSegments
|
|
146
|
+
onclick={() => toggleSegment(segment.id)}
|
|
147
|
+
title={collapsedSegments[segment.id] ? 'Expand' : 'Collapse'}
|
|
129
148
|
>
|
|
130
|
-
{collapsedSegments
|
|
149
|
+
{collapsedSegments[segment.id] ? '▶' : '▼'}
|
|
131
150
|
</button>
|
|
132
151
|
</div>
|
|
133
152
|
</div>
|
|
134
153
|
</div>
|
|
135
154
|
|
|
136
155
|
<!-- Card Body -->
|
|
137
|
-
{#if !collapsedSegments
|
|
156
|
+
{#if !collapsedSegments[segment.id]}
|
|
138
157
|
<div class="card-body">
|
|
139
158
|
{#each segment.fields as field (field.id)}
|
|
140
159
|
{#if isFieldVisible(field, segment.id)}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import type { SettingsSchema } from './types';
|
|
2
2
|
import { createSettingsStore } from './store';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Settings Component
|
|
5
|
+
*
|
|
6
|
+
* Reusable settings panel that accepts a schema and renders
|
|
7
|
+
* a data-driven UI with automatic persistence.
|
|
8
|
+
* Provides hierarchical access: $settings.segment.field
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```svelte
|
|
12
|
+
* const settings = createSettingsStore(mySchema, 'myApp');
|
|
13
|
+
* <Settings schema={mySchema} {settings} />
|
|
14
|
+
*
|
|
15
|
+
* // Access settings in parent:
|
|
16
|
+
* $settings.appearance.theme
|
|
17
|
+
* $settings.editor.fontSize
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
interface Props {
|
|
21
|
+
/** The settings schema defining all segments and fields */
|
|
22
|
+
schema: SettingsSchema;
|
|
23
|
+
/** The settings store instance (create externally for access in parent) */
|
|
24
|
+
settings: ReturnType<typeof createSettingsStore>;
|
|
25
|
+
/** Optional: Callback when settings change */
|
|
26
|
+
onChange?: ((values: any) => void) | undefined;
|
|
15
27
|
}
|
|
16
|
-
declare const Settings:
|
|
17
|
-
|
|
18
|
-
/** The settings store instance (create externally for access in parent) */ settings: ReturnType<typeof createSettingsStore>;
|
|
19
|
-
/** Optional: Callback when settings change */ onChange?: ((values: any) => void) | undefined;
|
|
20
|
-
}, {
|
|
21
|
-
[evt: string]: CustomEvent<any>;
|
|
22
|
-
}, {}, {}, string>;
|
|
23
|
-
type Settings = InstanceType<typeof Settings>;
|
|
28
|
+
declare const Settings: import("svelte").Component<Props, {}, "">;
|
|
29
|
+
type Settings = ReturnType<typeof Settings>;
|
|
24
30
|
export default Settings;
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartnet360/svelte-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "vite build && npm run prepack",
|
|
@@ -32,22 +32,30 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
+
"bootstrap": "^5.2.3",
|
|
36
|
+
"dexie": "^4.0.11",
|
|
35
37
|
"plotly.js-dist-min": "^3.1.0",
|
|
36
38
|
"svelte": "^5.0.0",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
+
"@turf/turf": "^7.2.0",
|
|
40
|
+
"deck.gl": "^9.1.0",
|
|
41
|
+
"mapbox-gl": "^3.0.0"
|
|
39
42
|
},
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"@eslint/compat": "^1.2.5",
|
|
42
45
|
"@eslint/js": "^9.18.0",
|
|
43
46
|
"@sveltejs/adapter-auto": "^6.0.0",
|
|
47
|
+
"@sveltejs/adapter-static": "^3.0.9",
|
|
44
48
|
"@sveltejs/kit": "^2.22.0",
|
|
45
49
|
"@sveltejs/package": "^2.0.0",
|
|
46
50
|
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
|
51
|
+
"bootstrap": "^5.2.3",
|
|
52
|
+
"bootstrap-icons": "^1.13.1",
|
|
53
|
+
"dexie": "^4.0.11",
|
|
47
54
|
"eslint": "^9.18.0",
|
|
48
55
|
"eslint-config-prettier": "^10.0.1",
|
|
49
56
|
"eslint-plugin-svelte": "^3.0.0",
|
|
50
57
|
"globals": "^16.0.0",
|
|
58
|
+
"plotly.js-dist-min": "^3.1.0",
|
|
51
59
|
"prettier": "^3.4.2",
|
|
52
60
|
"prettier-plugin-svelte": "^3.3.3",
|
|
53
61
|
"publint": "^0.3.2",
|
|
@@ -56,12 +64,7 @@
|
|
|
56
64
|
"svelte-check": "^4.0.0",
|
|
57
65
|
"typescript": "^5.0.0",
|
|
58
66
|
"typescript-eslint": "^8.20.0",
|
|
59
|
-
"vite": "^7.0.4"
|
|
60
|
-
"@sveltejs/adapter-static": "^3.0.9",
|
|
61
|
-
"bootstrap": "^5.2.3",
|
|
62
|
-
"bootstrap-icons": "^1.13.1",
|
|
63
|
-
"dexie": "^4.0.11",
|
|
64
|
-
"plotly.js-dist-min": "^3.1.0"
|
|
67
|
+
"vite": "^7.0.4"
|
|
65
68
|
},
|
|
66
69
|
"keywords": [
|
|
67
70
|
"svelte"
|