cellux 0.0.1 → 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/dist/TyeaheadEditor.d.ts +36 -0
- package/dist/TyeaheadEditor.d.ts.map +1 -0
- package/dist/asserts.d.ts +16 -0
- package/dist/asserts.d.ts.map +1 -0
- package/dist/cellux.css +1 -0
- package/dist/cellux.mjs +2703 -0
- package/dist/cellux.umd.js +134 -0
- package/dist/column-state.d.ts +9 -0
- package/dist/column-state.d.ts.map +1 -0
- package/dist/column-tab-builder.d.ts +17 -0
- package/dist/column-tab-builder.d.ts.map +1 -0
- package/dist/column-tab-container.d.ts +13 -0
- package/dist/column-tab-container.d.ts.map +1 -0
- package/dist/column.d.ts +81 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/console-log.d.ts +12 -0
- package/dist/console-log.d.ts.map +1 -0
- package/dist/context-menu.d.ts +11 -0
- package/dist/context-menu.d.ts.map +1 -0
- package/dist/data-dash.d.ts +8 -0
- package/dist/data-dash.d.ts.map +1 -0
- package/dist/date-time-picker.d.ts +17 -0
- package/dist/date-time-picker.d.ts.map +1 -0
- package/dist/debug-overlay/debug-overlay.d.ts +24 -0
- package/dist/debug-overlay/debug-overlay.d.ts.map +1 -0
- package/dist/enums.d.ts +6 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/event-maps.d.ts +24 -0
- package/dist/event-maps.d.ts.map +1 -0
- package/dist/events.d.ts +40 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/filter.d.ts +17 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/grid-api.d.ts +28 -0
- package/dist/grid-api.d.ts.map +1 -0
- package/dist/grid-assertions.d.ts +33 -0
- package/dist/grid-assertions.d.ts.map +1 -0
- package/dist/grid-assertions.test.d.ts +1 -0
- package/dist/grid-assertions.test.d.ts.map +1 -0
- package/dist/grid-class-name.d.ts +32 -0
- package/dist/grid-class-name.d.ts.map +1 -0
- package/dist/grid-options.d.ts +25 -0
- package/dist/grid-options.d.ts.map +1 -0
- package/dist/grid-row-ref.d.ts +12 -0
- package/dist/grid-row-ref.d.ts.map +1 -0
- package/dist/grid.d.ts +159 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/interfaces.d.ts +105 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/quick-filter.d.ts +12 -0
- package/dist/quick-filter.d.ts.map +1 -0
- package/dist/renderer.d.ts +83 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/select-editor-custom.d.ts +26 -0
- package/dist/select-editor-custom.d.ts.map +1 -0
- package/dist/select-editor.d.ts +11 -0
- package/dist/select-editor.d.ts.map +1 -0
- package/dist/sorting.d.ts +19 -0
- package/dist/sorting.d.ts.map +1 -0
- package/dist/status-bar.d.ts +11 -0
- package/dist/status-bar.d.ts.map +1 -0
- package/dist/text-editor.d.ts +13 -0
- package/dist/text-editor.d.ts.map +1 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utilities/formatter.d.ts +4 -0
- package/dist/utilities/formatter.d.ts.map +1 -0
- package/dist/utilities/utilities.d.ts +241 -0
- package/dist/utilities/utilities.d.ts.map +1 -0
- package/package.json +28 -16
- package/README.md +0 -11
- package/files.zip +0 -0
- package/index.d.ts +0 -4
- package/index.js +0 -4
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CellEditorParams, ICellEditor } from "./interfaces";
|
|
2
|
+
import { TableData } from "./types";
|
|
3
|
+
export declare class SelectEditorCustom<T extends TableData> implements ICellEditor<T> {
|
|
4
|
+
private container;
|
|
5
|
+
private input;
|
|
6
|
+
private dropdown;
|
|
7
|
+
private initialValue;
|
|
8
|
+
private commitInProgress;
|
|
9
|
+
private selectedIndex;
|
|
10
|
+
private options;
|
|
11
|
+
private documentClickHandler;
|
|
12
|
+
private _stopEditing?;
|
|
13
|
+
init(params: CellEditorParams<T>): HTMLElement;
|
|
14
|
+
private toggleDropdown;
|
|
15
|
+
private showDropdown;
|
|
16
|
+
private hideDropdown;
|
|
17
|
+
private selectOption;
|
|
18
|
+
private setSelectedIndex;
|
|
19
|
+
private updateSelectedStyle;
|
|
20
|
+
private handleKeyDown;
|
|
21
|
+
private moveSelection;
|
|
22
|
+
getValue(): any;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
isPopup(): boolean;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=select-editor-custom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-editor-custom.d.ts","sourceRoot":"","sources":["../src/cellux/select-editor-custom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,qBAAa,kBAAkB,CAAC,CAAC,SAAS,SAAS,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IAC5E,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,oBAAoB,CAA2B;IACvD,OAAO,CAAC,YAAY,CAAC,CAAa;IAElC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,WAAW;IA8I9C,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,aAAa;IA+CrB,OAAO,CAAC,aAAa;IAcrB,QAAQ,IAAI,GAAG;IAIf,OAAO;IAmBP,OAAO,IAAI,OAAO;CAMnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CellEditorParams, ICellEditor } from "./interfaces";
|
|
2
|
+
import { TableData } from "./types";
|
|
3
|
+
export declare class SelectEditor<T extends TableData> implements ICellEditor<T> {
|
|
4
|
+
private select;
|
|
5
|
+
private initialValue;
|
|
6
|
+
private commitInProgress;
|
|
7
|
+
init(params: CellEditorParams<T>): HTMLElement;
|
|
8
|
+
getValue(): any;
|
|
9
|
+
destroy(): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=select-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-editor.d.ts","sourceRoot":"","sources":["../src/cellux/select-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,qBAAa,YAAY,CAAE,CAAC,SAAS,SAAS,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,gBAAgB,CAAS;IAEjC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,WAAW;IAiE9C,QAAQ,IAAI,GAAG;IAIf,OAAO;CAIR"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SortDirection } from "./column";
|
|
2
|
+
import { Grid } from "./grid";
|
|
3
|
+
import { SortItem } from "./interfaces";
|
|
4
|
+
import { TableData } from "./types";
|
|
5
|
+
export declare class Sort<T extends TableData> {
|
|
6
|
+
private _grid;
|
|
7
|
+
sortModelArray: SortItem[];
|
|
8
|
+
constructor(_grid: Grid<T>);
|
|
9
|
+
updateSortModel: (field: string, shiftKey?: boolean) => void;
|
|
10
|
+
onSortChanged(sortModelArray: SortItem[]): void;
|
|
11
|
+
applySort(): void;
|
|
12
|
+
prepareFilteredSort(): void;
|
|
13
|
+
private sortRows;
|
|
14
|
+
compare: (a: unknown, b: unknown, dir: SortDirection) => number;
|
|
15
|
+
updateHeaderSortIndicators(): void;
|
|
16
|
+
private _updateHeaderSortIndicators;
|
|
17
|
+
getNodeList(): NodeListOf<HTMLElement>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=sorting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorting.d.ts","sourceRoot":"","sources":["../src/cellux/sorting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,MAAM,UAAU,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKpC,qBAAa,IAAI,CAAC,CAAC,SAAS,SAAS;IAKrB,OAAO,CAAC,KAAK;IAFzB,cAAc,EAAE,QAAQ,EAAE,CAAM;gBAEZ,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAWlC,eAAe,8CAqDb;IAEF,aAAa,CAAC,cAAc,EAAE,QAAQ,EAAE;IASxC,SAAS,IAAI,IAAI;IASjB,mBAAmB,IAAI,IAAI;IAS3B,OAAO,CAAC,QAAQ;IAuBhB,OAAO,yDAoBL;IAGF,0BAA0B,IAAI,IAAI;IAYlC,OAAO,CAAC,2BAA2B;IAoCnC,WAAW,IAAK,UAAU,CAAC,WAAW,CAAC;CAM1C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Grid } from "./grid";
|
|
2
|
+
export declare class StatusBar<T extends Record<string, any>> {
|
|
3
|
+
private _grid;
|
|
4
|
+
private rootEl;
|
|
5
|
+
private _statusBarEl;
|
|
6
|
+
constructor(_grid: Grid<T>, rootEl: HTMLElement);
|
|
7
|
+
destroy(): void;
|
|
8
|
+
updateRowsPanel(): void;
|
|
9
|
+
get statusBarEl(): HTMLElement | null;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=status-bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-bar.d.ts","sourceRoot":"","sources":["../src/cellux/status-bar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,qBAAa,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIpC,OAAO,CAAC,KAAK;IAAW,OAAO,CAAC,MAAM;IAFlD,OAAO,CAAC,YAAY,CAA4B;gBAE5B,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAU,MAAM,EAAE,WAAW;IAGvD,OAAO;IAIR,eAAe,IAAI,IAAI;IAiB9B,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAA6B;CAI5E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ICellEditor, CellEditorParams } from "./interfaces";
|
|
2
|
+
import { TableData } from "./types";
|
|
3
|
+
export declare class TextEditor<T extends TableData> implements ICellEditor<T> {
|
|
4
|
+
private params;
|
|
5
|
+
private input;
|
|
6
|
+
constructor(params: CellEditorParams<T>);
|
|
7
|
+
init(): any;
|
|
8
|
+
getGui(): HTMLElement;
|
|
9
|
+
getValue(): any;
|
|
10
|
+
afterGuiAttached(): void;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=text-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-editor.d.ts","sourceRoot":"","sources":["../src/cellux/text-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,qBAAa,UAAU,CAAC,CAAC,SAAS,SAAS,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IAGtD,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,KAAK,CAAmB;gBAEZ,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAU5C,IAAI,IAAI,GAAG;IASd,MAAM,IAAI,WAAW;IAIrB,QAAQ,IAAI,GAAG;IAIf,gBAAgB,IAAI,IAAI;IAIxB,OAAO;CAGV"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ColumnDef } from "./column";
|
|
2
|
+
export declare type DragOffset = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
export declare type EditingCell<T extends TableData> = {
|
|
7
|
+
cell: HTMLElement;
|
|
8
|
+
colDef: ColumnDef<T>;
|
|
9
|
+
rowData: T;
|
|
10
|
+
arrayIndex: number;
|
|
11
|
+
rowIndex: number;
|
|
12
|
+
originalValue: any;
|
|
13
|
+
customEditor: any;
|
|
14
|
+
};
|
|
15
|
+
export declare type TableData = Record<string, any>;
|
|
16
|
+
export declare type GridState = {
|
|
17
|
+
scrollTop: number;
|
|
18
|
+
viewportHeight: number;
|
|
19
|
+
rowHeight: number;
|
|
20
|
+
rowBuffer: number;
|
|
21
|
+
totalRows: number;
|
|
22
|
+
};
|
|
23
|
+
export declare type ComputeRenderedRowCountReturn = {
|
|
24
|
+
firstRenderedRowIndex: number;
|
|
25
|
+
lastRenderedRowIndex: number;
|
|
26
|
+
renderedRowCount: number;
|
|
27
|
+
firstVisibleRowIndex: number;
|
|
28
|
+
lastVisibleRowIndex: number;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/cellux/types.ts"],"names":[],"mappings":"AAEC,OAAO,EAAE,SAAS,EAAE,MAAK,UAAU,CAAA;AAEpC,oBAAY,UAAU,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjD,oBAAY,WAAW,CAAC,CAAC,SAAS,SAAS,IAAI;IAC7C,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,GAAG,CAAC;IACnB,YAAY,EAAE,GAAG,CAAC;CACnB,CAAA;AAED,oBAAY,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE5C,oBAAY,SAAS,GAAG;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAC;AAEF,oBAAY,6BAA6B,GAAG;IAC1C,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAA;CAC5B,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const formatMoney: (value: number, currency?: string, locale?: string) => string;
|
|
2
|
+
export declare const formatDate: (value: string | Date, locale?: string) => string;
|
|
3
|
+
export declare const formatNumber: (value: number, decimals?: number, locale?: string) => string;
|
|
4
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/cellux/utilities/formatter.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,WAAW,+DAOvB,CAAC;AAEF,eAAO,MAAM,UAAU,mDAEtB,CAAC;AAEF,eAAO,MAAM,YAAY,+DAKxB,CAAC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { ColumnDef } from '../column';
|
|
2
|
+
import { Grid } from '../grid';
|
|
3
|
+
import { Renderer } from '../renderer';
|
|
4
|
+
import { ComputeRenderedRowCountReturn, GridState, TableData } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Returns true if the input is a function.
|
|
7
|
+
* Useful for distinguishing between callback functions and static values
|
|
8
|
+
* in column definitions (e.g. cellStyle, cellClass, editable).
|
|
9
|
+
*
|
|
10
|
+
* @param input - Any value to test
|
|
11
|
+
* @returns Type predicate narrowing input to Function
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* if (isFunction(col.cellStyle)) {
|
|
15
|
+
* const styles = col.cellStyle(payload);
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
export declare function isFunction(input: any): input is Function;
|
|
19
|
+
/**
|
|
20
|
+
* Calculates which rows should be rendered for virtual scrolling.
|
|
21
|
+
*
|
|
22
|
+
* Determines the window of rows to render based on current scroll position and viewport height.
|
|
23
|
+
* Includes buffer rows above and below the visible area to reduce flicker during scrolling.
|
|
24
|
+
* The rendered row count remains constant in the middle of the dataset but decreases near
|
|
25
|
+
* the top (no buffer above row 0) and bottom (no buffer past last row).
|
|
26
|
+
*
|
|
27
|
+
* @param currentState - Current grid state including scroll position, viewport dimensions, and buffer size
|
|
28
|
+
* @param derivedIndices - Array of row indices after sorting/filtering (may differ from original order)
|
|
29
|
+
* @returns Object containing:
|
|
30
|
+
* - firstRenderedRowIndex: Index to start rendering from (includes top buffer)
|
|
31
|
+
* - lastRenderedRowIndex: Index to stop rendering at (includes bottom buffer, clipped at dataset end)
|
|
32
|
+
* - firstVisibleRowIndex: Index of first actually visible row (excludes top buffer)
|
|
33
|
+
* - lastVisibleRowIndex: Index of last actually visible row (excludes bottom buffer)
|
|
34
|
+
* - renderedRowCount: Total number of rows to render (visible + buffers, decreases at edges)
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // With viewport showing 15 rows, buffer of 3, scrolled to middle of 100 rows:
|
|
38
|
+
* // Returns: { firstRenderedRowIndex: 7, lastRenderedRowIndex: 27,
|
|
39
|
+
* // firstVisibleRowIndex: 10, renderedRowCount: 21 }
|
|
40
|
+
* // (3 buffer + 15 visible + 3 buffer = 21 total)
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Near bottom with only 30 total rows, scrolled to end:
|
|
44
|
+
* // Returns: { firstRenderedRowIndex: 12, lastRenderedRowIndex: 29,
|
|
45
|
+
* // firstVisibleRowIndex: 15, renderedRowCount: 18 }
|
|
46
|
+
* // (3 buffer + 15 visible + 0 buffer = 18, can't render past row 29)
|
|
47
|
+
*/
|
|
48
|
+
export declare function computeRenderedRowCount(currentState: GridState, derivedIndices: number[]): ComputeRenderedRowCountReturn;
|
|
49
|
+
/**
|
|
50
|
+
* Converts an array of column widths into a CSS grid-template-columns string.
|
|
51
|
+
*
|
|
52
|
+
* Transforms mixed width values (numbers and CSS strings) into a space-separated
|
|
53
|
+
* string suitable for the CSS `grid-template-columns` property. Numbers are
|
|
54
|
+
* converted to pixel values, while string values are validated and passed through.
|
|
55
|
+
*
|
|
56
|
+
* @param cols - Array of column widths. Numbers represent pixels, strings can be
|
|
57
|
+
* any valid CSS width value (e.g., '1fr', '200px', 'minmax(100px, 1fr)')
|
|
58
|
+
* @returns Space-separated string of width values for CSS grid
|
|
59
|
+
* @throws Error if:
|
|
60
|
+
* - Numeric width is not finite or is negative
|
|
61
|
+
* - String width is empty after trimming
|
|
62
|
+
* - String width contains whitespace (ensures token count matches column count)
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* convertWidthArray([200, '1fr', 150, 'minmax(100px, 300px)'])
|
|
66
|
+
* // Returns: "200px 1fr 150px minmax(100px, 300px)"
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Used to update CSS custom property
|
|
70
|
+
* const gridTemplate = convertWidthArray(columnWidths);
|
|
71
|
+
* element.style.setProperty('--grid-columns', gridTemplate);
|
|
72
|
+
*/
|
|
73
|
+
export declare function convertWidthArrayToString(cols: readonly (string | number)[]): string;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the column index of a cell element within its row.
|
|
76
|
+
*
|
|
77
|
+
* Traverses up from any element within a cell to find the closest grid cell,
|
|
78
|
+
* then determines its zero-based position among its sibling cells (which represent columns).
|
|
79
|
+
*
|
|
80
|
+
* @param el - Any HTML element within or representing a grid cell
|
|
81
|
+
* @returns The zero-based column index, or null if:
|
|
82
|
+
* - Element is not within a grid cell
|
|
83
|
+
* - Cell has no parent row
|
|
84
|
+
* - Cell is not found among parent's children
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* const colIndex = getColumnIndex(event.target as HTMLElement);
|
|
88
|
+
* if (colIndex !== null) {
|
|
89
|
+
* const column = columnDefs[colIndex];
|
|
90
|
+
* }
|
|
91
|
+
*/
|
|
92
|
+
export declare function getColumnIndex(el: Readonly<HTMLElement>): number | null;
|
|
93
|
+
/**
|
|
94
|
+
* Gets the array index from a grid row element.
|
|
95
|
+
*
|
|
96
|
+
* Traverses up from any element within a row to find the closest grid row,
|
|
97
|
+
* then extracts its `data-array-index` attribute. This index corresponds to the
|
|
98
|
+
* position in the original rowData array, which remains stable even when the grid
|
|
99
|
+
* is sorted or filtered (unlike the visual row index which changes with sort/filter).
|
|
100
|
+
*
|
|
101
|
+
* @param el - Any HTML element within or representing a grid row
|
|
102
|
+
* @returns The zero-based array index, or null if:
|
|
103
|
+
* - Element is not within a grid row
|
|
104
|
+
* - Row has no data-array-index attribute
|
|
105
|
+
* - Attribute value is not a valid number
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const arrayIndex = getArrayIndex(cellElement);
|
|
109
|
+
* if (arrayIndex !== null) {
|
|
110
|
+
* const data = rowData[arrayIndex];
|
|
111
|
+
* }
|
|
112
|
+
*/
|
|
113
|
+
export declare function getArrayIndex(el: Readonly<HTMLElement>): number | null;
|
|
114
|
+
/**
|
|
115
|
+
* Retrieves the data object for a grid row element.
|
|
116
|
+
*
|
|
117
|
+
* Convenience wrapper around getArrayIndex() that also performs the rowData lookup.
|
|
118
|
+
* Uses the stable array index (not the visual row index) so it works correctly
|
|
119
|
+
* when the grid is sorted or filtered.
|
|
120
|
+
*
|
|
121
|
+
* @param el - Any HTML element within or representing a grid row
|
|
122
|
+
* @param rowData - The grid's complete data array
|
|
123
|
+
* @returns The data object for this row
|
|
124
|
+
* @throws Error if element is not within a valid grid row, or if rowData lookup fails
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* const data = getRowData(event.target as HTMLElement, rowData);
|
|
128
|
+
* console.log(data.name, data.age);
|
|
129
|
+
*/
|
|
130
|
+
export declare function getRowData<T>(el: Readonly<HTMLElement>, rowData: Readonly<T[]>): T;
|
|
131
|
+
/**
|
|
132
|
+
* Builds a ColumnCallbackPayload from a DOM event and cell element.
|
|
133
|
+
*
|
|
134
|
+
* Resolves the column definition, row data, and index information needed
|
|
135
|
+
* for column callbacks (onCellClicked, onCellValueChanged, etc.) by walking
|
|
136
|
+
* the DOM from the cell element up to its parent row.
|
|
137
|
+
*
|
|
138
|
+
* All failure conditions throw — if this function returns, the payload is guaranteed
|
|
139
|
+
* to be fully populated and valid.
|
|
140
|
+
*
|
|
141
|
+
* @param e - The originating mouse or keyboard event
|
|
142
|
+
* @param cellEl - The grid cell element that was interacted with
|
|
143
|
+
* @param columns - The current column definitions array
|
|
144
|
+
* @param rowData - The grid's complete data array
|
|
145
|
+
* @returns A fully populated ColumnCallbackPayload
|
|
146
|
+
* @throws Error if cellEl is null, row element not found, column index invalid,
|
|
147
|
+
* column definition missing, or row data missing
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* const payload = getColumnCallbackPayload(event, cellEl, columnDefs, rowData);
|
|
151
|
+
* column.onCellClicked?.(payload);
|
|
152
|
+
*/
|
|
153
|
+
export declare function getColumnCallbackPayload<T extends TableData>(e: MouseEvent | KeyboardEvent, cellEl: HTMLElement, columns: ColumnDef<T>[], rowData: T[]): any;
|
|
154
|
+
/**
|
|
155
|
+
* Determines whether a cell is editable given its column definition and event payload.
|
|
156
|
+
*
|
|
157
|
+
* Handles both static boolean and callback forms of the `editable` column property.
|
|
158
|
+
* Returns false if `editable` is not defined on the column.
|
|
159
|
+
*
|
|
160
|
+
* @param column - The column definition to check
|
|
161
|
+
* @param payload - The cell event payload, passed to the editable callback if it's a function
|
|
162
|
+
* @returns true if the cell should allow editing, false otherwise
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* // Static: all cells in this column are editable
|
|
166
|
+
* { field: 'name', editable: true }
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* // Callback: only editable for certain rows
|
|
170
|
+
* { field: 'status', editable: (payload) => payload.data.isActive }
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
173
|
+
* Soft-normalizes a string value for safe storage and comparison.
|
|
174
|
+
*
|
|
175
|
+
* Cleans up invisible and problematic Unicode characters that can silently
|
|
176
|
+
* corrupt string comparisons or sneak in from pasted content (PDFs, web pages, etc.)
|
|
177
|
+
* without altering the visible content or collapsing internal whitespace.
|
|
178
|
+
*
|
|
179
|
+
* Removes:
|
|
180
|
+
* - Non-breaking spaces (converted to regular space)
|
|
181
|
+
* - Zero-width spaces and joiners
|
|
182
|
+
* - BOM characters
|
|
183
|
+
* - Bidirectional control characters (common in RTL text and PDF exports)
|
|
184
|
+
* - ASCII control characters (preserves tab, CR, LF)
|
|
185
|
+
*
|
|
186
|
+
* @param v - Any value; non-strings are coerced via String(), null/undefined become ''
|
|
187
|
+
* @returns Cleaned string with ends trimmed
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* normalizeTextSoft(' hello\u00A0world ') // 'hello world'
|
|
191
|
+
* normalizeTextSoft(null) // ''
|
|
192
|
+
* normalizeTextSoft(42) // '42'
|
|
193
|
+
*/
|
|
194
|
+
export declare function normalizeTextSoft(v: unknown): string;
|
|
195
|
+
/**
|
|
196
|
+
* Hard-normalizes a string value by applying soft normalization and then
|
|
197
|
+
* collapsing all internal whitespace runs to a single space.
|
|
198
|
+
*
|
|
199
|
+
* Use for simple text columns where multi-line or multi-space content from
|
|
200
|
+
* paste operations is never intentional. More aggressive than normalizeTextSoft —
|
|
201
|
+
* internal newlines and tab characters will be collapsed.
|
|
202
|
+
*
|
|
203
|
+
* @param v - Any value; non-strings are coerced via String(), null/undefined become ''
|
|
204
|
+
* @returns Cleaned string with all whitespace runs collapsed and ends trimmed
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* normalizeTextHard('hello world') // 'hello world'
|
|
208
|
+
* normalizeTextHard('hello\n\nworld') // 'hello world'
|
|
209
|
+
* normalizeTextHard(' lots of space ') // 'lots of space'
|
|
210
|
+
*/
|
|
211
|
+
export declare function normalizeTextHard(v: unknown): string;
|
|
212
|
+
export declare function getContainerEl(): Element | undefined | null;
|
|
213
|
+
export declare function getHeaderEl(): Element | undefined | null;
|
|
214
|
+
export declare function getHeaderInnerEl(): Element | undefined | null;
|
|
215
|
+
export declare function printHeaderDom(): void;
|
|
216
|
+
export declare function getColumnIndexOnlyFromFieldName<T = any>(field: string, renderer: Renderer<any>): number;
|
|
217
|
+
export declare function getColumnIndexFromFieldName<T = any>(field: string, renderer: Renderer<any>): {
|
|
218
|
+
colIndex: number;
|
|
219
|
+
isLeft: boolean;
|
|
220
|
+
};
|
|
221
|
+
export declare function reComputeColDefs<T extends TableData>(renderer: Renderer<T>): void;
|
|
222
|
+
export declare function getFieldFromHeaderCell(el: HTMLElement): string | null;
|
|
223
|
+
export declare function getColIndexFromHeaderCell(el: HTMLElement): number | null;
|
|
224
|
+
export declare function getColumnFromHeaderCell<T extends TableData>(headerEl: HTMLElement, grid: Grid<T>): ColumnDef<T> | null | undefined;
|
|
225
|
+
export declare function getRowFromCell(cellEl: HTMLElement): HTMLElement | null;
|
|
226
|
+
export declare function getArrayIndexFromRow(rowEl: HTMLElement): number | null;
|
|
227
|
+
export declare function getRowIndexFromRow(rowEl: HTMLElement): number | null;
|
|
228
|
+
export declare function getCellColIndex(cellEl: HTMLElement, rowEl: HTMLElement): number | null;
|
|
229
|
+
export declare function getColDefFromCell<T extends TableData>(cellEl: HTMLElement, grid: Grid<T>): ColumnDef<T> | null;
|
|
230
|
+
export declare function getRowAndArrayIndex(cellEl: HTMLElement): {
|
|
231
|
+
rowEl: HTMLElement;
|
|
232
|
+
rowIndex: number;
|
|
233
|
+
arrayIndex: number;
|
|
234
|
+
} | null;
|
|
235
|
+
export declare function getCellContext<T extends TableData>(cellEl: HTMLElement, grid: Grid<T>): {
|
|
236
|
+
colDef: ColumnDef<T>;
|
|
237
|
+
rowIndex: number;
|
|
238
|
+
arrayIndex: number;
|
|
239
|
+
rowEl: HTMLElement;
|
|
240
|
+
} | null;
|
|
241
|
+
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/cellux/utilities/utilities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,6BAA6B,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE/E;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,QAAQ,CAExD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,uBAAuB,CACnC,YAAY,EAAE,SAAS,EACvB,cAAc,EAAE,MAAM,EAAE,GACzB,6BAA6B,CA0C/B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAu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AAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG;IACtD,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACtB,GAAG,IAAI,CAUP;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,SAAS,EAC9C,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GACd;IAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAAG,IAAI,CAQ3F"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cellux",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"
|
|
5
|
-
"main": "
|
|
6
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/cellux.umd.js",
|
|
6
|
+
"module": "./dist/cellux.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": ["dist"],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/cellux.mjs",
|
|
12
|
+
"require": "./dist/cellux.umd.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
7
15
|
"scripts": {
|
|
8
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
17
|
+
"dev": "vite",
|
|
18
|
+
"build": "vite build && tsc -p tsconfig.lib.json",
|
|
19
|
+
"preview": "vite preview"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "ISC",
|
|
24
|
+
"description": "",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^12.20.55",
|
|
27
|
+
"typescript": "3.8.3",
|
|
28
|
+
"vite": "^7.3.1"
|
|
9
29
|
},
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"data-grid",
|
|
13
|
-
"typescript",
|
|
14
|
-
"table"
|
|
15
|
-
],
|
|
16
|
-
"author": "Mike",
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "https://github.com/yourusername/cellux.git"
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"tslib": "^2.8.1"
|
|
21
32
|
}
|
|
22
33
|
}
|
|
34
|
+
|
package/README.md
DELETED
package/files.zip
DELETED
|
Binary file
|
package/index.d.ts
DELETED
package/index.js
DELETED