@oneteme/jquery-table 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,199 @@
1
+ import { AfterViewInit, ElementRef, EventEmitter, OnChanges, OnDestroy, QueryList, SimpleChanges, TemplateRef } from '@angular/core';
2
+ import { MatMenuTrigger } from '@angular/material/menu';
3
+ import { MatPaginator } from '@angular/material/paginator';
4
+ import { MatSort } from '@angular/material/sort';
5
+ import { MatTableDataSource } from '@angular/material/table';
6
+ import { TableColumnProvider, TableProvider } from '../jquery-table.model';
7
+ import { JqtCellDefDirective } from '../directive/jqt-cell-def.directive';
8
+ import { SlicePanelComponent } from './slice-panel/slice-panel.component';
9
+ import * as i0 from "@angular/core";
10
+ export declare class TableComponent<T = any> implements OnChanges, AfterViewInit, OnDestroy {
11
+ config?: TableProvider<T>;
12
+ dataSource?: T[] | {
13
+ data: T[];
14
+ };
15
+ data?: T[];
16
+ displayedColumns?: string[];
17
+ columnsConfig?: TableColumnProvider<T>[];
18
+ columnLabels?: Record<string, string>;
19
+ isLoading: boolean;
20
+ addRequested: EventEmitter<void>;
21
+ columnAdded: EventEmitter<TableColumnProvider<T>>;
22
+ columnRemoved: EventEmitter<TableColumnProvider<T>>;
23
+ categorySelected: EventEmitter<string>;
24
+ rowSelected: EventEmitter<T>;
25
+ set paginator(value: MatPaginator | undefined);
26
+ get paginator(): MatPaginator | undefined;
27
+ private _paginator?;
28
+ sort?: MatSort;
29
+ tableBodyScrollRef?: ElementRef<HTMLElement>;
30
+ slicePanelRef?: SlicePanelComponent<T>;
31
+ viewMenuTrigger?: MatMenuTrigger;
32
+ _cellDefs: QueryList<JqtCellDefDirective>;
33
+ renderedColumns: string[];
34
+ tableDataSource: MatTableDataSource<any, import("@angular/material/table").MatTableDataSourcePaginator>;
35
+ activeColumns: TableColumnProvider<T>[];
36
+ activeSliceFilter: (row: T) => boolean;
37
+ _sliceConfigs: any[];
38
+ _sliceColumns: TableColumnProvider<T>[];
39
+ _sliceData: T[];
40
+ _sliceShowToggle: boolean;
41
+ _staticSlicesForMenu: Array<{
42
+ key: string;
43
+ title: string;
44
+ icon?: string;
45
+ }>;
46
+ _activeDynamicSliceColumns: TableColumnProvider<T>[];
47
+ _availableColumnsForDynamicSlice: TableColumnProvider<T>[];
48
+ _allDynamicSliceColumns: TableColumnProvider<T>[];
49
+ _activeSliceByLabel: string;
50
+ searchQuery: string;
51
+ activeGroupByKey: string | null;
52
+ _matSortActive: string;
53
+ _matSortDirection: 'asc' | 'desc' | '';
54
+ private _collapsedGroups;
55
+ private _activeSort;
56
+ private _sortSubscribed;
57
+ private _destroy$;
58
+ private _defaultGroupCollapsed;
59
+ private _groupPages;
60
+ private _totalFilteredCount;
61
+ _lazyColumnStatus: Map<string, "error" | "loaded" | "idle" | "loading">;
62
+ _lazyColumnData: Map<string, Map<any, any>>;
63
+ private _lazyFetchCancels;
64
+ private _cdr;
65
+ private _el;
66
+ isGroupHeader: (_: number, row: any) => boolean;
67
+ pageSize: number;
68
+ pageSizeOptions: number[];
69
+ pageSizeOptionsGroupBy: number[];
70
+ groupPageSize: number;
71
+ groupSortOrder: 'asc' | 'desc';
72
+ draggedColumnKey: string | null;
73
+ dragOverColumnKey: string | null;
74
+ private userCustomizedColumns;
75
+ private resolvedConfig;
76
+ private _columnMap;
77
+ private _resolvedData;
78
+ private _preservePageIndex;
79
+ private _initialSearchApplied;
80
+ private static readonly MAX_GROUP_COUNT;
81
+ private _allFilteredRows;
82
+ private _paginatorSubscribed;
83
+ private _groupCacheRows;
84
+ private _groupCacheKey;
85
+ private _groupCacheSortOrder;
86
+ private _groupCacheSortActive;
87
+ private _groupCacheSortDir;
88
+ private _groupCacheOrder;
89
+ private _groupCacheMap;
90
+ private _pendingRender;
91
+ ngOnChanges(changes: SimpleChanges): void;
92
+ ngAfterViewInit(): void;
93
+ ngOnDestroy(): void;
94
+ private _measureHeaderHeight;
95
+ get title(): string;
96
+ get showTitle(): boolean;
97
+ get visibleColumns(): TableColumnProvider<T>[];
98
+ get showSearchBar(): boolean;
99
+ get showViewButton(): boolean;
100
+ get showToolbar(): boolean;
101
+ get showFields(): boolean;
102
+ get showGroupBySection(): boolean;
103
+ get filteredRowCount(): number;
104
+ get activeGroupByLabel(): string;
105
+ get totalColumnCount(): number;
106
+ get activeSliceByLabel(): string;
107
+ get activeDynamicSliceColumns(): TableColumnProvider<T>[];
108
+ removeDynamicSliceByKey(key: string): void;
109
+ get groupByColumns(): TableColumnProvider<T>[];
110
+ colLabel(col: {
111
+ key: string;
112
+ header?: string;
113
+ }): string;
114
+ onSearchChange(): void;
115
+ onGroupByChange(key: string | null): void;
116
+ onGroupPageSizeChange(size: number | string): void;
117
+ onGroupSortToggle(dir: 'asc' | 'desc'): void;
118
+ getLazyColumnStatus(key: string): 'idle' | 'loading' | 'loaded' | 'error';
119
+ getLazyRenderType(rowValue: any): 'loading' | 'error' | 'value';
120
+ retryLazyColumn(column: TableColumnProvider<T>): void;
121
+ triggerLazyFetch(column: TableColumnProvider<T>): void;
122
+ toggleGroupCollapse(groupKey: string): void;
123
+ private scrollToGroupHeader;
124
+ isGroupCollapsed(groupKey: string): boolean;
125
+ groupPageBack(groupKey: string): void;
126
+ groupPageForward(groupKey: string, totalCount: number): void;
127
+ get hasAddableColumns(): boolean;
128
+ get menuBaseColumns(): TableColumnProvider<T>[];
129
+ get menuOptionalColumns(): TableColumnProvider<T>[];
130
+ get availableColumnsToAdd(): TableColumnProvider<T>[];
131
+ get allowColumnRemoval(): boolean;
132
+ get hasSliceConfig(): boolean;
133
+ get showSlicePanel(): boolean;
134
+ get showAddSliceButton(): boolean;
135
+ get staticSlicesForMenu(): Array<{
136
+ key: string;
137
+ title: string;
138
+ icon?: string;
139
+ }>;
140
+ get availableColumnsForDynamicSlice(): TableColumnProvider<T>[];
141
+ isStaticSliceVisible(columnKey: string): boolean;
142
+ toggleStaticSlice(columnKey: string): void;
143
+ addDynamicSlice(column: TableColumnProvider<T>): void;
144
+ get allDynamicSliceColumns(): TableColumnProvider<T>[];
145
+ isDynamicSliceActive(key: string): boolean;
146
+ toggleDynamicSlice(col: TableColumnProvider<T>): void;
147
+ onSliceFilterChange(pred: (row: T) => boolean): void;
148
+ onDynamicSliceKeysChange(keys: string[]): void;
149
+ get emptyStateLabel(): string;
150
+ get loadingStateLabel(): string;
151
+ get effectiveIsLoading(): boolean;
152
+ get isEmpty(): boolean;
153
+ get showPagination(): boolean;
154
+ get isColumnDragDropEnabled(): boolean;
155
+ get totalRows(): number;
156
+ onAddColumn(column: TableColumnProvider<T>): void;
157
+ onColumnVisibilityChange(column: TableColumnProvider<T>, checked: boolean): void;
158
+ isColumnVisible(columnKey: string): boolean;
159
+ onRemoveColumn(columnKey: string, event?: Event): void;
160
+ getCellTemplate(key: string): TemplateRef<{
161
+ $implicit: any;
162
+ index: number;
163
+ }> | null;
164
+ get hasCustomCellDefs(): boolean;
165
+ get hasRowClickHandler(): boolean;
166
+ trackRowFn: (_index: number, row: any) => any;
167
+ getRowClass(row: any): string | string[] | Record<string, boolean>;
168
+ onRowClick(row: any, event: MouseEvent | null): void;
169
+ onHeaderDragStart(columnKey: string, event: DragEvent): void;
170
+ onHeaderDragOver(columnKey: string, event: DragEvent): void;
171
+ onHeaderDrop(targetColumnKey: string, event: DragEvent): void;
172
+ onHeaderDragEnd(): void;
173
+ isHeaderDropTarget(columnKey: string): boolean;
174
+ canRemoveColumn(column: TableColumnProvider<T>): boolean;
175
+ isCellEmpty(value: any): boolean;
176
+ asTitle(value: any): string;
177
+ private refreshViewModel;
178
+ private _computeSliceLabel;
179
+ private _scheduleRender;
180
+ private _executeRender;
181
+ private _projectCurrentPage;
182
+ private buildEffectiveConfig;
183
+ private resolveData;
184
+ private resolveColumnsFromCompat;
185
+ private getCategoryFilteredData;
186
+ private projectRows;
187
+ private _buildSortComparator;
188
+ private getLazyAwareValue;
189
+ private resolveCellValue;
190
+ private resolvePageSize;
191
+ private resolvePageSizeOptions;
192
+ private resolvePageSizeOptionsGroupBy;
193
+ private resolveDefaultGroupPageSize;
194
+ private uniqueColumnsByKey;
195
+ private attachPaginator;
196
+ private attachSort;
197
+ static ɵfac: i0.ɵɵFactoryDeclaration<TableComponent<any>, never>;
198
+ static ɵcmp: i0.ɵɵComponentDeclaration<TableComponent<any>, "jquery-table", never, { "config": { "alias": "config"; "required": false; }; "dataSource": { "alias": "dataSource"; "required": false; }; "data": { "alias": "data"; "required": false; }; "displayedColumns": { "alias": "displayedColumns"; "required": false; }; "columnsConfig": { "alias": "columnsConfig"; "required": false; }; "columnLabels": { "alias": "columnLabels"; "required": false; }; "isLoading": { "alias": "isLoading"; "required": false; }; }, { "addRequested": "addRequested"; "columnAdded": "columnAdded"; "columnRemoved": "columnRemoved"; "categorySelected": "categorySelected"; "rowSelected": "rowSelected"; }, ["_cellDefs"], never, true, never>;
199
+ }
@@ -0,0 +1,17 @@
1
+ import { MatPaginatorIntl } from '@angular/material/paginator';
2
+ /** Traductions françaises du paginator Material. */
3
+ export declare function getFrenchPaginatorIntl(): MatPaginatorIntl;
4
+ /**
5
+ * Convertit une valeur brute en chaîne affichable.
6
+ * - null/undefined → ''
7
+ * - Date → format locale fr-FR
8
+ * - Tableau → valeurs jointes par ', '
9
+ * - Objet avec label/name → sa valeur string
10
+ * - Autres → String(value)
11
+ */
12
+ export declare function normalizeCellValue(value: any): any;
13
+ /**
14
+ * Transforme une clé camelCase/snake_case en libellé lisible.
15
+ * Ex: 'createdAt' → 'Created at', 'my_field' → 'My field'
16
+ */
17
+ export declare function humanizeKey(key: string): string;
@@ -0,0 +1,29 @@
1
+ import { TemplateRef } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Directive permettant de définir un template de cellule personnalisé pour une colonne.
5
+ *
6
+ * Usage:
7
+ * ```html
8
+ * <jquery-table [config]="tableConfig">
9
+ * <ng-template jqtCellDef="monKey" let-row>
10
+ * <span>{{ row.monChamp }}</span>
11
+ * </ng-template>
12
+ * </jquery-table>
13
+ * ```
14
+ * Le contexte expose `$implicit` (ligne brute `T`) et `index` (index global).
15
+ */
16
+ export declare class JqtCellDefDirective {
17
+ readonly template: TemplateRef<{
18
+ $implicit: any;
19
+ index: number;
20
+ }>;
21
+ /** Clé de la colonne à laquelle ce template s'applique. */
22
+ columnKey: string;
23
+ constructor(template: TemplateRef<{
24
+ $implicit: any;
25
+ index: number;
26
+ }>);
27
+ static ɵfac: i0.ɵɵFactoryDeclaration<JqtCellDefDirective, never>;
28
+ static ɵdir: i0.ɵɵDirectiveDeclaration<JqtCellDefDirective, "[jqtCellDef]", never, { "columnKey": { "alias": "jqtCellDef"; "required": false; }; }, {}, never, never, true, never>;
29
+ }
@@ -0,0 +1,72 @@
1
+ import { DataProvider } from '@oneteme/jquery-core';
2
+ import { Observable } from 'rxjs';
3
+ import { SliceConfig } from './component/slice-panel/slice-panel.model';
4
+ export { SliceConfig } from './component/slice-panel/slice-panel.model';
5
+ export interface TableColumnProvider<T = any> {
6
+ key: string;
7
+ /** Libellé affiché dans l'en-tête de colonne. Optionnel si la colonne utilise un template custom. */
8
+ header?: string;
9
+ icon?: string;
10
+ value?: DataProvider<any>;
11
+ /** Valeur utilisée pour le tri si différente de `value`. Utile quand `value` retourne une chaîne formatée (date, durée...). */
12
+ sortValue?: DataProvider<any>;
13
+ sortable?: boolean;
14
+ removable?: boolean;
15
+ optional?: boolean;
16
+ width?: string;
17
+ groupable?: boolean;
18
+ sliceable?: boolean;
19
+ /** Chargement différé : la présence de cet objet active le mode lazy. */
20
+ lazy?: {
21
+ /** Fonction appelée pour charger les valeurs de la colonne. Retourne un tableau dans le même ordre que les lignes. */
22
+ fetchFn: () => Observable<any[]>;
23
+ };
24
+ }
25
+ /** Configuration de la barre de recherche. */
26
+ export interface TableSearchConfig {
27
+ enabled?: boolean;
28
+ /** Valeur initiale au chargement. */
29
+ initialQuery?: string;
30
+ }
31
+ /** Configuration de la pagination. */
32
+ export interface TablePaginationConfig {
33
+ enabled?: boolean;
34
+ pageSize?: number;
35
+ pageSizeOptions?: number[];
36
+ /** Options de taille de page spécifiques au mode Group by. Si absent, utilise `pageSizeOptions`. */
37
+ pageSizeOptionsGroupBy?: number[];
38
+ }
39
+ /** Configuration du menu View (Champs / Group by / Slice by). */
40
+ export interface TableViewConfig {
41
+ /** Active le bouton View. Par défaut : `false`. */
42
+ enabled?: boolean;
43
+ /** Autorise le masquage/affichage des colonnes de base via View > Champs. Par défaut : `true`. */
44
+ enableColumnRemoval?: boolean;
45
+ /** Active le drag & drop pour réordonner les colonnes. Par défaut : `false`. */
46
+ enableColumnDragDrop?: boolean;
47
+ }
48
+ /** Labels d'état du tableau. */
49
+ export interface TableLabelsConfig {
50
+ /** Affiché quand le tableau est vide. Par défaut : `'Aucune donnée'`. */
51
+ empty?: string;
52
+ /** Affiché pendant le chargement. Par défaut : `'Chargement des données...'`. */
53
+ loading?: string;
54
+ }
55
+ export interface TableProvider<T = any> {
56
+ columns?: TableColumnProvider<T>[];
57
+ title?: string;
58
+ slices?: SliceConfig<T>[];
59
+ /** Affiche le bouton toggle pour replier/déplier le panneau de slices. Par défaut : `true`. */
60
+ enableSliceToggle?: boolean;
61
+ search?: TableSearchConfig;
62
+ pagination?: TablePaginationConfig;
63
+ view?: TableViewConfig;
64
+ labels?: TableLabelsConfig;
65
+ /** Tri initial appliqué au chargement. N'est pas écrasé par les changements de données. */
66
+ defaultSort?: {
67
+ active: string;
68
+ direction: 'asc' | 'desc';
69
+ };
70
+ rowClass?: (row: T, index: number) => string | string[] | Record<string, boolean>;
71
+ onRowSelected?: (row: T, event: MouseEvent | null) => void;
72
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@oneteme/jquery-table",
3
+ "version": "0.0.1",
4
+ "description": "jquery table lib",
5
+ "homepage": "https://github.com/oneteme/jquery-charts",
6
+ "bugs": "https://github.com/oneteme/jquery-charts/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/oneteme/jquery-charts.git"
10
+ },
11
+ "peerDependencies": {
12
+ "@angular/common": ">=16.1.0",
13
+ "@angular/core": ">=16.1.0",
14
+ "@angular/material": "^16.1.0",
15
+ "@angular/cdk": "^16.1.0",
16
+ "@oneteme/jquery-core": "^0.0.27"
17
+ },
18
+ "dependencies": {
19
+ "tslib": "^2.3.0"
20
+ },
21
+ "sideEffects": false,
22
+ "module": "fesm2022/oneteme-jquery-table.mjs",
23
+ "typings": "index.d.ts",
24
+ "exports": {
25
+ "./package.json": {
26
+ "default": "./package.json"
27
+ },
28
+ ".": {
29
+ "types": "./index.d.ts",
30
+ "esm2022": "./esm2022/oneteme-jquery-table.mjs",
31
+ "esm": "./esm2022/oneteme-jquery-table.mjs",
32
+ "default": "./fesm2022/oneteme-jquery-table.mjs"
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,5 @@
1
+ export * from './lib/jquery-table.model';
2
+ export * from './lib/component/table.component';
3
+ export * from './lib/component/slice-panel/slice-panel.model';
4
+ export * from './lib/component/slice-panel/slice-panel.component';
5
+ export * from './lib/directive/jqt-cell-def.directive';