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/sort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../src/controllers/sort.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAuB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAO5F,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,MAAM,OAAO,cAAc;IACzB,YAAsB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAIhC,UAAK,GAAiB,IAAI,GAAG,EAAE,CAAC;QAHrC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAID,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC;IAC9C,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC;IAC9C,CAAC;IAED,mBAAmB,CAA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I,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CACzF,CACF,CAAC;IACJ,CAAC;IAEM,aAAa,KAAI,CAAC;CAC1B","sourcesContent":["import type { ReactiveController } from 'lit';\nimport { PIPELINE } from '../internal/constants.js';\nimport { awaitChildUpdates, type KeyedFlipEntry, playKeyedFlip } from '../internal/flip.js';\nimport type {\n ColumnConfiguration,\n ColumnSortConfiguration,\n GridHost,\n Keys,\n} from '../internal/types.js';\nimport { asArray } from '../internal/utils.js';\nimport type { SortExpression, SortingDirection, SortState } from '../operations/sort/types.js';\n\nexport class SortController<T extends object> implements ReactiveController {\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n public state: SortState<T> = new Map();\n\n get #isMultipleSort() {\n return this.host.sortConfiguration.multiple;\n }\n\n get #isTriStateSort() {\n return this.host.sortConfiguration.triState;\n }\n\n #resolveSortOptions(options?: boolean | ColumnSortConfiguration<T>) {\n const expr: Pick<SortExpression<T>, 'caseSensitive' | 'comparer'> = {\n caseSensitive: false,\n comparer: undefined,\n };\n\n if (!options || typeof options === 'boolean') {\n return expr as Partial<SortExpression<T>>;\n }\n\n return Object.assign(expr, {\n caseSensitive: options.caseSensitive,\n comparer: options.comparer,\n }) as Partial<SortExpression<T>>;\n }\n\n #createDefaultExpression(key: Keys<T>) {\n const options = this.host.getColumn(key)?.sort;\n\n return {\n key,\n direction: 'ascending',\n ...this.#resolveSortOptions(options),\n } as SortExpression<T>;\n }\n\n #orderBy(dir?: SortingDirection): SortingDirection {\n return this.#isTriStateSort\n ? dir === 'ascending'\n ? 'descending'\n : dir === 'descending'\n ? 'none'\n : 'ascending'\n : dir === 'ascending'\n ? 'descending'\n : 'ascending';\n }\n\n #emitSortingEvent(detail: SortExpression<T>) {\n return this.host.emitEvent('sorting', { detail, cancelable: true });\n }\n\n #emitSortedEvent(detail: SortExpression<T>) {\n return this.host.emitEvent('sorted', { detail });\n }\n\n #setExpression(expression: SortExpression<T>) {\n expression.direction === 'none'\n ? this.reset(expression.key)\n : this.state.set(expression.key, { ...expression });\n }\n\n public async sortFromHeaderClick(column: ColumnConfiguration<T>, additive = false) {\n const expression = this.prepareExpression(column);\n\n if (!this.#emitSortingEvent(expression)) {\n return;\n }\n\n // A plain click sorts by this column alone, clearing any other sorted\n // columns. Only a Ctrl/Cmd+click while multi-sort is enabled keeps the\n // existing sort keys and appends this column as an additional, lower-\n // priority sort. Without this gate every plain click would accumulate a\n // key, so a second column added behind a unique primary column would not\n // change the visible order at all.\n if (!this.#isMultipleSort || !additive) {\n this.reset();\n }\n\n // Capture visible-row rects keyed by data identity BEFORE the pipeline\n // runs. After the new render the virtualizer will have repositioned\n // rows; we use those captured rects as the \"First\" of a FLIP and\n // animate each row from its old viewport position back to identity.\n const beforeRects = this.#captureRowRects();\n\n this._sort(expression);\n\n await this.host.updateComplete;\n // Wait for body row updates so the new data is committed to each row\n // element before measuring the \"Last\" rect — otherwise the captured-\n // before and measured-after rects match and the animation no-ops.\n await awaitChildUpdates(this.host.rows);\n this.#playRowFlip(beforeRects);\n this.#announce(expression, column);\n this.#emitSortedEvent(expression);\n }\n\n #announce(expression: SortExpression<T>, column: ColumnConfiguration<T>) {\n const label = column.headerText ?? String(column.key);\n const message =\n expression.direction === 'none'\n ? this.host.localize('announce.sortCleared', { label })\n : this.host.localize(\n expression.direction === 'ascending'\n ? 'announce.sortedAscending'\n : 'announce.sortedDescending',\n { label }\n );\n this.host.announce(message);\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 #playRowFlip(before: ReadonlyArray<KeyedFlipEntry<T>>) {\n // After sort, the same data may be rendered by a different `<apex-grid-row>`\n // DOM element (virtualizer recycles rows). Resolve by data identity.\n const rows = this.host.rows;\n const byData = new Map<T, HTMLElement>();\n for (const row of rows) {\n byData.set(row.data, row as unknown as HTMLElement);\n }\n playKeyedFlip(before, (data) => byData.get(data) ?? null, 'y');\n }\n\n public prepareExpression({ key, sort: options }: ColumnConfiguration<T>): SortExpression<T> {\n if (this.state.has(key)) {\n const expr = this.state.get(key)!;\n\n return Object.assign(expr, {\n direction: this.#orderBy(expr.direction),\n ...this.#resolveSortOptions(options),\n });\n }\n\n // Initial state\n return this.#createDefaultExpression(key);\n }\n\n public reset(key?: Keys<T>) {\n key ? this.state.delete(key) : this.state.clear();\n }\n\n get #rowReorder() {\n // @ts-expect-error - protected member access\n return this.host.stateController.rowReorder as\n | { hasManualOrder: boolean; clearManualOrder(announce?: boolean): void }\n | undefined;\n }\n\n protected _sort(expressions: SortExpression<T> | SortExpression<T>[]) {\n const exprs = asArray(expressions);\n // Applying a sort is mutually exclusive with a manual row order (F5):\n // a real sort (any non-`none` direction) clears it, with an announcement.\n const reorder = this.#rowReorder;\n if (reorder?.hasManualOrder && exprs.some((expr) => expr.direction !== 'none')) {\n reorder.clearManualOrder(true);\n }\n\n for (const expr of exprs) {\n this.#setExpression(expr);\n }\n\n this.host.requestUpdate(PIPELINE);\n }\n\n public sort(expressions: SortExpression<T> | SortExpression<T>[]) {\n this._sort(\n asArray(expressions).map((expr) =>\n Object.assign(this.state.get(expr.key) ?? this.#createDefaultExpression(expr.key), expr)\n )\n );\n }\n\n public hostConnected() {}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sort.js","sourceRoot":"","sources":["../../src/controllers/sort.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAuB,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAO5F,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,MAAM,OAAO,cAAc;IACzB,YAAsB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAIhC,UAAK,GAAiB,IAAI,GAAG,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AAC,IAAI,CAAC,SAAS,KAAK,MAAM,CAAC,EAAE,CAAC;YAC/E,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAEM,IAAI,CAAC,WAAoD;QAC9D,IAAI,CAAC,KAAK,CACR,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CACtB,CAAC,IAAI,EAAE,EAAE,CACP,CAAC;YACC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACxE,GAAG,IAAI;SACR,CAAsB,CAC1B,CACF,CAAC;IACJ,CAAC;IAEM,aAAa,KAAI,CAAC;CAC1B","sourcesContent":["import type { ReactiveController } from 'lit';\nimport { PIPELINE } from '../internal/constants.js';\nimport { type KeyedFlipEntry, playKeyedFlip, settleRowsForFlip } from '../internal/flip.js';\nimport type {\n ColumnConfiguration,\n ColumnSortConfiguration,\n GridHost,\n Keys,\n} from '../internal/types.js';\nimport { asArray } from '../internal/utils.js';\nimport type { SortExpression, SortingDirection, SortState } from '../operations/sort/types.js';\n\nexport class SortController<T extends object> implements ReactiveController {\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n public state: SortState<T> = new Map();\n\n get #isMultipleSort() {\n return this.host.sortConfiguration.multiple;\n }\n\n get #isTriStateSort() {\n return this.host.sortConfiguration.triState;\n }\n\n /**\n * Only the options the column config actually sets, so a header click keeps a\n * comparer or caseSensitive that came in through `grid.sort()` when the column\n * itself does not define one. The trade-off: a comparer later removed from\n * the column config stays on the stored expression until that column's sort\n * is cleared, because its origin is not tracked.\n */\n #resolveSortOptions(options?: boolean | ColumnSortConfiguration<T>) {\n const expr: Partial<SortExpression<T>> = {};\n if (options && typeof options === 'object') {\n if (options.caseSensitive !== undefined) expr.caseSensitive = options.caseSensitive;\n if (options.comparer !== undefined) expr.comparer = options.comparer as any;\n }\n return expr;\n }\n\n #createDefaultExpression(key: Keys<T>) {\n const options = this.host.getColumn(key)?.sort;\n\n return {\n key,\n direction: 'ascending',\n caseSensitive: false,\n comparer: undefined,\n ...this.#resolveSortOptions(options),\n } as SortExpression<T>;\n }\n\n #orderBy(dir?: SortingDirection): SortingDirection {\n return this.#isTriStateSort\n ? dir === 'ascending'\n ? 'descending'\n : dir === 'descending'\n ? 'none'\n : 'ascending'\n : dir === 'ascending'\n ? 'descending'\n : 'ascending';\n }\n\n #emitSortingEvent(detail: SortExpression<T>) {\n return this.host.emitEvent('sorting', { detail, cancelable: true });\n }\n\n #emitSortedEvent(detail: SortExpression<T>) {\n return this.host.emitEvent('sorted', { detail });\n }\n\n #setExpression(expression: SortExpression<T>) {\n expression.direction === 'none'\n ? this.reset(expression.key)\n : this.state.set(expression.key, { ...expression });\n }\n\n public sortFromHeaderClick(column: ColumnConfiguration<T>, additive = false) {\n return this.sortFromUI(column, { additive });\n }\n\n /**\n * The one path for a sort the user starts from the UI (header click, column\n * menu): fires the cancelable `sorting` event, replaces the sort unless the\n * gesture is additive in multi-sort mode, announces, then fires `sorted`.\n * Without a `direction` the column steps to its next direction.\n */\n public async sortFromUI(\n column: ColumnConfiguration<T>,\n { direction, additive = false }: { direction?: SortingDirection; additive?: boolean } = {}\n ) {\n const expression = this.prepareExpression(column, direction);\n\n if (!this.#emitSortingEvent(expression)) {\n return;\n }\n\n // A plain click sorts by this column alone, clearing any other sorted\n // columns. Only a Ctrl/Cmd+click while multi-sort is enabled keeps the\n // existing sort keys and appends this column as an additional, lower-\n // priority sort. Without this gate every plain click would accumulate a\n // key, so a second column added behind a unique primary column would not\n // change the visible order at all.\n if (!this.#isMultipleSort || !additive) {\n this.reset();\n }\n\n // Capture visible-row rects keyed by data identity BEFORE the pipeline\n // runs. After the new render the virtualizer will have repositioned\n // rows; we use those captured rects as the \"First\" of a FLIP and\n // animate each row from its old viewport position back to identity.\n const beforeRects = this.#captureRowRects();\n\n this._sort(expression);\n\n // The rows must show the sorted data before the \"Last\" rects are\n // measured, otherwise the captured-before and measured-after rects match\n // and the animation no-ops.\n await settleRowsForFlip(this.host);\n this.#playRowFlip(beforeRects);\n this.#announce(expression, column);\n this.#emitSortedEvent(expression);\n }\n\n #announce(expression: SortExpression<T>, column: ColumnConfiguration<T>) {\n const label = column.headerText ?? String(column.key);\n const message =\n expression.direction === 'none'\n ? this.host.localize('announce.sortCleared', { label })\n : this.host.localize(\n expression.direction === 'ascending'\n ? 'announce.sortedAscending'\n : 'announce.sortedDescending',\n { label }\n );\n this.host.announce(message);\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 #playRowFlip(before: ReadonlyArray<KeyedFlipEntry<T>>) {\n // After sort, the same data may be rendered by a different `<apex-grid-row>`\n // DOM element (virtualizer recycles rows). Resolve by data identity.\n const rows = this.host.rows;\n const byData = new Map<T, HTMLElement>();\n for (const row of rows) {\n byData.set(row.data, row as unknown as HTMLElement);\n }\n playKeyedFlip(before, (data) => byData.get(data) ?? null, 'y');\n }\n\n /**\n * The expression a UI sort would apply. Always a fresh object: the stored\n * entry is only replaced once the `sorting` event is not cancelled.\n */\n public prepareExpression(\n { key, sort: options }: ColumnConfiguration<T>,\n direction?: SortingDirection\n ): SortExpression<T> {\n const expr = this.state.get(key);\n\n return {\n ...(expr ?? this.#createDefaultExpression(key)),\n direction: direction ?? this.#orderBy(expr?.direction),\n ...this.#resolveSortOptions(options),\n } as SortExpression<T>;\n }\n\n /**\n * Whether the UI offers sorting on `column`: it declares `sort` and no\n * manual row order is active (sorting and a manual order are mutually\n * exclusive). The one rule for every sort affordance, built in or a module's.\n */\n public isSortable(column: ColumnConfiguration<T>): boolean {\n return Boolean(column.sort) && !this.#rowReorder?.hasManualOrder;\n }\n\n public reset(key?: Keys<T>) {\n key ? this.state.delete(key) : this.state.clear();\n }\n\n get #rowReorder() {\n // @ts-expect-error - protected member access\n return this.host.stateController.rowReorder as\n | { hasManualOrder: boolean; clearManualOrder(announce?: boolean): void }\n | undefined;\n }\n\n protected _sort(expressions: SortExpression<T> | SortExpression<T>[]) {\n const exprs = asArray(expressions);\n // Applying a sort is mutually exclusive with a manual row order (F5):\n // a real sort (any non-`none` direction) clears it, with an announcement.\n const reorder = this.#rowReorder;\n if (reorder?.hasManualOrder && exprs.some((expr) => expr.direction !== 'none')) {\n reorder.clearManualOrder(true);\n }\n\n for (const expr of exprs) {\n this.#setExpression(expr);\n }\n\n this.host.requestUpdate(PIPELINE);\n }\n\n public sort(expressions: SortExpression<T> | SortExpression<T>[]) {\n this._sort(\n asArray(expressions).map(\n (expr) =>\n ({\n ...(this.state.get(expr.key) ?? this.#createDefaultExpression(expr.key)),\n ...expr,\n }) as SortExpression<T>\n )\n );\n }\n\n public hostConnected() {}\n}\n"]}
|
package/controllers/state.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactiveController } from 'lit';
|
|
2
2
|
import type { GridLocaleKey, LocaleParams } from '../i18n/index.js';
|
|
3
3
|
import { type CellDecoration, type CellDecoratorContext, type CellInteraction, type GridFeatureModule, type PresentedRow, type RowAria, type RowPresenterContext } from '../internal/feature-module.js';
|
|
4
|
-
import type { ActiveNode, GridHost } from '../internal/types.js';
|
|
4
|
+
import type { ActiveNode, ColumnConfiguration, GridHost } from '../internal/types.js';
|
|
5
5
|
import { EditingController } from './editing.js';
|
|
6
6
|
import { ExpansionController } from './expansion.js';
|
|
7
7
|
import { FilterController } from './filter.js';
|
|
@@ -57,6 +57,13 @@ export declare class StateController<T extends object> implements ReactiveContro
|
|
|
57
57
|
* {@link ApexGrid.localize} so components can localize via `this.state`.
|
|
58
58
|
*/
|
|
59
59
|
localize(key: GridLocaleKey, params?: LocaleParams, fallback?: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Whether `column` holds numbers (`'number'`, `'currency'`, `'rating'`,
|
|
62
|
+
* `'progress'`), so it filters with the number operands and a numeric term.
|
|
63
|
+
* The one numeric-type rule the core filter applies; features that classify
|
|
64
|
+
* columns should read it here rather than keep their own list.
|
|
65
|
+
*/
|
|
66
|
+
isNumericColumn(column: Pick<ColumnConfiguration<T>, 'type'>): boolean;
|
|
60
67
|
get active(): ActiveNode<T>;
|
|
61
68
|
set active(node: ActiveNode<T>);
|
|
62
69
|
get headerRow(): import("../components/header-row.js").default<T>;
|
|
@@ -77,24 +84,77 @@ export declare class StateController<T extends object> implements ReactiveContro
|
|
|
77
84
|
module<C extends ReactiveController>(id: string): C | undefined;
|
|
78
85
|
/**
|
|
79
86
|
* Runs the post-pipeline row transforms contributed by feature modules
|
|
80
|
-
* implementing {@link RowTransformer}, in
|
|
81
|
-
*
|
|
82
|
-
*
|
|
87
|
+
* implementing {@link RowTransformer}, in ascending
|
|
88
|
+
* {@link RowTransformer.transformOrder} (registration order breaks ties).
|
|
89
|
+
* Returns the input unchanged when no such module is registered, so the
|
|
90
|
+
* community grid path is a no-op pass-through.
|
|
83
91
|
*/
|
|
84
92
|
applyModuleTransforms(rows: T[]): T[];
|
|
93
|
+
/**
|
|
94
|
+
* Whether `row` is a data record, as opposed to a row a feature module
|
|
95
|
+
* synthesized into the view (a group header, a grand-total row). Every
|
|
96
|
+
* consumer that treats the view as records (selection, export, paste, charts,
|
|
97
|
+
* keyboard actions) should skip rows for which this is `false`. A row is
|
|
98
|
+
* synthetic when any {@link RowTransformer} claims it through
|
|
99
|
+
* {@link RowTransformer.isSyntheticRow}. Always `true` for the community grid,
|
|
100
|
+
* which registers no modules, at the cost of one length check.
|
|
101
|
+
*/
|
|
102
|
+
isDataRow(row: T): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* The data records of `rows` (see {@link isDataRow}), in order. Returns `rows`
|
|
105
|
+
* itself, not a copy, when no module synthesizes rows (the community grid).
|
|
106
|
+
*/
|
|
107
|
+
dataRows(rows: ReadonlyArray<T>): ReadonlyArray<T>;
|
|
108
|
+
/**
|
|
109
|
+
* Every data record `rows` (a view) covers, in order: its data rows plus the
|
|
110
|
+
* records a synthesized row hides through
|
|
111
|
+
* {@link RowTransformer.hiddenRecords} (a collapsed group's leaves). This is
|
|
112
|
+
* what Select all selects and a `'view'` export writes. Returns `rows`
|
|
113
|
+
* itself when no module synthesizes rows (the community grid).
|
|
114
|
+
*/
|
|
115
|
+
viewRecords(rows: ReadonlyArray<T>): ReadonlyArray<T>;
|
|
85
116
|
/**
|
|
86
117
|
* Asks feature modules implementing {@link RowPresenter} whether they render
|
|
87
118
|
* the given row as full-width custom content (e.g. a group header). Returns
|
|
88
119
|
* the first non-null result, or `null` when no module owns the row.
|
|
89
120
|
*/
|
|
90
121
|
presentRow(row: T, ctx: RowPresenterContext<T>): PresentedRow | null;
|
|
122
|
+
/**
|
|
123
|
+
* Columns in the `aria-colindex` sequence: the visible columns plus the
|
|
124
|
+
* selection and expansion chrome columns. Shared by `aria-colcount` and the
|
|
125
|
+
* cells that span a whole row.
|
|
126
|
+
*/
|
|
127
|
+
get colCount(): number;
|
|
128
|
+
/**
|
|
129
|
+
* Whether rows carry tree semantics (`aria-level` / `aria-expanded`), which
|
|
130
|
+
* only a `treegrid` supports: the core tree, master-detail, or a feature
|
|
131
|
+
* module that reports {@link RowPresenter.hierarchical} (row grouping, a
|
|
132
|
+
* pivot tree, server-side groups). The grid role is read from here.
|
|
133
|
+
*/
|
|
134
|
+
get hierarchical(): boolean;
|
|
91
135
|
/**
|
|
92
136
|
* Asks feature modules implementing {@link RowAriaProvider} for ARIA
|
|
93
137
|
* tree/expansion semantics on a normal (cell-rendered) row — e.g. pivoting's
|
|
94
138
|
* expandable parent rows. Returns the first non-null result, or `null`.
|
|
95
139
|
*/
|
|
96
140
|
describeRow(row: T, ctx: RowPresenterContext<T>): RowAria | null;
|
|
141
|
+
/**
|
|
142
|
+
* The coordinate-hint label a module gives a row ({@link CoordinateLabeler}),
|
|
143
|
+
* `null` for none, or `undefined` when no module labels rows (the gutter then
|
|
144
|
+
* shows the view position). Only asked while `coordinateHints` is on.
|
|
145
|
+
*/
|
|
146
|
+
rowCoordinate(row: T): string | null | undefined;
|
|
147
|
+
/** The coordinate-hint letter a module gives a column; see {@link rowCoordinate}. */
|
|
148
|
+
columnCoordinate(key: string): string | null | undefined;
|
|
97
149
|
get decorationVersion(): number;
|
|
150
|
+
/**
|
|
151
|
+
* Monotonic token the grid bumps once per data pipeline run, forwarded to
|
|
152
|
+
* each body row and cell, so a cell whose output reads more than its own
|
|
153
|
+
* value (a `cellTemplate` reading other row fields, the tree group cell's
|
|
154
|
+
* chevron) re-renders after an edit, a data change or a tree toggle,
|
|
155
|
+
* although its own value binding did not change.
|
|
156
|
+
*/
|
|
157
|
+
dataVersion: number;
|
|
98
158
|
/**
|
|
99
159
|
* Signals that {@link CellDecorator} output may have changed. Bumps the
|
|
100
160
|
* {@link decorationVersion} and requests a host update so cells re-run their
|
|
@@ -109,6 +169,11 @@ export declare class StateController<T extends object> implements ReactiveContro
|
|
|
109
169
|
* for the community grid (no modules).
|
|
110
170
|
*/
|
|
111
171
|
get hasColumnMenu(): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Whether any feature module implements {@link CellDecorator}, so a cell can
|
|
174
|
+
* skip decoration altogether when none does (the community grid).
|
|
175
|
+
*/
|
|
176
|
+
get hasCellDecorators(): boolean;
|
|
112
177
|
/**
|
|
113
178
|
* Collects per-cell decoration contributed by feature modules implementing
|
|
114
179
|
* {@link CellDecorator}, merging their attribute maps (later modules win on a
|
|
@@ -130,10 +195,12 @@ export declare class StateController<T extends object> implements ReactiveContro
|
|
|
130
195
|
serializeModuleState(): Record<string, unknown>;
|
|
131
196
|
/**
|
|
132
197
|
* Dispatches previously-serialized state back to the matching feature modules
|
|
133
|
-
* (by id) that implement {@link SerializableModule}
|
|
134
|
-
*
|
|
198
|
+
* (by id) that implement {@link SerializableModule}, in registration order.
|
|
199
|
+
* Returns the ids in `data` that no registered module consumed, so the caller
|
|
200
|
+
* can report them instead of counting them as applied. Used by
|
|
201
|
+
* `ApexGrid.setState`.
|
|
135
202
|
*/
|
|
136
|
-
restoreModuleState(data: Record<string, unknown> | undefined):
|
|
203
|
+
restoreModuleState(data: Record<string, unknown> | undefined): string[];
|
|
137
204
|
hostConnected(): void;
|
|
138
205
|
hostUpdate(): void;
|
|
139
206
|
}
|
package/controllers/state.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createContext } from '@lit/context';
|
|
2
|
-
import { isCellDecorator, isCellInteractionHandler, isColumnMenuProvider, isRowAriaProvider, isRowPresenter, isRowTransformer, isSerializableModule, } from '../internal/feature-module.js';
|
|
2
|
+
import { isCellDecorator, isCellInteractionHandler, isColumnMenuProvider, isCoordinateLabeler, isRowAriaProvider, isRowPresenter, isRowTransformer, isSerializableModule, } from '../internal/feature-module.js';
|
|
3
|
+
import { isNumericColumn } from '../internal/utils.js';
|
|
3
4
|
import { EditingController } from './editing.js';
|
|
4
5
|
import { ExpansionController } from './expansion.js';
|
|
5
6
|
import { FilterController } from './filter.js';
|
|
@@ -22,12 +23,15 @@ export class StateController {
|
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
this.#announceToken = (this.#announceToken + 1) % 2;
|
|
25
|
-
this.announcement = this.#announceToken ? message : `${message}
|
|
26
|
+
this.announcement = this.#announceToken ? message : `${message}\u200B`;
|
|
26
27
|
this.host.requestUpdate();
|
|
27
28
|
}
|
|
28
29
|
localize(key, params, fallback) {
|
|
29
30
|
return this.host.localize(key, params, fallback);
|
|
30
31
|
}
|
|
32
|
+
isNumericColumn(column) {
|
|
33
|
+
return isNumericColumn(column);
|
|
34
|
+
}
|
|
31
35
|
get active() {
|
|
32
36
|
return this.navigation.active;
|
|
33
37
|
}
|
|
@@ -56,7 +60,11 @@ export class StateController {
|
|
|
56
60
|
this.modules = new Map();
|
|
57
61
|
this.announcement = '';
|
|
58
62
|
this.#announceToken = 0;
|
|
63
|
+
this.#transformers = [];
|
|
64
|
+
this.#synthesizers = [];
|
|
65
|
+
this.#hooks = new Map();
|
|
59
66
|
this.#decorationVersion = 0;
|
|
67
|
+
this.dataVersion = 0;
|
|
60
68
|
this.host.addController(this);
|
|
61
69
|
this.init();
|
|
62
70
|
}
|
|
@@ -79,39 +87,117 @@ export class StateController {
|
|
|
79
87
|
continue;
|
|
80
88
|
this.modules.set(module.id, module.create(this.host, this));
|
|
81
89
|
}
|
|
90
|
+
if (this.modules.size) {
|
|
91
|
+
const transformers = [];
|
|
92
|
+
for (const controller of this.modules.values()) {
|
|
93
|
+
if (isRowTransformer(controller))
|
|
94
|
+
transformers.push(controller);
|
|
95
|
+
}
|
|
96
|
+
transformers.sort((a, b) => (a.transformOrder ?? 0) - (b.transformOrder ?? 0));
|
|
97
|
+
this.#transformers = transformers;
|
|
98
|
+
this.#synthesizers = transformers.filter((t) => typeof t.isSyntheticRow === 'function');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
#transformers;
|
|
102
|
+
#synthesizers;
|
|
103
|
+
#hooks;
|
|
104
|
+
#withHook(guard) {
|
|
105
|
+
let list = this.#hooks.get(guard);
|
|
106
|
+
if (!list) {
|
|
107
|
+
list = [...this.modules.values()].filter(guard);
|
|
108
|
+
this.#hooks.set(guard, list);
|
|
109
|
+
}
|
|
110
|
+
return list;
|
|
82
111
|
}
|
|
83
112
|
module(id) {
|
|
84
113
|
return this.modules.get(id);
|
|
85
114
|
}
|
|
86
115
|
applyModuleTransforms(rows) {
|
|
87
116
|
let result = rows;
|
|
88
|
-
for (const
|
|
89
|
-
|
|
90
|
-
result = controller.processRows(result);
|
|
91
|
-
}
|
|
117
|
+
for (const transformer of this.#transformers) {
|
|
118
|
+
result = transformer.processRows(result);
|
|
92
119
|
}
|
|
93
120
|
return result;
|
|
94
121
|
}
|
|
95
|
-
|
|
96
|
-
for (const
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
122
|
+
isDataRow(row) {
|
|
123
|
+
for (const transformer of this.#synthesizers) {
|
|
124
|
+
if (transformer.isSyntheticRow(row))
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
dataRows(rows) {
|
|
130
|
+
if (this.#synthesizers.length === 0)
|
|
131
|
+
return rows;
|
|
132
|
+
return rows.filter((row) => this.isDataRow(row));
|
|
133
|
+
}
|
|
134
|
+
viewRecords(rows) {
|
|
135
|
+
if (this.#synthesizers.length === 0)
|
|
136
|
+
return rows;
|
|
137
|
+
const out = [];
|
|
138
|
+
for (const row of rows) {
|
|
139
|
+
if (this.isDataRow(row)) {
|
|
140
|
+
out.push(row);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
for (const transformer of this.#synthesizers) {
|
|
144
|
+
const hidden = transformer.hiddenRecords?.(row);
|
|
145
|
+
if (!hidden?.length)
|
|
146
|
+
continue;
|
|
147
|
+
for (const record of hidden)
|
|
148
|
+
out.push(record);
|
|
149
|
+
break;
|
|
101
150
|
}
|
|
102
151
|
}
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
presentRow(row, ctx) {
|
|
155
|
+
for (const controller of this.#withHook((isRowPresenter))) {
|
|
156
|
+
const presented = controller.presentRow(row, ctx);
|
|
157
|
+
if (presented)
|
|
158
|
+
return presented;
|
|
159
|
+
}
|
|
103
160
|
return null;
|
|
104
161
|
}
|
|
105
|
-
|
|
162
|
+
get colCount() {
|
|
163
|
+
return (this.host.columns.filter((column) => !column.hidden).length +
|
|
164
|
+
(this.selection.showCheckboxColumn ? 1 : 0) +
|
|
165
|
+
(this.expansion.showToggleColumn ? 1 : 0));
|
|
166
|
+
}
|
|
167
|
+
get hierarchical() {
|
|
168
|
+
if (this.tree.enabled || (this.expansion.enabled && this.host.expansion?.detailTemplate)) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
106
171
|
for (const controller of this.modules.values()) {
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
172
|
+
if (controller.hierarchical)
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
describeRow(row, ctx) {
|
|
178
|
+
for (const controller of this.#withHook((isRowAriaProvider))) {
|
|
179
|
+
const aria = controller.describeRow(row, ctx);
|
|
180
|
+
if (aria)
|
|
181
|
+
return aria;
|
|
112
182
|
}
|
|
113
183
|
return null;
|
|
114
184
|
}
|
|
185
|
+
rowCoordinate(row) {
|
|
186
|
+
for (const controller of this.#withHook((isCoordinateLabeler))) {
|
|
187
|
+
const label = controller.rowCoordinate(row);
|
|
188
|
+
if (label !== undefined)
|
|
189
|
+
return label;
|
|
190
|
+
}
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
columnCoordinate(key) {
|
|
194
|
+
for (const controller of this.#withHook((isCoordinateLabeler))) {
|
|
195
|
+
const label = controller.columnCoordinate(key);
|
|
196
|
+
if (label !== undefined)
|
|
197
|
+
return label;
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
115
201
|
#decorationVersion;
|
|
116
202
|
get decorationVersion() {
|
|
117
203
|
return this.#decorationVersion;
|
|
@@ -121,31 +207,25 @@ export class StateController {
|
|
|
121
207
|
this.host.requestUpdate();
|
|
122
208
|
}
|
|
123
209
|
get hasColumnMenu() {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
return false;
|
|
210
|
+
return this.#withHook(isColumnMenuProvider).some((controller) => controller.providesColumnMenu());
|
|
211
|
+
}
|
|
212
|
+
get hasCellDecorators() {
|
|
213
|
+
return this.#withHook(isCellDecorator).length > 0;
|
|
130
214
|
}
|
|
131
215
|
decorateCell(ctx) {
|
|
132
216
|
let attributes = null;
|
|
133
|
-
for (const controller of this
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
Object.assign(attributes, decoration.attributes);
|
|
139
|
-
}
|
|
217
|
+
for (const controller of this.#withHook((isCellDecorator))) {
|
|
218
|
+
const decoration = controller.decorateCell(ctx);
|
|
219
|
+
if (decoration) {
|
|
220
|
+
attributes ??= {};
|
|
221
|
+
Object.assign(attributes, decoration.attributes);
|
|
140
222
|
}
|
|
141
223
|
}
|
|
142
224
|
return attributes ? { attributes } : null;
|
|
143
225
|
}
|
|
144
226
|
handleCellInteraction(interaction) {
|
|
145
|
-
for (const controller of this
|
|
146
|
-
|
|
147
|
-
controller.handleCellInteraction(interaction);
|
|
148
|
-
}
|
|
227
|
+
for (const controller of this.#withHook((isCellInteractionHandler))) {
|
|
228
|
+
controller.handleCellInteraction(interaction);
|
|
149
229
|
}
|
|
150
230
|
}
|
|
151
231
|
serializeModuleState() {
|
|
@@ -159,12 +239,13 @@ export class StateController {
|
|
|
159
239
|
}
|
|
160
240
|
restoreModuleState(data) {
|
|
161
241
|
if (!data)
|
|
162
|
-
return;
|
|
242
|
+
return [];
|
|
163
243
|
for (const [id, controller] of this.modules) {
|
|
164
244
|
if (isSerializableModule(controller) && Object.hasOwn(data, id)) {
|
|
165
245
|
controller.restoreState(data[id]);
|
|
166
246
|
}
|
|
167
247
|
}
|
|
248
|
+
return Object.keys(data).filter((id) => !isSerializableModule(this.modules.get(id)));
|
|
168
249
|
}
|
|
169
250
|
hostConnected() { }
|
|
170
251
|
hostUpdate() {
|
package/controllers/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/controllers/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,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AC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IAOM,oBAAoB;QACzB,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC5C,IAAI,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC;gBACrC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,cAAc,EAAE,CAAC;YACxC,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAOM,kBAAkB,CAAC,IAAyC;QACjE,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,KAAK,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC5C,IAAI,oBAAoB,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;gBAChE,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IAEM,aAAa,KAAI,CAAC;IAElB,UAAU;QACf,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC;QAChC,IAAI,CAAC,eAAe,EAAE,aAAa,EAAE,CAAC;QACtC,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,CAAC;IAChC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAuB,qBAAqB,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\nimport type { ReactiveController } from 'lit';\nimport type { GridLocaleKey, LocaleParams } from '../i18n/index.js';\nimport {\n type CellDecoration,\n type CellDecoratorContext,\n type CellInteraction,\n type GridFeatureModule,\n isCellDecorator,\n isCellInteractionHandler,\n isColumnMenuProvider,\n isRowAriaProvider,\n isRowPresenter,\n isRowTransformer,\n isSerializableModule,\n type PresentedRow,\n type RowAria,\n type RowPresenterContext,\n} from '../internal/feature-module.js';\nimport type { ActiveNode, GridHost } from '../internal/types.js';\nimport { EditingController } from './editing.js';\nimport { ExpansionController } from './expansion.js';\nimport { FilterController } from './filter.js';\nimport { HistoryController } from './history.js';\nimport { NavigationController } from './navigation.js';\nimport { PaginationController } from './pagination.js';\nimport { ReorderController } from './reorder.js';\nimport { ResizeController } from './resize.js';\nimport { RowPinController } from './row-pin.js';\nimport { RowReorderController } from './row-reorder.js';\nimport { SelectionController } from './selection.js';\nimport { SortController } from './sort.js';\nimport { TreeController } from './tree.js';\n\nexport class StateController<T extends object> implements ReactiveController {\n public sorting!: SortController<T>;\n public filtering!: FilterController<T>;\n public navigation!: NavigationController<T>;\n public resizing!: ResizeController<T>;\n public pagination!: PaginationController<T>;\n public reordering!: ReorderController<T>;\n public editing!: EditingController<T>;\n public history!: HistoryController<T>;\n public selection!: SelectionController<T>;\n public expansion!: ExpansionController<T>;\n public tree!: TreeController<T>;\n public rowPin!: RowPinController<T>;\n public rowReorder!: RowReorderController<T>;\n\n /**\n * Optional feature controllers contributed by {@link GridFeatureModule}s,\n * keyed by module id. Empty for the community `<apex-grid>` element; populated\n * by derived grids (e.g. `@apexcharts/grid-enterprise`) that pass modules to\n * the constructor.\n */\n public readonly modules = new Map<string, ReactiveController>();\n\n /**\n * Current message in the grid's polite live region. Bound by the host's\n * `renderLiveRegion()` template; mutated through {@link setAnnouncement}\n * so screen readers re-announce on every change.\n */\n public announcement = '';\n #announceToken = 0;\n\n /**\n * Updates the polite live region's text. Repeats are forced to fire by\n * appending a zero-width space — screen readers ignore unchanged content,\n * so two identical sort announcements wouldn't otherwise be read aloud.\n */\n public setAnnouncement(message: string): void {\n if (!message) {\n this.announcement = '';\n this.host.requestUpdate();\n return;\n }\n this.#announceToken = (this.#announceToken + 1) % 2;\n this.announcement = this.#announceToken ? message : `${message} `;\n this.host.requestUpdate();\n }\n\n /**\n * Resolves a built-in locale key to its display string, honoring the host\n * grid's {@link ApexGrid.localeText} overrides. Thin proxy to\n * {@link ApexGrid.localize} so components can localize via `this.state`.\n */\n public localize(key: GridLocaleKey, params?: LocaleParams, fallback?: string): string {\n return this.host.localize(key, params, fallback);\n }\n\n public get active() {\n return this.navigation.active;\n }\n\n public set active(node: ActiveNode<T>) {\n this.navigation.active = node;\n }\n\n public get headerRow() {\n // @ts-expect-error - Protected member access\n return this.host.headerRow;\n }\n\n public get scrollContainer() {\n // @ts-expect-error - Protected member access\n return this.host.scrollContainer;\n }\n\n public get paginator() {\n // @ts-expect-error - Protected member access\n return this.host.paginator;\n }\n\n public get toolbar() {\n // @ts-expect-error - Protected member access\n return this.host.toolbar;\n }\n\n /**\n * Cumulative pin offsets (in px) keyed by column key. Populated by the\n * {@link GridDOMController} after each layout.\n */\n public get pinOffsets(): Map<unknown, number> {\n // @ts-expect-error - Protected member access\n const dom = this.host.DOM as { pinOffsets?: Map<unknown, number> } | undefined;\n return dom?.pinOffsets ?? new Map();\n }\n\n constructor(\n public host: GridHost<T>,\n private extraModules: ReadonlyArray<GridFeatureModule<T>> = []\n ) {\n this.host.addController(this);\n this.init();\n }\n\n protected init() {\n this.sorting = new SortController(this.host);\n this.filtering = new FilterController(this.host);\n this.navigation = new NavigationController(this.host);\n this.resizing = new ResizeController(this.host);\n this.pagination = new PaginationController(this.host);\n this.reordering = new ReorderController(this.host);\n this.history = new HistoryController(this.host);\n this.editing = new EditingController(this.host, this.history);\n this.selection = new SelectionController(this.host);\n this.expansion = new ExpansionController(this.host);\n this.tree = new TreeController(this.host);\n this.rowPin = new RowPinController(this.host);\n this.rowReorder = new RowReorderController(this.host);\n\n for (const module of this.extraModules) {\n if (this.modules.has(module.id)) continue;\n this.modules.set(module.id, module.create(this.host, this));\n }\n }\n\n /**\n * Look up a feature controller contributed by a {@link GridFeatureModule},\n * by its module id. Returns `undefined` when no such module is registered.\n */\n public module<C extends ReactiveController>(id: string): C | undefined {\n return this.modules.get(id) as C | undefined;\n }\n\n /**\n * Runs the post-pipeline row transforms contributed by feature modules\n * implementing {@link RowTransformer}, in registration order. Returns the\n * input unchanged when no such module is registered — the community grid path\n * is a no-op pass-through.\n */\n public applyModuleTransforms(rows: T[]): T[] {\n let result = rows;\n for (const controller of this.modules.values()) {\n if (isRowTransformer<T>(controller)) {\n result = controller.processRows(result);\n }\n }\n return result;\n }\n\n /**\n * Asks feature modules implementing {@link RowPresenter} whether they render\n * the given row as full-width custom content (e.g. a group header). Returns\n * the first non-null result, or `null` when no module owns the row.\n */\n public presentRow(row: T, ctx: RowPresenterContext<T>): PresentedRow | null {\n for (const controller of this.modules.values()) {\n if (isRowPresenter<T>(controller)) {\n const presented = controller.presentRow(row, ctx);\n if (presented) return presented;\n }\n }\n return null;\n }\n\n /**\n * Asks feature modules implementing {@link RowAriaProvider} for ARIA\n * tree/expansion semantics on a normal (cell-rendered) row — e.g. pivoting's\n * expandable parent rows. Returns the first non-null result, or `null`.\n */\n public describeRow(row: T, ctx: RowPresenterContext<T>): RowAria | null {\n for (const controller of this.modules.values()) {\n if (isRowAriaProvider<T>(controller)) {\n const aria = controller.describeRow(row, ctx);\n if (aria) return aria;\n }\n }\n return null;\n }\n\n /**\n * Monotonic token bumped by {@link bumpDecoration} whenever module-driven cell\n * decoration changes. Forwarded down to each cell as a reactive property so a\n * decoration-only change (e.g. dragging a selection range) re-renders cells\n * without re-running the data pipeline. Always `0` for the community grid.\n */\n #decorationVersion = 0;\n\n public get decorationVersion(): number {\n return this.#decorationVersion;\n }\n\n /**\n * Signals that {@link CellDecorator} output may have changed. Bumps the\n * {@link decorationVersion} and requests a host update so cells re-run their\n * decoration. Called by feature modules after mutating decoration state.\n */\n public bumpDecoration(): void {\n this.#decorationVersion += 1;\n this.host.requestUpdate();\n }\n\n /**\n * Whether any feature module implementing {@link ColumnMenuProvider} offers a\n * column header menu. The header uses this to show its kebab button even on\n * columns that are neither sortable nor resizable, so a module (the enterprise\n * context menu) can surface pin / hide / group / chart actions. Always `false`\n * for the community grid (no modules).\n */\n public get hasColumnMenu(): boolean {\n for (const controller of this.modules.values()) {\n if (isColumnMenuProvider(controller) && controller.providesColumnMenu()) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Collects per-cell decoration contributed by feature modules implementing\n * {@link CellDecorator}, merging their attribute maps (later modules win on a\n * key clash). Returns `null` when no module decorates the cell — the community\n * grid path, where each cell applies nothing.\n */\n public decorateCell(ctx: CellDecoratorContext<T>): CellDecoration | null {\n let attributes: Record<string, string | null | undefined> | null = null;\n for (const controller of this.modules.values()) {\n if (isCellDecorator<T>(controller)) {\n const decoration = controller.decorateCell(ctx);\n if (decoration) {\n attributes ??= {};\n Object.assign(attributes, decoration.attributes);\n }\n }\n }\n return attributes ? { attributes } : null;\n }\n\n /**\n * Forwards a body-cell pointer interaction to every feature module that\n * implements {@link CellInteractionHandler}. No-op for the community grid\n * (no modules); the grid only calls this when modules are registered.\n */\n public handleCellInteraction(interaction: CellInteraction<T>): void {\n for (const controller of this.modules.values()) {\n if (isCellInteractionHandler<T>(controller)) {\n controller.handleCellInteraction(interaction);\n }\n }\n }\n\n /**\n * Collects per-module snapshot state from feature controllers implementing\n * {@link SerializableModule}, keyed by module id. Returns an empty object for\n * the community grid (no modules). Used by `ApexGrid.getState`.\n */\n public serializeModuleState(): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [id, controller] of this.modules) {\n if (isSerializableModule(controller)) {\n out[id] = controller.serializeState();\n }\n }\n return out;\n }\n\n /**\n * Dispatches previously-serialized state back to the matching feature modules\n * (by id) that implement {@link SerializableModule}. Missing ids and unknown\n * modules are ignored. Used by `ApexGrid.setState`.\n */\n public restoreModuleState(data: Record<string, unknown> | undefined): void {\n if (!data) return;\n for (const [id, controller] of this.modules) {\n if (isSerializableModule(controller) && Object.hasOwn(data, id)) {\n controller.restoreState(data[id]);\n }\n }\n }\n\n public hostConnected() {}\n\n public hostUpdate(): void {\n this.headerRow?.requestUpdate();\n this.scrollContainer?.requestUpdate();\n this.paginator?.requestUpdate();\n this.toolbar?.requestUpdate();\n }\n}\n\nexport const gridStateContext = createContext<StateController<any>>('gridStateController');\n"]}
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/controllers/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAKL,eAAe,EACf,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,GAMrB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,eAAe;IA6B1B,cAAc,CAAK;IAOZ,eAAe,CAAC,OAAe;QACpC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,CAAC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MAAM,gBAAgB,GAAG,aAAa,CAAuB,qBAAqB,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\nimport type { ReactiveController } from 'lit';\nimport type { GridLocaleKey, LocaleParams } from '../i18n/index.js';\nimport {\n type CellDecoration,\n type CellDecoratorContext,\n type CellInteraction,\n type GridFeatureModule,\n isCellDecorator,\n isCellInteractionHandler,\n isColumnMenuProvider,\n isCoordinateLabeler,\n isRowAriaProvider,\n isRowPresenter,\n isRowTransformer,\n isSerializableModule,\n type PresentedRow,\n type RowAria,\n type RowAriaProvider,\n type RowPresenterContext,\n type RowTransformer,\n} from '../internal/feature-module.js';\nimport type { ActiveNode, ColumnConfiguration, GridHost } from '../internal/types.js';\nimport { isNumericColumn } from '../internal/utils.js';\nimport { EditingController } from './editing.js';\nimport { ExpansionController } from './expansion.js';\nimport { FilterController } from './filter.js';\nimport { HistoryController } from './history.js';\nimport { NavigationController } from './navigation.js';\nimport { PaginationController } from './pagination.js';\nimport { ReorderController } from './reorder.js';\nimport { ResizeController } from './resize.js';\nimport { RowPinController } from './row-pin.js';\nimport { RowReorderController } from './row-reorder.js';\nimport { SelectionController } from './selection.js';\nimport { SortController } from './sort.js';\nimport { TreeController } from './tree.js';\n\nexport class StateController<T extends object> implements ReactiveController {\n public sorting!: SortController<T>;\n public filtering!: FilterController<T>;\n public navigation!: NavigationController<T>;\n public resizing!: ResizeController<T>;\n public pagination!: PaginationController<T>;\n public reordering!: ReorderController<T>;\n public editing!: EditingController<T>;\n public history!: HistoryController<T>;\n public selection!: SelectionController<T>;\n public expansion!: ExpansionController<T>;\n public tree!: TreeController<T>;\n public rowPin!: RowPinController<T>;\n public rowReorder!: RowReorderController<T>;\n\n /**\n * Optional feature controllers contributed by {@link GridFeatureModule}s,\n * keyed by module id. Empty for the community `<apex-grid>` element; populated\n * by derived grids (e.g. `@apexcharts/grid-enterprise`) that pass modules to\n * the constructor.\n */\n public readonly modules = new Map<string, ReactiveController>();\n\n /**\n * Current message in the grid's polite live region. Bound by the host's\n * `renderLiveRegion()` template; mutated through {@link setAnnouncement}\n * so screen readers re-announce on every change.\n */\n public announcement = '';\n #announceToken = 0;\n\n /**\n * Updates the polite live region's text. Repeats are forced to fire by\n * appending a zero-width space — screen readers ignore unchanged content,\n * so two identical sort announcements wouldn't otherwise be read aloud.\n */\n public setAnnouncement(message: string): void {\n if (!message) {\n this.announcement = '';\n this.host.requestUpdate();\n return;\n }\n this.#announceToken = (this.#announceToken + 1) % 2;\n // Escaped on purpose: a literal zero-width space is invisible in review\n // and an ordinary space would be collapsed out of the accessible text.\n this.announcement = this.#announceToken ? message : `${message}\\u200B`;\n this.host.requestUpdate();\n }\n\n /**\n * Resolves a built-in locale key to its display string, honoring the host\n * grid's {@link ApexGrid.localeText} overrides. Thin proxy to\n * {@link ApexGrid.localize} so components can localize via `this.state`.\n */\n public localize(key: GridLocaleKey, params?: LocaleParams, fallback?: string): string {\n return this.host.localize(key, params, fallback);\n }\n\n /**\n * Whether `column` holds numbers (`'number'`, `'currency'`, `'rating'`,\n * `'progress'`), so it filters with the number operands and a numeric term.\n * The one numeric-type rule the core filter applies; features that classify\n * columns should read it here rather than keep their own list.\n */\n public isNumericColumn(column: Pick<ColumnConfiguration<T>, 'type'>): boolean {\n return isNumericColumn(column);\n }\n\n public get active() {\n return this.navigation.active;\n }\n\n public set active(node: ActiveNode<T>) {\n this.navigation.active = node;\n }\n\n public get headerRow() {\n // @ts-expect-error - Protected member access\n return this.host.headerRow;\n }\n\n public get scrollContainer() {\n // @ts-expect-error - Protected member access\n return this.host.scrollContainer;\n }\n\n public get paginator() {\n // @ts-expect-error - Protected member access\n return this.host.paginator;\n }\n\n public get toolbar() {\n // @ts-expect-error - Protected member access\n return this.host.toolbar;\n }\n\n /**\n * Cumulative pin offsets (in px) keyed by column key. Populated by the\n * {@link GridDOMController} after each layout.\n */\n public get pinOffsets(): Map<unknown, number> {\n // @ts-expect-error - Protected member access\n const dom = this.host.DOM as { pinOffsets?: Map<unknown, number> } | undefined;\n return dom?.pinOffsets ?? new Map();\n }\n\n constructor(\n public host: GridHost<T>,\n private extraModules: ReadonlyArray<GridFeatureModule<T>> = []\n ) {\n this.host.addController(this);\n this.init();\n }\n\n protected init() {\n this.sorting = new SortController(this.host);\n this.filtering = new FilterController(this.host);\n this.navigation = new NavigationController(this.host);\n this.resizing = new ResizeController(this.host);\n this.pagination = new PaginationController(this.host);\n this.reordering = new ReorderController(this.host);\n this.history = new HistoryController(this.host);\n this.editing = new EditingController(this.host, this.history);\n this.selection = new SelectionController(this.host);\n this.expansion = new ExpansionController(this.host);\n this.tree = new TreeController(this.host);\n this.rowPin = new RowPinController(this.host);\n this.rowReorder = new RowReorderController(this.host);\n\n for (const module of this.extraModules) {\n if (this.modules.has(module.id)) continue;\n this.modules.set(module.id, module.create(this.host, this));\n }\n\n // Resolve the row transforms once, in their declared order. Array sort is\n // stable, so equal (or unset) orders keep registration order.\n if (this.modules.size) {\n const transformers: RowTransformer<T>[] = [];\n for (const controller of this.modules.values()) {\n if (isRowTransformer<T>(controller)) transformers.push(controller);\n }\n transformers.sort((a, b) => (a.transformOrder ?? 0) - (b.transformOrder ?? 0));\n this.#transformers = transformers;\n this.#synthesizers = transformers.filter((t) => typeof t.isSyntheticRow === 'function');\n }\n }\n\n /** {@link RowTransformer}s sorted by `transformOrder`. Empty for the community grid. */\n #transformers: ReadonlyArray<RowTransformer<T>> = [];\n /** The transformers that can synthesize rows. Empty for the community grid. */\n #synthesizers: ReadonlyArray<RowTransformer<T>> = [];\n\n /** The controllers each hook guard matched, keyed by the guard. */\n #hooks = new Map<unknown, unknown[]>();\n\n /**\n * The module controllers implementing a hook, in registration order. The\n * module set is fixed once {@link init} returns (modules are passed to the\n * constructor only), so each hook's list is resolved on first use and the\n * per-row and per-cell dispatchers walk it instead of guarding every module.\n */\n #withHook<C>(guard: (controller: unknown) => controller is C): C[] {\n let list = this.#hooks.get(guard);\n if (!list) {\n list = [...this.modules.values()].filter(guard);\n this.#hooks.set(guard, list);\n }\n return list as C[];\n }\n\n /**\n * Look up a feature controller contributed by a {@link GridFeatureModule},\n * by its module id. Returns `undefined` when no such module is registered.\n */\n public module<C extends ReactiveController>(id: string): C | undefined {\n return this.modules.get(id) as C | undefined;\n }\n\n /**\n * Runs the post-pipeline row transforms contributed by feature modules\n * implementing {@link RowTransformer}, in ascending\n * {@link RowTransformer.transformOrder} (registration order breaks ties).\n * Returns the input unchanged when no such module is registered, so the\n * community grid path is a no-op pass-through.\n */\n public applyModuleTransforms(rows: T[]): T[] {\n let result = rows;\n for (const transformer of this.#transformers) {\n result = transformer.processRows(result);\n }\n return result;\n }\n\n /**\n * Whether `row` is a data record, as opposed to a row a feature module\n * synthesized into the view (a group header, a grand-total row). Every\n * consumer that treats the view as records (selection, export, paste, charts,\n * keyboard actions) should skip rows for which this is `false`. A row is\n * synthetic when any {@link RowTransformer} claims it through\n * {@link RowTransformer.isSyntheticRow}. Always `true` for the community grid,\n * which registers no modules, at the cost of one length check.\n */\n public isDataRow(row: T): boolean {\n for (const transformer of this.#synthesizers) {\n if (transformer.isSyntheticRow!(row)) return false;\n }\n return true;\n }\n\n /**\n * The data records of `rows` (see {@link isDataRow}), in order. Returns `rows`\n * itself, not a copy, when no module synthesizes rows (the community grid).\n */\n public dataRows(rows: ReadonlyArray<T>): ReadonlyArray<T> {\n if (this.#synthesizers.length === 0) return rows;\n return rows.filter((row) => this.isDataRow(row));\n }\n\n /**\n * Every data record `rows` (a view) covers, in order: its data rows plus the\n * records a synthesized row hides through\n * {@link RowTransformer.hiddenRecords} (a collapsed group's leaves). This is\n * what Select all selects and a `'view'` export writes. Returns `rows`\n * itself when no module synthesizes rows (the community grid).\n */\n public viewRecords(rows: ReadonlyArray<T>): ReadonlyArray<T> {\n if (this.#synthesizers.length === 0) return rows;\n const out: T[] = [];\n for (const row of rows) {\n if (this.isDataRow(row)) {\n out.push(row);\n continue;\n }\n for (const transformer of this.#synthesizers) {\n const hidden = transformer.hiddenRecords?.(row);\n if (!hidden?.length) continue;\n // A loop, not push(...hidden): a collapsed group can hold more leaves\n // than the engine accepts as call arguments.\n for (const record of hidden) out.push(record);\n break;\n }\n }\n return out;\n }\n\n /**\n * Asks feature modules implementing {@link RowPresenter} whether they render\n * the given row as full-width custom content (e.g. a group header). Returns\n * the first non-null result, or `null` when no module owns the row.\n */\n public presentRow(row: T, ctx: RowPresenterContext<T>): PresentedRow | null {\n for (const controller of this.#withHook(isRowPresenter<T>)) {\n const presented = controller.presentRow(row, ctx);\n if (presented) return presented;\n }\n return null;\n }\n\n /**\n * Columns in the `aria-colindex` sequence: the visible columns plus the\n * selection and expansion chrome columns. Shared by `aria-colcount` and the\n * cells that span a whole row.\n */\n public get colCount(): number {\n return (\n this.host.columns.filter((column) => !column.hidden).length +\n (this.selection.showCheckboxColumn ? 1 : 0) +\n (this.expansion.showToggleColumn ? 1 : 0)\n );\n }\n\n /**\n * Whether rows carry tree semantics (`aria-level` / `aria-expanded`), which\n * only a `treegrid` supports: the core tree, master-detail, or a feature\n * module that reports {@link RowPresenter.hierarchical} (row grouping, a\n * pivot tree, server-side groups). The grid role is read from here.\n */\n public get hierarchical(): boolean {\n // Master-detail rows can expand once there is a detail to show.\n if (this.tree.enabled || (this.expansion.enabled && this.host.expansion?.detailTemplate)) {\n return true;\n }\n for (const controller of this.modules.values()) {\n if ((controller as RowAriaProvider<T>).hierarchical) return true;\n }\n return false;\n }\n\n /**\n * Asks feature modules implementing {@link RowAriaProvider} for ARIA\n * tree/expansion semantics on a normal (cell-rendered) row — e.g. pivoting's\n * expandable parent rows. Returns the first non-null result, or `null`.\n */\n public describeRow(row: T, ctx: RowPresenterContext<T>): RowAria | null {\n for (const controller of this.#withHook(isRowAriaProvider<T>)) {\n const aria = controller.describeRow(row, ctx);\n if (aria) return aria;\n }\n return null;\n }\n\n /**\n * The coordinate-hint label a module gives a row ({@link CoordinateLabeler}),\n * `null` for none, or `undefined` when no module labels rows (the gutter then\n * shows the view position). Only asked while `coordinateHints` is on.\n */\n public rowCoordinate(row: T): string | null | undefined {\n for (const controller of this.#withHook(isCoordinateLabeler<T>)) {\n const label = controller.rowCoordinate(row);\n if (label !== undefined) return label;\n }\n return undefined;\n }\n\n /** The coordinate-hint letter a module gives a column; see {@link rowCoordinate}. */\n public columnCoordinate(key: string): string | null | undefined {\n for (const controller of this.#withHook(isCoordinateLabeler<T>)) {\n const label = controller.columnCoordinate(key);\n if (label !== undefined) return label;\n }\n return undefined;\n }\n\n /**\n * Monotonic token bumped by {@link bumpDecoration} whenever module-driven cell\n * decoration changes. Forwarded down to each cell as a reactive property so a\n * decoration-only change (e.g. dragging a selection range) re-decorates cells\n * without re-running the data pipeline. Always `0` for the community grid.\n */\n #decorationVersion = 0;\n\n public get decorationVersion(): number {\n return this.#decorationVersion;\n }\n\n /**\n * Monotonic token the grid bumps once per data pipeline run, forwarded to\n * each body row and cell, so a cell whose output reads more than its own\n * value (a `cellTemplate` reading other row fields, the tree group cell's\n * chevron) re-renders after an edit, a data change or a tree toggle,\n * although its own value binding did not change.\n */\n public dataVersion = 0;\n\n /**\n * Signals that {@link CellDecorator} output may have changed. Bumps the\n * {@link decorationVersion} and requests a host update so cells re-run their\n * decoration. Called by feature modules after mutating decoration state.\n */\n public bumpDecoration(): void {\n this.#decorationVersion += 1;\n this.host.requestUpdate();\n }\n\n /**\n * Whether any feature module implementing {@link ColumnMenuProvider} offers a\n * column header menu. The header uses this to show its kebab button even on\n * columns that are neither sortable nor resizable, so a module (the enterprise\n * context menu) can surface pin / hide / group / chart actions. Always `false`\n * for the community grid (no modules).\n */\n public get hasColumnMenu(): boolean {\n return this.#withHook(isColumnMenuProvider).some((controller) =>\n controller.providesColumnMenu()\n );\n }\n\n /**\n * Whether any feature module implements {@link CellDecorator}, so a cell can\n * skip decoration altogether when none does (the community grid).\n */\n public get hasCellDecorators(): boolean {\n return this.#withHook(isCellDecorator).length > 0;\n }\n\n /**\n * Collects per-cell decoration contributed by feature modules implementing\n * {@link CellDecorator}, merging their attribute maps (later modules win on a\n * key clash). Returns `null` when no module decorates the cell — the community\n * grid path, where each cell applies nothing.\n */\n public decorateCell(ctx: CellDecoratorContext<T>): CellDecoration | null {\n let attributes: Record<string, string | null | undefined> | null = null;\n for (const controller of this.#withHook(isCellDecorator<T>)) {\n const decoration = controller.decorateCell(ctx);\n if (decoration) {\n attributes ??= {};\n Object.assign(attributes, decoration.attributes);\n }\n }\n return attributes ? { attributes } : null;\n }\n\n /**\n * Forwards a body-cell pointer interaction to every feature module that\n * implements {@link CellInteractionHandler}. No-op for the community grid\n * (no modules); the grid only calls this when modules are registered.\n */\n public handleCellInteraction(interaction: CellInteraction<T>): void {\n for (const controller of this.#withHook(isCellInteractionHandler<T>)) {\n controller.handleCellInteraction(interaction);\n }\n }\n\n /**\n * Collects per-module snapshot state from feature controllers implementing\n * {@link SerializableModule}, keyed by module id. Returns an empty object for\n * the community grid (no modules). Used by `ApexGrid.getState`.\n */\n public serializeModuleState(): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [id, controller] of this.modules) {\n if (isSerializableModule(controller)) {\n out[id] = controller.serializeState();\n }\n }\n return out;\n }\n\n /**\n * Dispatches previously-serialized state back to the matching feature modules\n * (by id) that implement {@link SerializableModule}, in registration order.\n * Returns the ids in `data` that no registered module consumed, so the caller\n * can report them instead of counting them as applied. Used by\n * `ApexGrid.setState`.\n */\n public restoreModuleState(data: Record<string, unknown> | undefined): string[] {\n if (!data) return [];\n for (const [id, controller] of this.modules) {\n if (isSerializableModule(controller) && Object.hasOwn(data, id)) {\n controller.restoreState(data[id]);\n }\n }\n return Object.keys(data).filter((id) => !isSerializableModule(this.modules.get(id)));\n }\n\n public hostConnected() {}\n\n public hostUpdate(): void {\n this.headerRow?.requestUpdate();\n this.scrollContainer?.requestUpdate();\n this.paginator?.requestUpdate();\n this.toolbar?.requestUpdate();\n }\n}\n\nexport const gridStateContext = createContext<StateController<any>>('gridStateController');\n"]}
|
package/controllers/tree.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface TreeRowMeta {
|
|
|
13
13
|
hasChildren: boolean;
|
|
14
14
|
/** Stable key for the row (path-joined string). Useful for keyed reconciliation. */
|
|
15
15
|
key: string;
|
|
16
|
-
/** Last path segment
|
|
16
|
+
/** Last path segment, used as the group-column label for synthesized parents. */
|
|
17
17
|
label: string;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
@@ -21,19 +21,22 @@ export interface TreeRowMeta {
|
|
|
21
21
|
*
|
|
22
22
|
* @remarks
|
|
23
23
|
* Tree mode keeps the data array flat. Each row's hierarchy is derived from a
|
|
24
|
-
* user-supplied `getDataPath` callback
|
|
25
|
-
* controller:
|
|
24
|
+
* user-supplied `getDataPath` callback that returns the row's path from the
|
|
25
|
+
* root (the flat-array "tree data" pattern). The controller:
|
|
26
26
|
*
|
|
27
27
|
* 1. Builds an in-memory tree from the post-sort, post-filter rows.
|
|
28
|
-
* 2. Synthesizes parent nodes for any path level that lacks a backing row
|
|
28
|
+
* 2. Synthesizes parent nodes for any path level that lacks a backing row
|
|
29
|
+
* in the data. A level whose own row was filtered out shows that row.
|
|
29
30
|
* 3. Walks the tree honouring the current expansion set and emits a flat
|
|
30
31
|
* list of rows in display order.
|
|
31
32
|
* 4. Records per-row metadata (depth, hasChildren) that the cell renderer
|
|
32
33
|
* reads to draw the chevron + indentation.
|
|
33
34
|
*
|
|
34
|
-
* Expansion state is split into two sets
|
|
35
|
+
* Expansion state is split into two sets: `expanded` for rows that have
|
|
35
36
|
* backing data (keyed by reference, so it survives sort/filter), and
|
|
36
|
-
* `expandedKeys` for synthesized parents (keyed by their path string).
|
|
37
|
+
* `expandedKeys` for synthesized parents (keyed by their path string). Both
|
|
38
|
+
* follow a data refresh: entries whose row or path left the data are dropped,
|
|
39
|
+
* and `defaultExpanded` applies only to parents not seen before.
|
|
37
40
|
*/
|
|
38
41
|
export declare class TreeController<T extends object> implements ReactiveController {
|
|
39
42
|
#private;
|
|
@@ -42,6 +45,7 @@ export declare class TreeController<T extends object> implements ReactiveControl
|
|
|
42
45
|
expandedKeys: Set<string>;
|
|
43
46
|
constructor(host: GridHost<T>);
|
|
44
47
|
hostConnected(): void;
|
|
48
|
+
hostDisconnected(): void;
|
|
45
49
|
/** Whether tree mode is enabled at the grid level. */
|
|
46
50
|
get enabled(): boolean;
|
|
47
51
|
/** The configured indentation, in pixels, per depth level. */
|
|
@@ -79,7 +83,7 @@ export declare class TreeController<T extends object> implements ReactiveControl
|
|
|
79
83
|
*/
|
|
80
84
|
process(input: ReadonlyArray<T>): T[];
|
|
81
85
|
/**
|
|
82
|
-
* Replaces the expansion state wholesale
|
|
86
|
+
* Replaces the expansion state wholesale. Used by `ApexGrid.setState` to
|
|
83
87
|
* restore a snapshot. Sets both the backing-row set and the synthesized-parent
|
|
84
88
|
* key set directly (no `treeRowExpanding`/`treeRowExpanded` events), marks
|
|
85
89
|
* `defaultExpanded` as already applied so the next pipeline pass treats the
|
|
@@ -87,9 +91,10 @@ export declare class TreeController<T extends object> implements ReactiveControl
|
|
|
87
91
|
*/
|
|
88
92
|
restoreExpansion(expanded: Iterable<T>, expandedKeys: Iterable<string>): void;
|
|
89
93
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
94
|
+
* Reconciles the expansion state with replaced data. Called from the data
|
|
95
|
+
* watcher when the input array is replaced wholesale: expanded rows that
|
|
96
|
+
* left the data are dropped now, stale path keys on the next full build,
|
|
97
|
+
* and the next pass applies `defaultExpanded` to parents not seen before.
|
|
93
98
|
*/
|
|
94
99
|
resetForDataChange(): void;
|
|
95
100
|
}
|
package/controllers/tree.js
CHANGED
|
Binary file
|