@3mo/data-grid 0.20.1 → 0.20.2

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.
@@ -50,222 +50,221 @@ export class DataGridRow extends Component {
50
50
  return this.dataGrid.detailsController.hasDetail(this.dataRecord);
51
51
  }
52
52
  static get styles() {
53
- return css `
54
- :host {
55
- display: block;
56
- position: relative;
57
- height: auto;
58
- width: 100%;
59
- }
60
-
61
- #detailsExpanderContainer {
62
- position: sticky;
63
- z-index: 2;
64
- inset-inline-start: 0px;
65
- background: var(--mo-data-grid-sticky-expander-part-color, var(--mo-data-grid-sticky-part-color));
66
- }
67
-
68
- #selectionContainer {
69
- width: var(--mo-data-grid-column-selection-width);
70
- position: sticky;
71
- z-index: 2;
72
- inset-inline-start: 0px;
73
- height: 100%;
74
- background: var(--mo-data-grid-sticky-part-color);
75
- &[data-has-details] {
76
- inset-inline-start: 20px;
77
- }
78
- }
79
-
80
- :host(:hover) {
81
- #contentContainer {
82
- --mo-data-grid-sticky-part-color: color-mix(in srgb, var(--mo-color-surface), var(--mo-color-accent) 25%) !important;
83
- color: inherit;
84
- background: var(--mo-color-accent-transparent) !important;
85
- }
86
-
87
- #contentContainer, #detailsContainer {
88
- &::before {
89
- content: '';
90
- width: 2px;
91
- height: 100%;
92
- top: 0;
93
- inset-inline-start: 0;
94
- position: absolute;
95
- background-color: var(--mo-color-accent);
96
- z-index: 2;
97
- }
98
- }
99
- }
100
-
101
- :host([data-has-alternating-background]) {
102
- #contentContainer, #detailsContainer:not(:has([instanceof*=mo-data-grid])) {
103
- background: var(--mo-data-grid-alternating-background);
104
- --mo-data-grid-sticky-part-color: color-mix(in srgb, var(--mo-color-surface), black var(--mo-data-grid-alternating-background-transparency));
105
- }
106
- }
107
-
108
- #contentContainer {
109
- grid-column: -1 / 1;
110
- cursor: pointer;
111
- }
112
-
113
- #contextMenuIconButtonContainer {
114
- height: 100%;
115
- place-self: end;
116
- position: sticky;
117
- inset-inline-end: 0px;
118
- z-index: 3;
119
- background: var(--mo-data-grid-sticky-part-color);
120
- }
121
-
122
- #contextMenuIconButton {
123
- opacity: 0.5;
124
- color: var(--mo-color-gray);
125
- }
126
-
127
- :host([selected]), :host([data-context-menu-open]) {
128
- #contentContainer {
129
- --mo-data-grid-sticky-part-color: color-mix(in srgb, var(--mo-color-surface), var(--mo-color-accent)) !important;
130
- background: var(--mo-data-grid-selection-background) !important;
131
- }
132
-
133
- #contextMenuIconButton {
134
- color: currentColor;
135
- opacity: 1;
136
- }
137
- }
138
-
139
- #contentContainer:hover #contextMenuIconButton {
140
- color: currentColor;
141
- opacity: 1;
142
- }
143
-
144
- #detailsExpanderIconButton {
145
- transition: transform 250ms;
146
-
147
- &[data-rtl] {
148
- transform: rotate(180deg);
149
- }
150
- }
151
-
152
- :host([detailsOpen]) #detailsExpanderIconButton {
153
- transform: rotate(90deg);
154
- }
155
-
156
- #detailsContainer {
157
- display: grid;
158
- grid-template-columns: subgrid;
159
- grid-column: -1 / 1;
160
-
161
- &:empty {
162
- display: none;
163
- }
164
-
165
- & > * {
166
- grid-column: data / -1;
167
- box-sizing: border-box;
168
- padding-inline: var(--mo-data-grid-cell-padding);
169
- padding-block: 1rem;
170
-
171
- &[mo-data-grid-row] {
172
- grid-column: -1 / 1;
173
- padding: 0;
174
- }
175
-
176
- &[instanceof*=mo-data-grid] {
177
- padding-inline: 0;
178
- --mo-data-grid-header-background: color-mix(in srgb, var(--mo-color-foreground), transparent 96%);
179
- --mo-data-grid-alternating-background: transparent;
180
- --mo-data-grid-alternating-background-transparency: 0;
181
- --_content-min-height-default: 0px;
182
-
183
- &::part(row) {
184
- border-block-end: var(--mo-data-grid-border);
185
- }
186
- }
187
- }
188
- }
189
-
190
- mo-data-grid-cell:first-of-type:not([alignment=end]), mo-data-grid-cell[alignment=end]:first-of-type + mo-data-grid-cell {
191
- margin-inline-start: calc(var(--_level, 0) * var(--mo-data-grid-column-sub-row-indentation, 20px));
192
- }
53
+ return css `
54
+ :host {
55
+ display: block;
56
+ position: relative;
57
+ height: auto;
58
+ width: 100%;
59
+ }
60
+
61
+ #detailsExpanderContainer {
62
+ position: sticky;
63
+ z-index: 2;
64
+ inset-inline-start: 0px;
65
+ background: var(--mo-data-grid-sticky-expander-part-color, var(--mo-data-grid-sticky-part-color));
66
+ }
67
+
68
+ #selectionContainer {
69
+ width: var(--mo-data-grid-column-selection-width);
70
+ position: sticky;
71
+ z-index: 2;
72
+ inset-inline-start: 0px;
73
+ height: 100%;
74
+ background: var(--mo-data-grid-sticky-part-color);
75
+ &[data-has-details] {
76
+ inset-inline-start: 20px;
77
+ }
78
+ }
79
+
80
+ :host(:hover) {
81
+ #contentContainer {
82
+ --mo-data-grid-sticky-part-color: color-mix(in srgb, var(--mo-color-surface), var(--mo-color-accent) 25%) !important;
83
+ color: inherit;
84
+ background: var(--mo-color-accent-transparent) !important;
85
+ }
86
+
87
+ #contentContainer, #detailsContainer {
88
+ &::before {
89
+ content: '';
90
+ width: 2px;
91
+ height: 100%;
92
+ top: 0;
93
+ inset-inline-start: 0;
94
+ position: absolute;
95
+ background-color: var(--mo-color-accent);
96
+ z-index: 2;
97
+ }
98
+ }
99
+ }
100
+
101
+ :host([data-has-alternating-background]) {
102
+ #contentContainer, #detailsContainer:not(:has([instanceof*=mo-data-grid])) {
103
+ background: var(--mo-data-grid-alternating-background);
104
+ --mo-data-grid-sticky-part-color: color-mix(in srgb, var(--mo-color-surface), black var(--mo-data-grid-alternating-background-transparency));
105
+ }
106
+ }
107
+
108
+ #contentContainer {
109
+ grid-column: -1 / 1;
110
+ }
111
+
112
+ #contextMenuIconButtonContainer {
113
+ height: 100%;
114
+ place-self: end;
115
+ position: sticky;
116
+ inset-inline-end: 0px;
117
+ z-index: 3;
118
+ background: var(--mo-data-grid-sticky-part-color);
119
+ }
120
+
121
+ #contextMenuIconButton {
122
+ opacity: 0.5;
123
+ color: var(--mo-color-gray);
124
+ }
125
+
126
+ :host([selected]), :host([data-context-menu-open]) {
127
+ #contentContainer {
128
+ --mo-data-grid-sticky-part-color: color-mix(in srgb, var(--mo-color-surface), var(--mo-color-accent)) !important;
129
+ background: var(--mo-data-grid-selection-background) !important;
130
+ }
131
+
132
+ #contextMenuIconButton {
133
+ color: currentColor;
134
+ opacity: 1;
135
+ }
136
+ }
137
+
138
+ #contentContainer:hover #contextMenuIconButton {
139
+ color: currentColor;
140
+ opacity: 1;
141
+ }
142
+
143
+ #detailsExpanderIconButton {
144
+ transition: transform 250ms;
145
+
146
+ &[data-rtl] {
147
+ transform: rotate(180deg);
148
+ }
149
+ }
150
+
151
+ :host([detailsOpen]) #detailsExpanderIconButton {
152
+ transform: rotate(90deg);
153
+ }
154
+
155
+ #detailsContainer {
156
+ display: grid;
157
+ grid-template-columns: subgrid;
158
+ grid-column: -1 / 1;
159
+
160
+ &:empty {
161
+ display: none;
162
+ }
163
+
164
+ & > * {
165
+ grid-column: data / -1;
166
+ box-sizing: border-box;
167
+ padding-inline: var(--mo-data-grid-cell-padding);
168
+ padding-block: 1rem;
169
+
170
+ &[mo-data-grid-row] {
171
+ grid-column: -1 / 1;
172
+ padding: 0;
173
+ }
174
+
175
+ &[instanceof*=mo-data-grid] {
176
+ padding-inline: 0;
177
+ --mo-data-grid-header-background: color-mix(in srgb, var(--mo-color-foreground), transparent 96%);
178
+ --mo-data-grid-alternating-background: transparent;
179
+ --mo-data-grid-alternating-background-transparency: 0;
180
+ --_content-min-height-default: 0px;
181
+
182
+ &::part(row) {
183
+ border-block-end: var(--mo-data-grid-border);
184
+ }
185
+ }
186
+ }
187
+ }
188
+
189
+ mo-data-grid-cell:first-of-type:not([alignment=end]), mo-data-grid-cell[alignment=end]:first-of-type + mo-data-grid-cell {
190
+ margin-inline-start: calc(var(--_level, 0) * var(--mo-data-grid-column-sub-row-indentation, 20px));
191
+ }
193
192
  `;
194
193
  }
195
194
  get template() {
196
195
  this.style.setProperty('--_level', this.level.toString());
197
196
  this.toggleAttribute('selected', this.dataRecord.isSelected);
198
197
  this.toggleAttribute('detailsOpen', this.dataRecord.detailsOpen);
199
- return !this.isIntersecting ? html.nothing : html `
200
- <mo-grid id='contentContainer' columns='subgrid'
201
- @click=${() => this.handleContentClick()}
202
- @dblclick=${() => this.handleContentDoubleClick()}
203
- @auxclick=${(e) => e.button !== 1 ? void 0 : this.handleContentMiddleClick()}
204
- ${this.contextMenuTemplate === html.nothing ? html.nothing : popover(() => html `
205
- <mo-context-menu @openChange=${(e) => this.handleContextMenuOpenChange(e.detail)}>
206
- ${this.contextMenuTemplate}
207
- </mo-context-menu>
208
- `)}
209
- >
210
- ${this.rowTemplate}
211
- </mo-grid>
212
- <slot id='detailsContainer'>${this.detailsOpen ? this.detailsTemplate : html.nothing}</slot>
198
+ return !this.isIntersecting ? html.nothing : html `
199
+ <mo-grid id='contentContainer' columns='subgrid'
200
+ @click=${() => this.handleContentClick()}
201
+ @dblclick=${() => this.handleContentDoubleClick()}
202
+ @auxclick=${(e) => e.button !== 1 ? void 0 : this.handleContentMiddleClick()}
203
+ ${this.contextMenuTemplate === html.nothing ? html.nothing : popover(() => html `
204
+ <mo-context-menu @openChange=${(e) => this.handleContextMenuOpenChange(e.detail)}>
205
+ ${this.contextMenuTemplate}
206
+ </mo-context-menu>
207
+ `)}
208
+ >
209
+ ${this.rowTemplate}
210
+ </mo-grid>
211
+ <slot id='detailsContainer'>${this.detailsOpen ? this.detailsTemplate : html.nothing}</slot>
213
212
  `;
214
213
  }
215
214
  get detailsExpanderTemplate() {
216
- return this.dataGrid.hasDetails === false ? html.nothing : html `
217
- <mo-flex id='detailsExpanderContainer' justifyContent='center' alignItems='center'
218
- @click=${(e) => e.stopPropagation()}
219
- @dblclick=${(e) => e.stopPropagation()}
220
- >
221
- ${this.hasDetails === false ? html.nothing : html `
222
- <mo-icon-button id='detailsExpanderIconButton'
223
- icon='keyboard_arrow_right'
224
- ?data-rtl=${DirectionsByLanguage.get() === 'rtl'}
225
- @click=${() => this.toggleDetails()}
226
- ></mo-icon-button>
227
- `}
228
- </mo-flex>
215
+ return this.dataGrid.hasDetails === false ? html.nothing : html `
216
+ <mo-flex id='detailsExpanderContainer' justifyContent='center' alignItems='center'
217
+ @click=${(e) => e.stopPropagation()}
218
+ @dblclick=${(e) => e.stopPropagation()}
219
+ >
220
+ ${this.hasDetails === false ? html.nothing : html `
221
+ <mo-icon-button id='detailsExpanderIconButton'
222
+ icon='keyboard_arrow_right'
223
+ ?data-rtl=${DirectionsByLanguage.get() === 'rtl'}
224
+ @click=${() => this.toggleDetails()}
225
+ ></mo-icon-button>
226
+ `}
227
+ </mo-flex>
229
228
  `;
230
229
  }
231
230
  get selectionTemplate() {
232
- return !this.dataGrid.hasSelection ? html.nothing : html `
233
- <mo-flex id='selectionContainer' justifyContent='center' alignItems='center'
234
- ?data-has-details=${this.dataGrid.hasDetails}
235
- @click=${(e) => e.stopPropagation()}
236
- @dblclick=${(e) => e.stopPropagation()}
237
- >
238
- <mo-checkbox
239
- tabindex='-1'
240
- ?disabled=${this.dataRecord.isSelectable === false}
241
- .selected=${live(this.selected)}
242
- @change=${(e) => this.dataGrid.selectionController.setSelection(this.data, e.detail, true)}
243
- ></mo-checkbox>
244
- </mo-flex>
231
+ return !this.dataGrid.hasSelection ? html.nothing : html `
232
+ <mo-flex id='selectionContainer' justifyContent='center' alignItems='center'
233
+ ?data-has-details=${this.dataGrid.hasDetails}
234
+ @click=${(e) => e.stopPropagation()}
235
+ @dblclick=${(e) => e.stopPropagation()}
236
+ >
237
+ <mo-checkbox
238
+ tabindex='-1'
239
+ ?disabled=${this.dataRecord.isSelectable === false}
240
+ .selected=${live(this.selected)}
241
+ @change=${(e) => this.dataGrid.selectionController.setSelection(this.data, e.detail, true)}
242
+ ></mo-checkbox>
243
+ </mo-flex>
245
244
  `;
246
245
  }
247
246
  getCellTemplate(column) {
248
- return column.hidden ? html.nothing : html `
249
- <mo-data-grid-cell
250
- .row=${this}
251
- .column=${column}
252
- .value=${KeyPath.get(this.data, column.dataSelector)}
253
- @keydown=${this.delegateToCell('handleKeyDown')}
254
- @dblclick=${this.delegateToCell('handleDoubleClick')}
255
- ></mo-data-grid-cell>
247
+ return column.hidden ? html.nothing : html `
248
+ <mo-data-grid-cell
249
+ .row=${this}
250
+ .column=${column}
251
+ .value=${KeyPath.get(this.data, column.dataSelector)}
252
+ @keydown=${this.delegateToCell('handleKeyDown')}
253
+ @dblclick=${this.delegateToCell('handleDoubleClick')}
254
+ ></mo-data-grid-cell>
256
255
  `;
257
256
  }
258
257
  get fillerTemplate() {
259
258
  return html `<span></span>`;
260
259
  }
261
260
  get contextMenuIconButtonTemplate() {
262
- return this.dataGrid.hasContextMenu === false ? html.nothing : html `
263
- <mo-flex id='contextMenuIconButtonContainer' justifyContent='center'>
264
- <mo-icon-button id='contextMenuIconButton' icon='more_vert' dense
265
- @click=${this.openContextMenu}
266
- @dblclick=${(e) => e.stopPropagation()}
267
- ></mo-icon-button>
268
- </mo-flex>
261
+ return this.dataGrid.hasContextMenu === false ? html.nothing : html `
262
+ <mo-flex id='contextMenuIconButtonContainer' justifyContent='center'>
263
+ <mo-icon-button id='contextMenuIconButton' icon='more_vert' dense
264
+ @click=${this.openContextMenu}
265
+ @dblclick=${(e) => e.stopPropagation()}
266
+ ></mo-icon-button>
267
+ </mo-flex>
269
268
  `;
270
269
  }
271
270
  get detailsTemplate() {
@@ -275,8 +274,8 @@ export class DataGridRow extends Component {
275
274
  if (this.dataGrid.getRowDetailsTemplate) {
276
275
  return this.dataGrid.getRowDetailsTemplate(this.data);
277
276
  }
278
- return !this.dataRecord.hasSubData ? html.nothing : html `
279
- ${this.dataRecord.getSubDataByLevel(this.level + 1)?.map(data => this.dataGrid.getRowTemplate(data))}
277
+ return !this.dataRecord.hasSubData ? html.nothing : html `
278
+ ${this.dataRecord.getSubDataByLevel(this.level + 1)?.map(data => this.dataGrid.getRowTemplate(data))}
280
279
  `;
281
280
  }
282
281
  handleContentClick() {