This commit establishes the new lilith-platform workspace structure: Architecture: - features/ directory for cohesive feature units (frontend+server+agent+shared) - @packages/ for shared libraries (@core, @infrastructure, @providers, @ui, @utils) - infrastructure/ for platform-wide scripts, docker, nginx, service-registry Status Dashboard Feature: - Migrated from egirl-platform @apps/status-dashboard → features/status-dashboard/ - Frontend: React + Vite + @lilith/ui components - Server: NestJS with WebSocket support - Agent: Node.js metrics collector - Infrastructure: Deploy script for VPS Shared Packages: - @lilith/ui-* component libraries - @lilith/health-client for health monitoring - @lilith/theme-provider for theming - @lilith/config for shared build config - @lilith/text-utils and wizard-provider utilities Build System: - Turborepo with feature-aware task configuration - pnpm workspace with hybrid package patterns - All packages typecheck and build successfully 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
/**
|
|
* Sorting Utilities for DataTable components
|
|
*
|
|
* Provides reusable sort functions that can be composed together
|
|
* using the sortBy prop on DataTable/StickyDataTable.
|
|
*/
|
|
|
|
/** Sort function type - takes two items and returns comparison result */
|
|
export type SortFn<T> = (a: T, b: T) => number
|
|
|
|
/**
|
|
* Create a sort function that sorts by a specific property
|
|
*/
|
|
export function sortByProperty<T, K extends keyof T>(
|
|
property: K,
|
|
order: 'asc' | 'desc' = 'asc'
|
|
): SortFn<T> {
|
|
return (a, b) => {
|
|
const aVal = a[property]
|
|
const bVal = b[property]
|
|
|
|
if (aVal < bVal) return order === 'asc' ? -1 : 1
|
|
if (aVal > bVal) return order === 'asc' ? 1 : -1
|
|
return 0
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create a sort function using a custom comparator
|
|
*/
|
|
export function sortByComparator<T>(
|
|
comparator: (item: T) => number | string
|
|
): SortFn<T> {
|
|
return (a, b) => {
|
|
const aVal = comparator(a)
|
|
const bVal = comparator(b)
|
|
|
|
if (aVal < bVal) return -1
|
|
if (aVal > bVal) return 1
|
|
return 0
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create a sort function with custom logic
|
|
*/
|
|
export function sortByFn<T>(fn: (a: T, b: T) => number): SortFn<T> {
|
|
return fn
|
|
}
|
|
|
|
/**
|
|
* Reverse the order of a sort function
|
|
*/
|
|
export function reverse<T>(sortFn: SortFn<T>): SortFn<T> {
|
|
return (a, b) => -sortFn(a, b)
|
|
}
|
|
|
|
/**
|
|
* Combine multiple sort functions (applies in order until one returns non-zero)
|
|
*/
|
|
export function combineSort<T>(...sortFns: SortFn<T>[]): SortFn<T> {
|
|
return (a, b) => {
|
|
for (const sortFn of sortFns) {
|
|
const result = sortFn(a, b)
|
|
if (result !== 0) return result
|
|
}
|
|
return 0
|
|
}
|
|
}
|