@3mo/data-grid 0.5.5 → 0.5.7

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.
Files changed (35) hide show
  1. package/dist/CsvGenerator.js +2 -3
  2. package/dist/DataGrid.d.ts +3 -1
  3. package/dist/DataGrid.d.ts.map +1 -1
  4. package/dist/DataGrid.js +294 -297
  5. package/dist/DataGridCell.js +46 -50
  6. package/dist/DataGridFooter.js +93 -94
  7. package/dist/DataGridHeader.js +92 -92
  8. package/dist/DataGridHeaderSeparator.js +46 -47
  9. package/dist/DataGridPrimaryContextMenuItem.js +5 -5
  10. package/dist/DataGridSelectionController.js +1 -2
  11. package/dist/DataGridSidePanel.d.ts.map +1 -1
  12. package/dist/DataGridSidePanel.js +117 -130
  13. package/dist/FieldSelectDataGridPageSize.js +7 -7
  14. package/dist/columns/DataGridColumn.js +4 -7
  15. package/dist/columns/DataGridColumn.test.js +6 -6
  16. package/dist/columns/DataGridColumnBoolean.js +9 -9
  17. package/dist/columns/DataGridColumnImage.js +2 -2
  18. package/dist/columns/DataGridColumnText.js +6 -6
  19. package/dist/columns/date-time/DataGridColumnDate.js +1 -2
  20. package/dist/columns/date-time/DataGridColumnDateRange.js +1 -2
  21. package/dist/columns/date-time/DataGridColumnDateTime.js +1 -2
  22. package/dist/columns/date-time/DataGridColumnDateTimeBase.js +10 -11
  23. package/dist/columns/date-time/DataGridColumnDateTimeRange.js +1 -2
  24. package/dist/columns/number/DataGridColumnCurrency.js +10 -11
  25. package/dist/columns/number/DataGridColumnNumber.js +6 -7
  26. package/dist/columns/number/DataGridColumnNumberBase.js +5 -1
  27. package/dist/columns/number/DataGridColumnPercent.js +7 -8
  28. package/dist/columns/number/DataGridFooterSum.js +20 -20
  29. package/dist/excel.svg.js +47 -47
  30. package/dist/rows/DataGridDefaultRow.js +47 -47
  31. package/dist/rows/DataGridRow.d.ts +2 -0
  32. package/dist/rows/DataGridRow.d.ts.map +1 -1
  33. package/dist/rows/DataGridRow.js +159 -147
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +55 -56
@@ -16,17 +16,18 @@ export class DataGridRow extends Component {
16
16
  super(...arguments);
17
17
  this.selected = false;
18
18
  this.detailsOpen = false;
19
+ this.level = 0;
19
20
  this.contextMenuOpen = false;
20
21
  }
21
22
  get detailsElement() {
22
- var _a;
23
- return (_a = this.renderRoot.querySelector('#detailsContainer')) === null || _a === void 0 ? void 0 : _a.firstElementChild;
23
+ return this.renderRoot.querySelector('#detailsContainer')?.firstElementChild;
24
24
  }
25
25
  initialized() {
26
26
  this.toggleAttribute('mo-data-grid-row', true);
27
27
  }
28
28
  updated(...parameters) {
29
29
  this.cells.forEach(cell => cell.requestUpdate());
30
+ this.subRows.forEach(subRow => subRow.requestUpdate());
30
31
  if (this.detailsElement instanceof LitElement) {
31
32
  this.detailsElement.requestUpdate();
32
33
  }
@@ -36,157 +37,159 @@ export class DataGridRow extends Component {
36
37
  return this.dataGrid.hasDetail(this.data);
37
38
  }
38
39
  static get styles() {
39
- return css `
40
- :host {
41
- display: block;
42
- position: relative;
43
- height: auto;
44
- width: 100%;
45
- }
46
-
47
- :host(:hover) #contentContainer {
48
- color: inherit;
49
- background: var(--mo-color-accent-transparent) !important;
50
- }
51
-
52
- :host(:hover) #contentContainer::before, #detailsContainer::before {
53
- content: '';
54
- width: 2px;
55
- height: 100%;
56
- top: 0;
57
- inset-inline-start: 0;
58
- position: absolute;
59
- background-color: var(--mo-color-accent);
60
- }
61
-
62
- :host([data-has-alternating-background]) {
63
- background: var(--mo-data-grid-alternating-background);
64
- }
65
-
66
- #contentContainer {
67
- cursor: pointer;
68
- transition: 250ms;
69
- }
70
-
71
- :host([selected]) #contentContainer, :host([contextMenuOpen]) #contentContainer {
72
- background: var(--mo-data-grid-selection-background) !important;
73
- }
74
-
75
- :host([selected]:not(:last-of-type)) #contentContainer:after {
76
- content: '';
77
- position: absolute;
78
- bottom: 0;
79
- inset-inline-start: 0;
80
- width: 100%;
81
- border-bottom: 1px solid var(--mo-color-gray-transparent);
82
- }
83
-
84
- #contextMenuIconButton {
85
- transition: 250ms;
86
- opacity: 0.5;
87
- color: var(--mo-color-gray);
88
- }
89
-
90
- :host([selected]) #contextMenuIconButton, :host([contextMenuOpen]) #contextMenuIconButton {
91
- color: var(--mo-color-foreground);
92
- opacity: 1;
93
- }
94
-
95
- #contentContainer:hover #contextMenuIconButton {
96
- color: var(--mo-color-accent);
97
- opacity: 1;
98
- }
99
-
100
- #detailsExpanderIconButton {
101
- transition: 250ms;
102
- }
103
-
104
- #detailsExpanderIconButton:hover {
105
- color: var(--mo-color-accent);
106
- }
107
-
108
- :host([detailsOpen]) #detailsExpanderIconButton {
109
- transform: rotate(90deg);
110
- }
111
-
112
- #detailsContainer {
113
- display: inline-block;
114
- padding: 0;
115
- width: 100%;
116
- }
117
-
118
- #detailsContainer:empty {
119
- display: none;
120
- }
121
-
122
- #detailsContainer > :first-child {
123
- padding: 8px 0;
124
- }
40
+ return css `
41
+ :host {
42
+ display: block;
43
+ position: relative;
44
+ height: auto;
45
+ width: 100%;
46
+ }
47
+
48
+ :host(:hover) #contentContainer {
49
+ color: inherit;
50
+ background: var(--mo-color-accent-transparent) !important;
51
+ }
52
+
53
+ :host(:hover) #contentContainer::before, #detailsContainer::before {
54
+ content: '';
55
+ width: 2px;
56
+ height: 100%;
57
+ top: 0;
58
+ inset-inline-start: 0;
59
+ position: absolute;
60
+ background-color: var(--mo-color-accent);
61
+ }
62
+
63
+ :host([data-has-alternating-background]) {
64
+ background: var(--mo-data-grid-alternating-background);
65
+ }
66
+
67
+ #contentContainer {
68
+ cursor: pointer;
69
+ transition: 250ms;
70
+ }
71
+
72
+ :host([selected]) #contentContainer, :host([contextMenuOpen]) #contentContainer {
73
+ background: var(--mo-data-grid-selection-background) !important;
74
+ }
75
+
76
+ :host([selected]:not(:last-of-type)) #contentContainer:after {
77
+ content: '';
78
+ position: absolute;
79
+ bottom: 0;
80
+ inset-inline-start: 0;
81
+ width: 100%;
82
+ border-bottom: 1px solid var(--mo-color-gray-transparent);
83
+ }
84
+
85
+ #contextMenuIconButton {
86
+ transition: 250ms;
87
+ opacity: 0.5;
88
+ color: var(--mo-color-gray);
89
+ }
90
+
91
+ :host([selected]) #contextMenuIconButton, :host([contextMenuOpen]) #contextMenuIconButton {
92
+ color: var(--mo-color-foreground);
93
+ opacity: 1;
94
+ }
95
+
96
+ #contentContainer:hover #contextMenuIconButton {
97
+ color: var(--mo-color-accent);
98
+ opacity: 1;
99
+ }
100
+
101
+ #detailsExpanderIconButton {
102
+ transition: 250ms;
103
+ }
104
+
105
+ #detailsExpanderIconButton:hover {
106
+ color: var(--mo-color-accent);
107
+ }
108
+
109
+ :host([detailsOpen]) #detailsExpanderIconButton {
110
+ transform: rotate(90deg);
111
+ }
112
+
113
+ #detailsContainer {
114
+ display: inline-block;
115
+ padding: 0;
116
+ width: 100%;
117
+ }
118
+
119
+ #detailsContainer:empty {
120
+ display: none;
121
+ }
122
+
123
+ #detailsContainer > :first-child {
124
+ padding: 8px 0;
125
+ }
126
+
127
+ mo-data-grid-cell:first-of-type:not([alignment=end]), mo-data-grid-cell[alignment=end]:first-of-type + mo-data-grid-cell {
128
+ margin-inline-start: calc(var(--_level, 0) * var(--mo-data-grid-column-sub-row-indentation, 10px));
129
+ }
125
130
  `;
126
131
  }
127
132
  get template() {
128
- return html `
129
- <mo-grid id='contentContainer'
130
- @click=${() => this.handleContentClick()}
131
- @dblclick=${() => this.handleContentDoubleClick()}
132
- @auxclick=${(e) => e.button !== 1 ? void 0 : this.handleContentMiddleClick()}
133
- @contextmenu=${(e) => this.openContextMenu(e)}
134
- >
135
- ${this.rowTemplate}
136
- </mo-grid>
137
- <slot id='detailsContainer'>${this.detailsOpen ? this.detailsTemplate : html.nothing}</slot>
133
+ return html `
134
+ <mo-grid id='contentContainer'
135
+ @click=${() => this.handleContentClick()}
136
+ @dblclick=${() => this.handleContentDoubleClick()}
137
+ @auxclick=${(e) => e.button !== 1 ? void 0 : this.handleContentMiddleClick()}
138
+ @contextmenu=${(e) => this.openContextMenu(e)}
139
+ >
140
+ ${this.rowTemplate}
141
+ </mo-grid>
142
+ <slot id='detailsContainer'>${this.detailsOpen ? this.detailsTemplate : html.nothing}</slot>
138
143
  `;
139
144
  }
140
145
  get detailsExpanderTemplate() {
141
- var _a, _b;
142
- return this.dataGrid.hasDetails === false ? html.nothing : html `
143
- <mo-flex justifyContent='center' alignItems='center' ${style({ width: 'var(--mo-data-grid-column-details-width)' })}
144
- @click=${(e) => e.stopPropagation()}
145
- @dblclick=${(e) => e.stopPropagation()}
146
- >
147
- ${this.hasDetails === false ? html.nothing : html `
148
- <mo-icon-button id='detailsExpanderIconButton' ${style({ color: 'var(--mo-color-foreground)' })}
149
- icon=${getComputedStyle(this).direction === 'rtl' ? 'keyboard_arrow_left' : 'keyboard_arrow_right'}
150
- ?disabled=${((_b = (_a = this.dataGrid).hasDataDetail) === null || _b === void 0 ? void 0 : _b.call(_a, this.data)) === false}
151
- @click=${() => this.toggleDetails()}
152
- ></mo-icon-button>
153
- `}
154
- </mo-flex>
146
+ return this.dataGrid.hasDetails === false ? html.nothing : html `
147
+ <mo-flex justifyContent='center' alignItems='center' ${style({ width: 'var(--mo-data-grid-column-details-width)' })}
148
+ @click=${(e) => e.stopPropagation()}
149
+ @dblclick=${(e) => e.stopPropagation()}
150
+ >
151
+ ${this.hasDetails === false ? html.nothing : html `
152
+ <mo-icon-button id='detailsExpanderIconButton' ${style({ color: 'var(--mo-color-foreground)' })}
153
+ icon=${getComputedStyle(this).direction === 'rtl' ? 'keyboard_arrow_left' : 'keyboard_arrow_right'}
154
+ ?disabled=${this.dataGrid.hasDataDetail?.(this.data) === false}
155
+ @click=${() => this.toggleDetails()}
156
+ ></mo-icon-button>
157
+ `}
158
+ </mo-flex>
155
159
  `;
156
160
  }
157
161
  get selectionTemplate() {
158
- var _a, _b;
159
- return this.dataGrid.hasSelection === false || this.dataGrid.selectionCheckboxesHidden ? html.nothing : html `
160
- <mo-flex id='selectionContainer' ${style({ width: 'var(--mo-data-grid-column-selection-width)' })} justifyContent='center' alignItems='center'
161
- @click=${(e) => e.stopPropagation()}
162
- @dblclick=${(e) => e.stopPropagation()}
163
- >
164
- <mo-checkbox
165
- tabindex='-1'
166
- ?disabled=${((_b = (_a = this.dataGrid).isDataSelectable) === null || _b === void 0 ? void 0 : _b.call(_a, this.data)) === false}
167
- ?selected=${this.selected}
168
- @change=${(e) => this.setSelection(e.detail)}
169
- ></mo-checkbox>
170
- </mo-flex>
162
+ return this.dataGrid.hasSelection === false || this.dataGrid.selectionCheckboxesHidden ? html.nothing : html `
163
+ <mo-flex id='selectionContainer' ${style({ width: 'var(--mo-data-grid-column-selection-width)' })} justifyContent='center' alignItems='center'
164
+ @click=${(e) => e.stopPropagation()}
165
+ @dblclick=${(e) => e.stopPropagation()}
166
+ >
167
+ <mo-checkbox
168
+ tabindex='-1'
169
+ ?disabled=${this.dataGrid.isDataSelectable?.(this.data) === false}
170
+ ?selected=${this.selected}
171
+ @change=${(e) => this.setSelection(e.detail)}
172
+ ></mo-checkbox>
173
+ </mo-flex>
171
174
  `;
172
175
  }
173
176
  getCellTemplate(column) {
174
- return column.hidden ? html.nothing : html `
175
- <mo-data-grid-cell
176
- .row=${this}
177
- .column=${column}
178
- .value=${getValueByKeyPath(this.data, column.dataSelector)}
179
- ></mo-data-grid-cell>
177
+ return column.hidden ? html.nothing : html `
178
+ <mo-data-grid-cell
179
+ .row=${this}
180
+ .column=${column}
181
+ .value=${getValueByKeyPath(this.data, column.dataSelector)}
182
+ ></mo-data-grid-cell>
180
183
  `;
181
184
  }
182
185
  get contextMenuIconButtonTemplate() {
183
- return this.dataGrid.hasContextMenu === false ? html.nothing : html `
184
- <mo-flex justifyContent='center' alignItems='center'
185
- @click=${this.openContextMenu}
186
- @dblclick=${(e) => e.stopPropagation()}
187
- >
188
- <mo-icon-button id='contextMenuIconButton' icon='more_vert'></mo-icon-button>
189
- </mo-flex>
186
+ return this.dataGrid.hasContextMenu === false ? html.nothing : html `
187
+ <mo-flex justifyContent='center' alignItems='center'
188
+ @click=${this.openContextMenu}
189
+ @dblclick=${(e) => e.stopPropagation()}
190
+ >
191
+ <mo-icon-button id='contextMenuIconButton' icon='more_vert'></mo-icon-button>
192
+ </mo-flex>
190
193
  `;
191
194
  }
192
195
  get detailsTemplate() {
@@ -198,10 +201,10 @@ export class DataGridRow extends Component {
198
201
  }
199
202
  const subData = this.dataGrid.getSubData(this.data);
200
203
  if (subData) {
201
- return html `
202
- <mo-flex style='width: 100%; padding: 0px'>
203
- ${subData.map(data => this.dataGrid.getRowTemplate(data))}
204
- </mo-flex>
204
+ return html `
205
+ <mo-flex style='width: 100%; padding: 0px'>
206
+ ${subData.map(data => this.dataGrid.getRowTemplate(data, undefined, this.level + 1))}
207
+ </mo-flex>
205
208
  `;
206
209
  }
207
210
  return html.nothing;
@@ -228,10 +231,9 @@ export class DataGridRow extends Component {
228
231
  this.dataGrid.rowMiddleClick.dispatch(this);
229
232
  }
230
233
  async clickOnPrimaryContextMenuItemIfApplicable() {
231
- var _a, _b;
232
234
  if (this.dataGrid.hasContextMenu === true && this.dataGrid.primaryContextMenuItemOnDoubleClick === true) {
233
235
  await this.openContextMenu();
234
- (_b = (_a = ContextMenu.openInstance) === null || _a === void 0 ? void 0 : _a.items.find(item => item instanceof DataGridPrimaryContextMenuItem)) === null || _b === void 0 ? void 0 : _b.click();
236
+ ContextMenu.openInstance?.items.find(item => item instanceof DataGridPrimaryContextMenuItem)?.click();
235
237
  this.contextMenuOpen = false;
236
238
  }
237
239
  }
@@ -239,7 +241,7 @@ export class DataGridRow extends Component {
239
241
  if (!this.dataGrid.hasContextMenu) {
240
242
  return;
241
243
  }
242
- mouseEvent === null || mouseEvent === void 0 ? void 0 : mouseEvent.stopPropagation();
244
+ mouseEvent?.stopPropagation();
243
245
  if (this.dataGrid.selectedData.includes(this.data) === false) {
244
246
  this.dataGrid.select(this.dataGrid.selectionMode !== DataGridSelectionMode.None ? [this.data] : []);
245
247
  }
@@ -260,8 +262,7 @@ export class DataGridRow extends Component {
260
262
  : this.dataGrid.selectedData;
261
263
  }
262
264
  get contextMenuTemplate() {
263
- var _a, _b, _c;
264
- return (_c = (_b = (_a = this.dataGrid).getRowContextMenuTemplate) === null || _b === void 0 ? void 0 : _b.call(_a, this.contextMenuData)) !== null && _c !== void 0 ? _c : html.nothing;
265
+ return this.dataGrid.getRowContextMenuTemplate?.(this.contextMenuData) ?? html.nothing;
265
266
  }
266
267
  async closeContextMenu() {
267
268
  this.contextMenuOpen = false;
@@ -281,6 +282,9 @@ __decorate([
281
282
  __decorate([
282
283
  queryAll('mo-data-grid-cell')
283
284
  ], DataGridRow.prototype, "cells", void 0);
285
+ __decorate([
286
+ queryAll('[mo-data-grid-row]')
287
+ ], DataGridRow.prototype, "subRows", void 0);
284
288
  __decorate([
285
289
  property({ type: Object })
286
290
  ], DataGridRow.prototype, "dataGrid", void 0);
@@ -306,6 +310,14 @@ __decorate([
306
310
  }
307
311
  })
308
312
  ], DataGridRow.prototype, "detailsOpen", void 0);
313
+ __decorate([
314
+ property({
315
+ type: Number,
316
+ updated() {
317
+ this.style.setProperty('--_level', this.level.toString());
318
+ }
319
+ })
320
+ ], DataGridRow.prototype, "level", void 0);
309
321
  __decorate([
310
322
  property({ type: Boolean, reflect: true })
311
323
  ], DataGridRow.prototype, "contextMenuOpen", void 0);