@toolbox-web/grid-angular 1.9.1 → 2.0.0-beta
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/fesm2022/toolbox-web-grid-angular-features-editing.mjs +2317 -4
- package/fesm2022/toolbox-web-grid-angular-features-editing.mjs.map +1 -1
- package/fesm2022/toolbox-web-grid-angular-features-filtering.mjs +91 -2
- package/fesm2022/toolbox-web-grid-angular-features-filtering.mjs.map +1 -1
- package/fesm2022/toolbox-web-grid-angular-features-master-detail.mjs +97 -4
- package/fesm2022/toolbox-web-grid-angular-features-master-detail.mjs.map +1 -1
- package/fesm2022/toolbox-web-grid-angular-features-pinned-rows.mjs +1 -15
- package/fesm2022/toolbox-web-grid-angular-features-pinned-rows.mjs.map +1 -1
- package/fesm2022/toolbox-web-grid-angular-features-responsive.mjs +109 -3
- package/fesm2022/toolbox-web-grid-angular-features-responsive.mjs.map +1 -1
- package/fesm2022/toolbox-web-grid-angular-features-shell.mjs +452 -0
- package/fesm2022/toolbox-web-grid-angular-features-shell.mjs.map +1 -1
- package/fesm2022/toolbox-web-grid-angular.mjs +740 -4649
- package/fesm2022/toolbox-web-grid-angular.mjs.map +1 -1
- package/package.json +2 -6
- package/types/toolbox-web-grid-angular-features-editing.d.ts +1181 -4
- package/types/toolbox-web-grid-angular-features-editing.d.ts.map +1 -1
- package/types/toolbox-web-grid-angular-features-filtering.d.ts +102 -7
- package/types/toolbox-web-grid-angular-features-filtering.d.ts.map +1 -1
- package/types/toolbox-web-grid-angular-features-master-detail.d.ts +88 -4
- package/types/toolbox-web-grid-angular-features-master-detail.d.ts.map +1 -1
- package/types/toolbox-web-grid-angular-features-pinned-rows.d.ts +2 -7
- package/types/toolbox-web-grid-angular-features-pinned-rows.d.ts.map +1 -1
- package/types/toolbox-web-grid-angular-features-responsive.d.ts +109 -3
- package/types/toolbox-web-grid-angular-features-responsive.d.ts.map +1 -1
- package/types/toolbox-web-grid-angular-features-shell.d.ts +229 -0
- package/types/toolbox-web-grid-angular-features-shell.d.ts.map +1 -1
- package/types/toolbox-web-grid-angular.d.ts +483 -2929
- package/types/toolbox-web-grid-angular.d.ts.map +1 -1
- package/fesm2022/toolbox-web-grid-angular-features-reorder-rows.mjs +0 -70
- package/fesm2022/toolbox-web-grid-angular-features-reorder-rows.mjs.map +0 -1
- package/types/toolbox-web-grid-angular-features-reorder-rows.d.ts +0 -25
- package/types/toolbox-web-grid-angular-features-reorder-rows.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbox-web-grid-angular-features-filtering.mjs","sources":["../../../../libs/grid-angular/features/filtering/src/grid-filtering.directive.ts","../../../../libs/grid-angular/features/filtering/src/index.ts","../../../../libs/grid-angular/features/filtering/src/toolbox-web-grid-angular-features-filtering.ts"],"sourcesContent":["/**\n * `GridFilteringDirective` — attribute-selector directive that owns the\n * `filtering` input and the `filterChange` output on `<tbw-grid>`.\n *\n * ## Why this exists\n *\n * Historically these bindings lived on the central `Grid` directive in\n * `@toolbox-web/grid-angular`. That meant the typed surface for the\n * filtering plugin shipped in the core bundle of every consumer, even those\n * that never imported the filtering feature. Moving them here lets the\n * surface tree-shake away with the rest of the feature when it is not\n * imported, matching the philosophy of the React / Vue adapters and the\n * web-component core (where unloaded plugins simply don't exist on the\n * element).\n *\n * ## Usage\n *\n * ```typescript\n * import { Component } from '@angular/core';\n * import { Grid } from '@toolbox-web/grid-angular';\n * import { GridFilteringDirective } from '@toolbox-web/grid-angular/features/filtering';\n *\n * @Component({\n * selector: 'app-grid',\n * imports: [Grid, GridFilteringDirective],\n * template: `\n * <tbw-grid [rows]=\"rows\" [filtering]=\"true\" (filterChange)=\"onFilter($event)\" />\n * `,\n * })\n * export class AppGridComponent {}\n * ```\n *\n * ## Backward compatibility (v1.x)\n *\n * The matching `filtering` input and `filterChange` output also still exist\n * on `Grid` (marked `@deprecated`) so existing apps that bind them without\n * importing `GridFilteringDirective` continue to work — those will be\n * removed in v2.0.0. When both this directive and the deprecated bindings\n * are present, the directive wins via the per-grid claims registry in\n * `internal/feature-claims.ts`: `Grid` consults the registry and skips its\n * own plugin creation + event wiring for any claimed feature.\n *\n * @category Directive\n */\nimport { Directive, ElementRef, inject, input, OnDestroy, OnInit, output, type Type } from '@angular/core';\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport {\n claimEvent,\n registerFeatureClaim,\n unclaimEvent,\n unregisterFeatureClaim,\n type FilterPanel,\n} from '@toolbox-web/grid-angular';\nimport type { FilterConfig as CoreFilterConfig, FilterChangeDetail } from '@toolbox-web/grid/plugins/filtering';\n\n/**\n * Angular-specific filter config that allows an Angular component class as\n * the plugin-level `filterPanelRenderer`.\n *\n * Extends the core `FilterConfig` to accept a `Type<FilterPanel>` for\n * `filterPanelRenderer` in addition to the vanilla\n * `(container, params) => void` signature. Bridging to vanilla DOM is handled\n * by the side-effect import `@toolbox-web/grid-angular/features/filtering`.\n *\n * Re-exported from the feature entry under the same name as the core type\n * so Angular consumers see a single canonical `FilterConfig` from\n * `@toolbox-web/grid-angular/features/filtering`.\n *\n * @since 1.7.1\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FilterConfig<TRow = any> = Omit<CoreFilterConfig<TRow>, 'filterPanelRenderer'> & {\n filterPanelRenderer?: CoreFilterConfig<TRow>['filterPanelRenderer'] | Type<FilterPanel>;\n};\n\n/**\n * Owns the `[filtering]` input and `(filterChange)` output on `<tbw-grid>`.\n *\n * Selector matches when *either* binding is present so users can pick the\n * style that suits their template — both go through the same claim and the\n * same wiring.\n * @category Directive\n */\n@Directive({\n selector: 'tbw-grid[filtering], tbw-grid[filterChange]',\n standalone: true,\n})\nexport class GridFilteringDirective implements OnInit, OnDestroy {\n private readonly elementRef = inject(ElementRef<DataGridElement>);\n\n /**\n * Enable column filtering. Identical semantics to the deprecated input on\n * `Grid` — this directive owns the binding when both are present.\n *\n * @example\n * ```html\n * <tbw-grid [filtering]=\"true\" />\n * <tbw-grid [filtering]=\"{ debounceMs: 200 }\" />\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly filtering = input<boolean | FilterConfig<any>>();\n\n /**\n * Emitted when filter values change.\n *\n * @example\n * ```html\n * <tbw-grid (filterChange)=\"onFilterChange($event)\" />\n * ```\n */\n readonly filterChange = output<FilterChangeDetail>();\n\n // Listener kept so we can detach in `ngOnDestroy`.\n private listener?: (e: Event) => void;\n\n constructor() {\n const grid = this.elementRef.nativeElement;\n // Tell `Grid` we own this feature's input. Reading `this.filtering()`\n // inside the getter establishes a reactive dependency in `Grid`'s\n // `createFeaturePlugins` effect — when our input changes, that effect\n // re-runs and the plugin config is updated.\n registerFeatureClaim(grid, 'filtering', () => this.filtering());\n // Tell `Grid` we own the matching event so it doesn't double-emit on\n // its own deprecated `filterChange` output.\n claimEvent(grid, 'filter-change');\n }\n\n ngOnInit(): void {\n const grid = this.elementRef.nativeElement;\n this.listener = (e: Event) => {\n this.filterChange.emit((e as CustomEvent<FilterChangeDetail>).detail);\n };\n grid.addEventListener('filter-change', this.listener);\n }\n\n ngOnDestroy(): void {\n const grid = this.elementRef.nativeElement;\n if (this.listener) {\n grid.removeEventListener('filter-change', this.listener);\n this.listener = undefined;\n }\n // Drop the claims so that, if the directive is removed via *ngIf but\n // the host `<tbw-grid>` survives, `Grid`'s deprecated bindings take\n // back over without leaving stale ownership behind.\n unregisterFeatureClaim(grid, 'filtering');\n unclaimEvent(grid, 'filter-change');\n }\n}\n","/**\n * Filtering feature for @toolbox-web/grid-angular\n *\n * Two ways to use:\n *\n * 1. **Recommended (tree-shakeable surface):** add `GridFilteringDirective`\n * to your component's `imports`. The directive owns the `[filtering]`\n * input and `(filterChange)` output, so the typed surface tree-shakes\n * away when the feature is not imported.\n * 2. **Legacy (non-breaking, deprecated):** side-effect import the feature\n * entry; the matching `[filtering]` / `(filterChange)` bindings on the\n * central `Grid` directive will work as in v1.x. These bindings on `Grid`\n * are marked `@deprecated` and will be removed in v2.0.0.\n *\n * Either way `injectGridFiltering()` is available for programmatic control.\n *\n * @example Recommended (directive-owned binding)\n * ```typescript\n * import { Grid } from '@toolbox-web/grid-angular';\n * import { GridFilteringDirective } from '@toolbox-web/grid-angular/features/filtering';\n *\n * @Component({\n * imports: [Grid, GridFilteringDirective],\n * template: `<tbw-grid [filtering]=\"true\" (filterChange)=\"onChange($event)\" />`,\n * })\n * ```\n *\n * @example Legacy (deprecated; works without importing the directive)\n * ```typescript\n * import '@toolbox-web/grid-angular/features/filtering';\n *\n * <tbw-grid [filtering]=\"true\" />\n * <tbw-grid [filtering]=\"{ debounceMs: 200 }\" />\n * ```\n *\n * @example Using injectGridFiltering\n * ```typescript\n * import { injectGridFiltering } from '@toolbox-web/grid-angular/features/filtering';\n *\n * @Component({...})\n * export class MyComponent {\n * private filtering = injectGridFiltering();\n *\n * filterByStatus(status: string) {\n * this.filtering.setFilter('status', { operator: 'equals', value: status });\n * }\n * }\n * ```\n *\n * @packageDocumentation\n */\n\nimport { afterNextRender, DestroyRef, ElementRef, inject, signal, type Signal, type Type } from '@angular/core';\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport {\n isComponentClass,\n registerFeatureConfigPreprocessor,\n registerFilterPanelTypeDefaultBridge,\n type GridAdapter,\n} from '@toolbox-web/grid-angular';\nimport '@toolbox-web/grid/features/filtering';\nimport {\n FilteringPlugin,\n type BlankMode,\n type FilterConfig as CoreFilterConfig,\n type FilterModel,\n type FilterPanelParams,\n} from '@toolbox-web/grid/plugins/filtering';\nexport type { _Augmentation as _FilteringAugmentation } from '@toolbox-web/grid/features/filtering';\n\n// Attribute-selector directive that owns the `[filtering]` input and\n// `(filterChange)` output on `<tbw-grid>`. Add to your component's `imports`\n// alongside `Grid` to opt into the feature directly via the binding. The\n// matching deprecated bindings on `Grid` remain as a v1.x compatibility\n// shim and will be removed in v2.0.0.\nexport { GridFilteringDirective } from './grid-filtering.directive';\nexport type { FilterConfig } from './grid-filtering.directive';\n\n// ---------------------------------------------------------------------------\n// Re-exports from `@toolbox-web/grid-angular` (main entry).\n//\n// `BaseFilterPanel` is filtering-specific (implements `FilterPanel` from the\n// filtering plugin). It still physically lives in the main entry today, but\n// is re-exported here so consumers can import it from the feature entry that\n// owns the runtime behaviour. The same symbol is `@deprecated` on the main\n// entry; in v2.0.0 the source will physically move into this secondary entry\n// and the deprecated re-export on the main entry will be removed.\n// ---------------------------------------------------------------------------\nexport { BaseFilterPanel } from '@toolbox-web/grid-angular';\n\n// Bridge any Angular component classes used as `filterPanelRenderer` (in\n// `gridConfig.typeDefaults` or via `provideGridTypeDefaults`) to the\n// `(container, params) => void` form required by FilteringPlugin. Without\n// this import, component-class filterPanelRenderers are silently dropped \\u2014\n// the same precondition as the FilteringPlugin itself (TBW031).\nregisterFilterPanelTypeDefaultBridge((rendererValue: unknown, adapter: GridAdapter) => {\n const componentClass = rendererValue as Type<unknown>;\n const mount = adapter.mountComponentRenderer<FilterPanelParams>(componentClass, (params) => ({ params }));\n return (container: HTMLElement, params: FilterPanelParams) => {\n container.appendChild(mount(params).hostElement);\n };\n});\n\n/**\n * Bridge an Angular component class used as the plugin-level\n * `filterPanelRenderer` (in `FilterConfig`) to the `(container, params) => void`\n * form required by FilteringPlugin. Mirrors `registerFilterPanelTypeDefaultBridge`\n * above, but for the plugin-wide renderer rather than per-type defaults.\n *\n * Without this preprocessor, passing a component class as\n * `filtering.filterPanelRenderer` would be invoked as a function at render\n * time and crash.\n *\n * @since 1.7.1\n */\nregisterFeatureConfigPreprocessor('filtering', (config, adapter) => {\n if (!config || typeof config === 'boolean' || typeof config !== 'object') return config;\n const cfg = config as CoreFilterConfig;\n if (!isComponentClass(cfg.filterPanelRenderer)) return config;\n\n const componentClass = cfg.filterPanelRenderer as Type<unknown>;\n const mount = adapter.mountComponentRenderer<FilterPanelParams>(componentClass, (params) => ({ params }));\n const filterPanelRenderer: CoreFilterConfig['filterPanelRenderer'] = (container, params) => {\n container.appendChild(mount(params).hostElement);\n };\n return { ...cfg, filterPanelRenderer };\n});\n\n/**\n * Filtering methods returned from injectGridFiltering.\n *\n * Uses lazy discovery - the grid is found on first method call, not during initialization.\n */\nexport interface FilteringMethods {\n /**\n * Set a filter on a specific field.\n * @param field - The field name to filter\n * @param filter - Filter configuration, or null to remove\n * @param options - `{ silent: true }` applies the filter without emitting `filter-change`\n */\n setFilter: (field: string, filter: Omit<FilterModel, 'field'> | null, options?: { silent?: boolean }) => void;\n\n /**\n * Get the current filter for a field.\n */\n getFilter: (field: string) => FilterModel | undefined;\n\n /**\n * Get all active filters.\n */\n getFilters: () => FilterModel[];\n\n /**\n * Set all filters at once (replaces existing).\n * @param options - `{ silent: true }` applies filters without emitting `filter-change`\n */\n setFilterModel: (filters: FilterModel[], options?: { silent?: boolean }) => void;\n\n /**\n * Clear all active filters.\n * @param options - `{ silent: true }` clears filters without emitting `filter-change`\n */\n clearAllFilters: (options?: { silent?: boolean }) => void;\n\n /**\n * Clear filter for a specific field.\n * @param options - `{ silent: true }` clears filter without emitting `filter-change`\n */\n clearFieldFilter: (field: string, options?: { silent?: boolean }) => void;\n\n /**\n * Check if a field has an active filter.\n */\n isFieldFiltered: (field: string) => boolean;\n\n /**\n * Get the count of rows after filtering.\n */\n getFilteredRowCount: () => number;\n\n /**\n * Get unique values for a field (for building filter dropdowns).\n */\n getUniqueValues: (field: string) => unknown[];\n\n /**\n * Get set filters whose values no longer match any rows in the current data.\n */\n getStaleFilters: () => FilterModel[];\n\n /**\n * Get the current blank mode for a field.\n */\n getBlankMode: (field: string) => BlankMode;\n\n /**\n * Toggle blank filter mode for a field.\n */\n toggleBlankFilter: (field: string, mode: BlankMode) => void;\n\n /**\n * Signal indicating if grid is ready.\n */\n isReady: Signal<boolean>;\n}\n\n/**\n * Angular inject function for programmatic filter control.\n *\n * Uses **lazy grid discovery** - the grid element is found when methods are called,\n * not during initialization.\n *\n * @example\n * ```typescript\n * import { Component } from '@angular/core';\n * import { Grid } from '@toolbox-web/grid-angular';\n * import '@toolbox-web/grid-angular/features/filtering';\n * import { injectGridFiltering } from '@toolbox-web/grid-angular/features/filtering';\n *\n * @Component({\n * selector: 'app-my-grid',\n * imports: [Grid],\n * template: `\n * <input (input)=\"applyFilter($event)\" placeholder=\"Filter by name...\" />\n * <span>{{ filtering.getFilteredRowCount() }} results</span>\n * <button (click)=\"filtering.clearAllFilters()\">Clear</button>\n * <tbw-grid [rows]=\"rows\" [filtering]=\"true\"></tbw-grid>\n * `\n * })\n * export class MyGridComponent {\n * filtering = injectGridFiltering();\n *\n * applyFilter(event: Event) {\n * const value = (event.target as HTMLInputElement).value;\n * this.filtering.setFilter('name', value ? { operator: 'contains', value } : null);\n * }\n * }\n * ```\n *\n * @param selector - Optional CSS selector to target a specific grid element.\n * Defaults to `'tbw-grid'` (first grid in the component). Use when the\n * component contains multiple grids, e.g. `'tbw-grid.primary'` or `'#my-grid'`.\n */\nexport function injectGridFiltering(selector = 'tbw-grid'): FilteringMethods {\n const elementRef = inject(ElementRef);\n const destroyRef = inject(DestroyRef);\n const isReady = signal(false);\n\n let cachedGrid: DataGridElement | null = null;\n let readyPromiseStarted = false;\n\n const getGrid = (): DataGridElement | null => {\n if (cachedGrid) return cachedGrid;\n\n const grid = elementRef.nativeElement.querySelector(selector) as DataGridElement | null;\n if (grid) {\n cachedGrid = grid;\n if (!readyPromiseStarted) {\n readyPromiseStarted = true;\n grid.ready?.().then(() => {\n // If the plugin is already attached, signal readiness immediately.\n // Otherwise, Angular's Grid directive may not have applied gridConfig\n // yet (it uses effect + queueMicrotask). Defer to let pending\n // microtasks flush before signaling readiness.\n if (grid.getPluginByName('filtering')) {\n isReady.set(true);\n } else {\n setTimeout(() => isReady.set(true), 0);\n }\n });\n }\n }\n return grid;\n };\n\n const getPlugin = (): FilteringPlugin | undefined => {\n return getGrid()?.getPluginByName('filtering') as FilteringPlugin | undefined;\n };\n\n // Eagerly discover the grid after the first render so isReady updates\n // without requiring a programmatic method call. Falls back to a\n // MutationObserver for lazy-rendered tabs, *ngIf, @defer, etc.\n afterNextRender(() => {\n if (getGrid()) return;\n\n const host = elementRef.nativeElement as HTMLElement;\n const observer = new MutationObserver(() => {\n if (getGrid()) observer.disconnect();\n });\n observer.observe(host, { childList: true, subtree: true });\n\n destroyRef.onDestroy(() => observer.disconnect());\n });\n\n return {\n isReady: isReady.asReadonly(),\n\n setFilter: (field: string, filter: Omit<FilterModel, 'field'> | null, options?: { silent?: boolean }) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <tbw-grid [filtering]=\"true\" />`,\n );\n return;\n }\n plugin.setFilter(field, filter, options);\n },\n\n getFilter: (field: string) => getPlugin()?.getFilter(field),\n\n getFilters: () => getPlugin()?.getFilters() ?? [],\n\n setFilterModel: (filters: FilterModel[], options?: { silent?: boolean }) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <tbw-grid [filtering]=\"true\" />`,\n );\n return;\n }\n plugin.setFilterModel(filters, options);\n },\n\n clearAllFilters: (options?: { silent?: boolean }) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <tbw-grid [filtering]=\"true\" />`,\n );\n return;\n }\n plugin.clearAllFilters(options);\n },\n\n clearFieldFilter: (field: string, options?: { silent?: boolean }) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <tbw-grid [filtering]=\"true\" />`,\n );\n return;\n }\n plugin.clearFieldFilter(field, options);\n },\n\n isFieldFiltered: (field: string) => getPlugin()?.isFieldFiltered(field) ?? false,\n\n getFilteredRowCount: () => getPlugin()?.getFilteredRowCount() ?? 0,\n\n getUniqueValues: (field: string) => getPlugin()?.getUniqueValues(field) ?? [],\n\n getStaleFilters: () => getPlugin()?.getStaleFilters() ?? [],\n\n getBlankMode: (field: string) => getPlugin()?.getBlankMode(field) ?? 'all',\n\n toggleBlankFilter: (field: string, mode: BlankMode) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <tbw-grid [filtering]=\"true\" />`,\n );\n return;\n }\n plugin.toggleBlankFilter(field, mode);\n },\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CG;AAgCH;;;;;;;AAOG;MAKU,sBAAsB,CAAA;AAChB,IAAA,UAAU,GAAG,MAAM,EAAC,UAA2B,EAAC;AAEjE;;;;;;;;;AASG;;IAEM,SAAS,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,WAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAA+B;AAEzD;;;;;;;AAOG;IACM,YAAY,GAAG,MAAM,EAAsB;;AAG5C,IAAA,QAAQ;AAEhB,IAAA,WAAA,GAAA;AACE,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa;;;;;AAK1C,QAAA,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;;;AAG/D,QAAA,UAAU,CAAC,IAAI,EAAE,eAAe,CAAC;IACnC;IAEA,QAAQ,GAAA;AACN,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa;AAC1C,QAAA,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAQ,KAAI;YAC3B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAE,CAAqC,CAAC,MAAM,CAAC;AACvE,QAA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,CAAC,KAAa,EAAE,OAA8B,KAAI;AAClE,YAAA,MAAM,MAAM,GAAG,SAAS,EAAE;YAC1B,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO,CAAC,IAAI,CACV,CAAA,mDAAA,CAAqD;oBACnD,CAAA,mCAAA,CAAqC;AACrC,oBAAA,CAAA,mCAAA,CAAqC,CACxC;gBACD;YACF;AACA,YAAA,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC;QACzC,CAAC;AAED,QAAA,eAAe,EAAE,CAAC,KAAa,KAAK,SAAS,EAAE,EAAE,eAAe,CAAC,KAAK,CAAC,IAAI,KAAK;QAEhF,mBAAmB,EAAE,MAAM,SAAS,EAAE,EAAE,mBAAmB,EAAE,IAAI,CAAC;AAElE,QAAA,eAAe,EAAE,CAAC,KAAa,KAAK,SAAS,EAAE,EAAE,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE;QAE7E,eAAe,EAAE,MAAM,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE;AAE3D,QAAA,YAAY,EAAE,CAAC,KAAa,KAAK,SAAS,EAAE,EAAE,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK;AAE1E,QAAA,iBAAiB,EAAE,CAAC,KAAa,EAAE,IAAe,KAAI;AACpD,YAAA,MAAM,MAAM,GAAG,SAAS,EAAE;YAC1B,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO,CAAC,IAAI,CACV,CAAA,mDAAA,CAAqD;oBACnD,CAAA,mCAAA,CAAqC;AACrC,oBAAA,CAAA,mCAAA,CAAqC,CACxC;gBACD;YACF;AACA,YAAA,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC;QACvC,CAAC;KACF;AACH;;ACxXA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"toolbox-web-grid-angular-features-filtering.mjs","sources":["../../../../libs/grid-angular/features/filtering/src/grid-filtering.directive.ts","../../../../libs/grid-angular/features/filtering/src/base-filter-panel.ts","../../../../libs/grid-angular/features/filtering/src/index.ts","../../../../libs/grid-angular/features/filtering/src/toolbox-web-grid-angular-features-filtering.ts"],"sourcesContent":["/**\n * `GridFilteringDirective` — attribute-selector directive that owns the\n * `filtering` input and the `filterChange` output on `<tbw-grid>`.\n *\n * ## Why this exists\n *\n * Historically these bindings lived on the central `Grid` directive in\n * `@toolbox-web/grid-angular`. That meant the typed surface for the\n * filtering plugin shipped in the core bundle of every consumer, even those\n * that never imported the filtering feature. Moving them here lets the\n * surface tree-shake away with the rest of the feature when it is not\n * imported, matching the philosophy of the React / Vue adapters and the\n * web-component core (where unloaded plugins simply don't exist on the\n * element).\n *\n * ## Usage\n *\n * ```typescript\n * import { Component } from '@angular/core';\n * import { Grid } from '@toolbox-web/grid-angular';\n * import { GridFilteringDirective } from '@toolbox-web/grid-angular/features/filtering';\n *\n * @Component({\n * selector: 'app-grid',\n * imports: [Grid, GridFilteringDirective],\n * template: `\n * <tbw-grid [rows]=\"rows\" [filtering]=\"true\" (filterChange)=\"onFilter($event)\" />\n * `,\n * })\n * export class AppGridComponent {}\n * ```\n *\n * ## Backward compatibility (v1.x)\n *\n * The matching `filtering` input and `filterChange` output also still exist\n * on `Grid` (marked `@deprecated`) so existing apps that bind them without\n * importing `GridFilteringDirective` continue to work — those will be\n * removed in v2.0.0. When both this directive and the deprecated bindings\n * are present, the directive wins via the per-grid claims registry in\n * `internal/feature-claims.ts`: `Grid` consults the registry and skips its\n * own plugin creation + event wiring for any claimed feature.\n *\n * @category Directive\n */\nimport { Directive, ElementRef, inject, input, OnDestroy, OnInit, output, type Type } from '@angular/core';\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport {\n claimEvent,\n registerFeatureClaim,\n unclaimEvent,\n unregisterFeatureClaim,\n type FilterPanel,\n} from '@toolbox-web/grid-angular';\nimport type { FilterConfig as CoreFilterConfig, FilterChangeDetail } from '@toolbox-web/grid/plugins/filtering';\n\n/**\n * Angular-specific filter config that allows an Angular component class as\n * the plugin-level `filterPanelRenderer`.\n *\n * Extends the core `FilterConfig` to accept a `Type<FilterPanel>` for\n * `filterPanelRenderer` in addition to the vanilla\n * `(container, params) => void` signature. Bridging to vanilla DOM is handled\n * by the side-effect import `@toolbox-web/grid-angular/features/filtering`.\n *\n * Re-exported from the feature entry under the same name as the core type\n * so Angular consumers see a single canonical `FilterConfig` from\n * `@toolbox-web/grid-angular/features/filtering`.\n *\n * @since 1.7.1\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FilterConfig<TRow = any> = Omit<CoreFilterConfig<TRow>, 'filterPanelRenderer'> & {\n filterPanelRenderer?: CoreFilterConfig<TRow>['filterPanelRenderer'] | Type<FilterPanel>;\n};\n\n/**\n * Owns the `[filtering]` input and `(filterChange)` output on `<tbw-grid>`.\n *\n * Selector matches when *either* binding is present so users can pick the\n * style that suits their template — both go through the same claim and the\n * same wiring.\n * @category Directive\n */\n@Directive({\n selector: 'tbw-grid[filtering], tbw-grid[filterChange]',\n standalone: true,\n})\nexport class GridFilteringDirective implements OnInit, OnDestroy {\n private readonly elementRef = inject(ElementRef<DataGridElement>);\n\n /**\n * Enable column filtering. Identical semantics to the deprecated input on\n * `Grid` — this directive owns the binding when both are present.\n *\n * @example\n * ```html\n * <tbw-grid [filtering]=\"true\" />\n * <tbw-grid [filtering]=\"{ debounceMs: 200 }\" />\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly filtering = input<boolean | FilterConfig<any>>();\n\n /**\n * Emitted when filter values change.\n *\n * @example\n * ```html\n * <tbw-grid (filterChange)=\"onFilterChange($event)\" />\n * ```\n */\n readonly filterChange = output<FilterChangeDetail>();\n\n // Listener kept so we can detach in `ngOnDestroy`.\n private listener?: (e: Event) => void;\n\n constructor() {\n const grid = this.elementRef.nativeElement;\n // Tell `Grid` we own this feature's input. Reading `this.filtering()`\n // inside the getter establishes a reactive dependency in `Grid`'s\n // `createFeaturePlugins` effect — when our input changes, that effect\n // re-runs and the plugin config is updated.\n registerFeatureClaim(grid, 'filtering', () => this.filtering());\n // Tell `Grid` we own the matching event so it doesn't double-emit on\n // its own deprecated `filterChange` output.\n claimEvent(grid, 'filter-change');\n }\n\n ngOnInit(): void {\n const grid = this.elementRef.nativeElement;\n this.listener = (e: Event) => {\n this.filterChange.emit((e as CustomEvent<FilterChangeDetail>).detail);\n };\n grid.addEventListener('filter-change', this.listener);\n }\n\n ngOnDestroy(): void {\n const grid = this.elementRef.nativeElement;\n if (this.listener) {\n grid.removeEventListener('filter-change', this.listener);\n this.listener = undefined;\n }\n // Drop the claims so that, if the directive is removed via *ngIf but\n // the host `<tbw-grid>` survives, `Grid`'s deprecated bindings take\n // back over without leaving stale ownership behind.\n unregisterFeatureClaim(grid, 'filtering');\n unclaimEvent(grid, 'filter-change');\n }\n}\n","import { Directive, input } from '@angular/core';\nimport type { FilterPanel } from '@toolbox-web/grid-angular';\n\ntype FilterPanelParams = ReturnType<FilterPanel['params']>;\n\n/**\n * Base class for Angular filter panel components.\n *\n * Provides a ready-made `params` input and common lifecycle helpers\n * (`applyAndClose`, `clearAndClose`) so consumers only need to implement\n * their filter logic in `applyFilter()`.\n *\n * ## Usage\n *\n * ```typescript\n * import { Component, viewChild, ElementRef } from '@angular/core';\n * import { BaseFilterPanel } from '@toolbox-web/grid-angular/features/filtering';\n *\n * @Component({\n * selector: 'app-text-filter',\n * template: `\n * <input #input (keydown.enter)=\"applyAndClose()\" />\n * <button (click)=\"applyAndClose()\">Apply</button>\n * <button (click)=\"clearAndClose()\">Clear</button>\n * `\n * })\n * export class TextFilterComponent extends BaseFilterPanel {\n * input = viewChild.required<ElementRef<HTMLInputElement>>('input');\n *\n * applyFilter(): void {\n * this.params().applyTextFilter('contains', this.input().nativeElement.value);\n * }\n * }\n * ```\n *\n * ## Template Syntax\n *\n * The grid's filtering plugin will mount this component and provide `params`\n * automatically. No manual wiring is required:\n *\n * ```typescript\n * gridConfig = {\n * columns: [\n * { field: 'name', filterable: true, filterPanel: TextFilterComponent },\n * ],\n * };\n * ```\n *\n * @typeParam TRow - The row data type (available via `params().column`)\n *\n * @since 0.13.0\n */\n@Directive()\nexport abstract class BaseFilterPanel implements FilterPanel {\n /**\n * Filter panel parameters injected by the grid's filtering plugin.\n *\n * Provides access to:\n * - `field` — the column field name\n * - `column` — full column configuration\n * - `uniqueValues` — distinct values in the column\n * - `excludedValues` — currently excluded values (set filter)\n * - `searchText` — current search text\n * - `applySetFilter(excluded)` — apply a set-based (include/exclude) filter\n * - `applyTextFilter(operator, value, valueTo?)` — apply a text/number filter\n * - `clearFilter()` — clear the filter for this column\n * - `closePanel()` — close the filter panel\n */\n readonly params = input.required<FilterPanelParams>();\n\n /**\n * Implement this to apply your filter logic.\n *\n * Called by {@link applyAndClose} before closing the panel.\n * Use `this.params()` to access the filter API.\n *\n * @example\n * ```typescript\n * applyFilter(): void {\n * this.params().applyTextFilter('contains', this.searchText);\n * }\n * ```\n */\n abstract applyFilter(): void;\n\n /**\n * Apply the filter then close the panel.\n *\n * Calls {@link applyFilter} followed by `params().closePanel()`.\n * Bind this to your \"Apply\" button or Enter key handler.\n */\n applyAndClose(): void {\n this.applyFilter();\n this.params().closePanel();\n }\n\n /**\n * Clear the filter then close the panel.\n *\n * Calls `params().clearFilter()` followed by `params().closePanel()`.\n * Bind this to your \"Clear\" / \"Reset\" button.\n */\n clearAndClose(): void {\n this.params().clearFilter();\n this.params().closePanel();\n }\n}\n","/**\n * Filtering feature for @toolbox-web/grid-angular\n *\n * Two ways to use:\n *\n * 1. **Recommended (tree-shakeable surface):** add `GridFilteringDirective`\n * to your component's `imports`. The directive owns the `[filtering]`\n * input and `(filterChange)` output, so the typed surface tree-shakes\n * away when the feature is not imported.\n * 2. **Legacy (non-breaking, deprecated):** side-effect import the feature\n * entry; the matching `[filtering]` / `(filterChange)` bindings on the\n * central `Grid` directive will work as in v1.x. These bindings on `Grid`\n * are marked `@deprecated` and will be removed in v2.0.0.\n *\n * Either way `injectGridFiltering()` is available for programmatic control.\n *\n * @example Recommended (directive-owned binding)\n * ```typescript\n * import { Grid } from '@toolbox-web/grid-angular';\n * import { GridFilteringDirective } from '@toolbox-web/grid-angular/features/filtering';\n *\n * @Component({\n * imports: [Grid, GridFilteringDirective],\n * template: `<tbw-grid [filtering]=\"true\" (filterChange)=\"onChange($event)\" />`,\n * })\n * ```\n *\n * @example Legacy (deprecated; works without importing the directive)\n * ```typescript\n * import '@toolbox-web/grid-angular/features/filtering';\n *\n * <tbw-grid [filtering]=\"true\" />\n * <tbw-grid [filtering]=\"{ debounceMs: 200 }\" />\n * ```\n *\n * @example Using injectGridFiltering\n * ```typescript\n * import { injectGridFiltering } from '@toolbox-web/grid-angular/features/filtering';\n *\n * @Component({...})\n * export class MyComponent {\n * private filtering = injectGridFiltering();\n *\n * filterByStatus(status: string) {\n * this.filtering.setFilter('status', { operator: 'equals', value: status });\n * }\n * }\n * ```\n *\n * @packageDocumentation\n */\n\nimport { afterNextRender, DestroyRef, ElementRef, inject, signal, type Signal, type Type } from '@angular/core';\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport {\n isComponentClass,\n registerFeatureConfigPreprocessor,\n registerFilterPanelTypeDefaultBridge,\n type FilterPanel,\n type GridAdapter,\n} from '@toolbox-web/grid-angular';\nimport '@toolbox-web/grid/features/filtering';\nimport {\n FilteringPlugin,\n type BlankMode,\n type FilterConfig as CoreFilterConfig,\n type FilterModel,\n} from '@toolbox-web/grid/plugins/filtering';\nexport type { _Augmentation as _FilteringAugmentation } from '@toolbox-web/grid/features/filtering';\n\n// Attribute-selector directive that owns the `[filtering]` input and\n// `(filterChange)` output on `<tbw-grid>`. Add to your component's `imports`\n// alongside `Grid` to opt into the feature directly via the binding. The\n// matching deprecated bindings on `Grid` remain as a v1.x compatibility\n// shim and will be removed in v2.0.0.\nexport { GridFilteringDirective } from './grid-filtering.directive';\nexport type { FilterConfig } from './grid-filtering.directive';\n\n// `BaseFilterPanel` is filtering-specific (implements `FilterPanel` from the\n// filtering plugin) and physically lives in this secondary entry.\nexport { BaseFilterPanel } from './base-filter-panel';\n\ntype FilterPanelParams = ReturnType<FilterPanel['params']>;\n\n// Bridge any Angular component classes used as `filterPanelRenderer` (in\n// `gridConfig.typeDefaults` or via `provideGridTypeDefaults`) to the\n// `(container, params) => void` form required by FilteringPlugin. Without\n// this import, component-class filterPanelRenderers are silently dropped \\u2014\n// the same precondition as the FilteringPlugin itself (TBW031).\nregisterFilterPanelTypeDefaultBridge((rendererValue: unknown, adapter: GridAdapter) => {\n const componentClass = rendererValue as Type<unknown>;\n const mount = adapter.mountComponentRenderer<FilterPanelParams>(componentClass, (params) => ({ params }));\n return (container: HTMLElement, params: FilterPanelParams) => {\n container.appendChild(mount(params).hostElement);\n };\n});\n\n/**\n * Bridge an Angular component class used as the plugin-level\n * `filterPanelRenderer` (in `FilterConfig`) to the `(container, params) => void`\n * form required by FilteringPlugin. Mirrors `registerFilterPanelTypeDefaultBridge`\n * above, but for the plugin-wide renderer rather than per-type defaults.\n *\n * Without this preprocessor, passing a component class as\n * `filtering.filterPanelRenderer` would be invoked as a function at render\n * time and crash.\n *\n * @since 1.7.1\n */\nregisterFeatureConfigPreprocessor('filtering', (config, adapter) => {\n if (!config || typeof config === 'boolean' || typeof config !== 'object') return config;\n const cfg = config as CoreFilterConfig;\n if (!isComponentClass(cfg.filterPanelRenderer)) return config;\n\n type PluginFilterPanelRenderer = NonNullable<CoreFilterConfig['filterPanelRenderer']>;\n type PluginFilterPanelParams = Parameters<PluginFilterPanelRenderer>[1];\n\n const componentClass = cfg.filterPanelRenderer as Type<unknown>;\n const mount = adapter.mountComponentRenderer<PluginFilterPanelParams>(componentClass, (params) => ({ params }));\n const filterPanelRenderer: CoreFilterConfig['filterPanelRenderer'] = (container, params) => {\n container.appendChild(mount(params).hostElement);\n };\n return { ...cfg, filterPanelRenderer };\n});\n\n/**\n * Filtering methods returned from injectGridFiltering.\n *\n * Uses lazy discovery - the grid is found on first method call, not during initialization.\n */\nexport interface FilteringMethods {\n /**\n * Set a filter on a specific field.\n * @param field - The field name to filter\n * @param filter - Filter configuration, or null to remove\n * @param options - `{ silent: true }` applies the filter without emitting `filter-change`\n */\n setFilter: (field: string, filter: Omit<FilterModel, 'field'> | null, options?: { silent?: boolean }) => void;\n\n /**\n * Get the current filter for a field.\n */\n getFilter: (field: string) => FilterModel | undefined;\n\n /**\n * Get all active filters.\n */\n getFilters: () => FilterModel[];\n\n /**\n * Set all filters at once (replaces existing).\n * @param options - `{ silent: true }` applies filters without emitting `filter-change`\n */\n setFilterModel: (filters: FilterModel[], options?: { silent?: boolean }) => void;\n\n /**\n * Clear all active filters.\n * @param options - `{ silent: true }` clears filters without emitting `filter-change`\n */\n clearAllFilters: (options?: { silent?: boolean }) => void;\n\n /**\n * Clear filter for a specific field.\n * @param options - `{ silent: true }` clears filter without emitting `filter-change`\n */\n clearFieldFilter: (field: string, options?: { silent?: boolean }) => void;\n\n /**\n * Check if a field has an active filter.\n */\n isFieldFiltered: (field: string) => boolean;\n\n /**\n * Get the count of rows after filtering.\n */\n getFilteredRowCount: () => number;\n\n /**\n * Get unique values for a field (for building filter dropdowns).\n */\n getUniqueValues: (field: string) => unknown[];\n\n /**\n * Get set filters whose values no longer match any rows in the current data.\n */\n getStaleFilters: () => FilterModel[];\n\n /**\n * Get the current blank mode for a field.\n */\n getBlankMode: (field: string) => BlankMode;\n\n /**\n * Toggle blank filter mode for a field.\n */\n toggleBlankFilter: (field: string, mode: BlankMode) => void;\n\n /**\n * Signal indicating if grid is ready.\n */\n isReady: Signal<boolean>;\n}\n\n/**\n * Angular inject function for programmatic filter control.\n *\n * Uses **lazy grid discovery** - the grid element is found when methods are called,\n * not during initialization.\n *\n * @example\n * ```typescript\n * import { Component } from '@angular/core';\n * import { Grid } from '@toolbox-web/grid-angular';\n * import '@toolbox-web/grid-angular/features/filtering';\n * import { injectGridFiltering } from '@toolbox-web/grid-angular/features/filtering';\n *\n * @Component({\n * selector: 'app-my-grid',\n * imports: [Grid],\n * template: `\n * <input (input)=\"applyFilter($event)\" placeholder=\"Filter by name...\" />\n * <span>{{ filtering.getFilteredRowCount() }} results</span>\n * <button (click)=\"filtering.clearAllFilters()\">Clear</button>\n * <tbw-grid [rows]=\"rows\" [filtering]=\"true\"></tbw-grid>\n * `\n * })\n * export class MyGridComponent {\n * filtering = injectGridFiltering();\n *\n * applyFilter(event: Event) {\n * const value = (event.target as HTMLInputElement).value;\n * this.filtering.setFilter('name', value ? { operator: 'contains', value } : null);\n * }\n * }\n * ```\n *\n * @param selector - Optional CSS selector to target a specific grid element.\n * Defaults to `'tbw-grid'` (first grid in the component). Use when the\n * component contains multiple grids, e.g. `'tbw-grid.primary'` or `'#my-grid'`.\n */\nexport function injectGridFiltering(selector = 'tbw-grid'): FilteringMethods {\n const elementRef = inject(ElementRef);\n const destroyRef = inject(DestroyRef);\n const isReady = signal(false);\n\n let cachedGrid: DataGridElement | null = null;\n let readyPromiseStarted = false;\n\n const getGrid = (): DataGridElement | null => {\n if (cachedGrid) return cachedGrid;\n\n const grid = elementRef.nativeElement.querySelector(selector) as DataGridElement | null;\n if (grid) {\n cachedGrid = grid;\n if (!readyPromiseStarted) {\n readyPromiseStarted = true;\n grid.ready?.().then(() => {\n // If the plugin is already attached, signal readiness immediately.\n // Otherwise, Angular's Grid directive may not have applied gridConfig\n // yet (it uses effect + queueMicrotask). Defer to let pending\n // microtasks flush before signaling readiness.\n if (grid.getPluginByName('filtering')) {\n isReady.set(true);\n } else {\n setTimeout(() => isReady.set(true), 0);\n }\n });\n }\n }\n return grid;\n };\n\n const getPlugin = (): FilteringPlugin | undefined => {\n return getGrid()?.getPluginByName('filtering') as FilteringPlugin | undefined;\n };\n\n // Eagerly discover the grid after the first render so isReady updates\n // without requiring a programmatic method call. Falls back to a\n // MutationObserver for lazy-rendered tabs, *ngIf, @defer, etc.\n afterNextRender(() => {\n if (getGrid()) return;\n\n const host = elementRef.nativeElement as HTMLElement;\n const observer = new MutationObserver(() => {\n if (getGrid()) observer.disconnect();\n });\n observer.observe(host, { childList: true, subtree: true });\n\n destroyRef.onDestroy(() => observer.disconnect());\n });\n\n return {\n isReady: isReady.asReadonly(),\n\n setFilter: (field: string, filter: Omit<FilterModel, 'field'> | null, options?: { silent?: boolean }) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <tbw-grid [filtering]=\"true\" />`,\n );\n return;\n }\n plugin.setFilter(field, filter, options);\n },\n\n getFilter: (field: string) => getPlugin()?.getFilter(field),\n\n getFilters: () => getPlugin()?.getFilters() ?? [],\n\n setFilterModel: (filters: FilterModel[], options?: { silent?: boolean }) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <tbw-grid [filtering]=\"true\" />`,\n );\n return;\n }\n plugin.setFilterModel(filters, options);\n },\n\n clearAllFilters: (options?: { silent?: boolean }) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <tbw-grid [filtering]=\"true\" />`,\n );\n return;\n }\n plugin.clearAllFilters(options);\n },\n\n clearFieldFilter: (field: string, options?: { silent?: boolean }) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <tbw-grid [filtering]=\"true\" />`,\n );\n return;\n }\n plugin.clearFieldFilter(field, options);\n },\n\n isFieldFiltered: (field: string) => getPlugin()?.isFieldFiltered(field) ?? false,\n\n getFilteredRowCount: () => getPlugin()?.getFilteredRowCount() ?? 0,\n\n getUniqueValues: (field: string) => getPlugin()?.getUniqueValues(field) ?? [],\n\n getStaleFilters: () => getPlugin()?.getStaleFilters() ?? [],\n\n getBlankMode: (field: string) => getPlugin()?.getBlankMode(field) ?? 'all',\n\n toggleBlankFilter: (field: string, mode: BlankMode) => {\n const plugin = getPlugin();\n if (!plugin) {\n console.warn(\n `[tbw-grid:filtering] FilteringPlugin not found.\\n\\n` +\n ` → Enable filtering on the grid:\\n` +\n ` <tbw-grid [filtering]=\"true\" />`,\n );\n return;\n }\n plugin.toggleBlankFilter(field, mode);\n },\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CG;AAgCH;;;;;;;AAOG;MAKU,sBAAsB,CAAA;AAChB,IAAA,UAAU,GAAG,MAAM,EAAC,UAA2B,EAAC;AAEjE;;;;;;;;;AASG;;IAEM,SAAS,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,WAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAA+B;AAEzD;;;;;;;AAOG;IACM,YAAY,GAAG,MAAM,EAAsB;;AAG5C,IAAA,QAAQ;AAEhB,IAAA,WAAA,GAAA;AACE,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa;;;;;AAK1C,QAAA,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;;;AAG/D,QAAA,UAAU,CAAC,IAAI,EAAE,eAAe,CAAC;IACnC;IAEA,QAAQ,GAAA;AACN,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa;AAC1C,QAAA,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAQ,KAAI;YAC3B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAE,CAAqC,CAAC,MAAM,CAAC;AACvE,QAAA,CAAC;QACD,IAAI,CAAC,gBAAgB,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC;IACvD;IAEA,WAAW,GAAA;AACT,QAAA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KAAK,SAAS,EAAE,EAAE,eAAe,CAAC,KAAK,CAAC,IAAI,EAAE;QAE7E,eAAe,EAAE,MAAM,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE;AAE3D,QAAA,YAAY,EAAE,CAAC,KAAa,KAAK,SAAS,EAAE,EAAE,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK;AAE1E,QAAA,iBAAiB,EAAE,CAAC,KAAa,EAAE,IAAe,KAAI;AACpD,YAAA,MAAM,MAAM,GAAG,SAAS,EAAE;YAC1B,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO,CAAC,IAAI,CACV,CAAA,mDAAA,CAAqD;oBACnD,CAAA,mCAAA,CAAqC;AACrC,oBAAA,CAAA,mCAAA,CAAqC,CACxC;gBACD;YACF;AACA,YAAA,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC;QACvC,CAAC;KACF;AACH;;ACrXA;;AAEG;;;;"}
|
|
@@ -1,8 +1,101 @@
|
|
|
1
|
-
import { registerFeatureClaim, claimEvent, unregisterFeatureClaim, unclaimEvent, registerDetailRendererBridge,
|
|
2
|
-
export { GridDetailView, getDetailTemplate } from '@toolbox-web/grid-angular';
|
|
1
|
+
import { registerFeatureClaim, claimEvent, unregisterFeatureClaim, unclaimEvent, registerDetailRendererBridge, registerTemplateBridge, registerFeatureConfigPreprocessor, isComponentClass } from '@toolbox-web/grid-angular';
|
|
3
2
|
import '@toolbox-web/grid/features/master-detail';
|
|
4
3
|
import * as i0 from '@angular/core';
|
|
5
|
-
import { inject, ElementRef, input,
|
|
4
|
+
import { inject, ElementRef, input, contentChild, TemplateRef, effect, Directive, output } from '@angular/core';
|
|
5
|
+
|
|
6
|
+
// Global registry mapping DOM elements to their templates
|
|
7
|
+
const detailTemplateRegistry = new Map();
|
|
8
|
+
/**
|
|
9
|
+
* Gets the detail template registered for a given grid element.
|
|
10
|
+
* Used by AngularGridAdapter to retrieve templates at render time.
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
*/
|
|
13
|
+
function getDetailTemplate(gridElement) {
|
|
14
|
+
// Look for tbw-grid-detail child and get its template
|
|
15
|
+
const detailElement = gridElement.querySelector('tbw-grid-detail');
|
|
16
|
+
if (detailElement) {
|
|
17
|
+
return detailTemplateRegistry.get(detailElement);
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Directive that captures an `<ng-template>` for use as a master-detail row renderer.
|
|
23
|
+
*
|
|
24
|
+
* This enables declarative Angular component usage for expandable detail rows
|
|
25
|
+
* that appear below the main row when expanded.
|
|
26
|
+
*
|
|
27
|
+
* ## Usage
|
|
28
|
+
*
|
|
29
|
+
* ```html
|
|
30
|
+
* <tbw-grid [rows]="rows" [gridConfig]="config">
|
|
31
|
+
* <tbw-grid-detail [showExpandColumn]="true" animation="slide">
|
|
32
|
+
* <ng-template let-row>
|
|
33
|
+
* <app-detail-panel [employee]="row" />
|
|
34
|
+
* </ng-template>
|
|
35
|
+
* </tbw-grid-detail>
|
|
36
|
+
* </tbw-grid>
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* The template context provides:
|
|
40
|
+
* - `$implicit` / `row`: The full row data object
|
|
41
|
+
*
|
|
42
|
+
* Import the directive from the master-detail feature entry:
|
|
43
|
+
*
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { GridDetailView } from '@toolbox-web/grid-angular/features/master-detail';
|
|
46
|
+
*
|
|
47
|
+
* @Component({
|
|
48
|
+
* imports: [GridDetailView],
|
|
49
|
+
* // ...
|
|
50
|
+
* })
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```html
|
|
55
|
+
* <tbw-grid [rows]="rows" [gridConfig]="config">
|
|
56
|
+
* <tbw-grid-detail [showExpandColumn]="true" animation="slide">
|
|
57
|
+
* <ng-template let-row>
|
|
58
|
+
* <app-detail-panel [employee]="row" />
|
|
59
|
+
* </ng-template>
|
|
60
|
+
* </tbw-grid-detail>
|
|
61
|
+
* </tbw-grid>
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @category Directive
|
|
65
|
+
* @since 0.1.0
|
|
66
|
+
*/
|
|
67
|
+
class GridDetailView {
|
|
68
|
+
elementRef = inject((ElementRef));
|
|
69
|
+
/** Whether to show the expand/collapse column. Default: true */
|
|
70
|
+
showExpandColumn = input(true, ...(ngDevMode ? [{ debugName: "showExpandColumn" }] : /* istanbul ignore next */ []));
|
|
71
|
+
/** Animation style for expand/collapse. Default: 'slide' */
|
|
72
|
+
animation = input('slide', ...(ngDevMode ? [{ debugName: "animation" }] : /* istanbul ignore next */ []));
|
|
73
|
+
/**
|
|
74
|
+
* Query for the ng-template content child.
|
|
75
|
+
*/
|
|
76
|
+
template = contentChild((TemplateRef), ...(ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []));
|
|
77
|
+
/** Effect that triggers when the template is available */
|
|
78
|
+
onTemplateReceived = effect(() => {
|
|
79
|
+
const template = this.template();
|
|
80
|
+
if (template) {
|
|
81
|
+
// Register the template for this element
|
|
82
|
+
detailTemplateRegistry.set(this.elementRef.nativeElement, template);
|
|
83
|
+
}
|
|
84
|
+
}, ...(ngDevMode ? [{ debugName: "onTemplateReceived" }] : /* istanbul ignore next */ []));
|
|
85
|
+
/**
|
|
86
|
+
* Static type guard for template context.
|
|
87
|
+
* Enables type inference in templates.
|
|
88
|
+
*/
|
|
89
|
+
static ngTemplateContextGuard(dir, ctx) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: GridDetailView, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
93
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.5", type: GridDetailView, isStandalone: true, selector: "tbw-grid-detail", inputs: { showExpandColumn: { classPropertyName: "showExpandColumn", publicName: "showExpandColumn", isSignal: true, isRequired: false, transformFunction: null }, animation: { classPropertyName: "animation", publicName: "animation", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "template", first: true, predicate: (TemplateRef), descendants: true, isSignal: true }], ngImport: i0 });
|
|
94
|
+
}
|
|
95
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: GridDetailView, decorators: [{
|
|
96
|
+
type: Directive,
|
|
97
|
+
args: [{ selector: 'tbw-grid-detail' }]
|
|
98
|
+
}], propDecorators: { showExpandColumn: [{ type: i0.Input, args: [{ isSignal: true, alias: "showExpandColumn", required: false }] }], animation: [{ type: i0.Input, args: [{ isSignal: true, alias: "animation", required: false }] }], template: [{ type: i0.ContentChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }] } });
|
|
6
99
|
|
|
7
100
|
/**
|
|
8
101
|
* `GridMasterDetailDirective` — owns `[masterDetail]` and `(detailExpand)`
|
|
@@ -161,5 +254,5 @@ registerFeatureConfigPreprocessor('masterDetail', (config, adapter) => {
|
|
|
161
254
|
* Generated bundle index. Do not edit.
|
|
162
255
|
*/
|
|
163
256
|
|
|
164
|
-
export { GridMasterDetailDirective };
|
|
257
|
+
export { GridDetailView, GridMasterDetailDirective, getDetailTemplate };
|
|
165
258
|
//# sourceMappingURL=toolbox-web-grid-angular-features-master-detail.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbox-web-grid-angular-features-master-detail.mjs","sources":["../../../../libs/grid-angular/features/master-detail/src/grid-master-detail.directive.ts","../../../../libs/grid-angular/features/master-detail/src/index.ts","../../../../libs/grid-angular/features/master-detail/src/toolbox-web-grid-angular-features-master-detail.ts"],"sourcesContent":["/**\n * `GridMasterDetailDirective` — owns `[masterDetail]` and `(detailExpand)`\n * on `<tbw-grid>`. See `GridFilteringDirective` for the full rationale.\n *\n * Note: this directive is independent of the higher-level\n * `<tbw-grid-detail>` template element + `GridDetailView` wrapper, which\n * uses a different bridging mechanism (template registration). Apps using\n * the template form do not need this directive.\n *\n * @category Directive\n */\nimport { Directive, ElementRef, inject, input, OnDestroy, OnInit, output, type Type } from '@angular/core';\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport { claimEvent, registerFeatureClaim, unclaimEvent, unregisterFeatureClaim } from '@toolbox-web/grid-angular';\nimport type {\n MasterDetailConfig as CoreMasterDetailConfig,\n DetailExpandDetail,\n} from '@toolbox-web/grid/plugins/master-detail';\n\n/**\n * Angular-specific master-detail config that allows an Angular component class\n * as `detailRenderer`.\n *\n * Extends the core `MasterDetailConfig` to accept a `Type<unknown>` for\n * `detailRenderer` in addition to the vanilla\n * `(row, rowIndex) => HTMLElement | string` signature. Bridging to vanilla\n * DOM is handled by the side-effect import\n * `@toolbox-web/grid-angular/features/master-detail`.\n *\n * Re-exported from the feature entry under the same name as the core type\n * so Angular consumers see a single canonical `MasterDetailConfig` from\n * `@toolbox-web/grid-angular/features/master-detail`.\n *\n * @since 1.7.1\n */\nexport type MasterDetailConfig = Omit<CoreMasterDetailConfig, 'detailRenderer'> & {\n detailRenderer?: CoreMasterDetailConfig['detailRenderer'] | Type<unknown>;\n};\n\n/**\n * Owns the binding(s) `[masterDetail], [detailExpand]` on `<tbw-grid>` for the matching feature plugin. See `GridFilteringDirective` for the full rationale.\n *\n * @category Directive\n */\n@Directive({\n selector: 'tbw-grid[masterDetail], tbw-grid[detailExpand]',\n standalone: true,\n})\nexport class GridMasterDetailDirective implements OnInit, OnDestroy {\n private readonly elementRef = inject(ElementRef<DataGridElement>);\n\n readonly masterDetail = input<MasterDetailConfig>();\n readonly detailExpand = output<DetailExpandDetail>();\n\n private listener?: (e: Event) => void;\n\n constructor() {\n const grid = this.elementRef.nativeElement;\n registerFeatureClaim(grid, 'masterDetail', () => this.masterDetail());\n claimEvent(grid, 'detail-expand');\n }\n\n ngOnInit(): void {\n const grid = this.elementRef.nativeElement;\n this.listener = (e: Event): void => this.detailExpand.emit((e as CustomEvent<DetailExpandDetail>).detail);\n grid.addEventListener('detail-expand', this.listener);\n }\n\n ngOnDestroy(): void {\n const grid = this.elementRef.nativeElement;\n if (this.listener) {\n grid.removeEventListener('detail-expand', this.listener);\n this.listener = undefined;\n }\n unregisterFeatureClaim(grid, 'masterDetail');\n unclaimEvent(grid, 'detail-expand');\n }\n}\n","/**\n * Master-detail feature for @toolbox-web/grid-angular\n *\n * Import this module to enable the `[masterDetail]` input on the `Grid`\n * directive AND to wire `<tbw-grid-detail>` Angular templates into the\n * MasterDetailPlugin's `detailRenderer`.\n *\n * @example\n * ```typescript\n * // In your bootstrap (e.g. main.ts or app.component.ts):\n * import '@toolbox-web/grid-angular/features/master-detail';\n * ```\n *\n * ```html\n * <tbw-grid [masterDetail]=\"{ showExpandColumn: true }\">\n * <tbw-grid-detail>\n * <ng-template let-row>...</ng-template>\n * </tbw-grid-detail>\n * </tbw-grid>\n * ```\n *\n * @packageDocumentation\n */\n\nimport type { Type } from '@angular/core';\nimport {\n getDetailTemplate,\n isComponentClass,\n registerDetailRendererBridge,\n registerFeatureConfigPreprocessor,\n registerTemplateBridge,\n type GridAdapter,\n type GridDetailContext,\n} from '@toolbox-web/grid-angular';\nimport '@toolbox-web/grid/features/master-detail';\nimport type { MasterDetailConfig } from './grid-master-detail.directive';\nexport { GridMasterDetailDirective } from './grid-master-detail.directive';\nexport type { MasterDetailConfig } from './grid-master-detail.directive';\nexport type { _Augmentation as _MasterDetailAugmentation } from '@toolbox-web/grid/features/master-detail';\n\n// ---------------------------------------------------------------------------\n// Re-exports from `@toolbox-web/grid-angular` (main entry).\n//\n// `GridDetailView` (and its `getDetailTemplate` helper / `GridDetailContext`\n// type) still physically live in the main entry today but are master-detail\n// specific. They are re-exported here so consumers can import them from the\n// feature entry that owns the runtime behaviour. The same symbols are\n// `@deprecated` on the main entry; in v2.0.0 the source will physically move\n// into this secondary entry and the deprecated re-exports on the main entry\n// will be removed.\n// ---------------------------------------------------------------------------\nexport { getDetailTemplate, GridDetailView } from '@toolbox-web/grid-angular';\nexport type { GridDetailContext } from '@toolbox-web/grid-angular';\n\n/**\n * Subset of `MasterDetailPlugin` we touch from the bridge. Avoids importing\n * the plugin class itself (would defeat tree-shaking and re-introduce the\n * coupling we just removed from the core directive).\n */\ninterface MasterDetailPluginLike {\n refreshDetailRenderer?: () => void;\n}\n\n// Install the row renderer bridge on the adapter. This is what\n// `adapter.createDetailRenderer(grid)` and `adapter.parseDetailElement(el)`\n// delegate to. Without this import, both methods return undefined.\nregisterDetailRendererBridge(<TRow = unknown>(gridElement: HTMLElement, adapter: GridAdapter) => {\n // Type inferred from `getDetailTemplate` (same package instance as `adapter`),\n // not from a local `import type { TemplateRef } from '@angular/core'` — the\n // latter resolves through Bun's `.bun/` cache during ng-packagr build and\n // produces a brand-incompatible TemplateRef vs the built adapter `.d.ts`.\n const template = getDetailTemplate(gridElement);\n if (!template) return undefined;\n\n return (row: TRow) => {\n const context: GridDetailContext<TRow> = { $implicit: row, row };\n const viewRef = adapter.createTrackedEmbeddedView(template, context);\n const container = document.createElement('div');\n viewRef.rootNodes.forEach((node: Node) => container.appendChild(node));\n return container;\n };\n});\n\n// Wire <tbw-grid-detail> Angular templates into the MasterDetailPlugin once\n// content templates are registered. The plugin's `parseLightDomDetail()`\n// already calls back into the adapter via `grid.__frameworkAdapter.parseDetailElement`\n// (which the `Grid` directive set in `ngOnInit`), so all we need to do here\n// is trigger a refresh once Angular's content templates are available.\nregisterTemplateBridge(({ grid }) => {\n // Only act when the user actually placed a <tbw-grid-detail> in light DOM.\n const detailElement = grid.querySelector('tbw-grid-detail');\n if (!detailElement) return;\n\n // The plugin must already have been attached (via [masterDetail] input,\n // gridConfig.features.masterDetail, or gridConfig.plugins). Use the runtime\n // lookup so we don't miss plugins instantiated from `gridConfig.features`,\n // which never appear in `gridConfig.plugins`.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const existingPlugin = (grid as any).getPluginByName?.('masterDetail') as MasterDetailPluginLike | undefined;\n\n if (!existingPlugin) {\n console.warn(\n '[tbw-grid-angular] <tbw-grid-detail> found but MasterDetailPlugin is not configured.\\n' +\n 'Add the [masterDetail] input, set gridConfig.features.masterDetail, or include\\n' +\n 'MasterDetailPlugin in gridConfig.plugins:\\n\\n' +\n ' <tbw-grid [masterDetail]=\"{ showExpandColumn: true }\">...</tbw-grid>\\n\\n' +\n 'or:\\n\\n' +\n ' gridConfig = { features: { masterDetail: { showExpandColumn: true } } };',\n );\n return;\n }\n\n existingPlugin.refreshDetailRenderer?.();\n});\n\n/**\n * Bridge any Angular component class used as `masterDetail.detailRenderer` to\n * a plain `(row, rowIndex) => HTMLElement` function before the core plugin\n * factory consumes the config. Without this preprocessor, a component class\n * passed as `detailRenderer` would be invoked as a function at render time\n * and crash. Light-DOM `<tbw-grid-detail>` templates continue to win via\n * `parseLightDomDetail` inside the plugin.\n *\n * @since 1.7.1\n */\nregisterFeatureConfigPreprocessor('masterDetail', (config, adapter) => {\n if (!config || typeof config !== 'object') return config;\n const cfg = config as MasterDetailConfig;\n if (!isComponentClass(cfg.detailRenderer)) return config;\n\n const componentClass = cfg.detailRenderer as Type<unknown>;\n const mount = adapter.mountComponentRenderer<{ row: unknown; rowIndex: number }>(componentClass, (ctx) => ({\n row: ctx.row,\n rowIndex: ctx.rowIndex,\n }));\n const cached = new Map<unknown, HTMLElement>();\n const detailRenderer: MasterDetailConfig['detailRenderer'] = (row, rowIndex) => {\n const existing = cached.get(row);\n if (existing) return existing;\n const { hostElement } = mount({ row, rowIndex });\n cached.set(row, hostElement);\n return hostElement;\n };\n return { ...cfg, detailRenderer };\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;AAUG;AA6BH;;;;AAIG;MAKU,yBAAyB,CAAA;AACnB,IAAA,UAAU,GAAG,MAAM,EAAC,UAA2B,EAAC;IAExD,YAAY,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EA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
|
+
{"version":3,"file":"toolbox-web-grid-angular-features-master-detail.mjs","sources":["../../../../libs/grid-angular/features/master-detail/src/grid-detail-view.directive.ts","../../../../libs/grid-angular/features/master-detail/src/grid-master-detail.directive.ts","../../../../libs/grid-angular/features/master-detail/src/index.ts","../../../../libs/grid-angular/features/master-detail/src/toolbox-web-grid-angular-features-master-detail.ts"],"sourcesContent":["import { contentChild, Directive, effect, ElementRef, inject, input, TemplateRef } from '@angular/core';\nimport type { ExpandCollapseAnimation } from '@toolbox-web/grid';\n\n/**\n * Context object passed to the detail renderer template.\n * Contains the row data for the expanded detail view.\n * @since 0.1.0\n */\nexport interface GridDetailContext<TRow = unknown> {\n /** The row data (implicit binding for let-row) */\n $implicit: TRow;\n /** The row data (explicit binding) */\n row: TRow;\n}\n\n// Global registry mapping DOM elements to their templates\nconst detailTemplateRegistry = new Map<HTMLElement, TemplateRef<GridDetailContext>>();\n\n/**\n * Gets the detail template registered for a given grid element.\n * Used by AngularGridAdapter to retrieve templates at render time.\n * @since 0.1.0\n */\nexport function getDetailTemplate(gridElement: HTMLElement): TemplateRef<GridDetailContext> | undefined {\n // Look for tbw-grid-detail child and get its template\n const detailElement = gridElement.querySelector('tbw-grid-detail');\n if (detailElement) {\n return detailTemplateRegistry.get(detailElement as HTMLElement);\n }\n return undefined;\n}\n\n/**\n * Directive that captures an `<ng-template>` for use as a master-detail row renderer.\n *\n * This enables declarative Angular component usage for expandable detail rows\n * that appear below the main row when expanded.\n *\n * ## Usage\n *\n * ```html\n * <tbw-grid [rows]=\"rows\" [gridConfig]=\"config\">\n * <tbw-grid-detail [showExpandColumn]=\"true\" animation=\"slide\">\n * <ng-template let-row>\n * <app-detail-panel [employee]=\"row\" />\n * </ng-template>\n * </tbw-grid-detail>\n * </tbw-grid>\n * ```\n *\n * The template context provides:\n * - `$implicit` / `row`: The full row data object\n *\n * Import the directive from the master-detail feature entry:\n *\n * ```typescript\n * import { GridDetailView } from '@toolbox-web/grid-angular/features/master-detail';\n *\n * @Component({\n * imports: [GridDetailView],\n * // ...\n * })\n * ```\n *\n * @example\n * ```html\n * <tbw-grid [rows]=\"rows\" [gridConfig]=\"config\">\n * <tbw-grid-detail [showExpandColumn]=\"true\" animation=\"slide\">\n * <ng-template let-row>\n * <app-detail-panel [employee]=\"row\" />\n * </ng-template>\n * </tbw-grid-detail>\n * </tbw-grid>\n * ```\n *\n * @category Directive\n * @since 0.1.0\n */\n@Directive({ selector: 'tbw-grid-detail' })\nexport class GridDetailView {\n private elementRef = inject(ElementRef<HTMLElement>);\n\n /** Whether to show the expand/collapse column. Default: true */\n showExpandColumn = input<boolean>(true);\n\n /** Animation style for expand/collapse. Default: 'slide' */\n animation = input<ExpandCollapseAnimation>('slide');\n\n /**\n * Query for the ng-template content child.\n */\n template = contentChild(TemplateRef<GridDetailContext>);\n\n /** Effect that triggers when the template is available */\n private onTemplateReceived = effect(() => {\n const template = this.template();\n if (template) {\n // Register the template for this element\n detailTemplateRegistry.set(this.elementRef.nativeElement, template);\n }\n });\n\n /**\n * Static type guard for template context.\n * Enables type inference in templates.\n */\n static ngTemplateContextGuard(dir: GridDetailView, ctx: unknown): ctx is GridDetailContext {\n return true;\n }\n}\n","/**\n * `GridMasterDetailDirective` — owns `[masterDetail]` and `(detailExpand)`\n * on `<tbw-grid>`. See `GridFilteringDirective` for the full rationale.\n *\n * Note: this directive is independent of the higher-level\n * `<tbw-grid-detail>` template element + `GridDetailView` wrapper, which\n * uses a different bridging mechanism (template registration). Apps using\n * the template form do not need this directive.\n *\n * @category Directive\n */\nimport { Directive, ElementRef, inject, input, OnDestroy, OnInit, output, type Type } from '@angular/core';\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport { claimEvent, registerFeatureClaim, unclaimEvent, unregisterFeatureClaim } from '@toolbox-web/grid-angular';\nimport type {\n MasterDetailConfig as CoreMasterDetailConfig,\n DetailExpandDetail,\n} from '@toolbox-web/grid/plugins/master-detail';\n\n/**\n * Angular-specific master-detail config that allows an Angular component class\n * as `detailRenderer`.\n *\n * Extends the core `MasterDetailConfig` to accept a `Type<unknown>` for\n * `detailRenderer` in addition to the vanilla\n * `(row, rowIndex) => HTMLElement | string` signature. Bridging to vanilla\n * DOM is handled by the side-effect import\n * `@toolbox-web/grid-angular/features/master-detail`.\n *\n * Re-exported from the feature entry under the same name as the core type\n * so Angular consumers see a single canonical `MasterDetailConfig` from\n * `@toolbox-web/grid-angular/features/master-detail`.\n *\n * @since 1.7.1\n */\nexport type MasterDetailConfig = Omit<CoreMasterDetailConfig, 'detailRenderer'> & {\n detailRenderer?: CoreMasterDetailConfig['detailRenderer'] | Type<unknown>;\n};\n\n/**\n * Owns the binding(s) `[masterDetail], [detailExpand]` on `<tbw-grid>` for the matching feature plugin. See `GridFilteringDirective` for the full rationale.\n *\n * @category Directive\n */\n@Directive({\n selector: 'tbw-grid[masterDetail], tbw-grid[detailExpand]',\n standalone: true,\n})\nexport class GridMasterDetailDirective implements OnInit, OnDestroy {\n private readonly elementRef = inject(ElementRef<DataGridElement>);\n\n readonly masterDetail = input<MasterDetailConfig>();\n readonly detailExpand = output<DetailExpandDetail>();\n\n private listener?: (e: Event) => void;\n\n constructor() {\n const grid = this.elementRef.nativeElement;\n registerFeatureClaim(grid, 'masterDetail', () => this.masterDetail());\n claimEvent(grid, 'detail-expand');\n }\n\n ngOnInit(): void {\n const grid = this.elementRef.nativeElement;\n this.listener = (e: Event): void => this.detailExpand.emit((e as CustomEvent<DetailExpandDetail>).detail);\n grid.addEventListener('detail-expand', this.listener);\n }\n\n ngOnDestroy(): void {\n const grid = this.elementRef.nativeElement;\n if (this.listener) {\n grid.removeEventListener('detail-expand', this.listener);\n this.listener = undefined;\n }\n unregisterFeatureClaim(grid, 'masterDetail');\n unclaimEvent(grid, 'detail-expand');\n }\n}\n","/**\n * Master-detail feature for @toolbox-web/grid-angular\n *\n * Import this module to enable the `[masterDetail]` input on the `Grid`\n * directive AND to wire `<tbw-grid-detail>` Angular templates into the\n * MasterDetailPlugin's `detailRenderer`.\n *\n * @example\n * ```typescript\n * // In your bootstrap (e.g. main.ts or app.component.ts):\n * import '@toolbox-web/grid-angular/features/master-detail';\n * ```\n *\n * ```html\n * <tbw-grid [masterDetail]=\"{ showExpandColumn: true }\">\n * <tbw-grid-detail>\n * <ng-template let-row>...</ng-template>\n * </tbw-grid-detail>\n * </tbw-grid>\n * ```\n *\n * @packageDocumentation\n */\n\nimport type { Type } from '@angular/core';\nimport {\n isComponentClass,\n registerDetailRendererBridge,\n registerFeatureConfigPreprocessor,\n registerTemplateBridge,\n type GridAdapter,\n} from '@toolbox-web/grid-angular';\nimport '@toolbox-web/grid/features/master-detail';\nimport { getDetailTemplate, type GridDetailContext } from './grid-detail-view.directive';\nimport type { MasterDetailConfig } from './grid-master-detail.directive';\nexport { GridMasterDetailDirective } from './grid-master-detail.directive';\nexport type { MasterDetailConfig } from './grid-master-detail.directive';\nexport type { _Augmentation as _MasterDetailAugmentation } from '@toolbox-web/grid/features/master-detail';\n\n// ---------------------------------------------------------------------------\n// Master-detail-owned directive + helpers. These physically live in this\n// secondary entry (the runtime behaviour lives here too).\n// ---------------------------------------------------------------------------\nexport { getDetailTemplate, GridDetailView } from './grid-detail-view.directive';\nexport type { GridDetailContext } from './grid-detail-view.directive';\n\n/**\n * Subset of `MasterDetailPlugin` we touch from the bridge. Avoids importing\n * the plugin class itself (would defeat tree-shaking and re-introduce the\n * coupling we just removed from the core directive).\n */\ninterface MasterDetailPluginLike {\n refreshDetailRenderer?: () => void;\n}\n\n// Install the row renderer bridge on the adapter. This is what\n// `adapter.createDetailRenderer(grid)` and `adapter.parseDetailElement(el)`\n// delegate to. Without this import, both methods return undefined.\nregisterDetailRendererBridge(<TRow = unknown>(gridElement: HTMLElement, adapter: GridAdapter) => {\n // Type inferred from `getDetailTemplate` (same package instance as `adapter`),\n // not from a local `import type { TemplateRef } from '@angular/core'` — the\n // latter resolves through Bun's `.bun/` cache during ng-packagr build and\n // produces a brand-incompatible TemplateRef vs the built adapter `.d.ts`.\n const template = getDetailTemplate(gridElement);\n if (!template) return undefined;\n\n return (row: TRow) => {\n const context: GridDetailContext<TRow> = { $implicit: row, row };\n const viewRef = adapter.createTrackedEmbeddedView(template, context);\n const container = document.createElement('div');\n viewRef.rootNodes.forEach((node: Node) => container.appendChild(node));\n return container;\n };\n});\n\n// Wire <tbw-grid-detail> Angular templates into the MasterDetailPlugin once\n// content templates are registered. The plugin's `parseLightDomDetail()`\n// already calls back into the adapter via `grid.__frameworkAdapter.parseDetailElement`\n// (which the `Grid` directive set in `ngOnInit`), so all we need to do here\n// is trigger a refresh once Angular's content templates are available.\nregisterTemplateBridge(({ grid }) => {\n // Only act when the user actually placed a <tbw-grid-detail> in light DOM.\n const detailElement = grid.querySelector('tbw-grid-detail');\n if (!detailElement) return;\n\n // The plugin must already have been attached (via [masterDetail] input,\n // gridConfig.features.masterDetail, or gridConfig.plugins). Use the runtime\n // lookup so we don't miss plugins instantiated from `gridConfig.features`,\n // which never appear in `gridConfig.plugins`.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const existingPlugin = (grid as any).getPluginByName?.('masterDetail') as MasterDetailPluginLike | undefined;\n\n if (!existingPlugin) {\n console.warn(\n '[tbw-grid-angular] <tbw-grid-detail> found but MasterDetailPlugin is not configured.\\n' +\n 'Add the [masterDetail] input, set gridConfig.features.masterDetail, or include\\n' +\n 'MasterDetailPlugin in gridConfig.plugins:\\n\\n' +\n ' <tbw-grid [masterDetail]=\"{ showExpandColumn: true }\">...</tbw-grid>\\n\\n' +\n 'or:\\n\\n' +\n ' gridConfig = { features: { masterDetail: { showExpandColumn: true } } };',\n );\n return;\n }\n\n existingPlugin.refreshDetailRenderer?.();\n});\n\n/**\n * Bridge any Angular component class used as `masterDetail.detailRenderer` to\n * a plain `(row, rowIndex) => HTMLElement` function before the core plugin\n * factory consumes the config. Without this preprocessor, a component class\n * passed as `detailRenderer` would be invoked as a function at render time\n * and crash. Light-DOM `<tbw-grid-detail>` templates continue to win via\n * `parseLightDomDetail` inside the plugin.\n *\n * @since 1.7.1\n */\nregisterFeatureConfigPreprocessor('masterDetail', (config, adapter) => {\n if (!config || typeof config !== 'object') return config;\n const cfg = config as MasterDetailConfig;\n if (!isComponentClass(cfg.detailRenderer)) return config;\n\n const componentClass = cfg.detailRenderer as Type<unknown>;\n const mount = adapter.mountComponentRenderer<{ row: unknown; rowIndex: number }>(componentClass, (ctx) => ({\n row: ctx.row,\n rowIndex: ctx.rowIndex,\n }));\n const cached = new Map<unknown, HTMLElement>();\n const detailRenderer: MasterDetailConfig['detailRenderer'] = (row, rowIndex) => {\n const existing = cached.get(row);\n if (existing) return existing;\n const { hostElement } = mount({ row, rowIndex });\n cached.set(row, hostElement);\n return hostElement;\n };\n return { ...cfg, detailRenderer };\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAeA;AACA,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAA+C;AAErF;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,WAAwB,EAAA;;IAExD,MAAM,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC,iBAAiB,CAAC;IAClE,IAAI,aAAa,EAAE;AACjB,QAAA,OAAO,sBAAsB,CAAC,GAAG,CAAC,aAA4B,CAAC;IACjE;AACA,IAAA,OAAO,SAAS;AAClB;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CG;MAEU,cAAc,CAAA;AACjB,IAAA,UAAU,GAAG,MAAM,EAAC,UAAuB,EAAC;;AAGpD,IAAA,gBAAgB,GAAG,KAAK,CAAU,IAAI,uFAAC;;AAGvC,IAAA,SAAS,GAAG,KAAK,CAA0B,OAAO,gFAAC;AAEnD;;AAEG;AACH,IAAA,QAAQ,GAAG,YAAY,EAAC,WAA8B,gFAAC;;AAG/C,IAAA,kBAAkB,GAAG,MAAM,CAAC,MAAK;AACvC,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE;QA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,EAAE;AACnC,CAAC,CAAC;;ACxIF;;AAEG;;;;"}
|
|
@@ -128,27 +128,13 @@ function bridgeSlot(adapter, slot) {
|
|
|
128
128
|
}
|
|
129
129
|
return slot;
|
|
130
130
|
}
|
|
131
|
-
// Bridge any Angular component classes embedded in `
|
|
131
|
+
// Bridge any Angular component classes embedded in `slots`
|
|
132
132
|
// to plain renderer functions before the core plugin factory consumes the config.
|
|
133
133
|
registerFeatureConfigPreprocessor('pinnedRows', (config, adapter) => {
|
|
134
134
|
if (!config || typeof config !== 'object')
|
|
135
135
|
return config;
|
|
136
136
|
const cfg = config;
|
|
137
137
|
let next = cfg;
|
|
138
|
-
// Legacy customPanels bridging.
|
|
139
|
-
if (Array.isArray(cfg.customPanels)) {
|
|
140
|
-
const hasComponentRender = cfg.customPanels.some((panel) => isComponentClass(panel.render));
|
|
141
|
-
if (hasComponentRender) {
|
|
142
|
-
next = {
|
|
143
|
-
...next,
|
|
144
|
-
customPanels: cfg.customPanels.map((panel) => {
|
|
145
|
-
if (!isComponentClass(panel.render))
|
|
146
|
-
return panel;
|
|
147
|
-
return { ...panel, render: buildPanelRenderer(adapter, panel.render) };
|
|
148
|
-
}),
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
138
|
// Slots[] bridging \u2014 each PanelSlot.render may be a component class, or an
|
|
153
139
|
// array of { zone?, render } where each render may be a component class.
|
|
154
140
|
if (Array.isArray(cfg.slots)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbox-web-grid-angular-features-pinned-rows.mjs","sources":["../../../../libs/grid-angular/features/pinned-rows/src/cached-panel-renderer.ts","../../../../libs/grid-angular/features/pinned-rows/src/grid-pinned-rows.directive.ts","../../../../libs/grid-angular/features/pinned-rows/src/index.ts","../../../../libs/grid-angular/features/pinned-rows/src/toolbox-web-grid-angular-features-pinned-rows.ts"],"sourcesContent":["/**\n * @internal\n *\n * Cached panel-renderer factory for the Angular pinned-rows adapter (#354).\n *\n * Extracted into its own module so the pure caching logic can be unit-tested\n * without depending on the heavy `@toolbox-web/grid-angular` barrel (which\n * pulls in every directive at module-load and requires substantial Angular\n * DI mocking).\n *\n * @since 1.7.0\n */\nimport type { ComponentRef, Type } from '@angular/core';\nimport type { PinnedRowsContext } from '@toolbox-web/grid/plugins/pinned-rows';\n\n/**\n * Minimal structural shape of the adapter API used by {@link buildCachedPanelRenderer}.\n * Mirrors `GridAdapter.mountComponentRenderer` without the rest of the surface\n * so tests can pass a stub.\n *\n * @internal\n */\nexport interface PanelRendererAdapter {\n mountComponentRenderer<TCtx>(\n componentClass: Type<unknown>,\n mapInputs: (ctx: TCtx) => Record<string, unknown>,\n ): (ctx: TCtx) => { hostElement: HTMLElement; componentRef: ComponentRef<unknown> };\n}\n\n/**\n * Map a {@link PinnedRowsContext} to the Angular component input bag.\n * Centralized so both the initial `mountComponentRenderer` call and the\n * per-call input-refresh path stay in sync.\n *\n * @internal\n */\nexport function mapPinnedRowsInputs(ctx: PinnedRowsContext): Record<string, unknown> {\n return {\n totalRows: ctx.totalRows,\n filteredRows: ctx.filteredRows,\n selectedRows: ctx.selectedRows,\n columns: ctx.columns,\n rows: ctx.rows,\n grid: ctx.grid,\n };\n}\n\n/**\n * Build a pinned-rows panel renderer function from an Angular component class.\n * The component should accept inputs from {@link PinnedRowsContext}.\n *\n * Caches the mounted component across renders — the pinned-rows plugin\n * (`renderPanelSlot`) reference-checks renderer outputs to skip DOM mutation\n * when nothing changed. On subsequent calls inputs are refreshed via\n * `componentRef.setInput()` instead of mounting a fresh component.\n *\n * The cached `ComponentRef` is tracked in the adapter's render pool, so it is\n * destroyed automatically when the grid is disposed.\n *\n * @internal\n */\nexport function buildCachedPanelRenderer(\n adapter: PanelRendererAdapter,\n componentClass: Type<unknown>,\n): (ctx: PinnedRowsContext) => HTMLElement {\n const mount = adapter.mountComponentRenderer<PinnedRowsContext>(componentClass, mapPinnedRowsInputs);\n let cached: { hostElement: HTMLElement; componentRef: ComponentRef<unknown> } | null = null;\n return (ctx) => {\n if (!cached) {\n cached = mount(ctx);\n return cached.hostElement;\n }\n const inputs = mapPinnedRowsInputs(ctx);\n for (const name of Object.keys(inputs)) {\n cached.componentRef.setInput(name, inputs[name]);\n }\n cached.componentRef.changeDetectorRef.detectChanges();\n return cached.hostElement;\n };\n}\n","/**\n * `GridPinnedRowsDirective` — owns `[pinnedRows]` on `<tbw-grid>`. No\n * event outputs. See `GridFilteringDirective` for the full rationale.\n *\n * @category Directive\n */\nimport { Directive, ElementRef, inject, input, OnDestroy, type Type } from '@angular/core';\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport { registerFeatureClaim, unregisterFeatureClaim } from '@toolbox-web/grid-angular';\nimport type {\n PinnedRowsConfig as CorePinnedRowsConfig,\n PanelZone,\n PinnedRowsContext,\n} from '@toolbox-web/grid/plugins/pinned-rows';\n\n/**\n * Angular-shaped panel-slot render: a renderer function (vanilla), an Angular\n * component class, or an array of zoned entries that each accept the same.\n *\n * Component instances receive the {@link PinnedRowsContext} fields as inputs.\n *\n * @since 1.7.1\n */\nexport type PanelRender = ((ctx: PinnedRowsContext) => HTMLElement | null) | Type<unknown>;\n\n/**\n * Angular-shaped zoned panel render entry.\n *\n * @since 1.7.1\n */\nexport interface ZonedPanelRender {\n zone?: PanelZone;\n render: PanelRender;\n}\n\n/**\n * Angular-shaped pinned-rows panel slot.\n *\n * @since 1.7.1\n */\nexport interface PanelSlot {\n id?: string;\n position?: 'top' | 'bottom';\n render: PanelRender | ZonedPanelRender[];\n}\n\ntype CoreSlot = NonNullable<CorePinnedRowsConfig['slots']>[number];\ntype CoreAggregationSlot = Exclude<CoreSlot, { render: unknown }>;\n\n/**\n * Angular-shaped pinned-rows slot \\u2014 either an aggregation slot (passthrough)\n * or a panel slot accepting Angular component classes as `render`.\n *\n * @since 1.7.1\n */\nexport type PinnedRowSlot = CoreAggregationSlot | PanelSlot;\n\n/**\n * Pinned-rows config widened to accept Angular component classes as `render`\n * inside `slots[]` and `customPanels[]`. Bridging to vanilla DOM is handled\n * by the side-effect import `@toolbox-web/grid-angular/features/pinned-rows`.\n *\n * Re-exported under the same name as the core type so Angular users see a\n * single canonical `PinnedRowsConfig` from\n * `@toolbox-web/grid-angular/features/pinned-rows`.\n *\n * @since 1.7.1\n */\nexport type PinnedRowsConfig = Omit<CorePinnedRowsConfig, 'slots' | 'customPanels'> & {\n slots?: PinnedRowSlot[];\n customPanels?: Array<{\n id: string;\n position: PanelZone;\n render: ((ctx: PinnedRowsContext) => HTMLElement) | Type<unknown>;\n }>;\n};\n\n// ── Deprecated framework-prefixed aliases ──────────────────────────────────\n// Retained for backwards compatibility. New code should use the canonical\n// (unprefixed) names above.\n\n/** @deprecated Use {@link PanelRender} instead. */\nexport type AngularPanelRender = PanelRender;\n/** @deprecated Use {@link ZonedPanelRender} instead. */\nexport type AngularZonedPanelRender = ZonedPanelRender;\n/** @deprecated Use {@link PanelSlot} instead. */\nexport type AngularPanelSlot = PanelSlot;\n/** @deprecated Use {@link PinnedRowSlot} instead. */\nexport type AngularPinnedRowSlot = PinnedRowSlot;\n/** @deprecated Use {@link PinnedRowsConfig} instead. */\nexport type AngularPinnedRowsConfig = PinnedRowsConfig;\n\n/**\n * Owns the binding(s) `[pinnedRows]` on `<tbw-grid>` for the matching feature plugin. See `GridFilteringDirective` for the full rationale.\n *\n * @category Directive\n */\n@Directive({\n selector: 'tbw-grid[pinnedRows]',\n standalone: true,\n})\nexport class GridPinnedRowsDirective implements OnDestroy {\n private readonly elementRef = inject(ElementRef<DataGridElement>);\n\n readonly pinnedRows = input<boolean | PinnedRowsConfig>();\n\n constructor() {\n registerFeatureClaim(this.elementRef.nativeElement, 'pinnedRows', () => this.pinnedRows());\n }\n\n ngOnDestroy(): void {\n unregisterFeatureClaim(this.elementRef.nativeElement, 'pinnedRows');\n }\n}\n","/**\n * Pinned rows feature for @toolbox-web/grid-angular\n *\n * Import this module to enable the `pinnedRows` input on Grid directive.\n *\n * @example\n * ```typescript\n * import '@toolbox-web/grid-angular/features/pinned-rows';\n *\n * <tbw-grid [pinnedRows]=\"{ bottom: [{ type: 'aggregation' }] }\" />\n * ```\n *\n * @packageDocumentation\n */\n\nimport type { Type } from '@angular/core';\nimport { isComponentClass, registerFeatureConfigPreprocessor, type GridAdapter } from '@toolbox-web/grid-angular';\nimport '@toolbox-web/grid/features/pinned-rows';\nimport type {\n PinnedRowsConfig as CorePinnedRowsConfig,\n PinnedRowSlot as CorePinnedRowSlot,\n ZonedPanelRender as CoreZonedPanelRender,\n PinnedRowsContext,\n} from '@toolbox-web/grid/plugins/pinned-rows';\nimport { buildCachedPanelRenderer } from './cached-panel-renderer';\nexport { GridPinnedRowsDirective } from './grid-pinned-rows.directive';\nexport type {\n // Deprecated framework-prefixed aliases \\u2014 kept for backwards compatibility.\n AngularPanelRender,\n AngularPanelSlot,\n AngularPinnedRowsConfig,\n AngularPinnedRowSlot,\n AngularZonedPanelRender,\n // Canonical (unprefixed) widening types. Same names as the core types\n // from `@toolbox-web/grid` \\u2014 these accept Angular component classes in\n // addition to the vanilla `HTMLElement`-returning renderer functions.\n PanelRender,\n PanelSlot,\n PinnedRowsConfig,\n PinnedRowSlot,\n ZonedPanelRender,\n} from './grid-pinned-rows.directive';\nexport type { _Augmentation as _PinnedRowsAugmentation } from '@toolbox-web/grid/features/pinned-rows';\n\n/**\n * Build a pinned-rows panel renderer function from an Angular component class.\n * Thin wrapper around {@link buildCachedPanelRenderer} that fixes the adapter\n * type to the concrete `GridAdapter`.\n */\nfunction buildPanelRenderer(\n adapter: GridAdapter,\n componentClass: Type<unknown>,\n): (ctx: PinnedRowsContext) => HTMLElement {\n return buildCachedPanelRenderer(adapter, componentClass);\n}\n\n/**\n * Bridge a single pinned-row slot. Aggregation slots (no `render`) pass through.\n * For panel slots, wrap any component-class `render` (or array entry's `render`)\n * with the Angular component renderer.\n */\nfunction bridgeSlot(adapter: GridAdapter, slot: CorePinnedRowSlot): CorePinnedRowSlot {\n if (!('render' in slot) || slot.render == null) return slot;\n\n if (Array.isArray(slot.render)) {\n const zoned: CoreZonedPanelRender[] = slot.render.map((entry) => {\n if (entry?.render == null) return entry;\n if (isComponentClass(entry.render)) {\n return { zone: entry.zone, render: buildPanelRenderer(adapter, entry.render as Type<unknown>) };\n }\n return entry;\n });\n return { ...slot, render: zoned };\n }\n\n if (isComponentClass(slot.render)) {\n return { ...slot, render: buildPanelRenderer(adapter, slot.render as Type<unknown>) };\n }\n return slot;\n}\n\n// Bridge any Angular component classes embedded in `customPanels` and `slots`\n// to plain renderer functions before the core plugin factory consumes the config.\nregisterFeatureConfigPreprocessor('pinnedRows', (config, adapter) => {\n if (!config || typeof config !== 'object') return config;\n const cfg = config as CorePinnedRowsConfig;\n let next: CorePinnedRowsConfig = cfg;\n\n // Legacy customPanels bridging.\n if (Array.isArray(cfg.customPanels)) {\n const hasComponentRender = cfg.customPanels.some((panel) => isComponentClass(panel.render));\n if (hasComponentRender) {\n next = {\n ...next,\n customPanels: cfg.customPanels.map((panel) => {\n if (!isComponentClass(panel.render)) return panel;\n return { ...panel, render: buildPanelRenderer(adapter, panel.render) };\n }),\n };\n }\n }\n\n // Slots[] bridging \\u2014 each PanelSlot.render may be a component class, or an\n // array of { zone?, render } where each render may be a component class.\n if (Array.isArray(cfg.slots)) {\n next = { ...next, slots: cfg.slots.map((slot) => bridgeSlot(adapter, slot)) };\n }\n\n return next;\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AA6BA;;;;;;AAMG;AACG,SAAU,mBAAmB,CAAC,GAAsB,EAAA;IACxD,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,IAAI;KACf;AACH;AAEA;;;;;;;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AAG,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE;IAC/E;AAEA,IAAA,OAAO,IAAI;AACb,CAAC,CAAC;;AC7GF;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"toolbox-web-grid-angular-features-pinned-rows.mjs","sources":["../../../../libs/grid-angular/features/pinned-rows/src/cached-panel-renderer.ts","../../../../libs/grid-angular/features/pinned-rows/src/grid-pinned-rows.directive.ts","../../../../libs/grid-angular/features/pinned-rows/src/index.ts","../../../../libs/grid-angular/features/pinned-rows/src/toolbox-web-grid-angular-features-pinned-rows.ts"],"sourcesContent":["/**\n * @internal\n *\n * Cached panel-renderer factory for the Angular pinned-rows adapter (#354).\n *\n * Extracted into its own module so the pure caching logic can be unit-tested\n * without depending on the heavy `@toolbox-web/grid-angular` barrel (which\n * pulls in every directive at module-load and requires substantial Angular\n * DI mocking).\n *\n * @since 1.7.0\n */\nimport type { ComponentRef, Type } from '@angular/core';\nimport type { PinnedRowsContext } from '@toolbox-web/grid/plugins/pinned-rows';\n\n/**\n * Minimal structural shape of the adapter API used by {@link buildCachedPanelRenderer}.\n * Mirrors `GridAdapter.mountComponentRenderer` without the rest of the surface\n * so tests can pass a stub.\n *\n * @internal\n */\nexport interface PanelRendererAdapter {\n mountComponentRenderer<TCtx>(\n componentClass: Type<unknown>,\n mapInputs: (ctx: TCtx) => Record<string, unknown>,\n ): (ctx: TCtx) => { hostElement: HTMLElement; componentRef: ComponentRef<unknown> };\n}\n\n/**\n * Map a {@link PinnedRowsContext} to the Angular component input bag.\n * Centralized so both the initial `mountComponentRenderer` call and the\n * per-call input-refresh path stay in sync.\n *\n * @internal\n */\nexport function mapPinnedRowsInputs(ctx: PinnedRowsContext): Record<string, unknown> {\n return {\n totalRows: ctx.totalRows,\n filteredRows: ctx.filteredRows,\n selectedRows: ctx.selectedRows,\n columns: ctx.columns,\n rows: ctx.rows,\n grid: ctx.grid,\n };\n}\n\n/**\n * Build a pinned-rows panel renderer function from an Angular component class.\n * The component should accept inputs from {@link PinnedRowsContext}.\n *\n * Caches the mounted component across renders — the pinned-rows plugin\n * (`renderPanelSlot`) reference-checks renderer outputs to skip DOM mutation\n * when nothing changed. On subsequent calls inputs are refreshed via\n * `componentRef.setInput()` instead of mounting a fresh component.\n *\n * The cached `ComponentRef` is tracked in the adapter's render pool, so it is\n * destroyed automatically when the grid is disposed.\n *\n * @internal\n */\nexport function buildCachedPanelRenderer(\n adapter: PanelRendererAdapter,\n componentClass: Type<unknown>,\n): (ctx: PinnedRowsContext) => HTMLElement {\n const mount = adapter.mountComponentRenderer<PinnedRowsContext>(componentClass, mapPinnedRowsInputs);\n let cached: { hostElement: HTMLElement; componentRef: ComponentRef<unknown> } | null = null;\n return (ctx) => {\n if (!cached) {\n cached = mount(ctx);\n return cached.hostElement;\n }\n const inputs = mapPinnedRowsInputs(ctx);\n for (const name of Object.keys(inputs)) {\n cached.componentRef.setInput(name, inputs[name]);\n }\n cached.componentRef.changeDetectorRef.detectChanges();\n return cached.hostElement;\n };\n}\n","/**\n * `GridPinnedRowsDirective` — owns `[pinnedRows]` on `<tbw-grid>`. No\n * event outputs. See `GridFilteringDirective` for the full rationale.\n *\n * @category Directive\n */\nimport { Directive, ElementRef, inject, input, OnDestroy, type Type } from '@angular/core';\nimport type { DataGridElement } from '@toolbox-web/grid';\nimport { registerFeatureClaim, unregisterFeatureClaim } from '@toolbox-web/grid-angular';\nimport type {\n PinnedRowsConfig as CorePinnedRowsConfig,\n PanelZone,\n PinnedRowsContext,\n} from '@toolbox-web/grid/plugins/pinned-rows';\n\n/**\n * Angular-shaped panel-slot render: a renderer function (vanilla), an Angular\n * component class, or an array of zoned entries that each accept the same.\n *\n * Component instances receive the {@link PinnedRowsContext} fields as inputs.\n *\n * @since 1.7.1\n */\nexport type PanelRender = ((ctx: PinnedRowsContext) => HTMLElement | null) | Type<unknown>;\n\n/**\n * Angular-shaped zoned panel render entry.\n *\n * @since 1.7.1\n */\nexport interface ZonedPanelRender {\n zone?: PanelZone;\n render: PanelRender;\n}\n\n/**\n * Angular-shaped pinned-rows panel slot.\n *\n * @since 1.7.1\n */\nexport interface PanelSlot {\n id?: string;\n position?: 'top' | 'bottom';\n render: PanelRender | ZonedPanelRender[];\n}\n\ntype CoreSlot = NonNullable<CorePinnedRowsConfig['slots']>[number];\ntype CoreAggregationSlot = Exclude<CoreSlot, { render: unknown }>;\n\n/**\n * Angular-shaped pinned-rows slot \\u2014 either an aggregation slot (passthrough)\n * or a panel slot accepting Angular component classes as `render`.\n *\n * @since 1.7.1\n */\nexport type PinnedRowSlot = CoreAggregationSlot | PanelSlot;\n\n/**\n * Pinned-rows config widened to accept Angular component classes as `render`\n * inside `slots[]`. Bridging to vanilla DOM is handled\n * by the side-effect import `@toolbox-web/grid-angular/features/pinned-rows`.\n *\n * Re-exported under the same name as the core type so Angular users see a\n * single canonical `PinnedRowsConfig` from\n * `@toolbox-web/grid-angular/features/pinned-rows`.\n *\n * @since 1.7.1\n */\nexport type PinnedRowsConfig = Omit<CorePinnedRowsConfig, 'slots'> & {\n slots?: PinnedRowSlot[];\n};\n\n// ── Deprecated framework-prefixed aliases ──────────────────────────────────\n// Retained for backwards compatibility. New code should use the canonical\n// (unprefixed) names above.\n\n/** @deprecated Use {@link PanelRender} instead. */\nexport type AngularPanelRender = PanelRender;\n/** @deprecated Use {@link ZonedPanelRender} instead. */\nexport type AngularZonedPanelRender = ZonedPanelRender;\n/** @deprecated Use {@link PanelSlot} instead. */\nexport type AngularPanelSlot = PanelSlot;\n/** @deprecated Use {@link PinnedRowSlot} instead. */\nexport type AngularPinnedRowSlot = PinnedRowSlot;\n/** @deprecated Use {@link PinnedRowsConfig} instead. */\nexport type AngularPinnedRowsConfig = PinnedRowsConfig;\n\n/**\n * Owns the binding(s) `[pinnedRows]` on `<tbw-grid>` for the matching feature plugin. See `GridFilteringDirective` for the full rationale.\n *\n * @category Directive\n */\n@Directive({\n selector: 'tbw-grid[pinnedRows]',\n standalone: true,\n})\nexport class GridPinnedRowsDirective implements OnDestroy {\n private readonly elementRef = inject(ElementRef<DataGridElement>);\n\n readonly pinnedRows = input<boolean | PinnedRowsConfig>();\n\n constructor() {\n registerFeatureClaim(this.elementRef.nativeElement, 'pinnedRows', () => this.pinnedRows());\n }\n\n ngOnDestroy(): void {\n unregisterFeatureClaim(this.elementRef.nativeElement, 'pinnedRows');\n }\n}\n","/**\n * Pinned rows feature for @toolbox-web/grid-angular\n *\n * Import this module to enable the `pinnedRows` input on Grid directive.\n *\n * @example\n * ```typescript\n * import '@toolbox-web/grid-angular/features/pinned-rows';\n *\n * <tbw-grid [pinnedRows]=\"{ bottom: [{ type: 'aggregation' }] }\" />\n * ```\n *\n * @packageDocumentation\n */\n\nimport type { Type } from '@angular/core';\nimport { isComponentClass, registerFeatureConfigPreprocessor, type GridAdapter } from '@toolbox-web/grid-angular';\nimport '@toolbox-web/grid/features/pinned-rows';\nimport type {\n PinnedRowsConfig as CorePinnedRowsConfig,\n PinnedRowSlot as CorePinnedRowSlot,\n ZonedPanelRender as CoreZonedPanelRender,\n PinnedRowsContext,\n} from '@toolbox-web/grid/plugins/pinned-rows';\nimport { buildCachedPanelRenderer } from './cached-panel-renderer';\nexport { GridPinnedRowsDirective } from './grid-pinned-rows.directive';\nexport type {\n // Deprecated framework-prefixed aliases \\u2014 kept for backwards compatibility.\n AngularPanelRender,\n AngularPanelSlot,\n AngularPinnedRowsConfig,\n AngularPinnedRowSlot,\n AngularZonedPanelRender,\n // Canonical (unprefixed) widening types. Same names as the core types\n // from `@toolbox-web/grid` \\u2014 these accept Angular component classes in\n // addition to the vanilla `HTMLElement`-returning renderer functions.\n PanelRender,\n PanelSlot,\n PinnedRowsConfig,\n PinnedRowSlot,\n ZonedPanelRender,\n} from './grid-pinned-rows.directive';\nexport type { _Augmentation as _PinnedRowsAugmentation } from '@toolbox-web/grid/features/pinned-rows';\n\n/**\n * Build a pinned-rows panel renderer function from an Angular component class.\n * Thin wrapper around {@link buildCachedPanelRenderer} that fixes the adapter\n * type to the concrete `GridAdapter`.\n */\nfunction buildPanelRenderer(\n adapter: GridAdapter,\n componentClass: Type<unknown>,\n): (ctx: PinnedRowsContext) => HTMLElement {\n return buildCachedPanelRenderer(adapter, componentClass);\n}\n\n/**\n * Bridge a single pinned-row slot. Aggregation slots (no `render`) pass through.\n * For panel slots, wrap any component-class `render` (or array entry's `render`)\n * with the Angular component renderer.\n */\nfunction bridgeSlot(adapter: GridAdapter, slot: CorePinnedRowSlot): CorePinnedRowSlot {\n if (!('render' in slot) || slot.render == null) return slot;\n\n if (Array.isArray(slot.render)) {\n const zoned: CoreZonedPanelRender[] = slot.render.map((entry) => {\n if (entry?.render == null) return entry;\n if (isComponentClass(entry.render)) {\n return { zone: entry.zone, render: buildPanelRenderer(adapter, entry.render as Type<unknown>) };\n }\n return entry;\n });\n return { ...slot, render: zoned };\n }\n\n if (isComponentClass(slot.render)) {\n return { ...slot, render: buildPanelRenderer(adapter, slot.render as Type<unknown>) };\n }\n return slot;\n}\n\n// Bridge any Angular component classes embedded in `slots`\n// to plain renderer functions before the core plugin factory consumes the config.\nregisterFeatureConfigPreprocessor('pinnedRows', (config, adapter) => {\n if (!config || typeof config !== 'object') return config;\n const cfg = config as CorePinnedRowsConfig;\n let next: CorePinnedRowsConfig = cfg;\n\n // Slots[] bridging \\u2014 each PanelSlot.render may be a component class, or an\n // array of { zone?, render } where each render may be a component class.\n if (Array.isArray(cfg.slots)) {\n next = { ...next, slots: cfg.slots.map((slot) => bridgeSlot(adapter, slot)) };\n }\n\n return next;\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AA6BA;;;;;;AAMG;AACG,SAAU,mBAAmB,CAAC,GAAsB,EAAA;IACxD,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,OAAO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E,MAAM,EAAE,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,MAAuB,CAAC,EAAE;YACjG;AACA,YAAA,OAAO,KAAK;AACd,QAAA,CAAC,CAAC;QACF,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE;IACnC;AAEA,IAAA,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;AACjC,QAAA,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAuB,CAAC,EAAE;IACvF;AACA,IAAA,OAAO,IAAI;AACb;AAEA;AACA;AACA,iCAAiC,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAI;AAClE,IAAA,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;AAAE,QAAA,OAAO,MAAM;IACxD,MAAM,GAAG,GAAG,MAA8B;IAC1C,IAAI,IAAI,GAAyB,GAAG;;;IAIpC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QAC5B,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE;IAC/E;AAEA,IAAA,OAAO,IAAI;AACb,CAAC,CAAC;;AC/FF;;AAEG;;;;"}
|
|
@@ -1,7 +1,113 @@
|
|
|
1
|
-
import { registerFeatureClaim, claimEvent, unregisterFeatureClaim, unclaimEvent, registerResponsiveCardRendererBridge,
|
|
1
|
+
import { registerFeatureClaim, claimEvent, unregisterFeatureClaim, unclaimEvent, registerResponsiveCardRendererBridge, registerTemplateBridge, registerFeatureConfigPreprocessor, isComponentClass } from '@toolbox-web/grid-angular';
|
|
2
2
|
import '@toolbox-web/grid/features/responsive';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { inject, ElementRef, input,
|
|
4
|
+
import { inject, ElementRef, input, contentChild, TemplateRef, effect, Directive, output } from '@angular/core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Registry to store responsive card templates by grid element.
|
|
8
|
+
* Used by AngularGridAdapter to create card renderers.
|
|
9
|
+
*/
|
|
10
|
+
const responsiveCardTemplateRegistry = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the responsive card template for a grid element.
|
|
13
|
+
*
|
|
14
|
+
* @param gridElement - The grid element to look up
|
|
15
|
+
* @returns The template reference or undefined if not found
|
|
16
|
+
* @since 0.4.0
|
|
17
|
+
*/
|
|
18
|
+
function getResponsiveCardTemplate(gridElement) {
|
|
19
|
+
// Find the tbw-grid-responsive-card element inside the grid
|
|
20
|
+
const cardElement = gridElement.querySelector('tbw-grid-responsive-card');
|
|
21
|
+
if (!cardElement)
|
|
22
|
+
return undefined;
|
|
23
|
+
return responsiveCardTemplateRegistry.get(cardElement);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Directive for providing custom Angular templates for responsive card layout.
|
|
27
|
+
*
|
|
28
|
+
* Use this directive to define how each row should render when the grid
|
|
29
|
+
* is in responsive/mobile mode. The template receives the row data and index.
|
|
30
|
+
*
|
|
31
|
+
* ## Usage
|
|
32
|
+
*
|
|
33
|
+
* ```html
|
|
34
|
+
* <tbw-grid [rows]="employees">
|
|
35
|
+
* <tbw-grid-responsive-card>
|
|
36
|
+
* <ng-template let-employee let-idx="index">
|
|
37
|
+
* <div class="employee-card">
|
|
38
|
+
* <img [src]="employee.avatar" alt="">
|
|
39
|
+
* <div class="info">
|
|
40
|
+
* <strong>{{ employee.name }}</strong>
|
|
41
|
+
* <span>{{ employee.department }}</span>
|
|
42
|
+
* </div>
|
|
43
|
+
* </div>
|
|
44
|
+
* </ng-template>
|
|
45
|
+
* </tbw-grid-responsive-card>
|
|
46
|
+
* </tbw-grid>
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* ## Important Notes
|
|
50
|
+
*
|
|
51
|
+
* - The ResponsivePlugin must be added to your grid config
|
|
52
|
+
* - The Grid directive will automatically configure the plugin's cardRenderer
|
|
53
|
+
* - Template context provides `$implicit` (row), `row`, and `index`
|
|
54
|
+
*
|
|
55
|
+
* @see ResponsivePlugin
|
|
56
|
+
* @category Directive
|
|
57
|
+
* @since 0.4.0
|
|
58
|
+
*/
|
|
59
|
+
class GridResponsiveCard {
|
|
60
|
+
elementRef = inject((ElementRef));
|
|
61
|
+
/**
|
|
62
|
+
* Card row height in pixels. Use `'auto'` for dynamic height based on content.
|
|
63
|
+
*
|
|
64
|
+
* Mirrors to the `card-row-height` attribute on the underlying
|
|
65
|
+
* `<tbw-grid-responsive-card>` element which the ResponsivePlugin reads.
|
|
66
|
+
*
|
|
67
|
+
* @default 'auto'
|
|
68
|
+
*/
|
|
69
|
+
cardRowHeight = input(...(ngDevMode ? [undefined, { debugName: "cardRowHeight" }] : /* istanbul ignore next */ []));
|
|
70
|
+
/**
|
|
71
|
+
* The ng-template containing the card content.
|
|
72
|
+
*/
|
|
73
|
+
template = contentChild((TemplateRef), ...(ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []));
|
|
74
|
+
/**
|
|
75
|
+
* Effect that registers the template when it becomes available.
|
|
76
|
+
*/
|
|
77
|
+
onTemplateReceived = effect(() => {
|
|
78
|
+
const template = this.template();
|
|
79
|
+
if (template) {
|
|
80
|
+
responsiveCardTemplateRegistry.set(this.elementRef.nativeElement, template);
|
|
81
|
+
}
|
|
82
|
+
}, ...(ngDevMode ? [{ debugName: "onTemplateReceived" }] : /* istanbul ignore next */ []));
|
|
83
|
+
/**
|
|
84
|
+
* Effect that mirrors the `cardRowHeight` input to the kebab-cased attribute
|
|
85
|
+
* read by the ResponsivePlugin.
|
|
86
|
+
*/
|
|
87
|
+
onCardRowHeightChange = effect(() => {
|
|
88
|
+
const value = this.cardRowHeight();
|
|
89
|
+
const element = this.elementRef.nativeElement;
|
|
90
|
+
if (value === undefined) {
|
|
91
|
+
element.removeAttribute('card-row-height');
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
element.setAttribute('card-row-height', value === 'auto' ? 'auto' : String(value));
|
|
95
|
+
}, ...(ngDevMode ? [{ debugName: "onCardRowHeightChange" }] : /* istanbul ignore next */ []));
|
|
96
|
+
/**
|
|
97
|
+
* Type guard for template context inference.
|
|
98
|
+
*/
|
|
99
|
+
static ngTemplateContextGuard(_directive, context) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: GridResponsiveCard, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
103
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.5", type: GridResponsiveCard, isStandalone: true, selector: "tbw-grid-responsive-card", inputs: { cardRowHeight: { classPropertyName: "cardRowHeight", publicName: "cardRowHeight", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "template", first: true, predicate: (TemplateRef), descendants: true, isSignal: true }], ngImport: i0 });
|
|
104
|
+
}
|
|
105
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.5", ngImport: i0, type: GridResponsiveCard, decorators: [{
|
|
106
|
+
type: Directive,
|
|
107
|
+
args: [{
|
|
108
|
+
selector: 'tbw-grid-responsive-card',
|
|
109
|
+
}]
|
|
110
|
+
}], propDecorators: { cardRowHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "cardRowHeight", required: false }] }], template: [{ type: i0.ContentChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }] } });
|
|
5
111
|
|
|
6
112
|
/**
|
|
7
113
|
* `GridResponsiveDirective` — owns `[responsive]` and `(responsiveChange)`
|
|
@@ -155,5 +261,5 @@ registerFeatureConfigPreprocessor('responsive', (config, adapter) => {
|
|
|
155
261
|
* Generated bundle index. Do not edit.
|
|
156
262
|
*/
|
|
157
263
|
|
|
158
|
-
export { GridResponsiveDirective };
|
|
264
|
+
export { GridResponsiveCard, GridResponsiveDirective, getResponsiveCardTemplate };
|
|
159
265
|
//# sourceMappingURL=toolbox-web-grid-angular-features-responsive.mjs.map
|