@gaddario98/react-core 2.0.2 → 2.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/dist/auth/index.d.ts +7 -1
- package/dist/auth/index.js +9 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +9 -1
- package/dist/auth/index.mjs.map +1 -1
- package/dist/form/index.d.ts +236 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -2
- package/dist/index.mjs.map +1 -1
- package/dist/localization/index.d.ts +155 -0
- package/dist/notifications/index.d.ts +37 -0
- package/dist/pages/index.d.ts +1827 -0
- package/dist/queries/index.d.ts +372 -0
- package/dist/state/index.d.ts +28 -0
- package/package.json +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as _gaddario98_react_state from '@gaddario98/react-state';
|
|
2
|
+
|
|
3
|
+
type Locale = string;
|
|
4
|
+
type TranslationResources = Record<string, any>;
|
|
5
|
+
/**
|
|
6
|
+
* Opzioni di formattazione per i diversi tipi di valori
|
|
7
|
+
*/
|
|
8
|
+
interface FormatOptions {
|
|
9
|
+
number?: Intl.NumberFormatOptions;
|
|
10
|
+
date?: Intl.DateTimeFormatOptions;
|
|
11
|
+
currency?: Intl.NumberFormatOptions & {
|
|
12
|
+
currency?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Opzioni per la traduzione con supporto parametri avanzati
|
|
17
|
+
*/
|
|
18
|
+
interface TranslationOptions {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Opzioni di formattazione per i parametri specifici
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* t('welcome', {
|
|
27
|
+
* price: 1234.56,
|
|
28
|
+
* formatOptions: {
|
|
29
|
+
* price: {
|
|
30
|
+
* currency: { currency: 'EUR', minimumFractionDigits: 2 }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* })
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
formatOptions?: Record<string, FormatOptions>;
|
|
37
|
+
ns?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Funzione di traduzione con supporto parametri avanzati
|
|
41
|
+
*
|
|
42
|
+
* @example Interpolazione semplice
|
|
43
|
+
* ```ts
|
|
44
|
+
* t('welcome', { name: 'Mario' })
|
|
45
|
+
* // "Benvenuto {{name}}" -> "Benvenuto Mario"
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example Formattazione numeri
|
|
49
|
+
* ```ts
|
|
50
|
+
* t('items_count', { count: 1000 })
|
|
51
|
+
* // "Hai {{count, number}} elementi" -> "Hai 1,000 elementi"
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @example Formattazione date
|
|
55
|
+
* ```ts
|
|
56
|
+
* t('last_login', { date: new Date() })
|
|
57
|
+
* // "Ultimo accesso: {{date, date}}" -> "Ultimo accesso: 15/12/2025"
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example Formattazione valuta
|
|
61
|
+
* ```ts
|
|
62
|
+
* t('total', {
|
|
63
|
+
* price: 99.99,
|
|
64
|
+
* formatOptions: {
|
|
65
|
+
* price: { currency: { currency: 'EUR' } }
|
|
66
|
+
* }
|
|
67
|
+
* })
|
|
68
|
+
* // "Totale: {{price, currency}}" -> "Totale: €99.99"
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @example Pluralizzazione
|
|
72
|
+
* ```ts
|
|
73
|
+
* t('items', { count: 0 })
|
|
74
|
+
* // "{{count, plural, =0{Nessun elemento} one{Un elemento} other{# elementi}}}"
|
|
75
|
+
* // -> "Nessun elemento"
|
|
76
|
+
*
|
|
77
|
+
* t('items', { count: 1 })
|
|
78
|
+
* // -> "Un elemento"
|
|
79
|
+
*
|
|
80
|
+
* t('items', { count: 5 })
|
|
81
|
+
* // -> "5 elementi"
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example Selezione
|
|
85
|
+
* ```ts
|
|
86
|
+
* t('greeting', { gender: 'male' })
|
|
87
|
+
* // "{{gender, select, male{Benvenuto} female{Benvenuta} other{Benvenuto/a}}}"
|
|
88
|
+
* // -> "Benvenuto"
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
type TranslateFunction = (key: string, options?: TranslationOptions) => string;
|
|
92
|
+
interface I18nConfig {
|
|
93
|
+
defaultLocale: Locale;
|
|
94
|
+
supportedLocales: Array<Locale>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface LocalizationConfigProps {
|
|
98
|
+
currentLocale: Locale;
|
|
99
|
+
locales: Record<Locale, TranslationResources>;
|
|
100
|
+
}
|
|
101
|
+
declare const localizationConfigAtom: _gaddario98_react_state.PrimitiveAtom<LocalizationConfigProps>;
|
|
102
|
+
declare const useLocalizationConfigValue: () => LocalizationConfigProps;
|
|
103
|
+
declare const useLocalizationConfigState: () => [LocalizationConfigProps, (value: LocalizationConfigProps) => void];
|
|
104
|
+
declare const useLocalizationConfigReset: () => () => void;
|
|
105
|
+
/**
|
|
106
|
+
* Hook per gestire le operazioni di localization
|
|
107
|
+
*/
|
|
108
|
+
declare const useLocalizationActions: () => {
|
|
109
|
+
/**
|
|
110
|
+
* Aggiunge o aggiorna una locale con le sue risorse
|
|
111
|
+
*/
|
|
112
|
+
addLocale: (locale: Locale, resources: TranslationResources) => void;
|
|
113
|
+
/**
|
|
114
|
+
* Switch alla locale specificata
|
|
115
|
+
*/
|
|
116
|
+
switchLocale: (locale: Locale) => void;
|
|
117
|
+
/**
|
|
118
|
+
* Inizializza con una locale di default
|
|
119
|
+
*/
|
|
120
|
+
initializeLocale: (locale: Locale, resources: TranslationResources) => void;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Funzione core per risolvere una traduzione.
|
|
125
|
+
*/
|
|
126
|
+
declare const resolveTranslation: (key: string, resources: TranslationResources, options?: TranslationOptions, locale?: string) => string;
|
|
127
|
+
|
|
128
|
+
declare const useTranslation: (_ns?: string) => {
|
|
129
|
+
t: TranslateFunction;
|
|
130
|
+
locale: Locale;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Crea un'istanza di traduzione per l'uso lato server (o fuori dai componenti React).
|
|
135
|
+
*/
|
|
136
|
+
declare const createServerTranslator: (resources: TranslationResources, locale?: Locale) => {
|
|
137
|
+
t: TranslateFunction;
|
|
138
|
+
locale: Locale;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
type TranslationFunction = (key: string, options?: TranslationOptions) => string;
|
|
142
|
+
/**
|
|
143
|
+
* Hook per tradurre testi che si adatta al sistema di traduzione interno.
|
|
144
|
+
* Wrapper di retro-compatibilità per useTranslation.
|
|
145
|
+
*
|
|
146
|
+
* @param ns - Namespace opzionale (ignorato nella nuova implementazione)
|
|
147
|
+
* @returns Un oggetto con la funzione traslateText (e alias t)
|
|
148
|
+
*/
|
|
149
|
+
declare const useTranslatedText: (ns?: string) => {
|
|
150
|
+
traslateText: (text: string, options?: TranslationOptions) => string;
|
|
151
|
+
t: (text: string, options?: TranslationOptions) => string;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export { createServerTranslator, localizationConfigAtom, resolveTranslation, useLocalizationActions, useLocalizationConfigReset, useLocalizationConfigState, useLocalizationConfigValue, useTranslatedText, useTranslation };
|
|
155
|
+
export type { FormatOptions, I18nConfig, Locale, LocalizationConfigProps, TranslateFunction, TranslationFunction, TranslationOptions, TranslationResources };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as _gaddario98_react_state from '@gaddario98/react-state';
|
|
2
|
+
|
|
3
|
+
interface NotificationMessage {
|
|
4
|
+
id: string;
|
|
5
|
+
message: string;
|
|
6
|
+
type: 'success' | 'error' | 'info' | 'warning';
|
|
7
|
+
autoHideDuration?: number;
|
|
8
|
+
textTransOption?: Record<string, unknown>;
|
|
9
|
+
ns?: string;
|
|
10
|
+
}
|
|
11
|
+
type TypeNotification = 'like' | 'message' | 'comments' | 'follow';
|
|
12
|
+
interface UserNotification {
|
|
13
|
+
uid: string;
|
|
14
|
+
type: TypeNotification;
|
|
15
|
+
postId?: string;
|
|
16
|
+
typePost?: string;
|
|
17
|
+
token: string;
|
|
18
|
+
message?: string;
|
|
19
|
+
data?: Date;
|
|
20
|
+
read: boolean;
|
|
21
|
+
notificationId: string;
|
|
22
|
+
nickname?: string;
|
|
23
|
+
titlePost?: string;
|
|
24
|
+
}
|
|
25
|
+
type NotificationConfig = Partial<Omit<NotificationMessage, 'id'>>;
|
|
26
|
+
|
|
27
|
+
declare const useNotification: (ns?: string) => {
|
|
28
|
+
showNotification: (notification: Omit<NotificationMessage, "id">) => void;
|
|
29
|
+
clearNotification: () => void;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
declare const notificationAtom: _gaddario98_react_state.PrimitiveAtom<NotificationMessage | null>;
|
|
33
|
+
declare const useNotificationValue: () => NotificationMessage | null;
|
|
34
|
+
declare const useNotificationState: () => [NotificationMessage | null, (value: NotificationMessage | null) => void];
|
|
35
|
+
|
|
36
|
+
export { notificationAtom, useNotification, useNotificationState, useNotificationValue };
|
|
37
|
+
export type { NotificationConfig, NotificationMessage, UserNotification };
|