@smartnet360/svelte-components 0.0.22 → 0.0.24
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/utils/msi-parser.js +2 -2
- package/dist/cellular/CellularChartsView.svelte +293 -0
- package/dist/cellular/CellularChartsView.svelte.d.ts +7 -0
- package/dist/cellular/HierarchicalTree.svelte +469 -0
- package/dist/cellular/HierarchicalTree.svelte.d.ts +9 -0
- package/dist/cellular/SiteTree.svelte +286 -0
- package/dist/cellular/SiteTree.svelte.d.ts +11 -0
- package/dist/cellular/cellular-transforms.d.ts +25 -0
- package/dist/cellular/cellular-transforms.js +129 -0
- package/dist/cellular/cellular.model.d.ts +63 -0
- package/dist/cellular/cellular.model.js +6 -0
- package/dist/cellular/index.d.ts +11 -0
- package/dist/cellular/index.js +11 -0
- package/dist/cellular/mock-cellular-data.d.ts +13 -0
- package/dist/cellular/mock-cellular-data.js +241 -0
- package/dist/core/TreeChartView/TreeChartView.svelte +208 -0
- package/dist/core/TreeChartView/TreeChartView.svelte.d.ts +42 -0
- package/dist/core/TreeChartView/index.d.ts +7 -0
- package/dist/core/TreeChartView/index.js +7 -0
- package/dist/core/TreeView/TreeNode.svelte +173 -0
- package/dist/core/TreeView/TreeNode.svelte.d.ts +10 -0
- package/dist/core/TreeView/TreeView.svelte +163 -0
- package/dist/core/TreeView/TreeView.svelte.d.ts +10 -0
- package/dist/core/TreeView/index.d.ts +48 -0
- package/dist/core/TreeView/index.js +50 -0
- package/dist/core/TreeView/tree-utils.d.ts +56 -0
- package/dist/core/TreeView/tree-utils.js +194 -0
- package/dist/core/TreeView/tree.model.d.ts +104 -0
- package/dist/core/TreeView/tree.model.js +5 -0
- package/dist/core/TreeView/tree.store.d.ts +10 -0
- package/dist/core/TreeView/tree.store.js +225 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/package.json +1 -1
@@ -0,0 +1,225 @@
|
|
1
|
+
/**
|
2
|
+
* Tree Store
|
3
|
+
* Svelte writable store for managing tree state with persistence
|
4
|
+
*/
|
5
|
+
import { writable } from 'svelte/store';
|
6
|
+
import { flattenTree, buildInitialState, calculateIndeterminateStates, getDescendantPaths, getParentPath, saveStateToStorage, loadStateFromStorage, clearStorageForNamespace } from './tree-utils';
|
7
|
+
/**
|
8
|
+
* Create a tree store with state management and persistence
|
9
|
+
*/
|
10
|
+
export function createTreeStore(config) {
|
11
|
+
const separator = config.pathSeparator || ':';
|
12
|
+
// Flatten tree structure
|
13
|
+
const nodesMap = flattenTree(config.nodes, config);
|
14
|
+
// Build initial state
|
15
|
+
let state = buildInitialState(nodesMap, config);
|
16
|
+
// Load persisted state if enabled
|
17
|
+
if (config.persistState && config.namespace) {
|
18
|
+
const persistedState = loadStateFromStorage(config.namespace, state);
|
19
|
+
state = { ...state, ...persistedState };
|
20
|
+
}
|
21
|
+
// Create writable store
|
22
|
+
const store = writable({
|
23
|
+
state,
|
24
|
+
config,
|
25
|
+
toggle: () => { },
|
26
|
+
toggleExpand: () => { },
|
27
|
+
expandAll: () => { },
|
28
|
+
collapseAll: () => { },
|
29
|
+
checkAll: () => { },
|
30
|
+
uncheckAll: () => { },
|
31
|
+
getCheckedPaths: () => [],
|
32
|
+
getCheckedLeafPaths: () => [],
|
33
|
+
clearStorage: () => { }
|
34
|
+
});
|
35
|
+
/**
|
36
|
+
* Update state and trigger reactivity
|
37
|
+
*/
|
38
|
+
function updateState(updater) {
|
39
|
+
store.update(current => {
|
40
|
+
const newState = updater(current.state);
|
41
|
+
// Persist if enabled
|
42
|
+
if (config.persistState && config.namespace) {
|
43
|
+
saveStateToStorage(config.namespace, newState);
|
44
|
+
}
|
45
|
+
return {
|
46
|
+
...current,
|
47
|
+
state: newState
|
48
|
+
};
|
49
|
+
});
|
50
|
+
}
|
51
|
+
/**
|
52
|
+
* Toggle a node's checked state (with cascading)
|
53
|
+
*/
|
54
|
+
function toggle(path) {
|
55
|
+
updateState(state => {
|
56
|
+
const nodeState = state.nodes.get(path);
|
57
|
+
if (!nodeState)
|
58
|
+
return state;
|
59
|
+
const newChecked = !state.checkedPaths.has(path);
|
60
|
+
const newCheckedPaths = new Set(state.checkedPaths);
|
61
|
+
// Update this node
|
62
|
+
if (newChecked) {
|
63
|
+
newCheckedPaths.add(path);
|
64
|
+
}
|
65
|
+
else {
|
66
|
+
newCheckedPaths.delete(path);
|
67
|
+
}
|
68
|
+
// Cascade to all descendants
|
69
|
+
const descendants = getDescendantPaths(path, state.nodes, separator);
|
70
|
+
descendants.forEach(descendantPath => {
|
71
|
+
if (newChecked) {
|
72
|
+
newCheckedPaths.add(descendantPath);
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
newCheckedPaths.delete(descendantPath);
|
76
|
+
}
|
77
|
+
});
|
78
|
+
// Update ancestors (check for indeterminate states)
|
79
|
+
let currentPath = path;
|
80
|
+
while (true) {
|
81
|
+
const parentPath = getParentPath(currentPath, separator);
|
82
|
+
if (!parentPath)
|
83
|
+
break;
|
84
|
+
const parent = state.nodes.get(parentPath);
|
85
|
+
if (!parent)
|
86
|
+
break;
|
87
|
+
// Count checked children
|
88
|
+
const checkedChildren = parent.childPaths.filter(childPath => newCheckedPaths.has(childPath));
|
89
|
+
// If all children checked, check parent; if none checked, uncheck parent
|
90
|
+
if (checkedChildren.length === parent.childPaths.length) {
|
91
|
+
newCheckedPaths.add(parentPath);
|
92
|
+
}
|
93
|
+
else if (checkedChildren.length === 0) {
|
94
|
+
newCheckedPaths.delete(parentPath);
|
95
|
+
}
|
96
|
+
// If some checked, parent state depends on whether we're checking or unchecking
|
97
|
+
// For better UX: leave parent as-is (will show indeterminate)
|
98
|
+
currentPath = parentPath;
|
99
|
+
}
|
100
|
+
// Recalculate indeterminate states
|
101
|
+
const newIndeterminatePaths = calculateIndeterminateStates(state.nodes, newCheckedPaths);
|
102
|
+
return {
|
103
|
+
...state,
|
104
|
+
checkedPaths: newCheckedPaths,
|
105
|
+
indeterminatePaths: newIndeterminatePaths
|
106
|
+
};
|
107
|
+
});
|
108
|
+
}
|
109
|
+
/**
|
110
|
+
* Toggle expanded/collapsed state
|
111
|
+
*/
|
112
|
+
function toggleExpand(path) {
|
113
|
+
updateState(state => {
|
114
|
+
const newExpandedPaths = new Set(state.expandedPaths);
|
115
|
+
if (newExpandedPaths.has(path)) {
|
116
|
+
newExpandedPaths.delete(path);
|
117
|
+
}
|
118
|
+
else {
|
119
|
+
newExpandedPaths.add(path);
|
120
|
+
}
|
121
|
+
return {
|
122
|
+
...state,
|
123
|
+
expandedPaths: newExpandedPaths
|
124
|
+
};
|
125
|
+
});
|
126
|
+
}
|
127
|
+
/**
|
128
|
+
* Expand all nodes
|
129
|
+
*/
|
130
|
+
function expandAll() {
|
131
|
+
updateState(state => {
|
132
|
+
const newExpandedPaths = new Set();
|
133
|
+
// Add all nodes with children
|
134
|
+
state.nodes.forEach((nodeState, path) => {
|
135
|
+
if (nodeState.childPaths.length > 0) {
|
136
|
+
newExpandedPaths.add(path);
|
137
|
+
}
|
138
|
+
});
|
139
|
+
return {
|
140
|
+
...state,
|
141
|
+
expandedPaths: newExpandedPaths
|
142
|
+
};
|
143
|
+
});
|
144
|
+
}
|
145
|
+
/**
|
146
|
+
* Collapse all nodes
|
147
|
+
*/
|
148
|
+
function collapseAll() {
|
149
|
+
updateState(state => ({
|
150
|
+
...state,
|
151
|
+
expandedPaths: new Set()
|
152
|
+
}));
|
153
|
+
}
|
154
|
+
/**
|
155
|
+
* Check all nodes
|
156
|
+
*/
|
157
|
+
function checkAll() {
|
158
|
+
updateState(state => {
|
159
|
+
const newCheckedPaths = new Set();
|
160
|
+
state.nodes.forEach((_, path) => {
|
161
|
+
newCheckedPaths.add(path);
|
162
|
+
});
|
163
|
+
return {
|
164
|
+
...state,
|
165
|
+
checkedPaths: newCheckedPaths,
|
166
|
+
indeterminatePaths: new Set() // No indeterminate when all checked
|
167
|
+
};
|
168
|
+
});
|
169
|
+
}
|
170
|
+
/**
|
171
|
+
* Uncheck all nodes
|
172
|
+
*/
|
173
|
+
function uncheckAll() {
|
174
|
+
updateState(state => ({
|
175
|
+
...state,
|
176
|
+
checkedPaths: new Set(),
|
177
|
+
indeterminatePaths: new Set()
|
178
|
+
}));
|
179
|
+
}
|
180
|
+
/**
|
181
|
+
* Get all checked paths
|
182
|
+
*/
|
183
|
+
function getCheckedPaths() {
|
184
|
+
let result = [];
|
185
|
+
store.subscribe(value => {
|
186
|
+
result = Array.from(value.state.checkedPaths);
|
187
|
+
})();
|
188
|
+
return result;
|
189
|
+
}
|
190
|
+
/**
|
191
|
+
* Get only checked leaf paths (nodes without children)
|
192
|
+
*/
|
193
|
+
function getCheckedLeafPaths() {
|
194
|
+
let result = [];
|
195
|
+
store.subscribe(value => {
|
196
|
+
result = Array.from(value.state.checkedPaths).filter(path => {
|
197
|
+
const node = value.state.nodes.get(path);
|
198
|
+
return node && node.childPaths.length === 0;
|
199
|
+
});
|
200
|
+
})();
|
201
|
+
return result;
|
202
|
+
}
|
203
|
+
/**
|
204
|
+
* Clear localStorage
|
205
|
+
*/
|
206
|
+
function clearStorage() {
|
207
|
+
if (config.namespace) {
|
208
|
+
clearStorageForNamespace(config.namespace);
|
209
|
+
}
|
210
|
+
}
|
211
|
+
// Initialize store with methods
|
212
|
+
store.update(current => ({
|
213
|
+
...current,
|
214
|
+
toggle,
|
215
|
+
toggleExpand,
|
216
|
+
expandAll,
|
217
|
+
collapseAll,
|
218
|
+
checkAll,
|
219
|
+
uncheckAll,
|
220
|
+
getCheckedPaths,
|
221
|
+
getCheckedLeafPaths,
|
222
|
+
clearStorage
|
223
|
+
}));
|
224
|
+
return store;
|
225
|
+
}
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
@@ -4,3 +4,7 @@
|
|
4
4
|
export * from './Desktop/index.js';
|
5
5
|
// Chart visualization components
|
6
6
|
export * from './Charts/index.js';
|
7
|
+
// TreeView generic hierarchical component
|
8
|
+
export * from './TreeView/index.js';
|
9
|
+
// TreeChartView combined layout component
|
10
|
+
export * from './TreeChartView/index.js';
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
// Main library export - clean barrel export pattern
|
2
2
|
// This approach keeps the main index clean and allows for easy expansion
|
3
|
-
// Core components (Desktop orchestration + Charts)
|
3
|
+
// Core components (Desktop orchestration + Charts + TreeView)
|
4
4
|
export * from './core/index.js';
|
5
5
|
// Complete applications
|
6
6
|
export * from './apps/index.js';
|
7
|
+
// Cellular network components
|
8
|
+
export * from './cellular/index.js';
|