@simple-table/angular 3.9.9 → 4.0.0
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/dist/cjs/index.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/types/angular/src/index.d.ts +2 -1
- package/dist/types/angular/src/lib/SimpleTableComponent.d.ts +2 -0
- package/dist/types/core/src/core/SimpleTableVanilla.d.ts +8 -0
- package/dist/types/core/src/core/api/TableAPIImpl.d.ts +7 -1
- package/dist/types/core/src/index.d.ts +5 -1
- package/dist/types/core/src/managers/PivotManager.d.ts +35 -0
- package/dist/types/core/src/types/GetRowId.d.ts +7 -1
- package/dist/types/core/src/types/PivotTypes.d.ts +37 -0
- package/dist/types/core/src/types/SimpleTableConfig.d.ts +5 -0
- package/dist/types/core/src/types/SimpleTableProps.d.ts +8 -0
- package/dist/types/core/src/types/TableAPI.d.ts +8 -0
- package/dist/types/core/src/utils/aggregationUtils.d.ts +7 -0
- package/dist/types/core/src/utils/pivot/pivotRows.d.ts +16 -0
- package/dist/types/core/src/utils/propSyncEqual.d.ts +3 -8
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@angular/core"),t=require("simple-table-core");function o(e,t,o,n){var i,r=arguments.length,s=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,n);else for(var p=e.length-1;p>=0;p--)(i=e[p])&&(s=(r<3?i(s):r>3?i(t,o,s):i(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s}function n(t,o,n,i){return r=>{const s=document.createElement("div"),p=e.createComponent(t,{environmentInjector:n,hostElement:s});return Object.assign(p.instance,r),o.attachView(p.hostView),p.changeDetectorRef.detectChanges(),i?.register(s,()=>{o.detachView(p.hostView),p.destroy()}),s}}function i(t,o,n,i,r,s){const p="cell"===s?i.cellRendererCache:i.headerRendererCache,l=p.get(r);if(l)return l.component=t,l.wrapped;const a={component:t,wrapped:null},d=t=>{const r=document.createElement("div"),s=e.createComponent(a.component,{environmentInjector:n,hostElement:r});return Object.assign(s.instance,t),o.attachView(s.hostView),s.changeDetectorRef.detectChanges(),i.register(r,()=>{o.detachView(s.hostView),s.destroy()}),r};return a.wrapped=d,p.set(r,a),d}function r(e,o,s,p){const{defaultHeaders:l,rows:a,footerRenderer:d,emptyStateRenderer:h,errorStateRenderer:m,loadingStateRenderer:u,tableEmptyStateRenderer:c,headerDropdown:C,columnEditorConfig:v,icons:g,rowButtons:S,onColumnOrderChange:b,onColumnWidthChange:y,onHeaderEdit:R,onColumnSelect:x,...f}=e,w=e=>n(e,s,p,o);o.pruneRendererCaches(t.collectHeaderAccessors(l));const I={...f,rows:a,defaultHeaders:l.map(function e(t){const{cellRenderer:n,headerRenderer:l,children:a,nestedTable:d,...h}=t,m=String(t.accessor),u={...h};if(n&&(u.cellRenderer=n.ɵcmp?i(n,s,p,o,m,"cell"):n),l&&(u.headerRenderer=l.ɵcmp?i(l,s,p,o,m,"header"):l),a&&(u.children=a.map(e)),d){const e={...d,rows:[]};u.nestedTable=r(e,o,s,p)}return u}),onRendererHostDiscard:o.disposeHost,...b?{onColumnOrderChange:e=>b(e)}:{},...y?{onColumnWidthChange:e=>y(e)}:{},...R?{onHeaderEdit:(e,t)=>R(e,t)}:{},...x?{onColumnSelect:e=>x(e)}:{}};return void 0!==d&&(I.footerRenderer=d.ɵcmp?w(d):d),void 0!==h&&(I.emptyStateRenderer=h.ɵcmp?w(h):h),void 0!==m&&(I.errorStateRenderer=m.ɵcmp?w(m):m),void 0!==u&&(I.loadingStateRenderer=u.ɵcmp?w(u):u),void 0!==c&&(I.tableEmptyStateRenderer=c),void 0!==C&&(I.headerDropdown=w(C)),void 0!==v&&(I.columnEditorConfig=function(e){const{rowRenderer:t,customRenderer:o,...n}=e;return{...n,...t?{rowRenderer:w(t)}:{},...o?{customRenderer:w(o)}:{}}}(v)),void 0!==g&&(I.icons=function(e){const t={};for(const[o,n]of Object.entries(e))null!=n&&(t[o]="string"==typeof n||n instanceof HTMLElement||n instanceof SVGSVGElement?n:n.ɵcmp?w(n)({}):n);return t}(g)),void 0!==S&&(I.rowButtons=S.map(e=>w(e))),I}"function"==typeof SuppressedError&&SuppressedError;const s="data-st-mount-id";class p{constructor(){this.entries=new Map,this.nextId=0,this.cellRendererCache=new Map,this.headerRendererCache=new Map,this.disposeHost=e=>{if("function"!=typeof e.getAttribute)return;const t=[],o=e.getAttribute(s);null!==o&&t.push(o),e.querySelectorAll(`[${s}]`).forEach(e=>{const o=e.getAttribute(s);null!==o&&t.push(o)});for(const e of t){const t=this.entries.get(e);t&&(this.entries.delete(e),t())}}}register(e,t){const o="st-mount-"+this.nextId++;e.setAttribute(s,o),this.entries.set(o,t)}clear(){this.cellRendererCache.clear(),this.headerRendererCache.clear();for(const e of this.entries.values())e();this.entries.clear()}pruneRendererCaches(e){for(const t of this.cellRendererCache.keys())e.has(t)||this.cellRendererCache.delete(t);for(const t of this.headerRendererCache.keys())e.has(t)||this.headerRendererCache.delete(t)}get size(){return this.entries.size}}exports.SimpleTableComponent=class{constructor(){this.tableReady=new e.EventEmitter,this.instance=null,this.registry=new p,this.hostEl=e.inject(e.ElementRef),this.appRef=e.inject(e.ApplicationRef),this.envInjector=e.inject(e.EnvironmentInjector)}ngOnInit(){const e=this.hostEl.nativeElement.querySelector("div");if(!e)return;const o=this.getProps();this.instance=new t.SimpleTableVanilla(e,r(o,this.registry,this.appRef,this.envInjector)),this.instance.mount(),this.syncedDefaultHeaders=o.defaultHeaders,this.syncedRows=o.rows,this.tableReady.emit(this.instance.getAPI())}ngOnChanges(){if(!this.instance)return;const e=this.getProps(),o={...r(e,this.registry,this.appRef,this.envInjector)},n=t.headersStructurallyEqual(this.syncedDefaultHeaders,e.defaultHeaders);this.syncedDefaultHeaders=e.defaultHeaders,n&&delete o.defaultHeaders;const i=t.rowsShallowUnchanged(this.syncedRows,e.rows,e.getRowId);this.syncedRows=e.rows,i&&delete o.rows,this.instance.update(o)}ngOnDestroy(){this.instance?.destroy(),this.instance=null,this.syncedDefaultHeaders=void 0,this.syncedRows=void 0,this.registry.clear()}getAPI(){return this.instance?.getAPI()??null}getProps(){const e={rows:this.rows,defaultHeaders:this.defaultHeaders};return void 0!==this.footerRenderer&&(e.footerRenderer=this.footerRenderer),void 0!==this.loadingStateRenderer&&(e.loadingStateRenderer=this.loadingStateRenderer),void 0!==this.errorStateRenderer&&(e.errorStateRenderer=this.errorStateRenderer),void 0!==this.emptyStateRenderer&&(e.emptyStateRenderer=this.emptyStateRenderer),void 0!==this.tableEmptyStateRenderer&&(e.tableEmptyStateRenderer=this.tableEmptyStateRenderer),void 0!==this.headerDropdown&&(e.headerDropdown=this.headerDropdown),void 0!==this.columnEditorConfig&&(e.columnEditorConfig=this.columnEditorConfig),void 0!==this.onCellClick&&(e.onCellClick=this.onCellClick),void 0!==this.onCellEdit&&(e.onCellEdit=this.onCellEdit),void 0!==this.onSortChange&&(e.onSortChange=this.onSortChange),void 0!==this.onFilterChange&&(e.onFilterChange=this.onFilterChange),void 0!==this.onRowSelectionChange&&(e.onRowSelectionChange=this.onRowSelectionChange),void 0!==this.onRowGroupExpand&&(e.onRowGroupExpand=this.onRowGroupExpand),void 0!==this.onColumnOrderChange&&(e.onColumnOrderChange=this.onColumnOrderChange),void 0!==this.onColumnVisibilityChange&&(e.onColumnVisibilityChange=this.onColumnVisibilityChange),void 0!==this.onColumnWidthChange&&(e.onColumnWidthChange=this.onColumnWidthChange),void 0!==this.onPageChange&&(e.onPageChange=this.onPageChange),void 0!==this.onLoadMore&&(e.onLoadMore=this.onLoadMore),void 0!==this.onGridReady&&(e.onGridReady=this.onGridReady),void 0!==this.rowGrouping&&(e.rowGrouping=this.rowGrouping),void 0!==this.enableRowSelection&&(e.enableRowSelection=this.enableRowSelection),void 0!==this.theme&&(e.theme=this.theme),void 0!==this.quickFilter&&(e.quickFilter=this.quickFilter),void 0!==this.isLoading&&(e.isLoading=this.isLoading),void 0!==this.getRowId&&(e.getRowId=this.getRowId),void 0!==this.shouldPaginate&&(e.shouldPaginate=this.shouldPaginate),void 0!==this.rowsPerPage&&(e.rowsPerPage=this.rowsPerPage),void 0!==this.serverSidePagination&&(e.serverSidePagination=this.serverSidePagination),void 0!==this.totalRowCount&&(e.totalRowCount=this.totalRowCount),void 0!==this.height&&(e.height=this.height),void 0!==this.maxHeight&&(e.maxHeight=this.maxHeight),void 0!==this.scrollParent&&(e.scrollParent=this.scrollParent),void 0!==this.infiniteScrollThreshold&&(e.infiniteScrollThreshold=this.infiniteScrollThreshold),void 0!==this.columnResizing&&(e.columnResizing=this.columnResizing),void 0!==this.columnReordering&&(e.columnReordering=this.columnReordering),void 0!==this.editColumns&&(e.editColumns=this.editColumns),void 0!==this.editColumnsInitOpen&&(e.editColumnsInitOpen=this.editColumnsInitOpen),void 0!==this.selectableCells&&(e.selectableCells=this.selectableCells),void 0!==this.selectableColumns&&(e.selectableColumns=this.selectableColumns),void 0!==this.enableHeaderEditing&&(e.enableHeaderEditing=this.enableHeaderEditing),void 0!==this.onHeaderEdit&&(e.onHeaderEdit=this.onHeaderEdit),void 0!==this.customTheme&&(e.customTheme=this.customTheme),void 0!==this.icons&&(e.icons=this.icons),void 0!==this.externalFilterHandling&&(e.externalFilterHandling=this.externalFilterHandling),void 0!==this.externalSortHandling&&(e.externalSortHandling=this.externalSortHandling),void 0!==this.columnBorders&&(e.columnBorders=this.columnBorders),void 0!==this.rowButtons&&(e.rowButtons=this.rowButtons),void 0!==this.hideFooter&&(e.hideFooter=this.hideFooter),void 0!==this.footerPosition&&(e.footerPosition=this.footerPosition),void 0!==this.initialSortColumn&&(e.initialSortColumn=this.initialSortColumn),void 0!==this.initialSortDirection&&(e.initialSortDirection=this.initialSortDirection),void 0!==this.expandAll&&(e.expandAll=this.expandAll),void 0!==this.autoExpandColumns&&(e.autoExpandColumns=this.autoExpandColumns),void 0!==this.animations&&(e.animations=this.animations),void 0!==this.enableVirtualization&&(e.enableVirtualization=this.enableVirtualization),e}},o([e.Input({required:!0})],exports.SimpleTableComponent.prototype,"rows",void 0),o([e.Input({required:!0})],exports.SimpleTableComponent.prototype,"defaultHeaders",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"footerRenderer",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"loadingStateRenderer",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"errorStateRenderer",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"emptyStateRenderer",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"tableEmptyStateRenderer",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"headerDropdown",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"columnEditorConfig",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onCellClick",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onCellEdit",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onSortChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onFilterChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onRowSelectionChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onRowGroupExpand",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onColumnOrderChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onColumnVisibilityChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onColumnWidthChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onPageChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onLoadMore",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onGridReady",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"rowGrouping",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"enableRowSelection",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"theme",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"quickFilter",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"isLoading",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"getRowId",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"shouldPaginate",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"rowsPerPage",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"serverSidePagination",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"totalRowCount",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"height",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"maxHeight",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"scrollParent",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"infiniteScrollThreshold",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"columnResizing",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"columnReordering",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"editColumns",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"editColumnsInitOpen",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"selectableCells",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"selectableColumns",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"enableHeaderEditing",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onHeaderEdit",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"customTheme",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"icons",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"externalFilterHandling",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"externalSortHandling",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"columnBorders",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"rowButtons",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"hideFooter",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"footerPosition",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"initialSortColumn",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"initialSortDirection",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"expandAll",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"autoExpandColumns",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"animations",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"enableVirtualization",void 0),o([e.Output()],exports.SimpleTableComponent.prototype,"tableReady",void 0),exports.SimpleTableComponent=o([e.Component({selector:"simple-table",standalone:!0,template:"<div #host></div>",styles:[":host { display: block; }"]})],exports.SimpleTableComponent),Object.defineProperty(exports,"asRows",{enumerable:!0,get:function(){return t.asRows}}),exports.provideSimpleTable=function(){return e.makeEnvironmentProviders([])},exports.wrapAngularRenderer=n;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@angular/core"),t=require("simple-table-core");function o(e,t,o,n){var i,r=arguments.length,s=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,n);else for(var p=e.length-1;p>=0;p--)(i=e[p])&&(s=(r<3?i(s):r>3?i(t,o,s):i(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s}function n(t,o,n,i){return r=>{const s=document.createElement("div"),p=e.createComponent(t,{environmentInjector:n,hostElement:s});return Object.assign(p.instance,r),o.attachView(p.hostView),p.changeDetectorRef.detectChanges(),i?.register(s,()=>{o.detachView(p.hostView),p.destroy()}),s}}function i(t,o,n,i,r,s){const p="cell"===s?i.cellRendererCache:i.headerRendererCache,l=p.get(r);if(l)return l.component=t,l.wrapped;const a={component:t,wrapped:null},d=t=>{const r=document.createElement("div"),s=e.createComponent(a.component,{environmentInjector:n,hostElement:r});return Object.assign(s.instance,t),o.attachView(s.hostView),s.changeDetectorRef.detectChanges(),i.register(r,()=>{o.detachView(s.hostView),s.destroy()}),r};return a.wrapped=d,p.set(r,a),d}function r(e,o,s,p){const{defaultHeaders:l,rows:a,footerRenderer:d,emptyStateRenderer:h,errorStateRenderer:u,loadingStateRenderer:m,tableEmptyStateRenderer:c,headerDropdown:C,columnEditorConfig:v,icons:g,rowButtons:S,onColumnOrderChange:b,onColumnWidthChange:y,onHeaderEdit:R,onColumnSelect:x,...f}=e,I=e=>n(e,s,p,o);o.pruneRendererCaches(t.collectHeaderAccessors(l));const T={...f,rows:a,defaultHeaders:l.map(function e(t){const{cellRenderer:n,headerRenderer:l,children:a,nestedTable:d,...h}=t,u=String(t.accessor),m={...h};if(n&&(m.cellRenderer=n.ɵcmp?i(n,s,p,o,u,"cell"):n),l&&(m.headerRenderer=l.ɵcmp?i(l,s,p,o,u,"header"):l),a&&(m.children=a.map(e)),d){const e={...d,rows:[]};m.nestedTable=r(e,o,s,p)}return m}),onRendererHostDiscard:o.disposeHost,...b?{onColumnOrderChange:e=>b(e)}:{},...y?{onColumnWidthChange:e=>y(e)}:{},...R?{onHeaderEdit:(e,t)=>R(e,t)}:{},...x?{onColumnSelect:e=>x(e)}:{}};return void 0!==d&&(T.footerRenderer=d.ɵcmp?I(d):d),void 0!==h&&(T.emptyStateRenderer=h.ɵcmp?I(h):h),void 0!==u&&(T.errorStateRenderer=u.ɵcmp?I(u):u),void 0!==m&&(T.loadingStateRenderer=m.ɵcmp?I(m):m),void 0!==c&&(T.tableEmptyStateRenderer=c),void 0!==C&&(T.headerDropdown=I(C)),void 0!==v&&(T.columnEditorConfig=function(e){const{rowRenderer:t,customRenderer:o,...n}=e;return{...n,...t?{rowRenderer:I(t)}:{},...o?{customRenderer:I(o)}:{}}}(v)),void 0!==g&&(T.icons=function(e){const t={};for(const[o,n]of Object.entries(e))null!=n&&(t[o]="string"==typeof n||n instanceof HTMLElement||n instanceof SVGSVGElement?n:n.ɵcmp?I(n)({}):n);return t}(g)),void 0!==S&&(T.rowButtons=S.map(e=>I(e))),T}"function"==typeof SuppressedError&&SuppressedError;const s="data-st-mount-id";class p{constructor(){this.entries=new Map,this.nextId=0,this.cellRendererCache=new Map,this.headerRendererCache=new Map,this.disposeHost=e=>{if("function"!=typeof e.getAttribute)return;const t=[],o=e.getAttribute(s);null!==o&&t.push(o),e.querySelectorAll(`[${s}]`).forEach(e=>{const o=e.getAttribute(s);null!==o&&t.push(o)});for(const e of t){const t=this.entries.get(e);t&&(this.entries.delete(e),t())}}}register(e,t){const o="st-mount-"+this.nextId++;e.setAttribute(s,o),this.entries.set(o,t)}clear(){this.cellRendererCache.clear(),this.headerRendererCache.clear();for(const e of this.entries.values())e();this.entries.clear()}pruneRendererCaches(e){for(const t of this.cellRendererCache.keys())e.has(t)||this.cellRendererCache.delete(t);for(const t of this.headerRendererCache.keys())e.has(t)||this.headerRendererCache.delete(t)}get size(){return this.entries.size}}exports.SimpleTableComponent=class{constructor(){this.tableReady=new e.EventEmitter,this.instance=null,this.registry=new p,this.hostEl=e.inject(e.ElementRef),this.appRef=e.inject(e.ApplicationRef),this.envInjector=e.inject(e.EnvironmentInjector)}ngOnInit(){const e=this.hostEl.nativeElement.querySelector("div");if(!e)return;const o=this.getProps();this.instance=new t.SimpleTableVanilla(e,r(o,this.registry,this.appRef,this.envInjector)),this.instance.mount(),this.syncedDefaultHeaders=o.defaultHeaders,this.syncedRows=o.rows,this.tableReady.emit(this.instance.getAPI())}ngOnChanges(){if(!this.instance)return;const e=this.getProps(),o={...r(e,this.registry,this.appRef,this.envInjector)},n=t.headersStructurallyEqual(this.syncedDefaultHeaders,e.defaultHeaders);this.syncedDefaultHeaders=e.defaultHeaders,n&&delete o.defaultHeaders;const i=t.rowsShallowUnchanged(this.syncedRows,e.rows,e.getRowId);this.syncedRows=e.rows,i&&delete o.rows,this.instance.update(o)}ngOnDestroy(){this.instance?.destroy(),this.instance=null,this.syncedDefaultHeaders=void 0,this.syncedRows=void 0,this.registry.clear()}getAPI(){return this.instance?.getAPI()??null}getProps(){const e={rows:this.rows,defaultHeaders:this.defaultHeaders};return void 0!==this.footerRenderer&&(e.footerRenderer=this.footerRenderer),void 0!==this.loadingStateRenderer&&(e.loadingStateRenderer=this.loadingStateRenderer),void 0!==this.errorStateRenderer&&(e.errorStateRenderer=this.errorStateRenderer),void 0!==this.emptyStateRenderer&&(e.emptyStateRenderer=this.emptyStateRenderer),void 0!==this.tableEmptyStateRenderer&&(e.tableEmptyStateRenderer=this.tableEmptyStateRenderer),void 0!==this.headerDropdown&&(e.headerDropdown=this.headerDropdown),void 0!==this.columnEditorConfig&&(e.columnEditorConfig=this.columnEditorConfig),void 0!==this.onCellClick&&(e.onCellClick=this.onCellClick),void 0!==this.onCellEdit&&(e.onCellEdit=this.onCellEdit),void 0!==this.onSortChange&&(e.onSortChange=this.onSortChange),void 0!==this.onFilterChange&&(e.onFilterChange=this.onFilterChange),void 0!==this.onRowSelectionChange&&(e.onRowSelectionChange=this.onRowSelectionChange),void 0!==this.onRowGroupExpand&&(e.onRowGroupExpand=this.onRowGroupExpand),void 0!==this.onColumnOrderChange&&(e.onColumnOrderChange=this.onColumnOrderChange),void 0!==this.onColumnVisibilityChange&&(e.onColumnVisibilityChange=this.onColumnVisibilityChange),void 0!==this.onColumnWidthChange&&(e.onColumnWidthChange=this.onColumnWidthChange),void 0!==this.onPageChange&&(e.onPageChange=this.onPageChange),void 0!==this.onLoadMore&&(e.onLoadMore=this.onLoadMore),void 0!==this.onGridReady&&(e.onGridReady=this.onGridReady),void 0!==this.rowGrouping&&(e.rowGrouping=this.rowGrouping),void 0!==this.pivot&&(e.pivot=this.pivot),void 0!==this.onPivotChange&&(e.onPivotChange=this.onPivotChange),void 0!==this.enableRowSelection&&(e.enableRowSelection=this.enableRowSelection),void 0!==this.theme&&(e.theme=this.theme),void 0!==this.quickFilter&&(e.quickFilter=this.quickFilter),void 0!==this.isLoading&&(e.isLoading=this.isLoading),void 0!==this.getRowId&&(e.getRowId=this.getRowId),void 0!==this.shouldPaginate&&(e.shouldPaginate=this.shouldPaginate),void 0!==this.rowsPerPage&&(e.rowsPerPage=this.rowsPerPage),void 0!==this.serverSidePagination&&(e.serverSidePagination=this.serverSidePagination),void 0!==this.totalRowCount&&(e.totalRowCount=this.totalRowCount),void 0!==this.height&&(e.height=this.height),void 0!==this.maxHeight&&(e.maxHeight=this.maxHeight),void 0!==this.scrollParent&&(e.scrollParent=this.scrollParent),void 0!==this.infiniteScrollThreshold&&(e.infiniteScrollThreshold=this.infiniteScrollThreshold),void 0!==this.columnResizing&&(e.columnResizing=this.columnResizing),void 0!==this.columnReordering&&(e.columnReordering=this.columnReordering),void 0!==this.editColumns&&(e.editColumns=this.editColumns),void 0!==this.editColumnsInitOpen&&(e.editColumnsInitOpen=this.editColumnsInitOpen),void 0!==this.selectableCells&&(e.selectableCells=this.selectableCells),void 0!==this.selectableColumns&&(e.selectableColumns=this.selectableColumns),void 0!==this.enableHeaderEditing&&(e.enableHeaderEditing=this.enableHeaderEditing),void 0!==this.onHeaderEdit&&(e.onHeaderEdit=this.onHeaderEdit),void 0!==this.customTheme&&(e.customTheme=this.customTheme),void 0!==this.icons&&(e.icons=this.icons),void 0!==this.externalFilterHandling&&(e.externalFilterHandling=this.externalFilterHandling),void 0!==this.externalSortHandling&&(e.externalSortHandling=this.externalSortHandling),void 0!==this.columnBorders&&(e.columnBorders=this.columnBorders),void 0!==this.rowButtons&&(e.rowButtons=this.rowButtons),void 0!==this.hideFooter&&(e.hideFooter=this.hideFooter),void 0!==this.footerPosition&&(e.footerPosition=this.footerPosition),void 0!==this.initialSortColumn&&(e.initialSortColumn=this.initialSortColumn),void 0!==this.initialSortDirection&&(e.initialSortDirection=this.initialSortDirection),void 0!==this.expandAll&&(e.expandAll=this.expandAll),void 0!==this.autoExpandColumns&&(e.autoExpandColumns=this.autoExpandColumns),void 0!==this.animations&&(e.animations=this.animations),void 0!==this.enableVirtualization&&(e.enableVirtualization=this.enableVirtualization),e}},o([e.Input({required:!0})],exports.SimpleTableComponent.prototype,"rows",void 0),o([e.Input({required:!0})],exports.SimpleTableComponent.prototype,"defaultHeaders",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"footerRenderer",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"loadingStateRenderer",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"errorStateRenderer",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"emptyStateRenderer",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"tableEmptyStateRenderer",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"headerDropdown",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"columnEditorConfig",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onCellClick",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onCellEdit",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onSortChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onFilterChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onRowSelectionChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onRowGroupExpand",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onColumnOrderChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onColumnVisibilityChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onColumnWidthChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onPageChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onLoadMore",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onGridReady",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"rowGrouping",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"pivot",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onPivotChange",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"enableRowSelection",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"theme",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"quickFilter",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"isLoading",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"getRowId",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"shouldPaginate",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"rowsPerPage",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"serverSidePagination",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"totalRowCount",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"height",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"maxHeight",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"scrollParent",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"infiniteScrollThreshold",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"columnResizing",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"columnReordering",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"editColumns",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"editColumnsInitOpen",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"selectableCells",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"selectableColumns",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"enableHeaderEditing",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"onHeaderEdit",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"customTheme",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"icons",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"externalFilterHandling",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"externalSortHandling",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"columnBorders",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"rowButtons",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"hideFooter",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"footerPosition",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"initialSortColumn",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"initialSortDirection",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"expandAll",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"autoExpandColumns",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"animations",void 0),o([e.Input()],exports.SimpleTableComponent.prototype,"enableVirtualization",void 0),o([e.Output()],exports.SimpleTableComponent.prototype,"tableReady",void 0),exports.SimpleTableComponent=o([e.Component({selector:"simple-table",standalone:!0,template:"<div #host></div>",styles:[":host { display: block; }"]})],exports.SimpleTableComponent),Object.defineProperty(exports,"PIVOT_ACCESSOR_PREFIX",{enumerable:!0,get:function(){return t.PIVOT_ACCESSOR_PREFIX}}),Object.defineProperty(exports,"PIVOT_BLANK_LABEL",{enumerable:!0,get:function(){return t.PIVOT_BLANK_LABEL}}),Object.defineProperty(exports,"PIVOT_CHILDREN_KEY",{enumerable:!0,get:function(){return t.PIVOT_CHILDREN_KEY}}),Object.defineProperty(exports,"PIVOT_IS_TOTAL_KEY",{enumerable:!0,get:function(){return t.PIVOT_IS_TOTAL_KEY}}),Object.defineProperty(exports,"asRows",{enumerable:!0,get:function(){return t.asRows}}),Object.defineProperty(exports,"buildPivotAccessor",{enumerable:!0,get:function(){return t.buildPivotAccessor}}),Object.defineProperty(exports,"buildPivotRowTotalAccessor",{enumerable:!0,get:function(){return t.buildPivotRowTotalAccessor}}),Object.defineProperty(exports,"pivotRows",{enumerable:!0,get:function(){return t.pivotRows}}),exports.provideSimpleTable=function(){return e.makeEnvironmentProviders([])},exports.wrapAngularRenderer=n;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createComponent as e,Input as t,Output as o,Component as i,EventEmitter as n,inject as r,ElementRef as s,ApplicationRef as d,EnvironmentInjector as a,makeEnvironmentProviders as l}from"@angular/core";import{collectHeaderAccessors as h,SimpleTableVanilla as p,headersStructurallyEqual as c,rowsShallowUnchanged as u}from"simple-table-core";export{asRows}from"simple-table-core";function v(e,t,o,i){var n,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var d=e.length-1;d>=0;d--)(n=e[d])&&(s=(r<3?n(s):r>3?n(t,o,s):n(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s}function g(t,o,i,n){return r=>{const s=document.createElement("div"),d=e(t,{environmentInjector:i,hostElement:s});return Object.assign(d.instance,r),o.attachView(d.hostView),d.changeDetectorRef.detectChanges(),n?.register(s,()=>{o.detachView(d.hostView),d.destroy()}),s}}function m(t,o,i,n,r,s){const d="cell"===s?n.cellRendererCache:n.headerRendererCache,a=d.get(r);if(a)return a.component=t,a.wrapped;const l={component:t,wrapped:null},h=t=>{const r=document.createElement("div"),s=e(l.component,{environmentInjector:i,hostElement:r});return Object.assign(s.instance,t),o.attachView(s.hostView),s.changeDetectorRef.detectChanges(),n.register(r,()=>{o.detachView(s.hostView),s.destroy()}),r};return l.wrapped=h,d.set(r,l),h}function C(e,t,o,i){const{defaultHeaders:n,rows:r,footerRenderer:s,emptyStateRenderer:d,errorStateRenderer:a,loadingStateRenderer:l,tableEmptyStateRenderer:p,headerDropdown:c,columnEditorConfig:u,icons:v,rowButtons:y,onColumnOrderChange:R,onColumnWidthChange:f,onHeaderEdit:w,onColumnSelect:S,...b}=e,E=e=>g(e,o,i,t);t.pruneRendererCaches(h(n));const H={...b,rows:r,defaultHeaders:n.map(function e(n){const{cellRenderer:r,headerRenderer:s,children:d,nestedTable:a,...l}=n,h=String(n.accessor),p={...l};if(r&&(p.cellRenderer=r.ɵcmp?m(r,o,i,t,h,"cell"):r),s&&(p.headerRenderer=s.ɵcmp?m(s,o,i,t,h,"header"):s),d&&(p.children=d.map(e)),a){const e={...a,rows:[]};p.nestedTable=C(e,t,o,i)}return p}),onRendererHostDiscard:t.disposeHost,...R?{onColumnOrderChange:e=>R(e)}:{},...f?{onColumnWidthChange:e=>f(e)}:{},...w?{onHeaderEdit:(e,t)=>w(e,t)}:{},...S?{onColumnSelect:e=>S(e)}:{}};return void 0!==s&&(H.footerRenderer=s.ɵcmp?E(s):s),void 0!==d&&(H.emptyStateRenderer=d.ɵcmp?E(d):d),void 0!==a&&(H.errorStateRenderer=a.ɵcmp?E(a):a),void 0!==l&&(H.loadingStateRenderer=l.ɵcmp?E(l):l),void 0!==p&&(H.tableEmptyStateRenderer=p),void 0!==c&&(H.headerDropdown=E(c)),void 0!==u&&(H.columnEditorConfig=function(e){const{rowRenderer:t,customRenderer:o,...i}=e;return{...i,...t?{rowRenderer:E(t)}:{},...o?{customRenderer:E(o)}:{}}}(u)),void 0!==v&&(H.icons=function(e){const t={};for(const[o,i]of Object.entries(e))null!=i&&(t[o]="string"==typeof i||i instanceof HTMLElement||i instanceof SVGSVGElement?i:i.ɵcmp?E(i)({}):i);return t}(v)),void 0!==y&&(H.rowButtons=y.map(e=>E(e))),H}"function"==typeof SuppressedError&&SuppressedError;const y="data-st-mount-id";class R{constructor(){this.entries=new Map,this.nextId=0,this.cellRendererCache=new Map,this.headerRendererCache=new Map,this.disposeHost=e=>{if("function"!=typeof e.getAttribute)return;const t=[],o=e.getAttribute(y);null!==o&&t.push(o),e.querySelectorAll(`[${y}]`).forEach(e=>{const o=e.getAttribute(y);null!==o&&t.push(o)});for(const e of t){const t=this.entries.get(e);t&&(this.entries.delete(e),t())}}}register(e,t){const o="st-mount-"+this.nextId++;e.setAttribute(y,o),this.entries.set(o,t)}clear(){this.cellRendererCache.clear(),this.headerRendererCache.clear();for(const e of this.entries.values())e();this.entries.clear()}pruneRendererCaches(e){for(const t of this.cellRendererCache.keys())e.has(t)||this.cellRendererCache.delete(t);for(const t of this.headerRendererCache.keys())e.has(t)||this.headerRendererCache.delete(t)}get size(){return this.entries.size}}let f=class{constructor(){this.tableReady=new n,this.instance=null,this.registry=new R,this.hostEl=r(s),this.appRef=r(d),this.envInjector=r(a)}ngOnInit(){const e=this.hostEl.nativeElement.querySelector("div");if(!e)return;const t=this.getProps();this.instance=new p(e,C(t,this.registry,this.appRef,this.envInjector)),this.instance.mount(),this.syncedDefaultHeaders=t.defaultHeaders,this.syncedRows=t.rows,this.tableReady.emit(this.instance.getAPI())}ngOnChanges(){if(!this.instance)return;const e=this.getProps(),t={...C(e,this.registry,this.appRef,this.envInjector)},o=c(this.syncedDefaultHeaders,e.defaultHeaders);this.syncedDefaultHeaders=e.defaultHeaders,o&&delete t.defaultHeaders;const i=u(this.syncedRows,e.rows,e.getRowId);this.syncedRows=e.rows,i&&delete t.rows,this.instance.update(t)}ngOnDestroy(){this.instance?.destroy(),this.instance=null,this.syncedDefaultHeaders=void 0,this.syncedRows=void 0,this.registry.clear()}getAPI(){return this.instance?.getAPI()??null}getProps(){const e={rows:this.rows,defaultHeaders:this.defaultHeaders};return void 0!==this.footerRenderer&&(e.footerRenderer=this.footerRenderer),void 0!==this.loadingStateRenderer&&(e.loadingStateRenderer=this.loadingStateRenderer),void 0!==this.errorStateRenderer&&(e.errorStateRenderer=this.errorStateRenderer),void 0!==this.emptyStateRenderer&&(e.emptyStateRenderer=this.emptyStateRenderer),void 0!==this.tableEmptyStateRenderer&&(e.tableEmptyStateRenderer=this.tableEmptyStateRenderer),void 0!==this.headerDropdown&&(e.headerDropdown=this.headerDropdown),void 0!==this.columnEditorConfig&&(e.columnEditorConfig=this.columnEditorConfig),void 0!==this.onCellClick&&(e.onCellClick=this.onCellClick),void 0!==this.onCellEdit&&(e.onCellEdit=this.onCellEdit),void 0!==this.onSortChange&&(e.onSortChange=this.onSortChange),void 0!==this.onFilterChange&&(e.onFilterChange=this.onFilterChange),void 0!==this.onRowSelectionChange&&(e.onRowSelectionChange=this.onRowSelectionChange),void 0!==this.onRowGroupExpand&&(e.onRowGroupExpand=this.onRowGroupExpand),void 0!==this.onColumnOrderChange&&(e.onColumnOrderChange=this.onColumnOrderChange),void 0!==this.onColumnVisibilityChange&&(e.onColumnVisibilityChange=this.onColumnVisibilityChange),void 0!==this.onColumnWidthChange&&(e.onColumnWidthChange=this.onColumnWidthChange),void 0!==this.onPageChange&&(e.onPageChange=this.onPageChange),void 0!==this.onLoadMore&&(e.onLoadMore=this.onLoadMore),void 0!==this.onGridReady&&(e.onGridReady=this.onGridReady),void 0!==this.rowGrouping&&(e.rowGrouping=this.rowGrouping),void 0!==this.enableRowSelection&&(e.enableRowSelection=this.enableRowSelection),void 0!==this.theme&&(e.theme=this.theme),void 0!==this.quickFilter&&(e.quickFilter=this.quickFilter),void 0!==this.isLoading&&(e.isLoading=this.isLoading),void 0!==this.getRowId&&(e.getRowId=this.getRowId),void 0!==this.shouldPaginate&&(e.shouldPaginate=this.shouldPaginate),void 0!==this.rowsPerPage&&(e.rowsPerPage=this.rowsPerPage),void 0!==this.serverSidePagination&&(e.serverSidePagination=this.serverSidePagination),void 0!==this.totalRowCount&&(e.totalRowCount=this.totalRowCount),void 0!==this.height&&(e.height=this.height),void 0!==this.maxHeight&&(e.maxHeight=this.maxHeight),void 0!==this.scrollParent&&(e.scrollParent=this.scrollParent),void 0!==this.infiniteScrollThreshold&&(e.infiniteScrollThreshold=this.infiniteScrollThreshold),void 0!==this.columnResizing&&(e.columnResizing=this.columnResizing),void 0!==this.columnReordering&&(e.columnReordering=this.columnReordering),void 0!==this.editColumns&&(e.editColumns=this.editColumns),void 0!==this.editColumnsInitOpen&&(e.editColumnsInitOpen=this.editColumnsInitOpen),void 0!==this.selectableCells&&(e.selectableCells=this.selectableCells),void 0!==this.selectableColumns&&(e.selectableColumns=this.selectableColumns),void 0!==this.enableHeaderEditing&&(e.enableHeaderEditing=this.enableHeaderEditing),void 0!==this.onHeaderEdit&&(e.onHeaderEdit=this.onHeaderEdit),void 0!==this.customTheme&&(e.customTheme=this.customTheme),void 0!==this.icons&&(e.icons=this.icons),void 0!==this.externalFilterHandling&&(e.externalFilterHandling=this.externalFilterHandling),void 0!==this.externalSortHandling&&(e.externalSortHandling=this.externalSortHandling),void 0!==this.columnBorders&&(e.columnBorders=this.columnBorders),void 0!==this.rowButtons&&(e.rowButtons=this.rowButtons),void 0!==this.hideFooter&&(e.hideFooter=this.hideFooter),void 0!==this.footerPosition&&(e.footerPosition=this.footerPosition),void 0!==this.initialSortColumn&&(e.initialSortColumn=this.initialSortColumn),void 0!==this.initialSortDirection&&(e.initialSortDirection=this.initialSortDirection),void 0!==this.expandAll&&(e.expandAll=this.expandAll),void 0!==this.autoExpandColumns&&(e.autoExpandColumns=this.autoExpandColumns),void 0!==this.animations&&(e.animations=this.animations),void 0!==this.enableVirtualization&&(e.enableVirtualization=this.enableVirtualization),e}};function w(){return l([])}v([t({required:!0})],f.prototype,"rows",void 0),v([t({required:!0})],f.prototype,"defaultHeaders",void 0),v([t()],f.prototype,"footerRenderer",void 0),v([t()],f.prototype,"loadingStateRenderer",void 0),v([t()],f.prototype,"errorStateRenderer",void 0),v([t()],f.prototype,"emptyStateRenderer",void 0),v([t()],f.prototype,"tableEmptyStateRenderer",void 0),v([t()],f.prototype,"headerDropdown",void 0),v([t()],f.prototype,"columnEditorConfig",void 0),v([t()],f.prototype,"onCellClick",void 0),v([t()],f.prototype,"onCellEdit",void 0),v([t()],f.prototype,"onSortChange",void 0),v([t()],f.prototype,"onFilterChange",void 0),v([t()],f.prototype,"onRowSelectionChange",void 0),v([t()],f.prototype,"onRowGroupExpand",void 0),v([t()],f.prototype,"onColumnOrderChange",void 0),v([t()],f.prototype,"onColumnVisibilityChange",void 0),v([t()],f.prototype,"onColumnWidthChange",void 0),v([t()],f.prototype,"onPageChange",void 0),v([t()],f.prototype,"onLoadMore",void 0),v([t()],f.prototype,"onGridReady",void 0),v([t()],f.prototype,"rowGrouping",void 0),v([t()],f.prototype,"enableRowSelection",void 0),v([t()],f.prototype,"theme",void 0),v([t()],f.prototype,"quickFilter",void 0),v([t()],f.prototype,"isLoading",void 0),v([t()],f.prototype,"getRowId",void 0),v([t()],f.prototype,"shouldPaginate",void 0),v([t()],f.prototype,"rowsPerPage",void 0),v([t()],f.prototype,"serverSidePagination",void 0),v([t()],f.prototype,"totalRowCount",void 0),v([t()],f.prototype,"height",void 0),v([t()],f.prototype,"maxHeight",void 0),v([t()],f.prototype,"scrollParent",void 0),v([t()],f.prototype,"infiniteScrollThreshold",void 0),v([t()],f.prototype,"columnResizing",void 0),v([t()],f.prototype,"columnReordering",void 0),v([t()],f.prototype,"editColumns",void 0),v([t()],f.prototype,"editColumnsInitOpen",void 0),v([t()],f.prototype,"selectableCells",void 0),v([t()],f.prototype,"selectableColumns",void 0),v([t()],f.prototype,"enableHeaderEditing",void 0),v([t()],f.prototype,"onHeaderEdit",void 0),v([t()],f.prototype,"customTheme",void 0),v([t()],f.prototype,"icons",void 0),v([t()],f.prototype,"externalFilterHandling",void 0),v([t()],f.prototype,"externalSortHandling",void 0),v([t()],f.prototype,"columnBorders",void 0),v([t()],f.prototype,"rowButtons",void 0),v([t()],f.prototype,"hideFooter",void 0),v([t()],f.prototype,"footerPosition",void 0),v([t()],f.prototype,"initialSortColumn",void 0),v([t()],f.prototype,"initialSortDirection",void 0),v([t()],f.prototype,"expandAll",void 0),v([t()],f.prototype,"autoExpandColumns",void 0),v([t()],f.prototype,"animations",void 0),v([t()],f.prototype,"enableVirtualization",void 0),v([o()],f.prototype,"tableReady",void 0),f=v([i({selector:"simple-table",standalone:!0,template:"<div #host></div>",styles:[":host { display: block; }"]})],f);export{f as SimpleTableComponent,w as provideSimpleTable,g as wrapAngularRenderer};
|
|
1
|
+
import{createComponent as e,Input as t,Output as o,Component as i,EventEmitter as n,inject as r,ElementRef as s,ApplicationRef as d,EnvironmentInjector as a,makeEnvironmentProviders as l}from"@angular/core";import{collectHeaderAccessors as h,SimpleTableVanilla as p,headersStructurallyEqual as c,rowsShallowUnchanged as u}from"simple-table-core";export{PIVOT_ACCESSOR_PREFIX,PIVOT_BLANK_LABEL,PIVOT_CHILDREN_KEY,PIVOT_IS_TOTAL_KEY,asRows,buildPivotAccessor,buildPivotRowTotalAccessor,pivotRows}from"simple-table-core";function v(e,t,o,i){var n,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var d=e.length-1;d>=0;d--)(n=e[d])&&(s=(r<3?n(s):r>3?n(t,o,s):n(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s}function g(t,o,i,n){return r=>{const s=document.createElement("div"),d=e(t,{environmentInjector:i,hostElement:s});return Object.assign(d.instance,r),o.attachView(d.hostView),d.changeDetectorRef.detectChanges(),n?.register(s,()=>{o.detachView(d.hostView),d.destroy()}),s}}function m(t,o,i,n,r,s){const d="cell"===s?n.cellRendererCache:n.headerRendererCache,a=d.get(r);if(a)return a.component=t,a.wrapped;const l={component:t,wrapped:null},h=t=>{const r=document.createElement("div"),s=e(l.component,{environmentInjector:i,hostElement:r});return Object.assign(s.instance,t),o.attachView(s.hostView),s.changeDetectorRef.detectChanges(),n.register(r,()=>{o.detachView(s.hostView),s.destroy()}),r};return l.wrapped=h,d.set(r,l),h}function C(e,t,o,i){const{defaultHeaders:n,rows:r,footerRenderer:s,emptyStateRenderer:d,errorStateRenderer:a,loadingStateRenderer:l,tableEmptyStateRenderer:p,headerDropdown:c,columnEditorConfig:u,icons:v,rowButtons:y,onColumnOrderChange:R,onColumnWidthChange:f,onHeaderEdit:w,onColumnSelect:S,...E}=e,b=e=>g(e,o,i,t);t.pruneRendererCaches(h(n));const P={...E,rows:r,defaultHeaders:n.map(function e(n){const{cellRenderer:r,headerRenderer:s,children:d,nestedTable:a,...l}=n,h=String(n.accessor),p={...l};if(r&&(p.cellRenderer=r.ɵcmp?m(r,o,i,t,h,"cell"):r),s&&(p.headerRenderer=s.ɵcmp?m(s,o,i,t,h,"header"):s),d&&(p.children=d.map(e)),a){const e={...a,rows:[]};p.nestedTable=C(e,t,o,i)}return p}),onRendererHostDiscard:t.disposeHost,...R?{onColumnOrderChange:e=>R(e)}:{},...f?{onColumnWidthChange:e=>f(e)}:{},...w?{onHeaderEdit:(e,t)=>w(e,t)}:{},...S?{onColumnSelect:e=>S(e)}:{}};return void 0!==s&&(P.footerRenderer=s.ɵcmp?b(s):s),void 0!==d&&(P.emptyStateRenderer=d.ɵcmp?b(d):d),void 0!==a&&(P.errorStateRenderer=a.ɵcmp?b(a):a),void 0!==l&&(P.loadingStateRenderer=l.ɵcmp?b(l):l),void 0!==p&&(P.tableEmptyStateRenderer=p),void 0!==c&&(P.headerDropdown=b(c)),void 0!==u&&(P.columnEditorConfig=function(e){const{rowRenderer:t,customRenderer:o,...i}=e;return{...i,...t?{rowRenderer:b(t)}:{},...o?{customRenderer:b(o)}:{}}}(u)),void 0!==v&&(P.icons=function(e){const t={};for(const[o,i]of Object.entries(e))null!=i&&(t[o]="string"==typeof i||i instanceof HTMLElement||i instanceof SVGSVGElement?i:i.ɵcmp?b(i)({}):i);return t}(v)),void 0!==y&&(P.rowButtons=y.map(e=>b(e))),P}"function"==typeof SuppressedError&&SuppressedError;const y="data-st-mount-id";class R{constructor(){this.entries=new Map,this.nextId=0,this.cellRendererCache=new Map,this.headerRendererCache=new Map,this.disposeHost=e=>{if("function"!=typeof e.getAttribute)return;const t=[],o=e.getAttribute(y);null!==o&&t.push(o),e.querySelectorAll(`[${y}]`).forEach(e=>{const o=e.getAttribute(y);null!==o&&t.push(o)});for(const e of t){const t=this.entries.get(e);t&&(this.entries.delete(e),t())}}}register(e,t){const o="st-mount-"+this.nextId++;e.setAttribute(y,o),this.entries.set(o,t)}clear(){this.cellRendererCache.clear(),this.headerRendererCache.clear();for(const e of this.entries.values())e();this.entries.clear()}pruneRendererCaches(e){for(const t of this.cellRendererCache.keys())e.has(t)||this.cellRendererCache.delete(t);for(const t of this.headerRendererCache.keys())e.has(t)||this.headerRendererCache.delete(t)}get size(){return this.entries.size}}let f=class{constructor(){this.tableReady=new n,this.instance=null,this.registry=new R,this.hostEl=r(s),this.appRef=r(d),this.envInjector=r(a)}ngOnInit(){const e=this.hostEl.nativeElement.querySelector("div");if(!e)return;const t=this.getProps();this.instance=new p(e,C(t,this.registry,this.appRef,this.envInjector)),this.instance.mount(),this.syncedDefaultHeaders=t.defaultHeaders,this.syncedRows=t.rows,this.tableReady.emit(this.instance.getAPI())}ngOnChanges(){if(!this.instance)return;const e=this.getProps(),t={...C(e,this.registry,this.appRef,this.envInjector)},o=c(this.syncedDefaultHeaders,e.defaultHeaders);this.syncedDefaultHeaders=e.defaultHeaders,o&&delete t.defaultHeaders;const i=u(this.syncedRows,e.rows,e.getRowId);this.syncedRows=e.rows,i&&delete t.rows,this.instance.update(t)}ngOnDestroy(){this.instance?.destroy(),this.instance=null,this.syncedDefaultHeaders=void 0,this.syncedRows=void 0,this.registry.clear()}getAPI(){return this.instance?.getAPI()??null}getProps(){const e={rows:this.rows,defaultHeaders:this.defaultHeaders};return void 0!==this.footerRenderer&&(e.footerRenderer=this.footerRenderer),void 0!==this.loadingStateRenderer&&(e.loadingStateRenderer=this.loadingStateRenderer),void 0!==this.errorStateRenderer&&(e.errorStateRenderer=this.errorStateRenderer),void 0!==this.emptyStateRenderer&&(e.emptyStateRenderer=this.emptyStateRenderer),void 0!==this.tableEmptyStateRenderer&&(e.tableEmptyStateRenderer=this.tableEmptyStateRenderer),void 0!==this.headerDropdown&&(e.headerDropdown=this.headerDropdown),void 0!==this.columnEditorConfig&&(e.columnEditorConfig=this.columnEditorConfig),void 0!==this.onCellClick&&(e.onCellClick=this.onCellClick),void 0!==this.onCellEdit&&(e.onCellEdit=this.onCellEdit),void 0!==this.onSortChange&&(e.onSortChange=this.onSortChange),void 0!==this.onFilterChange&&(e.onFilterChange=this.onFilterChange),void 0!==this.onRowSelectionChange&&(e.onRowSelectionChange=this.onRowSelectionChange),void 0!==this.onRowGroupExpand&&(e.onRowGroupExpand=this.onRowGroupExpand),void 0!==this.onColumnOrderChange&&(e.onColumnOrderChange=this.onColumnOrderChange),void 0!==this.onColumnVisibilityChange&&(e.onColumnVisibilityChange=this.onColumnVisibilityChange),void 0!==this.onColumnWidthChange&&(e.onColumnWidthChange=this.onColumnWidthChange),void 0!==this.onPageChange&&(e.onPageChange=this.onPageChange),void 0!==this.onLoadMore&&(e.onLoadMore=this.onLoadMore),void 0!==this.onGridReady&&(e.onGridReady=this.onGridReady),void 0!==this.rowGrouping&&(e.rowGrouping=this.rowGrouping),void 0!==this.pivot&&(e.pivot=this.pivot),void 0!==this.onPivotChange&&(e.onPivotChange=this.onPivotChange),void 0!==this.enableRowSelection&&(e.enableRowSelection=this.enableRowSelection),void 0!==this.theme&&(e.theme=this.theme),void 0!==this.quickFilter&&(e.quickFilter=this.quickFilter),void 0!==this.isLoading&&(e.isLoading=this.isLoading),void 0!==this.getRowId&&(e.getRowId=this.getRowId),void 0!==this.shouldPaginate&&(e.shouldPaginate=this.shouldPaginate),void 0!==this.rowsPerPage&&(e.rowsPerPage=this.rowsPerPage),void 0!==this.serverSidePagination&&(e.serverSidePagination=this.serverSidePagination),void 0!==this.totalRowCount&&(e.totalRowCount=this.totalRowCount),void 0!==this.height&&(e.height=this.height),void 0!==this.maxHeight&&(e.maxHeight=this.maxHeight),void 0!==this.scrollParent&&(e.scrollParent=this.scrollParent),void 0!==this.infiniteScrollThreshold&&(e.infiniteScrollThreshold=this.infiniteScrollThreshold),void 0!==this.columnResizing&&(e.columnResizing=this.columnResizing),void 0!==this.columnReordering&&(e.columnReordering=this.columnReordering),void 0!==this.editColumns&&(e.editColumns=this.editColumns),void 0!==this.editColumnsInitOpen&&(e.editColumnsInitOpen=this.editColumnsInitOpen),void 0!==this.selectableCells&&(e.selectableCells=this.selectableCells),void 0!==this.selectableColumns&&(e.selectableColumns=this.selectableColumns),void 0!==this.enableHeaderEditing&&(e.enableHeaderEditing=this.enableHeaderEditing),void 0!==this.onHeaderEdit&&(e.onHeaderEdit=this.onHeaderEdit),void 0!==this.customTheme&&(e.customTheme=this.customTheme),void 0!==this.icons&&(e.icons=this.icons),void 0!==this.externalFilterHandling&&(e.externalFilterHandling=this.externalFilterHandling),void 0!==this.externalSortHandling&&(e.externalSortHandling=this.externalSortHandling),void 0!==this.columnBorders&&(e.columnBorders=this.columnBorders),void 0!==this.rowButtons&&(e.rowButtons=this.rowButtons),void 0!==this.hideFooter&&(e.hideFooter=this.hideFooter),void 0!==this.footerPosition&&(e.footerPosition=this.footerPosition),void 0!==this.initialSortColumn&&(e.initialSortColumn=this.initialSortColumn),void 0!==this.initialSortDirection&&(e.initialSortDirection=this.initialSortDirection),void 0!==this.expandAll&&(e.expandAll=this.expandAll),void 0!==this.autoExpandColumns&&(e.autoExpandColumns=this.autoExpandColumns),void 0!==this.animations&&(e.animations=this.animations),void 0!==this.enableVirtualization&&(e.enableVirtualization=this.enableVirtualization),e}};function w(){return l([])}v([t({required:!0})],f.prototype,"rows",void 0),v([t({required:!0})],f.prototype,"defaultHeaders",void 0),v([t()],f.prototype,"footerRenderer",void 0),v([t()],f.prototype,"loadingStateRenderer",void 0),v([t()],f.prototype,"errorStateRenderer",void 0),v([t()],f.prototype,"emptyStateRenderer",void 0),v([t()],f.prototype,"tableEmptyStateRenderer",void 0),v([t()],f.prototype,"headerDropdown",void 0),v([t()],f.prototype,"columnEditorConfig",void 0),v([t()],f.prototype,"onCellClick",void 0),v([t()],f.prototype,"onCellEdit",void 0),v([t()],f.prototype,"onSortChange",void 0),v([t()],f.prototype,"onFilterChange",void 0),v([t()],f.prototype,"onRowSelectionChange",void 0),v([t()],f.prototype,"onRowGroupExpand",void 0),v([t()],f.prototype,"onColumnOrderChange",void 0),v([t()],f.prototype,"onColumnVisibilityChange",void 0),v([t()],f.prototype,"onColumnWidthChange",void 0),v([t()],f.prototype,"onPageChange",void 0),v([t()],f.prototype,"onLoadMore",void 0),v([t()],f.prototype,"onGridReady",void 0),v([t()],f.prototype,"rowGrouping",void 0),v([t()],f.prototype,"pivot",void 0),v([t()],f.prototype,"onPivotChange",void 0),v([t()],f.prototype,"enableRowSelection",void 0),v([t()],f.prototype,"theme",void 0),v([t()],f.prototype,"quickFilter",void 0),v([t()],f.prototype,"isLoading",void 0),v([t()],f.prototype,"getRowId",void 0),v([t()],f.prototype,"shouldPaginate",void 0),v([t()],f.prototype,"rowsPerPage",void 0),v([t()],f.prototype,"serverSidePagination",void 0),v([t()],f.prototype,"totalRowCount",void 0),v([t()],f.prototype,"height",void 0),v([t()],f.prototype,"maxHeight",void 0),v([t()],f.prototype,"scrollParent",void 0),v([t()],f.prototype,"infiniteScrollThreshold",void 0),v([t()],f.prototype,"columnResizing",void 0),v([t()],f.prototype,"columnReordering",void 0),v([t()],f.prototype,"editColumns",void 0),v([t()],f.prototype,"editColumnsInitOpen",void 0),v([t()],f.prototype,"selectableCells",void 0),v([t()],f.prototype,"selectableColumns",void 0),v([t()],f.prototype,"enableHeaderEditing",void 0),v([t()],f.prototype,"onHeaderEdit",void 0),v([t()],f.prototype,"customTheme",void 0),v([t()],f.prototype,"icons",void 0),v([t()],f.prototype,"externalFilterHandling",void 0),v([t()],f.prototype,"externalSortHandling",void 0),v([t()],f.prototype,"columnBorders",void 0),v([t()],f.prototype,"rowButtons",void 0),v([t()],f.prototype,"hideFooter",void 0),v([t()],f.prototype,"footerPosition",void 0),v([t()],f.prototype,"initialSortColumn",void 0),v([t()],f.prototype,"initialSortDirection",void 0),v([t()],f.prototype,"expandAll",void 0),v([t()],f.prototype,"autoExpandColumns",void 0),v([t()],f.prototype,"animations",void 0),v([t()],f.prototype,"enableVirtualization",void 0),v([o()],f.prototype,"tableReady",void 0),f=v([i({selector:"simple-table",standalone:!0,template:"<div #host></div>",styles:[":host { display: block; }"]})],f);export{f as SimpleTableComponent,w as provideSimpleTable,g as wrapAngularRenderer};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|
|
@@ -4,4 +4,5 @@ export { provideSimpleTable } from "./lib/provideSimpleTable";
|
|
|
4
4
|
/** Wrap a standalone component as an HTMLElement (e.g. for `tableEmptyStateRenderer`). */
|
|
5
5
|
export { wrapAngularRenderer } from "./utils/wrapAngularRenderer";
|
|
6
6
|
export type { SimpleTableAngularProps, TableInstance, AngularHeaderObject, AngularIconsConfig, AngularIconSlot, AngularColumnEditorConfig, AngularCellRenderer, AngularHeaderRenderer, AngularFooterRenderer, AngularHeaderDropdown, AngularColumnEditorRowRenderer, AngularColumnEditorCustomRenderer, AngularLoadingStateRenderer, AngularErrorStateRenderer, AngularEmptyStateRenderer, AngularRowButton, } from "./types";
|
|
7
|
-
export type { Accessor, AggregationConfig, AggregationType, BoundingBox, Cell, CellChangeProps, CellClickProps, CellRenderer, CellRendererProps, CellValue, ChartOptions, ColumnEditorConfig, ColumnEditorRowRenderer, ColumnEditorRowRendererComponents, ColumnEditorCustomRenderer, ColumnEditorCustomRendererProps, ColumnEditorRowRendererProps, ColumnEditorSearchFunction, ColumnType, ColumnVisibilityState, Comparator, ComparatorProps, CustomTheme, CustomThemeProps, DragHandlerProps, EmptyStateRenderer, EmptyStateRendererProps, EnumOption, ErrorStateRenderer, ErrorStateRendererProps, ExportToCSVProps, ExportValueGetter, ExportValueProps, FilterCondition, FilterOperator, StringFilterOperator, NumberFilterOperator, BooleanFilterOperator, DateFilterOperator, EnumFilterOperator, FooterRendererProps, GetRowId, GetRowIdParams, HeaderDropdown, HeaderDropdownProps, HeaderObject, HeaderRenderer, HeaderRendererComponents, HeaderRendererProps, IconsConfig, LoadingStateRenderer, LoadingStateRendererProps, OnRowGroupExpandProps, OnSortProps, QuickFilterConfig, QuickFilterGetter, QuickFilterGetterProps, QuickFilterMode, Row, RowButtonProps, RowId, RowSelectionChangeProps, RowState, SetHeaderRenameProps, SharedTableProps, ShowWhen, SimpleTableConfig, SimpleTableProps, SortColumn, TableAPI, TableFilterState, TableHeaderProps, TableRowProps, Theme, UpdateDataProps, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps, } from "simple-table-core";
|
|
7
|
+
export type { Accessor, AggregationConfig, AggregationType, BoundingBox, Cell, CellChangeProps, CellClickProps, CellRenderer, CellRendererProps, CellValue, ChartOptions, ColumnEditorConfig, ColumnEditorRowRenderer, ColumnEditorRowRendererComponents, ColumnEditorCustomRenderer, ColumnEditorCustomRendererProps, ColumnEditorRowRendererProps, ColumnEditorSearchFunction, ColumnType, ColumnVisibilityState, Comparator, ComparatorProps, CustomTheme, CustomThemeProps, DragHandlerProps, EmptyStateRenderer, EmptyStateRendererProps, EnumOption, ErrorStateRenderer, ErrorStateRendererProps, ExportToCSVProps, ExportValueGetter, ExportValueProps, FilterCondition, FilterOperator, StringFilterOperator, NumberFilterOperator, BooleanFilterOperator, DateFilterOperator, EnumFilterOperator, FooterRendererProps, GetRowId, GetRowIdParams, HeaderDropdown, HeaderDropdownProps, HeaderObject, HeaderRenderer, HeaderRendererComponents, HeaderRendererProps, IconsConfig, LoadingStateRenderer, LoadingStateRendererProps, OnRowGroupExpandProps, OnSortProps, PivotConfig, PivotValueConfig, PivotResult, QuickFilterConfig, QuickFilterGetter, QuickFilterGetterProps, QuickFilterMode, Row, RowButtonProps, RowId, RowSelectionChangeProps, RowState, SetHeaderRenameProps, SharedTableProps, ShowWhen, SimpleTableConfig, SimpleTableProps, SortColumn, TableAPI, TableFilterState, TableHeaderProps, TableRowProps, Theme, UpdateDataProps, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps, } from "simple-table-core";
|
|
8
|
+
export { pivotRows, buildPivotAccessor, buildPivotRowTotalAccessor, PIVOT_CHILDREN_KEY, PIVOT_IS_TOTAL_KEY, PIVOT_ACCESSOR_PREFIX, PIVOT_BLANK_LABEL, } from "simple-table-core";
|
|
@@ -36,6 +36,8 @@ export declare class SimpleTableComponent implements OnInit, OnChanges, OnDestro
|
|
|
36
36
|
onLoadMore?: SimpleTableAngularProps["onLoadMore"];
|
|
37
37
|
onGridReady?: SimpleTableAngularProps["onGridReady"];
|
|
38
38
|
rowGrouping?: SimpleTableAngularProps["rowGrouping"];
|
|
39
|
+
pivot?: SimpleTableAngularProps["pivot"];
|
|
40
|
+
onPivotChange?: SimpleTableAngularProps["onPivotChange"];
|
|
39
41
|
enableRowSelection?: SimpleTableAngularProps["enableRowSelection"];
|
|
40
42
|
theme?: SimpleTableAngularProps["theme"];
|
|
41
43
|
quickFilter?: SimpleTableAngularProps["quickFilter"];
|
|
@@ -83,6 +83,7 @@ export declare class SimpleTableVanilla {
|
|
|
83
83
|
private sectionScrollController;
|
|
84
84
|
private sortManager;
|
|
85
85
|
private filterManager;
|
|
86
|
+
private pivotManager;
|
|
86
87
|
private selectionManager;
|
|
87
88
|
private rowSelectionManager;
|
|
88
89
|
private windowResizeManager;
|
|
@@ -290,6 +291,13 @@ export declare class SimpleTableVanilla {
|
|
|
290
291
|
private handleScroll;
|
|
291
292
|
private clearHoveredRows;
|
|
292
293
|
private updateAriaLiveRegion;
|
|
294
|
+
/** Row grouping used for flatten/expand while pivot is active (overrides consumer). */
|
|
295
|
+
private getEffectiveRowGrouping;
|
|
296
|
+
/**
|
|
297
|
+
* Recompute pivot from filtered source rows and feed sort/selection managers.
|
|
298
|
+
* When pivot is inactive, sort sees the filtered source rows directly.
|
|
299
|
+
*/
|
|
300
|
+
private syncPivotPipeline;
|
|
293
301
|
private getRenderContext;
|
|
294
302
|
private getRenderState;
|
|
295
303
|
/** A leaf column that should size to content (declared with width:"auto"). */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableAPI } from "../../types/TableAPI";
|
|
2
2
|
import { SimpleTableConfig } from "../../types/SimpleTableConfig";
|
|
3
|
-
import HeaderObject from "../../types/HeaderObject";
|
|
3
|
+
import HeaderObject, { Accessor } from "../../types/HeaderObject";
|
|
4
4
|
import Row from "../../types/Row";
|
|
5
5
|
import { CustomTheme } from "../../types/CustomTheme";
|
|
6
6
|
import RowState from "../../types/RowState";
|
|
@@ -10,6 +10,7 @@ import { SortManager } from "../../managers/SortManager";
|
|
|
10
10
|
import { FilterManager } from "../../managers/FilterManager";
|
|
11
11
|
import { FlattenRowsResult } from "../../utils/rowFlattening";
|
|
12
12
|
import { ProcessRowsResult } from "../../utils/rowProcessing";
|
|
13
|
+
import type { PivotConfig } from "../../types/PivotTypes";
|
|
13
14
|
export interface TableAPIContext {
|
|
14
15
|
config: SimpleTableConfig;
|
|
15
16
|
localRows: Row[];
|
|
@@ -66,6 +67,11 @@ export interface TableAPIContext {
|
|
|
66
67
|
setHeaders: (headers: HeaderObject[]) => void;
|
|
67
68
|
setCurrentPage: (page: number) => void;
|
|
68
69
|
setColumnEditorOpen: (open: boolean) => void;
|
|
70
|
+
getEffectiveRowGrouping: () => Accessor[] | undefined;
|
|
71
|
+
setPivot: (config: PivotConfig | null) => void;
|
|
72
|
+
getPivot: () => PivotConfig | null;
|
|
73
|
+
getPivotHeaders: () => HeaderObject[];
|
|
74
|
+
getPivotedRows: () => Row[];
|
|
69
75
|
}
|
|
70
76
|
export declare class TableAPIImpl {
|
|
71
77
|
static createAPI(context: TableAPIContext): TableAPI;
|
|
@@ -8,6 +8,9 @@ import type EnumOption from "./types/EnumOption";
|
|
|
8
8
|
import type HeaderObject from "./types/HeaderObject";
|
|
9
9
|
import type { Accessor, ChartOptions, ColumnType, Comparator, ComparatorProps, ExportValueGetter, ExportValueProps, ShowWhen, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps } from "./types/HeaderObject";
|
|
10
10
|
import type { AggregationConfig, AggregationType } from "./types/AggregationTypes";
|
|
11
|
+
import type { PivotConfig, PivotValueConfig, PivotResult } from "./types/PivotTypes";
|
|
12
|
+
import { PIVOT_CHILDREN_KEY, PIVOT_IS_TOTAL_KEY, PIVOT_ACCESSOR_PREFIX, PIVOT_BLANK_LABEL } from "./types/PivotTypes";
|
|
13
|
+
import { pivotRows, buildPivotAccessor, buildPivotRowTotalAccessor } from "./utils/pivot/pivotRows";
|
|
11
14
|
import type OnSortProps from "./types/OnSortProps";
|
|
12
15
|
import type OnRowGroupExpandProps from "./types/OnRowGroupExpandProps";
|
|
13
16
|
import type Row from "./types/Row";
|
|
@@ -49,6 +52,7 @@ import type { RowId } from "./types/RowId";
|
|
|
49
52
|
import type { PinnedSectionsState } from "./types/PinnedSectionsState";
|
|
50
53
|
export { SimpleTableVanilla };
|
|
51
54
|
export { asRows } from "./utils/asRows";
|
|
55
|
+
export { pivotRows, buildPivotAccessor, buildPivotRowTotalAccessor, PIVOT_CHILDREN_KEY, PIVOT_IS_TOTAL_KEY, PIVOT_ACCESSOR_PREFIX, PIVOT_BLANK_LABEL, };
|
|
52
56
|
export { headersStructurallyEqual, collectHeaderAccessors, rowsShallowUnchanged, shallowEqualRow, SHALLOW_ROW_COMPARE_MAX, } from "./utils/propSyncEqual";
|
|
53
57
|
export type { HeaderStructureLike, GetRowIdLike } from "./utils/propSyncEqual";
|
|
54
|
-
export type { Accessor, AggregationConfig, AggregationType, AnimationsConfig, BoundingBox, Cell, CellChangeProps, CellClickProps, CellRenderer, CellRendererProps, CellValue, ChartOptions, ColumnEditorConfig, ColumnEditorCustomRenderer, ColumnEditorCustomRendererProps, ColumnEditorRowRenderer, ColumnEditorRowRendererComponents, ColumnEditorRowRendererProps, ColumnEditorSearchFunction, ColumnType, ColumnVisibilityState, Comparator, ComparatorProps, CustomTheme, CustomThemeProps, DragHandlerProps, EmptyStateRenderer, EmptyStateRendererProps, EnumOption, ErrorStateRenderer, ErrorStateRendererProps, ExportToCSVProps, ExportValueGetter, ExportValueProps, FilterCondition, FilterOperator, StringFilterOperator, NumberFilterOperator, BooleanFilterOperator, DateFilterOperator, EnumFilterOperator, FooterRendererProps, FooterPosition, GetRowId, GetRowIdParams, IconsConfig, LoadingStateRenderer, LoadingStateRendererProps, HeaderDropdown, HeaderDropdownProps, HeaderObject, HeaderRenderer, HeaderRendererProps, HeaderRendererComponents, OnRowGroupExpandProps, OnSortProps, QuickFilterConfig, QuickFilterGetter, QuickFilterGetterProps, QuickFilterMode, Row, RowButtonProps, RowId, RowSelectionChangeProps, RowSelectionMode, RowState, SetHeaderRenameProps, SharedTableProps, ShowWhen, SimpleTableConfig, SimpleTableProps, SortColumn, TableAPI, TableFilterState, TableHeaderProps, TableRowProps, Theme, PinnedSectionsState, UpdateDataProps, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps, };
|
|
58
|
+
export type { Accessor, AggregationConfig, AggregationType, AnimationsConfig, BoundingBox, Cell, CellChangeProps, CellClickProps, CellRenderer, CellRendererProps, CellValue, ChartOptions, ColumnEditorConfig, ColumnEditorCustomRenderer, ColumnEditorCustomRendererProps, ColumnEditorRowRenderer, ColumnEditorRowRendererComponents, ColumnEditorRowRendererProps, ColumnEditorSearchFunction, ColumnType, ColumnVisibilityState, Comparator, ComparatorProps, CustomTheme, CustomThemeProps, DragHandlerProps, EmptyStateRenderer, EmptyStateRendererProps, EnumOption, ErrorStateRenderer, ErrorStateRendererProps, ExportToCSVProps, ExportValueGetter, ExportValueProps, FilterCondition, FilterOperator, StringFilterOperator, NumberFilterOperator, BooleanFilterOperator, DateFilterOperator, EnumFilterOperator, FooterRendererProps, FooterPosition, GetRowId, GetRowIdParams, IconsConfig, LoadingStateRenderer, LoadingStateRendererProps, HeaderDropdown, HeaderDropdownProps, HeaderObject, HeaderRenderer, HeaderRendererProps, HeaderRendererComponents, OnRowGroupExpandProps, OnSortProps, PivotConfig, PivotValueConfig, PivotResult, QuickFilterConfig, QuickFilterGetter, QuickFilterGetterProps, QuickFilterMode, Row, RowButtonProps, RowId, RowSelectionChangeProps, RowSelectionMode, RowState, SetHeaderRenameProps, SharedTableProps, ShowWhen, SimpleTableConfig, SimpleTableProps, SortColumn, TableAPI, TableFilterState, TableHeaderProps, TableRowProps, Theme, PinnedSectionsState, UpdateDataProps, ValueFormatter, ValueFormatterProps, ValueGetter, ValueGetterProps, };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type HeaderObject from "../types/HeaderObject";
|
|
2
|
+
import type { Accessor } from "../types/HeaderObject";
|
|
3
|
+
import type Row from "../types/Row";
|
|
4
|
+
import type { PivotConfig } from "../types/PivotTypes";
|
|
5
|
+
export interface PivotManagerConfig {
|
|
6
|
+
sourceRows: Row[];
|
|
7
|
+
fieldHeaders: HeaderObject[];
|
|
8
|
+
pivot: PivotConfig | null;
|
|
9
|
+
}
|
|
10
|
+
export interface PivotManagerState {
|
|
11
|
+
active: boolean;
|
|
12
|
+
pivotedRows: Row[];
|
|
13
|
+
headers: HeaderObject[];
|
|
14
|
+
rowGrouping?: Accessor[];
|
|
15
|
+
pivot: PivotConfig | null;
|
|
16
|
+
}
|
|
17
|
+
type StateChangeCallback = (state: PivotManagerState) => void;
|
|
18
|
+
export declare class PivotManager {
|
|
19
|
+
private config;
|
|
20
|
+
private state;
|
|
21
|
+
private subscribers;
|
|
22
|
+
private cacheKey;
|
|
23
|
+
constructor(config: PivotManagerConfig);
|
|
24
|
+
private buildCacheKey;
|
|
25
|
+
private computeState;
|
|
26
|
+
getState(): PivotManagerState;
|
|
27
|
+
isActive(): boolean;
|
|
28
|
+
getPivot(): PivotConfig | null;
|
|
29
|
+
updateConfig(partial: Partial<PivotManagerConfig>): void;
|
|
30
|
+
setPivot(pivot: PivotConfig | null): void;
|
|
31
|
+
subscribe(callback: StateChangeCallback): () => void;
|
|
32
|
+
private notifySubscribers;
|
|
33
|
+
destroy(): void;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -7,4 +7,10 @@ export interface GetRowIdParams {
|
|
|
7
7
|
rowIndexPath: number[];
|
|
8
8
|
groupingKey?: string;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Return a stable business id for the row, or `undefined` / `null` when the row
|
|
12
|
+
* has no id yet (e.g. loading placeholders, pivot aggregates). Nullish returns
|
|
13
|
+
* fall back to reference-based identity so cell keys never collide on
|
|
14
|
+
* `String(undefined)`.
|
|
15
|
+
*/
|
|
16
|
+
export type GetRowId = (params: GetRowIdParams) => string | number | null | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Accessor } from "./HeaderObject";
|
|
2
|
+
import { AggregationConfig } from "./AggregationTypes";
|
|
3
|
+
import HeaderObject from "./HeaderObject";
|
|
4
|
+
import Row from "./Row";
|
|
5
|
+
export type PivotValueConfig = {
|
|
6
|
+
accessor: Accessor;
|
|
7
|
+
aggregation: AggregationConfig;
|
|
8
|
+
label?: string;
|
|
9
|
+
};
|
|
10
|
+
export type PivotConfig = {
|
|
11
|
+
/** Row dimension accessors (0+). Multi-level dims become an expandable tree. */
|
|
12
|
+
rows: Accessor[];
|
|
13
|
+
/** Column dimension accessors (0+). Distinct values become dynamic header groups. */
|
|
14
|
+
columns: Accessor[];
|
|
15
|
+
/** Value/measure configs (required, length >= 1). */
|
|
16
|
+
values: PivotValueConfig[];
|
|
17
|
+
/** Total column(s) aggregating across column dimensions. Default true. */
|
|
18
|
+
showRowTotals?: boolean;
|
|
19
|
+
/** Total row aggregating across row dimensions. Default true. */
|
|
20
|
+
showColumnTotals?: boolean;
|
|
21
|
+
/** Grand-total cell(s) on the totals row/column. Default true. */
|
|
22
|
+
showGrandTotal?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/** Synthetic child-array key used for multi-level pivot row trees. */
|
|
25
|
+
export declare const PIVOT_CHILDREN_KEY = "__pivotChildren";
|
|
26
|
+
/** Marker on total rows for styling / identification. */
|
|
27
|
+
export declare const PIVOT_IS_TOTAL_KEY = "__pivotIsTotal";
|
|
28
|
+
/** Prefix for generated pivot measure accessors. */
|
|
29
|
+
export declare const PIVOT_ACCESSOR_PREFIX = "__pivot:";
|
|
30
|
+
/** Label used when a dimension value is null/undefined. */
|
|
31
|
+
export declare const PIVOT_BLANK_LABEL = "(blank)";
|
|
32
|
+
export type PivotResult = {
|
|
33
|
+
rows: Row[];
|
|
34
|
+
headers: HeaderObject[];
|
|
35
|
+
/** Internal rowGrouping to use while pivot is active (undefined when flat). */
|
|
36
|
+
rowGrouping?: Accessor[];
|
|
37
|
+
};
|
|
@@ -21,6 +21,7 @@ import { VanillaIconsConfig } from "./IconsConfig";
|
|
|
21
21
|
import { QuickFilterConfig } from "./QuickFilterTypes";
|
|
22
22
|
import { AnimationsConfig } from "./AnimationsConfig";
|
|
23
23
|
import type { FooterPosition } from "./FooterPosition";
|
|
24
|
+
import type { PivotConfig } from "./PivotTypes";
|
|
24
25
|
export interface SimpleTableConfig {
|
|
25
26
|
animations?: AnimationsConfig;
|
|
26
27
|
/**
|
|
@@ -99,6 +100,10 @@ export interface SimpleTableConfig {
|
|
|
99
100
|
*/
|
|
100
101
|
onRendererHostDiscard?: (host: HTMLElement) => void;
|
|
101
102
|
onSortChange?: (sort: SortColumn | null) => void;
|
|
103
|
+
/** @see SimpleTableProps.pivot */
|
|
104
|
+
pivot?: PivotConfig | null;
|
|
105
|
+
/** @see SimpleTableProps.onPivotChange */
|
|
106
|
+
onPivotChange?: (pivot: PivotConfig | null) => void;
|
|
102
107
|
quickFilter?: QuickFilterConfig;
|
|
103
108
|
rowButtons?: RowButton[];
|
|
104
109
|
rowGrouping?: Accessor[];
|
|
@@ -21,6 +21,7 @@ import { IconsConfig } from "./IconsConfig";
|
|
|
21
21
|
import { QuickFilterConfig } from "./QuickFilterTypes";
|
|
22
22
|
import { AnimationsConfig } from "./AnimationsConfig";
|
|
23
23
|
import type { FooterPosition } from "./FooterPosition";
|
|
24
|
+
import type { PivotConfig } from "./PivotTypes";
|
|
24
25
|
export interface SimpleTableProps {
|
|
25
26
|
animations?: AnimationsConfig;
|
|
26
27
|
autoExpandColumns?: boolean;
|
|
@@ -97,6 +98,13 @@ export interface SimpleTableProps {
|
|
|
97
98
|
onRowGroupExpand?: (props: OnRowGroupExpandProps) => void | Promise<void>;
|
|
98
99
|
onRowSelectionChange?: (props: RowSelectionChangeProps) => void;
|
|
99
100
|
onSortChange?: (sort: SortColumn | null) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Declarative matrix pivot. When set, flat `rows` are reshaped into a
|
|
103
|
+
* pivoted grid with dynamic columns. Ignores consumer `rowGrouping` while active.
|
|
104
|
+
*/
|
|
105
|
+
pivot?: PivotConfig | null;
|
|
106
|
+
/** Fired when pivot config changes via TableAPI.setPivot. */
|
|
107
|
+
onPivotChange?: (pivot: PivotConfig | null) => void;
|
|
100
108
|
quickFilter?: QuickFilterConfig;
|
|
101
109
|
rowButtons?: RowButton[];
|
|
102
110
|
rowGrouping?: Accessor[];
|
|
@@ -6,6 +6,7 @@ import SortColumn, { SortDirection } from "./SortColumn";
|
|
|
6
6
|
import { TableFilterState, FilterCondition } from "./FilterTypes";
|
|
7
7
|
import Cell from "./Cell";
|
|
8
8
|
import type { PinnedSectionsState } from "./PinnedSectionsState";
|
|
9
|
+
import type { PivotConfig } from "./PivotTypes";
|
|
9
10
|
export interface SetHeaderRenameProps {
|
|
10
11
|
accessor: Accessor;
|
|
11
12
|
}
|
|
@@ -71,4 +72,11 @@ export type TableAPI = {
|
|
|
71
72
|
toggleRowSelection: (rowId: string) => void;
|
|
72
73
|
/** Clears row selection only (does not clear cell selection). */
|
|
73
74
|
clearRowSelection: () => void;
|
|
75
|
+
/** Enable, update, or clear matrix pivot (`null` disables). */
|
|
76
|
+
setPivot: (config: PivotConfig | null) => void;
|
|
77
|
+
getPivot: () => PivotConfig | null;
|
|
78
|
+
/** Generated headers while pivot is active; otherwise current headers. */
|
|
79
|
+
getPivotHeaders: () => HeaderObject[];
|
|
80
|
+
/** Post-pivot rows (pre-flatten) while pivot is active; otherwise source rows. */
|
|
81
|
+
getPivotedRows: () => Row[];
|
|
74
82
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type CellValue from "../types/CellValue";
|
|
2
|
+
import type { AggregationConfig } from "../types/AggregationTypes";
|
|
3
|
+
/**
|
|
4
|
+
* Aggregate a flat list of cell values using the given AggregationConfig.
|
|
5
|
+
* Shared by row-grouping rollups and matrix pivot.
|
|
6
|
+
*/
|
|
7
|
+
export declare const aggregateValues: (allValues: CellValue[], config: AggregationConfig) => number | string | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type HeaderObject from "../../types/HeaderObject";
|
|
2
|
+
import type { Accessor } from "../../types/HeaderObject";
|
|
3
|
+
import type Row from "../../types/Row";
|
|
4
|
+
import type { PivotConfig, PivotResult } from "../../types/PivotTypes";
|
|
5
|
+
export type PivotRowsProps = {
|
|
6
|
+
rows: Row[];
|
|
7
|
+
pivot: PivotConfig;
|
|
8
|
+
/** Field catalog (`defaultHeaders`) for labels, types, widths, formatters. */
|
|
9
|
+
fieldHeaders: HeaderObject[];
|
|
10
|
+
};
|
|
11
|
+
export declare const buildPivotAccessor: (colKey: string, valueAccessor: Accessor) => string;
|
|
12
|
+
export declare const buildPivotRowTotalAccessor: (valueAccessor: Accessor) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Pure transform: flat source rows + pivot config → pivoted rows and generated headers.
|
|
15
|
+
*/
|
|
16
|
+
export declare const pivotRows: ({ rows, pivot, fieldHeaders }: PivotRowsProps) => PivotResult;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Used to skip no-op `defaultHeaders` / `rows` updates when consumers rebuild
|
|
4
4
|
* column configs or shallow-clone rows every render.
|
|
5
5
|
*/
|
|
6
|
+
import type { GetRowIdParams } from "../types/GetRowId";
|
|
6
7
|
/** Minimal header shape for structural comparison (renderers ignored). */
|
|
7
8
|
export type HeaderStructureLike = {
|
|
8
9
|
accessor: string | number | symbol;
|
|
@@ -43,14 +44,8 @@ export declare function collectHeaderAccessors(headers: ReadonlyArray<HeaderStru
|
|
|
43
44
|
* invisible — callers must pass new object identities when data changes.
|
|
44
45
|
*/
|
|
45
46
|
export declare function shallowEqualRow(a: object, b: object): boolean;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
depth?: number;
|
|
49
|
-
index?: number;
|
|
50
|
-
rowPath?: (string | number)[];
|
|
51
|
-
rowIndexPath?: number[];
|
|
52
|
-
groupingKey?: string;
|
|
53
|
-
}) => string | number | undefined;
|
|
47
|
+
/** Compatible with `GetRowId`; return may be undefined for sync helpers. */
|
|
48
|
+
export type GetRowIdLike = (params: GetRowIdParams) => string | number | undefined;
|
|
54
49
|
/**
|
|
55
50
|
* Above this length, skip per-field shallow compares when row object identity
|
|
56
51
|
* differs. Same-array-ref and same-row-object cases stay O(1) / O(n) pointer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simple-table/angular",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/index.es.js",
|
|
6
6
|
"types": "dist/types/angular/src/index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"tslib": "^2.8.1",
|
|
33
|
-
"simple-table-core": "
|
|
33
|
+
"simple-table-core": "4.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@angular/common": "^20.0.0",
|