@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,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Error Handling System for @wakastart/ui
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error handling patterns across all components.
|
|
5
|
+
*
|
|
6
|
+
* @module error-handling
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { WakaError, tryCatch, tryCatchAsync, handleError } from '@wakastellar/ui'
|
|
10
|
+
*
|
|
11
|
+
* // Sync operations
|
|
12
|
+
* const result = tryCatch(() => parseJSON(data), {
|
|
13
|
+
* context: 'DataTable.parseConfig',
|
|
14
|
+
* fallback: defaultConfig,
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* // Async operations
|
|
18
|
+
* const data = await tryCatchAsync(() => fetchData(), {
|
|
19
|
+
* context: 'DataTable.fetchData',
|
|
20
|
+
* onError: (err) => showToast(err.message),
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Error codes for @wakastart/ui
|
|
26
|
+
*/
|
|
27
|
+
export declare const ErrorCode: {
|
|
28
|
+
readonly UNKNOWN: "WAKA_UNKNOWN";
|
|
29
|
+
readonly VALIDATION: "WAKA_VALIDATION";
|
|
30
|
+
readonly NETWORK: "WAKA_NETWORK";
|
|
31
|
+
readonly TIMEOUT: "WAKA_TIMEOUT";
|
|
32
|
+
readonly THEME_LOAD_FAILED: "WAKA_THEME_LOAD_FAILED";
|
|
33
|
+
readonly THEME_PARSE_FAILED: "WAKA_THEME_PARSE_FAILED";
|
|
34
|
+
readonly THEME_APPLY_FAILED: "WAKA_THEME_APPLY_FAILED";
|
|
35
|
+
readonly LANG_LOAD_FAILED: "WAKA_LANG_LOAD_FAILED";
|
|
36
|
+
readonly LANG_PARSE_FAILED: "WAKA_LANG_PARSE_FAILED";
|
|
37
|
+
readonly TRANSLATION_MISSING: "WAKA_TRANSLATION_MISSING";
|
|
38
|
+
readonly DATATABLE_EXPORT_FAILED: "WAKA_DATATABLE_EXPORT_FAILED";
|
|
39
|
+
readonly DATATABLE_IMPORT_FAILED: "WAKA_DATATABLE_IMPORT_FAILED";
|
|
40
|
+
readonly DATATABLE_PARSE_FAILED: "WAKA_DATATABLE_PARSE_FAILED";
|
|
41
|
+
readonly COMPONENT_RENDER_FAILED: "WAKA_COMPONENT_RENDER_FAILED";
|
|
42
|
+
readonly COMPONENT_INIT_FAILED: "WAKA_COMPONENT_INIT_FAILED";
|
|
43
|
+
readonly PROVIDER_MISSING: "WAKA_PROVIDER_MISSING";
|
|
44
|
+
readonly PROVIDER_CONFIG_INVALID: "WAKA_PROVIDER_CONFIG_INVALID";
|
|
45
|
+
};
|
|
46
|
+
export type ErrorCodeType = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
47
|
+
/**
|
|
48
|
+
* Custom error class for @wakastart/ui
|
|
49
|
+
*/
|
|
50
|
+
export declare class WakaError extends Error {
|
|
51
|
+
/** Error code for programmatic handling */
|
|
52
|
+
readonly code: ErrorCodeType;
|
|
53
|
+
/** Context where the error occurred */
|
|
54
|
+
readonly context?: string;
|
|
55
|
+
/** Original error if wrapped */
|
|
56
|
+
readonly cause?: Error;
|
|
57
|
+
/** Additional metadata */
|
|
58
|
+
readonly metadata?: Record<string, unknown>;
|
|
59
|
+
/** Timestamp when error occurred */
|
|
60
|
+
readonly timestamp: Date;
|
|
61
|
+
constructor(message: string, options?: {
|
|
62
|
+
code?: ErrorCodeType;
|
|
63
|
+
context?: string;
|
|
64
|
+
cause?: Error;
|
|
65
|
+
metadata?: Record<string, unknown>;
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* Create a WakaError from any error type
|
|
69
|
+
*/
|
|
70
|
+
static from(error: unknown, options?: {
|
|
71
|
+
code?: ErrorCodeType;
|
|
72
|
+
context?: string;
|
|
73
|
+
metadata?: Record<string, unknown>;
|
|
74
|
+
}): WakaError;
|
|
75
|
+
/**
|
|
76
|
+
* Serialize error for logging or transmission
|
|
77
|
+
*/
|
|
78
|
+
toJSON(): Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Options for error handling utilities
|
|
82
|
+
*/
|
|
83
|
+
export interface ErrorHandlerOptions<T> {
|
|
84
|
+
/** Context identifier for logging */
|
|
85
|
+
context?: string;
|
|
86
|
+
/** Error code to use */
|
|
87
|
+
code?: ErrorCodeType;
|
|
88
|
+
/** Callback when error occurs */
|
|
89
|
+
onError?: (error: WakaError) => void;
|
|
90
|
+
/** Fallback value to return on error */
|
|
91
|
+
fallback?: T;
|
|
92
|
+
/** Whether to rethrow the error after handling */
|
|
93
|
+
rethrow?: boolean;
|
|
94
|
+
/** Additional metadata to attach to error */
|
|
95
|
+
metadata?: Record<string, unknown>;
|
|
96
|
+
/** Whether to suppress logging (default: false) */
|
|
97
|
+
silent?: boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Handle an error with consistent logging and callbacks
|
|
101
|
+
*/
|
|
102
|
+
export declare function handleError(error: unknown, options?: Omit<ErrorHandlerOptions<unknown>, "fallback">): WakaError;
|
|
103
|
+
/**
|
|
104
|
+
* Wrap a synchronous operation with error handling
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const config = tryCatch(
|
|
109
|
+
* () => JSON.parse(jsonString),
|
|
110
|
+
* { context: 'parseConfig', fallback: {} }
|
|
111
|
+
* )
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare function tryCatch<T>(fn: () => T, options?: ErrorHandlerOptions<T>): T | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Wrap an async operation with error handling
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const data = await tryCatchAsync(
|
|
121
|
+
* () => fetch('/api/data').then(r => r.json()),
|
|
122
|
+
* { context: 'fetchData', onError: showError }
|
|
123
|
+
* )
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare function tryCatchAsync<T>(fn: () => Promise<T>, options?: ErrorHandlerOptions<T>): Promise<T | undefined>;
|
|
127
|
+
/**
|
|
128
|
+
* Create a wrapped version of an async function with error handling
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* const safeFetch = withErrorHandling(
|
|
133
|
+
* fetchUserData,
|
|
134
|
+
* { context: 'UserService.fetchData' }
|
|
135
|
+
* )
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare function withErrorHandling<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => Promise<TReturn>, options?: Omit<ErrorHandlerOptions<TReturn>, "fallback">): (...args: TArgs) => Promise<TReturn>;
|
|
139
|
+
/**
|
|
140
|
+
* Assert a condition, throwing a WakaError if false
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* assertCondition(user != null, 'User must be authenticated', {
|
|
145
|
+
* code: ErrorCode.VALIDATION,
|
|
146
|
+
* context: 'UserProfile',
|
|
147
|
+
* })
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare function assertCondition(condition: boolean, message: string, options?: {
|
|
151
|
+
code?: ErrorCodeType;
|
|
152
|
+
context?: string;
|
|
153
|
+
metadata?: Record<string, unknown>;
|
|
154
|
+
}): asserts condition;
|
|
155
|
+
/**
|
|
156
|
+
* Type guard to check if an error is a WakaError
|
|
157
|
+
*/
|
|
158
|
+
export declare function isWakaError(error: unknown): error is WakaError;
|
|
159
|
+
/**
|
|
160
|
+
* Check if error matches a specific code
|
|
161
|
+
*/
|
|
162
|
+
export declare function isErrorCode(error: unknown, code: ErrorCodeType): error is WakaError;
|
|
163
|
+
/**
|
|
164
|
+
* Create error factories for specific contexts
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* const createDataTableError = createErrorFactory('DataTable')
|
|
169
|
+
* throw createDataTableError('Export failed', ErrorCode.DATATABLE_EXPORT_FAILED)
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export declare function createErrorFactory(context: string): (message: string, code?: ErrorCodeType, metadata?: Record<string, unknown>) => WakaError;
|
|
173
|
+
/**
|
|
174
|
+
* Retry an async operation with exponential backoff
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* const data = await retryAsync(
|
|
179
|
+
* () => fetchWithTimeout('/api/data'),
|
|
180
|
+
* { maxRetries: 3, context: 'fetchData' }
|
|
181
|
+
* )
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export declare function retryAsync<T>(fn: () => Promise<T>, options?: {
|
|
185
|
+
maxRetries?: number;
|
|
186
|
+
baseDelay?: number;
|
|
187
|
+
maxDelay?: number;
|
|
188
|
+
context?: string;
|
|
189
|
+
onRetry?: (attempt: number, error: WakaError) => void;
|
|
190
|
+
}): Promise<T>;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -3,3 +3,7 @@ export { tweak, type VariantProps } from './tweak';
|
|
|
3
3
|
export * from './datetime-helpers';
|
|
4
4
|
export { ThemeLoader, initThemeLoader, getThemeLoader, loadTheme, applyTheme, useThemeLoader } from './theme-loader';
|
|
5
5
|
export type { ThemeLoaderConfig } from './theme-loader';
|
|
6
|
+
export { logger, Logger } from './logger';
|
|
7
|
+
export type { LoggerConfig, LogLevel } from './logger';
|
|
8
|
+
export { WakaError, ErrorCode, handleError, tryCatch, tryCatchAsync, withErrorHandling, assertCondition, isWakaError, isErrorCode, createErrorFactory, retryAsync, } from './error-handling';
|
|
9
|
+
export type { ErrorCodeType, ErrorHandlerOptions } from './error-handling';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conditional logging utility for @wakastart/ui
|
|
3
|
+
*
|
|
4
|
+
* Respects NODE_ENV and debug flags to prevent console pollution in production.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { logger } from '@wakastart/ui'
|
|
9
|
+
*
|
|
10
|
+
* // Only logs in development or when debug is enabled
|
|
11
|
+
* logger.debug('DataTable props:', props)
|
|
12
|
+
* logger.info('Theme loaded successfully')
|
|
13
|
+
* logger.warn('Missing translation key')
|
|
14
|
+
* logger.error('Failed to load theme', error)
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
18
|
+
interface LoggerConfig {
|
|
19
|
+
/** Enable debug logging (overrides NODE_ENV check) */
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
/** Minimum log level to display */
|
|
22
|
+
minLevel?: LogLevel;
|
|
23
|
+
/** Prefix for all log messages */
|
|
24
|
+
prefix?: string;
|
|
25
|
+
}
|
|
26
|
+
declare class Logger {
|
|
27
|
+
private config;
|
|
28
|
+
constructor(config?: LoggerConfig);
|
|
29
|
+
/**
|
|
30
|
+
* Configure the logger
|
|
31
|
+
*/
|
|
32
|
+
configure(config: Partial<LoggerConfig>): void;
|
|
33
|
+
/**
|
|
34
|
+
* Check if logging is enabled for the given level
|
|
35
|
+
*/
|
|
36
|
+
private shouldLog;
|
|
37
|
+
/**
|
|
38
|
+
* Format log message with prefix
|
|
39
|
+
*/
|
|
40
|
+
private format;
|
|
41
|
+
/**
|
|
42
|
+
* Debug level logging (development only by default)
|
|
43
|
+
*/
|
|
44
|
+
debug(message: string, ...args: unknown[]): void;
|
|
45
|
+
/**
|
|
46
|
+
* Info level logging
|
|
47
|
+
*/
|
|
48
|
+
info(message: string, ...args: unknown[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* Warning level logging (always shown)
|
|
51
|
+
*/
|
|
52
|
+
warn(message: string, ...args: unknown[]): void;
|
|
53
|
+
/**
|
|
54
|
+
* Error level logging (always shown)
|
|
55
|
+
*/
|
|
56
|
+
error(message: string, ...args: unknown[]): void;
|
|
57
|
+
}
|
|
58
|
+
export declare const logger: Logger;
|
|
59
|
+
export { Logger };
|
|
60
|
+
export type { LoggerConfig, LogLevel };
|
|
@@ -1,66 +1,130 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @fileoverview Chargeur dynamique de thèmes pour WakaStart UI
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Ce module permet de charger des thèmes CSS depuis n'importe quelle URL
|
|
5
|
+
* (S3, CDN, serveur local) et de les appliquer dynamiquement.
|
|
6
|
+
*
|
|
7
|
+
* Fonctionnalités:
|
|
8
|
+
* - Chargement asynchrone avec timeout configurable
|
|
9
|
+
* - Cache des thèmes déjà chargés
|
|
10
|
+
* - Préchargement de plusieurs thèmes en parallèle
|
|
11
|
+
* - Persistance du thème actif dans localStorage
|
|
12
|
+
* - Support de tous les formats de couleurs (hex, rgb, hsl, oklch)
|
|
13
|
+
*
|
|
14
|
+
* @module utils/theme-loader
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* // Initialisation
|
|
19
|
+
* import { initThemeLoader, loadTheme } from '@wakastellar/ui'
|
|
20
|
+
*
|
|
21
|
+
* initThemeLoader({ baseUrl: 'https://cdn.example.com/themes' })
|
|
22
|
+
*
|
|
23
|
+
* // Charger et appliquer un thème
|
|
24
|
+
* await loadTheme('dark')
|
|
25
|
+
*
|
|
26
|
+
* // Avec le hook React
|
|
27
|
+
* const { loadTheme, currentTheme, isLoading } = useThemeLoader()
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Configuration du chargeur de thèmes
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* const config: ThemeLoaderConfig = {
|
|
36
|
+
* baseUrl: 'https://cdn.example.com/themes',
|
|
37
|
+
* cache: true,
|
|
38
|
+
* timeout: 5000,
|
|
39
|
+
* onError: (err, name) => console.error(`Theme ${name} failed:`, err),
|
|
40
|
+
* onSuccess: (name) => console.log(`Theme ${name} loaded`)
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
6
43
|
*/
|
|
7
44
|
export interface ThemeLoaderConfig {
|
|
8
|
-
/**
|
|
9
|
-
* URL de base où les thèmes sont stockés (S3, CDN, etc.)
|
|
10
|
-
*/
|
|
45
|
+
/** URL de base où les fichiers CSS des thèmes sont stockés */
|
|
11
46
|
baseUrl: string;
|
|
12
|
-
/**
|
|
13
|
-
* Cache les thèmes déjà chargés pour éviter les requêtes répétées
|
|
14
|
-
*/
|
|
47
|
+
/** Active le cache des thèmes chargés (défaut: true) */
|
|
15
48
|
cache?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Timeout en millisecondes pour le chargement d'un thème
|
|
18
|
-
*/
|
|
49
|
+
/** Timeout en ms pour le chargement d'un thème (défaut: 10000) */
|
|
19
50
|
timeout?: number;
|
|
20
|
-
/**
|
|
21
|
-
* Callback appelé en cas d'erreur de chargement
|
|
22
|
-
*/
|
|
51
|
+
/** Callback appelé en cas d'erreur de chargement */
|
|
23
52
|
onError?: (error: Error, themeName: string) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Callback appelé une fois le thème chargé avec succès
|
|
26
|
-
*/
|
|
53
|
+
/** Callback appelé après chargement réussi d'un thème */
|
|
27
54
|
onSuccess?: (themeName: string) => void;
|
|
28
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Classe principale pour le chargement dynamique des thèmes
|
|
58
|
+
*
|
|
59
|
+
* Gère le chargement, le cache et l'application des thèmes CSS.
|
|
60
|
+
* Utilisez `initThemeLoader()` pour créer une instance globale.
|
|
61
|
+
*/
|
|
29
62
|
declare class ThemeLoader {
|
|
30
63
|
private config;
|
|
31
64
|
private loadedThemes;
|
|
32
65
|
private styleElements;
|
|
66
|
+
/**
|
|
67
|
+
* Crée une nouvelle instance du chargeur de thèmes
|
|
68
|
+
* @param config - Configuration du chargeur
|
|
69
|
+
*/
|
|
33
70
|
constructor(config: ThemeLoaderConfig);
|
|
34
71
|
/**
|
|
35
|
-
* Charge un thème depuis
|
|
72
|
+
* Charge un thème depuis l'URL configurée et l'applique
|
|
73
|
+
*
|
|
74
|
+
* @param themeName - Nom du thème (sans extension .css)
|
|
75
|
+
* @throws {Error} Si le chargement échoue ou timeout
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* await loader.loadTheme('dark')
|
|
80
|
+
* ```
|
|
36
81
|
*/
|
|
37
82
|
loadTheme(themeName: string): Promise<void>;
|
|
38
83
|
/**
|
|
39
|
-
* Applique un thème déjà chargé
|
|
84
|
+
* Applique un thème déjà chargé au document
|
|
85
|
+
*
|
|
86
|
+
* Met à jour l'attribut `data-theme` sur `<html>` et sauvegarde dans localStorage.
|
|
87
|
+
*
|
|
88
|
+
* @param themeName - Nom du thème à appliquer
|
|
40
89
|
*/
|
|
41
90
|
applyTheme(themeName: string): void;
|
|
42
91
|
/**
|
|
43
|
-
* Récupère le thème actuellement appliqué
|
|
92
|
+
* Récupère le nom du thème actuellement appliqué
|
|
93
|
+
*
|
|
94
|
+
* @returns Nom du thème ou null si aucun n'est défini
|
|
44
95
|
*/
|
|
45
96
|
getCurrentTheme(): string | null;
|
|
46
97
|
/**
|
|
47
|
-
*
|
|
98
|
+
* Récupère le dernier thème utilisé depuis localStorage
|
|
99
|
+
*
|
|
100
|
+
* @returns Nom du thème sauvegardé ou null
|
|
48
101
|
*/
|
|
49
102
|
loadSavedTheme(): string | null;
|
|
50
103
|
/**
|
|
51
|
-
* Précharge plusieurs thèmes en parallèle
|
|
104
|
+
* Précharge plusieurs thèmes en parallèle pour un changement instantané
|
|
105
|
+
*
|
|
106
|
+
* @param themeNames - Liste des noms de thèmes à précharger
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* await loader.preloadThemes(['light', 'dark', 'forest'])
|
|
111
|
+
* ```
|
|
52
112
|
*/
|
|
53
113
|
preloadThemes(themeNames: string[]): Promise<void>;
|
|
54
114
|
/**
|
|
55
115
|
* Supprime un thème du cache et du DOM
|
|
116
|
+
*
|
|
117
|
+
* @param themeName - Nom du thème à décharger
|
|
56
118
|
*/
|
|
57
119
|
unloadTheme(themeName: string): void;
|
|
58
120
|
/**
|
|
59
|
-
* Vide complètement le cache
|
|
121
|
+
* Vide complètement le cache et supprime tous les styles injectés
|
|
60
122
|
*/
|
|
61
123
|
clearCache(): void;
|
|
62
124
|
/**
|
|
63
|
-
*
|
|
125
|
+
* Retourne la liste des noms de thèmes actuellement en cache
|
|
126
|
+
*
|
|
127
|
+
* @returns Tableau des noms de thèmes chargés
|
|
64
128
|
*/
|
|
65
129
|
getLoadedThemes(): string[];
|
|
66
130
|
/**
|
|
@@ -73,23 +137,69 @@ declare class ThemeLoader {
|
|
|
73
137
|
private injectThemeStyles;
|
|
74
138
|
}
|
|
75
139
|
/**
|
|
76
|
-
* Initialise le
|
|
140
|
+
* Initialise le chargeur de thèmes global avec la configuration fournie
|
|
141
|
+
*
|
|
142
|
+
* Cette fonction doit être appelée une fois au démarrage de l'application.
|
|
143
|
+
*
|
|
144
|
+
* @param config - Configuration du chargeur
|
|
145
|
+
* @returns Instance du ThemeLoader
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```tsx
|
|
149
|
+
* // Dans _app.tsx ou layout.tsx
|
|
150
|
+
* initThemeLoader({
|
|
151
|
+
* baseUrl: process.env.NEXT_PUBLIC_THEMES_URL,
|
|
152
|
+
* onError: (err, name) => toast.error(`Échec du thème ${name}`)
|
|
153
|
+
* })
|
|
154
|
+
* ```
|
|
77
155
|
*/
|
|
78
156
|
export declare function initThemeLoader(config: ThemeLoaderConfig): ThemeLoader;
|
|
79
157
|
/**
|
|
80
|
-
* Récupère l'instance globale du
|
|
158
|
+
* Récupère l'instance globale du chargeur de thèmes
|
|
159
|
+
*
|
|
160
|
+
* @throws {Error} Si initThemeLoader() n'a pas été appelé
|
|
161
|
+
* @returns Instance du ThemeLoader
|
|
81
162
|
*/
|
|
82
163
|
export declare function getThemeLoader(): ThemeLoader;
|
|
83
164
|
/**
|
|
84
|
-
* Charge un thème
|
|
165
|
+
* Charge et applique un thème via l'instance globale
|
|
166
|
+
*
|
|
167
|
+
* @param themeName - Nom du thème à charger
|
|
168
|
+
* @throws {Error} Si le loader n'est pas initialisé
|
|
85
169
|
*/
|
|
86
170
|
export declare function loadTheme(themeName: string): Promise<void>;
|
|
87
171
|
/**
|
|
88
|
-
* Applique un thème
|
|
172
|
+
* Applique un thème déjà chargé via l'instance globale
|
|
173
|
+
*
|
|
174
|
+
* @param themeName - Nom du thème à appliquer
|
|
89
175
|
*/
|
|
90
176
|
export declare function applyTheme(themeName: string): void;
|
|
91
177
|
/**
|
|
92
|
-
* Hook React pour charger
|
|
178
|
+
* Hook React pour charger et gérer les thèmes dynamiquement
|
|
179
|
+
*
|
|
180
|
+
* Fournit des méthodes pour charger et appliquer des thèmes,
|
|
181
|
+
* ainsi que l'état de chargement et le thème actuel.
|
|
182
|
+
*
|
|
183
|
+
* @param config - Configuration optionnelle (utilise l'instance globale si non fournie)
|
|
184
|
+
* @returns Objet avec méthodes et état du chargeur
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```tsx
|
|
188
|
+
* function ThemeSwitcher() {
|
|
189
|
+
* const { loadTheme, currentTheme, isLoading, loadedThemes } = useThemeLoader()
|
|
190
|
+
*
|
|
191
|
+
* return (
|
|
192
|
+
* <select
|
|
193
|
+
* value={currentTheme || ''}
|
|
194
|
+
* onChange={(e) => loadTheme(e.target.value)}
|
|
195
|
+
* disabled={isLoading}
|
|
196
|
+
* >
|
|
197
|
+
* <option value="light">Clair</option>
|
|
198
|
+
* <option value="dark">Sombre</option>
|
|
199
|
+
* </select>
|
|
200
|
+
* )
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
93
203
|
*/
|
|
94
204
|
export declare function useThemeLoader(config?: Partial<ThemeLoaderConfig>): {
|
|
95
205
|
loadTheme: (themeName: string) => Promise<void>;
|
package/dist/utils/tweak.d.ts
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import { ClassValue } from 'clsx';
|
|
2
2
|
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration des variantes pour un composant
|
|
5
|
+
*/
|
|
3
6
|
export type ConfigVariants<T> = T extends Record<string, Record<string, string>> ? {
|
|
4
7
|
[K in keyof T]?: keyof T[K];
|
|
5
8
|
} : never;
|
|
9
|
+
/**
|
|
10
|
+
* Props pour les classes CSS additionnelles
|
|
11
|
+
*/
|
|
6
12
|
export type ClassProp = {
|
|
7
13
|
class?: ClassValue;
|
|
8
14
|
className?: ClassValue;
|
|
9
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Fusionne des classes CSS en résolvant les conflits Tailwind.
|
|
18
|
+
* Combine clsx pour la logique conditionnelle et tailwind-merge pour la résolution des conflits.
|
|
19
|
+
*
|
|
20
|
+
* @param inputs - Classes CSS à fusionner
|
|
21
|
+
* @returns Chaîne de classes CSS fusionnée
|
|
22
|
+
*/
|
|
10
23
|
export declare function tweak(...inputs: ClassValue[]): string;
|
|
11
24
|
export declare namespace tweak {
|
|
12
25
|
var variants: <T extends Record<string, Record<string, string>>, Defaults extends Partial<Record<keyof T, string>> = {}>(config: {
|
|
13
26
|
base?: string;
|
|
14
27
|
variants?: T;
|
|
15
28
|
defaultVariants?: Defaults;
|
|
16
|
-
}) => (options?:
|
|
29
|
+
}) => (options?: ConfigVariants<T> & ClassProp) => string;
|
|
17
30
|
}
|
|
18
31
|
export type { VariantProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wakastellar/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "UI Library compatible TweakCN + i18n pour Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -18,39 +18,40 @@
|
|
|
18
18
|
"require": "./dist/index.cjs.js"
|
|
19
19
|
},
|
|
20
20
|
"./styles": "./src/styles/globals.css",
|
|
21
|
-
"./styles/*": "./src/styles/*.css"
|
|
21
|
+
"./styles/*": "./src/styles/*.css",
|
|
22
|
+
"./dist/ui.css": "./dist/ui.css"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
24
25
|
"dist",
|
|
25
26
|
"src/styles"
|
|
26
27
|
],
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@radix-ui/react-accordion": "^1.
|
|
29
|
-
"@radix-ui/react-alert-dialog": "^1.
|
|
30
|
-
"@radix-ui/react-aspect-ratio": "^1.
|
|
31
|
-
"@radix-ui/react-avatar": "^1.
|
|
32
|
-
"@radix-ui/react-checkbox": "^1.
|
|
33
|
-
"@radix-ui/react-collapsible": "^1.
|
|
34
|
-
"@radix-ui/react-context-menu": "^2.
|
|
35
|
-
"@radix-ui/react-dialog": "^1.
|
|
36
|
-
"@radix-ui/react-dropdown-menu": "^2.
|
|
37
|
-
"@radix-ui/react-hover-card": "^1.
|
|
38
|
-
"@radix-ui/react-label": "^2.
|
|
39
|
-
"@radix-ui/react-menubar": "^1.
|
|
40
|
-
"@radix-ui/react-navigation-menu": "^1.
|
|
41
|
-
"@radix-ui/react-popover": "^1.
|
|
42
|
-
"@radix-ui/react-progress": "^1.
|
|
43
|
-
"@radix-ui/react-radio-group": "^1.
|
|
44
|
-
"@radix-ui/react-scroll-area": "^1.
|
|
45
|
-
"@radix-ui/react-select": "^2.
|
|
46
|
-
"@radix-ui/react-separator": "^1.
|
|
47
|
-
"@radix-ui/react-slider": "^1.
|
|
48
|
-
"@radix-ui/react-slot": "^1.
|
|
49
|
-
"@radix-ui/react-switch": "^1.
|
|
50
|
-
"@radix-ui/react-tabs": "^1.
|
|
51
|
-
"@radix-ui/react-toast": "^1.
|
|
52
|
-
"@radix-ui/react-toggle": "^1.
|
|
53
|
-
"@radix-ui/react-tooltip": "^1.
|
|
29
|
+
"@radix-ui/react-accordion": "^1.2.12",
|
|
30
|
+
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
31
|
+
"@radix-ui/react-aspect-ratio": "^1.1.8",
|
|
32
|
+
"@radix-ui/react-avatar": "^1.1.11",
|
|
33
|
+
"@radix-ui/react-checkbox": "^1.3.3",
|
|
34
|
+
"@radix-ui/react-collapsible": "^1.1.12",
|
|
35
|
+
"@radix-ui/react-context-menu": "^2.2.16",
|
|
36
|
+
"@radix-ui/react-dialog": "^1.1.15",
|
|
37
|
+
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
38
|
+
"@radix-ui/react-hover-card": "^1.1.15",
|
|
39
|
+
"@radix-ui/react-label": "^2.1.8",
|
|
40
|
+
"@radix-ui/react-menubar": "^1.1.16",
|
|
41
|
+
"@radix-ui/react-navigation-menu": "^1.2.14",
|
|
42
|
+
"@radix-ui/react-popover": "^1.1.15",
|
|
43
|
+
"@radix-ui/react-progress": "^1.1.8",
|
|
44
|
+
"@radix-ui/react-radio-group": "^1.3.8",
|
|
45
|
+
"@radix-ui/react-scroll-area": "^1.2.10",
|
|
46
|
+
"@radix-ui/react-select": "^2.2.6",
|
|
47
|
+
"@radix-ui/react-separator": "^1.1.8",
|
|
48
|
+
"@radix-ui/react-slider": "^1.3.6",
|
|
49
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
50
|
+
"@radix-ui/react-switch": "^1.2.6",
|
|
51
|
+
"@radix-ui/react-tabs": "^1.1.13",
|
|
52
|
+
"@radix-ui/react-toast": "^1.2.15",
|
|
53
|
+
"@radix-ui/react-toggle": "^1.1.10",
|
|
54
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
54
55
|
"@tanstack/react-table": "^8.21.3",
|
|
55
56
|
"@tanstack/react-virtual": "^3.13.12",
|
|
56
57
|
"@types/prismjs": "^1.26.5",
|
|
@@ -62,28 +63,42 @@
|
|
|
62
63
|
"lucide-react": "^0.293.0",
|
|
63
64
|
"next-i18next": "^15.2.0",
|
|
64
65
|
"prismjs": "^1.30.0",
|
|
65
|
-
"react": "
|
|
66
|
+
"react": "^19.2.0",
|
|
66
67
|
"react-datepicker": "^8.7.0",
|
|
67
68
|
"react-day-picker": "^9.11.1",
|
|
68
|
-
"react-dom": "
|
|
69
|
+
"react-dom": "^19.2.0",
|
|
69
70
|
"react-i18next": "^13.2.0",
|
|
70
71
|
"tailwind-merge": "^3.3.1",
|
|
71
72
|
"tailwind-variants": "^0.1.18"
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
74
75
|
"next": ">=15.5.4",
|
|
75
|
-
"react": ">=19.
|
|
76
|
-
"react-dom": ">=
|
|
76
|
+
"react": ">=19.2.0",
|
|
77
|
+
"react-dom": ">=19.2.0",
|
|
77
78
|
"react-hook-form": "^7.0.0",
|
|
78
|
-
"xlsx": "
|
|
79
|
-
"jspdf": "
|
|
80
|
-
"jspdf-autotable": "
|
|
79
|
+
"xlsx": ">=0.18.0",
|
|
80
|
+
"jspdf": ">=2.5.0",
|
|
81
|
+
"jspdf-autotable": ">=3.5.0"
|
|
82
|
+
},
|
|
83
|
+
"peerDependenciesMeta": {
|
|
84
|
+
"xlsx": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"jspdf": {
|
|
88
|
+
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"jspdf-autotable": {
|
|
91
|
+
"optional": true
|
|
92
|
+
},
|
|
93
|
+
"react-hook-form": {
|
|
94
|
+
"optional": true
|
|
95
|
+
}
|
|
81
96
|
},
|
|
82
97
|
"devDependencies": {
|
|
83
98
|
"@chromatic-com/storybook": "^4.1.1",
|
|
84
|
-
"@testing-library/jest-dom": "^6.
|
|
85
|
-
"@testing-library/react": "^
|
|
86
|
-
"@testing-library/user-event": "^14.
|
|
99
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
100
|
+
"@testing-library/react": "^16.2.0",
|
|
101
|
+
"@testing-library/user-event": "^14.6.1",
|
|
87
102
|
"@types/node": "^24.7.2",
|
|
88
103
|
"@types/react": "^18.3.26",
|
|
89
104
|
"@types/react-datepicker": "^7.0.0",
|
|
@@ -113,6 +128,9 @@
|
|
|
113
128
|
"test": "vitest --config vitest.config.unit.ts",
|
|
114
129
|
"test:watch": "vitest --config vitest.config.unit.ts --watch",
|
|
115
130
|
"test:coverage": "vitest --config vitest.config.unit.ts --coverage",
|
|
116
|
-
"test:ui": "vitest --config vitest.config.unit.ts --ui"
|
|
131
|
+
"test:ui": "vitest --config vitest.config.unit.ts --ui",
|
|
132
|
+
"release": "./scripts/publish.sh patch",
|
|
133
|
+
"release:minor": "./scripts/publish.sh minor",
|
|
134
|
+
"release:major": "./scripts/publish.sh major"
|
|
117
135
|
}
|
|
118
136
|
}
|