@3mo/data-grid 0.1.5 → 0.2.1

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,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { nothing, css, property, Component, html, state, queryAll, style, LitElement, event } from '@a11d/lit';
2
+ import { nothing, css, property, Component, html, queryAll, style, LitElement, event } from '@a11d/lit';
3
3
  import { ContextMenu } from '@3mo/context-menu';
4
4
  import { KeyboardController } from '@3mo/keyboard-controller';
5
5
  import { DataGridPrimaryContextMenuItem } from '../index.js';
@@ -18,21 +18,13 @@ export class DataGridRow extends Component {
18
18
  this.selected = false;
19
19
  this.detailsOpen = false;
20
20
  this.contextMenuOpen = false;
21
- this.editing = false;
22
21
  }
23
22
  get detailsElement() {
24
23
  var _a;
25
24
  return (_a = this.renderRoot.querySelector('#detailsContainer')) === null || _a === void 0 ? void 0 : _a.firstElementChild;
26
25
  }
27
- connected() {
28
- this.dataGrid.rowConnected.dispatch(this);
29
- }
30
- disconnected() {
31
- this.dataGrid.rowDisconnected.dispatch(this);
32
- }
33
26
  initialized() {
34
27
  this.toggleAttribute('mo-data-grid-row', true);
35
- this.editing = this.dataGrid.editability === "always" /* DataGridEditability.Always */;
36
28
  }
37
29
  updated(...parameters) {
38
30
  this.cells.forEach(cell => cell.requestUpdate());
@@ -170,6 +162,7 @@ export class DataGridRow extends Component {
170
162
  @dblclick=${(e) => e.stopPropagation()}
171
163
  >
172
164
  <mo-checkbox
165
+ tabindex='-1'
173
166
  ?disabled=${((_b = (_a = this.dataGrid).isDataSelectable) === null || _b === void 0 ? void 0 : _b.call(_a, this.data)) === false}
174
167
  ?checked=${this.selected}
175
168
  @change=${(e) => this.setSelection(e.detail === 'checked')}
@@ -180,7 +173,6 @@ export class DataGridRow extends Component {
180
173
  getCellTemplate(column) {
181
174
  return column.hidden ? nothing : html `
182
175
  <mo-data-grid-cell
183
- ?editing=${this.editing}
184
176
  .row=${this}
185
177
  .column=${column}
186
178
  .value=${getValueByKeyPath(this.data, column.dataSelector)}
@@ -241,34 +233,14 @@ export class DataGridRow extends Component {
241
233
  }
242
234
  }
243
235
  handleContentClick() {
244
- if (this.dataGrid.editability === "on-row-click" /* DataGridEditability.OnRowClick */) {
245
- this.enableEditMode();
236
+ if (this.dataGrid.selectOnClick || this.dataGrid.selectionCheckboxesHidden) {
237
+ this.setSelection(this.dataGrid.selectionCheckboxesHidden || !this.selected);
246
238
  }
247
- else {
248
- if (this.dataGrid.selectOnClick || this.dataGrid.selectionCheckboxesHidden) {
249
- this.setSelection(this.dataGrid.selectionCheckboxesHidden || !this.selected);
250
- }
251
- if (this.dataGrid.hasDetails) {
252
- this.toggleDetails();
253
- }
239
+ if (this.dataGrid.detailsOnClick && this.dataGrid.hasDetails) {
240
+ this.toggleDetails();
254
241
  }
255
242
  this.dataGrid.rowClick.dispatch(this);
256
243
  }
257
- enableEditMode() {
258
- this.dataBeforeEdit = JSON.stringify(this.data);
259
- this.editing = true;
260
- const handleClick = (e) => {
261
- if (e.composedPath().includes(this) === false) {
262
- const dataAfterEdit = JSON.stringify(this.data);
263
- if (dataAfterEdit !== this.dataBeforeEdit) {
264
- this.dataGrid.rowEdit.dispatch(this);
265
- }
266
- window.removeEventListener('click', handleClick);
267
- this.editing = false;
268
- }
269
- };
270
- window.addEventListener('click', handleClick);
271
- }
272
244
  async handleContentDoubleClick() {
273
245
  var _a, _b;
274
246
  if (this.dataGrid.primaryContextMenuItemOnDoubleClick === true && this.dataGrid.hasContextMenu === true && this.dataGrid.selectionMode === "none" /* DataGridSelectionMode.None */) {
@@ -339,6 +311,3 @@ __decorate([
339
311
  __decorate([
340
312
  property({ type: Boolean, reflect: true })
341
313
  ], DataGridRow.prototype, "contextMenuOpen", void 0);
342
- __decorate([
343
- state()
344
- ], DataGridRow.prototype, "editing", void 0);