@dxos/lit-grid 0.6.12-main.c974201 → 0.6.12-main.ed7cda7

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.
@@ -99,8 +99,14 @@ var DxGrid = class extends LitElement {
99
99
  };
100
100
  this.rows = {};
101
101
  this.columns = {};
102
- this.cells = {};
102
+ this.initialCells = {};
103
103
  this.mode = "browse";
104
+ /**
105
+ * When this function is defined, it is used first to try to get a value for a cell, and otherwise will fall back
106
+ * to `cells`.
107
+ */
108
+ this.getCells = null;
109
+ this.cells = {};
104
110
  //
105
111
  // `pos`, short for ‘position’, is the position in pixels of the viewport from the origin.
106
112
  //
@@ -329,7 +335,8 @@ var DxGrid = class extends LitElement {
329
335
  return this.rowSizes?.[r] ?? this.rowDefault.size;
330
336
  }
331
337
  cell(c, r) {
332
- return this.cells[`${c}${separator}${r}`];
338
+ const index = `${c}${separator}${r}`;
339
+ return this.cells[index] ?? this.initialCells[index];
333
340
  }
334
341
  focusedCellBox() {
335
342
  const cellElement = this.focusedCellElement();
@@ -600,6 +607,18 @@ var DxGrid = class extends LitElement {
600
607
  </div>`;
601
608
  }
602
609
  firstUpdated() {
610
+ if (this.getCells) {
611
+ this.cells = this.getCells({
612
+ start: {
613
+ col: this.visColMin,
614
+ row: this.visRowMin
615
+ },
616
+ end: {
617
+ col: this.visColMax,
618
+ row: this.visRowMax
619
+ }
620
+ });
621
+ }
603
622
  this.observer.observe(this.viewportRef.value);
604
623
  this.colSizes = Object.entries(this.columns).reduce((acc, [colId, colMeta]) => {
605
624
  if (colMeta?.size) {
@@ -614,6 +633,20 @@ var DxGrid = class extends LitElement {
614
633
  return acc;
615
634
  }, {});
616
635
  }
636
+ willUpdate(changedProperties) {
637
+ if (this.getCells && (changedProperties.has("initialCells") || changedProperties.has("visColMin") || changedProperties.has("visColMax") || changedProperties.has("visRowMin") || changedProperties.has("visRowMax"))) {
638
+ this.cells = this.getCells({
639
+ start: {
640
+ col: this.visColMin,
641
+ row: this.visRowMin
642
+ },
643
+ end: {
644
+ col: this.visColMax,
645
+ row: this.visRowMax
646
+ }
647
+ });
648
+ }
649
+ }
617
650
  updated(changedProperties) {
618
651
  if (this.focusActive && (changedProperties.has("visRowMin") || changedProperties.has("visColMin") || changedProperties.has("focusedCell"))) {
619
652
  this.refocus();
@@ -658,12 +691,15 @@ _ts_decorate([
658
691
  property({
659
692
  type: Object
660
693
  })
661
- ], DxGrid.prototype, "cells", void 0);
694
+ ], DxGrid.prototype, "initialCells", void 0);
662
695
  _ts_decorate([
663
696
  property({
664
697
  type: String
665
698
  })
666
699
  ], DxGrid.prototype, "mode", void 0);
700
+ _ts_decorate([
701
+ state()
702
+ ], DxGrid.prototype, "cells", void 0);
667
703
  _ts_decorate([
668
704
  state()
669
705
  ], DxGrid.prototype, "posInline", void 0);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/dx-grid.ts", "../../../src/util.ts", "../../../src/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { LitElement, html, nothing } from 'lit';\nimport { customElement, state, property, eventOptions } from 'lit/decorators.js';\nimport { ref, createRef, type Ref } from 'lit/directives/ref.js';\n\nimport {\n type AxisMeta,\n type CellIndex,\n type CellValue,\n DxAxisResize,\n DxEditRequest,\n type DxGridAxis,\n DxGridCellsSelect,\n type DxGridMode,\n type DxGridPointer,\n type DxGridPosition,\n type DxGridPositionNullable,\n} from './types';\nimport { separator, toCellIndex } from './util';\n\n/**\n * The size in pixels of the gap between cells\n */\nconst gap = 1;\n\n/**\n * This should be about the width of the `1` numeral so resize is triggered as the row header column’s intrinsic size\n * changes when scrolling vertically.\n */\nconst resizeTolerance = 8;\n\n//\n// `overscan` is the number of columns or rows to render outside of the viewport\n//\nconst overscanCol = 1;\nconst overscanRow = 1;\n\n//\n// `size`, when suffixed with ‘row’ or ‘col’, are limits on size applied when resizing\n//\nconst sizeColMin = 32;\nconst sizeColMax = 1024;\nconst sizeRowMin = 16;\nconst sizeRowMax = 1024;\n\n//\n// A1 notation is the fallback for numbering columns and rows.\n//\n\nconst colToA1Notation = (col: number): string => {\n return (\n (col >= 26 ? String.fromCharCode('A'.charCodeAt(0) + Math.floor(col / 26) - 1) : '') +\n String.fromCharCode('A'.charCodeAt(0) + (col % 26))\n );\n};\n\nconst rowToA1Notation = (row: number): string => {\n return `${row + 1}`;\n};\n\nconst closestAction = (target: EventTarget | null): { action: string | null; actionEl: HTMLElement | null } => {\n const actionEl: HTMLElement | null = (target as HTMLElement | null)?.closest('[data-dx-grid-action]') ?? null;\n return { actionEl, action: actionEl?.getAttribute('data-dx-grid-action') ?? null };\n};\n\nconst closestCell = (target: EventTarget | null, actionEl?: HTMLElement | null): DxGridPositionNullable => {\n let cellElement = actionEl;\n if (!cellElement) {\n const { action, actionEl } = closestAction(target);\n if (action === 'cell') {\n cellElement = actionEl as HTMLElement;\n }\n }\n if (cellElement) {\n const col = parseInt(cellElement.getAttribute('aria-colindex') ?? 'never');\n const row = parseInt(cellElement.getAttribute('aria-rowindex') ?? 'never');\n return { col, row };\n } else {\n return null;\n }\n};\n\nconst isSameCell = (a: DxGridPositionNullable, b: DxGridPositionNullable) =>\n a && b && Number.isFinite(a.col) && Number.isFinite(a.row) && a.col === b.col && a.row === b.row;\n\nconst localChId = (c0: number) => `ch--${c0}`;\nconst localRhId = (r0: number) => `rh--${r0}`;\n\nconst getPage = (axis: string, event: PointerEvent) => (axis === 'col' ? event.pageX : event.pageY);\n\n@customElement('dx-grid')\nexport class DxGrid extends LitElement {\n @property({ type: String })\n gridId: string = 'default-grid-id';\n\n @property({ type: Object })\n rowDefault: AxisMeta = { size: 32 };\n\n @property({ type: Object })\n columnDefault: AxisMeta = { size: 180 };\n\n @property({ type: Object })\n rows: Record<string, AxisMeta> = {};\n\n @property({ type: Object })\n columns: Record<string, AxisMeta> = {};\n\n @property({ type: Object })\n cells: Record<CellIndex, CellValue> = {};\n\n @property({ type: String })\n mode: DxGridMode = 'browse';\n\n //\n // `pos`, short for ‘position’, is the position in pixels of the viewport from the origin.\n //\n\n @state()\n private posInline = 0;\n\n @state()\n private posBlock = 0;\n\n //\n // `size` (when not suffixed with ‘row’ or ‘col’, see above) is the size in pixels of the viewport.\n //\n\n @state()\n private sizeInline = 0;\n\n @state()\n private sizeBlock = 0;\n\n //\n // `overscan` is the amount in pixels to offset the grid content due to the number of overscanned columns or rows.\n //\n\n @state()\n private overscanInline = 0;\n\n @state()\n private overscanBlock = 0;\n\n //\n // `bin`, not short for anything, is the range in pixels within which virtualization does not need to reassess.\n //\n\n @state()\n private binInlineMin = 0;\n\n @state()\n private binInlineMax = this.colSize(0);\n\n @state()\n private binBlockMin = 0;\n\n @state()\n private binBlockMax = this.rowSize(0);\n\n //\n // `vis`, short for ‘visible’, is the range in numeric index of the columns or rows which should be rendered within\n // the viewport. These start with naïve values that are updated before first contentful render.\n //\n\n @state()\n private visColMin = 0;\n\n @state()\n private visColMax = 1;\n\n @state()\n private visRowMin = 0;\n\n @state()\n private visRowMax = 1;\n\n //\n // `template` is the rendered value of `grid-{axis}-template`.\n //\n @state()\n private templateColumns = `${this.colSize(0)}px`;\n\n @state()\n private templateRows = `${this.rowSize(0)}px`;\n\n //\n // Focus, selection, and resize states\n //\n\n @state()\n private pointer: DxGridPointer = null;\n\n @state()\n private colSizes: Record<string, number> = {};\n\n @state()\n private rowSizes: Record<string, number> = {};\n\n @state()\n private focusActive: boolean = false;\n\n @state()\n private focusedCell: DxGridPosition = { col: 0, row: 0 };\n\n @state()\n private selectionStart: DxGridPosition = { col: 0, row: 0 };\n\n @state()\n private selectionEnd: DxGridPosition = { col: 0, row: 0 };\n\n //\n // Primary pointer and keyboard handlers\n //\n\n private dispatchEditRequest(initialContent?: string) {\n this.snapPosToFocusedCell();\n // Without deferring, the event dispatches before `focusedCellBox` can get updated bounds of the cell, hence:\n queueMicrotask(() =>\n this.dispatchEvent(\n new DxEditRequest({\n cellIndex: toCellIndex(this.focusedCell),\n cellBox: this.focusedCellBox(),\n initialContent,\n }),\n ),\n );\n }\n\n private handlePointerDown = (event: PointerEvent) => {\n if (event.isPrimary) {\n const { action, actionEl } = closestAction(event.target);\n if (action) {\n if (action.startsWith('resize') && this.mode === 'browse') {\n const [resize, index] = action.split(',');\n const [_, axis] = resize.split('-');\n this.pointer = {\n state: 'resizing',\n axis: axis as DxGridAxis,\n size: axis === 'col' ? this.colSize(index) : this.rowSize(index),\n page: getPage(axis, event),\n index,\n };\n } else if (action === 'cell') {\n const cellCoords = closestCell(event.target, actionEl);\n if (cellCoords) {\n this.pointer = { state: 'selecting' };\n this.selectionStart = cellCoords;\n }\n if (this.mode === 'edit') {\n event.preventDefault();\n } else {\n if (this.focusActive && isSameCell(this.focusedCell, cellCoords)) {\n this.dispatchEditRequest();\n }\n }\n }\n }\n }\n };\n\n private handlePointerUp = (event: PointerEvent) => {\n if (this.pointer?.state === 'resizing') {\n const resizeEvent = new DxAxisResize({\n axis: this.pointer.axis,\n index: this.pointer.index,\n size: this[this.pointer.axis === 'col' ? 'colSize' : 'rowSize'](this.pointer.index),\n });\n this.dispatchEvent(resizeEvent);\n } else {\n const cell = closestCell(event.target);\n if (cell) {\n this.selectionEnd = cell;\n this.dispatchEvent(\n new DxGridCellsSelect({\n start: this.selectionStart,\n end: this.selectionEnd,\n }),\n );\n }\n }\n this.pointer = null;\n };\n\n private handlePointerMove = (event: PointerEvent) => {\n if (this.pointer?.state === 'resizing') {\n const delta = getPage(this.pointer.axis, event) - this.pointer.page;\n if (this.pointer.axis === 'col') {\n const nextSize = Math.max(sizeColMin, Math.min(sizeColMax, this.pointer.size + delta));\n this.colSizes = { ...this.colSizes, [this.pointer.index]: nextSize };\n this.updateVisInline();\n } else {\n const nextSize = Math.max(sizeRowMin, Math.min(sizeRowMax, this.pointer.size + delta));\n this.rowSizes = { ...this.rowSizes, [this.pointer.index]: nextSize };\n this.updateVisBlock();\n }\n } else if (this.pointer?.state === 'selecting') {\n const cell = closestCell(event.target);\n if (cell && (cell.col !== this.selectionEnd.col || cell.row !== this.selectionEnd.row)) {\n this.selectionEnd = cell;\n }\n }\n };\n\n private handleKeydown(event: KeyboardEvent) {\n if (this.focusActive && this.mode === 'browse') {\n // Adjust state\n switch (event.key) {\n case 'ArrowDown':\n this.focusedCell = { ...this.focusedCell, row: this.focusedCell.row + 1 };\n break;\n case 'ArrowUp':\n this.focusedCell = { ...this.focusedCell, row: Math.max(0, this.focusedCell.row - 1) };\n break;\n case 'ArrowRight':\n this.focusedCell = { ...this.focusedCell, col: this.focusedCell.col + 1 };\n break;\n case 'ArrowLeft':\n this.focusedCell = { ...this.focusedCell, col: Math.max(0, this.focusedCell.col - 1) };\n break;\n }\n // Emit edit request if relevant\n switch (event.key) {\n case 'Enter':\n this.dispatchEditRequest();\n break;\n default:\n if (event.key.length === 1 && event.key.match(/\\P{Cc}/u)) {\n this.dispatchEditRequest(event.key);\n }\n break;\n }\n // Handle virtualization & focus consequences\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n case 'ArrowRight':\n case 'ArrowLeft':\n event.preventDefault();\n this.snapPosToFocusedCell();\n break;\n }\n }\n }\n\n //\n // Accessors\n //\n\n private colSize(c: number | string) {\n return this.colSizes?.[c] ?? this.columnDefault.size;\n }\n\n private rowSize(r: number | string) {\n return this.rowSizes?.[r] ?? this.rowDefault.size;\n }\n\n private cell(c: number | string, r: number | string) {\n return this.cells[`${c}${separator}${r}`];\n }\n\n private focusedCellBox(): DxEditRequest['cellBox'] {\n const cellElement = this.focusedCellElement();\n const cellSize = { inlineSize: this.colSize(this.focusedCell.col), blockSize: this.rowSize(this.focusedCell.row) };\n if (!cellElement) {\n return { insetInlineStart: NaN, insetBlockStart: NaN, ...cellSize };\n }\n const contentElement = cellElement.offsetParent as HTMLElement;\n // Note that storing `offset` in state causes performance issues, so instead the transform is parsed here.\n const [_translate3d, inlineStr, blockStr] = contentElement.style.transform.split(/[()]|px,?\\s?/);\n const contentOffsetInline = parseFloat(inlineStr);\n const contentOffsetBlock = parseFloat(blockStr);\n const offsetParent = contentElement.offsetParent as HTMLElement;\n return {\n insetInlineStart: cellElement.offsetLeft + contentOffsetInline + offsetParent.offsetLeft,\n insetBlockStart: cellElement.offsetTop + contentOffsetBlock + offsetParent.offsetTop,\n ...cellSize,\n };\n }\n\n //\n // Resize & reposition handlers, observer, ref\n //\n\n @state()\n private observer = new ResizeObserver((entries) => {\n const { inlineSize, blockSize } = entries?.[0]?.contentBoxSize?.[0] ?? {\n inlineSize: 0,\n blockSize: 0,\n };\n if (\n Math.abs(inlineSize - this.sizeInline) > resizeTolerance ||\n Math.abs(blockSize - this.sizeBlock) > resizeTolerance\n ) {\n // console.info('[updating bounds]', 'resize', [inlineSize - this.sizeInline, blockSize - this.sizeBlock]);\n this.sizeInline = inlineSize;\n this.sizeBlock = blockSize;\n this.updateVis();\n }\n });\n\n private viewportRef: Ref<HTMLDivElement> = createRef();\n\n private handleWheel = ({ deltaX, deltaY }: WheelEvent) => {\n if (this.mode === 'browse') {\n this.posInline = Math.max(0, this.posInline + deltaX);\n this.posBlock = Math.max(0, this.posBlock + deltaY);\n if (\n this.posInline >= this.binInlineMin &&\n this.posInline < this.binInlineMax &&\n this.posBlock >= this.binBlockMin &&\n this.posBlock < this.binBlockMax\n ) {\n // do nothing\n } else {\n // console.info(\n // '[updating bounds]',\n // 'wheel',\n // [this.binInlineMin, this.posInline, this.binInlineMax],\n // [this.binBlockMin, this.posBlock, this.binBlockMax],\n // );\n this.updateVis();\n }\n }\n };\n\n private updateVisInline() {\n // todo: avoid starting from zero\n let colIndex = 0;\n let pxInline = this.colSize(colIndex);\n\n while (pxInline < this.posInline) {\n colIndex += 1;\n pxInline += this.colSize(colIndex) + gap;\n }\n\n this.visColMin = colIndex - overscanCol;\n\n this.binInlineMin = pxInline - this.colSize(colIndex) - gap;\n this.binInlineMax = pxInline + gap;\n\n this.overscanInline =\n [...Array(overscanCol)].reduce((acc, _, c0) => {\n acc += this.colSize(this.visColMin + c0);\n return acc;\n }, 0) +\n gap * (overscanCol - 1);\n\n while (pxInline < this.binInlineMax + this.sizeInline + gap) {\n colIndex += 1;\n pxInline += this.colSize(colIndex) + gap;\n }\n\n this.visColMax = colIndex + overscanCol;\n\n this.templateColumns = [...Array(this.visColMax - this.visColMin)]\n .map((_, c0) => `${this.colSize(this.visColMin + c0)}px`)\n .join(' ');\n }\n\n private updateVisBlock() {\n // todo: avoid starting from zero\n let rowIndex = 0;\n let pxBlock = this.rowSize(rowIndex);\n\n while (pxBlock < this.posBlock) {\n rowIndex += 1;\n pxBlock += this.rowSize(rowIndex) + gap;\n }\n\n this.visRowMin = rowIndex - overscanRow;\n\n this.binBlockMin = pxBlock - this.rowSize(rowIndex) - gap;\n this.binBlockMax = pxBlock + gap;\n\n this.overscanBlock =\n [...Array(overscanRow)].reduce((acc, _, r0) => {\n acc += this.rowSize(this.visRowMin + r0);\n return acc;\n }, 0) +\n gap * (overscanRow - 1);\n\n while (pxBlock < this.binBlockMax + this.sizeBlock) {\n rowIndex += 1;\n pxBlock += this.rowSize(rowIndex) + gap;\n }\n\n this.visRowMax = rowIndex + overscanRow;\n\n this.templateRows = [...Array(this.visRowMax - this.visRowMin)]\n .map((_, r0) => `${this.rowSize(this.visRowMin + r0)}px`)\n .join(' ');\n }\n\n private updateVis() {\n this.updateVisInline();\n this.updateVisBlock();\n }\n\n // Focus handlers\n\n @eventOptions({ capture: true })\n private handleFocus(event: FocusEvent) {\n const cellCoords = closestCell(event.target);\n if (cellCoords) {\n this.focusedCell = cellCoords;\n this.focusActive = true;\n }\n }\n\n @eventOptions({ capture: true })\n private handleBlur(event: FocusEvent) {\n // Only unset `focusActive` if focus is not moving to an element within the grid.\n if (!event.relatedTarget || !(event.relatedTarget as HTMLElement).closest(`[data-grid=\"${this.gridId}\"]`)) {\n this.focusActive = false;\n }\n }\n\n private focusedCellElement() {\n return this.viewportRef.value?.querySelector(\n `[aria-colindex=\"${this.focusedCell.col}\"][aria-rowindex=\"${this.focusedCell.row}\"]`,\n ) as HTMLElement | null;\n }\n\n /**\n * Moves focus to the cell with actual focus, otherwise moves focus to the viewport.\n */\n refocus(increment?: 'col' | 'row', delta: 1 | -1 = 1) {\n switch (increment) {\n case 'row':\n this.focusedCell = { ...this.focusedCell, row: this.focusedCell.row + delta };\n break;\n case 'col':\n this.focusedCell = { ...this.focusedCell, col: this.focusedCell.col + delta };\n }\n (this.focusedCell.row < this.visRowMin ||\n this.focusedCell.row > this.visRowMax ||\n this.focusedCell.col < this.visColMin ||\n this.focusedCell.col > this.visColMax\n ? this.viewportRef.value\n : this.focusedCellElement()\n )?.focus({ preventScroll: true });\n if (increment) {\n this.snapPosToFocusedCell();\n }\n }\n\n /**\n * Updates `pos` so that a cell in focus is fully within the viewport\n */\n snapPosToFocusedCell() {\n if (\n this.focusedCell.col < this.visColMin ||\n this.focusedCell.col > this.visColMax ||\n this.focusedCell.row < this.visRowMin ||\n this.focusedCell.row > this.visRowMax\n ) {\n // console.warn('Snapping position to a focused cell that is not already mounted is unsupported.');\n } else if (\n this.focusedCell.col > this.visColMin + overscanCol &&\n this.focusedCell.col < this.visColMax - overscanCol - 1 &&\n this.focusedCell.row > this.visRowMin + overscanRow &&\n this.focusedCell.row < this.visRowMax - overscanRow - 1\n ) {\n // console.log(\n // '[within bounds]',\n // this.focusedCell,\n // [this.visColMin, this.visColMax, overscanCol],\n // [this.visRowMin, this.visRowMax, overscanRow],\n // );\n } else {\n if (this.focusedCell.col <= this.visColMin + overscanCol) {\n this.posInline = this.binInlineMin;\n this.updateVisInline();\n } else if (this.focusedCell.col >= this.visColMax - overscanCol - 1) {\n const sizeSumCol = [...Array(this.focusedCell.col - this.visColMin)].reduce((acc, _, c0) => {\n acc += this.colSize(this.visColMin + overscanCol + c0) + gap;\n return acc;\n }, 0);\n this.posInline = Math.max(0, this.binInlineMin + sizeSumCol + gap * 2 - this.sizeInline);\n this.updateVisInline();\n }\n\n if (this.focusedCell.row <= this.visRowMin + overscanRow) {\n this.posBlock = this.binBlockMin;\n this.updateVisBlock();\n } else if (this.focusedCell.row >= this.visRowMax - overscanRow - 1) {\n const sizeSumRow = [...Array(this.focusedCell.row - this.visRowMin)].reduce((acc, _, r0) => {\n acc += this.rowSize(this.visRowMin + overscanRow + r0) + gap;\n return acc;\n }, 0);\n this.posBlock = Math.max(0, this.binBlockMin + sizeSumRow + gap * 2 - this.sizeBlock);\n this.updateVisBlock();\n }\n }\n }\n\n //\n // Render and other lifecycle methods\n //\n\n override render() {\n const visibleCols = this.visColMax - this.visColMin;\n const visibleRows = this.visRowMax - this.visRowMin;\n const offsetInline = this.binInlineMin - this.posInline - this.overscanInline;\n const offsetBlock = this.binBlockMin - this.posBlock - this.overscanBlock;\n\n const selectColMin = Math.min(this.selectionStart.col, this.selectionEnd.col);\n const selectColMax = Math.max(this.selectionStart.col, this.selectionEnd.col);\n const selectRowMin = Math.min(this.selectionStart.row, this.selectionEnd.row);\n const selectRowMax = Math.max(this.selectionStart.row, this.selectionEnd.row);\n const selectVisible = selectColMin !== selectColMax || selectRowMin !== selectRowMax;\n\n return html`<div\n role=\"none\"\n class=\"dx-grid\"\n data-grid=${this.gridId}\n data-grid-mode=${this.mode}\n ?data-grid-select=${selectVisible}\n @pointerdown=${this.handlePointerDown}\n @pointerup=${this.handlePointerUp}\n @pointermove=${this.handlePointerMove}\n @pointerleave=${this.handlePointerUp}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n @keydown=${this.handleKeydown}\n >\n <div role=\"none\" class=\"dx-grid__corner\"></div>\n <div role=\"none\" class=\"dx-grid__columnheader\">\n <div\n role=\"none\"\n class=\"dx-grid__columnheader__content\"\n style=\"transform:translate3d(${offsetInline}px,0,0);grid-template-columns:${this.templateColumns};\"\n >\n ${[...Array(visibleCols)].map((_, c0) => {\n const c = this.visColMin + c0;\n return html`<div\n role=\"columnheader\"\n ?inert=${c < 0}\n style=\"block-size:${this.rowDefault.size}px;grid-column:${c0 + 1}/${c0 + 2};\"\n >\n <span id=${localChId(c0)}>${colToA1Notation(c)}</span>\n ${(this.columns[c]?.resizeable ?? this.columnDefault.resizeable) &&\n html`<button class=\"dx-grid__resize-handle\" data-dx-grid-action=${`resize-col,${c}`}>\n <span class=\"sr-only\">Resize</span>\n </button>`}\n </div>`;\n })}\n </div>\n </div>\n <div role=\"none\" class=\"dx-grid__corner\"></div>\n <div role=\"none\" class=\"dx-grid__rowheader\">\n <div\n role=\"none\"\n class=\"dx-grid__rowheader__content\"\n style=\"transform:translate3d(0,${offsetBlock}px,0);grid-template-rows:${this.templateRows};\"\n >\n ${[...Array(visibleRows)].map((_, r0) => {\n const r = this.visRowMin + r0;\n return html`<div role=\"rowheader\" ?inert=${r < 0} style=\"grid-row:${r0 + 1}/${r0 + 2}\">\n <span id=${localRhId(r0)}>${rowToA1Notation(r)}</span>\n ${(this.rows[r]?.resizeable ?? this.rowDefault.resizeable) &&\n html`<button class=\"dx-grid__resize-handle\" data-dx-grid-action=${`resize-row,${r}`}>\n <span class=\"sr-only\">Resize</span>\n </button>`}\n </div>`;\n })}\n </div>\n </div>\n <div role=\"grid\" class=\"dx-grid__viewport\" tabindex=\"0\" @wheel=${this.handleWheel} ${ref(this.viewportRef)}>\n <div\n role=\"none\"\n class=\"dx-grid__content\"\n style=\"transform:translate3d(${offsetInline}px,${offsetBlock}px,0);grid-template-columns:${this\n .templateColumns};grid-template-rows:${this.templateRows};\"\n >\n ${[...Array(visibleCols)].map((_, c0) => {\n return [...Array(visibleRows)].map((_, r0) => {\n const c = c0 + this.visColMin;\n const r = r0 + this.visRowMin;\n const cell = this.cell(c, r);\n const active = this.focusActive && this.focusedCell.col === c && this.focusedCell.row === r;\n const selected = c >= selectColMin && c <= selectColMax && r >= selectRowMin && r <= selectRowMax;\n return html`<div\n role=\"gridcell\"\n tabindex=\"0\"\n ?inert=${c < 0 || r < 0}\n ?aria-selected=${selected}\n class=${cell || active\n ? (cell?.className ? cell.className + ' ' : '') + (active ? 'dx-grid__cell--active' : '')\n : nothing}\n aria-rowindex=${r}\n aria-colindex=${c}\n data-dx-grid-action=\"cell\"\n style=\"grid-column:${c0 + 1};grid-row:${r0 + 1}\"\n >\n ${cell?.value}\n </div>`;\n });\n })}\n </div>\n </div>\n <div role=\"none\" class=\"dx-grid__scrollbar\" aria-orientation=\"vertical\">\n <div role=\"none\" class=\"dx-grid__scrollbar__thumb\"></div>\n </div>\n <div role=\"none\" class=\"dx-grid__corner\"></div>\n <div role=\"none\" class=\"dx-grid__scrollbar\" aria-orientation=\"horizontal\">\n <div role=\"none\" class=\"dx-grid__scrollbar__thumb\"></div>\n </div>\n <div role=\"none\" class=\"dx-grid__corner\"></div>\n </div>`;\n }\n\n override firstUpdated() {\n this.observer.observe(this.viewportRef.value!);\n this.colSizes = Object.entries(this.columns).reduce((acc: Record<string, number>, [colId, colMeta]) => {\n if (colMeta?.size) {\n acc[colId] = colMeta.size;\n }\n return acc;\n }, {});\n this.rowSizes = Object.entries(this.rows).reduce((acc: Record<string, number>, [rowId, rowMeta]) => {\n if (rowMeta?.size) {\n acc[rowId] = rowMeta.size;\n }\n return acc;\n }, {});\n }\n\n override updated(changedProperties: Map<string, any>) {\n // Update the focused element if there is a change in bounds (otherwise Lit keeps focus on the relative element).\n if (\n this.focusActive &&\n (changedProperties.has('visRowMin') || changedProperties.has('visColMin') || changedProperties.has('focusedCell'))\n ) {\n this.refocus();\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n // console.log('[disconnected]', this.viewportRef.value);\n // TODO(thure): Will this even work?\n if (this.viewportRef.value) {\n this.observer.unobserve(this.viewportRef.value);\n }\n }\n\n override createRenderRoot() {\n return this;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type CellIndex, type DxGridPosition } from './types';\n\n/**\n * Separator for serializing cell position vectors\n */\nexport const separator = ',';\n\nexport const toCellIndex = (cellCoords: DxGridPosition): CellIndex => `${cellCoords.col}${separator}${cellCoords.row}`;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type DxGrid } from './dx-grid';\nimport { toCellIndex } from './util';\n\nexport type CellIndex = `${string},${string}`;\n\nexport type DxGridAxis = 'row' | 'col';\n\nexport type DxGridPosition = Record<DxGridAxis, number>;\nexport type DxGridPositionNullable = DxGridPosition | null;\n\nexport type DxGridPointer = null | ({ state: 'resizing'; page: number } & DxAxisResizeProps) | { state: 'selecting' };\n\nexport type DxAxisResizeProps = Pick<DxAxisResize, 'axis' | 'index' | 'size'>;\n\nexport type DxGridMode = 'browse' | 'edit';\n\nexport type CellValue = {\n /**\n * The content value\n */\n value: string;\n /**\n * If this is a merged cell, the bottomright-most of the range in numeric notation, otherwise undefined.\n */\n end?: string;\n /**\n * `class` attribute value to apply to the gridcell element\n */\n className?: string;\n};\n\nexport type AxisMeta = {\n size: number;\n description?: string;\n resizeable?: boolean;\n};\n\nexport type DxGridProps = Partial<Pick<DxGrid, 'cells' | 'rows' | 'columns' | 'rowDefault' | 'columnDefault'>>;\n\nexport class DxAxisResize extends Event {\n public readonly axis: DxGridAxis;\n public readonly index: string;\n public readonly size: number;\n constructor(props: DxAxisResizeProps) {\n super('dx-axis-resize');\n this.axis = props.axis;\n this.index = props.index;\n this.size = props.size;\n }\n}\n\nexport type DxEditRequestProps = Pick<DxEditRequest, 'cellIndex' | 'cellBox' | 'initialContent'>;\n\nexport class DxEditRequest extends Event {\n public readonly cellIndex: CellIndex;\n public readonly cellBox: Record<'insetInlineStart' | 'insetBlockStart' | 'inlineSize' | 'blockSize', number>;\n public readonly initialContent?: string;\n constructor(props: DxEditRequestProps) {\n super('dx-edit-request');\n this.cellIndex = props.cellIndex;\n this.cellBox = props.cellBox;\n this.initialContent = props.initialContent;\n }\n}\n\nexport type DxSelectProps = { start: DxGridPosition; end: DxGridPosition };\n\nexport class DxGridCellsSelect extends Event {\n public readonly start: string;\n public readonly end: string;\n public readonly minCol: number;\n public readonly maxCol: number;\n public readonly minRow: number;\n public readonly maxRow: number;\n constructor({ start, end }: DxSelectProps) {\n super('dx-grid-cells-select');\n this.start = toCellIndex(start);\n this.end = toCellIndex(end);\n this.minCol = Math.min(start.col, end.col);\n this.maxCol = Math.max(start.col, end.col);\n this.minRow = Math.min(start.row, end.row);\n this.maxRow = Math.max(start.row, end.row);\n }\n}\n"],
5
- "mappings": ";AAIA,SAASA,YAAYC,MAAMC,eAAe;AAC1C,SAASC,eAAeC,OAAOC,UAAUC,oBAAoB;AAC7D,SAASC,KAAKC,iBAA2B;;;ACGlC,IAAMC,YAAY;AAElB,IAAMC,cAAc,CAACC,eAA0C,GAAGA,WAAWC,GAAG,GAAGH,SAAAA,GAAYE,WAAWE,GAAG;;;ACgC7G,IAAMC,eAAN,cAA2BC,MAAAA;EAIhCC,YAAYC,OAA0B;AACpC,UAAM,gBAAA;AACN,SAAKC,OAAOD,MAAMC;AAClB,SAAKC,QAAQF,MAAME;AACnB,SAAKC,OAAOH,MAAMG;EACpB;AACF;AAIO,IAAMC,gBAAN,cAA4BN,MAAAA;EAIjCC,YAAYC,OAA2B;AACrC,UAAM,iBAAA;AACN,SAAKK,YAAYL,MAAMK;AACvB,SAAKC,UAAUN,MAAMM;AACrB,SAAKC,iBAAiBP,MAAMO;EAC9B;AACF;AAIO,IAAMC,oBAAN,cAAgCV,MAAAA;EAOrCC,YAAY,EAAEU,OAAOC,IAAG,GAAmB;AACzC,UAAM,sBAAA;AACN,SAAKD,QAAQE,YAAYF,KAAAA;AACzB,SAAKC,MAAMC,YAAYD,GAAAA;AACvB,SAAKE,SAASC,KAAKC,IAAIL,MAAMM,KAAKL,IAAIK,GAAG;AACzC,SAAKC,SAASH,KAAKI,IAAIR,MAAMM,KAAKL,IAAIK,GAAG;AACzC,SAAKG,SAASL,KAAKC,IAAIL,MAAMU,KAAKT,IAAIS,GAAG;AACzC,SAAKC,SAASP,KAAKI,IAAIR,MAAMU,KAAKT,IAAIS,GAAG;EAC3C;AACF;;;;;;;;;AF7DA,IAAME,MAAM;AAMZ,IAAMC,kBAAkB;AAKxB,IAAMC,cAAc;AAC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,aAAAA,MAAAA;;EA4EV0C,MAAAA;GA5EU1C,OAAAA,WAAAA,aAAAA,MAAAA;;EA+EV0C,MAAAA;GA/EU1C,OAAAA,WAAAA,aAAAA,MAAAA;;EAkFV0C,MAAAA;GAlFU1C,OAAAA,WAAAA,aAAAA,MAAAA;;EAwFV0C,MAAAA;GAxFU1C,OAAAA,WAAAA,mBAAAA,MAAAA;;EA2FV0C,MAAAA;GA3FU1C,OAAAA,WAAAA,gBAAAA,MAAAA;;EAkGV0C,MAAAA;GAlGU1C,OAAAA,WAAAA,WAAAA,MAAAA;;EAqGV0C,MAAAA;GArGU1C,OAAAA,WAAAA,YAAAA,MAAAA;;EAwGV0C,MAAAA;GAxGU1C,OAAAA,WAAAA,YAAAA,MAAAA;;EA2GV0C,MAAAA;GA3GU1C,OAAAA,WAAAA,eAAAA,MAAAA;;EA8GV0C,MAAAA;GA9GU1C,OAAAA,WAAAA,eAAAA,MAAAA;;EAiHV0C,MAAAA;GAjHU1C,OAAAA,WAAAA,kBAAAA,MAAAA;;EAoHV0C,MAAAA;GApHU1C,OAAAA,WAAAA,gBAAAA,MAAAA;;EAoSV0C,MAAAA;GApSU1C,OAAAA,WAAAA,YAAAA,MAAAA;;EAyZV+J,aAAa;IAAEC,SAAS;EAAK,CAAA;GAzZnBhK,OAAAA,WAAAA,eAAAA,IAAAA;;EAkaV+J,aAAa;IAAEC,SAAS;EAAK,CAAA;GAlanBhK,OAAAA,WAAAA,cAAAA,IAAAA;AAAAA,SAAAA,aAAAA;EADZiK,cAAc,SAAA;GACFjK,MAAAA;",
6
- "names": ["LitElement", "html", "nothing", "customElement", "state", "property", "eventOptions", "ref", "createRef", "separator", "toCellIndex", "cellCoords", "col", "row", "DxAxisResize", "Event", "constructor", "props", "axis", "index", "size", "DxEditRequest", "cellIndex", "cellBox", "initialContent", "DxGridCellsSelect", "start", "end", "toCellIndex", "minCol", "Math", "min", "col", "maxCol", "max", "minRow", "row", "maxRow", "gap", "resizeTolerance", "overscanCol", "overscanRow", "sizeColMin", "sizeColMax", "sizeRowMin", "sizeRowMax", "colToA1Notation", "col", "String", "fromCharCode", "charCodeAt", "Math", "floor", "rowToA1Notation", "row", "closestAction", "target", "actionEl", "closest", "action", "getAttribute", "closestCell", "cellElement", "parseInt", "isSameCell", "a", "b", "Number", "isFinite", "localChId", "c0", "localRhId", "r0", "getPage", "axis", "event", "pageX", "pageY", "DxGrid", "LitElement", "gridId", "rowDefault", "size", "columnDefault", "rows", "columns", "cells", "mode", "posInline", "posBlock", "sizeInline", "sizeBlock", "overscanInline", "overscanBlock", "binInlineMin", "binInlineMax", "colSize", "binBlockMin", "binBlockMax", "rowSize", "visColMin", "visColMax", "visRowMin", "visRowMax", "templateColumns", "templateRows", "pointer", "colSizes", "rowSizes", "focusActive", "focusedCell", "selectionStart", "selectionEnd", "handlePointerDown", "isPrimary", "startsWith", "resize", "index", "split", "_", "state", "page", "cellCoords", "preventDefault", "dispatchEditRequest", "handlePointerUp", "resizeEvent", "DxAxisResize", "dispatchEvent", "cell", "DxGridCellsSelect", "start", "end", "handlePointerMove", "delta", "nextSize", "max", "min", "updateVisInline", "updateVisBlock", "observer", "ResizeObserver", "entries", "inlineSize", "blockSize", "contentBoxSize", "abs", "updateVis", "viewportRef", "createRef", "handleWheel", "deltaX", "deltaY", "initialContent", "snapPosToFocusedCell", "queueMicrotask", "DxEditRequest", "cellIndex", "toCellIndex", "cellBox", "focusedCellBox", "handleKeydown", "key", "length", "match", "c", "r", "separator", "focusedCellElement", "cellSize", "insetInlineStart", "NaN", "insetBlockStart", "contentElement", "offsetParent", "_translate3d", "inlineStr", "blockStr", "style", "transform", "contentOffsetInline", "parseFloat", "contentOffsetBlock", "offsetLeft", "offsetTop", "colIndex", "pxInline", "Array", "reduce", "acc", "map", "join", "rowIndex", "pxBlock", "handleFocus", "handleBlur", "relatedTarget", "value", "querySelector", "refocus", "increment", "focus", "preventScroll", "sizeSumCol", "sizeSumRow", "render", "visibleCols", "visibleRows", "offsetInline", "offsetBlock", "selectColMin", "selectColMax", "selectRowMin", "selectRowMax", "selectVisible", "html", "resizeable", "ref", "active", "selected", "className", "nothing", "firstUpdated", "observe", "Object", "colId", "colMeta", "rowId", "rowMeta", "updated", "changedProperties", "has", "disconnectedCallback", "unobserve", "createRenderRoot", "property", "type", "eventOptions", "capture", "customElement"]
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { LitElement, html, nothing } from 'lit';\nimport { customElement, state, property, eventOptions } from 'lit/decorators.js';\nimport { ref, createRef, type Ref } from 'lit/directives/ref.js';\n\nimport {\n type AxisMeta,\n type CellIndex,\n DxAxisResize,\n DxEditRequest,\n type DxGridAxis,\n type DxGridAxisMeta,\n type DxGridCells,\n DxGridCellsSelect,\n type DxGridMode,\n type DxGridPointer,\n type DxGridPosition,\n type DxGridPositionNullable,\n type DxGridRange,\n} from './types';\nimport { separator, toCellIndex } from './util';\n\n/**\n * The size in pixels of the gap between cells\n */\nconst gap = 1;\n\n/**\n * This should be about the width of the `1` numeral so resize is triggered as the row header column’s intrinsic size\n * changes when scrolling vertically.\n */\nconst resizeTolerance = 8;\n\n//\n// `overscan` is the number of columns or rows to render outside of the viewport\n//\nconst overscanCol = 1;\nconst overscanRow = 1;\n\n//\n// `size`, when suffixed with ‘row’ or ‘col’, are limits on size applied when resizing\n//\nconst sizeColMin = 32;\nconst sizeColMax = 1024;\nconst sizeRowMin = 16;\nconst sizeRowMax = 1024;\n\n//\n// A1 notation is the fallback for numbering columns and rows.\n//\n\nconst colToA1Notation = (col: number): string => {\n return (\n (col >= 26 ? String.fromCharCode('A'.charCodeAt(0) + Math.floor(col / 26) - 1) : '') +\n String.fromCharCode('A'.charCodeAt(0) + (col % 26))\n );\n};\n\nconst rowToA1Notation = (row: number): string => {\n return `${row + 1}`;\n};\n\nconst closestAction = (target: EventTarget | null): { action: string | null; actionEl: HTMLElement | null } => {\n const actionEl: HTMLElement | null = (target as HTMLElement | null)?.closest('[data-dx-grid-action]') ?? null;\n return { actionEl, action: actionEl?.getAttribute('data-dx-grid-action') ?? null };\n};\n\nconst closestCell = (target: EventTarget | null, actionEl?: HTMLElement | null): DxGridPositionNullable => {\n let cellElement = actionEl;\n if (!cellElement) {\n const { action, actionEl } = closestAction(target);\n if (action === 'cell') {\n cellElement = actionEl as HTMLElement;\n }\n }\n if (cellElement) {\n const col = parseInt(cellElement.getAttribute('aria-colindex') ?? 'never');\n const row = parseInt(cellElement.getAttribute('aria-rowindex') ?? 'never');\n return { col, row };\n } else {\n return null;\n }\n};\n\nconst isSameCell = (a: DxGridPositionNullable, b: DxGridPositionNullable) =>\n a && b && Number.isFinite(a.col) && Number.isFinite(a.row) && a.col === b.col && a.row === b.row;\n\nconst localChId = (c0: number) => `ch--${c0}`;\nconst localRhId = (r0: number) => `rh--${r0}`;\n\nconst getPage = (axis: string, event: PointerEvent) => (axis === 'col' ? event.pageX : event.pageY);\n\n@customElement('dx-grid')\nexport class DxGrid extends LitElement {\n @property({ type: String })\n gridId: string = 'default-grid-id';\n\n @property({ type: Object })\n rowDefault: AxisMeta = { size: 32 };\n\n @property({ type: Object })\n columnDefault: AxisMeta = { size: 180 };\n\n @property({ type: Object })\n rows: DxGridAxisMeta = {};\n\n @property({ type: Object })\n columns: DxGridAxisMeta = {};\n\n @property({ type: Object })\n initialCells: DxGridCells = {};\n\n @property({ type: String })\n mode: DxGridMode = 'browse';\n\n /**\n * When this function is defined, it is used first to try to get a value for a cell, and otherwise will fall back\n * to `cells`.\n */\n getCells: ((nextRange: DxGridRange) => DxGridCells) | null = null;\n\n @state()\n private cells: DxGridCells = {};\n\n //\n // `pos`, short for ‘position’, is the position in pixels of the viewport from the origin.\n //\n\n @state()\n private posInline = 0;\n\n @state()\n private posBlock = 0;\n\n //\n // `size` (when not suffixed with ‘row’ or ‘col’, see above) is the size in pixels of the viewport.\n //\n\n @state()\n private sizeInline = 0;\n\n @state()\n private sizeBlock = 0;\n\n //\n // `overscan` is the amount in pixels to offset the grid content due to the number of overscanned columns or rows.\n //\n\n @state()\n private overscanInline = 0;\n\n @state()\n private overscanBlock = 0;\n\n //\n // `bin`, not short for anything, is the range in pixels within which virtualization does not need to reassess.\n //\n\n @state()\n private binInlineMin = 0;\n\n @state()\n private binInlineMax = this.colSize(0);\n\n @state()\n private binBlockMin = 0;\n\n @state()\n private binBlockMax = this.rowSize(0);\n\n //\n // `vis`, short for ‘visible’, is the range in numeric index of the columns or rows which should be rendered within\n // the viewport. These start with naïve values that are updated before first contentful render.\n //\n\n @state()\n private visColMin = 0;\n\n @state()\n private visColMax = 1;\n\n @state()\n private visRowMin = 0;\n\n @state()\n private visRowMax = 1;\n\n //\n // `template` is the rendered value of `grid-{axis}-template`.\n //\n @state()\n private templateColumns = `${this.colSize(0)}px`;\n\n @state()\n private templateRows = `${this.rowSize(0)}px`;\n\n //\n // Focus, selection, and resize states\n //\n\n @state()\n private pointer: DxGridPointer = null;\n\n @state()\n private colSizes: Record<string, number> = {};\n\n @state()\n private rowSizes: Record<string, number> = {};\n\n @state()\n private focusActive: boolean = false;\n\n @state()\n private focusedCell: DxGridPosition = { col: 0, row: 0 };\n\n @state()\n private selectionStart: DxGridPosition = { col: 0, row: 0 };\n\n @state()\n private selectionEnd: DxGridPosition = { col: 0, row: 0 };\n\n //\n // Primary pointer and keyboard handlers\n //\n\n private dispatchEditRequest(initialContent?: string) {\n this.snapPosToFocusedCell();\n // Without deferring, the event dispatches before `focusedCellBox` can get updated bounds of the cell, hence:\n queueMicrotask(() =>\n this.dispatchEvent(\n new DxEditRequest({\n cellIndex: toCellIndex(this.focusedCell),\n cellBox: this.focusedCellBox(),\n initialContent,\n }),\n ),\n );\n }\n\n private handlePointerDown = (event: PointerEvent) => {\n if (event.isPrimary) {\n const { action, actionEl } = closestAction(event.target);\n if (action) {\n if (action.startsWith('resize') && this.mode === 'browse') {\n const [resize, index] = action.split(',');\n const [_, axis] = resize.split('-');\n this.pointer = {\n state: 'resizing',\n axis: axis as DxGridAxis,\n size: axis === 'col' ? this.colSize(index) : this.rowSize(index),\n page: getPage(axis, event),\n index,\n };\n } else if (action === 'cell') {\n const cellCoords = closestCell(event.target, actionEl);\n if (cellCoords) {\n this.pointer = { state: 'selecting' };\n this.selectionStart = cellCoords;\n }\n if (this.mode === 'edit') {\n event.preventDefault();\n } else {\n if (this.focusActive && isSameCell(this.focusedCell, cellCoords)) {\n this.dispatchEditRequest();\n }\n }\n }\n }\n }\n };\n\n private handlePointerUp = (event: PointerEvent) => {\n if (this.pointer?.state === 'resizing') {\n const resizeEvent = new DxAxisResize({\n axis: this.pointer.axis,\n index: this.pointer.index,\n size: this[this.pointer.axis === 'col' ? 'colSize' : 'rowSize'](this.pointer.index),\n });\n this.dispatchEvent(resizeEvent);\n } else {\n const cell = closestCell(event.target);\n if (cell) {\n this.selectionEnd = cell;\n this.dispatchEvent(\n new DxGridCellsSelect({\n start: this.selectionStart,\n end: this.selectionEnd,\n }),\n );\n }\n }\n this.pointer = null;\n };\n\n private handlePointerMove = (event: PointerEvent) => {\n if (this.pointer?.state === 'resizing') {\n const delta = getPage(this.pointer.axis, event) - this.pointer.page;\n if (this.pointer.axis === 'col') {\n const nextSize = Math.max(sizeColMin, Math.min(sizeColMax, this.pointer.size + delta));\n this.colSizes = { ...this.colSizes, [this.pointer.index]: nextSize };\n this.updateVisInline();\n } else {\n const nextSize = Math.max(sizeRowMin, Math.min(sizeRowMax, this.pointer.size + delta));\n this.rowSizes = { ...this.rowSizes, [this.pointer.index]: nextSize };\n this.updateVisBlock();\n }\n } else if (this.pointer?.state === 'selecting') {\n const cell = closestCell(event.target);\n if (cell && (cell.col !== this.selectionEnd.col || cell.row !== this.selectionEnd.row)) {\n this.selectionEnd = cell;\n }\n }\n };\n\n private handleKeydown(event: KeyboardEvent) {\n if (this.focusActive && this.mode === 'browse') {\n // Adjust state\n switch (event.key) {\n case 'ArrowDown':\n this.focusedCell = { ...this.focusedCell, row: this.focusedCell.row + 1 };\n break;\n case 'ArrowUp':\n this.focusedCell = { ...this.focusedCell, row: Math.max(0, this.focusedCell.row - 1) };\n break;\n case 'ArrowRight':\n this.focusedCell = { ...this.focusedCell, col: this.focusedCell.col + 1 };\n break;\n case 'ArrowLeft':\n this.focusedCell = { ...this.focusedCell, col: Math.max(0, this.focusedCell.col - 1) };\n break;\n }\n // Emit edit request if relevant\n switch (event.key) {\n case 'Enter':\n this.dispatchEditRequest();\n break;\n default:\n if (event.key.length === 1 && event.key.match(/\\P{Cc}/u)) {\n this.dispatchEditRequest(event.key);\n }\n break;\n }\n // Handle virtualization & focus consequences\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n case 'ArrowRight':\n case 'ArrowLeft':\n event.preventDefault();\n this.snapPosToFocusedCell();\n break;\n }\n }\n }\n\n //\n // Accessors\n //\n\n private colSize(c: number | string) {\n return this.colSizes?.[c] ?? this.columnDefault.size;\n }\n\n private rowSize(r: number | string) {\n return this.rowSizes?.[r] ?? this.rowDefault.size;\n }\n\n private cell(c: number | string, r: number | string) {\n const index: CellIndex = `${c}${separator}${r}`;\n return this.cells[index] ?? this.initialCells[index];\n }\n\n private focusedCellBox(): DxEditRequest['cellBox'] {\n const cellElement = this.focusedCellElement();\n const cellSize = { inlineSize: this.colSize(this.focusedCell.col), blockSize: this.rowSize(this.focusedCell.row) };\n if (!cellElement) {\n return { insetInlineStart: NaN, insetBlockStart: NaN, ...cellSize };\n }\n const contentElement = cellElement.offsetParent as HTMLElement;\n // Note that storing `offset` in state causes performance issues, so instead the transform is parsed here.\n const [_translate3d, inlineStr, blockStr] = contentElement.style.transform.split(/[()]|px,?\\s?/);\n const contentOffsetInline = parseFloat(inlineStr);\n const contentOffsetBlock = parseFloat(blockStr);\n const offsetParent = contentElement.offsetParent as HTMLElement;\n return {\n insetInlineStart: cellElement.offsetLeft + contentOffsetInline + offsetParent.offsetLeft,\n insetBlockStart: cellElement.offsetTop + contentOffsetBlock + offsetParent.offsetTop,\n ...cellSize,\n };\n }\n\n //\n // Resize & reposition handlers, observer, ref\n //\n\n @state()\n private observer = new ResizeObserver((entries) => {\n const { inlineSize, blockSize } = entries?.[0]?.contentBoxSize?.[0] ?? {\n inlineSize: 0,\n blockSize: 0,\n };\n if (\n Math.abs(inlineSize - this.sizeInline) > resizeTolerance ||\n Math.abs(blockSize - this.sizeBlock) > resizeTolerance\n ) {\n // console.info('[updating bounds]', 'resize', [inlineSize - this.sizeInline, blockSize - this.sizeBlock]);\n this.sizeInline = inlineSize;\n this.sizeBlock = blockSize;\n this.updateVis();\n }\n });\n\n private viewportRef: Ref<HTMLDivElement> = createRef();\n\n private handleWheel = ({ deltaX, deltaY }: WheelEvent) => {\n if (this.mode === 'browse') {\n this.posInline = Math.max(0, this.posInline + deltaX);\n this.posBlock = Math.max(0, this.posBlock + deltaY);\n if (\n this.posInline >= this.binInlineMin &&\n this.posInline < this.binInlineMax &&\n this.posBlock >= this.binBlockMin &&\n this.posBlock < this.binBlockMax\n ) {\n // do nothing\n } else {\n // console.info(\n // '[updating bounds]',\n // 'wheel',\n // [this.binInlineMin, this.posInline, this.binInlineMax],\n // [this.binBlockMin, this.posBlock, this.binBlockMax],\n // );\n this.updateVis();\n }\n }\n };\n\n private updateVisInline() {\n // todo: avoid starting from zero\n let colIndex = 0;\n let pxInline = this.colSize(colIndex);\n\n while (pxInline < this.posInline) {\n colIndex += 1;\n pxInline += this.colSize(colIndex) + gap;\n }\n\n this.visColMin = colIndex - overscanCol;\n\n this.binInlineMin = pxInline - this.colSize(colIndex) - gap;\n this.binInlineMax = pxInline + gap;\n\n this.overscanInline =\n [...Array(overscanCol)].reduce((acc, _, c0) => {\n acc += this.colSize(this.visColMin + c0);\n return acc;\n }, 0) +\n gap * (overscanCol - 1);\n\n while (pxInline < this.binInlineMax + this.sizeInline + gap) {\n colIndex += 1;\n pxInline += this.colSize(colIndex) + gap;\n }\n\n this.visColMax = colIndex + overscanCol;\n\n this.templateColumns = [...Array(this.visColMax - this.visColMin)]\n .map((_, c0) => `${this.colSize(this.visColMin + c0)}px`)\n .join(' ');\n }\n\n private updateVisBlock() {\n // todo: avoid starting from zero\n let rowIndex = 0;\n let pxBlock = this.rowSize(rowIndex);\n\n while (pxBlock < this.posBlock) {\n rowIndex += 1;\n pxBlock += this.rowSize(rowIndex) + gap;\n }\n\n this.visRowMin = rowIndex - overscanRow;\n\n this.binBlockMin = pxBlock - this.rowSize(rowIndex) - gap;\n this.binBlockMax = pxBlock + gap;\n\n this.overscanBlock =\n [...Array(overscanRow)].reduce((acc, _, r0) => {\n acc += this.rowSize(this.visRowMin + r0);\n return acc;\n }, 0) +\n gap * (overscanRow - 1);\n\n while (pxBlock < this.binBlockMax + this.sizeBlock) {\n rowIndex += 1;\n pxBlock += this.rowSize(rowIndex) + gap;\n }\n\n this.visRowMax = rowIndex + overscanRow;\n\n this.templateRows = [...Array(this.visRowMax - this.visRowMin)]\n .map((_, r0) => `${this.rowSize(this.visRowMin + r0)}px`)\n .join(' ');\n }\n\n private updateVis() {\n this.updateVisInline();\n this.updateVisBlock();\n }\n\n // Focus handlers\n\n @eventOptions({ capture: true })\n private handleFocus(event: FocusEvent) {\n const cellCoords = closestCell(event.target);\n if (cellCoords) {\n this.focusedCell = cellCoords;\n this.focusActive = true;\n }\n }\n\n @eventOptions({ capture: true })\n private handleBlur(event: FocusEvent) {\n // Only unset `focusActive` if focus is not moving to an element within the grid.\n if (!event.relatedTarget || !(event.relatedTarget as HTMLElement).closest(`[data-grid=\"${this.gridId}\"]`)) {\n this.focusActive = false;\n }\n }\n\n private focusedCellElement() {\n return this.viewportRef.value?.querySelector(\n `[aria-colindex=\"${this.focusedCell.col}\"][aria-rowindex=\"${this.focusedCell.row}\"]`,\n ) as HTMLElement | null;\n }\n\n /**\n * Moves focus to the cell with actual focus, otherwise moves focus to the viewport.\n */\n refocus(increment?: 'col' | 'row', delta: 1 | -1 = 1) {\n switch (increment) {\n case 'row':\n this.focusedCell = { ...this.focusedCell, row: this.focusedCell.row + delta };\n break;\n case 'col':\n this.focusedCell = { ...this.focusedCell, col: this.focusedCell.col + delta };\n }\n (this.focusedCell.row < this.visRowMin ||\n this.focusedCell.row > this.visRowMax ||\n this.focusedCell.col < this.visColMin ||\n this.focusedCell.col > this.visColMax\n ? this.viewportRef.value\n : this.focusedCellElement()\n )?.focus({ preventScroll: true });\n if (increment) {\n this.snapPosToFocusedCell();\n }\n }\n\n /**\n * Updates `pos` so that a cell in focus is fully within the viewport\n */\n snapPosToFocusedCell() {\n if (\n this.focusedCell.col < this.visColMin ||\n this.focusedCell.col > this.visColMax ||\n this.focusedCell.row < this.visRowMin ||\n this.focusedCell.row > this.visRowMax\n ) {\n // console.warn('Snapping position to a focused cell that is not already mounted is unsupported.');\n } else if (\n this.focusedCell.col > this.visColMin + overscanCol &&\n this.focusedCell.col < this.visColMax - overscanCol - 1 &&\n this.focusedCell.row > this.visRowMin + overscanRow &&\n this.focusedCell.row < this.visRowMax - overscanRow - 1\n ) {\n // console.log(\n // '[within bounds]',\n // this.focusedCell,\n // [this.visColMin, this.visColMax, overscanCol],\n // [this.visRowMin, this.visRowMax, overscanRow],\n // );\n } else {\n if (this.focusedCell.col <= this.visColMin + overscanCol) {\n this.posInline = this.binInlineMin;\n this.updateVisInline();\n } else if (this.focusedCell.col >= this.visColMax - overscanCol - 1) {\n const sizeSumCol = [...Array(this.focusedCell.col - this.visColMin)].reduce((acc, _, c0) => {\n acc += this.colSize(this.visColMin + overscanCol + c0) + gap;\n return acc;\n }, 0);\n this.posInline = Math.max(0, this.binInlineMin + sizeSumCol + gap * 2 - this.sizeInline);\n this.updateVisInline();\n }\n\n if (this.focusedCell.row <= this.visRowMin + overscanRow) {\n this.posBlock = this.binBlockMin;\n this.updateVisBlock();\n } else if (this.focusedCell.row >= this.visRowMax - overscanRow - 1) {\n const sizeSumRow = [...Array(this.focusedCell.row - this.visRowMin)].reduce((acc, _, r0) => {\n acc += this.rowSize(this.visRowMin + overscanRow + r0) + gap;\n return acc;\n }, 0);\n this.posBlock = Math.max(0, this.binBlockMin + sizeSumRow + gap * 2 - this.sizeBlock);\n this.updateVisBlock();\n }\n }\n }\n\n //\n // Render and other lifecycle methods\n //\n\n override render() {\n const visibleCols = this.visColMax - this.visColMin;\n const visibleRows = this.visRowMax - this.visRowMin;\n const offsetInline = this.binInlineMin - this.posInline - this.overscanInline;\n const offsetBlock = this.binBlockMin - this.posBlock - this.overscanBlock;\n\n const selectColMin = Math.min(this.selectionStart.col, this.selectionEnd.col);\n const selectColMax = Math.max(this.selectionStart.col, this.selectionEnd.col);\n const selectRowMin = Math.min(this.selectionStart.row, this.selectionEnd.row);\n const selectRowMax = Math.max(this.selectionStart.row, this.selectionEnd.row);\n const selectVisible = selectColMin !== selectColMax || selectRowMin !== selectRowMax;\n\n return html`<div\n role=\"none\"\n class=\"dx-grid\"\n data-grid=${this.gridId}\n data-grid-mode=${this.mode}\n ?data-grid-select=${selectVisible}\n @pointerdown=${this.handlePointerDown}\n @pointerup=${this.handlePointerUp}\n @pointermove=${this.handlePointerMove}\n @pointerleave=${this.handlePointerUp}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n @keydown=${this.handleKeydown}\n >\n <div role=\"none\" class=\"dx-grid__corner\"></div>\n <div role=\"none\" class=\"dx-grid__columnheader\">\n <div\n role=\"none\"\n class=\"dx-grid__columnheader__content\"\n style=\"transform:translate3d(${offsetInline}px,0,0);grid-template-columns:${this.templateColumns};\"\n >\n ${[...Array(visibleCols)].map((_, c0) => {\n const c = this.visColMin + c0;\n return html`<div\n role=\"columnheader\"\n ?inert=${c < 0}\n style=\"block-size:${this.rowDefault.size}px;grid-column:${c0 + 1}/${c0 + 2};\"\n >\n <span id=${localChId(c0)}>${colToA1Notation(c)}</span>\n ${(this.columns[c]?.resizeable ?? this.columnDefault.resizeable) &&\n html`<button class=\"dx-grid__resize-handle\" data-dx-grid-action=${`resize-col,${c}`}>\n <span class=\"sr-only\">Resize</span>\n </button>`}\n </div>`;\n })}\n </div>\n </div>\n <div role=\"none\" class=\"dx-grid__corner\"></div>\n <div role=\"none\" class=\"dx-grid__rowheader\">\n <div\n role=\"none\"\n class=\"dx-grid__rowheader__content\"\n style=\"transform:translate3d(0,${offsetBlock}px,0);grid-template-rows:${this.templateRows};\"\n >\n ${[...Array(visibleRows)].map((_, r0) => {\n const r = this.visRowMin + r0;\n return html`<div role=\"rowheader\" ?inert=${r < 0} style=\"grid-row:${r0 + 1}/${r0 + 2}\">\n <span id=${localRhId(r0)}>${rowToA1Notation(r)}</span>\n ${(this.rows[r]?.resizeable ?? this.rowDefault.resizeable) &&\n html`<button class=\"dx-grid__resize-handle\" data-dx-grid-action=${`resize-row,${r}`}>\n <span class=\"sr-only\">Resize</span>\n </button>`}\n </div>`;\n })}\n </div>\n </div>\n <div role=\"grid\" class=\"dx-grid__viewport\" tabindex=\"0\" @wheel=${this.handleWheel} ${ref(this.viewportRef)}>\n <div\n role=\"none\"\n class=\"dx-grid__content\"\n style=\"transform:translate3d(${offsetInline}px,${offsetBlock}px,0);grid-template-columns:${this\n .templateColumns};grid-template-rows:${this.templateRows};\"\n >\n ${[...Array(visibleCols)].map((_, c0) => {\n return [...Array(visibleRows)].map((_, r0) => {\n const c = c0 + this.visColMin;\n const r = r0 + this.visRowMin;\n const cell = this.cell(c, r);\n const active = this.focusActive && this.focusedCell.col === c && this.focusedCell.row === r;\n const selected = c >= selectColMin && c <= selectColMax && r >= selectRowMin && r <= selectRowMax;\n return html`<div\n role=\"gridcell\"\n tabindex=\"0\"\n ?inert=${c < 0 || r < 0}\n ?aria-selected=${selected}\n class=${cell || active\n ? (cell?.className ? cell.className + ' ' : '') + (active ? 'dx-grid__cell--active' : '')\n : nothing}\n aria-rowindex=${r}\n aria-colindex=${c}\n data-dx-grid-action=\"cell\"\n style=\"grid-column:${c0 + 1};grid-row:${r0 + 1}\"\n >\n ${cell?.value}\n </div>`;\n });\n })}\n </div>\n </div>\n <div role=\"none\" class=\"dx-grid__scrollbar\" aria-orientation=\"vertical\">\n <div role=\"none\" class=\"dx-grid__scrollbar__thumb\"></div>\n </div>\n <div role=\"none\" class=\"dx-grid__corner\"></div>\n <div role=\"none\" class=\"dx-grid__scrollbar\" aria-orientation=\"horizontal\">\n <div role=\"none\" class=\"dx-grid__scrollbar__thumb\"></div>\n </div>\n <div role=\"none\" class=\"dx-grid__corner\"></div>\n </div>`;\n }\n\n override firstUpdated() {\n if (this.getCells) {\n this.cells = this.getCells({\n start: { col: this.visColMin, row: this.visRowMin },\n end: { col: this.visColMax, row: this.visRowMax },\n });\n }\n this.observer.observe(this.viewportRef.value!);\n this.colSizes = Object.entries(this.columns).reduce((acc: Record<string, number>, [colId, colMeta]) => {\n if (colMeta?.size) {\n acc[colId] = colMeta.size;\n }\n return acc;\n }, {});\n this.rowSizes = Object.entries(this.rows).reduce((acc: Record<string, number>, [rowId, rowMeta]) => {\n if (rowMeta?.size) {\n acc[rowId] = rowMeta.size;\n }\n return acc;\n }, {});\n }\n\n override willUpdate(changedProperties: Map<string, any>) {\n if (\n this.getCells &&\n (changedProperties.has('initialCells') ||\n changedProperties.has('visColMin') ||\n changedProperties.has('visColMax') ||\n changedProperties.has('visRowMin') ||\n changedProperties.has('visRowMax'))\n ) {\n this.cells = this.getCells({\n start: { col: this.visColMin, row: this.visRowMin },\n end: { col: this.visColMax, row: this.visRowMax },\n });\n }\n }\n\n override updated(changedProperties: Map<string, any>) {\n // Update the focused element if there is a change in bounds (otherwise Lit keeps focus on the relative element).\n if (\n this.focusActive &&\n (changedProperties.has('visRowMin') || changedProperties.has('visColMin') || changedProperties.has('focusedCell'))\n ) {\n this.refocus();\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n // console.log('[disconnected]', this.viewportRef.value);\n // TODO(thure): Will this even work?\n if (this.viewportRef.value) {\n this.observer.unobserve(this.viewportRef.value);\n }\n }\n\n override createRenderRoot() {\n return this;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type CellIndex, type DxGridPosition } from './types';\n\n/**\n * Separator for serializing cell position vectors\n */\nexport const separator = ',';\n\nexport const toCellIndex = (cellCoords: DxGridPosition): CellIndex => `${cellCoords.col}${separator}${cellCoords.row}`;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type DxGrid } from './dx-grid';\nimport { toCellIndex } from './util';\n\nexport type CellIndex = `${string},${string}`;\n\nexport type DxGridAxis = 'row' | 'col';\n\nexport type DxGridPosition = Record<DxGridAxis, number>;\nexport type DxGridPositionNullable = DxGridPosition | null;\n\nexport type DxGridCells = Record<CellIndex, CellValue>;\n\nexport type DxGridAxisMeta = Record<string, AxisMeta>;\n\nexport type DxGridPointer = null | ({ state: 'resizing'; page: number } & DxAxisResizeProps) | { state: 'selecting' };\n\nexport type DxAxisResizeProps = Pick<DxAxisResize, 'axis' | 'index' | 'size'>;\n\nexport type DxGridMode = 'browse' | 'edit';\n\nexport type CellValue = {\n /**\n * The content value\n */\n value: string;\n /**\n * If this is a merged cell, the bottomright-most of the range in numeric notation, otherwise undefined.\n */\n end?: string;\n /**\n * `class` attribute value to apply to the gridcell element\n */\n className?: string;\n};\n\nexport type AxisMeta = {\n size: number;\n description?: string;\n resizeable?: boolean;\n};\n\nexport type DxGridProps = Partial<Pick<DxGrid, 'initialCells' | 'rows' | 'columns' | 'rowDefault' | 'columnDefault'>>;\n\nexport class DxAxisResize extends Event {\n public readonly axis: DxGridAxis;\n public readonly index: string;\n public readonly size: number;\n constructor(props: DxAxisResizeProps) {\n super('dx-axis-resize');\n this.axis = props.axis;\n this.index = props.index;\n this.size = props.size;\n }\n}\n\nexport type DxEditRequestProps = Pick<DxEditRequest, 'cellIndex' | 'cellBox' | 'initialContent'>;\n\nexport class DxEditRequest extends Event {\n public readonly cellIndex: CellIndex;\n public readonly cellBox: Record<'insetInlineStart' | 'insetBlockStart' | 'inlineSize' | 'blockSize', number>;\n public readonly initialContent?: string;\n constructor(props: DxEditRequestProps) {\n super('dx-edit-request');\n this.cellIndex = props.cellIndex;\n this.cellBox = props.cellBox;\n this.initialContent = props.initialContent;\n }\n}\n\nexport type DxGridRange = { start: DxGridPosition; end: DxGridPosition };\n\nexport class DxGridCellsSelect extends Event {\n public readonly start: string;\n public readonly end: string;\n public readonly minCol: number;\n public readonly maxCol: number;\n public readonly minRow: number;\n public readonly maxRow: number;\n constructor({ start, end }: DxGridRange) {\n super('dx-grid-cells-select');\n this.start = toCellIndex(start);\n this.end = toCellIndex(end);\n this.minCol = Math.min(start.col, end.col);\n this.maxCol = Math.max(start.col, end.col);\n this.minRow = Math.min(start.row, end.row);\n this.maxRow = Math.max(start.row, end.row);\n }\n}\n"],
5
+ "mappings": ";AAIA,SAASA,YAAYC,MAAMC,eAAe;AAC1C,SAASC,eAAeC,OAAOC,UAAUC,oBAAoB;AAC7D,SAASC,KAAKC,iBAA2B;;;ACGlC,IAAMC,YAAY;AAElB,IAAMC,cAAc,CAACC,eAA0C,GAAGA,WAAWC,GAAG,GAAGH,SAAAA,GAAYE,WAAWE,GAAG;;;ACoC7G,IAAMC,eAAN,cAA2BC,MAAAA;EAIhCC,YAAYC,OAA0B;AACpC,UAAM,gBAAA;AACN,SAAKC,OAAOD,MAAMC;AAClB,SAAKC,QAAQF,MAAME;AACnB,SAAKC,OAAOH,MAAMG;EACpB;AACF;AAIO,IAAMC,gBAAN,cAA4BN,MAAAA;EAIjCC,YAAYC,OAA2B;AACrC,UAAM,iBAAA;AACN,SAAKK,YAAYL,MAAMK;AACvB,SAAKC,UAAUN,MAAMM;AACrB,SAAKC,iBAAiBP,MAAMO;EAC9B;AACF;AAIO,IAAMC,oBAAN,cAAgCV,MAAAA;EAOrCC,YAAY,EAAEU,OAAOC,IAAG,GAAiB;AACvC,UAAM,sBAAA;AACN,SAAKD,QAAQE,YAAYF,KAAAA;AACzB,SAAKC,MAAMC,YAAYD,GAAAA;AACvB,SAAKE,SAASC,KAAKC,IAAIL,MAAMM,KAAKL,IAAIK,GAAG;AACzC,SAAKC,SAASH,KAAKI,IAAIR,MAAMM,KAAKL,IAAIK,GAAG;AACzC,SAAKG,SAASL,KAAKC,IAAIL,M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A;GA3GU5C,OAAAA,WAAAA,WAAAA,MAAAA;;EA8GV4C,MAAAA;GA9GU5C,OAAAA,WAAAA,YAAAA,MAAAA;;EAiHV4C,MAAAA;GAjHU5C,OAAAA,WAAAA,YAAAA,MAAAA;;EAoHV4C,MAAAA;GApHU5C,OAAAA,WAAAA,eAAAA,MAAAA;;EAuHV4C,MAAAA;GAvHU5C,OAAAA,WAAAA,eAAAA,MAAAA;;EA0HV4C,MAAAA;GA1HU5C,OAAAA,WAAAA,kBAAAA,MAAAA;;EA6HV4C,MAAAA;GA7HU5C,OAAAA,WAAAA,gBAAAA,MAAAA;;EA8SV4C,MAAAA;GA9SU5C,OAAAA,WAAAA,YAAAA,MAAAA;;EAmaVkK,aAAa;IAAEC,SAAS;EAAK,CAAA;GAnanBnK,OAAAA,WAAAA,eAAAA,IAAAA;;EA4aVkK,aAAa;IAAEC,SAAS;EAAK,CAAA;GA5anBnK,OAAAA,WAAAA,cAAAA,IAAAA;AAAAA,SAAAA,aAAAA;EADZoK,cAAc,SAAA;GACFpK,MAAAA;",
6
+ "names": ["LitElement", "html", "nothing", "customElement", "state", "property", "eventOptions", "ref", "createRef", "separator", "toCellIndex", "cellCoords", "col", "row", "DxAxisResize", "Event", "constructor", "props", "axis", "index", "size", "DxEditRequest", "cellIndex", "cellBox", "initialContent", "DxGridCellsSelect", "start", "end", "toCellIndex", "minCol", "Math", "min", "col", "maxCol", "max", "minRow", "row", "maxRow", "gap", "resizeTolerance", "overscanCol", "overscanRow", "sizeColMin", "sizeColMax", "sizeRowMin", "sizeRowMax", "colToA1Notation", "col", "String", "fromCharCode", "charCodeAt", "Math", "floor", "rowToA1Notation", "row", "closestAction", "target", "actionEl", "closest", "action", "getAttribute", "closestCell", "cellElement", "parseInt", "isSameCell", "a", "b", "Number", "isFinite", "localChId", "c0", "localRhId", "r0", "getPage", "axis", "event", "pageX", "pageY", "DxGrid", "LitElement", "gridId", "rowDefault", "size", "columnDefault", "rows", "columns", "initialCells", "mode", "getCells", "cells", "posInline", "posBlock", "sizeInline", "sizeBlock", "overscanInline", "overscanBlock", "binInlineMin", "binInlineMax", "colSize", "binBlockMin", "binBlockMax", "rowSize", "visColMin", "visColMax", "visRowMin", "visRowMax", "templateColumns", "templateRows", "pointer", "colSizes", "rowSizes", "focusActive", "focusedCell", "selectionStart", "selectionEnd", "handlePointerDown", "isPrimary", "startsWith", "resize", "index", "split", "_", "state", "page", "cellCoords", "preventDefault", "dispatchEditRequest", "handlePointerUp", "resizeEvent", "DxAxisResize", "dispatchEvent", "cell", "DxGridCellsSelect", "start", "end", "handlePointerMove", "delta", "nextSize", "max", "min", "updateVisInline", "updateVisBlock", "observer", "ResizeObserver", "entries", "inlineSize", "blockSize", "contentBoxSize", "abs", "updateVis", "viewportRef", "createRef", "handleWheel", "deltaX", "deltaY", "initialContent", "snapPosToFocusedCell", "queueMicrotask", "DxEditRequest", "cellIndex", "toCellIndex", "cellBox", "focusedCellBox", "handleKeydown", "key", "length", "match", "c", "r", "separator", "focusedCellElement", "cellSize", "insetInlineStart", "NaN", "insetBlockStart", "contentElement", "offsetParent", "_translate3d", "inlineStr", "blockStr", "style", "transform", "contentOffsetInline", "parseFloat", "contentOffsetBlock", "offsetLeft", "offsetTop", "colIndex", "pxInline", "Array", "reduce", "acc", "map", "join", "rowIndex", "pxBlock", "handleFocus", "handleBlur", "relatedTarget", "value", "querySelector", "refocus", "increment", "focus", "preventScroll", "sizeSumCol", "sizeSumRow", "render", "visibleCols", "visibleRows", "offsetInline", "offsetBlock", "selectColMin", "selectColMax", "selectRowMin", "selectRowMax", "selectVisible", "html", "resizeable", "ref", "active", "selected", "className", "nothing", "firstUpdated", "observe", "Object", "colId", "colMeta", "rowId", "rowMeta", "willUpdate", "changedProperties", "has", "updated", "disconnectedCallback", "unobserve", "createRenderRoot", "property", "type", "eventOptions", "capture", "customElement"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/ui/lit-grid/src/util.ts":{"bytes":1219,"imports":[],"format":"esm"},"packages/ui/lit-grid/src/types.ts":{"bytes":6696,"imports":[{"path":"packages/ui/lit-grid/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/ui/lit-grid/src/dx-grid.ts":{"bytes":90202,"imports":[{"path":"lit","kind":"import-statement","external":true},{"path":"lit/decorators.js","kind":"import-statement","external":true},{"path":"lit/directives/ref.js","kind":"import-statement","external":true},{"path":"packages/ui/lit-grid/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/ui/lit-grid/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/ui/lit-grid/src/index.ts":{"bytes":572,"imports":[{"path":"packages/ui/lit-grid/src/dx-grid.ts","kind":"import-statement","original":"./dx-grid"},{"path":"packages/ui/lit-grid/src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"}},"outputs":{"packages/ui/lit-grid/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":46689},"packages/ui/lit-grid/dist/lib/browser/index.mjs":{"imports":[{"path":"lit","kind":"import-statement","external":true},{"path":"lit/decorators.js","kind":"import-statement","external":true},{"path":"lit/directives/ref.js","kind":"import-statement","external":true}],"exports":["DxAxisResize","DxEditRequest","DxGrid","DxGridCellsSelect"],"entryPoint":"packages/ui/lit-grid/src/index.ts","inputs":{"packages/ui/lit-grid/src/dx-grid.ts":{"bytesInOutput":23733},"packages/ui/lit-grid/src/util.ts":{"bytesInOutput":105},"packages/ui/lit-grid/src/types.ts":{"bytesInOutput":790},"packages/ui/lit-grid/src/index.ts":{"bytesInOutput":0}},"bytes":24892}}}
1
+ {"inputs":{"packages/ui/lit-grid/src/util.ts":{"bytes":1219,"imports":[],"format":"esm"},"packages/ui/lit-grid/src/types.ts":{"bytes":6856,"imports":[{"path":"packages/ui/lit-grid/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/ui/lit-grid/src/dx-grid.ts":{"bytes":94042,"imports":[{"path":"lit","kind":"import-statement","external":true},{"path":"lit/decorators.js","kind":"import-statement","external":true},{"path":"lit/directives/ref.js","kind":"import-statement","external":true},{"path":"packages/ui/lit-grid/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/ui/lit-grid/src/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/ui/lit-grid/src/index.ts":{"bytes":572,"imports":[{"path":"packages/ui/lit-grid/src/dx-grid.ts","kind":"import-statement","original":"./dx-grid"},{"path":"packages/ui/lit-grid/src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"}},"outputs":{"packages/ui/lit-grid/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":48570},"packages/ui/lit-grid/dist/lib/browser/index.mjs":{"imports":[{"path":"lit","kind":"import-statement","external":true},{"path":"lit/decorators.js","kind":"import-statement","external":true},{"path":"lit/directives/ref.js","kind":"import-statement","external":true}],"exports":["DxAxisResize","DxEditRequest","DxGrid","DxGridCellsSelect"],"entryPoint":"packages/ui/lit-grid/src/index.ts","inputs":{"packages/ui/lit-grid/src/dx-grid.ts":{"bytesInOutput":24796},"packages/ui/lit-grid/src/util.ts":{"bytesInOutput":105},"packages/ui/lit-grid/src/types.ts":{"bytesInOutput":790},"packages/ui/lit-grid/src/index.ts":{"bytesInOutput":0}},"bytes":25955}}}
@@ -1,13 +1,19 @@
1
1
  import { LitElement } from 'lit';
2
- import { type AxisMeta, type CellIndex, type CellValue, type DxGridMode } from './types';
2
+ import { type AxisMeta, type DxGridAxisMeta, type DxGridCells, type DxGridMode, type DxGridRange } from './types';
3
3
  export declare class DxGrid extends LitElement {
4
4
  gridId: string;
5
5
  rowDefault: AxisMeta;
6
6
  columnDefault: AxisMeta;
7
- rows: Record<string, AxisMeta>;
8
- columns: Record<string, AxisMeta>;
9
- cells: Record<CellIndex, CellValue>;
7
+ rows: DxGridAxisMeta;
8
+ columns: DxGridAxisMeta;
9
+ initialCells: DxGridCells;
10
10
  mode: DxGridMode;
11
+ /**
12
+ * When this function is defined, it is used first to try to get a value for a cell, and otherwise will fall back
13
+ * to `cells`.
14
+ */
15
+ getCells: ((nextRange: DxGridRange) => DxGridCells) | null;
16
+ private cells;
11
17
  private posInline;
12
18
  private posBlock;
13
19
  private sizeInline;
@@ -59,6 +65,7 @@ export declare class DxGrid extends LitElement {
59
65
  snapPosToFocusedCell(): void;
60
66
  render(): import("lit").TemplateResult<1>;
61
67
  firstUpdated(): void;
68
+ willUpdate(changedProperties: Map<string, any>): void;
62
69
  updated(changedProperties: Map<string, any>): void;
63
70
  disconnectedCallback(): void;
64
71
  createRenderRoot(): this;
@@ -1 +1 @@
1
- {"version":3,"file":"dx-grid.d.ts","sourceRoot":"","sources":["../../../src/dx-grid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AAIhD,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EAKd,KAAK,UAAU,EAIhB,MAAM,SAAS,CAAC;AAyEjB,qBACa,MAAO,SAAQ,UAAU;IAEpC,MAAM,EAAE,MAAM,CAAqB;IAGnC,UAAU,EAAE,QAAQ,CAAgB;IAGpC,aAAa,EAAE,QAAQ,CAAiB;IAGxC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAM;IAGpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAM;IAGvC,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAM;IAGzC,IAAI,EAAE,UAAU,CAAY;IAO5B,OAAO,CAAC,SAAS,CAAK;IAGtB,OAAO,CAAC,QAAQ,CAAK;IAOrB,OAAO,CAAC,UAAU,CAAK;IAGvB,OAAO,CAAC,SAAS,CAAK;IAOtB,OAAO,CAAC,cAAc,CAAK;IAG3B,OAAO,CAAC,aAAa,CAAK;IAO1B,OAAO,CAAC,YAAY,CAAK;IAGzB,OAAO,CAAC,YAAY,CAAmB;IAGvC,OAAO,CAAC,WAAW,CAAK;IAGxB,O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C,QAAQ,CAA8B;IAG9C,OAAO,CAAC,WAAW,CAAkB;IAGrC,OAAO,CAAC,WAAW,CAAsC;IAGzD,OAAO,CAAC,cAAc,CAAsC;IAG5D,OAAO,CAAC,YAAY,CAAsC;IAM1D,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,iBAAiB,CA8BvB;IAEF,OAAO,CAAC,eAAe,CAqBrB;IAEF,OAAO,CAAC,iBAAiB,CAkBvB;IAEF,OAAO,CAAC,aAAa;IA6CrB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,IAAI;IAKZ,OAAO,CAAC,cAAc;IAwBtB,OAAO,CAAC,QAAQ,CAcb;IAEH,OAAO,CAAC,WAAW,CAAoC;IAEvD,OAAO,CAAC,WAAW,CAqBjB;IAEF,OAAO,CAAC,eAAe;IAkCvB,OAAO,CAAC,cAAc;IAkCtB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,kBAAkB;IAM1B;;OAEG;IACH,OAAO,CAAC,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,KAAK,GAAE,CAAC,GAAG,CAAC,CAAK;IAoBpD;;OAEG;IACH,oBAAoB;IAmDX,MAAM;IAgHN,YAAY;IAsBZ,UAAU,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAgB9C,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAU3C,oBAAoB;IASpB,gBAAgB;CAG1B"}
@@ -3,6 +3,8 @@ export type CellIndex = `${string},${string}`;
3
3
  export type DxGridAxis = 'row' | 'col';
4
4
  export type DxGridPosition = Record<DxGridAxis, number>;
5
5
  export type DxGridPositionNullable = DxGridPosition | null;
6
+ export type DxGridCells = Record<CellIndex, CellValue>;
7
+ export type DxGridAxisMeta = Record<string, AxisMeta>;
6
8
  export type DxGridPointer = null | ({
7
9
  state: 'resizing';
8
10
  page: number;
@@ -30,7 +32,7 @@ export type AxisMeta = {
30
32
  description?: string;
31
33
  resizeable?: boolean;
32
34
  };
33
- export type DxGridProps = Partial<Pick<DxGrid, 'cells' | 'rows' | 'columns' | 'rowDefault' | 'columnDefault'>>;
35
+ export type DxGridProps = Partial<Pick<DxGrid, 'initialCells' | 'rows' | 'columns' | 'rowDefault' | 'columnDefault'>>;
34
36
  export declare class DxAxisResize extends Event {
35
37
  readonly axis: DxGridAxis;
36
38
  readonly index: string;
@@ -44,7 +46,7 @@ export declare class DxEditRequest extends Event {
44
46
  readonly initialContent?: string;
45
47
  constructor(props: DxEditRequestProps);
46
48
  }
47
- export type DxSelectProps = {
49
+ export type DxGridRange = {
48
50
  start: DxGridPosition;
49
51
  end: DxGridPosition;
50
52
  };
@@ -55,6 +57,6 @@ export declare class DxGridCellsSelect extends Event {
55
57
  readonly maxCol: number;
56
58
  readonly minRow: number;
57
59
  readonly maxRow: number;
58
- constructor({ start, end }: DxSelectProps);
60
+ constructor({ start, end }: DxGridRange);
59
61
  }
60
62
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,MAAM,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAE9C,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvC,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACxD,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,IAAI,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,iBAAiB,CAAC,GAA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AE,MAAM,CAAC;IAC5B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,MAAM,EAAE,MAAM,CAAC;gBACnB,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,WAAW;CASxC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/lit-grid",
3
- "version": "0.6.12-main.c974201",
3
+ "version": "0.6.12-main.ed7cda7",
4
4
  "description": "A grid Web Component using Lit",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -17,7 +17,7 @@ export default {
17
17
  export const Basic = (props: DxGridProps) => {
18
18
  return html`<div style="position:fixed;inset:0;">
19
19
  <dx-grid
20
- cells=${props.cells ?? nothing}
20
+ cells=${props.initialCells ?? nothing}
21
21
  columnDefault=${props.columnDefault ?? nothing}
22
22
  rowDefault=${props.rowDefault ?? nothing}
23
23
  columns=${props.columns ?? nothing}
@@ -31,7 +31,7 @@ Basic.args = {
31
31
  // end: '8,1',
32
32
  value: 'Weekly sales report',
33
33
  },
34
- } satisfies DxGridProps['cells']),
34
+ } satisfies DxGridProps['initialCells']),
35
35
  columnDefault: JSON.stringify({
36
36
  size: 180,
37
37
  resizeable: true,
package/src/dx-grid.ts CHANGED
@@ -9,15 +9,17 @@ import { ref, createRef, type Ref } from 'lit/directives/ref.js';
9
9
  import {
10
10
  type AxisMeta,
11
11
  type CellIndex,
12
- type CellValue,
13
12
  DxAxisResize,
14
13
  DxEditRequest,
15
14
  type DxGridAxis,
15
+ type DxGridAxisMeta,
16
+ type DxGridCells,
16
17
  DxGridCellsSelect,
17
18
  type DxGridMode,
18
19
  type DxGridPointer,
19
20
  type DxGridPosition,
20
21
  type DxGridPositionNullable,
22
+ type DxGridRange,
21
23
  } from './types';
22
24
  import { separator, toCellIndex } from './util';
23
25
 
@@ -103,17 +105,26 @@ export class DxGrid extends LitElement {
103
105
  columnDefault: AxisMeta = { size: 180 };
104
106
 
105
107
  @property({ type: Object })
106
- rows: Record<string, AxisMeta> = {};
108
+ rows: DxGridAxisMeta = {};
107
109
 
108
110
  @property({ type: Object })
109
- columns: Record<string, AxisMeta> = {};
111
+ columns: DxGridAxisMeta = {};
110
112
 
111
113
  @property({ type: Object })
112
- cells: Record<CellIndex, CellValue> = {};
114
+ initialCells: DxGridCells = {};
113
115
 
114
116
  @property({ type: String })
115
117
  mode: DxGridMode = 'browse';
116
118
 
119
+ /**
120
+ * When this function is defined, it is used first to try to get a value for a cell, and otherwise will fall back
121
+ * to `cells`.
122
+ */
123
+ getCells: ((nextRange: DxGridRange) => DxGridCells) | null = null;
124
+
125
+ @state()
126
+ private cells: DxGridCells = {};
127
+
117
128
  //
118
129
  // `pos`, short for ‘position’, is the position in pixels of the viewport from the origin.
119
130
  //
@@ -358,7 +369,8 @@ export class DxGrid extends LitElement {
358
369
  }
359
370
 
360
371
  private cell(c: number | string, r: number | string) {
361
- return this.cells[`${c}${separator}${r}`];
372
+ const index: CellIndex = `${c}${separator}${r}`;
373
+ return this.cells[index] ?? this.initialCells[index];
362
374
  }
363
375
 
364
376
  private focusedCellBox(): DxEditRequest['cellBox'] {
@@ -714,6 +726,12 @@ export class DxGrid extends LitElement {
714
726
  }
715
727
 
716
728
  override firstUpdated() {
729
+ if (this.getCells) {
730
+ this.cells = this.getCells({
731
+ start: { col: this.visColMin, row: this.visRowMin },
732
+ end: { col: this.visColMax, row: this.visRowMax },
733
+ });
734
+ }
717
735
  this.observer.observe(this.viewportRef.value!);
718
736
  this.colSizes = Object.entries(this.columns).reduce((acc: Record<string, number>, [colId, colMeta]) => {
719
737
  if (colMeta?.size) {
@@ -729,6 +747,22 @@ export class DxGrid extends LitElement {
729
747
  }, {});
730
748
  }
731
749
 
750
+ override willUpdate(changedProperties: Map<string, any>) {
751
+ if (
752
+ this.getCells &&
753
+ (changedProperties.has('initialCells') ||
754
+ changedProperties.has('visColMin') ||
755
+ changedProperties.has('visColMax') ||
756
+ changedProperties.has('visRowMin') ||
757
+ changedProperties.has('visRowMax'))
758
+ ) {
759
+ this.cells = this.getCells({
760
+ start: { col: this.visColMin, row: this.visRowMin },
761
+ end: { col: this.visColMax, row: this.visRowMax },
762
+ });
763
+ }
764
+ }
765
+
732
766
  override updated(changedProperties: Map<string, any>) {
733
767
  // Update the focused element if there is a change in bounds (otherwise Lit keeps focus on the relative element).
734
768
  if (
package/src/types.ts CHANGED
@@ -12,6 +12,10 @@ export type DxGridAxis = 'row' | 'col';
12
12
  export type DxGridPosition = Record<DxGridAxis, number>;
13
13
  export type DxGridPositionNullable = DxGridPosition | null;
14
14
 
15
+ export type DxGridCells = Record<CellIndex, CellValue>;
16
+
17
+ export type DxGridAxisMeta = Record<string, AxisMeta>;
18
+
15
19
  export type DxGridPointer = null | ({ state: 'resizing'; page: number } & DxAxisResizeProps) | { state: 'selecting' };
16
20
 
17
21
  export type DxAxisResizeProps = Pick<DxAxisResize, 'axis' | 'index' | 'size'>;
@@ -39,7 +43,7 @@ export type AxisMeta = {
39
43
  resizeable?: boolean;
40
44
  };
41
45
 
42
- export type DxGridProps = Partial<Pick<DxGrid, 'cells' | 'rows' | 'columns' | 'rowDefault' | 'columnDefault'>>;
46
+ export type DxGridProps = Partial<Pick<DxGrid, 'initialCells' | 'rows' | 'columns' | 'rowDefault' | 'columnDefault'>>;
43
47
 
44
48
  export class DxAxisResize extends Event {
45
49
  public readonly axis: DxGridAxis;
@@ -67,7 +71,7 @@ export class DxEditRequest extends Event {
67
71
  }
68
72
  }
69
73
 
70
- export type DxSelectProps = { start: DxGridPosition; end: DxGridPosition };
74
+ export type DxGridRange = { start: DxGridPosition; end: DxGridPosition };
71
75
 
72
76
  export class DxGridCellsSelect extends Event {
73
77
  public readonly start: string;
@@ -76,7 +80,7 @@ export class DxGridCellsSelect extends Event {
76
80
  public readonly maxCol: number;
77
81
  public readonly minRow: number;
78
82
  public readonly maxRow: number;
79
- constructor({ start, end }: DxSelectProps) {
83
+ constructor({ start, end }: DxGridRange) {
80
84
  super('dx-grid-cells-select');
81
85
  this.start = toCellIndex(start);
82
86
  this.end = toCellIndex(end);