@wakastellar/ui 1.0.2 → 1.0.4

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@wakastellar/ui",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "UI Library compatible TweakCN + i18n pour Next.js",
5
5
  "keywords": [
6
6
  "ui",
@@ -77,7 +77,33 @@
77
77
  "react-hook-form": "^7.0.0",
78
78
  "xlsx": "*",
79
79
  "jspdf": "*",
80
- "jspdf-autotable": "*"
80
+ "jspdf-autotable": "*",
81
+ "recharts": "^2.0.0",
82
+ "@tiptap/react": "^2.0.0 || ^3.0.0",
83
+ "@tiptap/starter-kit": "^2.0.0 || ^3.0.0",
84
+ "@tiptap/extension-link": "^2.0.0 || ^3.0.0",
85
+ "@tiptap/extension-text-align": "^2.0.0 || ^3.0.0",
86
+ "@tiptap/extension-underline": "^2.0.0 || ^3.0.0"
87
+ },
88
+ "peerDependenciesMeta": {
89
+ "recharts": {
90
+ "optional": true
91
+ },
92
+ "@tiptap/react": {
93
+ "optional": true
94
+ },
95
+ "@tiptap/starter-kit": {
96
+ "optional": true
97
+ },
98
+ "@tiptap/extension-link": {
99
+ "optional": true
100
+ },
101
+ "@tiptap/extension-text-align": {
102
+ "optional": true
103
+ },
104
+ "@tiptap/extension-underline": {
105
+ "optional": true
106
+ }
81
107
  },
82
108
  "devDependencies": {
83
109
  "@chromatic-com/storybook": "^4.1.1",
@@ -1,86 +0,0 @@
1
- import * as React from "react";
2
- export interface ThemeBlockColors {
3
- background: string;
4
- foreground: string;
5
- card: string;
6
- cardForeground: string;
7
- popover: string;
8
- popoverForeground: string;
9
- primary: string;
10
- primaryForeground: string;
11
- secondary: string;
12
- secondaryForeground: string;
13
- muted: string;
14
- mutedForeground: string;
15
- accent: string;
16
- accentForeground: string;
17
- destructive: string;
18
- destructiveForeground: string;
19
- border: string;
20
- input: string;
21
- ring: string;
22
- chart1: string;
23
- chart2: string;
24
- chart3: string;
25
- chart4: string;
26
- chart5: string;
27
- sidebarBackground?: string;
28
- sidebarForeground?: string;
29
- sidebarPrimary?: string;
30
- sidebarPrimaryForeground?: string;
31
- sidebarAccent?: string;
32
- sidebarAccentForeground?: string;
33
- sidebarBorder?: string;
34
- sidebarRing?: string;
35
- }
36
- export interface ThemeBlockAssets {
37
- logoLight?: string;
38
- logoDark?: string;
39
- backgroundLight?: string;
40
- backgroundDark?: string;
41
- favicon?: string;
42
- sponsorLight?: string;
43
- sponsorDark?: string;
44
- }
45
- export interface ThemeCreatorBlockTheme {
46
- id: string;
47
- name: string;
48
- description?: string;
49
- author?: string;
50
- lightColors: ThemeBlockColors;
51
- darkColors: ThemeBlockColors;
52
- assets?: ThemeBlockAssets;
53
- radius?: string;
54
- fonts?: {
55
- sans?: string;
56
- mono?: string;
57
- };
58
- }
59
- export interface ThemeColorGroup {
60
- id: string;
61
- label: string;
62
- icon?: React.ReactNode;
63
- colors: {
64
- key: keyof ThemeBlockColors;
65
- label: string;
66
- description?: string;
67
- }[];
68
- }
69
- export interface WakaThemeCreatorBlockProps {
70
- themes?: ThemeCreatorBlockTheme[];
71
- initialTheme?: ThemeCreatorBlockTheme;
72
- onThemeChange?: (theme: ThemeCreatorBlockTheme) => void;
73
- onSave?: (theme: ThemeCreatorBlockTheme) => Promise<void>;
74
- onUploadAsset?: (file: File, assetType: keyof ThemeBlockAssets) => Promise<string>;
75
- onExport?: (theme: ThemeCreatorBlockTheme, format: 'json' | 'css') => void;
76
- showTypography?: boolean;
77
- showSidebarColors?: boolean;
78
- previewTabs?: ('login' | 'dashboard' | 'chat')[];
79
- customPreview?: React.ReactNode;
80
- className?: string;
81
- }
82
- export declare const defaultThemes: ThemeCreatorBlockTheme[];
83
- export declare function WakaThemeCreatorBlock({ themes, initialTheme, onThemeChange, onSave, onUploadAsset, showSidebarColors, previewTabs, className, }: WakaThemeCreatorBlockProps): import("react/jsx-runtime").JSX.Element;
84
- export declare namespace WakaThemeCreatorBlock {
85
- var displayName: string;
86
- }
@@ -1,70 +0,0 @@
1
- import { Table, Row } from '@tanstack/react-table';
2
- import { ColumnEditConfig, EditableCellValue, RowExpansionConfig } from './types';
3
- /**
4
- * Props pour le composant DataTableBody
5
- */
6
- export interface DataTableBodyProps<TData extends Record<string, unknown>> {
7
- /** Instance de la table TanStack */
8
- table: Table<TData>;
9
- /** Configuration d'expansion des lignes */
10
- rowExpansion?: RowExpansionConfig<TData>;
11
- /** Classes CSS pour la densité */
12
- densityClasses?: {
13
- header?: string;
14
- table?: string;
15
- cell?: string;
16
- };
17
- /** Callback de clic sur ligne */
18
- onRowClick?: (row: TData) => void;
19
- /** Callback de double-clic */
20
- onRowDoubleClick?: (row: TData) => void;
21
- /** ID de la ligne en cours d'édition */
22
- editingRowId?: string | null;
23
- /** Configuration d'édition des colonnes */
24
- editableColumns?: ColumnEditConfig<TData>[];
25
- /** Callback pour mettre à jour un champ */
26
- onUpdateField?: (field: keyof TData, value: EditableCellValue) => void;
27
- /** Callback pour démarrer l'édition */
28
- onStartEdit?: (rowId: string, originalData: TData) => void;
29
- /** Callback pour sauvegarder */
30
- onSaveEdit?: () => void;
31
- /** Callback pour annuler */
32
- onCancelEdit?: () => void;
33
- }
34
- /**
35
- * Composant Body réutilisable pour DataTable
36
- *
37
- * Gère :
38
- * - Le rendu des lignes
39
- * - L'expansion des lignes
40
- * - Le groupement
41
- * - L'édition inline
42
- */
43
- export declare function DataTableBody<TData extends Record<string, unknown>>({ table, rowExpansion, densityClasses, onRowClick, onRowDoubleClick, editingRowId, editableColumns, onUpdateField, onStartEdit, onSaveEdit, onCancelEdit, }: DataTableBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
44
- /**
45
- * Props pour DataTableBodyRow
46
- */
47
- interface DataTableBodyRowProps<TData extends Record<string, unknown>> {
48
- row: Row<TData>;
49
- rowExpansion?: RowExpansionConfig<TData>;
50
- densityClasses: {
51
- header?: string;
52
- table?: string;
53
- cell?: string;
54
- };
55
- onRowClick?: (row: TData) => void;
56
- onRowDoubleClick?: (row: TData) => void;
57
- editingRowId?: string | null;
58
- editableColumns?: ColumnEditConfig<TData>[];
59
- onUpdateField?: (field: keyof TData, value: EditableCellValue) => void;
60
- onStartEdit?: (rowId: string, originalData: TData) => void;
61
- onSaveEdit?: () => void;
62
- onCancelEdit?: () => void;
63
- }
64
- /**
65
- * Ligne individuelle du body
66
- * Optimisé avec React.memo pour éviter les re-renders inutiles
67
- */
68
- declare function DataTableBodyRowInner<TData extends Record<string, unknown>>({ row, rowExpansion, densityClasses, onRowClick, onRowDoubleClick, editingRowId, editableColumns, onUpdateField, onStartEdit, onSaveEdit, onCancelEdit, }: DataTableBodyRowProps<TData>): import("react/jsx-runtime").JSX.Element;
69
- declare const DataTableBodyRow: typeof DataTableBodyRowInner;
70
- export { DataTableBodyRow };
@@ -1,38 +0,0 @@
1
- import { Cell, Row } from '@tanstack/react-table';
2
- import { ColumnEditConfig, EditableCellValue } from './types';
3
- /**
4
- * Props pour le composant DataTableCell
5
- */
6
- export interface DataTableCellProps<TData extends Record<string, unknown>> {
7
- /** Cellule TanStack Table */
8
- cell: Cell<TData, unknown>;
9
- /** Ligne parente */
10
- row: Row<TData>;
11
- /** ID de la ligne en cours d'édition */
12
- editingRowId?: string | null;
13
- /** Configuration d'édition des colonnes */
14
- editableColumns?: ColumnEditConfig<TData>[];
15
- /** Callback pour mettre à jour un champ */
16
- onUpdateField?: (field: keyof TData, value: EditableCellValue) => void;
17
- /** Callback pour démarrer l'édition */
18
- onStartEdit?: (rowId: string, originalData: TData) => void;
19
- /** Callback pour sauvegarder */
20
- onSaveEdit?: () => void;
21
- /** Callback pour annuler */
22
- onCancelEdit?: () => void;
23
- }
24
- /**
25
- * Composant de cellule réutilisable pour DataTable
26
- *
27
- * Gère tous les types de cellules :
28
- * - Cellules normales
29
- * - Cellules éditables
30
- * - Cellules groupées
31
- * - Cellules agrégées
32
- * - Cellules placeholder
33
- *
34
- * Optimisé avec React.memo pour éviter les re-renders inutiles
35
- */
36
- declare function DataTableCellInner<TData extends Record<string, unknown>>({ cell, row, editingRowId, editableColumns, onUpdateField, onStartEdit, onSaveEdit, onCancelEdit, }: DataTableCellProps<TData>): import("react/jsx-runtime").JSX.Element | null;
37
- export declare const DataTableCell: typeof DataTableCellInner;
38
- export {};
@@ -1,45 +0,0 @@
1
- import { ConflictEntry } from './services/IndexedDBService';
2
- /**
3
- * DataTableConflictResolver - Interface de résolution des conflits
4
- */
5
- import * as React from "react";
6
- export interface DataTableConflictResolverProps<TData> {
7
- /** Liste des conflits */
8
- conflicts: ConflictEntry<TData>[];
9
- /** Callback de résolution */
10
- onResolve: (conflictId: string, resolution: "local" | "server" | "merge", mergedData?: Partial<TData>) => Promise<void>;
11
- /** Ouvert */
12
- open?: boolean;
13
- /** Callback de fermeture */
14
- onOpenChange?: (open: boolean) => void;
15
- /** Afficher en mode sheet (sidebar) ou dialog */
16
- mode?: "dialog" | "sheet";
17
- /** Labels personnalisés */
18
- labels?: {
19
- title?: string;
20
- description?: string;
21
- localVersion?: string;
22
- serverVersion?: string;
23
- keepLocal?: string;
24
- keepServer?: string;
25
- merge?: string;
26
- resolve?: string;
27
- skip?: string;
28
- noConflicts?: string;
29
- conflictType?: Record<"create" | "update" | "delete", string>;
30
- };
31
- /** Fonction de rendu personnalisé pour les données */
32
- renderData?: (data: Partial<TData> | null, type: "local" | "server") => React.ReactNode;
33
- /** Clés à afficher dans la comparaison */
34
- displayKeys?: (keyof TData)[];
35
- /** Labels des clés */
36
- keyLabels?: Record<string, string>;
37
- }
38
- /**
39
- * Interface de résolution des conflits de synchronisation
40
- */
41
- export declare function DataTableConflictResolver<TData extends Record<string, unknown>>({ conflicts, onResolve, open, onOpenChange, mode, labels: customLabels, renderData, displayKeys, keyLabels, }: DataTableConflictResolverProps<TData>): import("react/jsx-runtime").JSX.Element;
42
- export declare namespace DataTableConflictResolver {
43
- var displayName: string;
44
- }
45
- export default DataTableConflictResolver;
@@ -1,14 +0,0 @@
1
- import { FilterOperator, FilterableColumn, AdvancedFiltersState, AdvancedFiltersActions } from './types';
2
- interface DataTableFilterBuilderProps<TData> {
3
- state: AdvancedFiltersState<TData>;
4
- actions: AdvancedFiltersActions<TData>;
5
- columns: FilterableColumn<TData>[];
6
- getOperatorsForColumn: (column: keyof TData | string) => FilterOperator[];
7
- className?: string;
8
- maxNestingDepth?: number;
9
- }
10
- /**
11
- * Composant de construction de filtres avancés
12
- */
13
- export declare function DataTableFilterBuilder<TData>({ state, actions, columns, getOperatorsForColumn, className, maxNestingDepth, }: DataTableFilterBuilderProps<TData>): import("react/jsx-runtime").JSX.Element;
14
- export default DataTableFilterBuilder;
@@ -1,50 +0,0 @@
1
- import { Table, HeaderGroup } from '@tanstack/react-table';
2
- /**
3
- * Props pour le composant DataTableHeader
4
- */
5
- export interface DataTableHeaderProps<TData> {
6
- /** Instance de la table TanStack */
7
- table: Table<TData>;
8
- /** Header sticky */
9
- headerSticky?: boolean;
10
- /** Classes CSS pour la densité */
11
- densityClasses?: {
12
- header?: string;
13
- table?: string;
14
- cell?: string;
15
- };
16
- /** Activer le redimensionnement des colonnes */
17
- enableColumnResize?: boolean;
18
- /** Mode de redimensionnement */
19
- columnResizeMode?: "onChange" | "onEnd";
20
- }
21
- /**
22
- * Composant Header réutilisable pour DataTable
23
- *
24
- * Gère :
25
- * - Le tri des colonnes
26
- * - Le redimensionnement
27
- * - Le sticky header
28
- */
29
- export declare function DataTableHeader<TData>({ table, headerSticky, densityClasses, enableColumnResize, columnResizeMode, }: DataTableHeaderProps<TData>): import("react/jsx-runtime").JSX.Element;
30
- /**
31
- * Props pour DataTableHeaderRow
32
- */
33
- interface DataTableHeaderRowProps<TData> {
34
- headerGroup: HeaderGroup<TData>;
35
- densityClasses: {
36
- header?: string;
37
- table?: string;
38
- cell?: string;
39
- };
40
- enableColumnResize: boolean;
41
- columnResizeMode: "onChange" | "onEnd";
42
- table: Table<TData>;
43
- }
44
- /**
45
- * Ligne d'en-tête individuelle
46
- * Optimisé avec React.memo pour éviter les re-renders inutiles
47
- */
48
- declare function DataTableHeaderRowInner<TData>({ headerGroup, densityClasses, enableColumnResize, columnResizeMode, table, }: DataTableHeaderRowProps<TData>): import("react/jsx-runtime").JSX.Element;
49
- declare const DataTableHeaderRow: typeof DataTableHeaderRowInner;
50
- export { DataTableHeaderRow };
@@ -1,31 +0,0 @@
1
- import { OfflineState } from './hooks/useDataTableOffline';
2
- export interface DataTableSyncStatusProps<TData> {
3
- /** État offline */
4
- state: OfflineState<TData>;
5
- /** Callback de synchronisation */
6
- onSync?: () => void;
7
- /** Afficher les détails */
8
- showDetails?: boolean;
9
- /** Classes CSS additionnelles */
10
- className?: string;
11
- /** Variante d'affichage */
12
- variant?: "default" | "compact" | "badge";
13
- /** Labels personnalisés */
14
- labels?: {
15
- online?: string;
16
- offline?: string;
17
- syncing?: string;
18
- pending?: string;
19
- conflicts?: string;
20
- sync?: string;
21
- lastSync?: string;
22
- };
23
- }
24
- /**
25
- * Indicateur de statut de synchronisation pour le mode offline
26
- */
27
- export declare function DataTableSyncStatus<TData>({ state, onSync, showDetails, className, variant, labels: customLabels, }: DataTableSyncStatusProps<TData>): import("react/jsx-runtime").JSX.Element | null;
28
- export declare namespace DataTableSyncStatus {
29
- var displayName: string;
30
- }
31
- export default DataTableSyncStatus;
@@ -1,127 +0,0 @@
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;
@@ -1,18 +0,0 @@
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;
@@ -1,28 +0,0 @@
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,80 +0,0 @@
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;