@3mo/data-grid 0.8.25 → 0.9.0-preview.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/DataGrid.d.ts +19 -34
- package/dist/DataGrid.d.ts.map +1 -1
- package/dist/DataGrid.js +64 -193
- package/dist/DataGridCell.d.ts +1 -1
- package/dist/DataGridCell.d.ts.map +1 -1
- package/dist/DataGridCell.js +11 -4
- package/dist/DataGridColumn.d.ts.map +1 -1
- package/dist/DataGridColumn.js +4 -3
- package/dist/DataGridColumnsController.d.ts +25 -0
- package/dist/DataGridColumnsController.d.ts.map +1 -0
- package/dist/DataGridColumnsController.js +110 -0
- package/dist/DataGridDetailsController.d.ts +28 -0
- package/dist/DataGridDetailsController.d.ts.map +1 -0
- package/dist/DataGridDetailsController.js +63 -0
- package/dist/DataGridFooter.js +3 -3
- package/dist/DataGridHeader.d.ts.map +1 -1
- package/dist/DataGridHeader.js +11 -6
- package/dist/DataGridSelectionController.d.ts +3 -1
- package/dist/DataGridSelectionController.d.ts.map +1 -1
- package/dist/DataGridSelectionController.js +4 -1
- package/dist/DataGridSortingController.d.ts +1 -0
- package/dist/DataGridSortingController.d.ts.map +1 -1
- package/dist/DataGridSortingController.js +5 -2
- package/dist/DataRecord.d.ts +15 -0
- package/dist/DataRecord.d.ts.map +1 -0
- package/dist/DataRecord.js +25 -0
- package/dist/columns/DataGridColumnDeletion.d.ts +0 -1
- package/dist/columns/DataGridColumnDeletion.d.ts.map +1 -1
- package/dist/columns/DataGridColumnDeletion.js +0 -1
- package/dist/columns/DataGridColumnText.js +1 -1
- package/dist/columns/date-time/DataGridColumnDateTimeBase.js +1 -1
- package/dist/columns/number/DataGridColumnCurrency.js +1 -1
- package/dist/columns/number/DataGridColumnNumber.js +1 -1
- package/dist/columns/number/DataGridColumnPercent.js +1 -1
- package/dist/custom-elements.json +102 -309
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/rows/DataGridRow.d.ts +9 -18
- package/dist/rows/DataGridRow.d.ts.map +1 -1
- package/dist/rows/DataGridRow.js +50 -83
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,10 +17,12 @@ import '@3mo/tab';
|
|
|
17
17
|
import '@3mo/slider';
|
|
18
18
|
import '@3mo/focus-ring';
|
|
19
19
|
import './types.js';
|
|
20
|
+
export * from './DataRecord.js';
|
|
20
21
|
export * from './DataGridColumn.js';
|
|
21
22
|
export * from './columns/index.js';
|
|
22
23
|
export * from './DataGridSelectionController.js';
|
|
23
24
|
export * from './DataGridSortingController.js';
|
|
25
|
+
export * from './DataGridDetailsController.js';
|
|
24
26
|
export * from './DataGrid.js';
|
|
25
27
|
export * from './DataGridHeader.js';
|
|
26
28
|
export * from './DataGridHeaderSeparator.js';
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import { Component, type HTMLTemplateResult } from '@a11d/lit';
|
|
2
2
|
import { type DataGridColumn } from '../DataGridColumn.js';
|
|
3
|
-
import { type
|
|
4
|
-
/**
|
|
5
|
-
* @attr dataGrid
|
|
6
|
-
* @attr data
|
|
7
|
-
* @attr selected
|
|
8
|
-
* @attr detailsOpen
|
|
9
|
-
*
|
|
10
|
-
* @fires detailsOpenChange - Dispatched when the details open state changes
|
|
11
|
-
*/
|
|
3
|
+
import { type DataGridCell, type DataRecord } from '../index.js';
|
|
12
4
|
export declare abstract class DataGridRow<TData, TDetailsElement extends Element | undefined = undefined> extends Component {
|
|
13
|
-
readonly detailsOpenChange: EventDispatcher<boolean>;
|
|
14
5
|
readonly cells: Array<DataGridCell<any, TData, TDetailsElement>>;
|
|
15
6
|
readonly subRows: Array<DataGridRow<TData, TDetailsElement>>;
|
|
16
7
|
readonly content: HTMLElement;
|
|
17
|
-
dataGrid: DataGrid<TData, TDetailsElement>;
|
|
18
|
-
data: TData;
|
|
19
|
-
selected: boolean;
|
|
20
|
-
index?: number;
|
|
21
|
-
detailsOpen: boolean;
|
|
22
|
-
level: number;
|
|
23
8
|
isIntersecting: boolean;
|
|
9
|
+
dataRecord: DataRecord<TData>;
|
|
10
|
+
get dataGrid(): import("../DataGrid.js").DataGrid<TData, any>;
|
|
11
|
+
get data(): TData;
|
|
12
|
+
get index(): number;
|
|
13
|
+
get level(): number;
|
|
14
|
+
get selected(): boolean;
|
|
15
|
+
get detailsOpen(): boolean;
|
|
24
16
|
get detailsElement(): TDetailsElement | undefined;
|
|
25
17
|
getCell(column: DataGridColumn<TData, any>): DataGridCell<any, TData, TDetailsElement> | undefined;
|
|
26
18
|
connected(): void;
|
|
@@ -47,8 +39,7 @@ export declare abstract class DataGridRow<TData, TDetailsElement extends Element
|
|
|
47
39
|
private get contextMenuData();
|
|
48
40
|
private get contextMenuTemplate();
|
|
49
41
|
closeContextMenu(): Promise<void>;
|
|
50
|
-
|
|
51
|
-
protected setDetailsOpen(value: boolean): void;
|
|
42
|
+
toggleDetails(): void;
|
|
52
43
|
}
|
|
53
44
|
declare global {
|
|
54
45
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridRow.d.ts","sourceRoot":"","sources":["../../rows/DataGridRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAgC,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"DataGridRow.d.ts","sourceRoot":"","sources":["../../rows/DataGridRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAgC,KAAK,kBAAkB,EAAoB,MAAM,WAAW,CAAA;AAI7H,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,KAAK,YAAY,EAAyD,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAEvH,8BAAsB,WAAW,CAAC,KAAK,EAAE,eAAe,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,CAAE,SAAQ,SAAS;IAC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;YAK1B,yCAAyC;IAQjD,eAAe,CAAC,KAAK,CAAC,EAAE,YAAY;IAgB1C,OAAO,KAAK,eAAe,GAI1B;IAED,OAAO,KAAK,mBAAmB,GAE9B;IAEK,gBAAgB;IAKtB,aAAa;CAQb;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,kBAAkB,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;KACxC;CACD"}
|
package/dist/rows/DataGridRow.js
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { css, property, Component, html, query, queryAll, style, LitElement,
|
|
2
|
+
import { css, property, Component, html, query, queryAll, style, LitElement, live } from '@a11d/lit';
|
|
3
3
|
import { DirectionsByLanguage } from '@3mo/localization';
|
|
4
4
|
import { popover } from '@3mo/popover';
|
|
5
5
|
import { ContextMenu } from '@3mo/context-menu';
|
|
6
6
|
import { DataGridPrimaryContextMenuItem, DataGridSelectionMode } from '../index.js';
|
|
7
|
-
/**
|
|
8
|
-
* @attr dataGrid
|
|
9
|
-
* @attr data
|
|
10
|
-
* @attr selected
|
|
11
|
-
* @attr detailsOpen
|
|
12
|
-
*
|
|
13
|
-
* @fires detailsOpenChange - Dispatched when the details open state changes
|
|
14
|
-
*/
|
|
15
7
|
export class DataGridRow extends Component {
|
|
16
8
|
constructor() {
|
|
17
9
|
super(...arguments);
|
|
18
|
-
this.selected = false;
|
|
19
|
-
this.detailsOpen = false;
|
|
20
|
-
this.level = 0;
|
|
21
10
|
this.isIntersecting = false;
|
|
22
11
|
this.delegateToCell = (method) => (e) => {
|
|
23
12
|
const target = e.target;
|
|
24
13
|
target?.[method]?.(e);
|
|
25
14
|
};
|
|
26
15
|
}
|
|
16
|
+
get dataGrid() { return this.dataRecord.dataGrid; }
|
|
17
|
+
get data() { return this.dataRecord.data; }
|
|
18
|
+
get index() { return this.dataRecord.index; }
|
|
19
|
+
get level() { return this.dataRecord.level; }
|
|
20
|
+
get selected() { return this.dataRecord.isSelected; }
|
|
21
|
+
get detailsOpen() { return this.dataRecord.detailsOpen; }
|
|
27
22
|
get detailsElement() {
|
|
28
23
|
return this.renderRoot.querySelector('#detailsContainer')?.firstElementChild;
|
|
29
24
|
}
|
|
@@ -31,7 +26,6 @@ export class DataGridRow extends Component {
|
|
|
31
26
|
return this.cells.find(cell => cell.column.equals(column));
|
|
32
27
|
}
|
|
33
28
|
connected() {
|
|
34
|
-
this.toggleAttribute('data-has-alternating-background', this.dataGrid.hasAlternatingBackground && (this.index ?? 0) % 2 === 1);
|
|
35
29
|
if ((this.index ?? 0) < 25) {
|
|
36
30
|
this.isIntersecting = true;
|
|
37
31
|
}
|
|
@@ -54,7 +48,7 @@ export class DataGridRow extends Component {
|
|
|
54
48
|
super.updated(...parameters);
|
|
55
49
|
}
|
|
56
50
|
get hasDetails() {
|
|
57
|
-
return this.
|
|
51
|
+
return this.dataRecord.hasDetails;
|
|
58
52
|
}
|
|
59
53
|
static get styles() {
|
|
60
54
|
return css `
|
|
@@ -65,6 +59,12 @@ export class DataGridRow extends Component {
|
|
|
65
59
|
width: 100%;
|
|
66
60
|
}
|
|
67
61
|
|
|
62
|
+
:host(:hover), :host([data-has-alternating-background]:hover) {
|
|
63
|
+
#contentContainer {
|
|
64
|
+
--mo-data-grid-sticky-part-color: color-mix(in srgb, var(--mo-color-surface), var(--mo-color-accent) 25%);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
68
|
:host(:hover) #contentContainer {
|
|
69
69
|
color: inherit;
|
|
70
70
|
background: var(--mo-color-accent-transparent) !important;
|
|
@@ -78,10 +78,12 @@ export class DataGridRow extends Component {
|
|
|
78
78
|
inset-inline-start: 0;
|
|
79
79
|
position: absolute;
|
|
80
80
|
background-color: var(--mo-color-accent);
|
|
81
|
+
z-index: 2;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
:host([data-has-alternating-background]) {
|
|
84
85
|
background: var(--mo-data-grid-alternating-background);
|
|
86
|
+
--mo-data-grid-sticky-part-color: color-mix(in srgb, var(--mo-color-surface), black var(--mo-data-grid-alternating-background-transparency));
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
#contentContainer {
|
|
@@ -99,7 +101,6 @@ export class DataGridRow extends Component {
|
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
#contextMenuIconButton {
|
|
102
|
-
transition: 250ms;
|
|
103
104
|
opacity: 0.5;
|
|
104
105
|
color: var(--mo-color-gray);
|
|
105
106
|
}
|
|
@@ -107,26 +108,26 @@ export class DataGridRow extends Component {
|
|
|
107
108
|
:host([selected]), :host([data-context-menu-open]) {
|
|
108
109
|
#contentContainer {
|
|
109
110
|
background: var(--mo-data-grid-selection-background) !important;
|
|
110
|
-
--mo-data-grid-sticky-part-color: color-mix(in srgb, var(--mo-color-surface), var(--mo-color-accent));
|
|
111
|
+
--mo-data-grid-sticky-part-color: color-mix(in srgb, var(--mo-color-surface), var(--mo-color-accent)) !important;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
#contextMenuIconButton {
|
|
114
|
-
color:
|
|
115
|
+
color: currentColor;
|
|
115
116
|
opacity: 1;
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
#contentContainer:hover #contextMenuIconButton {
|
|
120
|
-
color:
|
|
121
|
+
color: currentColor;
|
|
121
122
|
opacity: 1;
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
#detailsExpanderIconButton {
|
|
125
|
-
transition: 250ms;
|
|
126
|
-
}
|
|
126
|
+
transition: transform 250ms;
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
&[data-rtl] {
|
|
129
|
+
transform: rotate(180deg);
|
|
130
|
+
}
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
:host([detailsOpen]) #detailsExpanderIconButton {
|
|
@@ -153,6 +154,9 @@ export class DataGridRow extends Component {
|
|
|
153
154
|
`;
|
|
154
155
|
}
|
|
155
156
|
get template() {
|
|
157
|
+
this.style.setProperty('--_level', this.level.toString());
|
|
158
|
+
this.toggleAttribute('selected', this.dataRecord.isSelected);
|
|
159
|
+
this.toggleAttribute('detailsOpen', this.dataRecord.detailsOpen);
|
|
156
160
|
return !this.isIntersecting ? html.nothing : html `
|
|
157
161
|
<mo-grid id='contentContainer' columns='subgrid'
|
|
158
162
|
@click=${() => this.handleContentClick()}
|
|
@@ -176,13 +180,14 @@ export class DataGridRow extends Component {
|
|
|
176
180
|
@click=${(e) => e.stopPropagation()}
|
|
177
181
|
@dblclick=${(e) => e.stopPropagation()}
|
|
178
182
|
>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
${this.hasDetails === false ? html.nothing : html `
|
|
184
|
+
<mo-icon-button id='detailsExpanderIconButton'
|
|
185
|
+
icon='keyboard_arrow_right'
|
|
186
|
+
?data-rtl=${DirectionsByLanguage.get() === 'rtl'}
|
|
187
|
+
?disabled=${this.dataRecord.hasDetails === false}
|
|
188
|
+
@click=${() => this.toggleDetails()}
|
|
189
|
+
></mo-icon-button>
|
|
190
|
+
`}
|
|
186
191
|
</mo-flex>
|
|
187
192
|
`;
|
|
188
193
|
}
|
|
@@ -195,8 +200,8 @@ export class DataGridRow extends Component {
|
|
|
195
200
|
>
|
|
196
201
|
<mo-checkbox
|
|
197
202
|
tabindex='-1'
|
|
198
|
-
?disabled=${this.
|
|
199
|
-
|
|
203
|
+
?disabled=${this.dataRecord.isSelectable === false}
|
|
204
|
+
.selected=${live(this.selected)}
|
|
200
205
|
@change=${(e) => this.setSelection(e.detail)}
|
|
201
206
|
></mo-checkbox>
|
|
202
207
|
</mo-flex>
|
|
@@ -233,14 +238,10 @@ export class DataGridRow extends Component {
|
|
|
233
238
|
if (this.dataGrid.getRowDetailsTemplate) {
|
|
234
239
|
return this.dataGrid.getRowDetailsTemplate(this.data);
|
|
235
240
|
}
|
|
236
|
-
|
|
237
|
-
this.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
${subData.map(data => this.dataGrid.getRowTemplate(data, undefined, this.level + 1))}
|
|
241
|
-
`;
|
|
242
|
-
}
|
|
243
|
-
return html.nothing;
|
|
241
|
+
this.toggleAttribute('has-sub-data', !!this.dataRecord.hasSubData);
|
|
242
|
+
return !this.dataRecord.hasSubData ? html.nothing : html `
|
|
243
|
+
${this.dataRecord.subData?.map(data => this.dataGrid.getRowTemplate(data))}
|
|
244
|
+
`;
|
|
244
245
|
}
|
|
245
246
|
setSelection(selected) {
|
|
246
247
|
this.dataGrid.selectionController.setSelection(this.data, selected);
|
|
@@ -293,16 +294,15 @@ export class DataGridRow extends Component {
|
|
|
293
294
|
await this.updateComplete;
|
|
294
295
|
}
|
|
295
296
|
toggleDetails() {
|
|
296
|
-
this.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
297
|
+
this.dataGrid.detailsController.toggle(this.dataRecord);
|
|
298
|
+
if (this.dataRecord.detailsOpen) {
|
|
299
|
+
this.dataGrid.rowDetailsOpen.dispatch(this);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
this.dataGrid.rowDetailsClose.dispatch(this);
|
|
303
|
+
}
|
|
301
304
|
}
|
|
302
305
|
}
|
|
303
|
-
__decorate([
|
|
304
|
-
event()
|
|
305
|
-
], DataGridRow.prototype, "detailsOpenChange", void 0);
|
|
306
306
|
__decorate([
|
|
307
307
|
queryAll('mo-data-grid-cell')
|
|
308
308
|
], DataGridRow.prototype, "cells", void 0);
|
|
@@ -312,42 +312,6 @@ __decorate([
|
|
|
312
312
|
__decorate([
|
|
313
313
|
query('#contentContainer')
|
|
314
314
|
], DataGridRow.prototype, "content", void 0);
|
|
315
|
-
__decorate([
|
|
316
|
-
property({ type: Object })
|
|
317
|
-
], DataGridRow.prototype, "dataGrid", void 0);
|
|
318
|
-
__decorate([
|
|
319
|
-
property({ type: Object })
|
|
320
|
-
], DataGridRow.prototype, "data", void 0);
|
|
321
|
-
__decorate([
|
|
322
|
-
property({ type: Boolean, reflect: true })
|
|
323
|
-
], DataGridRow.prototype, "selected", void 0);
|
|
324
|
-
__decorate([
|
|
325
|
-
property({ type: Number })
|
|
326
|
-
], DataGridRow.prototype, "index", void 0);
|
|
327
|
-
__decorate([
|
|
328
|
-
property({
|
|
329
|
-
type: Boolean,
|
|
330
|
-
reflect: true,
|
|
331
|
-
updated(detailsOpen, wasDetailsOpen) {
|
|
332
|
-
if (wasDetailsOpen !== undefined) {
|
|
333
|
-
if (detailsOpen) {
|
|
334
|
-
this.dataGrid.rowDetailsOpen.dispatch(this);
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
this.dataGrid.rowDetailsClose.dispatch(this);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
})
|
|
342
|
-
], DataGridRow.prototype, "detailsOpen", void 0);
|
|
343
|
-
__decorate([
|
|
344
|
-
property({
|
|
345
|
-
type: Number,
|
|
346
|
-
updated() {
|
|
347
|
-
this.style.setProperty('--_level', this.level.toString());
|
|
348
|
-
}
|
|
349
|
-
})
|
|
350
|
-
], DataGridRow.prototype, "level", void 0);
|
|
351
315
|
__decorate([
|
|
352
316
|
property({
|
|
353
317
|
type: Boolean,
|
|
@@ -358,3 +322,6 @@ __decorate([
|
|
|
358
322
|
}
|
|
359
323
|
})
|
|
360
324
|
], DataGridRow.prototype, "isIntersecting", void 0);
|
|
325
|
+
__decorate([
|
|
326
|
+
property({ type: Object })
|
|
327
|
+
], DataGridRow.prototype, "dataRecord", void 0);
|