@3kles/kles-material-table-v2 21.2.0 → 21.4.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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@3kles/kles-material-table-v2",
3
- "version": "21.2.0",
3
+ "version": "21.4.0",
4
4
  "keywords": [
5
5
  "3KLES"
6
6
  ],
7
7
  "author": "3Kles Lab",
8
8
  "license": "ISC",
9
9
  "peerDependencies": {
10
- "@3kles/kles-material-dynamicforms": "^21.0.1",
10
+ "@3kles/kles-material-dynamicforms": "^21.3.0",
11
11
  "@angular/animations": "^21.0.0",
12
12
  "@angular/cdk": "^21.0.0",
13
13
  "@angular/common": "^21.0.0",
@@ -16,7 +16,7 @@
16
16
  "@angular/material": "^21.0.0",
17
17
  "@angular/platform-browser": "^21.0.0",
18
18
  "@angular/router": "^21.0.0",
19
- "rxjs": "^7.8.0"
19
+ "rxjs": "^6.5.3 || ^7.4.0"
20
20
  },
21
21
  "dependencies": {
22
22
  "tslib": "^2.0.0"
@@ -7,7 +7,7 @@ import * as i4 from '@3kles/kles-material-dynamicforms';
7
7
  import { IKlesFieldConfig, GroupUiState, ArrayUiState, AbstractUiState } from '@3kles/kles-material-dynamicforms';
8
8
  import { SortHeaderArrowPosition, SortDirection, Sort, MatSort } from '@angular/material/sort';
9
9
  import * as rxjs from 'rxjs';
10
- import { Observable } from 'rxjs';
10
+ import { Observable, Subject } from 'rxjs';
11
11
  import { PageEvent, MatPaginatorIntl, MatPaginatorSelectConfig, MatPaginator } from '@angular/material/paginator';
12
12
  import { CdkDrag, CdkDragDrop } from '@angular/cdk/drag-drop';
13
13
  import { DataSource } from '@angular/cdk/table';
@@ -40,7 +40,7 @@ interface IKlesHeaderFieldConfig {
40
40
  interface IKlesCellFieldConfig {
41
41
  executeAfterChange?: (property?: string, row?: any, group?: FormGroup<any> | FormArray<any>) => Observable<any>;
42
42
  style?: IStyle;
43
- field: C;
43
+ field?: C;
44
44
  }
45
45
  interface IKlesFooterFieldConfig {
46
46
  style?: IStyle;
@@ -74,8 +74,8 @@ interface KlesColumnConfig {
74
74
  sortable?: boolean;
75
75
  sortArrowPosition?: SortHeaderArrowPosition;
76
76
  resizable?: boolean;
77
- headerCell: IKlesHeaderFieldConfig;
78
- cell: IKlesCellFieldConfig;
77
+ headerCell?: IKlesHeaderFieldConfig;
78
+ cell?: IKlesCellFieldConfig;
79
79
  footerCell?: IKlesFooterFieldConfig;
80
80
  align?: AlignCell;
81
81
  width?: string;
@@ -131,7 +131,7 @@ interface ScrollbarApi {
131
131
  toBottom(sb?: ScrollBehavior): void;
132
132
  toRight(sb?: ScrollBehavior): void;
133
133
  to(top: number, left: number, sb?: ScrollBehavior): void;
134
- getTop(): number;
134
+ getTop(): number | undefined;
135
135
  }
136
136
 
137
137
  declare enum KlesSelectionModelState {
@@ -348,7 +348,20 @@ type Brand<K extends string> = {
348
348
  type SelectionConfig<T> = SelectionConfigDef<T> & Brand<'SelectionConfig'>;
349
349
  declare const selectionConfig: <T>(l: SelectionConfigDef<T>) => SelectionConfig<T>;
350
350
 
351
+ declare class KlesTableIntl {
352
+ readonly changes: Subject<void>;
353
+ emptyStateTitle: string;
354
+ emptyStateDescription: string;
355
+ static ɵfac: i0.ɵɵFactoryDeclaration<KlesTableIntl, never>;
356
+ static ɵprov: i0.ɵɵInjectableDeclaration<KlesTableIntl>;
357
+ }
358
+
351
359
  type TableElevationLevel = 0 | 1 | 2 | 3 | 4 | 5;
360
+ interface EmptyStateConfig {
361
+ enabled?: boolean;
362
+ component?: Type<unknown>;
363
+ intl?: Type<KlesTableIntl>;
364
+ }
352
365
  interface DefaultTableConfig {
353
366
  id?: string;
354
367
  columns: KlesColumnConfig[];
@@ -358,6 +371,7 @@ interface DefaultTableConfig {
358
371
  sortConfig?: Sort;
359
372
  columnSeparator?: boolean | ColumnSeparatorConfig;
360
373
  elevation?: TableElevationLevel;
374
+ emptyState?: boolean | EmptyStateConfig;
361
375
  }
362
376
  interface PaginatorConfig {
363
377
  paginator?: boolean;
@@ -455,8 +469,12 @@ declare class DragDropService extends DragDropBase {
455
469
  declare class ScrollbarService {
456
470
  private element;
457
471
  private default;
472
+ private readonly hiddenClass;
458
473
  register(el: HTMLElement): void;
459
474
  unregister(): void;
475
+ setScrollbarVisible(visible: boolean): void;
476
+ hideScrollbar(): void;
477
+ showScrollbar(): void;
460
478
  toTop(sb?: ScrollBehavior): void;
461
479
  toBottom(sb?: ScrollBehavior): void;
462
480
  toLeft(sb?: ScrollBehavior): void;
@@ -789,32 +807,51 @@ declare class KlesDataSource extends MatTableDataSource<FormGroup, MatPaginator>
789
807
  constructor();
790
808
  }
791
809
 
810
+ interface KlesRowContext<TSource = unknown> {
811
+ source: TSource;
812
+ _id: string | number;
813
+ meta: {
814
+ depth: number;
815
+ parentId: string | null;
816
+ };
817
+ }
818
+
819
+ interface KlesCreatedRow<TSource = unknown> {
820
+ formGroup: FormGroup;
821
+ groupUi: GroupUiState;
822
+ context: KlesRowContext<TSource>;
823
+ }
792
824
  declare class RowFormFactory {
793
825
  createControl(field: IKlesFieldConfig, value?: any): {
794
826
  control: AbstractControl;
795
827
  ui: AbstractUiState;
796
828
  };
797
- createRow(fields: IKlesFieldConfig[], record: any, meta?: {
829
+ createRow<TSource extends Record<string, any>>(fields: IKlesFieldConfig[], record: TSource, meta?: {
798
830
  depth: number;
799
831
  parentId: string | null;
800
- }): {
801
- formGroup: FormGroup;
802
- groupUi: GroupUiState;
803
- };
804
- createRows(fields: IKlesFieldConfig[], records: any[], meta?: {
832
+ }): KlesCreatedRow<TSource>;
833
+ createRows<TSource extends Record<string, any>>(fields: IKlesFieldConfig[], records: TSource[], meta?: {
805
834
  depth: number;
806
835
  parentId: string | null;
807
- }): {
808
- formGroup: FormGroup;
809
- groupUi: GroupUiState;
810
- }[];
836
+ }): KlesCreatedRow<TSource>[];
811
837
  static ɵfac: i0.ɵɵFactoryDeclaration<RowFormFactory, never>;
812
838
  static ɵprov: i0.ɵɵInjectableDeclaration<RowFormFactory>;
813
839
  }
814
840
 
841
+ declare class RowContextStore {
842
+ private readonly contexts;
843
+ set<TSource>(row: AbstractControl, context: KlesRowContext<TSource>): void;
844
+ get<TSource = unknown>(row: AbstractControl): Signal<KlesRowContext<TSource> | null> | null;
845
+ updateSource<TSource>(row: AbstractControl, source: TSource): void;
846
+ delete(row: AbstractControl): void;
847
+ static ɵfac: i0.ɵɵFactoryDeclaration<RowContextStore, never>;
848
+ static ɵprov: i0.ɵɵInjectableDeclaration<RowContextStore>;
849
+ }
850
+
815
851
  declare class KlesForm {
816
852
  private columnsService;
817
853
  private rowFactory;
854
+ private rowContextStore;
818
855
  readonly form: FormGroup<{
819
856
  header: FormGroup<{}>;
820
857
  rows: FormArray<FormGroup<any>>;
@@ -828,31 +865,22 @@ declare class KlesForm {
828
865
  readonly uiStore: WeakMap<AbstractControl<any, any, any>, AbstractUiState<any, any>>;
829
866
  private readonly rowsStructureChangedSubject;
830
867
  readonly rowsStructureChanged$: rxjs.Observable<void>;
831
- constructor(columnsService: ColumnsService, rowFactory: RowFormFactory);
868
+ constructor(columnsService: ColumnsService, rowFactory: RowFormFactory, rowContextStore: RowContextStore);
832
869
  getRows(): FormArray<FormGroup>;
833
870
  getUiRows(): ArrayUiState;
834
871
  getUiHeader(): GroupUiState;
835
872
  getUiFooter(): GroupUiState;
836
873
  getHeader(): FormGroup;
837
874
  getFooter(): FormGroup;
838
- setRows(rows: {
839
- formGroup: FormGroup;
840
- groupUi: GroupUiState;
841
- }[]): void;
875
+ setRows(rows: KlesCreatedRow[]): void;
842
876
  private insertRowAndNotify;
843
- insertRow(row: {
844
- formGroup: FormGroup;
845
- groupUi: GroupUiState;
846
- }, index?: number, options?: {
877
+ insertRow(row: KlesCreatedRow, index?: number, options?: {
847
878
  emitEvent?: boolean;
848
879
  }): {
849
880
  formGroup: FormGroup;
850
881
  groupUi: GroupUiState;
851
882
  };
852
- insertRows(rows: {
853
- formGroup: FormGroup;
854
- groupUi: GroupUiState;
855
- }[], index?: number): void;
883
+ insertRows(rows: KlesCreatedRow[], index?: number): void;
856
884
  updateRow(_id: number | string, value: any, options?: {
857
885
  emitEvent?: boolean;
858
886
  onlySelf?: boolean;
@@ -911,6 +939,7 @@ declare class ValidationService {
911
939
 
912
940
  interface IDatasourceService {
913
941
  get datasource(): IKlesDataSource;
942
+ readonly isEmpty: Signal<boolean>;
914
943
  register(): void;
915
944
  }
916
945
  declare class DatasourceService implements IDatasourceService {
@@ -920,6 +949,8 @@ declare class DatasourceService implements IDatasourceService {
920
949
  private validationService;
921
950
  private _datasource;
922
951
  private readonly destroyRef;
952
+ private readonly _isEmpty;
953
+ readonly isEmpty: Signal<boolean>;
923
954
  constructor(fm: KlesForm, columnsService: ColumnsService, cellValueChangeService: CellValueChangeService, validationService: ValidationService);
924
955
  register(): void;
925
956
  get datasource(): KlesDataSource;
@@ -1023,6 +1054,7 @@ interface ILinesService {
1023
1054
  register(): void;
1024
1055
  total(): number;
1025
1056
  loaded(): EventEmitter<void>;
1057
+ loading(): EventEmitter<void>;
1026
1058
  }
1027
1059
 
1028
1060
  interface ISelectionService {
@@ -1094,6 +1126,27 @@ declare class CellService {
1094
1126
  static ɵprov: i0.ɵɵInjectableDeclaration<CellService>;
1095
1127
  }
1096
1128
 
1129
+ declare class KlesTableEmptyStateComponent {
1130
+ readonly intl: KlesTableIntl;
1131
+ private readonly changeDetectorRef;
1132
+ private readonly destroyRef;
1133
+ constructor();
1134
+ static ɵfac: i0.ɵɵFactoryDeclaration<KlesTableEmptyStateComponent, never>;
1135
+ static ɵcmp: i0.ɵɵComponentDeclaration<KlesTableEmptyStateComponent, "kles-table-empty-state", never, {}, {}, never, never, true, never>;
1136
+ }
1137
+
1138
+ declare class EmptyStateService {
1139
+ private readonly _enabled;
1140
+ readonly enabled: i0.Signal<boolean>;
1141
+ readonly component: Type<unknown>;
1142
+ constructor(config: boolean | EmptyStateConfig | undefined);
1143
+ enable(): void;
1144
+ disable(): void;
1145
+ toggle(): void;
1146
+ static ɵfac: i0.ɵɵFactoryDeclaration<EmptyStateService, never>;
1147
+ static ɵprov: i0.ɵɵInjectableDeclaration<EmptyStateService>;
1148
+ }
1149
+
1097
1150
  type TableSection = 'header' | 'body' | 'footer';
1098
1151
  declare class TableComponent implements ITable, OnInit, AfterViewInit, OnDestroy {
1099
1152
  private readonly host;
@@ -1117,6 +1170,7 @@ declare class TableComponent implements ITable, OnInit, AfterViewInit, OnDestroy
1117
1170
  private readonly eventsService;
1118
1171
  readonly rowService: RowService;
1119
1172
  readonly cellService: CellService;
1173
+ readonly emptyStateService: EmptyStateService;
1120
1174
  table: MatTable<FormGroup>;
1121
1175
  matSort: MatSort;
1122
1176
  formElemRef: ElementRef<HTMLElement>;
@@ -1131,12 +1185,15 @@ declare class TableComponent implements ITable, OnInit, AfterViewInit, OnDestroy
1131
1185
  extraRows: Signal<(ExtraRowConfig & {
1132
1186
  displayedColumns: string[];
1133
1187
  })[]>;
1188
+ readonly isEmpty: Signal<boolean>;
1134
1189
  private ro?;
1135
1190
  private readonly destroyRef;
1136
1191
  private rafId?;
1137
1192
  private _cleanup?;
1138
- constructor(host: ElementRef<HTMLElement>, connectorService: KlesTableConnectorService, loader: ILoader<any>, datasourceService: IDatasourceService, tableService: ITableService, dragDropRowService: DragDropService, selectionService: ISelectionService, columnsService: ColumnsService, loadingService: LoadingService, paginatorService: PaginatorService, scrollbarService: ScrollbarService, footerService: FooterService, extraRowService: ExtraRowService, renderService: RenderService, sortService: ISortService, filterService: FilterService, expandedRowStore: ExpandedRowStore, rowFactory: RowFormFactory, eventsService: EventsService, rowService: RowService, cellService: CellService);
1193
+ emptyStateComponent: typeof KlesTableEmptyStateComponent;
1194
+ constructor(host: ElementRef<HTMLElement>, connectorService: KlesTableConnectorService, loader: ILoader<any>, datasourceService: IDatasourceService, tableService: ITableService, dragDropRowService: DragDropService, selectionService: ISelectionService, columnsService: ColumnsService, loadingService: LoadingService, paginatorService: PaginatorService, scrollbarService: ScrollbarService, footerService: FooterService, extraRowService: ExtraRowService, renderService: RenderService, sortService: ISortService, filterService: FilterService, expandedRowStore: ExpandedRowStore, rowFactory: RowFormFactory, eventsService: EventsService, rowService: RowService, cellService: CellService, emptyStateService: EmptyStateService);
1139
1195
  get isLoadingClass(): boolean;
1196
+ get isEmptyClass(): boolean;
1140
1197
  get events(): EventsApi;
1141
1198
  get form(): FormApi;
1142
1199
  get scrollbar(): ScrollbarApi;
@@ -1161,7 +1218,7 @@ declare class TableComponent implements ITable, OnInit, AfterViewInit, OnDestroy
1161
1218
  getStickyEndSeparator(column: KlesColumnConfig, section: TableSection): string | null;
1162
1219
  private getSeparatorStyle;
1163
1220
  private calculHeaderHeight;
1164
- static ɵfac: i0.ɵɵFactoryDeclaration<TableComponent, [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, { optional: true; }, null, null, null, null, null]>;
1221
+ static ɵfac: i0.ɵɵFactoryDeclaration<TableComponent, [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, { optional: true; }, null, null, null, null, null, null]>;
1165
1222
  static ɵcmp: i0.ɵɵComponentDeclaration<TableComponent, "kles-table", never, {}, {}, never, never, true, never>;
1166
1223
  }
1167
1224
 
@@ -1239,6 +1296,7 @@ declare const SELECTION_SERVICE: InjectionToken<ISelectionService>;
1239
1296
  declare const SORT_SERVICE: InjectionToken<ISortService>;
1240
1297
  declare const SCROLLBAR_ORCHESTRATOR_SERVICE: InjectionToken<IScrollbarOrchestratorService>;
1241
1298
  declare const TABLE_SERVICE: InjectionToken<ITableService>;
1299
+ declare const EMPTY_STATE_CONFIG: InjectionToken<boolean | EmptyStateConfig>;
1242
1300
 
1243
- export { AlignCell, COLUMNS, DATASOURCE_SERVICE, DRAG_DROP_CONFIG, EXTRA_ROWS, FOOTER, HEADER_SERVICE, KlesMaterialTableModule, KlesTableComponent, LINES_SERVICE, LOADER_CONFIG, LOADER_SERVICE, PAGINATOR_CONFIG, ROW_DRAG_DROP, SCROLLBAR_ORCHESTRATOR_SERVICE, SELECTION_CONFIG, SELECTION_SERVICE, SORT_CONFIG, SORT_SERVICE, Span, TABLE_SERVICE, TableComponent, linesLazyLoader, linesLoader, selectionConfig };
1244
- export type { ColumnSeparatorConfig, ColumnSeparatorStyle, DefaultTableConfig, DragDrop, DragDropConfig, ExtraRow, ExtraRowConfig, ExtraRowMode, IKlesCellFieldConfig, IKlesFooterFieldConfig, IKlesHeaderFieldConfig, ITable, InfiniteScrollConfig, KlesColumnConfig, KlesExtraCellFieldConfig, KlesTableApi, KlesTableConfig, LinesLazyLoader, LinesLoader, LoaderConfig, LoaderLazyResult, LoaderResult, NgStyleInput, PaginatorConfig, RowId, Selection, SelectionAllResponse, SelectionConfig, SelectionResponse, SelectionState, TableElevationLevel };
1301
+ export { AlignCell, COLUMNS, DATASOURCE_SERVICE, DRAG_DROP_CONFIG, EMPTY_STATE_CONFIG, EXTRA_ROWS, FOOTER, HEADER_SERVICE, KlesMaterialTableModule, KlesTableComponent, KlesTableEmptyStateComponent, KlesTableIntl, LINES_SERVICE, LOADER_CONFIG, LOADER_SERVICE, PAGINATOR_CONFIG, ROW_DRAG_DROP, SCROLLBAR_ORCHESTRATOR_SERVICE, SELECTION_CONFIG, SELECTION_SERVICE, SORT_CONFIG, SORT_SERVICE, Span, TABLE_SERVICE, TableComponent, linesLazyLoader, linesLoader, selectionConfig };
1302
+ export type { ColumnSeparatorConfig, ColumnSeparatorStyle, DefaultTableConfig, DragDrop, DragDropConfig, EmptyStateConfig, ExtraRow, ExtraRowConfig, ExtraRowMode, IKlesCellFieldConfig, IKlesFooterFieldConfig, IKlesHeaderFieldConfig, ITable, InfiniteScrollConfig, KlesColumnConfig, KlesExtraCellFieldConfig, KlesTableApi, KlesTableConfig, LinesLazyLoader, LinesLoader, LoaderConfig, LoaderLazyResult, LoaderResult, NgStyleInput, PaginatorConfig, RowId, Selection, SelectionAllResponse, SelectionConfig, SelectionResponse, SelectionState, TableElevationLevel };