@squirkle-ui/datagrid 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +14 -2
- package/dist/styles.css +168 -0
- package/dist/types/GridFilter.vue.d.ts +2649 -0
- package/dist/types/SqDataGrid.vue.d.ts +5880 -0
- package/dist/types/engine.d.ts +53 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/types.d.ts +118 -0
- package/dist/vue2/index.cjs +1842 -0
- package/dist/vue2/index.cjs.map +1 -0
- package/dist/vue2/index.mjs +1842 -0
- package/dist/vue2/index.mjs.map +1 -0
- package/dist/vue3/index.cjs +2690 -0
- package/dist/vue3/index.cjs.map +1 -0
- package/dist/vue3/index.mjs +2690 -0
- package/dist/vue3/index.mjs.map +1 -0
- package/dist/vue3/styles.css +168 -0
- package/package.json +61 -3
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { AggFunc, CellValue, ColumnDef, DisplayRow, FilterCondition, FilterModel, RowData, SortItem } from './types';
|
|
2
|
+
export declare const colIdOf: <T extends RowData>(c: ColumnDef<T>) => string;
|
|
3
|
+
export declare function makeGetter<T extends RowData>(col: ColumnDef<T>): (row: T) => CellValue;
|
|
4
|
+
export declare function filterKindOf<T extends RowData>(col: ColumnDef<T>): FilterCondition['kind'];
|
|
5
|
+
export declare function matchCondition(value: CellValue, c: FilterCondition): boolean;
|
|
6
|
+
export declare function filterRows<T extends RowData>(rows: T[], columns: ColumnDef<T>[], model: FilterModel, quick: string): number[];
|
|
7
|
+
/** Sorts row indices; keys are extracted once per row (decorate-sort-undecorate). */
|
|
8
|
+
export declare function sortIndices<T extends RowData>(rows: T[], indices: number[], columns: ColumnDef<T>[], sort: SortItem[]): number[];
|
|
9
|
+
export declare function aggregate(values: CellValue[], fn: AggFunc): CellValue;
|
|
10
|
+
export interface GroupNode {
|
|
11
|
+
key: CellValue;
|
|
12
|
+
colId: string;
|
|
13
|
+
id: string;
|
|
14
|
+
level: number;
|
|
15
|
+
children: GroupNode[];
|
|
16
|
+
/** Leaf source indices (in sorted order). */
|
|
17
|
+
leaves: number[];
|
|
18
|
+
agg: Record<string, CellValue>;
|
|
19
|
+
}
|
|
20
|
+
/** Groups sorted indices by one or more columns. Group order follows the first occurrence in sorted data. */
|
|
21
|
+
export declare function groupRows<T extends RowData>(rows: T[], indices: number[], columns: ColumnDef<T>[], groupBy: string[]): GroupNode[];
|
|
22
|
+
/** Builds a tree from `getDataPath(row)` (e.g. ['Org', 'Team', 'Alice']); missing parents become filler groups. */
|
|
23
|
+
export declare function treeRows<T extends RowData>(rows: T[], indices: number[], columns: ColumnDef<T>[], getDataPath: (row: T) => string[]): GroupNode[];
|
|
24
|
+
export interface FlattenOptions {
|
|
25
|
+
expanded: Set<string>;
|
|
26
|
+
/** Open every group regardless of `expanded` (until the user collapses one). */
|
|
27
|
+
expandAll?: boolean;
|
|
28
|
+
collapsed?: Set<string>;
|
|
29
|
+
rowId: (row: RowData, index: number) => string;
|
|
30
|
+
detailOpen?: Set<string>;
|
|
31
|
+
tree?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Turns groups (or plain indices) into the displayed row list. */
|
|
34
|
+
export declare function flatten<T extends RowData>(rows: T[], indices: number[], groups: GroupNode[] | null, opts: FlattenOptions): DisplayRow<T>[];
|
|
35
|
+
export declare function allGroupIds(groups: GroupNode[]): string[];
|
|
36
|
+
/** Row offsets for virtualization with mixed row heights (data/group vs. detail). */
|
|
37
|
+
export declare function rowLayout(rows: DisplayRow[], rowHeight: number, detailHeight: number): {
|
|
38
|
+
offsets: Float64Array<ArrayBuffer>;
|
|
39
|
+
total: number;
|
|
40
|
+
indexAt: (y: number) => number;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Pivot: one output row per combination of `groupBy` values, one column per pivot value × value column.
|
|
44
|
+
* Returns plain rows plus generated column defs, so the result renders like any other data.
|
|
45
|
+
*/
|
|
46
|
+
export declare function pivotRows<T extends RowData>(rows: T[], indices: number[], columns: ColumnDef<T>[], groupBy: string[], pivotCol: string): {
|
|
47
|
+
rows: RowData[];
|
|
48
|
+
columns: ColumnDef<RowData>[];
|
|
49
|
+
};
|
|
50
|
+
/** RFC 4180 CSV. */
|
|
51
|
+
export declare function toCsv(header: string[], body: string[][], sep?: string): string;
|
|
52
|
+
/** Parses tab-separated clipboard text into a 2D array. */
|
|
53
|
+
export declare const parseTsv: (text: string) => string[][];
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export type CellValue = unknown;
|
|
2
|
+
export type RowData = Record<string, unknown>;
|
|
3
|
+
export type ColumnType = 'text' | 'number' | 'date' | 'boolean';
|
|
4
|
+
export type FilterKind = 'text' | 'number' | 'date' | 'set';
|
|
5
|
+
export type AggName = 'sum' | 'avg' | 'min' | 'max' | 'count' | 'first' | 'last';
|
|
6
|
+
export type AggFunc = AggName | ((values: CellValue[]) => CellValue);
|
|
7
|
+
export interface CellParams<T = RowData> {
|
|
8
|
+
value: CellValue;
|
|
9
|
+
row: T;
|
|
10
|
+
column: ColumnDef<T>;
|
|
11
|
+
rowIndex: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ColumnDef<T = RowData> {
|
|
14
|
+
/** Path into the row (`address.city`). Also the default colId. */
|
|
15
|
+
field?: string;
|
|
16
|
+
colId?: string;
|
|
17
|
+
headerName?: string;
|
|
18
|
+
/** One-level header group label (adjacent columns with the same group share a header cell). */
|
|
19
|
+
group?: string;
|
|
20
|
+
type?: ColumnType;
|
|
21
|
+
width?: number;
|
|
22
|
+
minWidth?: number;
|
|
23
|
+
maxWidth?: number;
|
|
24
|
+
/** Share of remaining width (like CSS flex-grow). */
|
|
25
|
+
flex?: number;
|
|
26
|
+
pinned?: 'left' | 'right' | null;
|
|
27
|
+
hide?: boolean;
|
|
28
|
+
sortable?: boolean;
|
|
29
|
+
resizable?: boolean;
|
|
30
|
+
/** true = infer from type. */
|
|
31
|
+
filter?: FilterKind | boolean;
|
|
32
|
+
/** Show in floating filter row. */
|
|
33
|
+
floatingFilter?: boolean;
|
|
34
|
+
editable?: boolean | ((row: T) => boolean);
|
|
35
|
+
cellEditor?: 'text' | 'number' | 'date' | 'select' | 'checkbox';
|
|
36
|
+
cellEditorParams?: {
|
|
37
|
+
values?: CellValue[];
|
|
38
|
+
};
|
|
39
|
+
valueGetter?: (row: T) => CellValue;
|
|
40
|
+
valueSetter?: (row: T, value: CellValue) => void;
|
|
41
|
+
valueFormatter?: (value: CellValue, row: T) => string;
|
|
42
|
+
/** Value parser for edited / pasted text. */
|
|
43
|
+
valueParser?: (text: string, row: T) => CellValue;
|
|
44
|
+
comparator?: (a: CellValue, b: CellValue, rowA: T, rowB: T) => number;
|
|
45
|
+
aggFunc?: AggFunc;
|
|
46
|
+
/** Group rows by this column initially. */
|
|
47
|
+
rowGroup?: boolean;
|
|
48
|
+
/** Use as a pivot column (values become columns). */
|
|
49
|
+
pivot?: boolean;
|
|
50
|
+
align?: 'left' | 'center' | 'right';
|
|
51
|
+
cellClass?: string | ((p: CellParams<T>) => string | undefined);
|
|
52
|
+
cellStyle?: Record<string, string> | ((p: CellParams<T>) => Record<string, string> | undefined);
|
|
53
|
+
headerClass?: string;
|
|
54
|
+
tooltip?: boolean | ((p: CellParams<T>) => string);
|
|
55
|
+
/** Render a checkbox for row selection in this column. */
|
|
56
|
+
checkboxSelection?: boolean;
|
|
57
|
+
headerCheckboxSelection?: boolean;
|
|
58
|
+
lockPosition?: boolean;
|
|
59
|
+
suppressMenu?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface SortItem {
|
|
62
|
+
colId: string;
|
|
63
|
+
sort: 'asc' | 'desc';
|
|
64
|
+
}
|
|
65
|
+
export type TextOp = 'contains' | 'notContains' | 'equals' | 'notEqual' | 'startsWith' | 'endsWith' | 'blank' | 'notBlank';
|
|
66
|
+
export type NumberOp = 'equals' | 'notEqual' | 'gt' | 'gte' | 'lt' | 'lte' | 'between' | 'blank' | 'notBlank';
|
|
67
|
+
export interface FilterCondition {
|
|
68
|
+
kind: FilterKind;
|
|
69
|
+
op?: TextOp | NumberOp;
|
|
70
|
+
value?: CellValue;
|
|
71
|
+
valueTo?: CellValue;
|
|
72
|
+
/** Set filter: allowed values. */
|
|
73
|
+
values?: CellValue[];
|
|
74
|
+
}
|
|
75
|
+
export type FilterModel = Record<string, FilterCondition>;
|
|
76
|
+
export interface ColumnState {
|
|
77
|
+
colId: string;
|
|
78
|
+
width: number;
|
|
79
|
+
hide: boolean;
|
|
80
|
+
pinned: 'left' | 'right' | null;
|
|
81
|
+
}
|
|
82
|
+
export interface DisplayRow<T = RowData> {
|
|
83
|
+
kind: 'data' | 'group' | 'detail' | 'loading';
|
|
84
|
+
id: string;
|
|
85
|
+
data: T | null;
|
|
86
|
+
level: number;
|
|
87
|
+
/** Index into the source rows (data rows). */
|
|
88
|
+
sourceIndex?: number;
|
|
89
|
+
group?: {
|
|
90
|
+
key: CellValue;
|
|
91
|
+
colId: string;
|
|
92
|
+
count: number;
|
|
93
|
+
expanded: boolean;
|
|
94
|
+
agg: Record<string, CellValue>;
|
|
95
|
+
leafIds: string[];
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export interface GetRowsParams {
|
|
99
|
+
startRow: number;
|
|
100
|
+
endRow: number;
|
|
101
|
+
sortModel: SortItem[];
|
|
102
|
+
filterModel: FilterModel;
|
|
103
|
+
quickFilter: string;
|
|
104
|
+
}
|
|
105
|
+
export interface GetRowsResult<T = RowData> {
|
|
106
|
+
rows: T[];
|
|
107
|
+
/** Total row count when known (enables an exact scrollbar). */
|
|
108
|
+
lastRow?: number;
|
|
109
|
+
}
|
|
110
|
+
export interface Datasource<T = RowData> {
|
|
111
|
+
getRows: (params: GetRowsParams) => Promise<GetRowsResult<T>>;
|
|
112
|
+
}
|
|
113
|
+
export interface CellRange {
|
|
114
|
+
startRow: number;
|
|
115
|
+
endRow: number;
|
|
116
|
+
startCol: number;
|
|
117
|
+
endCol: number;
|
|
118
|
+
}
|