@3mo/data-grid 0.5.4 → 0.5.6
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/CsvGenerator.js +2 -3
- package/dist/DataGrid.d.ts +3 -1
- package/dist/DataGrid.d.ts.map +1 -1
- package/dist/DataGrid.js +294 -297
- package/dist/DataGridCell.js +46 -50
- package/dist/DataGridFooter.js +93 -94
- package/dist/DataGridHeader.js +92 -92
- package/dist/DataGridHeaderSeparator.d.ts.map +1 -1
- package/dist/DataGridHeaderSeparator.js +47 -49
- package/dist/DataGridPrimaryContextMenuItem.js +5 -5
- package/dist/DataGridSelectionController.js +1 -2
- package/dist/DataGridSidePanel.js +128 -129
- package/dist/FieldSelectDataGridPageSize.js +7 -7
- package/dist/columns/DataGridColumn.js +4 -7
- package/dist/columns/DataGridColumn.test.js +6 -6
- package/dist/columns/DataGridColumnBoolean.js +9 -9
- package/dist/columns/DataGridColumnImage.js +2 -2
- package/dist/columns/DataGridColumnText.js +6 -6
- package/dist/columns/date-time/DataGridColumnDate.js +1 -2
- package/dist/columns/date-time/DataGridColumnDateRange.js +1 -2
- package/dist/columns/date-time/DataGridColumnDateTime.js +1 -2
- package/dist/columns/date-time/DataGridColumnDateTimeBase.js +10 -11
- package/dist/columns/date-time/DataGridColumnDateTimeRange.js +1 -2
- package/dist/columns/number/DataGridColumnCurrency.js +10 -11
- package/dist/columns/number/DataGridColumnNumber.js +6 -7
- package/dist/columns/number/DataGridColumnNumberBase.js +5 -1
- package/dist/columns/number/DataGridColumnPercent.js +7 -8
- package/dist/columns/number/DataGridFooterSum.js +20 -20
- package/dist/excel.svg.js +47 -47
- package/dist/rows/DataGridDefaultRow.js +47 -47
- package/dist/rows/DataGridRow.d.ts +2 -0
- package/dist/rows/DataGridRow.d.ts.map +1 -1
- package/dist/rows/DataGridRow.js +159 -147
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -56
package/dist/DataGridCell.js
CHANGED
|
@@ -24,7 +24,7 @@ let DataGridCell = class DataGridCell extends Component {
|
|
|
24
24
|
get dataSelector() { return this.column.dataSelector; }
|
|
25
25
|
get cellIndex() { return this.row.cells.indexOf(this); }
|
|
26
26
|
get rowIndex() { return this.dataGrid.rows.indexOf(this.row); }
|
|
27
|
-
get valueTextContent() {
|
|
27
|
+
get valueTextContent() { return this.renderRoot.textContent?.trim() || ''; }
|
|
28
28
|
get isEditable() {
|
|
29
29
|
return this.dataGrid.editability !== DataGridEditability.Never
|
|
30
30
|
&& [undefined, null].includes(this.editContentTemplate) === false
|
|
@@ -46,7 +46,6 @@ let DataGridCell = class DataGridCell extends Component {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
async handleKeyDown(event) {
|
|
49
|
-
var _a, _b;
|
|
50
49
|
switch (event.key) {
|
|
51
50
|
case 'Enter':
|
|
52
51
|
event.preventDefault();
|
|
@@ -80,10 +79,10 @@ let DataGridCell = class DataGridCell extends Component {
|
|
|
80
79
|
this.focusCell(event, this.row.cells.at(this.cellIndex === 0 ? this.dataGrid.visibleColumns.length - 1 : this.cellIndex - 1));
|
|
81
80
|
break;
|
|
82
81
|
case 'ArrowUp':
|
|
83
|
-
this.focusCell(event,
|
|
82
|
+
this.focusCell(event, this.dataGrid.rows.at(this.rowIndex === 0 ? this.dataGrid.rows.length - 1 : this.rowIndex - 1)?.cells.at(this.cellIndex));
|
|
84
83
|
break;
|
|
85
84
|
case 'ArrowDown':
|
|
86
|
-
this.focusCell(event,
|
|
85
|
+
this.focusCell(event, this.dataGrid.rows.at(this.rowIndex === this.dataGrid.rows.length - 1 ? 0 : this.rowIndex + 1)?.cells.at(this.cellIndex));
|
|
87
86
|
break;
|
|
88
87
|
default:
|
|
89
88
|
break;
|
|
@@ -100,46 +99,46 @@ let DataGridCell = class DataGridCell extends Component {
|
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
static get styles() {
|
|
103
|
-
return css `
|
|
104
|
-
:host {
|
|
105
|
-
position: relative;
|
|
106
|
-
padding:
|
|
107
|
-
user-select: none;
|
|
108
|
-
line-height: var(--mo-data-grid-row-height);
|
|
109
|
-
white-space: nowrap;
|
|
110
|
-
overflow: hidden !important;
|
|
111
|
-
text-overflow: ellipsis;
|
|
112
|
-
font-size: var(--mo-data-grid-cell-font-size);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
:host(:not([isEditing]):focus) {
|
|
116
|
-
outline: 2px solid var(--mo-color-accent);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
:host([isEditing]) {
|
|
120
|
-
display: grid;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
:host([alignment=end]) {
|
|
124
|
-
text-align: end;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
:host([alignment=start]) {
|
|
128
|
-
text-align: start
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
:host([alignment=center]) {
|
|
132
|
-
text-align: center;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
:host > :first-child {
|
|
136
|
-
line-height: var(--mo-data-grid-row-height);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
:host([isEditing]) > :first-child {
|
|
140
|
-
align-self: center;
|
|
141
|
-
justify-self: stretch;
|
|
142
|
-
}
|
|
102
|
+
return css `
|
|
103
|
+
:host {
|
|
104
|
+
position: relative;
|
|
105
|
+
padding-inline: var(--mo-data-grid-cell-padding, 3px);
|
|
106
|
+
user-select: none;
|
|
107
|
+
line-height: var(--mo-data-grid-row-height);
|
|
108
|
+
white-space: nowrap;
|
|
109
|
+
overflow: hidden !important;
|
|
110
|
+
text-overflow: ellipsis;
|
|
111
|
+
font-size: var(--mo-data-grid-cell-font-size);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:host(:not([isEditing]):focus) {
|
|
115
|
+
outline: 2px solid var(--mo-color-accent);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:host([isEditing]) {
|
|
119
|
+
display: grid;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
:host([alignment=end]) {
|
|
123
|
+
text-align: end;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
:host([alignment=start]) {
|
|
127
|
+
text-align: start
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
:host([alignment=center]) {
|
|
131
|
+
text-align: center;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
:host > :first-child {
|
|
135
|
+
line-height: var(--mo-data-grid-row-height);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
:host([isEditing]) > :first-child {
|
|
139
|
+
align-self: center;
|
|
140
|
+
justify-self: stretch;
|
|
141
|
+
}
|
|
143
142
|
`;
|
|
144
143
|
}
|
|
145
144
|
get tooltip() { return this.valueTextContent; }
|
|
@@ -156,12 +155,10 @@ let DataGridCell = class DataGridCell extends Component {
|
|
|
156
155
|
return this.isEditing ? this.editContentTemplate : this.contentTemplate;
|
|
157
156
|
}
|
|
158
157
|
get contentTemplate() {
|
|
159
|
-
|
|
160
|
-
return (_c = (_b = (_a = this.column).getContentTemplate) === null || _b === void 0 ? void 0 : _b.call(_a, this.value, this.data)) !== null && _c !== void 0 ? _c : html `${this.value}`;
|
|
158
|
+
return this.column.getContentTemplate?.(this.value, this.data) ?? html `${this.value}`;
|
|
161
159
|
}
|
|
162
160
|
get editContentTemplate() {
|
|
163
|
-
|
|
164
|
-
return (_b = (_a = this.column).getEditContentTemplate) === null || _b === void 0 ? void 0 : _b.call(_a, this.value, this.data);
|
|
161
|
+
return this.column.getEditContentTemplate?.(this.value, this.data);
|
|
165
162
|
}
|
|
166
163
|
};
|
|
167
164
|
__decorate([
|
|
@@ -176,9 +173,8 @@ __decorate([
|
|
|
176
173
|
__decorate([
|
|
177
174
|
state({
|
|
178
175
|
updated() {
|
|
179
|
-
var _a;
|
|
180
176
|
if (this.isEditing) {
|
|
181
|
-
|
|
177
|
+
this.renderRoot.querySelector('[data-focus]')?.focus();
|
|
182
178
|
}
|
|
183
179
|
}
|
|
184
180
|
})
|
package/dist/DataGridFooter.js
CHANGED
|
@@ -23,93 +23,92 @@ let DataGridFooter = class DataGridFooter extends Component {
|
|
|
23
23
|
this.manualPageSize = false;
|
|
24
24
|
}
|
|
25
25
|
static get styles() {
|
|
26
|
-
return css `
|
|
27
|
-
:host {
|
|
28
|
-
grid-column: 1 / last-line;
|
|
29
|
-
grid-row: 3;
|
|
30
|
-
min-height: var(--mo-data-grid-footer-min-height);
|
|
31
|
-
background: var(--mo-data-grid-footer-background);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:host(:not([hideTopBorder])) {
|
|
35
|
-
border-top: var(--mo-data-grid-border);
|
|
36
|
-
}
|
|
26
|
+
return css `
|
|
27
|
+
:host {
|
|
28
|
+
grid-column: 1 / last-line;
|
|
29
|
+
grid-row: 3;
|
|
30
|
+
min-height: var(--mo-data-grid-footer-min-height);
|
|
31
|
+
background: var(--mo-data-grid-footer-background);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host(:not([hideTopBorder])) {
|
|
35
|
+
border-top: var(--mo-data-grid-border);
|
|
36
|
+
}
|
|
37
37
|
`;
|
|
38
38
|
}
|
|
39
39
|
get template() {
|
|
40
40
|
this.toggleAttribute('hideTopBorder', this.dataGrid.hasFooter === false);
|
|
41
|
-
return this.dataGrid.hasFooter === false ? html.nothing : html `
|
|
42
|
-
<mo-flex direction='horizontal' justifyContent='space-between' alignItems='center' wrap='wrap-reverse' gap='6px' ${style({ flex: '1', padding: '0 6px', height: '100%' })}>
|
|
43
|
-
<mo-flex direction='horizontal' alignItems='center' gap='3vw' ${style({ flexBasis: 'auto' })}>
|
|
44
|
-
${this.paginationTemplate}
|
|
45
|
-
${this.exportTemplate}
|
|
46
|
-
</mo-flex>
|
|
47
|
-
|
|
48
|
-
<mo-flex direction='horizontal' alignItems='center' gap='10px' wrap='wrap-reverse' ${style({ paddingInlineEnd: 'var(--mo-data-grid-footer-trailing-padding)' })}>
|
|
49
|
-
${this.dataGrid.sumsTemplate}
|
|
50
|
-
<slot name='sum'></slot>
|
|
51
|
-
</mo-flex>
|
|
52
|
-
</mo-flex>
|
|
41
|
+
return this.dataGrid.hasFooter === false ? html.nothing : html `
|
|
42
|
+
<mo-flex direction='horizontal' justifyContent='space-between' alignItems='center' wrap='wrap-reverse' gap='6px' ${style({ flex: '1', padding: '0 6px', height: '100%' })}>
|
|
43
|
+
<mo-flex direction='horizontal' alignItems='center' gap='3vw' ${style({ flexBasis: 'auto' })}>
|
|
44
|
+
${this.paginationTemplate}
|
|
45
|
+
${this.exportTemplate}
|
|
46
|
+
</mo-flex>
|
|
47
|
+
|
|
48
|
+
<mo-flex direction='horizontal' alignItems='center' gap='10px' wrap='wrap-reverse' ${style({ paddingInlineEnd: 'var(--mo-data-grid-footer-trailing-padding)' })}>
|
|
49
|
+
${this.dataGrid.sumsTemplate}
|
|
50
|
+
<slot name='sum'></slot>
|
|
51
|
+
</mo-flex>
|
|
52
|
+
</mo-flex>
|
|
53
53
|
`;
|
|
54
54
|
}
|
|
55
55
|
get paginationTemplate() {
|
|
56
|
-
var _a;
|
|
57
56
|
const isRtl = getComputedStyle(this).direction === 'rtl';
|
|
58
57
|
const hasUnknownDataLength = this.dataGrid.maxPage === undefined;
|
|
59
|
-
const pageText = hasUnknownDataLength ? this.page : t('${page:number} of ${maxPage:number}', { page: this.page, maxPage:
|
|
58
|
+
const pageText = hasUnknownDataLength ? this.page : t('${page:number} of ${maxPage:number}', { page: this.page, maxPage: this.dataGrid.maxPage ?? 0 });
|
|
60
59
|
const from = (this.page - 1) * this.dataGrid.pageSize + 1;
|
|
61
60
|
const to = from + this.dataGrid.renderData.length - 1;
|
|
62
61
|
const pageSizeText = [
|
|
63
62
|
`${(Math.min(from, to)).format()}-${to.format()}`,
|
|
64
63
|
hasUnknownDataLength ? undefined : this.dataGrid.dataLength.format(),
|
|
65
64
|
].filter(Boolean).join(' / ');
|
|
66
|
-
return !this.dataGrid.hasPagination ? html.nothing : html `
|
|
67
|
-
<mo-flex direction='horizontal' alignItems='center' gap='1vw'>
|
|
68
|
-
<mo-flex direction='horizontal' gap='4px' alignItems='center' justifyContent='center'>
|
|
69
|
-
<mo-icon-button dense icon=${isRtl ? 'last_page' : 'first_page'}
|
|
70
|
-
?disabled=${this.page === 1}
|
|
71
|
-
@click=${() => this.setPage(1)}
|
|
72
|
-
></mo-icon-button>
|
|
73
|
-
|
|
74
|
-
<mo-icon-button dense icon=${isRtl ? 'keyboard_arrow_right' : 'keyboard_arrow_left'}
|
|
75
|
-
?disabled=${this.page === 1}
|
|
76
|
-
@click=${() => this.setPage(this.page - 1)}
|
|
77
|
-
></mo-icon-button>
|
|
78
|
-
|
|
79
|
-
<div ${style({ cursor: 'pointer', width: hasUnknownDataLength ? '40px' : '75px', textAlign: 'center' })}>
|
|
80
|
-
${this.manualPagination ? html `
|
|
81
|
-
<mo-field-number dense
|
|
82
|
-
value=${this.page}
|
|
83
|
-
@change=${(e) => this.handleManualPageChange(e.detail)}>
|
|
84
|
-
</mo-field-number>
|
|
85
|
-
` : html `
|
|
86
|
-
<div ${style({ fontSize: 'small' })} @click=${() => this.manualPagination = hasUnknownDataLength === false}>${pageText}</div>
|
|
87
|
-
`}
|
|
88
|
-
</div>
|
|
89
|
-
|
|
90
|
-
<mo-icon-button dense icon=${isRtl ? 'keyboard_arrow_left' : 'keyboard_arrow_right'}
|
|
91
|
-
?disabled=${!this.dataGrid.hasNextPage}
|
|
92
|
-
@click=${() => this.setPage(this.page + 1)}
|
|
93
|
-
></mo-icon-button>
|
|
94
|
-
|
|
95
|
-
<mo-icon-button dense icon=${isRtl ? 'first_page' : 'last_page'}
|
|
96
|
-
?disabled=${hasUnknownDataLength || this.page === this.dataGrid.maxPage}
|
|
97
|
-
@click=${() =>
|
|
98
|
-
></mo-icon-button>
|
|
99
|
-
</mo-flex>
|
|
100
|
-
|
|
101
|
-
<div ${style({ color: 'var(--mo-color-gray)', marginInlineStart: '8px' })}>
|
|
102
|
-
${!this.manualPageSize ? html `
|
|
103
|
-
<div ${style({ fontSize: 'small' })} @click=${() => this.manualPageSize = true}>${pageSizeText}</div>
|
|
104
|
-
` : html `
|
|
105
|
-
<mo-field-select-data-grid-page-size dense ${style({ width: '90px' })}
|
|
106
|
-
.dataGrid=${this.dataGrid}
|
|
107
|
-
value=${ifDefined(this.dataGrid.pagination)}
|
|
108
|
-
@change=${(e) => this.handlePaginationChange(e.detail)}>
|
|
109
|
-
</mo-field-select-data-grid-page-size>
|
|
110
|
-
`}
|
|
111
|
-
</div>
|
|
112
|
-
</mo-flex>
|
|
65
|
+
return !this.dataGrid.hasPagination ? html.nothing : html `
|
|
66
|
+
<mo-flex direction='horizontal' alignItems='center' gap='1vw'>
|
|
67
|
+
<mo-flex direction='horizontal' gap='4px' alignItems='center' justifyContent='center'>
|
|
68
|
+
<mo-icon-button dense icon=${isRtl ? 'last_page' : 'first_page'}
|
|
69
|
+
?disabled=${this.page === 1}
|
|
70
|
+
@click=${() => this.setPage(1)}
|
|
71
|
+
></mo-icon-button>
|
|
72
|
+
|
|
73
|
+
<mo-icon-button dense icon=${isRtl ? 'keyboard_arrow_right' : 'keyboard_arrow_left'}
|
|
74
|
+
?disabled=${this.page === 1}
|
|
75
|
+
@click=${() => this.setPage(this.page - 1)}
|
|
76
|
+
></mo-icon-button>
|
|
77
|
+
|
|
78
|
+
<div ${style({ cursor: 'pointer', width: hasUnknownDataLength ? '40px' : '75px', textAlign: 'center' })}>
|
|
79
|
+
${this.manualPagination ? html `
|
|
80
|
+
<mo-field-number dense
|
|
81
|
+
value=${this.page}
|
|
82
|
+
@change=${(e) => this.handleManualPageChange(e.detail)}>
|
|
83
|
+
</mo-field-number>
|
|
84
|
+
` : html `
|
|
85
|
+
<div ${style({ fontSize: 'small' })} @click=${() => this.manualPagination = hasUnknownDataLength === false}>${pageText}</div>
|
|
86
|
+
`}
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<mo-icon-button dense icon=${isRtl ? 'keyboard_arrow_left' : 'keyboard_arrow_right'}
|
|
90
|
+
?disabled=${!this.dataGrid.hasNextPage}
|
|
91
|
+
@click=${() => this.setPage(this.page + 1)}
|
|
92
|
+
></mo-icon-button>
|
|
93
|
+
|
|
94
|
+
<mo-icon-button dense icon=${isRtl ? 'first_page' : 'last_page'}
|
|
95
|
+
?disabled=${hasUnknownDataLength || this.page === this.dataGrid.maxPage}
|
|
96
|
+
@click=${() => this.setPage(this.dataGrid.maxPage ?? 1)}
|
|
97
|
+
></mo-icon-button>
|
|
98
|
+
</mo-flex>
|
|
99
|
+
|
|
100
|
+
<div ${style({ color: 'var(--mo-color-gray)', marginInlineStart: '8px' })}>
|
|
101
|
+
${!this.manualPageSize ? html `
|
|
102
|
+
<div ${style({ fontSize: 'small' })} @click=${() => this.manualPageSize = true}>${pageSizeText}</div>
|
|
103
|
+
` : html `
|
|
104
|
+
<mo-field-select-data-grid-page-size dense ${style({ width: '90px' })}
|
|
105
|
+
.dataGrid=${this.dataGrid}
|
|
106
|
+
value=${ifDefined(this.dataGrid.pagination)}
|
|
107
|
+
@change=${(e) => this.handlePaginationChange(e.detail)}>
|
|
108
|
+
</mo-field-select-data-grid-page-size>
|
|
109
|
+
`}
|
|
110
|
+
</div>
|
|
111
|
+
</mo-flex>
|
|
113
112
|
`;
|
|
114
113
|
}
|
|
115
114
|
handlePaginationChange(value) {
|
|
@@ -127,28 +126,28 @@ let DataGridFooter = class DataGridFooter extends Component {
|
|
|
127
126
|
this.manualPagination = false;
|
|
128
127
|
}
|
|
129
128
|
get exportTemplate() {
|
|
130
|
-
return !this.dataGrid.exportable ? html.nothing : html `
|
|
131
|
-
<style>
|
|
132
|
-
#export {
|
|
133
|
-
height: 21px;
|
|
134
|
-
width: 21px;
|
|
135
|
-
aspect-ratio: 1 / 1;
|
|
136
|
-
transition: .25s;
|
|
137
|
-
-webkit-filter: grayscale(100%);
|
|
138
|
-
filter: grayscale(100%);
|
|
139
|
-
cursor: pointer;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
#export:hover {
|
|
143
|
-
-webkit-filter: grayscale(0%);
|
|
144
|
-
filter: grayscale(0%);
|
|
145
|
-
}
|
|
146
|
-
</style>
|
|
147
|
-
<img id='export'
|
|
148
|
-
src=${`data:image/svg+xml,${encodeURIComponent(excelSvg)}`}
|
|
149
|
-
${tooltip(t('Export current view to Excel'), TooltipPlacement.BlockStart)}
|
|
150
|
-
@click=${() => this.dataGrid.exportExcelFile()}
|
|
151
|
-
/>
|
|
129
|
+
return !this.dataGrid.exportable ? html.nothing : html `
|
|
130
|
+
<style>
|
|
131
|
+
#export {
|
|
132
|
+
height: 21px;
|
|
133
|
+
width: 21px;
|
|
134
|
+
aspect-ratio: 1 / 1;
|
|
135
|
+
transition: .25s;
|
|
136
|
+
-webkit-filter: grayscale(100%);
|
|
137
|
+
filter: grayscale(100%);
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#export:hover {
|
|
142
|
+
-webkit-filter: grayscale(0%);
|
|
143
|
+
filter: grayscale(0%);
|
|
144
|
+
}
|
|
145
|
+
</style>
|
|
146
|
+
<img id='export'
|
|
147
|
+
src=${`data:image/svg+xml,${encodeURIComponent(excelSvg)}`}
|
|
148
|
+
${tooltip(t('Export current view to Excel'), TooltipPlacement.BlockStart)}
|
|
149
|
+
@click=${() => this.dataGrid.exportExcelFile()}
|
|
150
|
+
/>
|
|
152
151
|
`;
|
|
153
152
|
}
|
|
154
153
|
setPage(value) {
|
package/dist/DataGridHeader.js
CHANGED
|
@@ -40,45 +40,45 @@ let DataGridHeader = class DataGridHeader extends Component {
|
|
|
40
40
|
this.dataGrid.selectionChange.unsubscribe(this.handleDataGridSelectionChange);
|
|
41
41
|
}
|
|
42
42
|
static get styles() {
|
|
43
|
-
return css `
|
|
44
|
-
:host {
|
|
45
|
-
--mo-data-grid-header-separator-height: 15px;
|
|
46
|
-
--mo-data-grid-header-separator-width: 2px;
|
|
47
|
-
display: inherit;
|
|
48
|
-
font-size: small;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
#header {
|
|
52
|
-
border-top: var(--mo-data-grid-border);
|
|
53
|
-
border-bottom: var(--mo-data-grid-border);
|
|
54
|
-
position: relative;
|
|
55
|
-
height: var(--mo-data-grid-header-height);
|
|
56
|
-
background: var(--mo-data-grid-header-background);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.headerContent {
|
|
60
|
-
padding: 0 var(--mo-data-grid-cell-padding, 3px);
|
|
61
|
-
display: inline-block;
|
|
62
|
-
overflow: hidden !important;
|
|
63
|
-
color: var(--mo-color-foreground);
|
|
64
|
-
font-weight: 500;
|
|
65
|
-
line-height: var(--mo-data-grid-header-height);
|
|
66
|
-
white-space: nowrap;
|
|
67
|
-
text-overflow: ellipsis;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.sort-rank {
|
|
71
|
-
background: var(--mo-color-transparent-gray-3);
|
|
72
|
-
color: var(--mo-color-foreground);
|
|
73
|
-
border: 1px solid var(--mo-color-gray-transparent);
|
|
74
|
-
border-radius: 50%;
|
|
75
|
-
width: 20px;
|
|
76
|
-
height: 20px;
|
|
77
|
-
aspect-ratio: 1 / 1;
|
|
78
|
-
display: flex;
|
|
79
|
-
align-items: center;
|
|
80
|
-
justify-content: center;
|
|
81
|
-
}
|
|
43
|
+
return css `
|
|
44
|
+
:host {
|
|
45
|
+
--mo-data-grid-header-separator-height: 15px;
|
|
46
|
+
--mo-data-grid-header-separator-width: 2px;
|
|
47
|
+
display: inherit;
|
|
48
|
+
font-size: small;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#header {
|
|
52
|
+
border-top: var(--mo-data-grid-border);
|
|
53
|
+
border-bottom: var(--mo-data-grid-border);
|
|
54
|
+
position: relative;
|
|
55
|
+
height: var(--mo-data-grid-header-height);
|
|
56
|
+
background: var(--mo-data-grid-header-background);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.headerContent {
|
|
60
|
+
padding: 0 var(--mo-data-grid-cell-padding, 3px);
|
|
61
|
+
display: inline-block;
|
|
62
|
+
overflow: hidden !important;
|
|
63
|
+
color: var(--mo-color-foreground);
|
|
64
|
+
font-weight: 500;
|
|
65
|
+
line-height: var(--mo-data-grid-header-height);
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
text-overflow: ellipsis;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.sort-rank {
|
|
71
|
+
background: var(--mo-color-transparent-gray-3);
|
|
72
|
+
color: var(--mo-color-foreground);
|
|
73
|
+
border: 1px solid var(--mo-color-gray-transparent);
|
|
74
|
+
border-radius: 50%;
|
|
75
|
+
width: 20px;
|
|
76
|
+
height: 20px;
|
|
77
|
+
aspect-ratio: 1 / 1;
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
}
|
|
82
82
|
`;
|
|
83
83
|
}
|
|
84
84
|
get skeletonColumns() {
|
|
@@ -93,75 +93,75 @@ let DataGridHeader = class DataGridHeader extends Component {
|
|
|
93
93
|
return this.dataGrid.dataColumnsWidths.join(' var(--mo-data-grid-columns-gap) ');
|
|
94
94
|
}
|
|
95
95
|
get template() {
|
|
96
|
-
return html `
|
|
97
|
-
<mo-grid id='header' columns=${this.skeletonColumns} columnGap='var(--mo-data-grid-columns-gap)'>
|
|
98
|
-
${this.detailsExpanderTemplate}
|
|
99
|
-
${this.selectionTemplate}
|
|
100
|
-
${this.contentTemplate}
|
|
101
|
-
${this.moreTemplate}
|
|
102
|
-
</mo-grid>
|
|
96
|
+
return html `
|
|
97
|
+
<mo-grid id='header' columns=${this.skeletonColumns} columnGap='var(--mo-data-grid-columns-gap)'>
|
|
98
|
+
${this.detailsExpanderTemplate}
|
|
99
|
+
${this.selectionTemplate}
|
|
100
|
+
${this.contentTemplate}
|
|
101
|
+
${this.moreTemplate}
|
|
102
|
+
</mo-grid>
|
|
103
103
|
`;
|
|
104
104
|
}
|
|
105
105
|
get detailsExpanderTemplate() {
|
|
106
|
-
return this.dataGrid.hasDetails === false ? html.nothing : html `
|
|
107
|
-
<mo-flex justifyContent='center' alignItems='center'>
|
|
108
|
-
${!this.dataGrid.hasDetails || !this.dataGrid.multipleDetails ? html.nothing : html `
|
|
109
|
-
<mo-icon-button dense ${style({ padding: '-10px 0px 0 -10px' })}
|
|
110
|
-
${style({ display: 'inherit' })}
|
|
111
|
-
icon=${this.dataGrid.allRowDetailsOpen ? 'unfold_less' : 'unfold_more'}
|
|
112
|
-
@click=${() => this.toggleAllDetails()}
|
|
113
|
-
></mo-icon-button>
|
|
114
|
-
`}
|
|
115
|
-
</mo-flex>
|
|
106
|
+
return this.dataGrid.hasDetails === false ? html.nothing : html `
|
|
107
|
+
<mo-flex justifyContent='center' alignItems='center'>
|
|
108
|
+
${!this.dataGrid.hasDetails || !this.dataGrid.multipleDetails ? html.nothing : html `
|
|
109
|
+
<mo-icon-button dense ${style({ padding: '-10px 0px 0 -10px' })}
|
|
110
|
+
${style({ display: 'inherit' })}
|
|
111
|
+
icon=${this.dataGrid.allRowDetailsOpen ? 'unfold_less' : 'unfold_more'}
|
|
112
|
+
@click=${() => this.toggleAllDetails()}
|
|
113
|
+
></mo-icon-button>
|
|
114
|
+
`}
|
|
115
|
+
</mo-flex>
|
|
116
116
|
`;
|
|
117
117
|
}
|
|
118
118
|
get selectionTemplate() {
|
|
119
|
-
return this.dataGrid.hasSelection === false || this.dataGrid.selectionCheckboxesHidden ? html.nothing : html `
|
|
120
|
-
<mo-flex justifyContent='center' alignItems='center'>
|
|
121
|
-
${this.dataGrid.selectionMode !== DataGridSelectionMode.Multiple ? html.nothing : html `
|
|
122
|
-
<mo-checkbox ${style({ position: 'absolute' })} .selected=${this.selection} @change=${this.handleSelectionChange}></mo-checkbox>
|
|
123
|
-
`}
|
|
124
|
-
</mo-flex>
|
|
119
|
+
return this.dataGrid.hasSelection === false || this.dataGrid.selectionCheckboxesHidden ? html.nothing : html `
|
|
120
|
+
<mo-flex justifyContent='center' alignItems='center'>
|
|
121
|
+
${this.dataGrid.selectionMode !== DataGridSelectionMode.Multiple ? html.nothing : html `
|
|
122
|
+
<mo-checkbox ${style({ position: 'absolute' })} .selected=${this.selection} @change=${this.handleSelectionChange}></mo-checkbox>
|
|
123
|
+
`}
|
|
124
|
+
</mo-flex>
|
|
125
125
|
`;
|
|
126
126
|
}
|
|
127
127
|
get contentTemplate() {
|
|
128
|
-
return html `
|
|
129
|
-
<mo-grid columns=${this.separatorAdjustedColumns}>
|
|
130
|
-
${join(this.dataGrid.visibleColumns.map(column => this.getHeaderCellTemplate(column)), index => html `
|
|
131
|
-
<mo-data-grid-header-separator
|
|
132
|
-
.dataGrid=${this.dataGrid}
|
|
133
|
-
.column=${this.dataGrid.visibleColumns[index]}
|
|
134
|
-
@columnUpdate=${() => this.dataGrid.requestUpdate()}
|
|
135
|
-
></mo-data-grid-header-separator>
|
|
136
|
-
`)}
|
|
137
|
-
</mo-grid>
|
|
128
|
+
return html `
|
|
129
|
+
<mo-grid columns=${this.separatorAdjustedColumns}>
|
|
130
|
+
${join(this.dataGrid.visibleColumns.map(column => this.getHeaderCellTemplate(column)), index => html `
|
|
131
|
+
<mo-data-grid-header-separator
|
|
132
|
+
.dataGrid=${this.dataGrid}
|
|
133
|
+
.column=${this.dataGrid.visibleColumns[index]}
|
|
134
|
+
@columnUpdate=${() => this.dataGrid.requestUpdate()}
|
|
135
|
+
></mo-data-grid-header-separator>
|
|
136
|
+
`)}
|
|
137
|
+
</mo-grid>
|
|
138
138
|
`;
|
|
139
139
|
}
|
|
140
140
|
getHeaderCellTemplate(column) {
|
|
141
141
|
const sortingDefinition = this.dataGrid.getSortingDefinition(column);
|
|
142
142
|
const sortIcon = !sortingDefinition ? undefined : sortingDefinition.strategy === DataGridSortingStrategy.Ascending ? 'arrow_upward' : 'arrow_downward';
|
|
143
143
|
const sortingRank = !sortingDefinition || this.dataGrid.getSorting().length <= 1 ? undefined : sortingDefinition.rank;
|
|
144
|
-
return html `
|
|
145
|
-
<mo-flex direction=${column.alignment === 'end' ? 'horizontal-reversed' : 'horizontal'} alignItems='center'
|
|
146
|
-
${style({ overflow: 'hidden', position: 'relative', cursor: 'pointer', userSelect: 'none' })}
|
|
147
|
-
@click=${() => this.sort(column)}
|
|
148
|
-
>
|
|
149
|
-
<div class='headerContent' ${style({ width: '100%', textAlign: column.alignment })} title=${column.title || column.heading}>${column.heading}</div>
|
|
150
|
-
|
|
151
|
-
${sortIcon === undefined ? html.nothing : html `
|
|
152
|
-
${!sortingRank ? html.nothing : html `<span class='sort-rank'>${sortingRank}</span>`}
|
|
153
|
-
<mo-icon ${style({ color: 'var(--mo-color-accent)' })} icon=${ifDefined(sortIcon)}></mo-icon>
|
|
154
|
-
`}
|
|
155
|
-
</mo-flex>
|
|
144
|
+
return html `
|
|
145
|
+
<mo-flex direction=${column.alignment === 'end' ? 'horizontal-reversed' : 'horizontal'} alignItems='center'
|
|
146
|
+
${style({ overflow: 'hidden', position: 'relative', cursor: 'pointer', userSelect: 'none' })}
|
|
147
|
+
@click=${() => this.sort(column)}
|
|
148
|
+
>
|
|
149
|
+
<div class='headerContent' ${style({ width: '100%', textAlign: column.alignment })} title=${column.title || column.heading}>${column.heading}</div>
|
|
150
|
+
|
|
151
|
+
${sortIcon === undefined ? html.nothing : html `
|
|
152
|
+
${!sortingRank ? html.nothing : html `<span class='sort-rank'>${sortingRank}</span>`}
|
|
153
|
+
<mo-icon ${style({ color: 'var(--mo-color-accent)' })} icon=${ifDefined(sortIcon)}></mo-icon>
|
|
154
|
+
`}
|
|
155
|
+
</mo-flex>
|
|
156
156
|
`;
|
|
157
157
|
}
|
|
158
158
|
get moreTemplate() {
|
|
159
|
-
return this.dataGrid.hasToolbar || this.dataGrid.sidePanelHidden ? html.nothing : html `
|
|
160
|
-
<mo-flex alignItems='center' justifyContent='center' ${style({ marginInlineEnd: '8px', cursor: 'pointer', position: 'relative' })}>
|
|
161
|
-
<mo-icon-button dense icon='settings' ${style({ color: 'var(--mo-color-accent)', fontSize: 'large' })}
|
|
162
|
-
@click=${() => this.dataGrid.navigateToSidePanelTab(this.dataGrid.sidePanelTab ? undefined : DataGridSidePanelTab.Settings)}
|
|
163
|
-
></mo-icon-button>
|
|
164
|
-
</mo-flex>
|
|
159
|
+
return this.dataGrid.hasToolbar || this.dataGrid.sidePanelHidden ? html.nothing : html `
|
|
160
|
+
<mo-flex alignItems='center' justifyContent='center' ${style({ marginInlineEnd: '8px', cursor: 'pointer', position: 'relative' })}>
|
|
161
|
+
<mo-icon-button dense icon='settings' ${style({ color: 'var(--mo-color-accent)', fontSize: 'large' })}
|
|
162
|
+
@click=${() => this.dataGrid.navigateToSidePanelTab(this.dataGrid.sidePanelTab ? undefined : DataGridSidePanelTab.Settings)}
|
|
163
|
+
></mo-icon-button>
|
|
164
|
+
</mo-flex>
|
|
165
165
|
`;
|
|
166
166
|
}
|
|
167
167
|
sort(column) {
|
|
@@ -173,7 +173,7 @@ let DataGridHeader = class DataGridHeader extends Component {
|
|
|
173
173
|
const sortingDefinition = this.dataGrid.getSortingDefinition(column);
|
|
174
174
|
if (KeyboardController.shift || KeyboardController.meta || KeyboardController.ctrl) {
|
|
175
175
|
const sortings = this.dataGrid.getSorting();
|
|
176
|
-
if (
|
|
176
|
+
if (sortingDefinition?.selector !== sortDataSelector) {
|
|
177
177
|
this.dataGrid.handleSortChange([...sortings, { selector: sortDataSelector, strategy: defaultSortingStrategy }]);
|
|
178
178
|
}
|
|
179
179
|
else if (sortingDefinition.strategy === DataGridSortingStrategy.Descending) {
|
|
@@ -187,7 +187,7 @@ let DataGridHeader = class DataGridHeader extends Component {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
else {
|
|
190
|
-
if (
|
|
190
|
+
if (sortingDefinition?.selector !== sortDataSelector) {
|
|
191
191
|
this.dataGrid.handleSortChange({ selector: sortDataSelector, strategy: defaultSortingStrategy });
|
|
192
192
|
}
|
|
193
193
|
else if (sortingDefinition.strategy === DataGridSortingStrategy.Descending) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridHeaderSeparator.d.ts","sourceRoot":"","sources":["../DataGridHeaderSeparator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsE,MAAM,WAAW,CAAA;AACzG,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,wCAAwC;AACxC,qBACa,uBAAwB,SAAQ,SAAS;IACrD,MAAM,CAAC,eAAe,UAAQ;IAErB,QAAQ,CAAC,YAAY,EAAG,eAAe,CAAA;IAEpB,QAAQ,EAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC5B,MAAM,EAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAErD,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,KAAK,CAAI;IAE1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAK;IAE7B,OAAO,CAAC,YAAY,CAAC,CAAQ;IAC7B,OAAO,CAAC,WAAW,CAAC,CAAQ;IAE5B,WAAoB,MAAM,
|
|
1
|
+
{"version":3,"file":"DataGridHeaderSeparator.d.ts","sourceRoot":"","sources":["../DataGridHeaderSeparator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsE,MAAM,WAAW,CAAA;AACzG,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEvD,wCAAwC;AACxC,qBACa,uBAAwB,SAAQ,SAAS;IACrD,MAAM,CAAC,eAAe,UAAQ;IAErB,QAAQ,CAAC,YAAY,EAAG,eAAe,CAAA;IAEpB,QAAQ,EAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC5B,MAAM,EAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAErD,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,KAAK,CAAI;IAE1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAK;IAE7B,OAAO,CAAC,YAAY,CAAC,CAAQ;IAC7B,OAAO,CAAC,WAAW,CAAC,CAAQ;IAE5B,WAAoB,MAAM,kCAuCzB;IAED,cAAuB,QAAQ,0CAW9B;IAGD,SAAS,CAAC,aAAa;IAavB,SAAS,CAAC,eAAe,CAAC,CAAC,EAAE,UAAU;IAmBvC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAM/B;IAED,OAAO,CAAC,cAAc;CAmBtB;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,+BAA+B,EAAE,uBAAuB,CAAA;KACxD;CACD"}
|