@dxos/lit-grid 0.6.11 → 0.6.12-main.15a606f
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/lib/browser/index.mjs +283 -103
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/dx-grid.d.ts +41 -58
- package/dist/types/src/dx-grid.d.ts.map +1 -1
- package/dist/types/src/dx-grid.lit-stories.d.ts +4 -1
- package/dist/types/src/dx-grid.lit-stories.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +51 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +7 -0
- package/dist/types/src/util.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/dx-grid.lit-stories.ts +10 -7
- package/src/dx-grid.pcss +27 -3
- package/src/dx-grid.ts +280 -154
- package/src/types.ts +69 -0
- package/src/util.ts +12 -0
package/src/types.ts
CHANGED
|
@@ -2,10 +2,45 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type DxGrid } from './dx-grid';
|
|
6
|
+
import { toCellIndex } from './util';
|
|
7
|
+
|
|
8
|
+
export type CellIndex = `${string},${string}`;
|
|
9
|
+
|
|
5
10
|
export type DxGridAxis = 'row' | 'col';
|
|
6
11
|
|
|
12
|
+
export type DxGridPosition = Record<DxGridAxis, number>;
|
|
13
|
+
export type DxGridPositionNullable = DxGridPosition | null;
|
|
14
|
+
|
|
15
|
+
export type DxGridPointer = null | ({ state: 'resizing'; page: number } & DxAxisResizeProps) | { state: 'selecting' };
|
|
16
|
+
|
|
7
17
|
export type DxAxisResizeProps = Pick<DxAxisResize, 'axis' | 'index' | 'size'>;
|
|
8
18
|
|
|
19
|
+
export type DxGridMode = 'browse' | 'edit';
|
|
20
|
+
|
|
21
|
+
export type CellValue = {
|
|
22
|
+
/**
|
|
23
|
+
* The content value
|
|
24
|
+
*/
|
|
25
|
+
value: string;
|
|
26
|
+
/**
|
|
27
|
+
* If this is a merged cell, the bottomright-most of the range in numeric notation, otherwise undefined.
|
|
28
|
+
*/
|
|
29
|
+
end?: string;
|
|
30
|
+
/**
|
|
31
|
+
* `class` attribute value to apply to the gridcell element
|
|
32
|
+
*/
|
|
33
|
+
className?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type AxisMeta = {
|
|
37
|
+
size: number;
|
|
38
|
+
description?: string;
|
|
39
|
+
resizeable?: boolean;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type DxGridProps = Partial<Pick<DxGrid, 'cells' | 'rows' | 'columns' | 'rowDefault' | 'columnDefault'>>;
|
|
43
|
+
|
|
9
44
|
export class DxAxisResize extends Event {
|
|
10
45
|
public readonly axis: DxGridAxis;
|
|
11
46
|
public readonly index: string;
|
|
@@ -17,3 +52,37 @@ export class DxAxisResize extends Event {
|
|
|
17
52
|
this.size = props.size;
|
|
18
53
|
}
|
|
19
54
|
}
|
|
55
|
+
|
|
56
|
+
export type DxEditRequestProps = Pick<DxEditRequest, 'cellIndex' | 'cellBox' | 'initialContent'>;
|
|
57
|
+
|
|
58
|
+
export class DxEditRequest extends Event {
|
|
59
|
+
public readonly cellIndex: CellIndex;
|
|
60
|
+
public readonly cellBox: Record<'insetInlineStart' | 'insetBlockStart' | 'inlineSize' | 'blockSize', number>;
|
|
61
|
+
public readonly initialContent?: string;
|
|
62
|
+
constructor(props: DxEditRequestProps) {
|
|
63
|
+
super('dx-edit-request');
|
|
64
|
+
this.cellIndex = props.cellIndex;
|
|
65
|
+
this.cellBox = props.cellBox;
|
|
66
|
+
this.initialContent = props.initialContent;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type DxSelectProps = { start: DxGridPosition; end: DxGridPosition };
|
|
71
|
+
|
|
72
|
+
export class DxGridCellsSelect extends Event {
|
|
73
|
+
public readonly start: string;
|
|
74
|
+
public readonly end: string;
|
|
75
|
+
public readonly minCol: number;
|
|
76
|
+
public readonly maxCol: number;
|
|
77
|
+
public readonly minRow: number;
|
|
78
|
+
public readonly maxRow: number;
|
|
79
|
+
constructor({ start, end }: DxSelectProps) {
|
|
80
|
+
super('dx-grid-cells-select');
|
|
81
|
+
this.start = toCellIndex(start);
|
|
82
|
+
this.end = toCellIndex(end);
|
|
83
|
+
this.minCol = Math.min(start.col, end.col);
|
|
84
|
+
this.maxCol = Math.max(start.col, end.col);
|
|
85
|
+
this.minRow = Math.min(start.row, end.row);
|
|
86
|
+
this.maxRow = Math.max(start.row, end.row);
|
|
87
|
+
}
|
|
88
|
+
}
|
package/src/util.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type CellIndex, type DxGridPosition } from './types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Separator for serializing cell position vectors
|
|
9
|
+
*/
|
|
10
|
+
export const separator = ',';
|
|
11
|
+
|
|
12
|
+
export const toCellIndex = (cellCoords: DxGridPosition): CellIndex => `${cellCoords.col}${separator}${cellCoords.row}`;
|