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
package/controllers/tree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/controllers/tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAKzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAGtC,MAAM,WAAW,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAkDnD,MAAM,OAAO,cAAc;IAIzB,KAAK,CAAiC;IACtC,cAAc,CAAkC;IAEhD,cAAc,CAAwB;IAEtC,gBAAgB,CAAS;IAEzB,SAAS,CAA4B;IAErC,YAAsB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAZhC,aAAQ,GAAW,IAAI,GAAG,EAAE,CAAC;QAC7B,iBAAY,GAAgB,IAAI,GAAG,EAAE,CAAC;QAE7C,UAAK,GAAG,IAAI,OAAO,EAAkB,CAAC;QACtC,mBAAc,GAAG,IAAI,GAAG,EAAuB,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AAC,QAAQ;YAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE3E,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE;YACtD,MAAM,EAAE;gBACN,KAAK;gBACL,OAAO;gBACP,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAClC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;aAC3B;YACD,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAE3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;QAE7B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAElC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE;YACrC,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 { PIPELINE } from '../internal/constants.js';\nimport type { GridHost, Keys } from '../internal/types.js';\nimport { getDisplayColumns } from '../internal/utils.js';\n\n/**\n * Default pixel indentation per depth level for the tree group column.\n */\nexport const DEFAULT_TREE_INDENT = 20;\n\n/** Sentinel value used to mark synthesized parents (those that exist only as a path segment, with no backing row). */\nconst SYNTHESIZED = Symbol('synthesized-tree-row');\n\n/**\n * Internal tree node. Built from the flat data + `getDataPath` callback;\n * lives only for the duration of one pipeline pass.\n */\ninterface TreeNode<T extends object> {\n /** The backing row when one exists at this path, else `null` (synthesized parent). */\n data: T | null;\n /** Path segments from root to this node. */\n path: readonly string[];\n /** `path.join('\u0000')` — used as stable string identity for synthesized nodes. */\n key: string;\n depth: number;\n parent: TreeNode<T> | null;\n children: TreeNode<T>[];\n}\n\n/**\n * Tree metadata exposed to renderers. One entry per row that ends up in the\n * flat output.\n */\nexport interface TreeRowMeta {\n depth: number;\n hasChildren: boolean;\n /** Stable key for the row (path-joined string). Useful for keyed reconciliation. */\n key: string;\n /** Last path segment — used as the group-column label for synthesized parents. */\n label: string;\n}\n\n/**\n * Reactive controller backing tree (nested-row) data.\n *\n * @remarks\n * Tree mode keeps the data array flat. Each row's hierarchy is derived from a\n * user-supplied `getDataPath` callback (AG Grid's \"tree data\" pattern). The\n * controller:\n *\n * 1. Builds an in-memory tree from the post-sort, post-filter rows.\n * 2. Synthesizes parent nodes for any path level that lacks a backing row.\n * 3. Walks the tree honouring the current expansion set and emits a flat\n * list of rows in display order.\n * 4. Records per-row metadata (depth, hasChildren) that the cell renderer\n * reads to draw the chevron + indentation.\n *\n * Expansion state is split into two sets — `expanded` for rows that have\n * backing data (keyed by reference, so it survives sort/filter), and\n * `expandedKeys` for synthesized parents (keyed by their path string).\n */\nexport class TreeController<T extends object> implements ReactiveController {\n public expanded: Set<T> = new Set();\n public expandedKeys: Set<string> = new Set();\n\n #meta = new WeakMap<T, TreeRowMeta>();\n #syntheticMeta = new Map<string, TreeRowMeta>();\n /** Synthesized parent placeholder rows so consumers still get a `T`-shaped object. */\n #syntheticRows = new Map<string, T>();\n /** Whether `defaultExpanded` has been applied once for the current data set. */\n #defaultsApplied = false;\n /** Most recently built root node. Used to walk the full tree for expand-all. */\n #lastRoot: TreeNode<T> | null = null;\n\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n public hostConnected() {}\n\n /** Whether tree mode is enabled at the grid level. */\n public get enabled(): boolean {\n return Boolean(this.host.tree?.enabled && this.host.tree?.getDataPath);\n }\n\n /** The configured indentation, in pixels, per depth level. */\n public get childIndent(): number {\n return this.host.tree?.childIndent ?? DEFAULT_TREE_INDENT;\n }\n\n /**\n * The column key that displays the chevron + indentation. Resolves to the\n * configured `groupColumnKey`, falling back to the first visible data column.\n */\n public get groupColumnKey(): Keys<T> | undefined {\n const configured = this.host.tree?.groupColumnKey;\n if (configured) return configured;\n const displayed = getDisplayColumns(this.host.columns).find((column) => !column.hidden);\n return displayed?.key;\n }\n\n public isGroupColumn(key: Keys<T>): boolean {\n return this.enabled && this.groupColumnKey === key;\n }\n\n /**\n * Per-row metadata. Populated as a side effect of {@link process}; reading\n * before the first pipeline pass returns `undefined`.\n */\n public getMeta(row: T): TreeRowMeta | undefined {\n return this.#meta.get(row);\n }\n\n public getDepth(row: T): number {\n return this.#meta.get(row)?.depth ?? 0;\n }\n\n public hasChildren(row: T): boolean {\n return Boolean(this.#meta.get(row)?.hasChildren);\n }\n\n public isSynthesized(row: T): boolean {\n return (row as { [SYNTHESIZED]?: boolean })[SYNTHESIZED] === true;\n }\n\n /** Group-column label override for synthesized parent rows. */\n public getLabel(row: T): string | null {\n if (!this.isSynthesized(row)) return null;\n return this.#meta.get(row)?.label ?? null;\n }\n\n public isExpanded(row: T): boolean {\n if (this.isSynthesized(row)) {\n const key = this.#meta.get(row)?.key;\n return key ? this.expandedKeys.has(key) : false;\n }\n return this.expanded.has(row);\n }\n\n /** Toggles the expansion state of a tree row. */\n public async toggleRow(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n if (!this.hasChildren(row)) return false;\n const wasExpanded = this.isExpanded(row);\n return wasExpanded ? this.collapseRow(row) : this.expandRow(row);\n }\n\n public async expandRow(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n if (!this.hasChildren(row)) return false;\n if (this.isExpanded(row)) return true;\n return this.#commit((nextData, nextKeys) => {\n if (this.isSynthesized(row)) {\n const key = this.#meta.get(row)?.key;\n if (key) nextKeys.add(key);\n } else {\n nextData.add(row);\n }\n });\n }\n\n public async collapseRow(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n if (!this.isExpanded(row)) return true;\n return this.#commit((nextData, nextKeys) => {\n if (this.isSynthesized(row)) {\n const key = this.#meta.get(row)?.key;\n if (key) nextKeys.delete(key);\n } else {\n nextData.delete(row);\n }\n });\n }\n\n /** Expands every parent in the current tree. */\n public async expandAll(): Promise<boolean> {\n if (!this.enabled) return false;\n const root = this.#lastRoot;\n if (!root) return false;\n return this.#commit((nextData, nextKeys) => {\n const visit = (node: TreeNode<T>) => {\n if (node !== root && node.children.length > 0) {\n if (node.data) nextData.add(node.data);\n else nextKeys.add(node.key);\n }\n for (const child of node.children) visit(child);\n };\n visit(root);\n });\n }\n\n /** Collapses every currently-expanded row. */\n public async collapseAll(): Promise<boolean> {\n if (!this.enabled) return false;\n if (this.expanded.size === 0 && this.expandedKeys.size === 0) return true;\n return this.#commit((nextData, nextKeys) => {\n nextData.clear();\n nextKeys.clear();\n });\n }\n\n /**\n * Pipeline entry point. Called by {@link DataOperationsController.apply}\n * after sort/filter/quickFilter. Builds the tree, applies the configured\n * defaults the first time we see this data, and returns rows in\n * display-order with any synthesized parents inserted.\n */\n public process(input: ReadonlyArray<T>): T[] {\n if (!this.enabled) return input as T[];\n\n const getDataPath = this.host.tree!.getDataPath;\n const root = this.#buildTree(input, getDataPath);\n this.#lastRoot = root;\n\n // Apply defaultExpanded once per data set.\n if (!this.#defaultsApplied) {\n this.#applyDefaults(root);\n this.#defaultsApplied = true;\n }\n\n this.#refreshMeta(root);\n return this.#flatten(root);\n }\n\n /**\n * Replaces the expansion state wholesale — used by `ApexGrid.setState` to\n * restore a snapshot. Sets both the backing-row set and the synthesized-parent\n * key set directly (no `treeRowExpanding`/`treeRowExpanded` events), marks\n * `defaultExpanded` as already applied so the next pipeline pass treats the\n * restored state as authoritative, and re-runs the pipeline.\n */\n public restoreExpansion(expanded: Iterable<T>, expandedKeys: Iterable<string>): void {\n this.expanded = new Set(expanded);\n this.expandedKeys = new Set(expandedKeys);\n this.#defaultsApplied = true;\n this.host.requestUpdate(PIPELINE);\n }\n\n /**\n * Resets cached metadata + defaults flag so the next pipeline pass\n * re-applies `defaultExpanded`. Called from the data watcher when the\n * input array is replaced wholesale.\n */\n public resetForDataChange(): void {\n this.#defaultsApplied = false;\n // Don't clear `expanded`/`expandedKeys`; consumers may want them to\n // survive across pipeline passes. If a wholesale data swap orphans\n // references, those entries are simply ignored on the next pass.\n }\n\n // --- internals ---------------------------------------------------------\n\n #buildTree(rows: ReadonlyArray<T>, getDataPath: (row: T) => readonly string[]): TreeNode<T> {\n const root: TreeNode<T> = {\n data: null,\n path: [],\n key: '',\n depth: -1,\n parent: null,\n children: [],\n };\n const byKey = new Map<string, TreeNode<T>>();\n byKey.set('', root);\n\n for (const row of rows) {\n const fullPath = getDataPath(row);\n if (!fullPath || fullPath.length === 0) continue;\n\n let parent = root;\n for (let i = 0; i < fullPath.length; i++) {\n const sub = fullPath.slice(0, i + 1);\n const key = sub.join('\u0000');\n let node = byKey.get(key);\n if (!node) {\n node = {\n data: null,\n path: sub,\n key,\n depth: i,\n parent,\n children: [],\n };\n byKey.set(key, node);\n parent.children.push(node);\n }\n if (i === fullPath.length - 1) {\n // The terminal segment is the actual record. If we previously\n // saw a child path that synthesized this level, attach the data\n // now.\n node.data = row;\n }\n parent = node;\n }\n }\n\n return root;\n }\n\n #applyDefaults(root: TreeNode<T>): void {\n const setting = this.host.tree?.defaultExpanded;\n if (setting === undefined || setting === false) return;\n const expandToDepth = typeof setting === 'number' ? setting : Number.POSITIVE_INFINITY;\n const visit = (node: TreeNode<T>) => {\n if (node !== root && node.children.length > 0 && node.depth <= expandToDepth) {\n if (node.data) this.expanded.add(node.data);\n else this.expandedKeys.add(node.key);\n }\n for (const child of node.children) visit(child);\n };\n visit(root);\n }\n\n #refreshMeta(root: TreeNode<T>): void {\n // Recompute meta for every node in the tree, both synthesized and\n // backed. The metadata is fresh each pipeline pass since depth or\n // hasChildren may have changed (rows reordered, filter dropped a\n // descendant, etc.).\n const visit = (node: TreeNode<T>) => {\n if (node !== root) {\n const meta: TreeRowMeta = {\n depth: node.depth,\n hasChildren: node.children.length > 0,\n key: node.key,\n label: node.path[node.path.length - 1] ?? '',\n };\n if (node.data) {\n this.#meta.set(node.data, meta);\n } else {\n this.#syntheticMeta.set(node.key, meta);\n }\n }\n for (const child of node.children) visit(child);\n };\n visit(root);\n }\n\n #flatten(root: TreeNode<T>): T[] {\n const out: T[] = [];\n const walk = (node: TreeNode<T>) => {\n if (node !== root) {\n if (node.data) {\n out.push(node.data);\n } else {\n // Synthesize a `T`-shaped placeholder so callers don't trip on\n // `null` rows. The placeholder carries the SYNTHESIZED marker.\n let placeholder = this.#syntheticRows.get(node.key);\n if (!placeholder) {\n placeholder = Object.create(null) as T;\n Object.defineProperty(placeholder, SYNTHESIZED, {\n value: true,\n enumerable: false,\n });\n this.#syntheticRows.set(node.key, placeholder);\n }\n this.#meta.set(placeholder, this.#syntheticMeta.get(node.key)!);\n out.push(placeholder);\n }\n }\n const expanded =\n node === root ||\n (node.data ? this.expanded.has(node.data) : this.expandedKeys.has(node.key));\n if (expanded) {\n for (const child of node.children) walk(child);\n }\n };\n walk(root);\n return out;\n }\n\n async #commit(mutate: (nextData: Set<T>, nextKeys: Set<string>) => void): Promise<boolean> {\n const nextData = new Set(this.expanded);\n const nextKeys = new Set(this.expandedKeys);\n mutate(nextData, nextKeys);\n\n const dataChanged =\n nextData.size !== this.expanded.size || [...nextData].some((row) => !this.expanded.has(row));\n const keysChanged =\n nextKeys.size !== this.expandedKeys.size ||\n [...nextKeys].some((key) => !this.expandedKeys.has(key));\n if (!dataChanged && !keysChanged) return true;\n\n const added: T[] = [];\n const removed: T[] = [];\n for (const row of nextData) if (!this.expanded.has(row)) added.push(row);\n for (const row of this.expanded) if (!nextData.has(row)) removed.push(row);\n\n const proceed = this.host.emitEvent('treeRowExpanding', {\n detail: {\n added,\n removed,\n current: Array.from(this.expanded),\n next: Array.from(nextData),\n },\n cancelable: true,\n });\n if (!proceed) return false;\n\n this.expanded = nextData;\n this.expandedKeys = nextKeys;\n // Re-run the pipeline so the flat output reflects the new expansion set.\n this.host.requestUpdate(PIPELINE);\n\n this.host.emitEvent('treeRowExpanded', {\n detail: { added, removed, expanded: Array.from(this.expanded) },\n });\n return true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/controllers/tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAGtC,MAAM,WAAW,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAGnD,MAAM,cAAc,GAAG,IAAI,CAAC;AA6D5B,MAAM,OAAO,cAAc;IAIzB,KAAK,CAAiC;IAEtC,cAAc,CAAwB;IAEtC,gBAAgB,CAAS;IAEzB,YAAY,CAAoB;IAChC,SAAS,CAAqB;IAE9B,iBAAiB,CAAS;IAE1B,SAAS,CAA4B;IAErC,QAAQ,CAA+B;IAEvC,YAAsB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAlBhC,aAAQ,GAAW,IAAI,GAAG,EAAE,CAAC;QAC7B,iBAAY,GAAgB,IAAI,GAAG,EAAE,CAAC;QAE7C,UAAK,GAAG,IAAI,OAAO,EAAkB,CAAC;QAEtC,mBAAc,GAAG,IAAI,GAAG,EAAa,CAAC;QAEtC,qBAAgB,GAAG,KAAK,CAAC;QAEzB,iBAAY,GAAG,IAAI,OAAO,EAAK,CAAC;QAChC,cAAS,GAAG,IAAI,GAAG,EAAU,CAAC;QAE9B,sBAAiB,GAAG,KAAK,CAAC;QAE1B,cAAS,GAAuB,IAAI,CAAC;QAErC,aAAQ,GAA0B,IAAI,CAAC;QAevC,iBAAY,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,I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OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC;gBACvD,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC;aACvC;YACD,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,IAAI,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAE3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;QAE7B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAElC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE;YACrC,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,EAAE;SACrF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import type { ReactiveController } from 'lit';\nimport { PIPELINE } from '../internal/constants.js';\nimport type { GridHost, Keys } from '../internal/types.js';\nimport { getDisplayColumns } from '../internal/utils.js';\nimport { retainPresent } from './expansion.js';\n\n/**\n * Default pixel indentation per depth level for the tree group column.\n */\nexport const DEFAULT_TREE_INDENT = 20;\n\n/** Sentinel value used to mark synthesized parents (those that exist only as a path segment, with no backing row). */\nconst SYNTHESIZED = Symbol('synthesized-tree-row');\n\n/** Joins path segments into a node key; a character no segment is expected to hold. */\nconst PATH_SEPARATOR = '\\0';\n\n/**\n * Internal tree node. Built from the flat data + `getDataPath` callback;\n * lives only for the duration of one pipeline pass.\n */\ninterface TreeNode<T extends object> {\n /** The backing row when one exists at this path, else `null` (synthesized parent). */\n data: T | null;\n /** Path segments from root to this node. */\n path: readonly string[];\n /** `path.join(PATH_SEPARATOR)`, the stable string identity for synthesized nodes. */\n key: string;\n depth: number;\n parent: TreeNode<T> | null;\n children: TreeNode<T>[];\n}\n\n/** Path key to record lookup over one data array, valid while that array is unchanged. */\ninterface RecordIndex<T extends object> {\n data: ReadonlyArray<T>;\n length: number;\n getDataPath: (row: T) => readonly string[];\n byKey: Map<string, T>;\n}\n\n/**\n * Tree metadata exposed to renderers. One entry per row that ends up in the\n * flat output.\n */\nexport interface TreeRowMeta {\n depth: number;\n hasChildren: boolean;\n /** Stable key for the row (path-joined string). Useful for keyed reconciliation. */\n key: string;\n /** Last path segment, used as the group-column label for synthesized parents. */\n label: string;\n}\n\n/**\n * Reactive controller backing tree (nested-row) data.\n *\n * @remarks\n * Tree mode keeps the data array flat. Each row's hierarchy is derived from a\n * user-supplied `getDataPath` callback that returns the row's path from the\n * root (the flat-array \"tree data\" pattern). The controller:\n *\n * 1. Builds an in-memory tree from the post-sort, post-filter rows.\n * 2. Synthesizes parent nodes for any path level that lacks a backing row\n * in the data. A level whose own row was filtered out shows that row.\n * 3. Walks the tree honouring the current expansion set and emits a flat\n * list of rows in display order.\n * 4. Records per-row metadata (depth, hasChildren) that the cell renderer\n * reads to draw the chevron + indentation.\n *\n * Expansion state is split into two sets: `expanded` for rows that have\n * backing data (keyed by reference, so it survives sort/filter), and\n * `expandedKeys` for synthesized parents (keyed by their path string). Both\n * follow a data refresh: entries whose row or path left the data are dropped,\n * and `defaultExpanded` applies only to parents not seen before.\n */\nexport class TreeController<T extends object> implements ReactiveController {\n public expanded: Set<T> = new Set();\n public expandedKeys: Set<string> = new Set();\n\n #meta = new WeakMap<T, TreeRowMeta>();\n /** Synthesized parent placeholder rows so consumers still get a `T`-shaped object. */\n #syntheticRows = new Map<string, T>();\n /** Whether `defaultExpanded` has been applied once for the current data set. */\n #defaultsApplied = false;\n /** Parents `defaultExpanded` has already been weighed for, by row and by path. */\n #seenParents = new WeakSet<T>();\n #seenKeys = new Set<string>();\n /** Set on a data change: the next build over the whole data prunes stale path keys. */\n #reconcilePending = false;\n /** Most recently built root node. Used to walk the full tree for expand-all. */\n #lastRoot: TreeNode<T> | null = null;\n /** The first record per path key in `host.data`, built once per data array when needed. */\n #records: RecordIndex<T> | null = null;\n\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n public hostConnected() {\n this.host.addEventListener('cellValueChanged', this.#dropRecords);\n }\n\n public hostDisconnected() {\n this.host.removeEventListener('cellValueChanged', this.#dropRecords);\n }\n\n /** An edit writes through to the record in place and may change its path. */\n #dropRecords = () => {\n this.#records = null;\n };\n\n /** Whether tree mode is enabled at the grid level. */\n public get enabled(): boolean {\n return Boolean(this.host.tree?.enabled && this.host.tree?.getDataPath);\n }\n\n /** The configured indentation, in pixels, per depth level. */\n public get childIndent(): number {\n return this.host.tree?.childIndent ?? DEFAULT_TREE_INDENT;\n }\n\n /**\n * The column key that displays the chevron + indentation. Resolves to the\n * configured `groupColumnKey`, falling back to the first visible data column.\n */\n public get groupColumnKey(): Keys<T> | undefined {\n const configured = this.host.tree?.groupColumnKey;\n if (configured) return configured;\n const displayed = getDisplayColumns(this.host.columns).find((column) => !column.hidden);\n return displayed?.key;\n }\n\n public isGroupColumn(key: Keys<T>): boolean {\n return this.enabled && this.groupColumnKey === key;\n }\n\n /**\n * Per-row metadata. Populated as a side effect of {@link process}; reading\n * before the first pipeline pass returns `undefined`.\n */\n public getMeta(row: T): TreeRowMeta | undefined {\n return this.#meta.get(row);\n }\n\n public getDepth(row: T): number {\n return this.#meta.get(row)?.depth ?? 0;\n }\n\n public hasChildren(row: T): boolean {\n return Boolean(this.#meta.get(row)?.hasChildren);\n }\n\n public isSynthesized(row: T): boolean {\n return (row as { [SYNTHESIZED]?: boolean })[SYNTHESIZED] === true;\n }\n\n /** Group-column label override for synthesized parent rows. */\n public getLabel(row: T): string | null {\n if (!this.isSynthesized(row)) return null;\n return this.#meta.get(row)?.label ?? null;\n }\n\n public isExpanded(row: T): boolean {\n if (this.isSynthesized(row)) {\n const key = this.#meta.get(row)?.key;\n return key ? this.expandedKeys.has(key) : false;\n }\n return this.expanded.has(row);\n }\n\n /** Toggles the expansion state of a tree row. */\n public async toggleRow(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n if (!this.hasChildren(row)) return false;\n const wasExpanded = this.isExpanded(row);\n return wasExpanded ? this.collapseRow(row) : this.expandRow(row);\n }\n\n public async expandRow(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n if (!this.hasChildren(row)) return false;\n if (this.isExpanded(row)) return true;\n return this.#commit((nextData, nextKeys) => {\n if (this.isSynthesized(row)) {\n const key = this.#meta.get(row)?.key;\n if (key) nextKeys.add(key);\n } else {\n nextData.add(row);\n }\n });\n }\n\n public async collapseRow(row: T): Promise<boolean> {\n if (!this.enabled) return false;\n if (!this.isExpanded(row)) return true;\n return this.#commit((nextData, nextKeys) => {\n if (this.isSynthesized(row)) {\n const key = this.#meta.get(row)?.key;\n if (key) nextKeys.delete(key);\n } else {\n nextData.delete(row);\n }\n });\n }\n\n /** Expands every parent in the current tree. */\n public async expandAll(): Promise<boolean> {\n if (!this.enabled) return false;\n const root = this.#lastRoot;\n if (!root) return false;\n return this.#commit((nextData, nextKeys) => {\n const visit = (node: TreeNode<T>) => {\n if (node !== root && node.children.length > 0) {\n if (node.data) nextData.add(node.data);\n else nextKeys.add(node.key);\n }\n for (const child of node.children) visit(child);\n };\n visit(root);\n });\n }\n\n /** Collapses every currently-expanded row. */\n public async collapseAll(): Promise<boolean> {\n if (!this.enabled) return false;\n if (this.expanded.size === 0 && this.expandedKeys.size === 0) return true;\n return this.#commit((nextData, nextKeys) => {\n nextData.clear();\n nextKeys.clear();\n });\n }\n\n /**\n * Pipeline entry point. Called by {@link DataOperationsController.apply}\n * after sort/filter/quickFilter. Builds the tree, applies the configured\n * defaults the first time we see this data, and returns rows in\n * display-order with any synthesized parents inserted.\n */\n public process(input: ReadonlyArray<T>): T[] {\n if (!this.enabled) return input as T[];\n\n const getDataPath = this.host.tree!.getDataPath;\n const root = this.#buildTree(input, getDataPath);\n this.#lastRoot = root;\n\n // Apply defaultExpanded once per data set, to parents not seen before.\n const applyDefaults = !this.#defaultsApplied;\n this.#defaultsApplied = true;\n // Only a build over the whole data knows which path keys are gone.\n const reconcile = this.#reconcilePending && input.length >= (this.host.data?.length ?? 0);\n if (reconcile) this.#reconcilePending = false;\n\n this.#refreshMeta(root, applyDefaults, reconcile);\n return this.#flatten(root);\n }\n\n /**\n * Replaces the expansion state wholesale. Used by `ApexGrid.setState` to\n * restore a snapshot. Sets both the backing-row set and the synthesized-parent\n * key set directly (no `treeRowExpanding`/`treeRowExpanded` events), marks\n * `defaultExpanded` as already applied so the next pipeline pass treats the\n * restored state as authoritative, and re-runs the pipeline.\n */\n public restoreExpansion(expanded: Iterable<T>, expandedKeys: Iterable<string>): void {\n this.expanded = new Set(expanded);\n this.expandedKeys = new Set(expandedKeys);\n this.#defaultsApplied = true;\n this.host.requestUpdate(PIPELINE);\n }\n\n /**\n * Reconciles the expansion state with replaced data. Called from the data\n * watcher when the input array is replaced wholesale: expanded rows that\n * left the data are dropped now, stale path keys on the next full build,\n * and the next pass applies `defaultExpanded` to parents not seen before.\n */\n public resetForDataChange(): void {\n this.#defaultsApplied = false;\n this.#reconcilePending = true;\n this.#records = null;\n this.expanded = retainPresent(this.expanded, this.host.data ?? []);\n }\n\n // --- internals ---------------------------------------------------------\n\n #buildTree(rows: ReadonlyArray<T>, getDataPath: (row: T) => readonly string[]): TreeNode<T> {\n const root: TreeNode<T> = {\n data: null,\n path: [],\n key: '',\n depth: -1,\n parent: null,\n children: [],\n };\n const byKey = new Map<string, TreeNode<T>>();\n byKey.set('', root);\n /** Twins made so far per node; twins stay out of `byKey`, so no path resolves to one. */\n const twins = new Map<TreeNode<T>, number>();\n /** Levels first reached as an ancestor, which may still lack a record. */\n const intermediate: TreeNode<T>[] = [];\n\n for (const row of rows) {\n const fullPath = getDataPath(row);\n if (!fullPath || fullPath.length === 0) continue;\n\n let parent = root;\n for (let i = 0; i < fullPath.length; i++) {\n const sub = fullPath.slice(0, i + 1);\n const key = sub.join(PATH_SEPARATOR);\n let node = byKey.get(key);\n if (!node) {\n node = {\n data: null,\n path: sub,\n key,\n depth: i,\n parent,\n children: [],\n };\n byKey.set(key, node);\n parent.children.push(node);\n if (i < fullPath.length - 1) intermediate.push(node);\n }\n if (i === fullPath.length - 1) {\n // The terminal segment is the actual record. If we previously\n // saw a child path that synthesized this level, attach the data\n // now. A second row with the same path gets a sibling node, so\n // no row is dropped.\n if (node.data && node.data !== row) this.#addTwin(node, row, twins, getDataPath);\n else node.data = row;\n }\n parent = node;\n }\n }\n\n this.#adoptFilteredAncestors(rows, intermediate, getDataPath);\n return root;\n }\n\n /**\n * Adds a sibling of `node` for another row that returns the same path, so\n * no row is dropped. The earliest of those rows in `host.data` keeps the\n * path node and its descendants whatever the sort order, so sorting never\n * moves children between them; the others sit next to it in sort order.\n */\n #addTwin(\n node: TreeNode<T>,\n row: T,\n twins: Map<TreeNode<T>, number>,\n getDataPath: (row: T) => readonly string[]\n ): void {\n const n = (twins.get(node) ?? 0) + 1;\n twins.set(node, n);\n const twin: TreeNode<T> = {\n ...node,\n data: row,\n key: `${node.key}${PATH_SEPARATOR}${PATH_SEPARATOR}${n}`,\n children: [],\n };\n const siblings = node.parent!.children;\n siblings.push(twin);\n if (this.#recordAt(node.key, getDataPath) === row) {\n // The owner arrived after a later duplicate: it takes the path node,\n // and the twin takes the slot the duplicate was sorted into.\n twin.data = node.data;\n node.data = row;\n siblings[siblings.indexOf(node)] = twin;\n siblings[siblings.length - 1] = node;\n }\n }\n\n /**\n * Gives an ancestor level its own record when a filter removed that record\n * but kept a descendant. Otherwise the ancestor renders as a blank\n * placeholder with an expansion state of its own, so the match sits under a\n * collapsed level the user had opened. Runs only when the input is a\n * filtered subset of the data and some ancestor level lacks a record; the\n * lookup costs one pass over the data per data array (and after a cell\n * edit), then a map hit per level, so filter keystrokes and expand clicks\n * stay O(visible).\n */\n #adoptFilteredAncestors(\n rows: ReadonlyArray<T>,\n intermediate: ReadonlyArray<TreeNode<T>>,\n getDataPath: (row: T) => readonly string[]\n ): void {\n if ((this.host.data?.length ?? 0) <= rows.length) return;\n for (const node of intermediate) {\n if (!node.data) node.data = this.#recordAt(node.key, getDataPath) ?? null;\n }\n }\n\n /**\n * The first record in `host.data` whose path joins to `key`. A hit is\n * checked against the record's current path, since a path can change in\n * place without a new data array; a stale hit rebuilds the index once.\n */\n #recordAt(key: string, getDataPath: (row: T) => readonly string[]): T | undefined {\n const record = this.#recordsByKey(getDataPath).get(key);\n if (!record || getDataPath(record)?.join(PATH_SEPARATOR) === key) return record;\n this.#records = null;\n return this.#recordsByKey(getDataPath).get(key);\n }\n\n /**\n * The first record per path key in `host.data`. Built on first use and\n * kept while the data array, its length and `getDataPath` are unchanged\n * and no cell edit was applied.\n */\n #recordsByKey(getDataPath: (row: T) => readonly string[]): Map<string, T> {\n const data = this.host.data ?? [];\n const cached = this.#records;\n if (\n cached?.data === data &&\n cached.length === data.length &&\n cached.getDataPath === getDataPath\n ) {\n return cached.byKey;\n }\n const byKey = new Map<string, T>();\n for (const row of data) {\n const path = getDataPath(row);\n if (!path?.length) continue;\n const key = path.join(PATH_SEPARATOR);\n if (!byKey.has(key)) byKey.set(key, row);\n }\n this.#records = { data, length: data.length, getDataPath, byKey };\n return byKey;\n }\n\n /**\n * Records fresh metadata for every node, both synthesized and backed, since\n * depth or hasChildren may change between passes (rows reordered, a filter\n * dropped a descendant). The same walk weighs `defaultExpanded` for parents\n * seen for the first time and, on a reconciling pass, drops the path keys\n * and placeholders of synthesized parents that left the data.\n */\n #refreshMeta(root: TreeNode<T>, applyDefaults: boolean, reconcile: boolean): void {\n const setting = applyDefaults ? this.host.tree?.defaultExpanded : undefined;\n const expandToDepth =\n setting === true ? Number.POSITIVE_INFINITY : typeof setting === 'number' ? setting : -1;\n const liveKeys = reconcile ? new Set<string>() : null;\n const visit = (node: TreeNode<T>) => {\n if (node !== root) {\n const meta: TreeRowMeta = {\n depth: node.depth,\n hasChildren: node.children.length > 0,\n key: node.key,\n label: node.path[node.path.length - 1] ?? '',\n };\n if (node.data) {\n this.#meta.set(node.data, meta);\n if (meta.hasChildren && !this.#seenParents.has(node.data)) {\n this.#seenParents.add(node.data);\n if (node.depth <= expandToDepth) this.expanded.add(node.data);\n }\n } else {\n this.#meta.set(this.#placeholder(node.key), meta);\n liveKeys?.add(node.key);\n if (!this.#seenKeys.has(node.key)) {\n this.#seenKeys.add(node.key);\n if (node.depth <= expandToDepth) this.expandedKeys.add(node.key);\n }\n }\n }\n for (const child of node.children) visit(child);\n };\n visit(root);\n\n if (liveKeys) {\n for (const key of this.expandedKeys) if (!liveKeys.has(key)) this.expandedKeys.delete(key);\n for (const key of this.#seenKeys) if (!liveKeys.has(key)) this.#seenKeys.delete(key);\n for (const key of this.#syntheticRows.keys()) {\n if (!liveKeys.has(key)) this.#syntheticRows.delete(key);\n }\n }\n }\n\n /**\n * The placeholder row of a synthesized parent, stable per path so callers\n * can hold on to it. It carries the SYNTHESIZED marker.\n */\n #placeholder(key: string): T {\n let placeholder = this.#syntheticRows.get(key);\n if (!placeholder) {\n placeholder = Object.create(null) as T;\n Object.defineProperty(placeholder, SYNTHESIZED, { value: true, enumerable: false });\n this.#syntheticRows.set(key, placeholder);\n }\n return placeholder;\n }\n\n #flatten(root: TreeNode<T>): T[] {\n const out: T[] = [];\n const walk = (node: TreeNode<T>) => {\n if (node !== root) out.push(node.data ?? this.#placeholder(node.key));\n const expanded =\n node === root ||\n (node.data ? this.expanded.has(node.data) : this.expandedKeys.has(node.key));\n if (expanded) {\n for (const child of node.children) walk(child);\n }\n };\n walk(root);\n return out;\n }\n\n /** Rows for an event payload: backed rows, then the placeholders of `keys`. */\n #rowsOf(rows: Iterable<T>, keys: Iterable<string>): T[] {\n const out = Array.from(rows);\n for (const key of keys) {\n const placeholder = this.#syntheticRows.get(key);\n if (placeholder) out.push(placeholder);\n }\n return out;\n }\n\n async #commit(mutate: (nextData: Set<T>, nextKeys: Set<string>) => void): Promise<boolean> {\n const nextData = new Set(this.expanded);\n const nextKeys = new Set(this.expandedKeys);\n mutate(nextData, nextKeys);\n\n const addedRows = [...nextData].filter((row) => !this.expanded.has(row));\n const removedRows = [...this.expanded].filter((row) => !nextData.has(row));\n const addedKeys = [...nextKeys].filter((key) => !this.expandedKeys.has(key));\n const removedKeys = [...this.expandedKeys].filter((key) => !nextKeys.has(key));\n if (!addedRows.length && !removedRows.length && !addedKeys.length && !removedKeys.length) {\n return true;\n }\n\n // Synthesized parents appear in the payload as their placeholder rows,\n // the same objects pageItems holds, so listeners can tell them apart.\n const added = this.#rowsOf(addedRows, addedKeys);\n const removed = this.#rowsOf(removedRows, removedKeys);\n\n const proceed = this.host.emitEvent('treeRowExpanding', {\n detail: {\n added,\n removed,\n current: this.#rowsOf(this.expanded, this.expandedKeys),\n next: this.#rowsOf(nextData, nextKeys),\n },\n cancelable: true,\n });\n if (!proceed) return false;\n\n this.expanded = nextData;\n this.expandedKeys = nextKeys;\n // Re-run the pipeline so the flat output reflects the new expansion set.\n this.host.requestUpdate(PIPELINE);\n\n this.host.emitEvent('treeRowExpanded', {\n detail: { added, removed, expanded: this.#rowsOf(this.expanded, this.expandedKeys) },\n });\n return true;\n }\n}\n"]}
|