@wakastellar/ui 0.1.11 → 0.1.12
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/README.md +403 -199
- package/dist/blocks/sidebar/index.d.ts +3 -1
- package/dist/components/DataTable/DataTableCell.d.ts +5 -1
- package/dist/components/DataTable/DataTableRow.d.ts +3 -1
- package/dist/components/DataTable/hooks/useDataTableExport.d.ts +8 -1
- package/dist/components/DataTable/hooks/useDataTableImport.d.ts +12 -0
- package/dist/components/DataTable/workers/exportWorker.d.ts +29 -0
- package/dist/components/waka-theme-manager/index.d.ts +14 -1
- package/dist/context/index.d.ts +2 -2
- package/dist/context/language-context.d.ts +99 -83
- package/dist/context/theme-context.d.ts +4 -3
- package/dist/context/theme-provider.d.ts +48 -48
- package/dist/index.cjs.js +145 -32
- package/dist/index.d.ts +3 -3
- package/dist/index.es.js +8264 -7885
- package/dist/types/provider.d.ts +33 -32
- package/package.json +1 -1
|
@@ -91,6 +91,8 @@ export interface WakaSidebarProps {
|
|
|
91
91
|
footer?: React.ReactNode;
|
|
92
92
|
/** Header personnalisé (après le logo) */
|
|
93
93
|
header?: React.ReactNode;
|
|
94
|
+
/** Mode de positionnement : "fixed" pour app layout, "relative" pour preview/demo */
|
|
95
|
+
position?: "fixed" | "relative";
|
|
94
96
|
}
|
|
95
97
|
/**
|
|
96
98
|
* WakaSidebar - Sidebar personnalisable avec menu hamburger responsive
|
|
@@ -119,7 +121,7 @@ export interface WakaSidebarProps {
|
|
|
119
121
|
* />
|
|
120
122
|
* ```
|
|
121
123
|
*/
|
|
122
|
-
export declare function WakaSidebar({ logo, menu, user, width, mobileBreakpoint, open, onOpenChange, className, contentClassName, backgroundColor, textColor, activeColor, hoverColor, userPosition, showHamburger, hamburgerPosition, renderItem, footer, header, }: WakaSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
124
|
+
export declare function WakaSidebar({ logo, menu, user, width, mobileBreakpoint, open, onOpenChange, className, contentClassName, backgroundColor, textColor, activeColor, hoverColor, userPosition, showHamburger, hamburgerPosition, renderItem, footer, header, position, }: WakaSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
123
125
|
/**
|
|
124
126
|
* Hook pour gérer l'état de la sidebar externalement
|
|
125
127
|
*/
|
|
@@ -30,5 +30,9 @@ export interface DataTableCellProps<TData extends Record<string, unknown>> {
|
|
|
30
30
|
* - Cellules groupées
|
|
31
31
|
* - Cellules agrégées
|
|
32
32
|
* - Cellules placeholder
|
|
33
|
+
*
|
|
34
|
+
* Optimisé avec React.memo pour éviter les re-renders inutiles
|
|
33
35
|
*/
|
|
34
|
-
|
|
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 {};
|
|
@@ -23,6 +23,8 @@ interface DataTableRowProps<TData> {
|
|
|
23
23
|
* DataTableRow - Composant pour le rendu d'une ligne standard du DataTable
|
|
24
24
|
*
|
|
25
25
|
* Extrait de DataTableAdvanced pour réduire la complexité
|
|
26
|
+
* Optimisé avec React.memo pour éviter les re-renders inutiles
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
declare function DataTableRowInner<TData>({ row, onRowClick, onRowDoubleClick, themeDensityClasses, editState, editActions, edit, }: DataTableRowProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare const DataTableRow: typeof DataTableRowInner;
|
|
28
30
|
export {};
|
|
@@ -3,6 +3,10 @@ import { ExportConfig } from '../types';
|
|
|
3
3
|
import { WakaError } from '../../../utils/error-handling';
|
|
4
4
|
/**
|
|
5
5
|
* Hook pour gérer l'export des données du DataTable
|
|
6
|
+
*
|
|
7
|
+
* Optimisé avec Web Workers pour les grandes tables (>1000 lignes)
|
|
8
|
+
* pour éviter de bloquer l'interface utilisateur.
|
|
9
|
+
*
|
|
6
10
|
* @template TData - Type des données de la table
|
|
7
11
|
*/
|
|
8
12
|
export declare function useDataTableExport<TData extends Record<string, unknown>>({ data, columns, exportConfig, onError, }: {
|
|
@@ -14,6 +18,9 @@ export declare function useDataTableExport<TData extends Record<string, unknown>
|
|
|
14
18
|
exportData: (format: string, customData?: TData[], customFilename?: string) => Promise<void>;
|
|
15
19
|
exportAll: (format: string) => Promise<void>;
|
|
16
20
|
exportSelected: (format: string, selectedData: TData[]) => Promise<void>;
|
|
17
|
-
|
|
21
|
+
cancelExport: () => void;
|
|
22
|
+
exportProgress: number;
|
|
23
|
+
isExporting: boolean;
|
|
24
|
+
supportedFormats: ("csv" | "xlsx" | "json" | "pdf" | "xml")[] | readonly ["csv", "xlsx", "json"];
|
|
18
25
|
isExportSupported: (format: string) => boolean;
|
|
19
26
|
};
|
|
@@ -2,6 +2,7 @@ import { ImportConfig } from '../types';
|
|
|
2
2
|
import { WakaError } from '../../../utils/error-handling';
|
|
3
3
|
/**
|
|
4
4
|
* Hook pour gérer l'import des données dans le DataTable
|
|
5
|
+
* Supporte le streaming pour les fichiers volumineux
|
|
5
6
|
*/
|
|
6
7
|
export declare function useDataTableImport<TData>({ importConfig, onError, }: {
|
|
7
8
|
importConfig?: ImportConfig<TData>;
|
|
@@ -9,6 +10,17 @@ export declare function useDataTableImport<TData>({ importConfig, onError, }: {
|
|
|
9
10
|
}): {
|
|
10
11
|
importData: (file: File) => Promise<TData[]>;
|
|
11
12
|
importWithUI: () => Promise<TData[]>;
|
|
13
|
+
importDataStreaming: (file: File, options?: {
|
|
14
|
+
onProgress?: (progress: number) => void;
|
|
15
|
+
onChunk?: (chunk: TData[], totalProcessed: number) => void;
|
|
16
|
+
}) => Promise<TData[]>;
|
|
17
|
+
importWithUIStreaming: (options?: {
|
|
18
|
+
onProgress?: (progress: number) => void;
|
|
19
|
+
onChunk?: (chunk: TData[], totalProcessed: number) => void;
|
|
20
|
+
}) => Promise<TData[]>;
|
|
21
|
+
cancelImport: () => void;
|
|
22
|
+
importProgress: number;
|
|
23
|
+
isImporting: boolean;
|
|
12
24
|
supportedFormats: string[];
|
|
13
25
|
isFormatSupported: (filename: string) => boolean;
|
|
14
26
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Worker pour l'export de grandes tables
|
|
3
|
+
*
|
|
4
|
+
* Ce worker gère la conversion de données en différents formats (CSV, JSON, XML)
|
|
5
|
+
* dans un thread séparé pour éviter de bloquer l'interface utilisateur.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Utilisation via le hook useDataTableExport
|
|
9
|
+
* const { exportDataAsync } = useDataTableExport({ data, columns })
|
|
10
|
+
* await exportDataAsync('csv') // Utilise automatiquement le worker pour >1000 lignes
|
|
11
|
+
*/
|
|
12
|
+
export interface ExportWorkerMessage {
|
|
13
|
+
type: 'export';
|
|
14
|
+
format: 'csv' | 'json' | 'xml';
|
|
15
|
+
data: Record<string, unknown>[];
|
|
16
|
+
columns: {
|
|
17
|
+
key: string;
|
|
18
|
+
header: string;
|
|
19
|
+
}[];
|
|
20
|
+
filename: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ExportWorkerResponse {
|
|
23
|
+
type: 'success' | 'error' | 'progress';
|
|
24
|
+
content?: string;
|
|
25
|
+
blob?: Blob;
|
|
26
|
+
progress?: number;
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -3,6 +3,9 @@ import * as React from "react";
|
|
|
3
3
|
declare const themeManagerVariants: (props?: ({
|
|
4
4
|
size?: "base" | "sm" | "lg" | "full" | null | undefined;
|
|
5
5
|
} & import('class-variance-authority/dist/types').ClassProp) | undefined) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Interface pour un thème au format simplifié (couleurs directes)
|
|
8
|
+
*/
|
|
6
9
|
export interface TweakCNTheme {
|
|
7
10
|
name: string;
|
|
8
11
|
description?: string;
|
|
@@ -36,17 +39,27 @@ export interface TweakCNTheme {
|
|
|
36
39
|
};
|
|
37
40
|
}
|
|
38
41
|
export interface WakaThemeManagerProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof themeManagerVariants> {
|
|
42
|
+
/** Callback lors du changement de thème */
|
|
39
43
|
onThemeChange?: (theme: TweakCNTheme) => void;
|
|
44
|
+
/** Callback lors du chargement d'un thème */
|
|
40
45
|
onThemeLoad?: (theme: TweakCNTheme) => void;
|
|
46
|
+
/** Callback lors de la sauvegarde d'un thème */
|
|
41
47
|
onThemeSave?: (theme: TweakCNTheme) => void;
|
|
48
|
+
/** Thème initial */
|
|
42
49
|
initialTheme?: TweakCNTheme;
|
|
50
|
+
/** Afficher la prévisualisation */
|
|
43
51
|
showPreview?: boolean;
|
|
52
|
+
/** Afficher l'export */
|
|
44
53
|
showExport?: boolean;
|
|
54
|
+
/** Afficher l'import */
|
|
45
55
|
showImport?: boolean;
|
|
56
|
+
/** Autoriser la modification des couleurs */
|
|
46
57
|
allowCustomColors?: boolean;
|
|
47
58
|
}
|
|
48
59
|
/**
|
|
49
|
-
* WakaThemeManager - Gestionnaire complet de thèmes
|
|
60
|
+
* WakaThemeManager - Gestionnaire complet de thèmes
|
|
61
|
+
*
|
|
62
|
+
* Supporte le format shadcn/ui registry-item et peut charger des thèmes à la volée.
|
|
50
63
|
*
|
|
51
64
|
* @example
|
|
52
65
|
* ```tsx
|
package/dist/context/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ThemeProvider, useTheme } from './theme-provider';
|
|
2
|
-
export type { ThemeContextValue, ThemeProviderProps, ThemeConfig,
|
|
2
|
+
export type { ThemeContextValue, ThemeProviderProps, ThemeConfig, ShadcnRegistryItem } from './theme-provider';
|
|
3
3
|
export { ThemeProvider as LegacyThemeProvider, useTheme as useLegacyTheme } from './theme-context';
|
|
4
4
|
export type { ThemeContextValue as LegacyThemeContextValue, ThemeProviderProps as LegacyThemeProviderProps } from './theme-context';
|
|
5
5
|
export { LanguageProvider, useLanguage } from './language-context';
|
|
6
|
-
export type { LanguageConfig,
|
|
6
|
+
export type { LanguageConfig, LanguageProviderProps, LanguageContextValue, I18nTranslations, S3Config, TranslationsJSON } from './language-context';
|
|
7
7
|
export { WakaProvider, useWaka } from './waka-provider';
|
|
8
8
|
export type { WakaProviderConfig, WakaProviderProps } from './waka-provider';
|
|
@@ -3,73 +3,38 @@ import { WakaError } from '../utils/error-handling';
|
|
|
3
3
|
* @fileoverview Contexte de gestion des langues pour WakaStart UI
|
|
4
4
|
*
|
|
5
5
|
* Ce module fournit un système complet de gestion de l'internationalisation:
|
|
6
|
-
* - Chargement dynamique des traductions depuis
|
|
6
|
+
* - Chargement dynamique des traductions depuis URL ou inline JSON
|
|
7
7
|
* - Cache des traductions déjà chargées
|
|
8
8
|
* - Intégration transparente avec i18next
|
|
9
9
|
* - Persistance de la langue dans localStorage
|
|
10
|
+
* - Chargement à la volée de traductions JSON
|
|
10
11
|
*
|
|
11
12
|
* @module context/language-context
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```tsx
|
|
15
|
-
* // Configuration avec S3
|
|
16
|
-
* <LanguageProvider
|
|
17
|
-
* languages={[
|
|
18
|
-
* { code: "fr", label: "Français", flagEmoji: "🇫🇷" },
|
|
19
|
-
* { code: "en", label: "English", flagEmoji: "🇬🇧" }
|
|
20
|
-
* ]}
|
|
21
|
-
* defaultLanguage="fr"
|
|
22
|
-
* s3Config={{ baseUrl: "https://cdn.example.com/translations" }}
|
|
23
|
-
* >
|
|
24
|
-
* <App />
|
|
25
|
-
* </LanguageProvider>
|
|
26
|
-
* ```
|
|
27
13
|
*/
|
|
28
14
|
import * as React from "react";
|
|
29
15
|
/**
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
export interface S3Config {
|
|
33
|
-
/** URL de base du bucket S3 (ex: "https://bucket.s3.region.amazonaws.com") */
|
|
34
|
-
baseUrl: string;
|
|
35
|
-
/** Préfixe des fichiers de traduction (ex: "translations/") */
|
|
36
|
-
prefix?: string;
|
|
37
|
-
/** Extension des fichiers (défaut: "json") */
|
|
38
|
-
extension?: string;
|
|
39
|
-
/** Headers HTTP personnalisés pour les requêtes */
|
|
40
|
-
headers?: Record<string, string>;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Type pour les traductions JSON inline
|
|
44
|
-
* Structure clé-valeur avec support des namespaces imbriqués
|
|
45
|
-
*/
|
|
46
|
-
export type TranslationsJSON = Record<string, string | Record<string, unknown>>;
|
|
47
|
-
/**
|
|
48
|
-
* Configuration d'une langue disponible
|
|
16
|
+
* Format standard i18n pour les traductions
|
|
17
|
+
* Compatible avec i18next resource bundles
|
|
49
18
|
*
|
|
50
19
|
* @example
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* }
|
|
20
|
+
* ```json
|
|
21
|
+
* {
|
|
22
|
+
* "common": {
|
|
23
|
+
* "save": "Enregistrer",
|
|
24
|
+
* "cancel": "Annuler",
|
|
25
|
+
* "confirm": "Confirmer"
|
|
26
|
+
* },
|
|
27
|
+
* "errors": {
|
|
28
|
+
* "required": "Ce champ est requis",
|
|
29
|
+
* "invalid_email": "Email invalide"
|
|
62
30
|
* }
|
|
63
31
|
* }
|
|
64
|
-
*
|
|
65
|
-
* // Sans traductions inline (utilise S3)
|
|
66
|
-
* const english: LanguageConfig = {
|
|
67
|
-
* code: "en",
|
|
68
|
-
* label: "English",
|
|
69
|
-
* flagEmoji: "🇬🇧"
|
|
70
|
-
* }
|
|
71
32
|
* ```
|
|
72
33
|
*/
|
|
34
|
+
export type I18nTranslations = Record<string, string | Record<string, unknown>>;
|
|
35
|
+
/**
|
|
36
|
+
* Configuration d'une langue disponible
|
|
37
|
+
*/
|
|
73
38
|
export interface LanguageConfig {
|
|
74
39
|
/** Code ISO de la langue (ex: "fr", "en", "es") */
|
|
75
40
|
code: string;
|
|
@@ -80,11 +45,34 @@ export interface LanguageConfig {
|
|
|
80
45
|
/** URL de l'image du drapeau (optionnel) */
|
|
81
46
|
flag?: string;
|
|
82
47
|
/**
|
|
83
|
-
* Traductions inline au format JSON
|
|
84
|
-
* Si fourni, les traductions sont utilisées directement
|
|
48
|
+
* Traductions inline au format i18n JSON
|
|
49
|
+
* Si fourni, les traductions sont utilisées directement
|
|
50
|
+
*/
|
|
51
|
+
translations?: I18nTranslations;
|
|
52
|
+
/**
|
|
53
|
+
* URL pour charger le JSON des traductions (optionnel)
|
|
54
|
+
* Le JSON doit être au format I18nTranslations
|
|
85
55
|
*/
|
|
86
|
-
|
|
56
|
+
jsonUrl?: string;
|
|
87
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Configuration pour le chargement distant (legacy, utiliser jsonUrl dans LanguageConfig)
|
|
60
|
+
* @deprecated Utiliser `jsonUrl` dans LanguageConfig à la place
|
|
61
|
+
*/
|
|
62
|
+
export interface S3Config {
|
|
63
|
+
/** URL de base */
|
|
64
|
+
baseUrl: string;
|
|
65
|
+
/** Préfixe des fichiers */
|
|
66
|
+
prefix?: string;
|
|
67
|
+
/** Extension des fichiers (défaut: "json") */
|
|
68
|
+
extension?: string;
|
|
69
|
+
/** Headers HTTP personnalisés */
|
|
70
|
+
headers?: Record<string, string>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Type pour les traductions JSON (alias pour compatibilité)
|
|
74
|
+
*/
|
|
75
|
+
export type TranslationsJSON = I18nTranslations;
|
|
88
76
|
/**
|
|
89
77
|
* Valeur exposée par le contexte de langue
|
|
90
78
|
*/
|
|
@@ -99,6 +87,23 @@ export interface LanguageContextValue {
|
|
|
99
87
|
isLoading: boolean;
|
|
100
88
|
/** Set des codes de langues dont les traductions sont chargées */
|
|
101
89
|
loadedLanguages: Set<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Charge des traductions depuis un objet JSON à la volée
|
|
92
|
+
* @param langCode - Code de la langue
|
|
93
|
+
* @param translations - Traductions au format i18n JSON
|
|
94
|
+
* @param apply - Si true, change aussi la langue courante (défaut: true)
|
|
95
|
+
*/
|
|
96
|
+
loadLanguageFromJSON: (langCode: string, translations: I18nTranslations, apply?: boolean) => Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Ajoute/met à jour une langue dans la liste
|
|
99
|
+
* @param config - Configuration de la langue
|
|
100
|
+
*/
|
|
101
|
+
addLanguage: (config: LanguageConfig) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Recharge les traductions d'une langue depuis son URL
|
|
104
|
+
* @param langCode - Code de la langue à recharger
|
|
105
|
+
*/
|
|
106
|
+
reloadLanguage: (langCode: string) => Promise<void>;
|
|
102
107
|
}
|
|
103
108
|
/**
|
|
104
109
|
* Props du provider de langue
|
|
@@ -110,30 +115,42 @@ export interface LanguageProviderProps {
|
|
|
110
115
|
languages: LanguageConfig[];
|
|
111
116
|
/** Code de la langue par défaut (défaut: "fr") */
|
|
112
117
|
defaultLanguage?: string;
|
|
113
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Configuration S3 (legacy)
|
|
120
|
+
* @deprecated Utiliser `jsonUrl` dans chaque LanguageConfig à la place
|
|
121
|
+
*/
|
|
114
122
|
s3Config?: S3Config;
|
|
115
123
|
/** Callback appelé après chaque changement de langue réussi */
|
|
116
124
|
onLanguageChange?: (code: string) => void;
|
|
117
|
-
/** Callback en cas d'erreur
|
|
125
|
+
/** Callback en cas d'erreur */
|
|
118
126
|
onError?: (error: WakaError) => void;
|
|
127
|
+
/** Headers personnalisés pour les requêtes fetch */
|
|
128
|
+
fetchHeaders?: Record<string, string>;
|
|
129
|
+
/** Timeout en millisecondes pour les requêtes fetch (défaut: 10000) */
|
|
130
|
+
fetchTimeout?: number;
|
|
119
131
|
}
|
|
120
132
|
/**
|
|
121
|
-
*
|
|
133
|
+
* LanguageProvider
|
|
122
134
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* -
|
|
135
|
+
* Provider pour la gestion de l'internationalisation avec support
|
|
136
|
+
* du chargement dynamique de traductions JSON.
|
|
137
|
+
*
|
|
138
|
+
* Features:
|
|
139
|
+
* - Traductions inline ou chargées depuis URL
|
|
140
|
+
* - Chargement à la volée via loadLanguageFromJSON()
|
|
141
|
+
* - Cache des traductions déjà chargées
|
|
142
|
+
* - Intégration avec i18next
|
|
143
|
+
* - Persistance dans localStorage
|
|
128
144
|
*
|
|
129
145
|
* @example
|
|
130
146
|
* ```tsx
|
|
131
|
-
* // Configuration avec traductions inline
|
|
147
|
+
* // Configuration avec traductions inline
|
|
132
148
|
* <LanguageProvider
|
|
133
149
|
* languages={[
|
|
134
150
|
* {
|
|
135
151
|
* code: "fr",
|
|
136
152
|
* label: "Français",
|
|
153
|
+
* flagEmoji: "🇫🇷",
|
|
137
154
|
* translations: {
|
|
138
155
|
* common: { save: "Enregistrer", cancel: "Annuler" }
|
|
139
156
|
* }
|
|
@@ -141,36 +158,22 @@ export interface LanguageProviderProps {
|
|
|
141
158
|
* {
|
|
142
159
|
* code: "en",
|
|
143
160
|
* label: "English",
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* }
|
|
161
|
+
* flagEmoji: "🇬🇧",
|
|
162
|
+
* jsonUrl: "https://example.com/i18n/en.json"
|
|
147
163
|
* }
|
|
148
164
|
* ]}
|
|
149
|
-
*
|
|
150
|
-
* <App />
|
|
151
|
-
* </LanguageProvider>
|
|
152
|
-
*
|
|
153
|
-
* // Avec S3 pour chargement distant
|
|
154
|
-
* <LanguageProvider
|
|
155
|
-
* languages={languages}
|
|
156
|
-
* s3Config={{ baseUrl: "https://cdn.example.com/i18n" }}
|
|
157
|
-
* onLanguageChange={(lang) => analytics.track("language_changed", { lang })}
|
|
165
|
+
* defaultLanguage="fr"
|
|
158
166
|
* >
|
|
159
167
|
* <App />
|
|
160
168
|
* </LanguageProvider>
|
|
161
169
|
* ```
|
|
162
170
|
*/
|
|
163
|
-
export declare function LanguageProvider({ children, languages, defaultLanguage, s3Config, onLanguageChange, onError, }: LanguageProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
171
|
+
export declare function LanguageProvider({ children, languages: initialLanguages, defaultLanguage, s3Config, onLanguageChange, onError, fetchHeaders, fetchTimeout, }: LanguageProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
164
172
|
/**
|
|
165
173
|
* Hook pour accéder au contexte de langue
|
|
166
174
|
*
|
|
167
|
-
* Fournit la langue courante, les langues disponibles et la fonction
|
|
168
|
-
* de changement de langue.
|
|
169
|
-
*
|
|
170
175
|
* @throws {Error} Si utilisé en dehors d'un LanguageProvider
|
|
171
176
|
*
|
|
172
|
-
* @returns Valeur du contexte de langue
|
|
173
|
-
*
|
|
174
177
|
* @example
|
|
175
178
|
* ```tsx
|
|
176
179
|
* function LanguageSwitcher() {
|
|
@@ -190,6 +193,19 @@ export declare function LanguageProvider({ children, languages, defaultLanguage,
|
|
|
190
193
|
* </select>
|
|
191
194
|
* )
|
|
192
195
|
* }
|
|
196
|
+
*
|
|
197
|
+
* // Charger des traductions à la volée
|
|
198
|
+
* function LoadCustomTranslations() {
|
|
199
|
+
* const { loadLanguageFromJSON } = useLanguage()
|
|
200
|
+
*
|
|
201
|
+
* const handleLoad = async () => {
|
|
202
|
+
* await loadLanguageFromJSON("custom", {
|
|
203
|
+
* common: { hello: "Bonjour" }
|
|
204
|
+
* })
|
|
205
|
+
* }
|
|
206
|
+
*
|
|
207
|
+
* return <button onClick={handleLoad}>Load Custom</button>
|
|
208
|
+
* }
|
|
193
209
|
* ```
|
|
194
210
|
*/
|
|
195
211
|
export declare function useLanguage(): LanguageContextValue;
|
|
@@ -6,17 +6,18 @@ export interface ThemeContextValue {
|
|
|
6
6
|
themes: ThemeConfigItem[];
|
|
7
7
|
systemTheme?: string;
|
|
8
8
|
isLoadingThemes?: boolean;
|
|
9
|
-
themesSource?: "config" | "
|
|
9
|
+
themesSource?: "config" | "fallback";
|
|
10
10
|
}
|
|
11
11
|
export interface ThemeProviderProps {
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
config?: WakaThemeConfig;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Provider de thème pour WakaStart UI
|
|
16
|
+
* Provider de thème legacy pour WakaStart UI
|
|
17
17
|
*
|
|
18
18
|
* Gère le thème actif, le stockage dans localStorage et la détection du thème système
|
|
19
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Utiliser ThemeProvider de theme-provider.tsx avec support shadcn registry-item
|
|
20
21
|
*
|
|
21
22
|
* @example
|
|
22
23
|
* ```tsx
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { WakaError } from '../utils/error-handling';
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
export interface ThemeS3Config {
|
|
4
|
-
/** URL de base du bucket S3 */
|
|
5
|
-
baseUrl: string;
|
|
6
|
-
/** Préfixe des fichiers (ex: "themes/") */
|
|
7
|
-
prefix?: string;
|
|
8
|
-
/** Extension des fichiers (défaut: "css") */
|
|
9
|
-
extension?: string;
|
|
10
|
-
/** Headers personnalisés pour les requêtes */
|
|
11
|
-
headers?: Record<string, string>;
|
|
12
|
-
/** Timeout en millisecondes */
|
|
13
|
-
timeout?: number;
|
|
14
|
-
}
|
|
15
3
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
4
|
+
* Format shadcn/ui registry-item pour les thèmes
|
|
5
|
+
* Compatible avec https://ui.shadcn.com/schema/registry-item.json
|
|
18
6
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
export interface ShadcnRegistryItem {
|
|
8
|
+
/** Schema URL (optionnel) */
|
|
9
|
+
$schema?: string;
|
|
10
|
+
/** Nom du thème */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Type de registry item */
|
|
13
|
+
type?: "registry:style" | "registry:theme" | string;
|
|
14
|
+
/** CSS personnalisé avec support @layer */
|
|
15
|
+
css?: {
|
|
16
|
+
"@layer base"?: Record<string, Record<string, string>>;
|
|
17
|
+
[selector: string]: Record<string, string> | Record<string, Record<string, string>> | undefined;
|
|
18
|
+
};
|
|
19
|
+
/** Variables CSS par mode */
|
|
20
|
+
cssVars?: {
|
|
21
|
+
/** Variables communes au thème (fonts, radius, etc.) */
|
|
22
|
+
theme?: Record<string, string>;
|
|
23
|
+
/** Variables mode clair */
|
|
24
|
+
light?: Record<string, string>;
|
|
25
|
+
/** Variables mode sombre */
|
|
26
|
+
dark?: Record<string, string>;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
28
29
|
/**
|
|
29
|
-
* Configuration d'un thème
|
|
30
|
+
* Configuration d'un thème
|
|
30
31
|
*/
|
|
31
32
|
export interface ThemeConfig {
|
|
32
33
|
/** Identifiant du thème (utilisé dans data-theme) */
|
|
@@ -38,24 +39,15 @@ export interface ThemeConfig {
|
|
|
38
39
|
/** Couleur représentative du thème (pour preview) */
|
|
39
40
|
previewColor?: string;
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* cssVars: {
|
|
47
|
-
* "--background": "0 0% 100%",
|
|
48
|
-
* "--foreground": "222.2 84% 4.9%",
|
|
49
|
-
* "--primary": "222.2 47.4% 11.2%"
|
|
50
|
-
* }
|
|
51
|
-
* ```
|
|
42
|
+
* Données du thème au format shadcn registry-item
|
|
43
|
+
* C'est le format recommandé pour définir les thèmes
|
|
52
44
|
*/
|
|
53
|
-
|
|
45
|
+
registryItem?: ShadcnRegistryItem;
|
|
54
46
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
47
|
+
* URL pour charger le JSON du thème (optionnel)
|
|
48
|
+
* Le JSON doit être au format ShadcnRegistryItem
|
|
57
49
|
*/
|
|
58
|
-
|
|
50
|
+
jsonUrl?: string;
|
|
59
51
|
}
|
|
60
52
|
export interface ThemeContextValue {
|
|
61
53
|
/** Thème courant */
|
|
@@ -76,6 +68,12 @@ export interface ThemeContextValue {
|
|
|
76
68
|
preloadTheme: (id: string) => Promise<void>;
|
|
77
69
|
/** Vérifier si un thème est chargé */
|
|
78
70
|
isThemeLoaded: (id: string) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Charger un thème depuis un objet JSON
|
|
73
|
+
* @param themeId - ID du thème à créer/mettre à jour
|
|
74
|
+
* @param registryItem - Données au format shadcn registry-item
|
|
75
|
+
*/
|
|
76
|
+
loadThemeFromJSON: (themeId: string, registryItem: ShadcnRegistryItem) => Promise<void>;
|
|
79
77
|
}
|
|
80
78
|
export interface ThemeProviderProps {
|
|
81
79
|
children: React.ReactNode;
|
|
@@ -83,29 +81,31 @@ export interface ThemeProviderProps {
|
|
|
83
81
|
themes: ThemeConfig[];
|
|
84
82
|
/** Thème par défaut */
|
|
85
83
|
defaultTheme?: string;
|
|
86
|
-
/** Configuration S3 (optionnel - si non fourni, utilise les thèmes locaux) */
|
|
87
|
-
s3Config?: ThemeS3Config;
|
|
88
84
|
/** Callback après changement de thème */
|
|
89
85
|
onThemeChange?: (id: string) => void;
|
|
90
|
-
/** Callback en cas d'erreur
|
|
86
|
+
/** Callback en cas d'erreur */
|
|
91
87
|
onError?: (error: WakaError) => void;
|
|
92
88
|
/** Activer le mode sombre (optionnel) */
|
|
93
89
|
enableDarkMode?: boolean;
|
|
90
|
+
/** Headers personnalisés pour les requêtes fetch (optionnel) */
|
|
91
|
+
fetchHeaders?: Record<string, string>;
|
|
92
|
+
/** Timeout en millisecondes pour les requêtes fetch (défaut: 10000) */
|
|
93
|
+
fetchTimeout?: number;
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* ThemeProvider
|
|
97
97
|
*
|
|
98
|
-
* Provider pour gérer les thèmes
|
|
98
|
+
* Provider pour gérer les thèmes avec support du format shadcn/ui registry-item.
|
|
99
99
|
*
|
|
100
100
|
* Features:
|
|
101
|
-
* -
|
|
101
|
+
* - Support complet du format shadcn registry-item JSON
|
|
102
|
+
* - Chargement dynamique depuis URL ou inline
|
|
102
103
|
* - Cache des thèmes déjà chargés
|
|
103
|
-
* - Support
|
|
104
|
+
* - Support @layer base pour styles personnalisés
|
|
104
105
|
* - Persistance dans localStorage
|
|
105
|
-
* -
|
|
106
|
-
* - Support des thèmes locaux si pas de S3
|
|
106
|
+
* - Support dark mode
|
|
107
107
|
*/
|
|
108
|
-
export declare function ThemeProvider({ children, themes, defaultTheme,
|
|
108
|
+
export declare function ThemeProvider({ children, themes, defaultTheme, onThemeChange, onError, enableDarkMode, fetchHeaders, fetchTimeout, }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
109
109
|
/**
|
|
110
110
|
* Hook pour utiliser le ThemeProvider
|
|
111
111
|
*/
|