@smartnet360/svelte-components 0.0.107 → 0.0.108

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.
@@ -16,7 +16,8 @@
16
16
  getColumnsForPreset,
17
17
  getGroupHeaderFormatter,
18
18
  DEFAULT_TECH_COLORS,
19
- DEFAULT_STATUS_COLORS
19
+ DEFAULT_STATUS_COLORS,
20
+ cellDataSorter
20
21
  } from './column-config';
21
22
 
22
23
  interface Props extends CellTableProps {
@@ -63,10 +64,15 @@
63
64
  return getColumnsForPreset(columnPreset, techColors, statusColors, headerFilters);
64
65
  });
65
66
 
67
+ // Pre-sort data using our custom multi-level sorter
68
+ let sortedCells = $derived.by(() => {
69
+ return [...cells].sort(cellDataSorter);
70
+ });
71
+
66
72
  // Build Tabulator options
67
73
  function buildOptions(): Options {
68
74
  const baseOptions: Options = {
69
- data: cells,
75
+ data: sortedCells,
70
76
  columns: columns,
71
77
  layout: 'fitDataFill',
72
78
  height: height,
@@ -79,8 +85,12 @@
79
85
  resizableColumns: resizableColumns,
80
86
  movableColumns: movableColumns,
81
87
 
82
- // Sorting
83
- initialSort: [{ column: 'siteId', dir: 'asc' }],
88
+ // No initial sort - data is pre-sorted
89
+ initialSort: [
90
+ { column: 'tech', dir: 'asc' },
91
+ { column: 'fband', dir: 'asc' },
92
+ { column: 'cellName', dir: 'asc' }
93
+ ],
84
94
 
85
95
  // Row selection
86
96
  selectable: selectable ? (multiSelect ? true : 1) : false,
@@ -193,19 +203,19 @@
193
203
 
194
204
  // Update table data when cells actually change (not just reference)
195
205
  $effect(() => {
196
- const currentLength = cells?.length ?? 0;
197
- const currentFirstId = cells?.[0]?.id ?? null;
206
+ const currentLength = sortedCells?.length ?? 0;
207
+ const currentFirstId = sortedCells?.[0]?.id ?? null;
198
208
 
199
209
  // Only update if length or first item changed (rough equality check)
200
210
  if (isInitialized && table &&
201
211
  (currentLength !== prevCellsLength || currentFirstId !== prevCellsFirstId)) {
202
212
  prevCellsLength = currentLength;
203
213
  prevCellsFirstId = currentFirstId;
204
- table.replaceData(cells);
214
+ table.replaceData(sortedCells);
205
215
  ondatachange?.({
206
216
  type: 'load',
207
- rowCount: cells.length,
208
- filteredCount: cells.length
217
+ rowCount: sortedCells.length,
218
+ filteredCount: sortedCells.length
209
219
  });
210
220
  }
211
221
  });
@@ -49,6 +49,25 @@ export declare function azimuthFormatter(cell: CellComponent): string;
49
49
  * Height formatter with meter unit
50
50
  */
51
51
  export declare function heightFormatter(cell: CellComponent): string;
52
+ /**
53
+ * Custom sorter for fband - extracts numeric portion and sorts numerically
54
+ * Examples: LTE700 → 700, GSM900 → 900, LTE1800 → 1800, 5G-3500 → 3500
55
+ */
56
+ export declare function fbandSorter(a: string, b: string): number;
57
+ /**
58
+ * Custom sorter for cellName - sorts by the 5th character (sector digit)
59
+ * Example: 10001 → '1', 10002 → '2', 10003 → '3'
60
+ */
61
+ export declare function cellNameSectorSorter(a: string, b: string): number;
62
+ /**
63
+ * Combined multi-level sorter for cell data
64
+ * Sort order: tech (asc) → fband by numeric value (asc) → cellName by 5th digit (asc)
65
+ */
66
+ export declare function cellDataSorter<T extends {
67
+ tech?: string;
68
+ fband?: string;
69
+ cellName?: string;
70
+ }>(a: T, b: T): number;
52
71
  /**
53
72
  * Get all column definitions
54
73
  */
@@ -123,6 +123,46 @@ export function heightFormatter(cell) {
123
123
  return '';
124
124
  return `${value}m`;
125
125
  }
126
+ /**
127
+ * Custom sorter for fband - extracts numeric portion and sorts numerically
128
+ * Examples: LTE700 → 700, GSM900 → 900, LTE1800 → 1800, 5G-3500 → 3500
129
+ */
130
+ export function fbandSorter(a, b) {
131
+ const numA = parseInt(a.replace(/\D/g, ''), 10) || 0;
132
+ const numB = parseInt(b.replace(/\D/g, ''), 10) || 0;
133
+ return numA - numB;
134
+ }
135
+ /**
136
+ * Custom sorter for cellName - sorts by the 5th character (sector digit)
137
+ * Example: 10001 → '1', 10002 → '2', 10003 → '3'
138
+ */
139
+ export function cellNameSectorSorter(a, b) {
140
+ const charA = a.charAt(4) || '0';
141
+ const charB = b.charAt(4) || '0';
142
+ return charA.localeCompare(charB);
143
+ }
144
+ /**
145
+ * Combined multi-level sorter for cell data
146
+ * Sort order: tech (asc) → fband by numeric value (asc) → cellName by 5th digit (asc)
147
+ */
148
+ export function cellDataSorter(a, b) {
149
+ // 1. Sort by tech (string comparison)
150
+ const techA = String(a.tech || '');
151
+ const techB = String(b.tech || '');
152
+ const techCompare = techA.localeCompare(techB);
153
+ if (techCompare !== 0)
154
+ return techCompare;
155
+ // 2. Sort by fband (numeric extraction)
156
+ const fbandA = String(a.fband || '');
157
+ const fbandB = String(b.fband || '');
158
+ const fbandCompare = fbandSorter(fbandA, fbandB);
159
+ if (fbandCompare !== 0)
160
+ return fbandCompare;
161
+ // 3. Sort by cellName 5th character (sector)
162
+ const cellNameA = String(a.cellName || '');
163
+ const cellNameB = String(b.cellName || '');
164
+ return cellNameSectorSorter(cellNameA, cellNameB);
165
+ }
126
166
  /**
127
167
  * Get all column definitions
128
168
  */
@@ -10,4 +10,4 @@ export { default as CellTableDemo } from './CellTableDemo.svelte';
10
10
  export { default as ColumnPicker } from './ColumnPicker.svelte';
11
11
  export { generateCells, generateCellsFromPreset, getGeneratorInfo, GENERATOR_PRESETS, type CellGeneratorConfig, type GeneratorPreset } from '../../shared/demo';
12
12
  export type { CellData, CellTableGroupField, ColumnPreset, ColumnVisibility, TechColorMap, StatusColorMap, CellTableProps, RowSelectionEvent, RowClickEvent, RowDblClickEvent, DataChangeEvent, CellTableColumn, ColumnGroups } from './types';
13
- export { DEFAULT_TECH_COLORS, DEFAULT_STATUS_COLORS, FBAND_COLORS, COLUMN_GROUPS, getAllColumns, getColumnsForPreset, getGroupHeaderFormatter, getColumnMetadata, getPresetVisibleFields, createTechFormatter, createStatusFormatter, createFbandFormatter, numberFormatter, coordinateFormatter, azimuthFormatter, heightFormatter, type ColumnMeta } from './column-config';
13
+ export { DEFAULT_TECH_COLORS, DEFAULT_STATUS_COLORS, FBAND_COLORS, COLUMN_GROUPS, getAllColumns, getColumnsForPreset, getGroupHeaderFormatter, getColumnMetadata, getPresetVisibleFields, fbandSorter, cellNameSectorSorter, cellDataSorter, createTechFormatter, createStatusFormatter, createFbandFormatter, numberFormatter, coordinateFormatter, azimuthFormatter, heightFormatter, type ColumnMeta } from './column-config';
@@ -14,4 +14,4 @@ export { default as ColumnPicker } from './ColumnPicker.svelte';
14
14
  // Import Cell from '$lib/shared/demo' or '@smartnet360/svelte-components' directly
15
15
  export { generateCells, generateCellsFromPreset, getGeneratorInfo, GENERATOR_PRESETS } from '../../shared/demo';
16
16
  // Configuration utilities
17
- export { DEFAULT_TECH_COLORS, DEFAULT_STATUS_COLORS, FBAND_COLORS, COLUMN_GROUPS, getAllColumns, getColumnsForPreset, getGroupHeaderFormatter, getColumnMetadata, getPresetVisibleFields, createTechFormatter, createStatusFormatter, createFbandFormatter, numberFormatter, coordinateFormatter, azimuthFormatter, heightFormatter } from './column-config';
17
+ export { DEFAULT_TECH_COLORS, DEFAULT_STATUS_COLORS, FBAND_COLORS, COLUMN_GROUPS, getAllColumns, getColumnsForPreset, getGroupHeaderFormatter, getColumnMetadata, getPresetVisibleFields, fbandSorter, cellNameSectorSorter, cellDataSorter, createTechFormatter, createStatusFormatter, createFbandFormatter, numberFormatter, coordinateFormatter, azimuthFormatter, heightFormatter } from './column-config';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartnet360/svelte-components",
3
- "version": "0.0.107",
3
+ "version": "0.0.108",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",