@3mo/data-grid 0.5.9 → 0.5.10

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.
@@ -3,48 +3,48 @@ import { css, component, html } from '@a11d/lit';
3
3
  import { DataGridRow } from './DataGridRow.js';
4
4
  let DataGridDefaultRow = class DataGridDefaultRow extends DataGridRow {
5
5
  static get styles() {
6
- return css `
7
- ${super.styles}
8
-
9
- mo-grid {
10
- height: var(--mo-data-grid-row-height);
11
- grid-template-columns: var(--mo-data-grid-columns);
12
- column-gap: var(--mo-data-grid-columns-gap);
13
- }
14
-
15
- mo-flex {
16
- white-space: nowrap;
17
- text-overflow: ellipsis;
18
- overflow: hidden;
19
- }
20
-
21
- #selectionContainer {
22
- height: var(--mo-data-grid-row-height);
23
- }
24
-
25
- #detailsContainer [instanceof*=mo-data-grid] {
26
- --mo-data-grid-header-background: rgba(var(--mo-color-foreground-base), 0.04);
27
- --mo-data-grid-alternating-background: transparent;
28
- --mo-data-grid-content-min-height: 0px;
29
- }
30
-
31
- #detailsContainer [instanceof*=mo-data-grid]:not([headerHidden]) {
32
- background: var(--mo-color-transparent-gray-1);
33
- }
34
-
35
- :host([data-grid-has-details]) #detailsContainer > [instanceof*=mo-data-grid][headerHidden] {
36
- margin-inline-start: var(--mo-details-data-grid-start-margin);
37
- width: calc(100% - var(--mo-details-data-grid-start-margin));
38
- }
39
-
40
- :host([data-grid-has-details]) #detailsContainer > [instanceof*=mo-data-grid]:not([headerHidden]) {
41
- margin: 16px var(--mo-details-data-grid-start-margin);
42
- width: calc(100% - calc(var(--mo-details-data-grid-start-margin) * 2));
43
- }
44
-
45
- :host([data-grid-has-details]) #detailsContainer > [instanceof*=mo-data-grid] {
46
- padding: 0px !important;
47
- }
6
+ return css `
7
+ ${super.styles}
8
+
9
+ mo-grid {
10
+ height: var(--mo-data-grid-row-height);
11
+ grid-template-columns: var(--mo-data-grid-columns);
12
+ column-gap: var(--mo-data-grid-columns-gap);
13
+ }
14
+
15
+ mo-flex {
16
+ white-space: nowrap;
17
+ text-overflow: ellipsis;
18
+ overflow: hidden;
19
+ }
20
+
21
+ #selectionContainer {
22
+ height: var(--mo-data-grid-row-height);
23
+ }
24
+
25
+ #detailsContainer [instanceof*=mo-data-grid] {
26
+ --mo-data-grid-header-background: rgba(var(--mo-color-foreground-base), 0.04);
27
+ --mo-data-grid-alternating-background: transparent;
28
+ --mo-data-grid-content-min-height: 0px;
29
+ }
30
+
31
+ #detailsContainer [instanceof*=mo-data-grid]:not([headerHidden]) {
32
+ background: var(--mo-color-transparent-gray-1);
33
+ }
34
+
35
+ :host([data-grid-has-details]) #detailsContainer > [instanceof*=mo-data-grid][headerHidden] {
36
+ margin-inline-start: var(--mo-details-data-grid-start-margin);
37
+ width: calc(100% - var(--mo-details-data-grid-start-margin));
38
+ }
39
+
40
+ :host([data-grid-has-details]) #detailsContainer > [instanceof*=mo-data-grid]:not([headerHidden]) {
41
+ margin: 16px var(--mo-details-data-grid-start-margin);
42
+ width: calc(100% - calc(var(--mo-details-data-grid-start-margin) * 2));
43
+ }
44
+
45
+ :host([data-grid-has-details]) #detailsContainer > [instanceof*=mo-data-grid] {
46
+ padding: 0px !important;
47
+ }
48
48
  `;
49
49
  }
50
50
  updated(...parameters) {
@@ -55,11 +55,11 @@ let DataGridDefaultRow = class DataGridDefaultRow extends DataGridRow {
55
55
  }
56
56
  }
57
57
  get rowTemplate() {
58
- return html `
59
- ${this.detailsExpanderTemplate}
60
- ${this.selectionTemplate}
61
- ${this.dataGrid.columns.map(column => this.getCellTemplate(column))}
62
- ${this.contextMenuIconButtonTemplate}
58
+ return html `
59
+ ${this.detailsExpanderTemplate}
60
+ ${this.selectionTemplate}
61
+ ${this.dataGrid.columns.map(column => this.getCellTemplate(column))}
62
+ ${this.contextMenuIconButtonTemplate}
63
63
  `;
64
64
  }
65
65
  };
@@ -37,159 +37,159 @@ export class DataGridRow extends Component {
37
37
  return this.dataGrid.hasDetail(this.data);
38
38
  }
39
39
  static get styles() {
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
- }
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
+ }
130
130
  `;
131
131
  }
132
132
  get template() {
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>
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>
143
143
  `;
144
144
  }
145
145
  get detailsExpanderTemplate() {
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>
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>
159
159
  `;
160
160
  }
161
161
  get selectionTemplate() {
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.selectionController.isSelectable(this.data) === false}
170
- ?selected=${this.selected}
171
- @change=${(e) => this.setSelection(e.detail)}
172
- ></mo-checkbox>
173
- </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.selectionController.isSelectable(this.data) === false}
170
+ ?selected=${this.selected}
171
+ @change=${(e) => this.setSelection(e.detail)}
172
+ ></mo-checkbox>
173
+ </mo-flex>
174
174
  `;
175
175
  }
176
176
  getCellTemplate(column) {
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>
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>
183
183
  `;
184
184
  }
185
185
  get contextMenuIconButtonTemplate() {
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>
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>
193
193
  `;
194
194
  }
195
195
  get detailsTemplate() {
@@ -201,10 +201,10 @@ export class DataGridRow extends Component {
201
201
  }
202
202
  const subData = this.dataGrid.getSubData(this.data);
203
203
  if (subData) {
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>
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>
208
208
  `;
209
209
  }
210
210
  return html.nothing;