@3mo/data-grid 0.9.0 → 0.9.1
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 +1 -3
- package/dist/DataGrid.d.ts.map +1 -1
- package/dist/DataGrid.js +7 -82
- package/dist/DataGridFooter.d.ts +2 -2
- package/dist/DataGridFooter.d.ts.map +1 -1
- package/dist/DataGridFooter.js +87 -41
- package/dist/DataGridHeader.d.ts +2 -3
- package/dist/DataGridHeader.d.ts.map +1 -1
- package/dist/DataGridHeader.js +90 -33
- package/dist/custom-elements.json +10 -634
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/FieldSelectDataGridPageSize.d.ts +0 -13
- package/dist/FieldSelectDataGridPageSize.d.ts.map +0 -1
- package/dist/FieldSelectDataGridPageSize.js +0 -24
package/dist/DataGridHeader.js
CHANGED
|
@@ -1,25 +1,44 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { component, Component, css, html, ifDefined, property, event, style } from '@a11d/lit';
|
|
2
|
+
import { component, Component, css, html, ifDefined, property, event, style, live } from '@a11d/lit';
|
|
3
3
|
import { tooltip } from '@3mo/tooltip';
|
|
4
4
|
import { observeResize } from '@3mo/resize-observer';
|
|
5
|
+
import { Localizer } from '@3mo/localization';
|
|
5
6
|
import { DataGridSelectionMode, DataGridSortingStrategy, DataGridSidePanelTab } from './index.js';
|
|
7
|
+
Localizer.register('en', {
|
|
8
|
+
'${count:pluralityNumber} entries selected': [
|
|
9
|
+
'1 entry selected',
|
|
10
|
+
'${count} entries selected',
|
|
11
|
+
],
|
|
12
|
+
'Options for ${count:pluralityNumber} selected entries': [
|
|
13
|
+
'Options for the selected entry',
|
|
14
|
+
'Options for ${count} selected entries',
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
Localizer.register('de', {
|
|
18
|
+
'${count:pluralityNumber} entries selected': [
|
|
19
|
+
'1 Eintrag ausgewählt',
|
|
20
|
+
'${count} Einträge ausgewählt',
|
|
21
|
+
],
|
|
22
|
+
'Options for ${count:pluralityNumber} selected entries': [
|
|
23
|
+
'Optionen für den ausgewählten Eintrag',
|
|
24
|
+
'Optionen für ${count} ausgewählte Einträge',
|
|
25
|
+
],
|
|
26
|
+
});
|
|
6
27
|
let DataGridHeader = class DataGridHeader extends Component {
|
|
7
28
|
constructor() {
|
|
8
29
|
super(...arguments);
|
|
9
|
-
this.selection = false;
|
|
10
30
|
this.overlayOpen = false;
|
|
11
31
|
this.handleDataGridDataChange = () => {
|
|
12
32
|
this.requestUpdate();
|
|
13
33
|
};
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.selection = true;
|
|
34
|
+
this.toggleSelection = (e) => {
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
const selection = this.selection === 'indeterminate' ? false : !this.selection;
|
|
37
|
+
if (selection === true) {
|
|
38
|
+
this.dataGrid.selectAll();
|
|
20
39
|
}
|
|
21
40
|
else {
|
|
22
|
-
this.
|
|
41
|
+
this.dataGrid.deselectAll();
|
|
23
42
|
}
|
|
24
43
|
};
|
|
25
44
|
this.getHeaderCellTemplate = (column, index, columns) => {
|
|
@@ -60,23 +79,12 @@ let DataGridHeader = class DataGridHeader extends Component {
|
|
|
60
79
|
</mo-flex>
|
|
61
80
|
`;
|
|
62
81
|
};
|
|
63
|
-
this.handleSelectionChange = (e) => {
|
|
64
|
-
const selected = e.target.selected;
|
|
65
|
-
if (selected === true) {
|
|
66
|
-
this.dataGrid.selectAll();
|
|
67
|
-
}
|
|
68
|
-
else if (selected === false) {
|
|
69
|
-
this.dataGrid.deselectAll();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
82
|
}
|
|
73
83
|
connected() {
|
|
74
84
|
this.dataGrid.dataChange.subscribe(this.handleDataGridDataChange);
|
|
75
|
-
this.dataGrid.selectionChange.subscribe(this.handleDataGridSelectionChange);
|
|
76
85
|
}
|
|
77
86
|
disconnected() {
|
|
78
87
|
this.dataGrid.dataChange.unsubscribe(this.handleDataGridDataChange);
|
|
79
|
-
this.dataGrid.selectionChange.unsubscribe(this.handleDataGridSelectionChange);
|
|
80
88
|
}
|
|
81
89
|
static get styles() {
|
|
82
90
|
return css `
|
|
@@ -142,7 +150,7 @@ let DataGridHeader = class DataGridHeader extends Component {
|
|
|
142
150
|
z-index: 7;
|
|
143
151
|
}
|
|
144
152
|
|
|
145
|
-
.details, .selection, .more {
|
|
153
|
+
.details, .selection, .more, .context-menu {
|
|
146
154
|
position: sticky;
|
|
147
155
|
background: var(--mo-data-grid-sticky-part-color);
|
|
148
156
|
z-index: 5;
|
|
@@ -156,10 +164,32 @@ let DataGridHeader = class DataGridHeader extends Component {
|
|
|
156
164
|
inset-inline-start: 0px;
|
|
157
165
|
}
|
|
158
166
|
|
|
159
|
-
.more {
|
|
167
|
+
.more, .context-menu {
|
|
160
168
|
cursor: pointer;
|
|
161
169
|
inset-inline-end: 0px;
|
|
162
170
|
}
|
|
171
|
+
|
|
172
|
+
.more {
|
|
173
|
+
mo-icon-button {
|
|
174
|
+
color: var(--mo-color-accent);
|
|
175
|
+
font-size: large;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.context-menu {
|
|
180
|
+
background-color: var(--mo-data-grid-selection-background);
|
|
181
|
+
|
|
182
|
+
mo-icon-button {
|
|
183
|
+
color: var(--mo-color-on-accent);
|
|
184
|
+
font-size: 22px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
mo-menu div {
|
|
188
|
+
padding: 12px 8px;
|
|
189
|
+
color: var(--mo-color-gray);
|
|
190
|
+
pointer-events: none;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
163
193
|
`;
|
|
164
194
|
}
|
|
165
195
|
get template() {
|
|
@@ -193,11 +223,21 @@ let DataGridHeader = class DataGridHeader extends Component {
|
|
|
193
223
|
${this.getResizeObserver('selectionColumnWidthInPixels')}
|
|
194
224
|
>
|
|
195
225
|
${this.dataGrid.selectionMode !== DataGridSelectionMode.Multiple ? html.nothing : html `
|
|
196
|
-
<mo-checkbox .selected=${this.selection} @
|
|
226
|
+
<mo-checkbox .selected=${live(this.selection)} @click=${this.toggleSelection}></mo-checkbox>
|
|
197
227
|
`}
|
|
198
228
|
</mo-flex>
|
|
199
229
|
`;
|
|
200
230
|
}
|
|
231
|
+
get selection() {
|
|
232
|
+
switch (this.dataGrid.selectedData.length) {
|
|
233
|
+
case 0:
|
|
234
|
+
return false;
|
|
235
|
+
case this.dataGrid.dataLength:
|
|
236
|
+
return true;
|
|
237
|
+
default:
|
|
238
|
+
return 'indeterminate';
|
|
239
|
+
}
|
|
240
|
+
}
|
|
201
241
|
get contentTemplate() {
|
|
202
242
|
return html `
|
|
203
243
|
${this.dataGrid.visibleColumns.map(this.getHeaderCellTemplate)}
|
|
@@ -207,13 +247,33 @@ let DataGridHeader = class DataGridHeader extends Component {
|
|
|
207
247
|
return html `<span></span>`;
|
|
208
248
|
}
|
|
209
249
|
get moreTemplate() {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
<mo-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
250
|
+
if (this.dataGrid.hasContextMenu && this.dataGrid.selectedData.length > 1) {
|
|
251
|
+
return html `
|
|
252
|
+
<mo-flex class='context-menu' alignItems='end' justifyContent='center' ${this.getResizeObserver('moreColumnWidthInPixels')}>
|
|
253
|
+
<mo-popover-container fixed>
|
|
254
|
+
<mo-icon-button dense icon='more_vert' title=${t('Actions for ${count:pluralityNumber} selected entries', { count: this.dataGrid.selectedData.length })}></mo-icon-button>
|
|
255
|
+
|
|
256
|
+
<mo-menu slot='popover'>
|
|
257
|
+
<div>
|
|
258
|
+
${t('${count:pluralityNumber} entries selected', { count: this.dataGrid.selectedData.length })}
|
|
259
|
+
</div>
|
|
260
|
+
<mo-line></mo-line>
|
|
261
|
+
${this.dataGrid.getRowContextMenuTemplate?.(this.dataGrid.selectedData) ?? html.nothing}
|
|
262
|
+
</mo-menu>
|
|
263
|
+
</mo-popover-container>
|
|
264
|
+
</mo-flex>
|
|
265
|
+
`;
|
|
266
|
+
}
|
|
267
|
+
if (!this.dataGrid.hasToolbar && !this.dataGrid.sidePanelHidden) {
|
|
268
|
+
return html `
|
|
269
|
+
<mo-flex class='more' alignItems='end' justifyContent='center' ${this.getResizeObserver('moreColumnWidthInPixels')}>
|
|
270
|
+
<mo-icon-button dense icon='settings'
|
|
271
|
+
@click=${() => this.dataGrid.navigateToSidePanelTab(this.dataGrid.sidePanelTab ? undefined : DataGridSidePanelTab.Settings)}
|
|
272
|
+
></mo-icon-button>
|
|
273
|
+
</mo-flex>
|
|
274
|
+
`;
|
|
275
|
+
}
|
|
276
|
+
return html.nothing;
|
|
217
277
|
}
|
|
218
278
|
getResizeObserver(property) {
|
|
219
279
|
// @ts-expect-error Readonly property set here
|
|
@@ -239,9 +299,6 @@ __decorate([
|
|
|
239
299
|
__decorate([
|
|
240
300
|
property({ type: Object })
|
|
241
301
|
], DataGridHeader.prototype, "dataGrid", void 0);
|
|
242
|
-
__decorate([
|
|
243
|
-
property()
|
|
244
|
-
], DataGridHeader.prototype, "selection", void 0);
|
|
245
302
|
__decorate([
|
|
246
303
|
property({ type: Boolean, reflect: true })
|
|
247
304
|
], DataGridHeader.prototype, "overlayOpen", void 0);
|