apex-grid 3.5.0 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +573 -0
- package/LICENSE.md +125 -0
- package/README.md +143 -23
- package/components/cell.d.ts +43 -5
- package/components/cell.js +225 -64
- package/components/cell.js.map +1 -1
- package/components/filter-row.d.ts +2 -0
- package/components/filter-row.js +82 -28
- package/components/filter-row.js.map +1 -1
- package/components/grid.d.ts +281 -49
- package/components/grid.js +600 -159
- package/components/grid.js.map +1 -1
- package/components/group-header-row.js +28 -25
- package/components/group-header-row.js.map +1 -1
- package/components/header-row.d.ts +6 -10
- package/components/header-row.js +12 -28
- package/components/header-row.js.map +1 -1
- package/components/header.js +71 -22
- package/components/header.js.map +1 -1
- package/components/paginator.d.ts +20 -5
- package/components/paginator.js +54 -17
- package/components/paginator.js.map +1 -1
- package/components/row.d.ts +19 -3
- package/components/row.js +211 -56
- package/components/row.js.map +1 -1
- package/components/toolbar.d.ts +5 -1
- package/components/toolbar.js +6 -2
- package/components/toolbar.js.map +1 -1
- package/components/virtualize-rows.d.ts +38 -0
- package/components/virtualize-rows.js +286 -0
- package/components/virtualize-rows.js.map +1 -0
- package/components/virtualizer.d.ts +111 -1
- package/components/virtualizer.js +192 -5
- package/components/virtualizer.js.map +1 -1
- package/controllers/dom.d.ts +14 -7
- package/controllers/dom.js +45 -27
- package/controllers/dom.js.map +1 -1
- package/controllers/editing.d.ts +104 -37
- package/controllers/editing.js +230 -78
- package/controllers/editing.js.map +1 -1
- package/controllers/expansion.d.ts +14 -5
- package/controllers/expansion.js +24 -1
- package/controllers/expansion.js.map +1 -1
- package/controllers/filter.d.ts +10 -2
- package/controllers/filter.js +62 -17
- package/controllers/filter.js.map +1 -1
- package/controllers/history.d.ts +45 -8
- package/controllers/history.js +58 -20
- package/controllers/history.js.map +1 -1
- package/controllers/navigation.d.ts +130 -13
- package/controllers/navigation.js +474 -60
- package/controllers/navigation.js.map +1 -1
- package/controllers/pagination.d.ts +13 -6
- package/controllers/pagination.js +29 -22
- package/controllers/pagination.js.map +1 -1
- package/controllers/reorder.js +38 -22
- package/controllers/reorder.js.map +1 -1
- package/controllers/resize.d.ts +17 -2
- package/controllers/resize.js +16 -6
- package/controllers/resize.js.map +1 -1
- package/controllers/row-pin.d.ts +26 -2
- package/controllers/row-pin.js +24 -11
- package/controllers/row-pin.js.map +1 -1
- package/controllers/row-reorder.d.ts +40 -12
- package/controllers/row-reorder.js +137 -43
- package/controllers/row-reorder.js.map +1 -1
- package/controllers/selection.d.ts +33 -4
- package/controllers/selection.js +49 -11
- package/controllers/selection.js.map +1 -1
- package/controllers/sort.d.ts +22 -2
- package/controllers/sort.js +30 -25
- package/controllers/sort.js.map +1 -1
- package/controllers/state.d.ts +74 -7
- package/controllers/state.js +117 -36
- package/controllers/state.js.map +1 -1
- package/controllers/tree.d.ts +15 -10
- package/controllers/tree.js +0 -0
- package/controllers/tree.js.map +1 -1
- package/custom-elements.json +5091 -1023
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/highlight.css +15 -8
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/ApexGrid.html +233 -87
- package/docs/classes/ApexGridPaginator.html +39 -8
- package/docs/classes/ApexGridToolbar.html +11 -7
- package/docs/functions/localize.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +159 -26
- package/docs/interfaces/ApexCellValidationFailedEvent.html +3 -2
- package/docs/interfaces/ApexCellValueChangedEvent.html +4 -2
- package/docs/interfaces/ApexCellValueChangingEvent.html +3 -2
- package/docs/interfaces/ApexGridEventMap.html +5 -2
- package/docs/interfaces/ApexPageChangedEvent.html +3 -1
- package/docs/interfaces/ApexRowEditEndedEvent.html +2 -1
- package/docs/interfaces/ApexRowEditStartedEvent.html +2 -1
- package/docs/interfaces/ApexRowMovingEvent.html +9 -3
- package/docs/interfaces/ApexRowPinningEvent.html +1 -1
- package/docs/interfaces/ApexTreeRowExpandedEvent.html +4 -1
- package/docs/interfaces/ApexTreeRowExpandingEvent.html +4 -1
- package/docs/interfaces/BaseApexCellContext.html +18 -5
- package/docs/interfaces/BaseApexEditorContext.html +20 -5
- package/docs/interfaces/BaseFilterExpression.html +3 -3
- package/docs/interfaces/CSVExportOptions.html +12 -4
- package/docs/interfaces/DataPipelineConfiguration.html +4 -9
- package/docs/interfaces/ExportOptions.html +5 -3
- package/docs/interfaces/GridExpansionConfiguration.html +6 -2
- package/docs/interfaces/GridRowReorderingConfiguration.html +1 -1
- package/docs/interfaces/GridSelectionConfiguration.html +19 -4
- package/docs/interfaces/PaginationConfiguration.html +11 -4
- package/docs/interfaces/PaginationState.html +4 -2
- package/docs/interfaces/SetStateResult.html +3 -2
- package/docs/interfaces/ValidatorContext.html +7 -2
- package/docs/media/_token-values.scss +118 -0
- package/docs/media/package.json +9 -5
- package/docs/modules.html +1 -1
- package/docs/types/DataPipelineParams.html +2 -2
- package/docs/types/ExportSource.html +6 -4
- package/docs/types/OperandKeys.html +9 -0
- package/docs/types/PaginationMode.html +5 -4
- package/docs/variables/EN_LOCALE.html +2 -2
- package/i18n/en.d.ts +7 -0
- package/i18n/en.js +7 -0
- package/i18n/en.js.map +1 -1
- package/i18n/es.js +7 -0
- package/i18n/es.js.map +1 -1
- package/internal/column-types.d.ts +38 -2
- package/internal/column-types.js +83 -55
- package/internal/column-types.js.map +1 -1
- package/internal/constants.d.ts +1 -2
- package/internal/constants.js +0 -4
- package/internal/constants.js.map +1 -1
- package/internal/document-styles.d.ts +30 -0
- package/internal/document-styles.js +48 -0
- package/internal/document-styles.js.map +1 -0
- package/internal/export.d.ts +45 -7
- package/internal/export.js +39 -34
- package/internal/export.js.map +1 -1
- package/internal/feature-module.d.ts +67 -3
- package/internal/feature-module.js +6 -0
- package/internal/feature-module.js.map +1 -1
- package/internal/flip.d.ts +28 -16
- package/internal/flip.js +42 -10
- package/internal/flip.js.map +1 -1
- package/internal/index.d.ts +7 -5
- package/internal/index.js +6 -4
- package/internal/index.js.map +1 -1
- package/internal/normalize-case.d.ts +8 -1
- package/internal/normalize-case.js +3 -2
- package/internal/normalize-case.js.map +1 -1
- package/internal/state-snapshot.d.ts +60 -8
- package/internal/state-snapshot.js +87 -19
- package/internal/state-snapshot.js.map +1 -1
- package/internal/types.d.ts +92 -21
- package/internal/types.js.map +1 -1
- package/internal/utils.d.ts +34 -6
- package/internal/utils.js +30 -21
- package/internal/utils.js.map +1 -1
- package/internal/validators.js +1 -0
- package/internal/validators.js.map +1 -1
- package/operations/filter/operands/number.js +9 -6
- package/operations/filter/operands/number.js.map +1 -1
- package/operations/filter/operands/string.js +2 -3
- package/operations/filter/operands/string.js.map +1 -1
- package/operations/filter/types.d.ts +14 -2
- package/operations/filter/types.js.map +1 -1
- package/operations/filter.d.ts +6 -0
- package/operations/filter.js +23 -7
- package/operations/filter.js.map +1 -1
- package/operations/quick-filter.js +2 -5
- package/operations/quick-filter.js.map +1 -1
- package/operations/sort.d.ts +21 -2
- package/operations/sort.js +41 -14
- package/operations/sort.js.map +1 -1
- package/package.json +9 -4
- package/setup.d.ts +11 -0
- package/setup.js +9 -19
- package/setup.js.map +1 -1
- package/styles/_token-values.css.d.ts +1 -0
- package/styles/_token-values.css.js +3 -0
- package/styles/_token-values.css.js.map +1 -0
- package/styles/_tokens.css.js +1 -1
- package/styles/_tokens.css.js.map +1 -1
- package/styles/body-cell/body-cell.css.js +1 -1
- package/styles/body-cell/body-cell.css.js.map +1 -1
- package/styles/body-cell/cell-renderers.css.js +1 -1
- package/styles/body-cell/cell-renderers.css.js.map +1 -1
- package/styles/body-row/body-row.css.js +1 -1
- package/styles/body-row/body-row.css.js.map +1 -1
- package/styles/document-tokens.css.d.ts +1 -0
- package/styles/document-tokens.css.js +3 -0
- package/styles/document-tokens.css.js.map +1 -0
- package/styles/filter-row/filter-row.css.js +1 -1
- package/styles/filter-row/filter-row.css.js.map +1 -1
- package/styles/grid/_grid.base.css.js +1 -1
- package/styles/grid/_grid.base.css.js.map +1 -1
- package/styles/grid/grid.css.js +1 -1
- package/styles/grid/grid.css.js.map +1 -1
- package/styles/group-header-row/group-header-row.css.js +1 -1
- package/styles/group-header-row/group-header-row.css.js.map +1 -1
- package/styles/header-cell/header-cell.css.js +1 -1
- package/styles/header-cell/header-cell.css.js.map +1 -1
- package/styles/header-row/header-row.base.css.js +1 -1
- package/styles/header-row/header-row.base.css.js.map +1 -1
- package/styles/paginator/paginator.css.js +1 -1
- package/styles/paginator/paginator.css.js.map +1 -1
- package/styles/toolbar/toolbar.css.js +1 -1
- package/styles/toolbar/toolbar.css.js.map +1 -1
- package/tokens.css +78 -0
- package/LICENSE +0 -80
- package/docs/media/LICENSE +0 -80
- package/docs/media/_tokens.scss +0 -214
- package/operations/pagination.d.ts +0 -19
- package/operations/pagination.js +0 -12
- package/operations/pagination.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-reorder.js","sourceRoot":"","sources":["../../src/controllers/row-reorder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAuB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAO5F,MAAM,iBAAiB,GAAG,CAAC,CAAC;AA+D5B,MAAM,OAAO,oBAAoB;IAE/B,MAAM,CAAoB;IAG1B,QAAQ,CAAoB;IAgB5B,SAAS,CAAS;IAOlB,QAAQ,CAMQ;IAEhB,YAAsB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAlCvC,WAAM,GAAe,IAAI,CAAC;QAG1B,aAAQ,GAAe,IAAI,CAAC;QAGrB,aAAQ,GAAa,IAAI,CAAC;QAO1B,UAAK,GAAyB,IAAI,CAAC;QAGnC,YAAO,GAAa,IAAI,CAAC;QAGhC,cAAS,GAAG,KAAK,CAAC;QAOlB,aAAQ,GAMG,IAAI,CAAC;QA6MhB,uBAAkB,GAAG,CAAC,KAAmB,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I,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,YAAY,CAAC,MAAwC;QACnD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;QACzC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACjC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAA6B,CAAC,CAAC;QACtD,CAAC;QACD,aAAa,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,GAAG,CAAC,CAAC;IACjE,CAAC;CACF","sourcesContent":["import type { ReactiveController } from 'lit';\nimport { PIPELINE } from '../internal/constants.js';\nimport { awaitChildUpdates, type KeyedFlipEntry, playKeyedFlip } from '../internal/flip.js';\nimport type { GridHost } from '../internal/types.js';\n\n/** Where a moved row lands relative to its target. */\nexport type RowDropPosition = 'before' | 'after';\n\n/** Pixels the pointer must travel before a row drag engages. */\nconst DRAG_THRESHOLD_PX = 4;\n\n/** A single cell snapshot used to paint the floating row ghost. */\nexport interface RowGhostCell {\n /** The cell's rendered text at grab time. */\n text: string;\n /** The cell's rendered width (px), so the ghost matches the column layout. */\n width: number;\n /** The cell's computed `text-align`, so numbers stay right-aligned in the ghost. */\n align: string;\n}\n\n/** Everything the row hands the controller to seed the floating ghost. */\nexport interface RowGhostInit {\n /** The source row's bounding rect at grab time. */\n rect: DOMRect;\n /** Pointer position at grab time (to keep the grab point under the cursor). */\n clientX: number;\n clientY: number;\n /** Per-cell snapshot of the row's visible content. */\n cells: RowGhostCell[];\n}\n\n/**\n * Live state for the floating \"ghost\" row that trails the cursor during a\n * pointer drag. Mirrors {@link ReorderController}'s column ghost: the source\n * row stays in the grid (and live-swaps), the ghost is a purely visual proxy.\n */\nexport interface RowGhostState {\n /** Ghost position (viewport-relative top-left, in CSS pixels). */\n x: number;\n y: number;\n /** Ghost size, fixed at the source row's initial bounding rect. */\n width: number;\n height: number;\n /** Cursor offset within the ghost so the grab point stays under the cursor. */\n pointerOffsetX: number;\n pointerOffsetY: number;\n /** Snapshot of the row's visible cells. */\n cells: ReadonlyArray<RowGhostCell>;\n}\n\n/**\n * Reactive controller backing row drag-reorder and a manual row order.\n *\n * @remarks\n * Row order is normally derived (filter → sort). This controller adds a\n * **manual order**: an explicit sequence of row references applied as a\n * pipeline step after sort. While a manual order is active, sorting is mutually\n * exclusive (applying a sort clears the manual order). State is reference-based,\n * so it survives the in-place pipeline.\n *\n * Reordering happens through {@link moveRow} (pointer live-swap during a drag,\n * the keyboard grab/move flow, or the public API). Each move goes through the\n * cancellable `rowMoving` event and emits a follow-up `rowMoved`, then animates\n * with a Y-axis FLIP. Pinned rows (F4) are never the drag source and reorder\n * only within the unpinned body set.\n *\n * Persistence: by default the order lives in this controller and the app\n * persists via `rowMoved`. With `rowReordering.applyToData` the move also\n * splices {@link ApexGrid.data} in place (and clears the manual order, since the\n * data array then carries the order).\n */\nexport class RowReorderController<T extends object> implements ReactiveController {\n /** Manual order of row references, or `null` for the natural (sorted) order. */\n #order: T[] | null = null;\n\n /** Order snapshot captured at keyboard-grab time, for Escape-to-cancel. */\n #preGrab: T[] | null = null;\n\n /** The row currently being pointer-dragged, or `null`. */\n public dragging: T | null = null;\n\n /**\n * Live floating-ghost state during a pointer drag, or `null`. Surfaced to the\n * grid, which renders the ghost at the top of its shadow tree (outside the\n * virtualizer) so `position: fixed` tracks the viewport cleanly.\n */\n public ghost: RowGhostState | null = null;\n\n /** The row currently grabbed for keyboard reorder, or `null`. */\n public grabbed: T | null = null;\n\n /** Re-entrancy guard so a slow swap can't trigger a second mid-drag. */\n #swapping = false;\n\n /**\n * In-flight pointer-drag gesture. The move/up listeners live on the **grid\n * host** (a stable element), not the row, so a live-swap that recycles the\n * source row's DOM can't tear the drag down mid-gesture.\n */\n #pending: {\n data: T;\n getGhost: () => RowGhostInit;\n startX: number;\n startY: number;\n pointerId: number;\n } | null = null;\n\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n /** The grid host as a DOM event target (it is always an `HTMLElement`). */\n get #hostElement(): HTMLElement {\n return this.host as unknown as HTMLElement;\n }\n\n public hostConnected() {}\n\n /** Whether row reordering is enabled at the grid level. */\n public get enabled(): boolean {\n return Boolean(this.host.rowReordering?.enabled);\n }\n\n /**\n * Whether a pointer drag must start from the dedicated grip handle (the\n * default), rather than from anywhere on the row. Driven by\n * `rowReordering.handle` (defaults to `true`).\n */\n public get handleMode(): boolean {\n return this.enabled && this.host.rowReordering?.handle !== false;\n }\n\n /**\n * Whether the leading grip-handle column is rendered. Only in handle mode, and\n * only while reordering is enabled.\n */\n public get showHandleColumn(): boolean {\n return this.handleMode;\n }\n\n /** Whether moves also splice {@link ApexGrid.data} in place. */\n public get applyToData(): boolean {\n return Boolean(this.host.rowReordering?.applyToData);\n }\n\n /** Whether a manual order is currently active. */\n public get hasManualOrder(): boolean {\n return this.#order !== null;\n }\n\n /** Whether a row is currently grabbed for keyboard reorder. */\n public get isGrabbing(): boolean {\n return this.grabbed !== null;\n }\n\n /**\n * Pipeline step: reorders the (post-filter, post-sort) rows by the manual\n * order. Rows absent from the manual order (e.g. newly added) keep their\n * incoming relative order at the end. Identity pass-through when inactive.\n */\n public apply(rows: T[]): T[] {\n if (!this.#order) return rows;\n const rank = new Map<T, number>();\n this.#order.forEach((row, i) => {\n rank.set(row, i);\n });\n return [...rows].sort((a, b) => {\n const ra = rank.has(a) ? (rank.get(a) as number) : Number.POSITIVE_INFINITY;\n const rb = rank.has(b) ? (rank.get(b) as number) : Number.POSITIVE_INFINITY;\n return ra - rb;\n });\n }\n\n /**\n * The current manual order as a copy of its row references, or `null` for the\n * derived order. Consumed by `ApexGrid.getState`.\n */\n public getManualOrder(): T[] | null {\n return this.#order ? [...this.#order] : null;\n }\n\n /**\n * Restores a manual order from a list of row references (state restore). Pass\n * `null` (or an empty list) to clear it. Silent: emits no `rowMoving` /\n * `rowMoved` and does not animate; re-runs the pipeline.\n */\n public restoreManualOrder(order: T[] | null): void {\n this.#order = order?.length ? [...order] : null;\n this.host.requestUpdate(PIPELINE);\n }\n\n /**\n * Clears the manual order (e.g. when a sort is applied). Re-runs the pipeline.\n */\n public clearManualOrder(announce = false): void {\n if (!this.#order) return;\n this.#order = null;\n this.host.requestUpdate(PIPELINE);\n if (announce) this.host.announce(this.host.localize('announce.manualOrderCleared'));\n }\n\n /**\n * Moves the row at view index `from` relative to the row at view index `to`.\n * Indices are into {@link ApexGrid.pageItems}.\n *\n * @returns `true` when applied, `false` when disabled, out of range, or\n * cancelled via `rowMoving`.\n */\n public moveRow(from: number, to: number, position: RowDropPosition = 'before'): boolean {\n const view = this.host.pageItems;\n const before = this.#captureRowRects();\n const ok = this.#commit(view[from] as T, view[to] as T, position);\n if (ok) void this.#flipAfterUpdate(before);\n return ok;\n }\n\n // --- pointer drag -------------------------------------------------------\n\n /**\n * Begins a pointer drag from `source`. When `ghost` is supplied (the pointer\n * path always does), seeds the floating ghost from the source row's rect and\n * the grab point so it stays anchored under the cursor.\n */\n public startDrag(source: T, ghost?: RowGhostInit): void {\n if (!this.enabled) return;\n this.dragging = source;\n this.ghost = ghost\n ? {\n x: ghost.rect.left,\n y: ghost.rect.top,\n width: ghost.rect.width,\n height: ghost.rect.height,\n pointerOffsetX: ghost.clientX - ghost.rect.left,\n pointerOffsetY: ghost.clientY - ghost.rect.top,\n cells: ghost.cells,\n }\n : null;\n this.host.requestUpdate();\n }\n\n /** Moves the floating ghost to track the cursor. No-op without an active ghost. */\n public moveGhost(clientX: number, clientY: number): void {\n if (!this.ghost) return;\n this.ghost = {\n ...this.ghost,\n x: clientX - this.ghost.pointerOffsetX,\n y: clientY - this.ghost.pointerOffsetY,\n };\n this.host.requestUpdate();\n }\n\n /**\n * Called on pointer-move during a drag: live-swaps the dragged row past the\n * body row currently under `clientY` once the cursor crosses its midpoint.\n */\n public dragOver(clientY: number): void {\n if (!this.dragging || this.#swapping) return;\n const target = this.#bodyRowAt(clientY);\n if (!target || target.data === this.dragging) return;\n\n const view = this.host.pageItems;\n const sourceIdx = view.indexOf(this.dragging);\n const targetIdx = view.indexOf(target.data);\n if (sourceIdx === -1 || targetIdx === -1) return;\n\n const rect = target.element.getBoundingClientRect();\n const midpoint = rect.top + rect.height / 2;\n let position: RowDropPosition;\n if (sourceIdx < targetIdx) {\n if (clientY < midpoint) return; // dragging down — wait for the midpoint\n position = 'after';\n } else {\n if (clientY > midpoint) return; // dragging up\n position = 'before';\n }\n void this.#dragSwap(target.data, position);\n }\n\n /** Ends the pointer drag. The order is already final (live-swapped). */\n public endDrag(): void {\n if (!this.dragging) return;\n this.dragging = null;\n this.ghost = null;\n this.host.requestUpdate();\n }\n\n /**\n * Arms a pointer drag from a row press. Called by the row on `pointerdown`\n * (from the grip in handle mode, or anywhere in whole-row mode). The move /\n * up / cancel listeners are bound to the **grid host**, so the gesture is\n * immune to the source row's DOM being recycled by a live-swap. `getGhost` is\n * a thunk the controller invokes once, the instant the drag engages, to\n * snapshot the row's cells (the row is still in place then).\n */\n public armPointerDrag(data: T, getGhost: () => RowGhostInit, event: PointerEvent): void {\n const pinned = this.host.pinnedRows;\n if (!this.enabled || pinned.top.includes(data) || pinned.bottom.includes(data)) return;\n this.#pending = {\n data,\n getGhost,\n startX: event.clientX,\n startY: event.clientY,\n pointerId: event.pointerId,\n };\n const host = this.#hostElement;\n host.addEventListener('pointermove', this.#onHostPointerMove);\n host.addEventListener('pointerup', this.#onHostPointerUp);\n host.addEventListener('pointercancel', this.#onHostPointerUp);\n }\n\n #onHostPointerMove = (event: PointerEvent): void => {\n const pending = this.#pending;\n if (!pending || event.pointerId !== pending.pointerId) return;\n if (!this.dragging) {\n const dx = event.clientX - pending.startX;\n const dy = event.clientY - pending.startY;\n if (Math.hypot(dx, dy) < DRAG_THRESHOLD_PX) return;\n // Capture on the stable host so moves keep arriving even when the cursor\n // leaves the grid, and so the source row reflowing can't drop the pointer.\n try {\n this.#hostElement.setPointerCapture(pending.pointerId);\n } catch {\n /* a synthetic pointer id may not be capturable; hit-testing still works */\n }\n this.startDrag(pending.data, pending.getGhost());\n }\n this.moveGhost(event.clientX, event.clientY);\n this.dragOver(event.clientY);\n };\n\n #onHostPointerUp = (event: PointerEvent): void => {\n const pending = this.#pending;\n if (!pending || event.pointerId !== pending.pointerId) return;\n const host = this.#hostElement;\n host.removeEventListener('pointermove', this.#onHostPointerMove);\n host.removeEventListener('pointerup', this.#onHostPointerUp);\n host.removeEventListener('pointercancel', this.#onHostPointerUp);\n try {\n if (host.hasPointerCapture(pending.pointerId)) host.releasePointerCapture(pending.pointerId);\n } catch {\n /* capture was never taken or already released */\n }\n this.#pending = null;\n this.endDrag();\n };\n\n async #dragSwap(target: T, position: RowDropPosition): Promise<void> {\n if (this.#swapping) return;\n this.#swapping = true;\n try {\n const before = this.#captureRowRects();\n if (this.#commit(this.dragging as T, target, position)) {\n await this.host.updateComplete;\n await awaitChildUpdates(this.host.rows);\n this.#playRowFlip(before);\n }\n } finally {\n this.#swapping = false;\n }\n }\n\n // --- keyboard grab ------------------------------------------------------\n\n /** Grabs the row at view index `rowIndex` for keyboard reorder. */\n public grab(rowIndex: number): boolean {\n if (!this.enabled) return false;\n const row = this.host.pageItems[rowIndex] as T | undefined;\n if (!row) return false;\n this.grabbed = row;\n this.#preGrab = this.#order ? [...this.#order] : null;\n this.host.requestUpdate();\n this.host.announce(this.host.localize('announce.rowGrabbed'));\n return true;\n }\n\n /**\n * Moves the grabbed row one position in `direction`. Returns the grabbed\n * row's new view index, or `-1` when it can't move (no grab / at the edge).\n */\n public moveGrabbed(direction: -1 | 1): number {\n if (!this.grabbed) return -1;\n const view = this.host.pageItems;\n const current = view.indexOf(this.grabbed);\n const target = current + direction;\n if (current === -1 || target < 0 || target >= view.length) return -1;\n const before = this.#captureRowRects();\n const ok = this.#commit(this.grabbed, view[target] as T, direction > 0 ? 'after' : 'before', {\n silent: true,\n });\n if (!ok) return -1;\n void this.#flipAfterUpdate(before);\n this.host.announce(this.host.localize('announce.rowMovedTo', { position: target + 1 }));\n return target;\n }\n\n /** Drops the grabbed row, keeping its moves. */\n public drop(): void {\n if (!this.grabbed) return;\n this.grabbed = null;\n this.#preGrab = null;\n this.host.requestUpdate();\n this.host.announce(this.host.localize('announce.rowDropped'));\n }\n\n /** Cancels the grab, reverting to the order captured when it was grabbed. */\n public cancelGrab(): void {\n if (!this.grabbed) return;\n this.grabbed = null;\n this.#order = this.#preGrab;\n this.#preGrab = null;\n this.host.requestUpdate(PIPELINE);\n this.host.announce(this.host.localize('announce.reorderCancelled'));\n }\n\n // --- internals ----------------------------------------------------------\n\n /**\n * The core order mutation: validates, emits `rowMoving` (cancellable),\n * updates the manual order (or splices data when `applyToData`), re-runs the\n * pipeline, and emits `rowMoved`. Does not animate.\n */\n #commit(\n source: T | undefined,\n target: T | undefined,\n position: RowDropPosition,\n options: { silent?: boolean } = {}\n ): boolean {\n if (!this.enabled || !source || !target || source === target) return false;\n const view = this.host.pageItems;\n const from = view.indexOf(source);\n const to = view.indexOf(target);\n\n const proceed = this.host.emitEvent('rowMoving', {\n detail: { from, to, data: source },\n cancelable: true,\n });\n if (!proceed) return false;\n\n const baseline = this.#order ?? [...(this.host.dataView as ReadonlyArray<T>)];\n const next = baseline.filter((row) => row !== source);\n let index = next.indexOf(target);\n if (index === -1) return false;\n if (position === 'after') index += 1;\n next.splice(index, 0, source);\n\n if (this.applyToData) {\n this.#spliceData(next);\n this.#order = null; // the data array now carries the order\n } else {\n this.#order = next;\n }\n\n this.host.requestUpdate(PIPELINE);\n if (!options.silent) this.host.announce(this.host.localize('announce.rowMoved'));\n this.host.emitEvent('rowMoved', { detail: { from, to, data: source } });\n return true;\n }\n\n /** Reorders {@link ApexGrid.data} in place to match `order`. */\n #spliceData(order: ReadonlyArray<T>): void {\n const rank = new Map<T, number>();\n order.forEach((row, i) => {\n rank.set(row, i);\n });\n (this.host.data as T[]).sort((a, b) => {\n const ra = rank.has(a) ? (rank.get(a) as number) : Number.POSITIVE_INFINITY;\n const rb = rank.has(b) ? (rank.get(b) as number) : Number.POSITIVE_INFINITY;\n return ra - rb;\n });\n }\n\n /** The rendered body row (non-pinned) whose box contains `clientY`. */\n #bodyRowAt(clientY: number): { data: T; element: HTMLElement } | null {\n const pinned = this.host.pinnedRows;\n for (const row of this.host.rows) {\n if (pinned.top.includes(row.data) || pinned.bottom.includes(row.data)) continue;\n const element = row as unknown as HTMLElement;\n const rect = element.getBoundingClientRect();\n if (clientY >= rect.top && clientY < rect.bottom) return { data: row.data, element };\n }\n return null;\n }\n\n #captureRowRects(): KeyedFlipEntry<T>[] {\n const entries: KeyedFlipEntry<T>[] = [];\n for (const row of this.host.rows) {\n const el = row as unknown as HTMLElement;\n entries.push({ key: row.data, rect: el.getBoundingClientRect() });\n }\n return entries;\n }\n\n async #flipAfterUpdate(before: ReadonlyArray<KeyedFlipEntry<T>>): Promise<void> {\n await this.host.updateComplete;\n await awaitChildUpdates(this.host.rows);\n this.#playRowFlip(before);\n }\n\n #playRowFlip(before: ReadonlyArray<KeyedFlipEntry<T>>): void {\n const byData = new Map<T, HTMLElement>();\n for (const row of this.host.rows) {\n byData.set(row.data, row as unknown as HTMLElement);\n }\n playKeyedFlip(before, (data) => byData.get(data) ?? null, 'y');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"row-reorder.js","sourceRoot":"","sources":["../../src/controllers/row-reorder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAuB,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAG5F,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AAMtD,MAAM,iBAAiB,GAAG,CAAC,CAAC;AA4B5B,MAAM,UAAU,eAAe,CAC7B,GAAY,EACZ,KAA6B,EAC7B,OAAe,EACf,OAAe;IAEf,M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\nimport { PIPELINE } from '../internal/constants.js';\nimport { type KeyedFlipEntry, playKeyedFlip, settleRowsForFlip } from '../internal/flip.js';\nimport type { GridHost } from '../internal/types.js';\nimport type { SortExpression } from '../operations/sort/types.js';\nimport SortDataOperation from '../operations/sort.js';\n\n/** Where a moved row lands relative to its target. */\nexport type RowDropPosition = 'before' | 'after';\n\n/** Pixels the pointer must travel before a row drag engages. */\nconst DRAG_THRESHOLD_PX = 4;\n\n/** A single cell snapshot used to paint the floating row ghost. */\nexport interface RowGhostCell {\n /** The cell's rendered text at grab time. */\n text: string;\n /** The cell's rendered width (px), so the ghost matches the column layout. */\n width: number;\n /** The cell's computed `text-align`, so numbers stay right-aligned in the ghost. */\n align: string;\n}\n\n/** Everything the row hands the controller to seed the floating ghost. */\nexport interface RowGhostInit {\n /** The source row's bounding rect at grab time. */\n rect: DOMRect;\n /** Pointer position at grab time (to keep the grab point under the cursor). */\n clientX: number;\n clientY: number;\n /** Per-cell snapshot of the row's visible content. */\n cells: RowGhostCell[];\n}\n\n/**\n * Snapshots a row element for the floating ghost: its bounding rect and each\n * cell's rendered text, width and alignment. A cell renders into its own\n * shadow root, so the text is read from there.\n */\nexport function captureRowGhost(\n row: Element,\n cells: ReadonlyArray<Element>,\n clientX: number,\n clientY: number\n): RowGhostInit {\n const rect = row.getBoundingClientRect();\n const snapshot = cells.map((cell) => ({\n text: ((cell.shadowRoot ?? cell).textContent ?? '').replace(/\\s+/g, ' ').trim(),\n width: cell.getBoundingClientRect().width,\n align: getComputedStyle(cell).textAlign,\n }));\n return { rect, clientX, clientY, cells: snapshot };\n}\n\n/**\n * Live state for the floating \"ghost\" row that trails the cursor during a\n * pointer drag. Mirrors {@link ReorderController}'s column ghost: the source\n * row stays in the grid (and live-swaps), the ghost is a purely visual proxy.\n */\nexport interface RowGhostState {\n /** Ghost position (viewport-relative top-left, in CSS pixels). */\n x: number;\n y: number;\n /** Ghost size, fixed at the source row's initial bounding rect. */\n width: number;\n height: number;\n /** Cursor offset within the ghost so the grab point stays under the cursor. */\n pointerOffsetX: number;\n pointerOffsetY: number;\n /** Snapshot of the row's visible cells. */\n cells: ReadonlyArray<RowGhostCell>;\n}\n\n/**\n * Reactive controller backing row drag-reorder and a manual row order.\n *\n * @remarks\n * Row order is normally derived (filter → sort). This controller adds a\n * **manual order**: an explicit sequence of row references applied as a\n * pipeline step after sort. A manual order and a sort are mutually exclusive:\n * applying a sort clears the manual order, and a move clears the sort. The\n * order spans every row, hidden by a filter or not, so a move made under a\n * filter leaves the hidden rows in place. State is reference-based, so it\n * survives the in-place pipeline, and it is carried onto a new `data` array\n * (by `rowId` when set, else by identity).\n *\n * Reordering happens through {@link moveRow} (pointer live-swap during a drag,\n * the keyboard grab/move flow, or the public API). Each move goes through the\n * cancellable `rowMoving` event and emits a follow-up `rowMoved`, then animates\n * with a Y-axis FLIP. Pinned rows (F4) are never the drag source and reorder\n * only within the unpinned body set.\n *\n * Persistence: by default the order lives in this controller and the app\n * persists via `rowMoved`. With `rowReordering.applyToData` the move also\n * splices {@link ApexGrid.data} in place (and clears the manual order, since the\n * data array then carries the order).\n */\nexport class RowReorderController<T extends object> implements ReactiveController {\n /** Manual order of row references, or `null` for the natural (sorted) order. */\n #order: T[] | null = null;\n\n /**\n * What a keyboard grab may change, captured when it starts, for\n * Escape-to-cancel: the manual order, the data order (with `applyToData`),\n * the sort and the grabbed row's view index.\n */\n #preGrab: {\n order: T[] | null;\n data: T[] | null;\n sort: SortExpression<T>[];\n index: number;\n } | null = null;\n\n /** The row currently being pointer-dragged, or `null`. */\n public dragging: T | null = null;\n\n /**\n * Live floating-ghost state during a pointer drag, or `null`. Surfaced to the\n * grid, which renders the ghost at the top of its shadow tree (outside the\n * virtualizer) so `position: fixed` tracks the viewport cleanly.\n */\n public ghost: RowGhostState | null = null;\n\n /** The row currently grabbed for keyboard reorder, or `null`. */\n public grabbed: T | null = null;\n\n /** Re-entrancy guard so a slow swap can't trigger a second mid-drag. */\n #swapping = false;\n\n /**\n * In-flight pointer-drag gesture. The move/up listeners live on the **grid\n * host** (a stable element), not the row, so a live-swap that recycles the\n * source row's DOM can't tear the drag down mid-gesture.\n */\n #pending: {\n data: T;\n getGhost: () => RowGhostInit | null;\n startX: number;\n startY: number;\n pointerId: number;\n } | null = null;\n\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n /** The grid host as a DOM event target (it is always an `HTMLElement`). */\n get #hostElement(): HTMLElement {\n return this.host as unknown as HTMLElement;\n }\n\n public hostConnected() {}\n\n /** A grid detached mid-drag ends the gesture, so no frozen ghost stays behind. */\n public hostDisconnected() {\n this.#endPointer();\n }\n\n /** Whether row reordering is enabled at the grid level. */\n public get enabled(): boolean {\n return Boolean(this.host.rowReordering?.enabled);\n }\n\n /**\n * Whether a pointer drag must start from the dedicated grip handle (the\n * default), rather than from anywhere on the row. Driven by\n * `rowReordering.handle` (defaults to `true`).\n */\n public get handleMode(): boolean {\n return this.enabled && this.host.rowReordering?.handle !== false;\n }\n\n /**\n * Whether the leading grip-handle column is rendered. Only in handle mode, and\n * only while reordering is enabled.\n */\n public get showHandleColumn(): boolean {\n return this.handleMode;\n }\n\n /** Whether moves also splice {@link ApexGrid.data} in place. */\n public get applyToData(): boolean {\n return Boolean(this.host.rowReordering?.applyToData);\n }\n\n /** Whether a manual order is currently active. */\n public get hasManualOrder(): boolean {\n return this.#order !== null;\n }\n\n /** Whether a row is currently grabbed for keyboard reorder. */\n public get isGrabbing(): boolean {\n return this.grabbed !== null;\n }\n\n /**\n * Pipeline step: reorders the (post-filter, post-sort) rows by the manual\n * order. Rows absent from the manual order (e.g. newly added) keep their\n * incoming relative order at the end. Identity pass-through when inactive.\n */\n public apply(rows: T[]): T[] {\n if (!this.#order) return rows;\n const rank = new Map<T, number>();\n this.#order.forEach((row, i) => {\n rank.set(row, i);\n });\n return [...rows].sort((a, b) => {\n const ra = rank.has(a) ? (rank.get(a) as number) : Number.POSITIVE_INFINITY;\n const rb = rank.has(b) ? (rank.get(b) as number) : Number.POSITIVE_INFINITY;\n return ra - rb;\n });\n }\n\n /**\n * The current manual order as a copy of its row references, or `null` for the\n * derived order. Consumed by `ApexGrid.getState`.\n */\n public getManualOrder(): T[] | null {\n return this.#order ? [...this.#order] : null;\n }\n\n /**\n * Restores a manual order from a list of row references (state restore). Pass\n * `null` (or an empty list) to clear it. Silent: emits no `rowMoving` /\n * `rowMoved` and does not animate; re-runs the pipeline.\n */\n public restoreManualOrder(order: T[] | null): void {\n this.#order = order?.length ? [...order] : null;\n this.host.requestUpdate(PIPELINE);\n }\n\n /**\n * Clears the manual order (e.g. when a sort is applied). Re-runs the pipeline.\n */\n public clearManualOrder(announce = false): void {\n if (!this.#order) return;\n this.#order = null;\n this.host.requestUpdate(PIPELINE);\n if (announce) this.host.announce(this.host.localize('announce.manualOrderCleared'));\n }\n\n /**\n * Carries the manual order onto a new `data` array through `carry` (by\n * `rowId` when set, else the rows still present), clearing it when no row\n * survives. A grab or drag follows its row onto the new data, so an app\n * that re-sets `data` on `rowMoved` keeps the gesture; it ends only when\n * the row is gone.\n */\n public resetForDataChange(carry: (rows: T[]) => T[]): void {\n const pre = this.#preGrab;\n if (this.grabbed) {\n this.grabbed = carry([this.grabbed])[0] ?? null;\n if (!this.grabbed) this.#preGrab = null;\n else if (pre) {\n pre.order = pre.order && carry(pre.order);\n pre.data = pre.data && carry(pre.data);\n }\n }\n const pending = this.#pending;\n const held = pending?.data ?? this.dragging;\n if (held) {\n const row = carry([held])[0];\n if (!row) this.#endPointer();\n else {\n if (pending) pending.data = row;\n if (this.dragging) this.dragging = row;\n }\n }\n if (this.#order) this.restoreManualOrder(carry(this.#order));\n }\n\n /**\n * Moves the row at view index `from` relative to the row at view index `to`.\n * Indices are into {@link ApexGrid.pageItems}.\n *\n * @returns `true` when applied, `false` when disabled, out of range, a\n * no-op (the row would land where it is), or cancelled via `rowMoving`.\n */\n public moveRow(from: number, to: number, position: RowDropPosition = 'before'): boolean {\n const view = this.host.pageItems;\n const before = this.#captureRowRects();\n const ok = this.#commit(view[from] as T, view[to] as T, position);\n if (ok) void this.#flipAfterUpdate(before);\n return ok;\n }\n\n // --- pointer drag -------------------------------------------------------\n\n /**\n * Begins a pointer drag from `source`. When `ghost` is supplied (the pointer\n * path always does), seeds the floating ghost from the source row's rect and\n * the grab point so it stays anchored under the cursor.\n */\n public startDrag(source: T, ghost?: RowGhostInit): void {\n if (!this.enabled) return;\n this.dragging = source;\n this.ghost = ghost\n ? {\n x: ghost.rect.left,\n y: ghost.rect.top,\n width: ghost.rect.width,\n height: ghost.rect.height,\n pointerOffsetX: ghost.clientX - ghost.rect.left,\n pointerOffsetY: ghost.clientY - ghost.rect.top,\n cells: ghost.cells,\n }\n : null;\n this.host.requestUpdate();\n }\n\n /** Moves the floating ghost to track the cursor. No-op without an active ghost. */\n public moveGhost(clientX: number, clientY: number): void {\n if (!this.ghost) return;\n this.ghost = {\n ...this.ghost,\n x: clientX - this.ghost.pointerOffsetX,\n y: clientY - this.ghost.pointerOffsetY,\n };\n this.host.requestUpdate();\n }\n\n /**\n * Called on pointer-move during a drag: live-swaps the dragged row past the\n * body row currently under `clientY` once the cursor crosses its midpoint.\n */\n public dragOver(clientY: number): void {\n if (!this.dragging || this.#swapping) return;\n const target = this.#bodyRowAt(clientY);\n if (!target || target.data === this.dragging) return;\n\n const view = this.host.pageItems;\n const sourceIdx = view.indexOf(this.dragging);\n const targetIdx = view.indexOf(target.data);\n if (sourceIdx === -1 || targetIdx === -1) return;\n\n const rect = target.element.getBoundingClientRect();\n const midpoint = rect.top + rect.height / 2;\n let position: RowDropPosition;\n if (sourceIdx < targetIdx) {\n if (clientY < midpoint) return; // dragging down — wait for the midpoint\n position = 'after';\n } else {\n if (clientY > midpoint) return; // dragging up\n position = 'before';\n }\n void this.#dragSwap(target.data, position);\n }\n\n /** Ends the pointer drag. The order is already final (live-swapped). */\n public endDrag(): void {\n if (!this.dragging) return;\n this.dragging = null;\n this.ghost = null;\n this.host.requestUpdate();\n }\n\n /**\n * Arms a pointer drag from a row press. Called by the row on `pointerdown`\n * (from the grip in handle mode, or anywhere in whole-row mode). The move\n * listener is bound to the **grid host**, so the gesture is immune to the\n * source row's DOM being recycled by a live-swap; the up / cancel listeners\n * are bound to the document, so a release outside the grid ends it too, as\n * does a move with the primary button no longer held. The ghost is\n * snapshotted once, the instant the drag engages, from the row element that\n * renders `data` then; `getGhost` is the pressed row's own snapshot, used\n * when no rendered row shows `data`, and returns `null` once that row shows\n * another record.\n */\n public armPointerDrag(data: T, getGhost: () => RowGhostInit | null, event: PointerEvent): void {\n const pinned = this.host.pinnedRows;\n if (!this.enabled || pinned.top.includes(data) || pinned.bottom.includes(data)) return;\n this.#pending = {\n data,\n getGhost,\n startX: event.clientX,\n startY: event.clientY,\n pointerId: event.pointerId,\n };\n const host = this.#hostElement;\n host.addEventListener('pointermove', this.#onHostPointerMove);\n host.ownerDocument.addEventListener('pointerup', this.#onPointerUp, true);\n host.ownerDocument.addEventListener('pointercancel', this.#onPointerUp, true);\n }\n\n #onHostPointerMove = (event: PointerEvent): void => {\n const pending = this.#pending;\n if (!pending || event.pointerId !== pending.pointerId) return;\n // The release was missed (e.g. outside the window): a hover is not a drag.\n if (!(event.buttons & 1)) {\n this.#endPointer();\n return;\n }\n if (!this.dragging) {\n const dx = event.clientX - pending.startX;\n const dy = event.clientY - pending.startY;\n if (Math.hypot(dx, dy) < DRAG_THRESHOLD_PX) return;\n // Capture on the stable host so moves keep arriving even when the cursor\n // leaves the grid, and so the source row reflowing can't drop the pointer.\n try {\n this.#hostElement.setPointerCapture(pending.pointerId);\n } catch {\n /* a synthetic pointer id may not be capturable; hit-testing still works */\n }\n this.startDrag(pending.data, this.#ghostAtEngage(pending) ?? undefined);\n }\n this.moveGhost(event.clientX, event.clientY);\n this.dragOver(event.clientY);\n };\n\n /**\n * The ghost snapshot for an engaging drag, taken from the row element that\n * renders the pressed record now. A re-bind between the press and the\n * engage (a sort, a data change) can leave another record in the pressed\n * element, so the element is found by record, not kept from the press.\n */\n #ghostAtEngage(pending: {\n data: T;\n getGhost: () => RowGhostInit | null;\n startX: number;\n startY: number;\n }): RowGhostInit | null {\n const row = this.host.rows.find((candidate) => candidate.data === pending.data);\n if (!row) return pending.getGhost();\n const cells = row.cells as unknown as Element[];\n return captureRowGhost(row as unknown as Element, cells, pending.startX, pending.startY);\n }\n\n #onPointerUp = (event: PointerEvent): void => {\n if (event.pointerId === this.#pending?.pointerId) this.#endPointer();\n };\n\n /** Tears down an armed or engaged pointer gesture. */\n #endPointer(): void {\n const pending = this.#pending;\n if (pending) {\n const host = this.#hostElement;\n host.removeEventListener('pointermove', this.#onHostPointerMove);\n host.ownerDocument.removeEventListener('pointerup', this.#onPointerUp, true);\n host.ownerDocument.removeEventListener('pointercancel', this.#onPointerUp, true);\n try {\n if (host.hasPointerCapture(pending.pointerId)) {\n host.releasePointerCapture(pending.pointerId);\n }\n } catch {\n /* capture was never taken or already released */\n }\n this.#pending = null;\n }\n this.endDrag();\n }\n\n async #dragSwap(target: T, position: RowDropPosition): Promise<void> {\n if (this.#swapping) return;\n this.#swapping = true;\n try {\n const before = this.#captureRowRects();\n if (this.#commit(this.dragging as T, target, position)) {\n await settleRowsForFlip(this.host);\n this.#playRowFlip(before);\n }\n } finally {\n this.#swapping = false;\n }\n }\n\n // --- keyboard grab ------------------------------------------------------\n\n /** Grabs the row at view index `rowIndex` for keyboard reorder. */\n public grab(rowIndex: number): boolean {\n if (!this.enabled) return false;\n const row = this.host.pageItems[rowIndex] as T | undefined;\n if (!row) return false;\n this.grabbed = row;\n this.#preGrab = {\n order: this.#order,\n data: this.applyToData ? [...this.host.data] : null,\n sort: this.host.sortExpressions,\n index: rowIndex,\n };\n this.host.requestUpdate();\n this.host.announce(this.host.localize('announce.rowGrabbed'));\n return true;\n }\n\n /**\n * Moves the grabbed row one position in `direction`. Returns the grabbed\n * row's new view index, or `-1` when it can't move (no grab / at the edge).\n */\n public moveGrabbed(direction: -1 | 1): number {\n if (!this.grabbed) return -1;\n const view = this.host.pageItems;\n const current = view.indexOf(this.grabbed);\n const target = current + direction;\n if (current === -1 || target < 0 || target >= view.length) return -1;\n const before = this.#captureRowRects();\n const ok = this.#commit(this.grabbed, view[target] as T, direction > 0 ? 'after' : 'before', {\n silent: true,\n });\n if (!ok) return -1;\n void this.#flipAfterUpdate(before);\n this.host.announce(this.host.localize('announce.rowMovedTo', { position: target + 1 }));\n return target;\n }\n\n /** Drops the grabbed row, keeping its moves. */\n public drop(): void {\n if (!this.grabbed) return;\n this.grabbed = null;\n this.#preGrab = null;\n this.host.requestUpdate();\n this.host.announce(this.host.localize('announce.rowDropped'));\n }\n\n /**\n * Cancels the grab, reverting the order, the data order (with\n * `applyToData`) and the sort to what they were when the row was grabbed.\n * Emits `rowMoved` for the way back when the row had moved, so an app\n * persisting each step sees the revert too.\n */\n public cancelGrab(): void {\n const row = this.grabbed;\n const pre = this.#preGrab;\n if (!row || !pre) return;\n const from = this.host.pageItems.indexOf(row);\n this.grabbed = this.#preGrab = null;\n this.#order = pre.order;\n if (pre.data) this.#spliceData(pre.data);\n if (pre.sort.length) this.host.sortExpressions = pre.sort;\n this.host.requestUpdate(PIPELINE);\n this.host.announce(this.host.localize('announce.reorderCancelled'));\n const to = pre.index;\n if (from !== to) {\n const position: RowDropPosition = from > to ? 'before' : 'after';\n this.host.emitEvent('rowMoved', { detail: { from, to, position, toIndex: to, data: row } });\n }\n }\n\n // --- internals ----------------------------------------------------------\n\n /**\n * The order every row is in, hidden by a filter or not: the manual order,\n * else `data` under the active sort, with rows it lacks following in data\n * order. The rows the view shows are laid into their own slots in view order,\n * so the move applies to exactly what the user sees and hidden rows stay put.\n */\n #fullOrder(): T[] {\n const data = this.host.data;\n const sort = this.host.sortExpressions;\n let base: T[];\n if (this.#order) {\n const rest = new Set(data);\n base = this.#order.filter((row) => rest.delete(row));\n base.push(...rest);\n } else if (sort.length && !this.host.dataPipelineConfiguration?.sort) {\n const state = new Map(sort.map((expr) => [expr.key, expr] as const));\n base = new SortDataOperation<T>().apply([...data], state);\n } else {\n base = [...data];\n }\n const listed = new Set(base);\n const shown = this.host.dataView.filter((row) => listed.has(row));\n const inView = new Set(shown);\n let k = 0;\n return base.map((row) => (inView.has(row) ? shown[k++] : row));\n }\n\n /**\n * The core order mutation: validates, emits `rowMoving` (cancellable),\n * updates the manual order (or splices data when `applyToData`), clears any\n * sort (a move establishes a manual order, which a sort would undo), re-runs\n * the pipeline, and emits `rowMoved`. Does not animate.\n */\n #commit(\n source: T | undefined,\n target: T | undefined,\n position: RowDropPosition,\n options: { silent?: boolean } = {}\n ): boolean {\n if (!this.enabled || !source || !target || source === target) return false;\n const view = this.host.pageItems;\n const from = view.indexOf(source);\n const to = view.indexOf(target);\n // Where the row lands in the view; a move that leaves it in place is no move.\n const toIndex = position === 'after' ? (from < to ? to : to + 1) : from < to ? to - 1 : to;\n if (from === -1 || to === -1 || toIndex === from) return false;\n\n // A row outside the order (a tree child, a module's row) cannot move.\n const next = this.#fullOrder();\n const at = next.indexOf(source);\n if (at === -1 || !next.includes(target)) return false;\n next.splice(at, 1);\n next.splice(next.indexOf(target) + (position === 'after' ? 1 : 0), 0, source);\n // Rows outside the order (group rows) can make a view move a no-op too.\n if (next.indexOf(source) === at) return false;\n\n const detail = { from, to, position, toIndex, data: source };\n if (!this.host.emitEvent('rowMoving', { detail, cancelable: true })) return false;\n\n if (this.host.sortExpressions.length) this.host.sortExpressions = [];\n\n if (this.applyToData) {\n this.#spliceData(next);\n this.#order = null; // the data array now carries the order\n } else {\n this.#order = next;\n }\n\n this.host.requestUpdate(PIPELINE);\n if (!options.silent) this.host.announce(this.host.localize('announce.rowMoved'));\n this.host.emitEvent('rowMoved', { detail });\n return true;\n }\n\n /** Reorders {@link ApexGrid.data} in place to match `order`. */\n #spliceData(order: ReadonlyArray<T>): void {\n const rank = new Map<T, number>();\n order.forEach((row, i) => {\n rank.set(row, i);\n });\n (this.host.data as T[]).sort((a, b) => {\n const ra = rank.has(a) ? (rank.get(a) as number) : Number.POSITIVE_INFINITY;\n const rb = rank.has(b) ? (rank.get(b) as number) : Number.POSITIVE_INFINITY;\n return ra - rb;\n });\n }\n\n /** The rendered body row (non-pinned) whose box contains `clientY`. */\n #bodyRowAt(clientY: number): { data: T; element: HTMLElement } | null {\n const pinned = this.host.pinnedRows;\n for (const row of this.host.rows) {\n if (pinned.top.includes(row.data) || pinned.bottom.includes(row.data)) continue;\n const element = row as unknown as HTMLElement;\n const rect = element.getBoundingClientRect();\n if (clientY >= rect.top && clientY < rect.bottom) return { data: row.data, element };\n }\n return null;\n }\n\n #captureRowRects(): KeyedFlipEntry<T>[] {\n const entries: KeyedFlipEntry<T>[] = [];\n for (const row of this.host.rows) {\n const el = row as unknown as HTMLElement;\n entries.push({ key: row.data, rect: el.getBoundingClientRect() });\n }\n return entries;\n }\n\n async #flipAfterUpdate(before: ReadonlyArray<KeyedFlipEntry<T>>): Promise<void> {\n await settleRowsForFlip(this.host);\n this.#playRowFlip(before);\n }\n\n #playRowFlip(before: ReadonlyArray<KeyedFlipEntry<T>>): void {\n const byData = new Map<T, HTMLElement>();\n for (const row of this.host.rows) {\n byData.set(row.data, row as unknown as HTMLElement);\n }\n playKeyedFlip(before, (data) => byData.get(data) ?? null, 'y');\n }\n}\n"]}
|
|
@@ -19,6 +19,12 @@ export declare const DEFAULT_SELECTION_CONFIG: Readonly<{
|
|
|
19
19
|
* any selected rows that are no longer present in the new array; consumers
|
|
20
20
|
* should call {@link clear} or re-apply selection after such a change.
|
|
21
21
|
*
|
|
22
|
+
* Only selectable data records are selected (see {@link isSelectable}): rows
|
|
23
|
+
* a feature module synthesizes into the view (group headers, a grand-total
|
|
24
|
+
* row; see {@link StateController.isDataRow}) and rows the
|
|
25
|
+
* `selection.isRowSelectable` predicate rejects are skipped by every
|
|
26
|
+
* mutation and ignored by {@link allSelected}.
|
|
27
|
+
*
|
|
22
28
|
* Mutations go through the cancellable `rowSelecting` event and emit a
|
|
23
29
|
* follow-up `rowSelected` event, mirroring the pattern used by editing.
|
|
24
30
|
*/
|
|
@@ -34,6 +40,14 @@ export declare class SelectionController<T extends object> implements ReactiveCo
|
|
|
34
40
|
anchor: T | null;
|
|
35
41
|
constructor(host: GridHost<T>);
|
|
36
42
|
hostConnected(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Drops selected rows the `isRowSelectable` predicate rejects once
|
|
45
|
+
* `selection` or `data` is reassigned. Runs after the render, so the
|
|
46
|
+
* `rowSelecting`/`rowSelected` listeners (and any grid property they
|
|
47
|
+
* write) start a normal update. Without a predicate nothing is checked,
|
|
48
|
+
* and a mode switch never trims the selection here.
|
|
49
|
+
*/
|
|
50
|
+
hostUpdated(): void;
|
|
37
51
|
/**
|
|
38
52
|
* Whether selection is enabled at the grid level.
|
|
39
53
|
*/
|
|
@@ -50,13 +64,27 @@ export declare class SelectionController<T extends object> implements ReactiveCo
|
|
|
50
64
|
* Whether the given row is currently selected.
|
|
51
65
|
*/
|
|
52
66
|
isSelected(row: T): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Whether `row` can be selected: a data record (see
|
|
69
|
+
* {@link StateController.isDataRow}) that `selection.isRowSelectable`, when
|
|
70
|
+
* set, accepts.
|
|
71
|
+
*/
|
|
72
|
+
isSelectable(row: T): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The selectable rows of `rows` (see {@link isSelectable}), in order.
|
|
75
|
+
* Returns `rows` itself when nothing filters them (the community grid
|
|
76
|
+
* without a predicate).
|
|
77
|
+
*/
|
|
78
|
+
selectable(rows: ReadonlyArray<T>): ReadonlyArray<T>;
|
|
53
79
|
/**
|
|
54
80
|
* Returns the currently selected rows in insertion order.
|
|
55
81
|
*/
|
|
56
82
|
selectedRows(): T[];
|
|
57
83
|
/**
|
|
58
|
-
* Whether every
|
|
59
|
-
*
|
|
84
|
+
* Whether every selectable record the current view covers is selected,
|
|
85
|
+
* including the leaves of collapsed groups (see
|
|
86
|
+
* {@link StateController.viewRecords}). `false` when the view covers none.
|
|
87
|
+
* Used by the header checkbox to render its "all" state.
|
|
60
88
|
*/
|
|
61
89
|
allSelected(): boolean;
|
|
62
90
|
/**
|
|
@@ -92,8 +120,9 @@ export declare class SelectionController<T extends object> implements ReactiveCo
|
|
|
92
120
|
*/
|
|
93
121
|
rangeToggle(row: T): Promise<boolean>;
|
|
94
122
|
/**
|
|
95
|
-
* Selects every
|
|
96
|
-
*
|
|
123
|
+
* Selects every selectable record the current view
|
|
124
|
+
* ({@link ApexGrid.dataView}) covers, including the leaves of collapsed
|
|
125
|
+
* groups. No-op in `'single'` mode.
|
|
97
126
|
*/
|
|
98
127
|
selectAll(): Promise<boolean>;
|
|
99
128
|
/**
|
package/controllers/selection.js
CHANGED
|
@@ -4,13 +4,26 @@ export const DEFAULT_SELECTION_CONFIG = Object.freeze({
|
|
|
4
4
|
showCheckboxColumn: false,
|
|
5
5
|
});
|
|
6
6
|
export class SelectionController {
|
|
7
|
+
#seen;
|
|
7
8
|
constructor(host) {
|
|
8
9
|
this.host = host;
|
|
9
10
|
this.selected = new Set();
|
|
10
11
|
this.anchor = null;
|
|
12
|
+
this.#seen = [undefined, undefined];
|
|
11
13
|
this.host.addController(this);
|
|
12
14
|
}
|
|
13
15
|
hostConnected() { }
|
|
16
|
+
hostUpdated() {
|
|
17
|
+
const { selection, data } = this.host;
|
|
18
|
+
if (selection === this.#seen[0] && data === this.#seen[1])
|
|
19
|
+
return;
|
|
20
|
+
this.#seen = [selection, data];
|
|
21
|
+
if (!this.enabled || !selection?.isRowSelectable)
|
|
22
|
+
return;
|
|
23
|
+
const keep = this.selectable(this.selectedRows());
|
|
24
|
+
if (keep.length < this.selected.size)
|
|
25
|
+
void this.#commit(new Set(keep));
|
|
26
|
+
}
|
|
14
27
|
get enabled() {
|
|
15
28
|
return Boolean(this.host.selection?.enabled);
|
|
16
29
|
}
|
|
@@ -24,14 +37,28 @@ export class SelectionController {
|
|
|
24
37
|
isSelected(row) {
|
|
25
38
|
return this.selected.has(row);
|
|
26
39
|
}
|
|
40
|
+
isSelectable(row) {
|
|
41
|
+
return ((this.#state?.isDataRow(row) ?? true) && (this.host.selection?.isRowSelectable?.(row) ?? true));
|
|
42
|
+
}
|
|
43
|
+
selectable(rows) {
|
|
44
|
+
return this.#accepted(this.#state?.dataRows(rows) ?? rows);
|
|
45
|
+
}
|
|
46
|
+
#accepted(rows) {
|
|
47
|
+
const accept = this.host.selection?.isRowSelectable;
|
|
48
|
+
return accept ? rows.filter((row) => accept(row)) : rows;
|
|
49
|
+
}
|
|
27
50
|
selectedRows() {
|
|
28
51
|
return Array.from(this.selected);
|
|
29
52
|
}
|
|
30
53
|
allSelected() {
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
54
|
+
const records = this.#records();
|
|
55
|
+
if (records.length === 0)
|
|
33
56
|
return false;
|
|
34
|
-
|
|
57
|
+
for (const row of records) {
|
|
58
|
+
if (!this.selected.has(row))
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
35
62
|
}
|
|
36
63
|
someSelected() {
|
|
37
64
|
if (this.selected.size === 0)
|
|
@@ -41,7 +68,7 @@ export class SelectionController {
|
|
|
41
68
|
return true;
|
|
42
69
|
}
|
|
43
70
|
async toggleRow(row) {
|
|
44
|
-
if (!this
|
|
71
|
+
if (!this.#togglable(row))
|
|
45
72
|
return false;
|
|
46
73
|
const next = new Set(this.selected);
|
|
47
74
|
if (next.has(row)) {
|
|
@@ -56,7 +83,7 @@ export class SelectionController {
|
|
|
56
83
|
return this.#commit(next);
|
|
57
84
|
}
|
|
58
85
|
async selectRow(row) {
|
|
59
|
-
if (!this.enabled)
|
|
86
|
+
if (!this.enabled || !this.isSelectable(row))
|
|
60
87
|
return false;
|
|
61
88
|
const next = new Set(this.mode === 'single' ? [] : this.selected);
|
|
62
89
|
next.add(row);
|
|
@@ -73,7 +100,7 @@ export class SelectionController {
|
|
|
73
100
|
return this.#commit(next);
|
|
74
101
|
}
|
|
75
102
|
async additiveToggle(row) {
|
|
76
|
-
if (!this
|
|
103
|
+
if (!this.#togglable(row))
|
|
77
104
|
return false;
|
|
78
105
|
if (this.mode === 'single')
|
|
79
106
|
return this.toggleRow(row);
|
|
@@ -88,7 +115,7 @@ export class SelectionController {
|
|
|
88
115
|
return this.#commit(next);
|
|
89
116
|
}
|
|
90
117
|
async rangeToggle(row) {
|
|
91
|
-
if (!this.enabled)
|
|
118
|
+
if (!this.enabled || !this.isSelectable(row))
|
|
92
119
|
return false;
|
|
93
120
|
if (this.mode === 'single' || !this.anchor) {
|
|
94
121
|
return this.selectRow(row);
|
|
@@ -102,15 +129,15 @@ export class SelectionController {
|
|
|
102
129
|
const [lo, hi] = startIdx < endIdx ? [startIdx, endIdx] : [endIdx, startIdx];
|
|
103
130
|
const next = new Set(this.selected);
|
|
104
131
|
for (let i = lo; i <= hi; i++) {
|
|
105
|
-
|
|
132
|
+
if (this.isSelectable(pageItems[i]))
|
|
133
|
+
next.add(pageItems[i]);
|
|
106
134
|
}
|
|
107
135
|
return this.#commit(next);
|
|
108
136
|
}
|
|
109
137
|
async selectAll() {
|
|
110
138
|
if (!this.enabled || this.mode === 'single')
|
|
111
139
|
return false;
|
|
112
|
-
|
|
113
|
-
return this.#commit(next);
|
|
140
|
+
return this.#commit(new Set(this.#records()));
|
|
114
141
|
}
|
|
115
142
|
async clear() {
|
|
116
143
|
if (this.selected.size === 0)
|
|
@@ -120,9 +147,20 @@ export class SelectionController {
|
|
|
120
147
|
async replaceSelection(rows) {
|
|
121
148
|
if (!this.enabled)
|
|
122
149
|
return false;
|
|
123
|
-
const
|
|
150
|
+
const records = this.selectable(rows);
|
|
151
|
+
const next = new Set(this.mode === 'single' ? records.slice(0, 1) : records);
|
|
124
152
|
return this.#commit(next);
|
|
125
153
|
}
|
|
154
|
+
get #state() {
|
|
155
|
+
return this.host.stateController;
|
|
156
|
+
}
|
|
157
|
+
#togglable(row) {
|
|
158
|
+
return this.enabled && (this.selected.has(row) || this.isSelectable(row));
|
|
159
|
+
}
|
|
160
|
+
#records() {
|
|
161
|
+
const view = this.host.dataView;
|
|
162
|
+
return this.#accepted(this.#state?.viewRecords(view) ?? view);
|
|
163
|
+
}
|
|
126
164
|
async #commit(next) {
|
|
127
165
|
const added = [];
|
|
128
166
|
const removed = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/controllers/selection.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC;IACpD,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,UAA2B;IACjC,kBAAkB,EAAE,KAAK;CAC1B,CAAC,CAAC;AAgBH,MAAM,OAAO,mBAAmB;IAU9B,YAAsB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QARhC,aAAQ,GAAW,IAAI,GAAG,EAAE,CAAC;QAM7B,WAAM,GAAa,IAAI,CAAC;QAG7B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAEM,aAAa,KAAI,CAAC;IAKzB,IAAW,OAAO;QAChB,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAKD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,IAAI,wBAAwB,CAAC,IAAI,CAAC;IACpE,CAAC;IAKD,IAAW,kBAAkB;QAC3B,OAAO,CACL,IAAI,CAAC,OAAO;YACZ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,IAAI,wBAAwB,CAAC,kBAAkB,CAAC,CACzF,CAAC;IACJ,CAAC;IAKM,UAAU,CAAC,GAAM;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAKM,YAAY;QACjB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnC,CA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CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;SAChE,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import type { ReactiveController } from 'lit';\nimport type { GridHost, SelectionMode } from '../internal/types.js';\n\n/**\n * The default selection configuration used when the grid has none set.\n */\nexport const DEFAULT_SELECTION_CONFIG = Object.freeze({\n enabled: false,\n mode: 'multiple' as SelectionMode,\n showCheckboxColumn: false,\n});\n\n/**\n * Reactive controller backing row selection.\n *\n * @remarks\n * Selection state is reference-based — the controller holds a `Set` of row\n * data references so the selection survives sort / filter / pagination as\n * long as those operations preserve identities (the default in-place\n * pipeline does). Replacing {@link ApexGrid.data} wholesale will invalidate\n * any selected rows that are no longer present in the new array; consumers\n * should call {@link clear} or re-apply selection after such a change.\n *\n * Mutations go through the cancellable `rowSelecting` event and emit a\n * follow-up `rowSelected` event, mirroring the pattern used by editing.\n */\nexport class SelectionController<T extends object> implements ReactiveController {\n /** Set of currently selected row data references. */\n public selected: Set<T> = new Set();\n\n /**\n * Anchor row for Shift+click range selection. Set whenever a single row\n * is toggled / picked so a follow-up Shift+click knows where to start.\n */\n public anchor: T | null = null;\n\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n public hostConnected() {}\n\n /**\n * Whether selection is enabled at the grid level.\n */\n public get enabled(): boolean {\n return Boolean(this.host.selection?.enabled);\n }\n\n /**\n * The resolved selection mode (`'multiple'` if unset).\n */\n public get mode(): SelectionMode {\n return this.host.selection?.mode ?? DEFAULT_SELECTION_CONFIG.mode;\n }\n\n /**\n * Whether to render the built-in checkbox column.\n */\n public get showCheckboxColumn(): boolean {\n return (\n this.enabled &&\n (this.host.selection?.showCheckboxColumn ?? DEFAULT_SELECTION_CONFIG.showCheckboxColumn)\n );\n }\n\n /**\n * Whether the given row is currently selected.\n */\n public isSelected(row: T): boolean {\n return this.selected.has(row);\n }\n\n /**\n * Returns the currently selected rows in insertion order.\n */\n public selectedRows(): T[] {\n return Array.from(this.selected);\n }\n\n /**\n * Whether every row in the current view ({@link ApexGrid.dataView}) is\n * selected. Used by the header checkbox to render its \"all\" state.\n */\n public allSelected(): boolean {\n const view = this.host.dataView;\n if (view.length === 0) return false;\n return view.every((row) => this.selected.has(row as T));\n }\n\n /**\n * Whether some — but not all — rows in the current view are selected.\n * Used to render the header checkbox in its indeterminate state.\n */\n public someSelected(): boolean {\n if (this.selected.size === 0) return false;\n if (this.allSelected()) return false;\n return true;\n }\n\n /**\n * Toggles selection of `row`. In `'single'` mode this either selects the\n * row (replacing any previous selection) or deselects it if it was the\n * only selected row.\n */\n public async toggleRow(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n const next = new Set(this.selected);\n if (next.has(row)) {\n next.delete(row);\n } else {\n if (this.mode === 'single') next.clear();\n next.add(row);\n }\n this.anchor = next.has(row) ? row : null;\n return this.#commit(next);\n }\n\n /**\n * Adds `row` to the selection. In `'single'` mode the existing selection\n * is cleared first.\n */\n public async selectRow(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n const next = new Set(this.mode === 'single' ? [] : this.selected);\n next.add(row);\n this.anchor = row;\n return this.#commit(next);\n }\n\n /**\n * Removes `row` from the selection.\n */\n public async deselectRow(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n if (!this.selected.has(row)) return true;\n const next = new Set(this.selected);\n next.delete(row);\n return this.#commit(next);\n }\n\n /**\n * Adds `row` to the selection without affecting other selected rows\n * (`'multiple'` mode only). In `'single'` mode this behaves like\n * {@link selectRow}.\n */\n public async additiveToggle(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n if (this.mode === 'single') return this.toggleRow(row);\n const next = new Set(this.selected);\n if (next.has(row)) {\n next.delete(row);\n } else {\n next.add(row);\n }\n this.anchor = next.has(row) ? row : this.anchor;\n return this.#commit(next);\n }\n\n /**\n * Selects every row between {@link anchor} and `row` (inclusive) in the\n * current page view. No-op in `'single'` mode or when no anchor is set —\n * in those cases the call falls back to a plain {@link selectRow}.\n */\n public async rangeToggle(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n if (this.mode === 'single' || !this.anchor) {\n return this.selectRow(row);\n }\n const pageItems = this.host.pageItems as ReadonlyArray<T>;\n const startIdx = pageItems.indexOf(this.anchor);\n const endIdx = pageItems.indexOf(row);\n if (startIdx === -1 || endIdx === -1) {\n return this.selectRow(row);\n }\n const [lo, hi] = startIdx < endIdx ? [startIdx, endIdx] : [endIdx, startIdx];\n const next = new Set(this.selected);\n for (let i = lo; i <= hi; i++) {\n next.add(pageItems[i] as T);\n }\n return this.#commit(next);\n }\n\n /**\n * Selects every row currently in view ({@link ApexGrid.dataView}). No-op\n * in `'single'` mode.\n */\n public async selectAll(): Promise<boolean> {\n if (!this.enabled || this.mode === 'single') return false;\n const next = new Set(this.host.dataView as ReadonlyArray<T>);\n return this.#commit(next);\n }\n\n /**\n * Clears the selection.\n */\n public async clear(): Promise<boolean> {\n if (this.selected.size === 0) return true;\n return this.#commit(new Set());\n }\n\n /**\n * Replaces the current selection with `rows`. Used by the public\n * {@link ApexGrid.selectedRows} setter so callers can drive selection\n * programmatically. Single-mode keeps at most one row.\n */\n public async replaceSelection(rows: ReadonlyArray<T>): Promise<boolean> {\n if (!this.enabled) return false;\n const next = new Set(this.mode === 'single' ? rows.slice(0, 1) : rows);\n return this.#commit(next);\n }\n\n async #commit(next: Set<T>): Promise<boolean> {\n const added: T[] = [];\n const removed: T[] = [];\n for (const row of next) {\n if (!this.selected.has(row)) added.push(row);\n }\n for (const row of this.selected) {\n if (!next.has(row)) removed.push(row);\n }\n if (added.length === 0 && removed.length === 0) return true;\n\n const proceed = this.host.emitEvent('rowSelecting', {\n detail: {\n added,\n removed,\n current: Array.from(this.selected),\n next: Array.from(next),\n },\n cancelable: true,\n });\n if (!proceed) return false;\n\n this.selected = next;\n this.host.requestUpdate();\n\n const total = this.selected.size;\n if (total === 0) {\n this.host.announce(this.host.localize('announce.selectionCleared'));\n } else if (added.length === 1 && removed.length === 0 && total === 1) {\n this.host.announce(this.host.localize('announce.rowSelected'));\n } else {\n this.host.announce(this.host.localize('announce.rowsSelected', { count: total }));\n }\n\n this.host.emitEvent('rowSelected', {\n detail: { added, removed, selected: Array.from(this.selected) },\n });\n return true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/controllers/selection.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC;IACpD,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,UAA2B;IACjC,kBAAkB,EAAE,KAAK;CAC1B,CAAC,CAAC;AAsBH,MAAM,OAAO,mBAAmB;IAW9B,KAAK,CAA8C;IAEnD,YAAsB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAXhC,aAAQ,GAAW,IAAI,GAAG,EAAE,CAAC;QAM7B,WAAM,GAAa,IAAI,CAAC;QAG/B,UAAK,GAAuB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAGjD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAEM,aAAa,KAAI,CAAC;IASlB,WAAW;QAChB,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;QACtC,IAAI,SAAS,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAAE,OAAO;QAClE,IAAI,CAAC,KAAK,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,EAAE,eAAe;YAAE,OAAO;QACzD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QAClD,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI;YAA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GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAE1B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QACjC,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC,CAAC,CAAC;QACtE,CAAC;aAAM,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACrE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACpF,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;YACjC,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;SAChE,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import type { ReactiveController } from 'lit';\nimport type { GridHost, SelectionMode } from '../internal/types.js';\nimport type { StateController } from './state.js';\n\n/**\n * The default selection configuration used when the grid has none set.\n */\nexport const DEFAULT_SELECTION_CONFIG = Object.freeze({\n enabled: false,\n mode: 'multiple' as SelectionMode,\n showCheckboxColumn: false,\n});\n\n/**\n * Reactive controller backing row selection.\n *\n * @remarks\n * Selection state is reference-based — the controller holds a `Set` of row\n * data references so the selection survives sort / filter / pagination as\n * long as those operations preserve identities (the default in-place\n * pipeline does). Replacing {@link ApexGrid.data} wholesale will invalidate\n * any selected rows that are no longer present in the new array; consumers\n * should call {@link clear} or re-apply selection after such a change.\n *\n * Only selectable data records are selected (see {@link isSelectable}): rows\n * a feature module synthesizes into the view (group headers, a grand-total\n * row; see {@link StateController.isDataRow}) and rows the\n * `selection.isRowSelectable` predicate rejects are skipped by every\n * mutation and ignored by {@link allSelected}.\n *\n * Mutations go through the cancellable `rowSelecting` event and emit a\n * follow-up `rowSelected` event, mirroring the pattern used by editing.\n */\nexport class SelectionController<T extends object> implements ReactiveController {\n /** Set of currently selected row data references. */\n public selected: Set<T> = new Set();\n\n /**\n * Anchor row for Shift+click range selection. Set whenever a single row\n * is toggled / picked so a follow-up Shift+click knows where to start.\n */\n public anchor: T | null = null;\n\n /** The selection config and data the selection was last checked against. */\n #seen: [unknown, unknown] = [undefined, undefined];\n\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n public hostConnected() {}\n\n /**\n * Drops selected rows the `isRowSelectable` predicate rejects once\n * `selection` or `data` is reassigned. Runs after the render, so the\n * `rowSelecting`/`rowSelected` listeners (and any grid property they\n * write) start a normal update. Without a predicate nothing is checked,\n * and a mode switch never trims the selection here.\n */\n public hostUpdated() {\n const { selection, data } = this.host;\n if (selection === this.#seen[0] && data === this.#seen[1]) return;\n this.#seen = [selection, data];\n if (!this.enabled || !selection?.isRowSelectable) return;\n const keep = this.selectable(this.selectedRows());\n if (keep.length < this.selected.size) void this.#commit(new Set(keep));\n }\n\n /**\n * Whether selection is enabled at the grid level.\n */\n public get enabled(): boolean {\n return Boolean(this.host.selection?.enabled);\n }\n\n /**\n * The resolved selection mode (`'multiple'` if unset).\n */\n public get mode(): SelectionMode {\n return this.host.selection?.mode ?? DEFAULT_SELECTION_CONFIG.mode;\n }\n\n /**\n * Whether to render the built-in checkbox column.\n */\n public get showCheckboxColumn(): boolean {\n return (\n this.enabled &&\n (this.host.selection?.showCheckboxColumn ?? DEFAULT_SELECTION_CONFIG.showCheckboxColumn)\n );\n }\n\n /**\n * Whether the given row is currently selected.\n */\n public isSelected(row: T): boolean {\n return this.selected.has(row);\n }\n\n /**\n * Whether `row` can be selected: a data record (see\n * {@link StateController.isDataRow}) that `selection.isRowSelectable`, when\n * set, accepts.\n */\n public isSelectable(row: T): boolean {\n return (\n (this.#state?.isDataRow(row) ?? true) && (this.host.selection?.isRowSelectable?.(row) ?? true)\n );\n }\n\n /**\n * The selectable rows of `rows` (see {@link isSelectable}), in order.\n * Returns `rows` itself when nothing filters them (the community grid\n * without a predicate).\n */\n public selectable(rows: ReadonlyArray<T>): ReadonlyArray<T> {\n return this.#accepted(this.#state?.dataRows(rows) ?? rows);\n }\n\n /** The rows `selection.isRowSelectable` accepts; `rows` itself when unset. */\n #accepted(rows: ReadonlyArray<T>): ReadonlyArray<T> {\n const accept = this.host.selection?.isRowSelectable;\n return accept ? rows.filter((row) => accept(row)) : rows;\n }\n\n /**\n * Returns the currently selected rows in insertion order.\n */\n public selectedRows(): T[] {\n return Array.from(this.selected);\n }\n\n /**\n * Whether every selectable record the current view covers is selected,\n * including the leaves of collapsed groups (see\n * {@link StateController.viewRecords}). `false` when the view covers none.\n * Used by the header checkbox to render its \"all\" state.\n */\n public allSelected(): boolean {\n const records = this.#records();\n if (records.length === 0) return false;\n for (const row of records) {\n if (!this.selected.has(row)) return false;\n }\n return true;\n }\n\n /**\n * Whether some — but not all — rows in the current view are selected.\n * Used to render the header checkbox in its indeterminate state.\n */\n public someSelected(): boolean {\n if (this.selected.size === 0) return false;\n if (this.allSelected()) return false;\n return true;\n }\n\n /**\n * Toggles selection of `row`. In `'single'` mode this either selects the\n * row (replacing any previous selection) or deselects it if it was the\n * only selected row.\n */\n public async toggleRow(row: T): Promise<boolean> {\n if (!this.#togglable(row)) return false;\n const next = new Set(this.selected);\n if (next.has(row)) {\n next.delete(row);\n } else {\n if (this.mode === 'single') next.clear();\n next.add(row);\n }\n this.anchor = next.has(row) ? row : null;\n return this.#commit(next);\n }\n\n /**\n * Adds `row` to the selection. In `'single'` mode the existing selection\n * is cleared first.\n */\n public async selectRow(row: T): Promise<boolean> {\n if (!this.enabled || !this.isSelectable(row)) return false;\n const next = new Set(this.mode === 'single' ? [] : this.selected);\n next.add(row);\n this.anchor = row;\n return this.#commit(next);\n }\n\n /**\n * Removes `row` from the selection.\n */\n public async deselectRow(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n if (!this.selected.has(row)) return true;\n const next = new Set(this.selected);\n next.delete(row);\n return this.#commit(next);\n }\n\n /**\n * Adds `row` to the selection without affecting other selected rows\n * (`'multiple'` mode only). In `'single'` mode this behaves like\n * {@link selectRow}.\n */\n public async additiveToggle(row: T): Promise<boolean> {\n if (!this.#togglable(row)) return false;\n if (this.mode === 'single') return this.toggleRow(row);\n const next = new Set(this.selected);\n if (next.has(row)) {\n next.delete(row);\n } else {\n next.add(row);\n }\n this.anchor = next.has(row) ? row : this.anchor;\n return this.#commit(next);\n }\n\n /**\n * Selects every row between {@link anchor} and `row` (inclusive) in the\n * current page view. No-op in `'single'` mode or when no anchor is set —\n * in those cases the call falls back to a plain {@link selectRow}.\n */\n public async rangeToggle(row: T): Promise<boolean> {\n if (!this.enabled || !this.isSelectable(row)) return false;\n if (this.mode === 'single' || !this.anchor) {\n return this.selectRow(row);\n }\n const pageItems = this.host.pageItems as ReadonlyArray<T>;\n const startIdx = pageItems.indexOf(this.anchor);\n const endIdx = pageItems.indexOf(row);\n if (startIdx === -1 || endIdx === -1) {\n return this.selectRow(row);\n }\n const [lo, hi] = startIdx < endIdx ? [startIdx, endIdx] : [endIdx, startIdx];\n const next = new Set(this.selected);\n for (let i = lo; i <= hi; i++) {\n if (this.isSelectable(pageItems[i])) next.add(pageItems[i]);\n }\n return this.#commit(next);\n }\n\n /**\n * Selects every selectable record the current view\n * ({@link ApexGrid.dataView}) covers, including the leaves of collapsed\n * groups. No-op in `'single'` mode.\n */\n public async selectAll(): Promise<boolean> {\n if (!this.enabled || this.mode === 'single') return false;\n return this.#commit(new Set(this.#records()));\n }\n\n /**\n * Clears the selection.\n */\n public async clear(): Promise<boolean> {\n if (this.selected.size === 0) return true;\n return this.#commit(new Set());\n }\n\n /**\n * Replaces the current selection with `rows`. Used by the public\n * {@link ApexGrid.selectedRows} setter so callers can drive selection\n * programmatically. Single-mode keeps at most one row.\n */\n public async replaceSelection(rows: ReadonlyArray<T>): Promise<boolean> {\n if (!this.enabled) return false;\n const records = this.selectable(rows);\n const next = new Set(this.mode === 'single' ? records.slice(0, 1) : records);\n return this.#commit(next);\n }\n\n /** The owning state controller; absent only while the grid is constructing. */\n get #state(): StateController<T> | undefined {\n return (this.host as unknown as { stateController?: StateController<T> }).stateController;\n }\n\n /**\n * Whether a toggle may act on `row`: a selected row can always be\n * deselected, even one the predicate has since come to reject (a row\n * pinned or edited in place), so it never gets stuck selected.\n */\n #togglable(row: T): boolean {\n return this.enabled && (this.selected.has(row) || this.isSelectable(row));\n }\n\n /** The selectable records the current view covers, collapsed group leaves included. */\n #records(): ReadonlyArray<T> {\n const view = this.host.dataView as ReadonlyArray<T>;\n return this.#accepted(this.#state?.viewRecords(view) ?? view);\n }\n\n async #commit(next: Set<T>): Promise<boolean> {\n const added: T[] = [];\n const removed: T[] = [];\n for (const row of next) {\n if (!this.selected.has(row)) added.push(row);\n }\n for (const row of this.selected) {\n if (!next.has(row)) removed.push(row);\n }\n if (added.length === 0 && removed.length === 0) return true;\n\n const proceed = this.host.emitEvent('rowSelecting', {\n detail: {\n added,\n removed,\n current: Array.from(this.selected),\n next: Array.from(next),\n },\n cancelable: true,\n });\n if (!proceed) return false;\n\n this.selected = next;\n this.host.requestUpdate();\n\n const total = this.selected.size;\n if (total === 0) {\n this.host.announce(this.host.localize('announce.selectionCleared'));\n } else if (added.length === 1 && removed.length === 0 && total === 1) {\n this.host.announce(this.host.localize('announce.rowSelected'));\n } else {\n this.host.announce(this.host.localize('announce.rowsSelected', { count: total }));\n }\n\n this.host.emitEvent('rowSelected', {\n detail: { added, removed, selected: Array.from(this.selected) },\n });\n return true;\n }\n}\n"]}
|
package/controllers/sort.d.ts
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
import type { ReactiveController } from 'lit';
|
|
2
2
|
import type { ColumnConfiguration, GridHost, Keys } from '../internal/types.js';
|
|
3
|
-
import type { SortExpression, SortState } from '../operations/sort/types.js';
|
|
3
|
+
import type { SortExpression, SortingDirection, SortState } from '../operations/sort/types.js';
|
|
4
4
|
export declare class SortController<T extends object> implements ReactiveController {
|
|
5
5
|
#private;
|
|
6
6
|
protected host: GridHost<T>;
|
|
7
7
|
constructor(host: GridHost<T>);
|
|
8
8
|
state: SortState<T>;
|
|
9
9
|
sortFromHeaderClick(column: ColumnConfiguration<T>, additive?: boolean): Promise<void>;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The one path for a sort the user starts from the UI (header click, column
|
|
12
|
+
* menu): fires the cancelable `sorting` event, replaces the sort unless the
|
|
13
|
+
* gesture is additive in multi-sort mode, announces, then fires `sorted`.
|
|
14
|
+
* Without a `direction` the column steps to its next direction.
|
|
15
|
+
*/
|
|
16
|
+
sortFromUI(column: ColumnConfiguration<T>, { direction, additive }?: {
|
|
17
|
+
direction?: SortingDirection;
|
|
18
|
+
additive?: boolean;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* The expression a UI sort would apply. Always a fresh object: the stored
|
|
22
|
+
* entry is only replaced once the `sorting` event is not cancelled.
|
|
23
|
+
*/
|
|
24
|
+
prepareExpression({ key, sort: options }: ColumnConfiguration<T>, direction?: SortingDirection): SortExpression<T>;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the UI offers sorting on `column`: it declares `sort` and no
|
|
27
|
+
* manual row order is active (sorting and a manual order are mutually
|
|
28
|
+
* exclusive). The one rule for every sort affordance, built in or a module's.
|
|
29
|
+
*/
|
|
30
|
+
isSortable(column: ColumnConfiguration<T>): boolean;
|
|
11
31
|
reset(key?: Keys<T>): void;
|
|
12
32
|
protected _sort(expressions: SortExpression<T> | SortExpression<T>[]): void;
|
|
13
33
|
sort(expressions: SortExpression<T> | SortExpression<T>[]): void;
|
package/controllers/sort.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PIPELINE } from '../internal/constants.js';
|
|
2
|
-
import {
|
|
2
|
+
import { playKeyedFlip, settleRowsForFlip } from '../internal/flip.js';
|
|
3
3
|
import { asArray } from '../internal/utils.js';
|
|
4
4
|
export class SortController {
|
|
5
5
|
constructor(host) {
|
|
@@ -14,23 +14,22 @@ export class SortController {
|
|
|
14
14
|
return this.host.sortConfiguration.triState;
|
|
15
15
|
}
|
|
16
16
|
#resolveSortOptions(options) {
|
|
17
|
-
const expr = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const expr = {};
|
|
18
|
+
if (options && typeof options === 'object') {
|
|
19
|
+
if (options.caseSensitive !== undefined)
|
|
20
|
+
expr.caseSensitive = options.caseSensitive;
|
|
21
|
+
if (options.comparer !== undefined)
|
|
22
|
+
expr.comparer = options.comparer;
|
|
23
23
|
}
|
|
24
|
-
return
|
|
25
|
-
caseSensitive: options.caseSensitive,
|
|
26
|
-
comparer: options.comparer,
|
|
27
|
-
});
|
|
24
|
+
return expr;
|
|
28
25
|
}
|
|
29
26
|
#createDefaultExpression(key) {
|
|
30
27
|
const options = this.host.getColumn(key)?.sort;
|
|
31
28
|
return {
|
|
32
29
|
key,
|
|
33
30
|
direction: 'ascending',
|
|
31
|
+
caseSensitive: false,
|
|
32
|
+
comparer: undefined,
|
|
34
33
|
...this.#resolveSortOptions(options),
|
|
35
34
|
};
|
|
36
35
|
}
|
|
@@ -56,8 +55,11 @@ export class SortController {
|
|
|
56
55
|
? this.reset(expression.key)
|
|
57
56
|
: this.state.set(expression.key, { ...expression });
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
sortFromHeaderClick(column, additive = false) {
|
|
59
|
+
return this.sortFromUI(column, { additive });
|
|
60
|
+
}
|
|
61
|
+
async sortFromUI(column, { direction, additive = false } = {}) {
|
|
62
|
+
const expression = this.prepareExpression(column, direction);
|
|
61
63
|
if (!this.#emitSortingEvent(expression)) {
|
|
62
64
|
return;
|
|
63
65
|
}
|
|
@@ -66,8 +68,7 @@ export class SortController {
|
|
|
66
68
|
}
|
|
67
69
|
const beforeRects = this.#captureRowRects();
|
|
68
70
|
this._sort(expression);
|
|
69
|
-
await this.host
|
|
70
|
-
await awaitChildUpdates(this.host.rows);
|
|
71
|
+
await settleRowsForFlip(this.host);
|
|
71
72
|
this.#playRowFlip(beforeRects);
|
|
72
73
|
this.#announce(expression, column);
|
|
73
74
|
this.#emitSortedEvent(expression);
|
|
@@ -97,15 +98,16 @@ export class SortController {
|
|
|
97
98
|
}
|
|
98
99
|
playKeyedFlip(before, (data) => byData.get(data) ?? null, 'y');
|
|
99
100
|
}
|
|
100
|
-
prepareExpression({ key, sort: options }) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
prepareExpression({ key, sort: options }, direction) {
|
|
102
|
+
const expr = this.state.get(key);
|
|
103
|
+
return {
|
|
104
|
+
...(expr ?? this.#createDefaultExpression(key)),
|
|
105
|
+
direction: direction ?? this.#orderBy(expr?.direction),
|
|
106
|
+
...this.#resolveSortOptions(options),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
isSortable(column) {
|
|
110
|
+
return Boolean(column.sort) && !this.#rowReorder?.hasManualOrder;
|
|
109
111
|
}
|
|
110
112
|
reset(key) {
|
|
111
113
|
key ? this.state.delete(key) : this.state.clear();
|
|
@@ -125,7 +127,10 @@ export class SortController {
|
|
|
125
127
|
this.host.requestUpdate(PIPELINE);
|
|
126
128
|
}
|
|
127
129
|
sort(expressions) {
|
|
128
|
-
this._sort(asArray(expressions).map((expr) =>
|
|
130
|
+
this._sort(asArray(expressions).map((expr) => ({
|
|
131
|
+
...(this.state.get(expr.key) ?? this.#createDefaultExpression(expr.key)),
|
|
132
|
+
...expr,
|
|
133
|
+
})));
|
|
129
134
|
}
|
|
130
135
|
hostConnected() { }
|
|
131
136
|
}
|