@smartnet360/svelte-components 0.0.103 → 0.0.105

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.
@@ -0,0 +1,465 @@
1
+ /**
2
+ * CellTable - Column Configuration
3
+ *
4
+ * Defines column definitions, presets, and formatters for the cell table
5
+ */
6
+ /**
7
+ * Default technology colors (Bootstrap-aligned)
8
+ */
9
+ export const DEFAULT_TECH_COLORS = {
10
+ '2G': '#6c757d', // secondary gray
11
+ '3G': '#0d6efd', // primary blue
12
+ '4G': '#198754', // success green
13
+ '5G': '#6f42c1', // purple
14
+ 'LTE': '#198754', // success green
15
+ 'NR': '#6f42c1', // purple
16
+ };
17
+ /**
18
+ * Default status colors (Bootstrap-aligned)
19
+ */
20
+ export const DEFAULT_STATUS_COLORS = {
21
+ 'On_Air': '#198754', // success green
22
+ 'On_Air_UNDER_CONSTRUCTION': '#ffc107', // warning yellow
23
+ 'On_Air_Locked': '#0dcaf0', // info cyan
24
+ 'RF_Plan_Ready': '#0d6efd', // primary blue
25
+ 'Re-Planned_RF_Plan_Ready': '#6f42c1', // purple
26
+ 'Tavlati_RF_Plan_Ready': '#fd7e14', // orange
27
+ };
28
+ /**
29
+ * Frequency band colors
30
+ */
31
+ export const FBAND_COLORS = {
32
+ 'GSM900': '#6c757d',
33
+ 'GSM1800': '#495057',
34
+ 'LTE700': '#dc3545',
35
+ 'LTE800': '#e35d6a',
36
+ 'LTE900': '#fd7e14',
37
+ 'LTE1800': '#198754',
38
+ 'LTE2100': '#20c997',
39
+ 'LTE2600': '#0dcaf0',
40
+ '5G-700': '#6f42c1',
41
+ '5G-3500': '#d63384',
42
+ 'NR3500': '#d63384',
43
+ };
44
+ /**
45
+ * Column groups for different presets
46
+ */
47
+ export const COLUMN_GROUPS = {
48
+ core: ['id', 'cellName', 'siteId', 'tech', 'fband', 'status'],
49
+ physical: ['antenna', 'azimuth', 'height', 'electricalTilt', 'beamwidth'],
50
+ network: ['dlEarfn', 'bcch', 'pci1', 'cellId3', 'nwtP1', 'nwtP2', 'nwtRS', 'nwtBW'],
51
+ planning: ['planner', 'comment', 'onAirDate', 'type'],
52
+ atoll: ['atollETP', 'atollPW', 'atollRS', 'atollBW'],
53
+ position: ['latitude', 'longitude', 'siteLatitude', 'siteLongitude', 'dx', 'dy'],
54
+ };
55
+ /**
56
+ * Create a technology badge formatter
57
+ */
58
+ export function createTechFormatter(colors = DEFAULT_TECH_COLORS) {
59
+ return (cell) => {
60
+ const value = cell.getValue();
61
+ const color = colors[value] || '#6c757d';
62
+ return `<span class="badge" style="background-color: ${color}; color: white;">${value}</span>`;
63
+ };
64
+ }
65
+ /**
66
+ * Create a status badge formatter
67
+ */
68
+ export function createStatusFormatter(colors = DEFAULT_STATUS_COLORS) {
69
+ return (cell) => {
70
+ const value = cell.getValue();
71
+ const color = colors[value] || '#6c757d';
72
+ const displayValue = value.replace(/_/g, ' ');
73
+ return `<span class="badge" style="background-color: ${color}; color: white; font-size: 0.7rem;">${displayValue}</span>`;
74
+ };
75
+ }
76
+ /**
77
+ * Create an fband badge formatter
78
+ */
79
+ export function createFbandFormatter() {
80
+ return (cell) => {
81
+ const value = cell.getValue();
82
+ const color = FBAND_COLORS[value] || '#6c757d';
83
+ return `<span class="badge" style="background-color: ${color}; color: white;">${value}</span>`;
84
+ };
85
+ }
86
+ /**
87
+ * Number formatter with fixed decimals
88
+ */
89
+ export function numberFormatter(decimals = 2) {
90
+ return (cell) => {
91
+ const value = cell.getValue();
92
+ if (value === null || value === undefined || value === '')
93
+ return '';
94
+ const num = Number(value);
95
+ return isNaN(num) ? String(value) : num.toFixed(decimals);
96
+ };
97
+ }
98
+ /**
99
+ * Coordinate formatter (lat/lng)
100
+ */
101
+ export function coordinateFormatter(cell) {
102
+ const value = cell.getValue();
103
+ if (value === null || value === undefined || value === '')
104
+ return '';
105
+ const num = Number(value);
106
+ return isNaN(num) ? String(value) : num.toFixed(6);
107
+ }
108
+ /**
109
+ * Azimuth formatter with degree symbol
110
+ */
111
+ export function azimuthFormatter(cell) {
112
+ const value = cell.getValue();
113
+ if (value === null || value === undefined || value === '')
114
+ return '';
115
+ return `${value}°`;
116
+ }
117
+ /**
118
+ * Height formatter with meter unit
119
+ */
120
+ export function heightFormatter(cell) {
121
+ const value = cell.getValue();
122
+ if (value === null || value === undefined || value === '')
123
+ return '';
124
+ return `${value}m`;
125
+ }
126
+ /**
127
+ * Get all column definitions
128
+ */
129
+ export function getAllColumns(techColors = DEFAULT_TECH_COLORS, statusColors = DEFAULT_STATUS_COLORS, headerFilters = true) {
130
+ const headerFilterParams = headerFilters ? { headerFilter: 'input' } : {};
131
+ const selectHeaderFilter = headerFilters ? { headerFilter: 'list', headerFilterParams: { valuesLookup: true } } : {};
132
+ return [
133
+ // Core columns
134
+ {
135
+ title: 'ID',
136
+ field: 'id',
137
+ width: 120,
138
+ frozen: true,
139
+ ...headerFilterParams,
140
+ },
141
+ {
142
+ title: 'Cell Name',
143
+ field: 'cellName',
144
+ width: 150,
145
+ ...headerFilterParams,
146
+ },
147
+ {
148
+ title: 'Site ID',
149
+ field: 'siteId',
150
+ width: 120,
151
+ ...headerFilterParams,
152
+ },
153
+ {
154
+ title: 'Tech',
155
+ field: 'tech',
156
+ width: 80,
157
+ hozAlign: 'center',
158
+ formatter: createTechFormatter(techColors),
159
+ ...selectHeaderFilter,
160
+ },
161
+ {
162
+ title: 'Band',
163
+ field: 'fband',
164
+ width: 100,
165
+ hozAlign: 'center',
166
+ formatter: createFbandFormatter(),
167
+ ...selectHeaderFilter,
168
+ },
169
+ {
170
+ title: 'Freq',
171
+ field: 'frq',
172
+ width: 80,
173
+ hozAlign: 'center',
174
+ ...selectHeaderFilter,
175
+ },
176
+ {
177
+ title: 'Status',
178
+ field: 'status',
179
+ width: 180,
180
+ formatter: createStatusFormatter(statusColors),
181
+ ...selectHeaderFilter,
182
+ },
183
+ {
184
+ title: 'Type',
185
+ field: 'type',
186
+ width: 100,
187
+ ...selectHeaderFilter,
188
+ },
189
+ {
190
+ title: 'On Air Date',
191
+ field: 'onAirDate',
192
+ width: 120,
193
+ ...headerFilterParams,
194
+ },
195
+ // Physical columns
196
+ {
197
+ title: 'Antenna',
198
+ field: 'antenna',
199
+ width: 150,
200
+ ...headerFilterParams,
201
+ },
202
+ {
203
+ title: 'Azimuth',
204
+ field: 'azimuth',
205
+ width: 90,
206
+ hozAlign: 'right',
207
+ formatter: azimuthFormatter,
208
+ ...headerFilterParams,
209
+ },
210
+ {
211
+ title: 'Height',
212
+ field: 'height',
213
+ width: 80,
214
+ hozAlign: 'right',
215
+ formatter: heightFormatter,
216
+ ...headerFilterParams,
217
+ },
218
+ {
219
+ title: 'E-Tilt',
220
+ field: 'electricalTilt',
221
+ width: 80,
222
+ hozAlign: 'right',
223
+ ...headerFilterParams,
224
+ },
225
+ {
226
+ title: 'Beamwidth',
227
+ field: 'beamwidth',
228
+ width: 100,
229
+ hozAlign: 'right',
230
+ formatter: azimuthFormatter,
231
+ ...headerFilterParams,
232
+ },
233
+ // Network columns
234
+ {
235
+ title: 'DL EARFCN',
236
+ field: 'dlEarfn',
237
+ width: 100,
238
+ hozAlign: 'right',
239
+ ...headerFilterParams,
240
+ },
241
+ {
242
+ title: 'BCCH',
243
+ field: 'bcch',
244
+ width: 80,
245
+ hozAlign: 'right',
246
+ ...headerFilterParams,
247
+ },
248
+ {
249
+ title: 'PCI',
250
+ field: 'pci1',
251
+ width: 80,
252
+ hozAlign: 'right',
253
+ ...headerFilterParams,
254
+ },
255
+ {
256
+ title: 'Cell ID 3',
257
+ field: 'cellId3',
258
+ width: 100,
259
+ ...headerFilterParams,
260
+ },
261
+ {
262
+ title: 'Cell ID',
263
+ field: 'cellID',
264
+ width: 100,
265
+ ...headerFilterParams,
266
+ },
267
+ {
268
+ title: 'Cell ID 2G',
269
+ field: 'cellID2G',
270
+ width: 100,
271
+ ...headerFilterParams,
272
+ },
273
+ {
274
+ title: 'TX ID',
275
+ field: 'txId',
276
+ width: 100,
277
+ ...headerFilterParams,
278
+ },
279
+ {
280
+ title: 'Ctrl ID',
281
+ field: 'ctrlid',
282
+ width: 100,
283
+ ...headerFilterParams,
284
+ },
285
+ {
286
+ title: 'NWT P1',
287
+ field: 'nwtP1',
288
+ width: 80,
289
+ hozAlign: 'right',
290
+ ...headerFilterParams,
291
+ },
292
+ {
293
+ title: 'NWT P2',
294
+ field: 'nwtP2',
295
+ width: 80,
296
+ hozAlign: 'right',
297
+ ...headerFilterParams,
298
+ },
299
+ {
300
+ title: 'NWT RS',
301
+ field: 'nwtRS',
302
+ width: 80,
303
+ hozAlign: 'right',
304
+ ...headerFilterParams,
305
+ },
306
+ {
307
+ title: 'NWT BW',
308
+ field: 'nwtBW',
309
+ width: 80,
310
+ hozAlign: 'right',
311
+ ...headerFilterParams,
312
+ },
313
+ // Atoll columns
314
+ {
315
+ title: 'Atoll ETP',
316
+ field: 'atollETP',
317
+ width: 90,
318
+ hozAlign: 'right',
319
+ formatter: numberFormatter(1),
320
+ ...headerFilterParams,
321
+ },
322
+ {
323
+ title: 'Atoll PW',
324
+ field: 'atollPW',
325
+ width: 90,
326
+ hozAlign: 'right',
327
+ formatter: numberFormatter(1),
328
+ ...headerFilterParams,
329
+ },
330
+ {
331
+ title: 'Atoll RS',
332
+ field: 'atollRS',
333
+ width: 90,
334
+ hozAlign: 'right',
335
+ formatter: numberFormatter(1),
336
+ ...headerFilterParams,
337
+ },
338
+ {
339
+ title: 'Atoll BW',
340
+ field: 'atollBW',
341
+ width: 90,
342
+ hozAlign: 'right',
343
+ formatter: numberFormatter(1),
344
+ ...headerFilterParams,
345
+ },
346
+ // Position columns
347
+ {
348
+ title: 'Latitude',
349
+ field: 'latitude',
350
+ width: 120,
351
+ hozAlign: 'right',
352
+ formatter: coordinateFormatter,
353
+ ...headerFilterParams,
354
+ },
355
+ {
356
+ title: 'Longitude',
357
+ field: 'longitude',
358
+ width: 120,
359
+ hozAlign: 'right',
360
+ formatter: coordinateFormatter,
361
+ ...headerFilterParams,
362
+ },
363
+ {
364
+ title: 'Site Lat',
365
+ field: 'siteLatitude',
366
+ width: 120,
367
+ hozAlign: 'right',
368
+ formatter: coordinateFormatter,
369
+ ...headerFilterParams,
370
+ },
371
+ {
372
+ title: 'Site Lng',
373
+ field: 'siteLongitude',
374
+ width: 120,
375
+ hozAlign: 'right',
376
+ formatter: coordinateFormatter,
377
+ ...headerFilterParams,
378
+ },
379
+ {
380
+ title: 'DX',
381
+ field: 'dx',
382
+ width: 80,
383
+ hozAlign: 'right',
384
+ formatter: numberFormatter(2),
385
+ ...headerFilterParams,
386
+ },
387
+ {
388
+ title: 'DY',
389
+ field: 'dy',
390
+ width: 80,
391
+ hozAlign: 'right',
392
+ formatter: numberFormatter(2),
393
+ ...headerFilterParams,
394
+ },
395
+ // Planning columns
396
+ {
397
+ title: 'Planner',
398
+ field: 'planner',
399
+ width: 120,
400
+ ...headerFilterParams,
401
+ },
402
+ {
403
+ title: 'Comment',
404
+ field: 'comment',
405
+ width: 200,
406
+ ...headerFilterParams,
407
+ },
408
+ {
409
+ title: 'Subgroup',
410
+ field: 'customSubgroup',
411
+ width: 120,
412
+ ...headerFilterParams,
413
+ },
414
+ ];
415
+ }
416
+ /**
417
+ * Get columns for a specific preset
418
+ */
419
+ export function getColumnsForPreset(preset, techColors = DEFAULT_TECH_COLORS, statusColors = DEFAULT_STATUS_COLORS, headerFilters = true) {
420
+ const allColumns = getAllColumns(techColors, statusColors, headerFilters);
421
+ let visibleFields;
422
+ switch (preset) {
423
+ case 'compact':
424
+ visibleFields = ['cellName', 'siteId', 'tech', 'fband', 'status'];
425
+ break;
426
+ case 'full':
427
+ return allColumns;
428
+ case 'physical':
429
+ visibleFields = [...COLUMN_GROUPS.core, ...COLUMN_GROUPS.physical];
430
+ break;
431
+ case 'network':
432
+ visibleFields = [...COLUMN_GROUPS.core, ...COLUMN_GROUPS.network];
433
+ break;
434
+ case 'planning':
435
+ visibleFields = [...COLUMN_GROUPS.core, ...COLUMN_GROUPS.planning];
436
+ break;
437
+ case 'default':
438
+ default:
439
+ visibleFields = [
440
+ 'id', 'cellName', 'siteId', 'tech', 'fband', 'frq', 'status',
441
+ 'azimuth', 'height', 'antenna'
442
+ ];
443
+ }
444
+ return allColumns.filter(col => visibleFields.includes(col.field));
445
+ }
446
+ /**
447
+ * Get group header formatter for a specific field
448
+ */
449
+ export function getGroupHeaderFormatter(groupField) {
450
+ return (value, count) => {
451
+ const displayValue = String(value).replace(/_/g, ' ');
452
+ let color = '#6c757d';
453
+ if (groupField === 'tech') {
454
+ color = DEFAULT_TECH_COLORS[String(value)] || color;
455
+ }
456
+ else if (groupField === 'fband') {
457
+ color = FBAND_COLORS[String(value)] || color;
458
+ }
459
+ else if (groupField === 'status') {
460
+ color = DEFAULT_STATUS_COLORS[String(value)] || color;
461
+ }
462
+ return `<span class="badge me-2" style="background-color: ${color}; color: white;">${displayValue}</span>
463
+ <span class="text-muted">(${count} cell${count !== 1 ? 's' : ''})</span>`;
464
+ };
465
+ }
@@ -0,0 +1,5 @@
1
+ import type { CellData } from './types';
2
+ /**
3
+ * Demo cell data for testing the CellTable component
4
+ */
5
+ export declare const demoCells: CellData[];