@dxos/lit-grid 0.6.12-main.78ddbdf → 0.6.12-main.89e9959
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 +522 -217
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/dx-grid-axis-resize-handle.d.ts +2 -1
- package/dist/types/src/dx-grid-axis-resize-handle.d.ts.map +1 -1
- package/dist/types/src/dx-grid.d.ts +30 -6
- package/dist/types/src/dx-grid.d.ts.map +1 -1
- package/dist/types/src/dx-grid.lit-stories.d.ts +23 -1
- package/dist/types/src/dx-grid.lit-stories.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +42 -10
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +2 -0
- package/dist/types/src/util.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dx-grid-axis-resize-handle.ts +6 -2
- package/src/dx-grid.lit-stories.ts +140 -16
- package/src/dx-grid.pcss +37 -62
- package/src/dx-grid.ts +553 -237
- package/src/types.ts +52 -8
- package/src/util.ts +15 -0
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
import { type DxGrid } from './dx-grid';
|
|
2
2
|
export type CellIndex = `${string},${string}`;
|
|
3
3
|
export type DxGridAxis = 'row' | 'col';
|
|
4
|
-
export type
|
|
4
|
+
export type DxGridFrozenColsPlane = `frozenCols${'Start' | 'End'}`;
|
|
5
|
+
export type DxGridFrozenRowsPlane = `frozenRows${'Start' | 'End'}`;
|
|
6
|
+
export type DxGridFrozenPlane = DxGridFrozenColsPlane | DxGridFrozenRowsPlane;
|
|
7
|
+
export type DxGridFixedPlane = `fixed${'Start' | 'End'}${'Start' | 'End'}`;
|
|
8
|
+
export type DxGridPlane = 'grid' | DxGridFrozenPlane | DxGridFixedPlane;
|
|
9
|
+
export type DxGridPlaneRecord<P extends Exclude<DxGridPlane, 'grid'>, T> = Record<'grid', T> & Partial<Record<P, T>>;
|
|
10
|
+
export type DxGridPlanePosition = Record<DxGridAxis, number>;
|
|
11
|
+
export type DxGridPosition = DxGridPlanePosition & {
|
|
12
|
+
plane: DxGridPlane;
|
|
13
|
+
};
|
|
5
14
|
export type DxGridPositionNullable = DxGridPosition | null;
|
|
6
|
-
export type
|
|
7
|
-
export type
|
|
15
|
+
export type DxGridPlaneCells = Record<CellIndex, DxGridCellValue>;
|
|
16
|
+
export type DxGridCells = {
|
|
17
|
+
grid: DxGridPlaneCells;
|
|
18
|
+
} & Partial<Record<DxGridFixedPlane | DxGridFrozenPlane, DxGridPlaneCells>>;
|
|
19
|
+
export type DxGridPlaneAxisMeta = Record<string, AxisMeta>;
|
|
20
|
+
export type DxGridAxisMeta = DxGridPlaneRecord<DxGridFrozenPlane, DxGridPlaneAxisMeta>;
|
|
8
21
|
export type DxGridPointer = null | ({
|
|
9
|
-
state: '
|
|
10
|
-
|
|
11
|
-
} & DxAxisResizeProps) | {
|
|
22
|
+
state: 'maybeSelecting';
|
|
23
|
+
} & Pick<PointerEvent, 'pageX' | 'pageY'>) | {
|
|
12
24
|
state: 'selecting';
|
|
13
25
|
};
|
|
14
|
-
export type DxAxisResizeProps = Pick<DxAxisResize, 'axis' | 'index' | 'size'>;
|
|
26
|
+
export type DxAxisResizeProps = Pick<DxAxisResize, 'axis' | 'plane' | 'index' | 'size'>;
|
|
15
27
|
export type DxAxisResizeInternalProps = DxAxisResizeProps & {
|
|
16
28
|
delta: number;
|
|
17
29
|
state: 'dragging' | 'dropped';
|
|
18
30
|
};
|
|
19
31
|
export type DxGridMode = 'browse' | 'edit';
|
|
20
|
-
export type
|
|
32
|
+
export type DxGridFrozenAxes = Partial<Record<DxGridFrozenPlane, number>>;
|
|
33
|
+
export type DxGridCellValue = {
|
|
21
34
|
/**
|
|
22
35
|
* The content value
|
|
23
36
|
*/
|
|
@@ -27,24 +40,39 @@ export type CellValue = {
|
|
|
27
40
|
*/
|
|
28
41
|
end?: string;
|
|
29
42
|
/**
|
|
30
|
-
* `class` attribute value to apply to the gridcell element
|
|
43
|
+
* `class` attribute value to apply to the gridcell element.
|
|
31
44
|
*/
|
|
32
45
|
className?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Whether to render a resize handle for this cell’s row or column.
|
|
48
|
+
*/
|
|
49
|
+
resizeHandle?: DxGridAxis;
|
|
33
50
|
};
|
|
34
51
|
export type AxisMeta = {
|
|
35
52
|
size: number;
|
|
36
53
|
description?: string;
|
|
37
54
|
resizeable?: boolean;
|
|
38
55
|
};
|
|
39
|
-
export type
|
|
56
|
+
export type AxisSizes = DxGridPlaneRecord<DxGridFrozenPlane, Record<string, number>>;
|
|
57
|
+
export type DxGridProps = Partial<Pick<DxGrid, 'initialCells' | 'rows' | 'columns' | 'rowDefault' | 'columnDefault' | 'limitRows' | 'limitColumns' | 'frozen'>>;
|
|
58
|
+
export type DxGridSelectionProps = {
|
|
59
|
+
plane: DxGridPlane;
|
|
60
|
+
colMin: number;
|
|
61
|
+
colMax: number;
|
|
62
|
+
rowMin: number;
|
|
63
|
+
rowMax: number;
|
|
64
|
+
visible?: boolean;
|
|
65
|
+
};
|
|
40
66
|
export declare class DxAxisResize extends Event {
|
|
41
67
|
readonly axis: DxGridAxis;
|
|
68
|
+
readonly plane: 'grid' | DxGridFrozenPlane;
|
|
42
69
|
readonly index: string;
|
|
43
70
|
readonly size: number;
|
|
44
71
|
constructor(props: DxAxisResizeProps);
|
|
45
72
|
}
|
|
46
73
|
export declare class DxAxisResizeInternal extends Event {
|
|
47
74
|
readonly axis: DxGridAxis;
|
|
75
|
+
readonly plane: 'grid' | DxGridFrozenPlane;
|
|
48
76
|
readonly index: string;
|
|
49
77
|
readonly size: number;
|
|
50
78
|
readonly delta: number;
|
|
@@ -58,6 +86,10 @@ export declare class DxEditRequest extends Event {
|
|
|
58
86
|
readonly initialContent?: string;
|
|
59
87
|
constructor(props: DxEditRequestProps);
|
|
60
88
|
}
|
|
89
|
+
export type DxGridPlaneRange = {
|
|
90
|
+
start: DxGridPlanePosition;
|
|
91
|
+
end: DxGridPlanePosition;
|
|
92
|
+
};
|
|
61
93
|
export type DxGridRange = {
|
|
62
94
|
start: DxGridPosition;
|
|
63
95
|
end: DxGridPosition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,MAAM,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAE9C,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvC,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,MAAM,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAE9C,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvC,MAAM,MAAM,qBAAqB,GAAG,aAAa,OAAO,GAAG,KAAK,EAAE,CAAC;AACnE,MAAM,MAAM,qBAAqB,GAAG,aAAa,OAAO,GAAG,KAAK,EAAE,CAAC;AAEnE,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;AAC9E,MAAM,MAAM,gBAAgB,GAAG,QAAQ,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,EAAE,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AACxE,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAA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
|
export declare const toCellIndex: (cellCoords: DxGridPosition) => CellIndex;
|
|
7
|
+
export declare const colToA1Notation: (col: number) => string;
|
|
8
|
+
export declare const rowToA1Notation: (row: number) => string;
|
|
7
9
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,SAAS,MAAM,CAAC;AAE7B,eAAO,MAAM,WAAW,eAAgB,cAAc,KAAG,SAA6D,CAAC"}
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,SAAS,MAAM,CAAC;AAE7B,eAAO,MAAM,WAAW,eAAgB,cAAc,KAAG,SAA6D,CAAC;AAMvH,eAAO,MAAM,eAAe,QAAS,MAAM,KAAG,MAK7C,CAAC;AAEF,eAAO,MAAM,eAAe,QAAS,MAAM,KAAG,MAE7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -10,13 +10,16 @@ import { html, LitElement } from 'lit';
|
|
|
10
10
|
import { customElement, property } from 'lit/decorators.js';
|
|
11
11
|
import { ref } from 'lit/directives/ref.js';
|
|
12
12
|
|
|
13
|
-
import { DxAxisResizeInternal, type DxGridAxis } from './types';
|
|
13
|
+
import { DxAxisResizeInternal, type DxGridAxis, type DxGridFrozenPlane } from './types';
|
|
14
14
|
|
|
15
15
|
@customElement('dx-grid-axis-resize-handle')
|
|
16
16
|
export class DxGridAxisResizeHandle extends LitElement {
|
|
17
17
|
@property({ type: String })
|
|
18
18
|
axis: DxGridAxis = 'row';
|
|
19
19
|
|
|
20
|
+
@property({ type: String })
|
|
21
|
+
plane: 'grid' | DxGridFrozenPlane = 'grid';
|
|
22
|
+
|
|
20
23
|
@property({ type: String })
|
|
21
24
|
index: string = '-1';
|
|
22
25
|
|
|
@@ -26,7 +29,7 @@ export class DxGridAxisResizeHandle extends LitElement {
|
|
|
26
29
|
private dragStartSize: number = 128;
|
|
27
30
|
|
|
28
31
|
override render() {
|
|
29
|
-
return html`<button class="dx-grid__resize-handle" ${ref(this.mount)}>
|
|
32
|
+
return html`<button class="dx-grid__resize-handle" data-dx-grid-axis=${this.axis} ${ref(this.mount)}>
|
|
30
33
|
<span class="sr-only">Resize</span>
|
|
31
34
|
</button>`;
|
|
32
35
|
}
|
|
@@ -37,6 +40,7 @@ export class DxGridAxisResizeHandle extends LitElement {
|
|
|
37
40
|
const client = this.axis === 'row' ? 'clientY' : 'clientX';
|
|
38
41
|
const event = new DxAxisResizeInternal({
|
|
39
42
|
axis: this.axis,
|
|
43
|
+
plane: this.plane,
|
|
40
44
|
size: this.dragStartSize,
|
|
41
45
|
index: this.index,
|
|
42
46
|
delta: location.current.input[client] - location.initial.input[client],
|
|
@@ -7,7 +7,8 @@ import './dx-grid.pcss';
|
|
|
7
7
|
|
|
8
8
|
import { html, nothing } from 'lit';
|
|
9
9
|
|
|
10
|
-
import { type DxGridProps } from './types';
|
|
10
|
+
import { type DxGridFrozenPlane, type DxGridPlaneCells, type DxGridProps } from './types';
|
|
11
|
+
import { colToA1Notation, rowToA1Notation } from './util';
|
|
11
12
|
|
|
12
13
|
export default {
|
|
13
14
|
title: 'dx-grid',
|
|
@@ -15,36 +16,159 @@ export default {
|
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
export const Basic = (props: DxGridProps) => {
|
|
18
|
-
return html`<div style="position:fixed;inset:0;">
|
|
19
|
+
return html`<div class="dark" style="position:fixed;inset:0;">
|
|
19
20
|
<dx-grid
|
|
20
|
-
|
|
21
|
+
initialCells=${props.initialCells ?? nothing}
|
|
21
22
|
columnDefault=${props.columnDefault ?? nothing}
|
|
22
23
|
rowDefault=${props.rowDefault ?? nothing}
|
|
23
24
|
columns=${props.columns ?? nothing}
|
|
25
|
+
frozen=${props.frozen ?? nothing}
|
|
24
26
|
></dx-grid>
|
|
25
27
|
</div>`;
|
|
26
28
|
};
|
|
27
29
|
|
|
30
|
+
const initialLabels = {
|
|
31
|
+
fixedStartStart: {
|
|
32
|
+
'0,0': { value: '', resizeHandle: 'col' },
|
|
33
|
+
},
|
|
34
|
+
frozenColsStart: [...Array(64)].reduce((acc, _, i) => {
|
|
35
|
+
acc[`0,${i}`] = { value: rowToA1Notation(i), className: 'text-end !pie-1', resizeHandle: 'row' };
|
|
36
|
+
return acc;
|
|
37
|
+
}, {}),
|
|
38
|
+
frozenRowsStart: [...Array(12)].reduce((acc, _, i) => {
|
|
39
|
+
acc[`${i},0`] = { value: colToA1Notation(i), resizeHandle: 'col' };
|
|
40
|
+
return acc;
|
|
41
|
+
}, {}),
|
|
42
|
+
} satisfies Partial<Record<DxGridFrozenPlane | 'fixedStartStart', DxGridPlaneCells>>;
|
|
43
|
+
|
|
28
44
|
Basic.args = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
initialCells: JSON.stringify({
|
|
46
|
+
grid: {
|
|
47
|
+
'1,1': {
|
|
48
|
+
// end: '8,1',
|
|
49
|
+
value: 'Weekly sales report',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
...initialLabels,
|
|
53
|
+
} satisfies DxGridProps['initialCells']),
|
|
54
|
+
columnDefault: JSON.stringify({
|
|
55
|
+
grid: {
|
|
56
|
+
size: 180,
|
|
57
|
+
resizeable: true,
|
|
58
|
+
},
|
|
59
|
+
frozenColsStart: {
|
|
60
|
+
size: 64,
|
|
61
|
+
resizeable: true,
|
|
62
|
+
},
|
|
63
|
+
} satisfies DxGridProps['columnDefault']),
|
|
64
|
+
rowDefault: JSON.stringify({
|
|
65
|
+
grid: {
|
|
66
|
+
size: 32,
|
|
67
|
+
resizeable: true,
|
|
68
|
+
},
|
|
69
|
+
frozenRowsStart: {
|
|
70
|
+
size: 32,
|
|
71
|
+
resizeable: true,
|
|
72
|
+
},
|
|
73
|
+
} satisfies DxGridProps['rowDefault']),
|
|
74
|
+
columns: JSON.stringify({
|
|
75
|
+
grid: {
|
|
76
|
+
0: { size: 200 },
|
|
77
|
+
1: { size: 210 },
|
|
78
|
+
2: { size: 230 },
|
|
79
|
+
3: { size: 250 },
|
|
80
|
+
4: { size: 270 },
|
|
33
81
|
},
|
|
82
|
+
} satisfies DxGridProps['columns']),
|
|
83
|
+
frozen: JSON.stringify({
|
|
84
|
+
frozenColsStart: 1,
|
|
85
|
+
frozenRowsStart: 1,
|
|
86
|
+
} satisfies DxGridProps['frozen']),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const Frozen = (props: DxGridProps) => {
|
|
90
|
+
return html`<div class="dark" style="position:fixed;inset:0;">
|
|
91
|
+
<dx-grid
|
|
92
|
+
initialCells=${props.initialCells ?? nothing}
|
|
93
|
+
columnDefault=${props.columnDefault ?? nothing}
|
|
94
|
+
rowDefault=${props.rowDefault ?? nothing}
|
|
95
|
+
columns=${props.columns ?? nothing}
|
|
96
|
+
frozen=${props.frozen ?? nothing}
|
|
97
|
+
></dx-grid>
|
|
98
|
+
</div>`;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
Frozen.args = {
|
|
102
|
+
initialCells: JSON.stringify({
|
|
103
|
+
grid: {},
|
|
104
|
+
...initialLabels,
|
|
34
105
|
} satisfies DxGridProps['initialCells']),
|
|
35
106
|
columnDefault: JSON.stringify({
|
|
36
|
-
|
|
37
|
-
|
|
107
|
+
grid: {
|
|
108
|
+
size: 32,
|
|
109
|
+
},
|
|
110
|
+
frozenColsStart: {
|
|
111
|
+
size: 32,
|
|
112
|
+
},
|
|
113
|
+
frozenColsEnd: {
|
|
114
|
+
size: 32,
|
|
115
|
+
},
|
|
116
|
+
} satisfies DxGridProps['columnDefault']),
|
|
117
|
+
rowDefault: JSON.stringify({
|
|
118
|
+
grid: {
|
|
119
|
+
size: 32,
|
|
120
|
+
},
|
|
121
|
+
frozenRowsStart: {
|
|
122
|
+
size: 32,
|
|
123
|
+
},
|
|
124
|
+
frozenRowsEnd: {
|
|
125
|
+
size: 32,
|
|
126
|
+
},
|
|
127
|
+
} satisfies DxGridProps['rowDefault']),
|
|
128
|
+
columns: JSON.stringify({ grid: {} } satisfies DxGridProps['columns']),
|
|
129
|
+
rows: JSON.stringify({ grid: {} } satisfies DxGridProps['rows']),
|
|
130
|
+
frozen: JSON.stringify({
|
|
131
|
+
frozenColsStart: 2,
|
|
132
|
+
frozenRowsStart: 2,
|
|
133
|
+
frozenColsEnd: 2,
|
|
134
|
+
frozenRowsEnd: 2,
|
|
135
|
+
} satisfies DxGridProps['frozen']),
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const Limits = (props: DxGridProps) => {
|
|
139
|
+
return html`<div style="position:fixed;inset:0;">
|
|
140
|
+
<dx-grid
|
|
141
|
+
limitRows=${props.limitRows ?? nothing}
|
|
142
|
+
limitColumns=${props.limitColumns ?? nothing}
|
|
143
|
+
columnDefault=${props.columnDefault ?? nothing}
|
|
144
|
+
rowDefault=${props.rowDefault ?? nothing}
|
|
145
|
+
columns=${props.columns ?? nothing}
|
|
146
|
+
></dx-grid>
|
|
147
|
+
</div>`;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
Limits.args = {
|
|
151
|
+
limitRows: JSON.stringify(10 satisfies DxGridProps['limitRows']),
|
|
152
|
+
limitColumns: JSON.stringify(3 satisfies DxGridProps['limitColumns']),
|
|
153
|
+
columnDefault: JSON.stringify({
|
|
154
|
+
grid: {
|
|
155
|
+
size: 180,
|
|
156
|
+
resizeable: true,
|
|
157
|
+
},
|
|
38
158
|
} satisfies DxGridProps['columnDefault']),
|
|
39
159
|
rowDefault: JSON.stringify({
|
|
40
|
-
|
|
41
|
-
|
|
160
|
+
grid: {
|
|
161
|
+
size: 32,
|
|
162
|
+
resizeable: true,
|
|
163
|
+
},
|
|
42
164
|
} satisfies DxGridProps['rowDefault']),
|
|
43
165
|
columns: JSON.stringify({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
166
|
+
grid: {
|
|
167
|
+
0: { size: 200 },
|
|
168
|
+
1: { size: 210 },
|
|
169
|
+
2: { size: 230 },
|
|
170
|
+
3: { size: 250 },
|
|
171
|
+
4: { size: 270 },
|
|
172
|
+
},
|
|
49
173
|
} satisfies DxGridProps['columns']),
|
|
50
174
|
};
|
package/src/dx-grid.pcss
CHANGED
|
@@ -2,24 +2,15 @@ dx-grid, dx-grid-axis-resize-handle {
|
|
|
2
2
|
display: contents;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
.sr-only {
|
|
6
|
-
position: absolute;
|
|
7
|
-
width: 1px;
|
|
8
|
-
height: 1px;
|
|
9
|
-
padding: 0;
|
|
10
|
-
margin: -1px;
|
|
11
|
-
overflow: hidden;
|
|
12
|
-
clip: rect(0, 0, 0, 0);
|
|
13
|
-
white-space: nowrap;
|
|
14
|
-
border-width: 0;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
5
|
.dx-grid {
|
|
6
|
+
--dx-grid-gap: 1px;
|
|
7
|
+
--dx-plane-gap: 2px;
|
|
8
|
+
|
|
18
9
|
display: grid;
|
|
10
|
+
gap: var(--dx-plane-gap);
|
|
19
11
|
grid-template-columns: min-content 1fr min-content;
|
|
20
12
|
grid-template-rows: min-content 1fr min-content;
|
|
21
13
|
font-variant-numeric: tabular-nums;
|
|
22
|
-
--dx-grid-gap: 1px;
|
|
23
14
|
|
|
24
15
|
min-inline-size: 4rem;
|
|
25
16
|
min-block-size: 4rem;
|
|
@@ -29,34 +20,16 @@ dx-grid, dx-grid-axis-resize-handle {
|
|
|
29
20
|
max-block-size: 100dvh;
|
|
30
21
|
|
|
31
22
|
user-select: none;
|
|
32
|
-
}
|
|
33
23
|
|
|
34
|
-
.dx-grid__scrollbar__thumb {
|
|
35
|
-
height: 1rem;
|
|
36
|
-
width: 1rem;
|
|
37
|
-
background: var(--dx-grid-thumb, var(--dx-separator));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.dx-grid__corner,
|
|
41
|
-
.dx-grid__scrollbar {
|
|
42
|
-
background: var(--dx-grid-corner, var(--dx-hoverSurface));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.dx-grid__columnheader__content,
|
|
46
|
-
.dx-grid__rowheader__content,
|
|
47
|
-
.dx-grid__content {
|
|
48
|
-
display: grid;
|
|
49
|
-
gap: var(--dx-grid-gap);
|
|
50
24
|
background: var(--dx-grid-lines, var(--dx-separator));
|
|
51
|
-
inline-size: min-content;
|
|
52
|
-
block-size: min-content;
|
|
53
25
|
}
|
|
54
26
|
|
|
55
|
-
.dx-
|
|
56
|
-
.dx-
|
|
57
|
-
.dx-
|
|
27
|
+
.dx-grid__plane--frozen-row,
|
|
28
|
+
.dx-grid__plane--frozen-col,
|
|
29
|
+
.dx-grid__plane--grid {
|
|
58
30
|
overflow: hidden;
|
|
59
31
|
position: relative;
|
|
32
|
+
display: grid;
|
|
60
33
|
&:focus-visible {
|
|
61
34
|
outline: none;
|
|
62
35
|
}
|
|
@@ -69,14 +42,12 @@ dx-grid, dx-grid-axis-resize-handle {
|
|
|
69
42
|
}
|
|
70
43
|
}
|
|
71
44
|
|
|
72
|
-
.dx-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
grid-template-columns: min-content;
|
|
79
|
-
text-align: end;
|
|
45
|
+
.dx-grid__plane--fixed,
|
|
46
|
+
.dx-grid__plane--frozen-row__content,
|
|
47
|
+
.dx-grid__plane--frozen-col__content,
|
|
48
|
+
.dx-grid__plane--grid__content {
|
|
49
|
+
display: grid;
|
|
50
|
+
gap: var(--dx-grid-gap);
|
|
80
51
|
}
|
|
81
52
|
|
|
82
53
|
.dx-grid {
|
|
@@ -116,31 +87,35 @@ dx-grid, dx-grid-axis-resize-handle {
|
|
|
116
87
|
}
|
|
117
88
|
}
|
|
118
89
|
|
|
119
|
-
.dx-grid__columnheader__content,
|
|
120
|
-
.dx-grid__rowheader__content {
|
|
121
|
-
& > [role='columnheader'], &> [role='rowheader'] {
|
|
122
|
-
position: relative;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
90
|
.dx-grid__resize-handle {
|
|
127
91
|
position: absolute;
|
|
128
92
|
background: transparent;
|
|
129
93
|
&:hover {
|
|
130
94
|
background: var(--dx-grid-resizeHandleHover, var(--dx-hoverSurface));
|
|
131
95
|
}
|
|
96
|
+
&[data-dx-grid-axis='col'] {
|
|
97
|
+
inset-block: 0;
|
|
98
|
+
inset-inline-end: 0;
|
|
99
|
+
inline-size: .5rem;
|
|
100
|
+
cursor: col-resize;
|
|
101
|
+
}
|
|
102
|
+
&[data-dx-grid-axis='row'] {
|
|
103
|
+
inset-inline: 0;
|
|
104
|
+
inset-block-end: 0;
|
|
105
|
+
block-size: .5rem;
|
|
106
|
+
cursor: row-resize;
|
|
107
|
+
}
|
|
132
108
|
}
|
|
133
109
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
cursor: row-resize;
|
|
110
|
+
// todo(thure): Move this somewhere better.
|
|
111
|
+
.sr-only {
|
|
112
|
+
position: absolute;
|
|
113
|
+
width: 1px;
|
|
114
|
+
height: 1px;
|
|
115
|
+
padding: 0;
|
|
116
|
+
margin: -1px;
|
|
117
|
+
overflow: hidden;
|
|
118
|
+
clip: rect(0, 0, 0, 0);
|
|
119
|
+
white-space: nowrap;
|
|
120
|
+
border-width: 0;
|
|
146
121
|
}
|