@3mo/data-grid 0.2.5 → 0.2.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.
@@ -1,50 +1,50 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { css, component, html } from '@a11d/lit';
3
3
  import { DataGridRow } from './DataGridRow.js';
4
- let DataGridDefaultRow = class DataGridDefaultRow extends DataGridRow {
4
+ export 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-context(:not([hasDetails]):not([selectionMode=single]):not([selectionMode=multiple])) #detailsContainer > [instanceof*=mo-data-grid]:not([headerHidden]) {
36
- margin: 16px var(--mo-details-data-grid-start-margin);
37
- width: calc(100% - calc(var(--mo-details-data-grid-start-margin) * 2));
38
- }
39
-
40
- :host-context(:not([hasDetails]):not([selectionMode=single]):not([selectionMode=multiple])) #detailsContainer > [instanceof*=mo-data-grid] {
41
- padding: 0px !important;
42
- }
43
-
44
- :host-context(:not([hasDetails]):not([selectionMode=single]):not([selectionMode=multiple])) #detailsContainer > [instanceof*=mo-data-grid][headerHidden] {
45
- margin-inline-start: var(--mo-details-data-grid-start-margin);
46
- width: calc(100% - var(--mo-details-data-grid-start-margin));
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-context(:not([hasDetails]):not([selectionMode=single]):not([selectionMode=multiple])) #detailsContainer > [instanceof*=mo-data-grid]:not([headerHidden]) {
36
+ margin: 16px var(--mo-details-data-grid-start-margin);
37
+ width: calc(100% - calc(var(--mo-details-data-grid-start-margin) * 2));
38
+ }
39
+
40
+ :host-context(:not([hasDetails]):not([selectionMode=single]):not([selectionMode=multiple])) #detailsContainer > [instanceof*=mo-data-grid] {
41
+ padding: 0px !important;
42
+ }
43
+
44
+ :host-context(:not([hasDetails]):not([selectionMode=single]):not([selectionMode=multiple])) #detailsContainer > [instanceof*=mo-data-grid][headerHidden] {
45
+ margin-inline-start: var(--mo-details-data-grid-start-margin);
46
+ width: calc(100% - var(--mo-details-data-grid-start-margin));
47
+ }
48
48
  `;
49
49
  }
50
50
  updated(...parameters) {
@@ -55,15 +55,14 @@ 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
  };
66
66
  DataGridDefaultRow = __decorate([
67
67
  component('mo-data-grid-default-row')
68
68
  ], DataGridDefaultRow);
69
- export { DataGridDefaultRow };
@@ -37,156 +37,156 @@ 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) {
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
- #contentContainer {
64
- cursor: pointer;
65
- transition: 250ms;
66
- }
67
-
68
- :host([detailsOpen]) #contentContainer {
69
- background: var(--mo-data-grid-row-background-on-opened-detail-element, var(--mo-color-accent-transparent));
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
- }
40
+ return css `
41
+ :host {
42
+ display: block;
43
+ position: relative;
44
+ height: auto;
45
+ width: 100%;
46
+ }
47
+
48
+ :host(:hover) {
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
+ #contentContainer {
64
+ cursor: pointer;
65
+ transition: 250ms;
66
+ }
67
+
68
+ :host([detailsOpen]) #contentContainer {
69
+ background: var(--mo-data-grid-row-background-on-opened-detail-element, var(--mo-color-accent-transparent));
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
126
  `;
127
127
  }
128
128
  get template() {
129
- return html `
130
- <mo-grid id='contentContainer'
131
- @click=${() => this.handleContentClick()}
132
- @dblclick=${() => this.handleContentDoubleClick()}
133
- @contextmenu=${(e) => this.openContextMenu(e)}
134
- >
135
- ${this.rowTemplate}
136
- </mo-grid>
137
- <slot id='detailsContainer'>${this.detailsOpen ? this.detailsTemplate : nothing}</slot>
129
+ return html `
130
+ <mo-grid id='contentContainer'
131
+ @click=${() => this.handleContentClick()}
132
+ @dblclick=${() => this.handleContentDoubleClick()}
133
+ @contextmenu=${(e) => this.openContextMenu(e)}
134
+ >
135
+ ${this.rowTemplate}
136
+ </mo-grid>
137
+ <slot id='detailsContainer'>${this.detailsOpen ? this.detailsTemplate : nothing}</slot>
138
138
  `;
139
139
  }
140
140
  get detailsExpanderTemplate() {
141
141
  var _a, _b;
142
- return this.dataGrid.hasDetails === false ? 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 ? 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>
142
+ return this.dataGrid.hasDetails === false ? 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 ? 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>
155
155
  `;
156
156
  }
157
157
  get selectionTemplate() {
158
158
  var _a, _b;
159
- return this.dataGrid.hasSelection === false || this.dataGrid.selectionCheckboxesHidden ? 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
- ?checked=${this.selected}
168
- @change=${(e) => this.setSelection(e.detail === 'checked')}
169
- ></mo-checkbox>
170
- </mo-flex>
159
+ return this.dataGrid.hasSelection === false || this.dataGrid.selectionCheckboxesHidden ? 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
+ ?checked=${this.selected}
168
+ @change=${(e) => this.setSelection(e.detail === 'checked')}
169
+ ></mo-checkbox>
170
+ </mo-flex>
171
171
  `;
172
172
  }
173
173
  getCellTemplate(column) {
174
- return column.hidden ? 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>
174
+ return column.hidden ? 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>
180
180
  `;
181
181
  }
182
182
  get contextMenuIconButtonTemplate() {
183
- return this.dataGrid.hasContextMenu === false ? 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>
183
+ return this.dataGrid.hasContextMenu === false ? 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>
190
190
  `;
191
191
  }
192
192
  get detailsTemplate() {