@3mo/data-grid 0.2.6 → 0.2.8

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
- export let DataGridDefaultRow = class DataGridDefaultRow extends DataGridRow {
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-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,14 +55,15 @@ export 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 };
@@ -1 +1 @@
1
- {"version":3,"file":"DataGridRow.d.ts","sourceRoot":"","sources":["../../rows/DataGridRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,SAAS,EAAyB,kBAAkB,EAAqB,MAAM,WAAW,CAAA;AAG3H,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAyD,MAAM,aAAa,CAAA;AAE3G;;;;;;;;GAQG;AACH,8BAAsB,WAAW,CAAC,KAAK,EAAE,eAAe,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,CAAE,SAAQ,SAAS;IACzG,QAAQ,CAAC,iBAAiB,EAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IAE/B,QAAQ,CAAC,KAAK,EAAG,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAA;IAEpE,QAAQ,EAAG,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC,CAAA;IAC3C,IAAI,EAAG,KAAK,CAAA;IACI,QAAQ,UAAQ;IAChB,WAAW,UAAQ;IAEnB,SAAS,CAAC,eAAe,UAAQ;IAE7E,IAAI,cAAc,gCAEjB;cAEkB,WAAW;IAIrB,OAAO,CAAC,GAAG,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAQhE,SAAS,KAAK,UAAU,YAEvB;IAED,WAAoB,MAAM,kCAwFzB;IAED,cAAuB,QAAQ,yCAW9B;IAED,SAAS,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CAAC,CAAA;IAEpE,QAAQ,EAAG,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC,CAAA;IAC3C,IAAI,EAAG,KAAK,CAAA;IACI,QAAQ,UAAQ;IAChB,WAAW,UAAQ;IAEnB,SAAS,CAAC,eAAe,UAAQ;IAE7E,IAAI,cAAc,gCAEjB;cAEkB,WAAW;IAIrB,OAAO,CAAC,GAAG,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAQhE,SAAS,KAAK,UAAU,YAEvB;IAED,WAAoB,MAAM,kCA4FzB;IAED,cAAuB,QAAQ,yCAW9B;IAED,SAAS,CAAC,QAAQ,KAAK,WAAW,IAAI,kBAAkB,CAAA;IAExD,SAAS,KAAK,uBAAuB,uBAepC;IAED,SAAS,KAAK,iBAAiB,uBAc9B;IAED,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAUlG,SAAS,KAAK,6BAA6B,uBAS1C;IAED,SAAS,KAAK,eAAe,uBAK5B;IAED,OAAO,CAAC,YAAY;IAsCpB,SAAS,CAAC,kBAAkB;cAYZ,wBAAwB;IAUlC,eAAe,CAAC,UAAU,CAAC,EAAE,UAAU;IAwB7C,OAAO,KAAK,eAAe,GAI1B;IAED,OAAO,KAAK,mBAAmB,GAE9B;IAEK,gBAAgB;IAKtB,SAAS,CAAC,aAAa;IAIvB,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO;CAInC;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,kBAAkB,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;KACxC;CACD"}
@@ -37,156 +37,160 @@ 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
+ :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([detailsOpen]) #contentContainer {
73
+ background: var(--mo-data-grid-row-background-on-opened-detail-element, var(--mo-color-accent-transparent));
74
+ }
75
+
76
+ :host([selected]) #contentContainer, :host([contextMenuOpen]) #contentContainer {
77
+ background: var(--mo-data-grid-selection-background) !important;
78
+ }
79
+
80
+ :host([selected]:not(:last-of-type)) #contentContainer:after {
81
+ content: '';
82
+ position: absolute;
83
+ bottom: 0;
84
+ inset-inline-start: 0;
85
+ width: 100%;
86
+ border-bottom: 1px solid var(--mo-color-gray-transparent);
87
+ }
88
+
89
+ #contextMenuIconButton {
90
+ transition: 250ms;
91
+ opacity: 0.5;
92
+ color: var(--mo-color-gray);
93
+ }
94
+
95
+ :host([selected]) #contextMenuIconButton, :host([contextMenuOpen]) #contextMenuIconButton {
96
+ color: var(--mo-color-foreground);
97
+ opacity: 1;
98
+ }
99
+
100
+ #contentContainer:hover #contextMenuIconButton {
101
+ color: var(--mo-color-accent);
102
+ opacity: 1;
103
+ }
104
+
105
+ #detailsExpanderIconButton {
106
+ transition: 250ms;
107
+ }
108
+
109
+ #detailsExpanderIconButton:hover {
110
+ color: var(--mo-color-accent);
111
+ }
112
+
113
+ :host([detailsOpen]) #detailsExpanderIconButton {
114
+ transform: rotate(90deg);
115
+ }
116
+
117
+ #detailsContainer {
118
+ display: inline-block;
119
+ padding: 0;
120
+ width: 100%;
121
+ }
122
+
123
+ #detailsContainer:empty {
124
+ display: none;
125
+ }
126
+
127
+ #detailsContainer > :first-child {
128
+ padding: 8px 0;
129
+ }
126
130
  `;
127
131
  }
128
132
  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>
133
+ return html `
134
+ <mo-grid id='contentContainer'
135
+ @click=${() => this.handleContentClick()}
136
+ @dblclick=${() => this.handleContentDoubleClick()}
137
+ @contextmenu=${(e) => this.openContextMenu(e)}
138
+ >
139
+ ${this.rowTemplate}
140
+ </mo-grid>
141
+ <slot id='detailsContainer'>${this.detailsOpen ? this.detailsTemplate : nothing}</slot>
138
142
  `;
139
143
  }
140
144
  get detailsExpanderTemplate() {
141
145
  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>
146
+ return this.dataGrid.hasDetails === false ? 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 ? 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=${((_b = (_a = this.dataGrid).hasDataDetail) === null || _b === void 0 ? void 0 : _b.call(_a, this.data)) === false}
155
+ @click=${() => this.toggleDetails()}
156
+ ></mo-icon-button>
157
+ `}
158
+ </mo-flex>
155
159
  `;
156
160
  }
157
161
  get selectionTemplate() {
158
162
  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>
163
+ return this.dataGrid.hasSelection === false || this.dataGrid.selectionCheckboxesHidden ? nothing : html `
164
+ <mo-flex id='selectionContainer' ${style({ width: 'var(--mo-data-grid-column-selection-width)' })} justifyContent='center' alignItems='center'
165
+ @click=${(e) => e.stopPropagation()}
166
+ @dblclick=${(e) => e.stopPropagation()}
167
+ >
168
+ <mo-checkbox
169
+ tabindex='-1'
170
+ ?disabled=${((_b = (_a = this.dataGrid).isDataSelectable) === null || _b === void 0 ? void 0 : _b.call(_a, this.data)) === false}
171
+ ?checked=${this.selected}
172
+ @change=${(e) => this.setSelection(e.detail === 'checked')}
173
+ ></mo-checkbox>
174
+ </mo-flex>
171
175
  `;
172
176
  }
173
177
  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>
178
+ return column.hidden ? nothing : html `
179
+ <mo-data-grid-cell
180
+ .row=${this}
181
+ .column=${column}
182
+ .value=${getValueByKeyPath(this.data, column.dataSelector)}
183
+ ></mo-data-grid-cell>
180
184
  `;
181
185
  }
182
186
  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>
187
+ return this.dataGrid.hasContextMenu === false ? nothing : html `
188
+ <mo-flex justifyContent='center' alignItems='center'
189
+ @click=${this.openContextMenu}
190
+ @dblclick=${(e) => e.stopPropagation()}
191
+ >
192
+ <mo-icon-button id='contextMenuIconButton' icon='more_vert'></mo-icon-button>
193
+ </mo-flex>
190
194
  `;
191
195
  }
192
196
  get detailsTemplate() {