@wakastellar/ui 0.1.6 → 0.1.10
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/blocks/index.d.ts +3 -0
- package/dist/blocks/sidebar/index.d.ts +149 -0
- package/dist/components/DataTable/DataTable.d.ts +1 -1
- package/dist/components/DataTable/DataTableAdvanced.d.ts +1 -1
- package/dist/components/DataTable/DataTableBody.d.ts +68 -0
- package/dist/components/DataTable/DataTableCell.d.ts +34 -0
- package/dist/components/DataTable/DataTableConflictResolver.d.ts +45 -0
- package/dist/components/DataTable/DataTableFilterBuilder.d.ts +14 -0
- package/dist/components/DataTable/DataTableFilters.d.ts +3 -3
- package/dist/components/DataTable/DataTableGroupRow.d.ts +35 -0
- package/dist/components/DataTable/DataTableHeader.d.ts +48 -0
- package/dist/components/DataTable/DataTableRow.d.ts +28 -0
- package/dist/components/DataTable/DataTableSelection.d.ts +17 -12
- package/dist/components/DataTable/DataTableSyncStatus.d.ts +31 -0
- package/dist/components/DataTable/formatters/index.d.ts +127 -0
- package/dist/components/DataTable/hooks/useDataTable.d.ts +1 -1
- package/dist/components/DataTable/hooks/useDataTableAdvanced.d.ts +6 -6
- package/dist/components/DataTable/hooks/useDataTableAdvancedFilters.d.ts +18 -0
- package/dist/components/DataTable/hooks/useDataTableColumnTemplates.d.ts +28 -0
- package/dist/components/DataTable/hooks/useDataTableExport.d.ts +7 -3
- package/dist/components/DataTable/hooks/useDataTableImport.d.ts +4 -2
- package/dist/components/DataTable/hooks/useDataTableOffline.d.ts +80 -0
- package/dist/components/DataTable/hooks/useDataTableVirtualization.d.ts +1 -1
- package/dist/components/DataTable/index.d.ts +48 -2
- package/dist/components/DataTable/services/IndexedDBService.d.ts +117 -0
- package/dist/components/DataTable/templates/index.d.ts +104 -0
- package/dist/components/DataTable/types.d.ts +417 -25
- package/dist/components/WakaKeycloakLogin/WakaKeycloakLogin.d.ts +3 -0
- package/dist/components/WakaKeycloakLogin/index.d.ts +2 -0
- package/dist/components/WakaKeycloakLogin/types.d.ts +56 -0
- package/dist/components/command/index.d.ts +1 -1
- package/dist/components/error-boundary/ErrorBoundary.d.ts +102 -0
- package/dist/components/error-boundary/index.d.ts +2 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/typography/index.d.ts +1 -1
- package/dist/components/waka-autocomplete/index.d.ts +59 -0
- package/dist/components/waka-charts/WakaAreaChart.d.ts +12 -0
- package/dist/components/waka-charts/WakaBarChart.d.ts +12 -0
- package/dist/components/waka-charts/WakaChart.d.ts +17 -0
- package/dist/components/waka-charts/WakaLineChart.d.ts +12 -0
- package/dist/components/waka-charts/WakaMiniChart.d.ts +13 -0
- package/dist/components/waka-charts/WakaPieChart.d.ts +12 -0
- package/dist/components/waka-charts/WakaSparkline.d.ts +13 -0
- package/dist/components/waka-charts/dataTableHelpers.d.ts +34 -0
- package/dist/components/waka-charts/hooks/useChartTheme.d.ts +23 -0
- package/dist/components/waka-charts/hooks/useRechartsLoader.d.ts +161 -0
- package/dist/components/waka-charts/index.d.ts +57 -0
- package/dist/components/waka-charts/types.d.ts +298 -0
- package/dist/components/waka-color-picker/index.d.ts +40 -0
- package/dist/components/waka-file-upload/index.d.ts +49 -0
- package/dist/components/waka-rich-text-editor/index.d.ts +36 -0
- package/dist/context/admincrumb-context.d.ts +118 -1
- package/dist/context/language-context.d.ts +160 -22
- package/dist/context/theme-provider.d.ts +39 -1
- package/dist/context/waka-provider.d.ts +50 -7
- package/dist/hooks/use-toast.d.ts +116 -0
- package/dist/hooks/use-translation.d.ts +24 -1
- package/dist/hooks/useToast.d.ts +82 -0
- package/dist/index.cjs.js +32 -26
- package/dist/index.d.ts +35 -3
- package/dist/index.es.js +11538 -5687
- package/dist/types/provider.d.ts +30 -0
- package/dist/ui.css +1 -1
- package/dist/utils/cn.d.ts +15 -1
- package/dist/utils/datetime-helpers.d.ts +241 -33
- package/dist/utils/error-handling.d.ts +190 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/logger.d.ts +60 -0
- package/dist/utils/theme-loader.d.ts +140 -30
- package/dist/utils/tweak.d.ts +14 -1
- package/package.json +57 -39
- package/src/styles/datepicker.css +9 -2
- package/src/styles/globals.css +4 -4
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatters utilitaires pour le DataTable
|
|
3
|
+
* @module formatters
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Formate une date
|
|
7
|
+
* @param value - Valeur à formater (Date, string ISO, timestamp)
|
|
8
|
+
* @param formatStr - Format de sortie (default: 'PP' = 16 déc. 2025)
|
|
9
|
+
* @param locale - Locale (default: 'fr')
|
|
10
|
+
* @returns Date formatée ou chaîne vide
|
|
11
|
+
* @example formatters.date(new Date(), 'PP', 'fr') // "16 déc. 2025"
|
|
12
|
+
*/
|
|
13
|
+
export declare function date(value: unknown, formatStr?: string, locale?: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Formate une date avec heure
|
|
16
|
+
* @param value - Valeur à formater
|
|
17
|
+
* @param formatStr - Format de sortie (default: 'PPpp')
|
|
18
|
+
* @param locale - Locale
|
|
19
|
+
* @returns Date/heure formatée
|
|
20
|
+
* @example formatters.datetime(new Date()) // "16 déc. 2025, 14:30"
|
|
21
|
+
*/
|
|
22
|
+
export declare function datetime(value: unknown, formatStr?: string, locale?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Formate une heure
|
|
25
|
+
* @param value - Valeur à formater
|
|
26
|
+
* @param formatStr - Format de sortie (default: 'HH:mm')
|
|
27
|
+
* @param locale - Locale
|
|
28
|
+
* @returns Heure formatée
|
|
29
|
+
* @example formatters.time(new Date()) // "14:30"
|
|
30
|
+
*/
|
|
31
|
+
export declare function time(value: unknown, formatStr?: string, locale?: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Formate une valeur monétaire
|
|
34
|
+
* @param value - Valeur numérique
|
|
35
|
+
* @param currencyCode - Code devise (default: 'EUR')
|
|
36
|
+
* @param locale - Locale (default: 'fr-FR')
|
|
37
|
+
* @param options - Options Intl.NumberFormat additionnelles
|
|
38
|
+
* @returns Valeur formatée
|
|
39
|
+
* @example formatters.currency(1234.56, 'EUR', 'fr-FR') // "1 234,56 €"
|
|
40
|
+
*/
|
|
41
|
+
export declare function currency(value: unknown, currencyCode?: string, locale?: string, options?: Partial<Intl.NumberFormatOptions>): string;
|
|
42
|
+
/**
|
|
43
|
+
* Formate un pourcentage
|
|
44
|
+
* @param value - Valeur (0-100 ou 0-1)
|
|
45
|
+
* @param decimals - Nombre de décimales (default: 0)
|
|
46
|
+
* @param isDecimal - Si true, value est entre 0 et 1
|
|
47
|
+
* @returns Pourcentage formaté
|
|
48
|
+
* @example formatters.percentage(42.5) // "42.5%"
|
|
49
|
+
* @example formatters.percentage(0.425, 1, true) // "42.5%"
|
|
50
|
+
*/
|
|
51
|
+
export declare function percentage(value: unknown, decimals?: number, isDecimal?: boolean): string;
|
|
52
|
+
/**
|
|
53
|
+
* Formate un nombre
|
|
54
|
+
* @param value - Valeur numérique
|
|
55
|
+
* @param locale - Locale (default: 'fr-FR')
|
|
56
|
+
* @param options - Options Intl.NumberFormat
|
|
57
|
+
* @returns Nombre formaté
|
|
58
|
+
* @example formatters.number(1234567.89, 'fr-FR') // "1 234 567,89"
|
|
59
|
+
*/
|
|
60
|
+
export declare function number(value: unknown, locale?: string, options?: Intl.NumberFormatOptions): string;
|
|
61
|
+
/**
|
|
62
|
+
* Formate un numéro de téléphone
|
|
63
|
+
* @param value - Numéro de téléphone
|
|
64
|
+
* @param countryCode - Code pays (default: 'FR')
|
|
65
|
+
* @returns Numéro formaté
|
|
66
|
+
* @example formatters.phone('+33612345678') // "+33 6 12 34 56 78"
|
|
67
|
+
* @example formatters.phone('0612345678', 'FR') // "06 12 34 56 78"
|
|
68
|
+
*/
|
|
69
|
+
export declare function phone(value: unknown, countryCode?: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Formate une taille en bytes
|
|
72
|
+
* @param value - Taille en bytes
|
|
73
|
+
* @param decimals - Nombre de décimales (default: 2)
|
|
74
|
+
* @returns Taille formatée (KB, MB, GB, etc.)
|
|
75
|
+
* @example formatters.bytes(1048576) // "1 MB"
|
|
76
|
+
* @example formatters.bytes(1536, 1) // "1.5 KB"
|
|
77
|
+
*/
|
|
78
|
+
export declare function bytes(value: unknown, decimals?: number): string;
|
|
79
|
+
/**
|
|
80
|
+
* Formate un texte tronqué
|
|
81
|
+
* @param value - Texte
|
|
82
|
+
* @param maxLength - Longueur max (default: 50)
|
|
83
|
+
* @param suffix - Suffixe de troncature (default: '...')
|
|
84
|
+
* @returns Texte tronqué
|
|
85
|
+
*/
|
|
86
|
+
export declare function truncate(value: unknown, maxLength?: number, suffix?: string): string;
|
|
87
|
+
/**
|
|
88
|
+
* Récupère les initiales d'un nom
|
|
89
|
+
* @param value - Nom complet
|
|
90
|
+
* @param maxInitials - Nombre max d'initiales (default: 2)
|
|
91
|
+
* @returns Initiales
|
|
92
|
+
* @example formatters.initials("Jean Dupont") // "JD"
|
|
93
|
+
*/
|
|
94
|
+
export declare function initials(value: unknown, maxInitials?: number): string;
|
|
95
|
+
/**
|
|
96
|
+
* Formate un booléen
|
|
97
|
+
* @param value - Valeur booléenne
|
|
98
|
+
* @param trueLabel - Label pour true (default: 'Oui')
|
|
99
|
+
* @param falseLabel - Label pour false (default: 'Non')
|
|
100
|
+
* @returns Label correspondant
|
|
101
|
+
*/
|
|
102
|
+
export declare function boolean(value: unknown, trueLabel?: string, falseLabel?: string): string;
|
|
103
|
+
/**
|
|
104
|
+
* Formate du JSON
|
|
105
|
+
* @param value - Valeur à sérialiser
|
|
106
|
+
* @param indent - Indentation (default: 2)
|
|
107
|
+
* @returns JSON formaté
|
|
108
|
+
*/
|
|
109
|
+
export declare function json(value: unknown, indent?: number): string;
|
|
110
|
+
/**
|
|
111
|
+
* Objet contenant tous les formatters
|
|
112
|
+
*/
|
|
113
|
+
export declare const formatters: {
|
|
114
|
+
date: typeof date;
|
|
115
|
+
datetime: typeof datetime;
|
|
116
|
+
time: typeof time;
|
|
117
|
+
currency: typeof currency;
|
|
118
|
+
percentage: typeof percentage;
|
|
119
|
+
number: typeof number;
|
|
120
|
+
phone: typeof phone;
|
|
121
|
+
bytes: typeof bytes;
|
|
122
|
+
truncate: typeof truncate;
|
|
123
|
+
initials: typeof initials;
|
|
124
|
+
boolean: typeof boolean;
|
|
125
|
+
json: typeof json;
|
|
126
|
+
};
|
|
127
|
+
export default formatters;
|
|
@@ -3,7 +3,7 @@ import { DataTableProps } from '../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Hook principal pour gérer l'état et la logique du DataTable
|
|
5
5
|
*/
|
|
6
|
-
export declare function useDataTable<TData
|
|
6
|
+
export declare function useDataTable<TData extends Record<string, unknown>>({ data, columns, pagination: paginationConfig, tableId, onSortingChange, onFiltersChange, onSelectionChange, }: Pick<DataTableProps<TData>, "data" | "columns" | "pagination" | "tableId" | "onSortingChange" | "onFiltersChange" | "onSelectionChange">): {
|
|
7
7
|
table: import('@tanstack/react-table').Table<TData>;
|
|
8
8
|
sorting: SortingState;
|
|
9
9
|
setSorting: import('react').Dispatch<import('react').SetStateAction<SortingState>>;
|
|
@@ -3,8 +3,8 @@ import { DataTableProps } from '../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Hook avancé pour gérer toutes les fonctionnalités du DataTable
|
|
5
5
|
*/
|
|
6
|
-
export declare function useDataTableAdvanced<TData
|
|
7
|
-
table: import('@tanstack/react-table').Table<
|
|
6
|
+
export declare function useDataTableAdvanced<TData extends Record<string, unknown>>({ data, columns, pagination: paginationConfig, tableId, onSortingChange, onFiltersChange, onSelectionChange, onColumnOrderChange, onExpandedChange, onGroupingChange, grouping, virtualization, sortMode, performance, }: Pick<DataTableProps<TData>, "data" | "columns" | "pagination" | "tableId" | "onSortingChange" | "onFiltersChange" | "onSelectionChange" | "onColumnOrderChange" | "onExpandedChange" | "onGroupingChange" | "grouping" | "virtualization" | "sortMode" | "performance">): {
|
|
7
|
+
table: import('@tanstack/react-table').Table<any>;
|
|
8
8
|
sorting: SortingState;
|
|
9
9
|
setSorting: import('react').Dispatch<import('react').SetStateAction<SortingState>>;
|
|
10
10
|
columnFilters: ColumnFiltersState;
|
|
@@ -23,13 +23,13 @@ export declare function useDataTableAdvanced<TData>({ data, columns, pagination:
|
|
|
23
23
|
setGlobalFilter: import('react').Dispatch<import('react').SetStateAction<string>>;
|
|
24
24
|
pagination: PaginationState;
|
|
25
25
|
setPagination: import('react').Dispatch<import('react').SetStateAction<PaginationState>>;
|
|
26
|
-
selectedRows:
|
|
26
|
+
selectedRows: any[];
|
|
27
27
|
resetFilters: () => void;
|
|
28
28
|
resetSelection: () => void;
|
|
29
29
|
resetAll: () => void;
|
|
30
|
-
exportData: () =>
|
|
31
|
-
getGroupedData: () =>
|
|
32
|
-
getExpandedData: () =>
|
|
30
|
+
exportData: () => any[];
|
|
31
|
+
getGroupedData: () => any[];
|
|
32
|
+
getExpandedData: () => any[];
|
|
33
33
|
toggleGrouping: (columnId: string) => void;
|
|
34
34
|
clearGrouping: () => void;
|
|
35
35
|
toggleRowExpansion: (rowId: string) => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FilterOperator, FilterColumnType, AdvancedFiltersConfig, AdvancedFiltersResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Opérateurs par type de colonne
|
|
4
|
+
*/
|
|
5
|
+
declare const OPERATORS_BY_TYPE: Record<FilterColumnType, FilterOperator[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Labels des opérateurs pour l'affichage
|
|
8
|
+
*/
|
|
9
|
+
export declare const OPERATOR_LABELS: Record<FilterOperator, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Hook pour gérer les filtres avancés du DataTable
|
|
12
|
+
*/
|
|
13
|
+
export declare function useDataTableAdvancedFilters<TData extends Record<string, unknown>>({ data, config, }: {
|
|
14
|
+
data: TData[];
|
|
15
|
+
config: AdvancedFiltersConfig<TData>;
|
|
16
|
+
}): AdvancedFiltersResult<TData>;
|
|
17
|
+
export { OPERATORS_BY_TYPE };
|
|
18
|
+
export default useDataTableAdvancedFilters;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ColumnTemplatesConfig, ColumnTemplatesResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook pour créer des colonnes DataTable à partir de templates prédéfinis
|
|
4
|
+
*
|
|
5
|
+
* @template TData - Type des données de la table
|
|
6
|
+
* @param config - Configuration des templates (locale, currency, etc.)
|
|
7
|
+
* @returns Fonctions pour créer des colonnes et accéder aux formatters
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const { createColumns, getFormatter } = useDataTableColumnTemplates({
|
|
12
|
+
* locale: 'fr-FR',
|
|
13
|
+
* currency: 'EUR',
|
|
14
|
+
* })
|
|
15
|
+
*
|
|
16
|
+
* const columns = createColumns<User>([
|
|
17
|
+
* { accessorKey: 'email', template: 'email' },
|
|
18
|
+
* { accessorKey: 'salary', template: 'currency' },
|
|
19
|
+
* { accessorKey: 'status', template: 'status', options: {
|
|
20
|
+
* templateOptions: {
|
|
21
|
+
* statusColors: { active: 'bg-green-100 text-green-800' }
|
|
22
|
+
* }
|
|
23
|
+
* }},
|
|
24
|
+
* ])
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useDataTableColumnTemplates<TData extends Record<string, unknown>>(config?: ColumnTemplatesConfig): ColumnTemplatesResult<TData>;
|
|
28
|
+
export default useDataTableColumnTemplates;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
1
2
|
import { ExportConfig } from '../types';
|
|
3
|
+
import { WakaError } from '../../../utils/error-handling';
|
|
2
4
|
/**
|
|
3
5
|
* Hook pour gérer l'export des données du DataTable
|
|
6
|
+
* @template TData - Type des données de la table
|
|
4
7
|
*/
|
|
5
|
-
export declare function useDataTableExport<TData
|
|
8
|
+
export declare function useDataTableExport<TData extends Record<string, unknown>>({ data, columns, exportConfig, onError, }: {
|
|
6
9
|
data: TData[];
|
|
7
|
-
columns:
|
|
8
|
-
exportConfig?: ExportConfig
|
|
10
|
+
columns: ColumnDef<TData, unknown>[];
|
|
11
|
+
exportConfig?: ExportConfig<TData>;
|
|
12
|
+
onError?: (error: WakaError) => void;
|
|
9
13
|
}): {
|
|
10
14
|
exportData: (format: string, customData?: TData[], customFilename?: string) => Promise<void>;
|
|
11
15
|
exportAll: (format: string) => Promise<void>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ImportConfig } from '../types';
|
|
2
|
+
import { WakaError } from '../../../utils/error-handling';
|
|
2
3
|
/**
|
|
3
4
|
* Hook pour gérer l'import des données dans le DataTable
|
|
4
5
|
*/
|
|
5
|
-
export declare function useDataTableImport<TData>({ importConfig, }: {
|
|
6
|
-
importConfig?: ImportConfig
|
|
6
|
+
export declare function useDataTableImport<TData>({ importConfig, onError, }: {
|
|
7
|
+
importConfig?: ImportConfig<TData>;
|
|
8
|
+
onError?: (error: WakaError) => void;
|
|
7
9
|
}): {
|
|
8
10
|
importData: (file: File) => Promise<TData[]>;
|
|
9
11
|
importWithUI: () => Promise<TData[]>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { SyncQueueItem, ConflictEntry } from '../services/IndexedDBService';
|
|
2
|
+
export type ConflictResolution = "client-wins" | "server-wins" | "latest-wins" | "manual";
|
|
3
|
+
export interface SyncResult<TData> {
|
|
4
|
+
id: string;
|
|
5
|
+
success: boolean;
|
|
6
|
+
data?: Partial<TData>;
|
|
7
|
+
error?: string;
|
|
8
|
+
serverData?: Partial<TData>;
|
|
9
|
+
serverTimestamp?: Date;
|
|
10
|
+
}
|
|
11
|
+
export interface OfflineConfig<TData> {
|
|
12
|
+
/** ID unique de la table pour le stockage */
|
|
13
|
+
tableId: string;
|
|
14
|
+
/** Activer le mode offline */
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
/** Stratégie de résolution des conflits */
|
|
17
|
+
conflictResolution?: ConflictResolution;
|
|
18
|
+
/** Callback de synchronisation vers le serveur */
|
|
19
|
+
onSync?: (changes: SyncQueueItem<TData>[]) => Promise<SyncResult<TData>[]>;
|
|
20
|
+
/** Intervalle de synchronisation automatique (ms) */
|
|
21
|
+
autoSyncInterval?: number;
|
|
22
|
+
/** Taille max du cache (nombre d'entrées) */
|
|
23
|
+
maxCacheSize?: number;
|
|
24
|
+
/** Durée d'expiration du cache (ms) */
|
|
25
|
+
cacheExpiration?: number;
|
|
26
|
+
/** Callback quand le statut online change */
|
|
27
|
+
onOnlineStatusChange?: (isOnline: boolean) => void;
|
|
28
|
+
/** Callback après synchronisation */
|
|
29
|
+
onSyncComplete?: (results: SyncResult<TData>[]) => void;
|
|
30
|
+
/** Callback sur conflit */
|
|
31
|
+
onConflict?: (conflict: ConflictEntry<TData>) => void;
|
|
32
|
+
}
|
|
33
|
+
export interface OfflineState<TData> {
|
|
34
|
+
/** Connexion internet disponible */
|
|
35
|
+
isOnline: boolean;
|
|
36
|
+
/** Synchronisation en cours */
|
|
37
|
+
isSyncing: boolean;
|
|
38
|
+
/** Nombre de changements en attente */
|
|
39
|
+
pendingChangesCount: number;
|
|
40
|
+
/** Données en cache */
|
|
41
|
+
cachedData: TData[] | null;
|
|
42
|
+
/** Timestamp du dernier cache */
|
|
43
|
+
lastCacheUpdate: Date | null;
|
|
44
|
+
/** Conflits à résoudre */
|
|
45
|
+
conflicts: ConflictEntry<TData>[];
|
|
46
|
+
/** Erreur de synchronisation */
|
|
47
|
+
syncError: string | null;
|
|
48
|
+
/** Dernière synchronisation réussie */
|
|
49
|
+
lastSyncTime: Date | null;
|
|
50
|
+
/** IndexedDB disponible */
|
|
51
|
+
isAvailable: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface OfflineActions<TData> {
|
|
54
|
+
/** Cache les données */
|
|
55
|
+
cacheData: (data: TData[]) => Promise<void>;
|
|
56
|
+
/** Ajoute un changement à la queue */
|
|
57
|
+
queueChange: (change: {
|
|
58
|
+
rowId: string;
|
|
59
|
+
type: SyncQueueItem<TData>["type"];
|
|
60
|
+
data: Partial<TData> | null;
|
|
61
|
+
}) => Promise<void>;
|
|
62
|
+
/** Lance la synchronisation */
|
|
63
|
+
sync: () => Promise<void>;
|
|
64
|
+
/** Résout un conflit */
|
|
65
|
+
resolveConflict: (conflictId: string, resolution: "local" | "server" | "merge", mergedData?: Partial<TData>) => Promise<void>;
|
|
66
|
+
/** Récupère les données du cache */
|
|
67
|
+
loadFromCache: () => Promise<TData[] | null>;
|
|
68
|
+
/** Vide le cache */
|
|
69
|
+
clearCache: () => Promise<void>;
|
|
70
|
+
/** Vide la queue de synchronisation */
|
|
71
|
+
clearQueue: () => Promise<void>;
|
|
72
|
+
/** Force le rafraîchissement de l'état */
|
|
73
|
+
refresh: () => Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
export type UseDataTableOfflineResult<TData> = [OfflineState<TData>, OfflineActions<TData>];
|
|
76
|
+
/**
|
|
77
|
+
* Hook pour gérer le mode offline du DataTable
|
|
78
|
+
*/
|
|
79
|
+
export declare function useDataTableOffline<TData extends Record<string, unknown>>(config: OfflineConfig<TData>): UseDataTableOfflineResult<TData>;
|
|
80
|
+
export default useDataTableOffline;
|
|
@@ -2,7 +2,7 @@ import { VirtualizationConfig } from '../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Hook pour gérer la virtualisation du DataTable
|
|
4
4
|
*/
|
|
5
|
-
export declare function useDataTableVirtualization<TData
|
|
5
|
+
export declare function useDataTableVirtualization<TData extends Record<string, unknown>>({ data, virtualization, containerRef, }: {
|
|
6
6
|
data: TData[];
|
|
7
7
|
virtualization?: VirtualizationConfig;
|
|
8
8
|
containerRef: React.RefObject<HTMLElement>;
|
|
@@ -6,13 +6,38 @@
|
|
|
6
6
|
* Composant de table de données hautement configurable avec support de :
|
|
7
7
|
* - Tri, filtrage, pagination
|
|
8
8
|
* - Sélection multiple
|
|
9
|
-
* - Export/Import (CSV, JSON)
|
|
9
|
+
* - Export/Import (CSV, JSON, XLSX)
|
|
10
10
|
* - Layouts multiples (standard, card, compact, split, infinite)
|
|
11
11
|
* - Thème clair/sombre via TweakCN
|
|
12
12
|
* - i18n complet
|
|
13
13
|
* - Virtualisation pour grandes données
|
|
14
14
|
* - Toolbar customisable
|
|
15
15
|
* - Actions par ligne et groupées
|
|
16
|
+
* - Édition inline
|
|
17
|
+
* - Groupement avec agrégations
|
|
18
|
+
* - Redimensionnement des colonnes
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import {
|
|
23
|
+
* DataTableAdvanced,
|
|
24
|
+
* useDataTableAdvanced,
|
|
25
|
+
* type DataTableProps,
|
|
26
|
+
* type ColumnDef
|
|
27
|
+
* } from '@wakastellar/ui'
|
|
28
|
+
*
|
|
29
|
+
* const columns: ColumnDef<User>[] = [
|
|
30
|
+
* { accessorKey: 'name', header: 'Name' },
|
|
31
|
+
* { accessorKey: 'email', header: 'Email' },
|
|
32
|
+
* ]
|
|
33
|
+
*
|
|
34
|
+
* <DataTableAdvanced
|
|
35
|
+
* data={users}
|
|
36
|
+
* columns={columns}
|
|
37
|
+
* selection="multiple"
|
|
38
|
+
* enableExport={{ formats: ['csv', 'xlsx'] }}
|
|
39
|
+
* />
|
|
40
|
+
* ```
|
|
16
41
|
*/
|
|
17
42
|
export { DataTable } from './DataTable';
|
|
18
43
|
export { DataTableAdvanced } from './DataTableAdvanced';
|
|
@@ -24,6 +49,14 @@ export { DataTableColumnResizer } from './DataTableColumnResizer';
|
|
|
24
49
|
export { DataTableGrouping, DataTableGroupTotals, DataTableGroupingControls } from './DataTableGrouping';
|
|
25
50
|
export { DataTableContextMenu } from './DataTableContextMenu';
|
|
26
51
|
export { DataTableSelection, useDataTableSelection } from './DataTableSelection';
|
|
52
|
+
export { DataTableCell } from './DataTableCell';
|
|
53
|
+
export type { DataTableCellProps } from './DataTableCell';
|
|
54
|
+
export { DataTableHeader, DataTableHeaderRow } from './DataTableHeader';
|
|
55
|
+
export type { DataTableHeaderProps } from './DataTableHeader';
|
|
56
|
+
export { DataTableBody, DataTableBodyRow } from './DataTableBody';
|
|
57
|
+
export type { DataTableBodyProps } from './DataTableBody';
|
|
58
|
+
export { DataTableRow } from './DataTableRow';
|
|
59
|
+
export { DataTableGroupRow } from './DataTableGroupRow';
|
|
27
60
|
export { useDataTable } from './hooks/useDataTable';
|
|
28
61
|
export { useDataTableAdvanced } from './hooks/useDataTableAdvanced';
|
|
29
62
|
export { useDataTableVirtualization } from './hooks/useDataTableVirtualization';
|
|
@@ -32,6 +65,19 @@ export { useDataTableImport } from './hooks/useDataTableImport';
|
|
|
32
65
|
export { useDataTableTheme } from './hooks/useDataTableTheme';
|
|
33
66
|
export { useTableLayout } from './hooks/useTableLayout';
|
|
34
67
|
export { useDataTableEdit } from './hooks/useDataTableEdit';
|
|
35
|
-
export
|
|
68
|
+
export { useDataTableColumnTemplates } from './hooks/useDataTableColumnTemplates';
|
|
69
|
+
export { useDataTableAdvancedFilters, OPERATORS_BY_TYPE, OPERATOR_LABELS } from './hooks/useDataTableAdvancedFilters';
|
|
70
|
+
export { useDataTableOffline } from './hooks/useDataTableOffline';
|
|
71
|
+
export type { OfflineConfig, OfflineState, OfflineActions, SyncResult, ConflictResolution, UseDataTableOfflineResult, } from './hooks/useDataTableOffline';
|
|
72
|
+
export { DataTableFilterBuilder } from './DataTableFilterBuilder';
|
|
73
|
+
export { DataTableSyncStatus } from './DataTableSyncStatus';
|
|
74
|
+
export type { DataTableSyncStatusProps } from './DataTableSyncStatus';
|
|
75
|
+
export { DataTableConflictResolver } from './DataTableConflictResolver';
|
|
76
|
+
export type { DataTableConflictResolverProps } from './DataTableConflictResolver';
|
|
77
|
+
export { IndexedDBService, getIndexedDBService } from './services/IndexedDBService';
|
|
78
|
+
export type { CacheEntry, SyncQueueItem, ConflictEntry, } from './services/IndexedDBService';
|
|
79
|
+
export { formatters } from './formatters';
|
|
80
|
+
export { templatesMap, getTemplate, availableTemplateNames, createActionsTemplate, dateTemplate, datetimeTemplate, timeTemplate, currencyTemplate, percentageTemplate, numberTemplate, statusTemplate, badgeTemplate, emailTemplate, phoneTemplate, urlTemplate, avatarTemplate, booleanTemplate, actionsTemplate, indexTemplate, idTemplate, ratingTemplate, progressTemplate, tagsTemplate, jsonTemplate, textTemplate, } from './templates';
|
|
81
|
+
export type { DataTableProps, DataTableLayout, DataTableVariant, DataTableDensity, DataTableState, FilterConfig, FilterPosition, FilterValue, PaginationConfig, ToolbarConfig, TableAction, ExportConfig, ImportConfig, SelectionState, EditConfig, ColumnEditConfig, EditableCellValue, SelectionMode, SortMode, VirtualizationType, GroupingConfig, VirtualizationConfig, ColumnResizeConfig, ColumnOrderConfig, RowExpansionConfig, DataTableTheme, RangeValue, DateRangeValue, AggregatedValue, ExportableCellValue, ImportedRowData, TypographyConfig, ColumnTemplateName, FormatterType, ColumnTemplateAction, ColumnTemplateOptions, ColumnTemplateDefinition, ColumnTemplate, ColumnTemplatesConfig, ColumnTemplatesResult, FilterOperator, FilterColumnType, FilterRule, FilterGroup, FilterPreset, FilterableColumn, AdvancedFiltersConfig, AdvancedFiltersState, AdvancedFiltersActions, AdvancedFiltersResult, } from './types';
|
|
36
82
|
export type { EditCellConfig } from './DataTableEditCell';
|
|
37
83
|
export { exportToCSV, exportToJSON, parseCSV, saveTableState, loadTableState, } from './utils';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service IndexedDB pour le mode offline du DataTable
|
|
3
|
+
* Gère le cache des données, la queue de synchronisation et les conflits
|
|
4
|
+
*/
|
|
5
|
+
export interface CacheEntry<TData> {
|
|
6
|
+
id: string;
|
|
7
|
+
tableId: string;
|
|
8
|
+
data: TData[];
|
|
9
|
+
timestamp: Date;
|
|
10
|
+
version: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SyncQueueItem<TData> {
|
|
13
|
+
id: string;
|
|
14
|
+
tableId: string;
|
|
15
|
+
rowId: string;
|
|
16
|
+
type: "create" | "update" | "delete";
|
|
17
|
+
data: Partial<TData> | null;
|
|
18
|
+
timestamp: Date;
|
|
19
|
+
attempts: number;
|
|
20
|
+
lastError?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ConflictEntry<TData> {
|
|
23
|
+
id: string;
|
|
24
|
+
tableId: string;
|
|
25
|
+
rowId: string;
|
|
26
|
+
localData: Partial<TData> | null;
|
|
27
|
+
serverData: Partial<TData> | null;
|
|
28
|
+
localTimestamp: Date;
|
|
29
|
+
serverTimestamp: Date;
|
|
30
|
+
type: "create" | "update" | "delete";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Service pour gérer IndexedDB
|
|
34
|
+
*/
|
|
35
|
+
export declare class IndexedDBService {
|
|
36
|
+
private db;
|
|
37
|
+
private initPromise;
|
|
38
|
+
/**
|
|
39
|
+
* Initialise la connexion à IndexedDB
|
|
40
|
+
*/
|
|
41
|
+
init(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Vérifie si IndexedDB est disponible
|
|
44
|
+
*/
|
|
45
|
+
isAvailable(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Ferme la connexion
|
|
48
|
+
*/
|
|
49
|
+
close(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Sauvegarde les données en cache
|
|
52
|
+
*/
|
|
53
|
+
cacheData<TData>(tableId: string, data: TData[], version?: number): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Récupère les données du cache
|
|
56
|
+
*/
|
|
57
|
+
getCachedData<TData>(tableId: string): Promise<CacheEntry<TData> | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Supprime les données du cache
|
|
60
|
+
*/
|
|
61
|
+
clearCache(tableId: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Supprime les entrées de cache expirées
|
|
64
|
+
*/
|
|
65
|
+
cleanExpiredCache(maxAgeMs: number): Promise<number>;
|
|
66
|
+
/**
|
|
67
|
+
* Ajoute un changement à la queue de synchronisation
|
|
68
|
+
*/
|
|
69
|
+
queueChange<TData>(tableId: string, rowId: string, type: SyncQueueItem<TData>["type"], data: Partial<TData> | null): Promise<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Récupère les changements en attente
|
|
72
|
+
*/
|
|
73
|
+
getPendingChanges<TData>(tableId: string): Promise<SyncQueueItem<TData>[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Compte les changements en attente
|
|
76
|
+
*/
|
|
77
|
+
countPendingChanges(tableId: string): Promise<number>;
|
|
78
|
+
/**
|
|
79
|
+
* Marque un changement comme traité (le supprime)
|
|
80
|
+
*/
|
|
81
|
+
removeFromQueue(id: string): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Met à jour le nombre de tentatives d'un changement
|
|
84
|
+
*/
|
|
85
|
+
updateAttempts<TData>(id: string, error?: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Vide la queue de synchronisation
|
|
88
|
+
*/
|
|
89
|
+
clearQueue(tableId: string): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Ajoute un conflit
|
|
92
|
+
*/
|
|
93
|
+
addConflict<TData>(conflict: Omit<ConflictEntry<TData>, "id">): Promise<string>;
|
|
94
|
+
/**
|
|
95
|
+
* Récupère les conflits d'une table
|
|
96
|
+
*/
|
|
97
|
+
getConflicts<TData>(tableId: string): Promise<ConflictEntry<TData>[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Supprime un conflit résolu
|
|
100
|
+
*/
|
|
101
|
+
resolveConflict(id: string): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Vide tous les conflits d'une table
|
|
104
|
+
*/
|
|
105
|
+
clearConflicts(tableId: string): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Obtient des statistiques sur la base de données
|
|
108
|
+
*/
|
|
109
|
+
getStats(tableId: string): Promise<{
|
|
110
|
+
cacheSize: number;
|
|
111
|
+
pendingChanges: number;
|
|
112
|
+
conflicts: number;
|
|
113
|
+
lastCacheUpdate: Date | null;
|
|
114
|
+
}>;
|
|
115
|
+
}
|
|
116
|
+
export declare function getIndexedDBService(): IndexedDBService;
|
|
117
|
+
export default IndexedDBService;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ColumnTemplate } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Template Date
|
|
4
|
+
*/
|
|
5
|
+
export declare const dateTemplate: ColumnTemplate<unknown, unknown>;
|
|
6
|
+
/**
|
|
7
|
+
* Template DateTime
|
|
8
|
+
*/
|
|
9
|
+
export declare const datetimeTemplate: ColumnTemplate<unknown, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Template Time
|
|
12
|
+
*/
|
|
13
|
+
export declare const timeTemplate: ColumnTemplate<unknown, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Template Currency
|
|
16
|
+
*/
|
|
17
|
+
export declare const currencyTemplate: ColumnTemplate<unknown, unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* Template Percentage
|
|
20
|
+
*/
|
|
21
|
+
export declare const percentageTemplate: ColumnTemplate<unknown, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Template Number
|
|
24
|
+
*/
|
|
25
|
+
export declare const numberTemplate: ColumnTemplate<unknown, unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Template Status/Badge
|
|
28
|
+
*/
|
|
29
|
+
export declare const statusTemplate: ColumnTemplate<unknown, unknown>;
|
|
30
|
+
/**
|
|
31
|
+
* Template Badge (alias de status)
|
|
32
|
+
*/
|
|
33
|
+
export declare const badgeTemplate: ColumnTemplate<unknown, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Template Email
|
|
36
|
+
*/
|
|
37
|
+
export declare const emailTemplate: ColumnTemplate<unknown, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Template Phone
|
|
40
|
+
*/
|
|
41
|
+
export declare const phoneTemplate: ColumnTemplate<unknown, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Template URL
|
|
44
|
+
*/
|
|
45
|
+
export declare const urlTemplate: ColumnTemplate<unknown, unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* Template Avatar
|
|
48
|
+
*/
|
|
49
|
+
export declare const avatarTemplate: ColumnTemplate<unknown, unknown>;
|
|
50
|
+
/**
|
|
51
|
+
* Template Boolean
|
|
52
|
+
*/
|
|
53
|
+
export declare const booleanTemplate: ColumnTemplate<unknown, unknown>;
|
|
54
|
+
/**
|
|
55
|
+
* Template Actions
|
|
56
|
+
*/
|
|
57
|
+
export declare function createActionsTemplate<TData>(): ColumnTemplate<TData, unknown>;
|
|
58
|
+
/**
|
|
59
|
+
* Template Actions par défaut
|
|
60
|
+
*/
|
|
61
|
+
export declare const actionsTemplate: ColumnTemplate<unknown, unknown>;
|
|
62
|
+
/**
|
|
63
|
+
* Template Index (numéro de ligne)
|
|
64
|
+
*/
|
|
65
|
+
export declare const indexTemplate: ColumnTemplate<unknown, unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Template ID
|
|
68
|
+
*/
|
|
69
|
+
export declare const idTemplate: ColumnTemplate<unknown, unknown>;
|
|
70
|
+
/**
|
|
71
|
+
* Template Rating (étoiles)
|
|
72
|
+
*/
|
|
73
|
+
export declare const ratingTemplate: ColumnTemplate<unknown, unknown>;
|
|
74
|
+
/**
|
|
75
|
+
* Template Progress
|
|
76
|
+
*/
|
|
77
|
+
export declare const progressTemplate: ColumnTemplate<unknown, unknown>;
|
|
78
|
+
/**
|
|
79
|
+
* Template Tags
|
|
80
|
+
*/
|
|
81
|
+
export declare const tagsTemplate: ColumnTemplate<unknown, unknown>;
|
|
82
|
+
/**
|
|
83
|
+
* Template JSON
|
|
84
|
+
*/
|
|
85
|
+
export declare const jsonTemplate: ColumnTemplate<unknown, unknown>;
|
|
86
|
+
/**
|
|
87
|
+
* Template Text (par défaut)
|
|
88
|
+
*/
|
|
89
|
+
export declare const textTemplate: ColumnTemplate<unknown, unknown>;
|
|
90
|
+
/**
|
|
91
|
+
* Map des templates par nom
|
|
92
|
+
* Note: Les templates sont typés avec `unknown` pour permettre l'accès dynamique par nom.
|
|
93
|
+
* Le typage précis est assuré lors de l'utilisation via useDataTableColumnTemplates.
|
|
94
|
+
*/
|
|
95
|
+
export declare const templatesMap: Record<string, ColumnTemplate<unknown, unknown>>;
|
|
96
|
+
/**
|
|
97
|
+
* Récupère un template par son nom
|
|
98
|
+
*/
|
|
99
|
+
export declare function getTemplate(name: string): ColumnTemplate<unknown, unknown> | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Liste des noms de templates disponibles
|
|
102
|
+
*/
|
|
103
|
+
export declare const availableTemplateNames: string[];
|
|
104
|
+
export default templatesMap;
|