@smartnet360/svelte-components 0.0.107 → 0.0.109

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,16 +85,14 @@
79
85
  resizableColumns: resizableColumns,
80
86
  movableColumns: movableColumns,
81
87
 
82
- // Sorting
83
- initialSort: [{ column: 'siteId', dir: 'asc' }],
88
+ // No initialSort - data is pre-sorted by cellDataSorter (tech → fband → sector)
84
89
 
85
90
  // Row selection
86
91
  selectable: selectable ? (multiSelect ? true : 1) : false,
87
92
  selectableRangeMode: 'click',
88
93
 
89
- // Persistence
94
+ // Persistence - disable sort persistence to preserve pre-sorted order
90
95
  persistence: persistLayout ? {
91
- sort: true,
92
96
  filter: true,
93
97
  columns: ['width', 'visible'],
94
98
  } : false,
@@ -193,19 +197,19 @@
193
197
 
194
198
  // Update table data when cells actually change (not just reference)
195
199
  $effect(() => {
196
- const currentLength = cells?.length ?? 0;
197
- const currentFirstId = cells?.[0]?.id ?? null;
200
+ const currentLength = sortedCells?.length ?? 0;
201
+ const currentFirstId = sortedCells?.[0]?.id ?? null;
198
202
 
199
203
  // Only update if length or first item changed (rough equality check)
200
204
  if (isInitialized && table &&
201
205
  (currentLength !== prevCellsLength || currentFirstId !== prevCellsFirstId)) {
202
206
  prevCellsLength = currentLength;
203
207
  prevCellsFirstId = currentFirstId;
204
- table.replaceData(cells);
208
+ table.replaceData(sortedCells);
205
209
  ondatachange?.({
206
210
  type: 'load',
207
- rowCount: cells.length,
208
- filteredCount: cells.length
211
+ rowCount: sortedCells.length,
212
+ filteredCount: sortedCells.length
209
213
  });
210
214
  }
211
215
  });
@@ -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.109",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",