@ixfx/components 0.9.5 → 0.9.7

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.
@@ -102,6 +102,12 @@ type DataGridGroupChangeDetail = {
102
102
  readonly groupBy: DataGridGroupBy<unknown> | null;
103
103
  };
104
104
  type DataGridGroupChangeEvent = CustomEvent<DataGridGroupChangeDetail>;
105
+ type DataGridRowActivateDetail = {
106
+ readonly rowKey: string;
107
+ readonly row: unknown;
108
+ readonly rowIndex: number;
109
+ };
110
+ type DataGridRowActivateEvent = CustomEvent<DataGridRowActivateDetail>;
105
111
  interface DataGridElementEventMap {
106
112
  'datagrid-sort': DataGridSortEvent;
107
113
  'datagrid-select': DataGridSelectEvent;
@@ -111,6 +117,7 @@ interface DataGridElementEventMap {
111
117
  'datagrid-cell-click': DataGridCellClickEvent;
112
118
  'datagrid-cell-edit': DataGridCellEditEvent;
113
119
  'datagrid-group-change': DataGridGroupChangeEvent;
120
+ 'datagrid-row-activate': DataGridRowActivateEvent;
114
121
  'list-native-drag-start': ListNativeDragStartEvent<unknown>;
115
122
  }
116
123
  declare class DataGridElement extends LitElement {
@@ -200,6 +207,14 @@ declare class DataGridElement extends LitElement {
200
207
  dispatch(commandId: CommandId, args?: Record<string, unknown>): void;
201
208
  private _onFocusOut;
202
209
  protected firstUpdated(): void;
210
+ /**
211
+ * Force a fresh re-measure of the viewport and re-render. Normally
212
+ * unnecessary — a `ResizeObserver` tracks the viewport automatically — but
213
+ * gives a consumer an escape hatch to recover if an ancestor's
214
+ * layout/visibility changes without the observer noticing (matches
215
+ * `ixfx-grid-list`'s `refreshLayout()`).
216
+ */
217
+ refreshLayout(): void;
203
218
  protected updated(changed: Map<string, unknown>): void;
204
219
  protected willUpdate(changed: Map<string, unknown>): void;
205
220
  private _getGroupKey;
@@ -246,6 +261,7 @@ declare class DataGridElement extends LitElement {
246
261
  private _isEditable;
247
262
  private _isTextEditor;
248
263
  private _isCellEditing;
264
+ private _activateRow;
249
265
  private _startEdit;
250
266
  /** Programmatic: put a single cell in edit mode. Works in manual/user/immediate (no-op if disabled or not editable). */
251
267
  startEdit(rowKey: string, colKey: string): void;
@@ -267,6 +283,8 @@ declare class DataGridElement extends LitElement {
267
283
  startCol: number;
268
284
  endCol: number;
269
285
  };
286
+ /** Row keys currently within the windowed/visible range, in display order. */
287
+ renderedKeys(): string[];
270
288
  private _findFirstVisibleCol;
271
289
  private _findLastVisibleCol;
272
290
  protected render(): import("lit").TemplateResult<1>;
@@ -281,5 +299,5 @@ interface DataGridElement {
281
299
  removeEventListener: (<K extends keyof DataGridElementEventMap>(type: K, listener: (this: DataGridElement, event: DataGridElementEventMap[K]) => void, options?: boolean | EventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void);
282
300
  }
283
301
  //#endregion
284
- export { DataGridSortDetail as _, DataGridColumnReorderDetail as a, DataGridColumnResizeEvent as c, DataGridElement as d, DataGridElementEventMap as f, DataGridSelectEvent as g, DataGridSelectDetail as h, DataGridCellEditEvent as i, DataGridColumnVisibilityDetail as l, DataGridGroupChangeEvent as m, DataGridCellClickEvent as n, DataGridColumnReorderEvent as o, DataGridGroupChangeDetail as p, DataGridCellEditDetail as r, DataGridColumnResizeDetail as s, DataGridCellClickDetail as t, DataGridColumnVisibilityEvent as u, DataGridSortEvent as v };
285
- //# sourceMappingURL=data-grid-pp8WaKxG.d.ts.map
302
+ export { DataGridGroupBy as A, DataGridColumn as C, DataGridEditorFactory as D, DataGridEditorContext as E, DataGridSortState as F, GlobalFormatter as I, DataGridInteractionMode as M, DataGridSelectionMode as N, DataGridEditorType as O, DataGridSortDirection as P, BuiltInFormatterOptions as S, DataGridEditability as T, DataGridSelectDetail as _, DataGridColumnReorderDetail as a, DataGridSortEvent as b, DataGridColumnResizeEvent as c, DataGridElement as d, DataGridElementEventMap as f, DataGridRowActivateEvent as g, DataGridRowActivateDetail as h, DataGridCellEditEvent as i, DataGridGroupLabel as j, DataGridGetRowKey as k, DataGridColumnVisibilityDetail as l, DataGridGroupChangeEvent as m, DataGridCellClickEvent as n, DataGridColumnReorderEvent as o, DataGridGroupChangeDetail as p, DataGridCellEditDetail as r, DataGridColumnResizeDetail as s, DataGridCellClickDetail as t, DataGridColumnVisibilityEvent as u, DataGridSelectEvent as v, DataGridColumnMenu as w, BuiltInFormatterName as x, DataGridSortDetail as y };
303
+ //# sourceMappingURL=data-grid-8N0Kd5-6.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-grid-8N0Kd5-6.d.ts","names":[],"sources":["../src/data-grid/types.ts","../src/data-grid/data-grid.ts"],"mappings":";;;;;;KAAY;KACA;KACA;KACA;WAA+B;WAAsB,WAAW;;KAChE;KAEA,sBAAsB;WACvB,KAAK;WACL,QAAQ,eAAe;WACvB;WACA;WACA;EACT,SAAS;EACT;;KAEU,sBAAsB,gBAAgB,KAAK,sBAAsB;KAEjE,eAAe;EACzB;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU,GAAG,GAAG,GAAG;EACnB;EACA;EACA;EACA,YAAY,KAAK,GAAG,KAAK,eAAe,IAAI;EAC5C;EACA;EACA;EACA,SAAS,qBAAqB,sBAAsB;EACpD,gBAAgB;IAAyB;IAAe;;EACxD,aAAa,gBAAgB,KAAK,GAAG,KAAK,eAAe;;KAG/C,mBAAmB,gBAAgB,oBAAoB;KAEvD;KAEA;KACA;EAA4B;;KAE5B,kBAAkB,MAAM,KAAK,GAAG;KAChC,gBAAgB,gBAAgB,KAAK;KACrC,sBAAsB,kBAAkB;;KAGxC;;;KCpBA;WAAgC,MAAM;WAA4B,UAAU;;KAC5E,oBAAoB,YAAY;KAChC;WAAkC,cAAc;WAA8B,UAAU;;KACxF,sBAAsB,YAAY;KAClC;WAAyC;WAAuB;WAAqB,kBAAkB;;KACvG,6BAA6B,YAAY;KACzC;WAAwC;WAAsB;;KAC9D,4BAA4B,YAAY;KACxC;WAA4C;WAAsB;;KAClE,gCAAgC,Y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gB;;EAK1B,aAAa;EAWb;EAIA,mBAAmB,mBAAmB,aAAa,8BAA8B,6BAA6B,UAAU;UAkBhH;UAWA;UAYA;UAyBA;UACA;UA2BA;UAYA;UAkCA;EAoBR;IAAqB;IAAkB;IAAgB;IAAkB;;;EAUzE;UAKQ;UAaA;YAQW,wBAAM;;QA6MnB;YACI;IAAwB,kBAAkB;;;UAErC;EACf,oBAAoB,gBAAgB,yBAAyB,MAAM,GAAG,WAAW,MAAM,iBAAiB,OAAO,wBAAwB,aAAa,oBAAoB,sCAAsC,cAAc,UAAU,oCAAoC,oBAAoB;EAC9R,uBAAuB,gBAAgB,yBAAyB,MAAM,GAAG,WAAW,MAAM,iBAAiB,OAAO,wBAAwB,aAAa,oBAAoB,mCAAmC,cAAc,UAAU,oCAAoC,oBAAoB"}
@@ -1,3 +1,3 @@
1
1
  import { F as ListDragSource, I as ListNativeDragStartDetail, L as ListNativeDragStartEvent, M as ListDragPreview, N as ListDragPreviewContext, P as ListDragPreviewRenderer, j as ListDragEntry } from "./tree-component-BW2iCFq9.js";
2
- import { _ as DataGridSortDetail, a as DataGridColumnReorderDetail, c as DataGridColumnResizeEvent, d as DataGridElement, f as DataGridElementEventMap, g as DataGridSelectEvent, h as DataGridSelectDetail, i as DataGridCellEditEvent, l as DataGridColumnVisibilityDetail, m as DataGridGroupChangeEvent, n as DataGridCellClickEvent, o as DataGridColumnReorderEvent, p as DataGridGroupChangeDetail, r as DataGridCellEditDetail, s as DataGridColumnResizeDetail, t as DataGridCellClickDetail, u as DataGridColumnVisibilityEvent, v as DataGridSortEvent } from "./data-grid-pp8WaKxG.js";
3
- export { DataGridCellClickDetail, DataGridCellClickEvent, DataGridCellEditDetail, DataGridCellEditEvent, DataGridColumnReorderDetail, DataGridColumnReorderEvent, DataGridColumnResizeDetail, DataGridColumnResizeEvent, DataGridColumnVisibilityDetail, DataGridColumnVisibilityEvent, DataGridElement, DataGridElementEventMap, DataGridGroupChangeDetail, DataGridGroupChangeEvent, DataGridSelectDetail, DataGridSelectEvent, DataGridSortDetail, DataGridSortEvent, type ListDragEntry, type ListDragPreview, type ListDragPreviewContext, type ListDragPreviewRenderer, type ListDragSource, type ListNativeDragStartDetail, type ListNativeDragStartEvent };
2
+ import { A as DataGridGroupBy, C as DataGridColumn, D as DataGridEditorFactory, E as DataGridEditorContext, F as DataGridSortState, I as GlobalFormatter, M as DataGridInteractionMode, N as DataGridSelectionMode, O as DataGridEditorType, P as DataGridSortDirection, S as BuiltInFormatterOptions, T as DataGridEditability, _ as DataGridSelectDetail, a as DataGridColumnReorderDetail, b as DataGridSortEvent, c as DataGridColumnResizeEvent, d as DataGridElement, f as DataGridElementEventMap, g as DataGridRowActivateEvent, h as DataGridRowActivateDetail, i as DataGridCellEditEvent, j as DataGridGroupLabel, k as DataGridGetRowKey, l as DataGridColumnVisibilityDetail, m as DataGridGroupChangeEvent, n as DataGridCellClickEvent, o as DataGridColumnReorderEvent, p as DataGridGroupChangeDetail, r as DataGridCellEditDetail, s as DataGridColumnResizeDetail, t as DataGridCellClickDetail, u as DataGridColumnVisibilityEvent, v as DataGridSelectEvent, w as DataGridColumnMenu, x as BuiltInFormatterName, y as DataGridSortDetail } from "./data-grid-8N0Kd5-6.js";
3
+ export { type BuiltInFormatterName, type BuiltInFormatterOptions, DataGridCellClickDetail, DataGridCellClickEvent, DataGridCellEditDetail, DataGridCellEditEvent, type DataGridColumn, type DataGridColumnMenu, DataGridColumnReorderDetail, DataGridColumnReorderEvent, DataGridColumnResizeDetail, DataGridColumnResizeEvent, DataGridColumnVisibilityDetail, DataGridColumnVisibilityEvent, type DataGridEditability, type DataGridEditorContext, type DataGridEditorFactory, type DataGridEditorType, DataGridElement, DataGridElementEventMap, type DataGridGetRowKey, type DataGridGroupBy, DataGridGroupChangeDetail, DataGridGroupChangeEvent, type DataGridGroupLabel, type DataGridInteractionMode, DataGridRowActivateDetail, DataGridRowActivateEvent, DataGridSelectDetail, DataGridSelectEvent, type DataGridSelectionMode, DataGridSortDetail, type DataGridSortDirection, DataGridSortEvent, type DataGridSortState, type GlobalFormatter, type ListDragEntry, type ListDragPreview, type ListDragPreviewContext, type ListDragPreviewRenderer, type ListDragSource, type ListNativeDragStartDetail, type ListNativeDragStartEvent };
package/dist/data-grid.js CHANGED
@@ -225,6 +225,10 @@ let DataGridElement = class DataGridElement extends LitElement {
225
225
  }
226
226
  if (!this._editing) {
227
227
  const idx = this._sortedRows.findIndex((r, i) => this.getRowKey(r, i) === key);
228
+ if (this._selectedKeys.has(key)) {
229
+ this._activateRow(key, idx >= 0 ? this._sortedRows[idx] : void 0, idx);
230
+ break;
231
+ }
228
232
  if (this.interactionMode !== `manual` && this.interactionMode !== `checked`) this._replaceSelection(key);
229
233
  this.dispatchEvent(new CustomEvent(`datagrid-cell-click`, {
230
234
  detail: {
@@ -404,6 +408,7 @@ let DataGridElement = class DataGridElement extends LitElement {
404
408
  `
405
409
  ];
406
410
  }
411
+ #viewportResizeObserver;
407
412
  #nativeDragging;
408
413
  #dragOriginKey;
409
414
  #postDragSuppressTimer;
@@ -521,6 +526,8 @@ let DataGridElement = class DataGridElement extends LitElement {
521
526
  clearTimeout(this.#postDragSuppressTimer);
522
527
  this.#postDragSuppressTimer = 0;
523
528
  }
529
+ this.#viewportResizeObserver?.disconnect();
530
+ this.#viewportResizeObserver = void 0;
524
531
  }
525
532
  /**
526
533
  * Dispatch a command to this grid — routes through the command registry so
@@ -530,14 +537,35 @@ let DataGridElement = class DataGridElement extends LitElement {
530
537
  this.#searchRegistry?.invoke(commandId, args);
531
538
  }
532
539
  firstUpdated() {
533
- new ResizeObserver(() => {
534
- if (!this._viewportEl) return;
535
- this._viewportH = this._viewportEl.clientHeight;
536
- this._viewportW = this._viewportEl.clientWidth;
537
- this.requestUpdate();
538
- }).observe(this._viewportEl);
539
- this._viewportH = this._viewportEl.clientHeight;
540
- this._viewportW = this._viewportEl.clientWidth;
540
+ this.#viewportResizeObserver = new ResizeObserver(() => this.#measureViewport());
541
+ this.#viewportResizeObserver.observe(this._viewportEl);
542
+ this.#measureViewport();
543
+ }
544
+ /**
545
+ * Re-read the viewport's size and update `_viewportH`/`_viewportW` if it
546
+ * changed. A zero-sized read (e.g. while hosted in a hidden/inactive dock
547
+ * tab) is ignored so it never clobbers the last known-good geometry — the
548
+ * observer fires again with the real size once the host becomes visible.
549
+ */
550
+ #measureViewport() {
551
+ if (!this._viewportEl) return;
552
+ const w = this._viewportEl.clientWidth;
553
+ const h = this._viewportEl.clientHeight;
554
+ if (w <= 0 || h <= 0) return;
555
+ if (w === this._viewportW && h === this._viewportH) return;
556
+ this._viewportW = w;
557
+ this._viewportH = h;
558
+ }
559
+ /**
560
+ * Force a fresh re-measure of the viewport and re-render. Normally
561
+ * unnecessary — a `ResizeObserver` tracks the viewport automatically — but
562
+ * gives a consumer an escape hatch to recover if an ancestor's
563
+ * layout/visibility changes without the observer noticing (matches
564
+ * `ixfx-grid-list`'s `refreshLayout()`).
565
+ */
566
+ refreshLayout() {
567
+ this.#measureViewport();
568
+ this.requestUpdate();
541
569
  }
542
570
  updated(changed) {
543
571
  super.updated(changed);
@@ -1059,6 +1087,17 @@ let DataGridElement = class DataGridElement extends LitElement {
1059
1087
  if (this._editingRow === rowKey) return this._isEditable(this._sortedRows.find((r, i) => this.getRowKey(r, i) === rowKey) ?? {}, this.columns.find((c) => c.key === colKey));
1060
1088
  return this._editing?.rowKey === rowKey && this._editing?.colKey === colKey;
1061
1089
  }
1090
+ _activateRow(rowKey, row, rowIndex) {
1091
+ this.dispatchEvent(new CustomEvent(`datagrid-row-activate`, {
1092
+ detail: {
1093
+ rowKey,
1094
+ row,
1095
+ rowIndex
1096
+ },
1097
+ bubbles: true,
1098
+ composed: true
1099
+ }));
1100
+ }
1062
1101
  _startEdit(rowKey, colKey) {
1063
1102
  if (this.editability === `disabled`) return;
1064
1103
  const row = this._sortedRows.find((r, i) => this.getRowKey(r, i) === rowKey);
@@ -1255,6 +1294,11 @@ let DataGridElement = class DataGridElement extends LitElement {
1255
1294
  endCol: this._findLastVisibleCol(this._scrollLeft + this._viewportW)
1256
1295
  };
1257
1296
  }
1297
+ /** Row keys currently within the windowed/visible range, in display order. */
1298
+ renderedKeys() {
1299
+ const { startRow, endRow } = this.getVisibleRange();
1300
+ return this._flat.slice(startRow, endRow).filter((f) => f.type === `row`).map((f) => f.key);
1301
+ }
1258
1302
  _findFirstVisibleCol(scrollLeft) {
1259
1303
  let lo = 0;
1260
1304
  let hi = this._colOffsets.length - 1;
@@ -1279,7 +1323,7 @@ let DataGridElement = class DataGridElement extends LitElement {
1279
1323
  const visibleFlat = this._flat.slice(startRow, endRow);
1280
1324
  const showCheckbox = this.interactionMode === `checked`;
1281
1325
  return html`
1282
- <div class="grid" style="height:400px">
1326
+ <div class="grid">
1283
1327
  <div class="header-bar">
1284
1328
  <div class="header-scroll">
1285
1329
  ${showCheckbox ? html`<div class="header-cell checkbox-col"></div>` : nothing}
@@ -1383,6 +1427,7 @@ let DataGridElement = class DataGridElement extends LitElement {
1383
1427
  @pointerleave=${() => this._tickled.clearTickled()}
1384
1428
  @dblclick=${() => {
1385
1429
  if (this._visibleColumns[0] && this._isEditable(row, this._visibleColumns[0])) this._startEdit(rowKey, this._visibleColumns[0].key);
1430
+ else this._activateRow(rowKey, row, absIdx2);
1386
1431
  }}>
1387
1432
  ${showCheckbox ? html`<div class="checkbox-col"><input type="checkbox" .checked=${selected} @click=${(e) => this._onCheckboxClick(rowKey, e)} /></div>` : nothing}
1388
1433
  ${repeat(this._visibleColumns, (c) => c.key, (col) => {