@abpjs/language-management 0.7.2 → 2.0.0
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/index.d.mts +124 -8
- package/dist/index.d.ts +124 -8
- package/dist/index.js +179 -0
- package/dist/index.mjs +178 -0
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Language Management Models
|
|
6
|
-
* Translated from @volo/abp.ng.language-management
|
|
6
|
+
* Translated from @volo/abp.ng.language-management v2.0.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -121,7 +121,7 @@ declare const LANGUAGE_MANAGEMENT_ROUTES: {
|
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* Language Management Service
|
|
124
|
-
* Translated from @volo/abp.ng.language-management
|
|
124
|
+
* Translated from @volo/abp.ng.language-management v2.0.0
|
|
125
125
|
*
|
|
126
126
|
* Provides API operations for managing languages and language texts (localization).
|
|
127
127
|
*/
|
|
@@ -130,7 +130,7 @@ declare const LANGUAGE_MANAGEMENT_ROUTES: {
|
|
|
130
130
|
* Service for managing language-related API operations.
|
|
131
131
|
* Handles languages, cultures, resources, and language texts CRUD operations.
|
|
132
132
|
*
|
|
133
|
-
* @since 0.
|
|
133
|
+
* @since 2.0.0
|
|
134
134
|
*/
|
|
135
135
|
declare class LanguageManagementService {
|
|
136
136
|
private rest;
|
|
@@ -208,6 +208,122 @@ declare class LanguageManagementService {
|
|
|
208
208
|
restoreLanguageTextByName(params: LanguageManagement.LanguageTextRequestByNameParams): Promise<void>;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Language Management State Service
|
|
213
|
+
* Translated from @volo/abp.ng.language-management v2.0.0
|
|
214
|
+
*
|
|
215
|
+
* Provides a stateful facade over language management operations,
|
|
216
|
+
* maintaining internal state that mirrors the Angular NGXS store pattern.
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* State service for language management operations.
|
|
221
|
+
* Provides dispatch methods that execute API operations and update internal state,
|
|
222
|
+
* mirroring the Angular NGXS store pattern.
|
|
223
|
+
*
|
|
224
|
+
* @since 2.0.0
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```tsx
|
|
228
|
+
* const stateService = new LanguageManagementStateService(restService);
|
|
229
|
+
*
|
|
230
|
+
* // Dispatch to fetch languages
|
|
231
|
+
* await stateService.dispatchGetLanguages({ maxResultCount: 10 });
|
|
232
|
+
*
|
|
233
|
+
* // Access the result
|
|
234
|
+
* const languages = stateService.getLanguages();
|
|
235
|
+
* const total = stateService.getLanguagesTotalCount();
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
declare class LanguageManagementStateService {
|
|
239
|
+
private service;
|
|
240
|
+
private state;
|
|
241
|
+
constructor(rest: RestService);
|
|
242
|
+
/**
|
|
243
|
+
* Get the current list of languages from state
|
|
244
|
+
*/
|
|
245
|
+
getLanguages(): LanguageManagement.Language[];
|
|
246
|
+
/**
|
|
247
|
+
* Get the total count of languages from state
|
|
248
|
+
*/
|
|
249
|
+
getLanguagesTotalCount(): number;
|
|
250
|
+
/**
|
|
251
|
+
* Get the current list of language texts from state
|
|
252
|
+
*/
|
|
253
|
+
getLanguageTexts(): LanguageManagement.LanguageText[];
|
|
254
|
+
/**
|
|
255
|
+
* Get the total count of language texts from state
|
|
256
|
+
*/
|
|
257
|
+
getLanguageTextsTotalCount(): number;
|
|
258
|
+
/**
|
|
259
|
+
* Get the current list of cultures from state
|
|
260
|
+
*/
|
|
261
|
+
getCultures(): LanguageManagement.Culture[];
|
|
262
|
+
/**
|
|
263
|
+
* Get the current list of resources from state
|
|
264
|
+
*/
|
|
265
|
+
getResources(): LanguageManagement.Resource[];
|
|
266
|
+
/**
|
|
267
|
+
* Dispatch action to fetch languages with optional pagination
|
|
268
|
+
* @param params - Optional query parameters for pagination and filtering
|
|
269
|
+
* @returns Promise with the language response
|
|
270
|
+
*/
|
|
271
|
+
dispatchGetLanguages(params?: ABP.PageQueryParams): Promise<LanguageManagement.LanguageResponse>;
|
|
272
|
+
/**
|
|
273
|
+
* Dispatch action to fetch a language by ID
|
|
274
|
+
* @param id - The language ID
|
|
275
|
+
* @returns Promise with the language
|
|
276
|
+
*/
|
|
277
|
+
dispatchGetLanguageById(id: string): Promise<LanguageManagement.Language>;
|
|
278
|
+
/**
|
|
279
|
+
* Dispatch action to create or update a language
|
|
280
|
+
* @param body - The language data
|
|
281
|
+
* @param id - Optional ID for update (if not provided, creates new)
|
|
282
|
+
* @returns Promise with the created/updated language
|
|
283
|
+
*/
|
|
284
|
+
dispatchCreateUpdateLanguage(body: LanguageManagement.CreateLanguageInput | LanguageManagement.UpdateLanguageInput, id?: string): Promise<LanguageManagement.Language>;
|
|
285
|
+
/**
|
|
286
|
+
* Dispatch action to delete a language
|
|
287
|
+
* @param id - The language ID to delete
|
|
288
|
+
* @returns Promise resolving when complete (returns null per v2.0.0 spec)
|
|
289
|
+
*/
|
|
290
|
+
dispatchDeleteLanguage(id: string): Promise<null>;
|
|
291
|
+
/**
|
|
292
|
+
* Dispatch action to set a language as the default
|
|
293
|
+
* @param id - The language ID to set as default
|
|
294
|
+
* @returns Promise resolving when complete
|
|
295
|
+
*/
|
|
296
|
+
dispatchSetAsDefaultLanguage(id: string): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* Dispatch action to fetch language texts with filters
|
|
299
|
+
* @param params - Query parameters including resource name, cultures, and filter options
|
|
300
|
+
* @returns Promise with the language text response
|
|
301
|
+
*/
|
|
302
|
+
dispatchGetLanguageTexts(params: LanguageManagement.LanguageTextQueryParams): Promise<LanguageManagement.LanguageTextResponse>;
|
|
303
|
+
/**
|
|
304
|
+
* Dispatch action to update a language text by name
|
|
305
|
+
* @param params - Parameters including the new value
|
|
306
|
+
* @returns Promise with the updated language text
|
|
307
|
+
*/
|
|
308
|
+
dispatchUpdateLanguageTextByName(params: LanguageManagement.LanguageTextUpdateByNameParams): Promise<LanguageManagement.LanguageText>;
|
|
309
|
+
/**
|
|
310
|
+
* Dispatch action to restore a language text to its default value
|
|
311
|
+
* @param params - Parameters identifying the language text
|
|
312
|
+
* @returns Promise resolving when complete
|
|
313
|
+
*/
|
|
314
|
+
dispatchRestoreLanguageTextByName(params: LanguageManagement.LanguageTextRequestByNameParams): Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Dispatch action to fetch available cultures
|
|
317
|
+
* @returns Promise with the list of cultures
|
|
318
|
+
*/
|
|
319
|
+
dispatchGetLanguageCultures(): Promise<LanguageManagement.Culture[]>;
|
|
320
|
+
/**
|
|
321
|
+
* Dispatch action to fetch available localization resources
|
|
322
|
+
* @returns Promise with the list of resources
|
|
323
|
+
*/
|
|
324
|
+
dispatchGetLanguageResources(): Promise<LanguageManagement.Resource[]>;
|
|
325
|
+
}
|
|
326
|
+
|
|
211
327
|
/**
|
|
212
328
|
* Sort order type for language lists
|
|
213
329
|
*/
|
|
@@ -410,7 +526,7 @@ declare function useLanguageTexts(): UseLanguageTextsReturn;
|
|
|
410
526
|
|
|
411
527
|
/**
|
|
412
528
|
* Props for LanguagesComponent
|
|
413
|
-
* @since 0.
|
|
529
|
+
* @since 2.0.0
|
|
414
530
|
*/
|
|
415
531
|
interface LanguagesComponentProps {
|
|
416
532
|
/** Optional callback when a language is created */
|
|
@@ -426,7 +542,7 @@ interface LanguagesComponentProps {
|
|
|
426
542
|
* This is the React equivalent of Angular's LanguagesComponent.
|
|
427
543
|
* It displays a table of languages with CRUD operations.
|
|
428
544
|
*
|
|
429
|
-
* @since 0.
|
|
545
|
+
* @since 2.0.0
|
|
430
546
|
*
|
|
431
547
|
* @example
|
|
432
548
|
* ```tsx
|
|
@@ -444,7 +560,7 @@ declare function LanguagesComponent({ onLanguageCreated, onLanguageUpdated, onLa
|
|
|
444
560
|
|
|
445
561
|
/**
|
|
446
562
|
* Props for LanguageTextsComponent
|
|
447
|
-
* @since 0.
|
|
563
|
+
* @since 2.0.0
|
|
448
564
|
*/
|
|
449
565
|
interface LanguageTextsComponentProps {
|
|
450
566
|
/** Optional callback when a language text is updated */
|
|
@@ -458,7 +574,7 @@ interface LanguageTextsComponentProps {
|
|
|
458
574
|
* This is the React equivalent of Angular's LanguageTextsComponent.
|
|
459
575
|
* It displays a table of language texts with editing capabilities.
|
|
460
576
|
*
|
|
461
|
-
* @since 0.
|
|
577
|
+
* @since 2.0.0
|
|
462
578
|
*
|
|
463
579
|
* @example
|
|
464
580
|
* ```tsx
|
|
@@ -473,4 +589,4 @@ interface LanguageTextsComponentProps {
|
|
|
473
589
|
*/
|
|
474
590
|
declare function LanguageTextsComponent({ onLanguageTextUpdated, onLanguageTextRestored, }: LanguageTextsComponentProps): React.ReactElement;
|
|
475
591
|
|
|
476
|
-
export { LANGUAGE_MANAGEMENT_ROUTES, LanguageManagement, LanguageManagementService, type LanguageOperationResult, type LanguageTextOperationResult, LanguageTextsComponent, type LanguageTextsComponentProps, LanguagesComponent, type LanguagesComponentProps, type SortOrder$1 as SortOrder, type UseLanguageTextsReturn, type UseLanguagesReturn, useLanguageTexts, useLanguages };
|
|
592
|
+
export { LANGUAGE_MANAGEMENT_ROUTES, LanguageManagement, LanguageManagementService, LanguageManagementStateService, type LanguageOperationResult, type LanguageTextOperationResult, LanguageTextsComponent, type LanguageTextsComponentProps, LanguagesComponent, type LanguagesComponentProps, type SortOrder$1 as SortOrder, type UseLanguageTextsReturn, type UseLanguagesReturn, useLanguageTexts, useLanguages };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Language Management Models
|
|
6
|
-
* Translated from @volo/abp.ng.language-management
|
|
6
|
+
* Translated from @volo/abp.ng.language-management v2.0.0
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -121,7 +121,7 @@ declare const LANGUAGE_MANAGEMENT_ROUTES: {
|
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* Language Management Service
|
|
124
|
-
* Translated from @volo/abp.ng.language-management
|
|
124
|
+
* Translated from @volo/abp.ng.language-management v2.0.0
|
|
125
125
|
*
|
|
126
126
|
* Provides API operations for managing languages and language texts (localization).
|
|
127
127
|
*/
|
|
@@ -130,7 +130,7 @@ declare const LANGUAGE_MANAGEMENT_ROUTES: {
|
|
|
130
130
|
* Service for managing language-related API operations.
|
|
131
131
|
* Handles languages, cultures, resources, and language texts CRUD operations.
|
|
132
132
|
*
|
|
133
|
-
* @since 0.
|
|
133
|
+
* @since 2.0.0
|
|
134
134
|
*/
|
|
135
135
|
declare class LanguageManagementService {
|
|
136
136
|
private rest;
|
|
@@ -208,6 +208,122 @@ declare class LanguageManagementService {
|
|
|
208
208
|
restoreLanguageTextByName(params: LanguageManagement.LanguageTextRequestByNameParams): Promise<void>;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Language Management State Service
|
|
213
|
+
* Translated from @volo/abp.ng.language-management v2.0.0
|
|
214
|
+
*
|
|
215
|
+
* Provides a stateful facade over language management operations,
|
|
216
|
+
* maintaining internal state that mirrors the Angular NGXS store pattern.
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* State service for language management operations.
|
|
221
|
+
* Provides dispatch methods that execute API operations and update internal state,
|
|
222
|
+
* mirroring the Angular NGXS store pattern.
|
|
223
|
+
*
|
|
224
|
+
* @since 2.0.0
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```tsx
|
|
228
|
+
* const stateService = new LanguageManagementStateService(restService);
|
|
229
|
+
*
|
|
230
|
+
* // Dispatch to fetch languages
|
|
231
|
+
* await stateService.dispatchGetLanguages({ maxResultCount: 10 });
|
|
232
|
+
*
|
|
233
|
+
* // Access the result
|
|
234
|
+
* const languages = stateService.getLanguages();
|
|
235
|
+
* const total = stateService.getLanguagesTotalCount();
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
declare class LanguageManagementStateService {
|
|
239
|
+
private service;
|
|
240
|
+
private state;
|
|
241
|
+
constructor(rest: RestService);
|
|
242
|
+
/**
|
|
243
|
+
* Get the current list of languages from state
|
|
244
|
+
*/
|
|
245
|
+
getLanguages(): LanguageManagement.Language[];
|
|
246
|
+
/**
|
|
247
|
+
* Get the total count of languages from state
|
|
248
|
+
*/
|
|
249
|
+
getLanguagesTotalCount(): number;
|
|
250
|
+
/**
|
|
251
|
+
* Get the current list of language texts from state
|
|
252
|
+
*/
|
|
253
|
+
getLanguageTexts(): LanguageManagement.LanguageText[];
|
|
254
|
+
/**
|
|
255
|
+
* Get the total count of language texts from state
|
|
256
|
+
*/
|
|
257
|
+
getLanguageTextsTotalCount(): number;
|
|
258
|
+
/**
|
|
259
|
+
* Get the current list of cultures from state
|
|
260
|
+
*/
|
|
261
|
+
getCultures(): LanguageManagement.Culture[];
|
|
262
|
+
/**
|
|
263
|
+
* Get the current list of resources from state
|
|
264
|
+
*/
|
|
265
|
+
getResources(): LanguageManagement.Resource[];
|
|
266
|
+
/**
|
|
267
|
+
* Dispatch action to fetch languages with optional pagination
|
|
268
|
+
* @param params - Optional query parameters for pagination and filtering
|
|
269
|
+
* @returns Promise with the language response
|
|
270
|
+
*/
|
|
271
|
+
dispatchGetLanguages(params?: ABP.PageQueryParams): Promise<LanguageManagement.LanguageResponse>;
|
|
272
|
+
/**
|
|
273
|
+
* Dispatch action to fetch a language by ID
|
|
274
|
+
* @param id - The language ID
|
|
275
|
+
* @returns Promise with the language
|
|
276
|
+
*/
|
|
277
|
+
dispatchGetLanguageById(id: string): Promise<LanguageManagement.Language>;
|
|
278
|
+
/**
|
|
279
|
+
* Dispatch action to create or update a language
|
|
280
|
+
* @param body - The language data
|
|
281
|
+
* @param id - Optional ID for update (if not provided, creates new)
|
|
282
|
+
* @returns Promise with the created/updated language
|
|
283
|
+
*/
|
|
284
|
+
dispatchCreateUpdateLanguage(body: LanguageManagement.CreateLanguageInput | LanguageManagement.UpdateLanguageInput, id?: string): Promise<LanguageManagement.Language>;
|
|
285
|
+
/**
|
|
286
|
+
* Dispatch action to delete a language
|
|
287
|
+
* @param id - The language ID to delete
|
|
288
|
+
* @returns Promise resolving when complete (returns null per v2.0.0 spec)
|
|
289
|
+
*/
|
|
290
|
+
dispatchDeleteLanguage(id: string): Promise<null>;
|
|
291
|
+
/**
|
|
292
|
+
* Dispatch action to set a language as the default
|
|
293
|
+
* @param id - The language ID to set as default
|
|
294
|
+
* @returns Promise resolving when complete
|
|
295
|
+
*/
|
|
296
|
+
dispatchSetAsDefaultLanguage(id: string): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* Dispatch action to fetch language texts with filters
|
|
299
|
+
* @param params - Query parameters including resource name, cultures, and filter options
|
|
300
|
+
* @returns Promise with the language text response
|
|
301
|
+
*/
|
|
302
|
+
dispatchGetLanguageTexts(params: LanguageManagement.LanguageTextQueryParams): Promise<LanguageManagement.LanguageTextResponse>;
|
|
303
|
+
/**
|
|
304
|
+
* Dispatch action to update a language text by name
|
|
305
|
+
* @param params - Parameters including the new value
|
|
306
|
+
* @returns Promise with the updated language text
|
|
307
|
+
*/
|
|
308
|
+
dispatchUpdateLanguageTextByName(params: LanguageManagement.LanguageTextUpdateByNameParams): Promise<LanguageManagement.LanguageText>;
|
|
309
|
+
/**
|
|
310
|
+
* Dispatch action to restore a language text to its default value
|
|
311
|
+
* @param params - Parameters identifying the language text
|
|
312
|
+
* @returns Promise resolving when complete
|
|
313
|
+
*/
|
|
314
|
+
dispatchRestoreLanguageTextByName(params: LanguageManagement.LanguageTextRequestByNameParams): Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Dispatch action to fetch available cultures
|
|
317
|
+
* @returns Promise with the list of cultures
|
|
318
|
+
*/
|
|
319
|
+
dispatchGetLanguageCultures(): Promise<LanguageManagement.Culture[]>;
|
|
320
|
+
/**
|
|
321
|
+
* Dispatch action to fetch available localization resources
|
|
322
|
+
* @returns Promise with the list of resources
|
|
323
|
+
*/
|
|
324
|
+
dispatchGetLanguageResources(): Promise<LanguageManagement.Resource[]>;
|
|
325
|
+
}
|
|
326
|
+
|
|
211
327
|
/**
|
|
212
328
|
* Sort order type for language lists
|
|
213
329
|
*/
|
|
@@ -410,7 +526,7 @@ declare function useLanguageTexts(): UseLanguageTextsReturn;
|
|
|
410
526
|
|
|
411
527
|
/**
|
|
412
528
|
* Props for LanguagesComponent
|
|
413
|
-
* @since 0.
|
|
529
|
+
* @since 2.0.0
|
|
414
530
|
*/
|
|
415
531
|
interface LanguagesComponentProps {
|
|
416
532
|
/** Optional callback when a language is created */
|
|
@@ -426,7 +542,7 @@ interface LanguagesComponentProps {
|
|
|
426
542
|
* This is the React equivalent of Angular's LanguagesComponent.
|
|
427
543
|
* It displays a table of languages with CRUD operations.
|
|
428
544
|
*
|
|
429
|
-
* @since 0.
|
|
545
|
+
* @since 2.0.0
|
|
430
546
|
*
|
|
431
547
|
* @example
|
|
432
548
|
* ```tsx
|
|
@@ -444,7 +560,7 @@ declare function LanguagesComponent({ onLanguageCreated, onLanguageUpdated, onLa
|
|
|
444
560
|
|
|
445
561
|
/**
|
|
446
562
|
* Props for LanguageTextsComponent
|
|
447
|
-
* @since 0.
|
|
563
|
+
* @since 2.0.0
|
|
448
564
|
*/
|
|
449
565
|
interface LanguageTextsComponentProps {
|
|
450
566
|
/** Optional callback when a language text is updated */
|
|
@@ -458,7 +574,7 @@ interface LanguageTextsComponentProps {
|
|
|
458
574
|
* This is the React equivalent of Angular's LanguageTextsComponent.
|
|
459
575
|
* It displays a table of language texts with editing capabilities.
|
|
460
576
|
*
|
|
461
|
-
* @since 0.
|
|
577
|
+
* @since 2.0.0
|
|
462
578
|
*
|
|
463
579
|
* @example
|
|
464
580
|
* ```tsx
|
|
@@ -473,4 +589,4 @@ interface LanguageTextsComponentProps {
|
|
|
473
589
|
*/
|
|
474
590
|
declare function LanguageTextsComponent({ onLanguageTextUpdated, onLanguageTextRestored, }: LanguageTextsComponentProps): React.ReactElement;
|
|
475
591
|
|
|
476
|
-
export { LANGUAGE_MANAGEMENT_ROUTES, LanguageManagement, LanguageManagementService, type LanguageOperationResult, type LanguageTextOperationResult, LanguageTextsComponent, type LanguageTextsComponentProps, LanguagesComponent, type LanguagesComponentProps, type SortOrder$1 as SortOrder, type UseLanguageTextsReturn, type UseLanguagesReturn, useLanguageTexts, useLanguages };
|
|
592
|
+
export { LANGUAGE_MANAGEMENT_ROUTES, LanguageManagement, LanguageManagementService, LanguageManagementStateService, type LanguageOperationResult, type LanguageTextOperationResult, LanguageTextsComponent, type LanguageTextsComponentProps, LanguagesComponent, type LanguagesComponentProps, type SortOrder$1 as SortOrder, type UseLanguageTextsReturn, type UseLanguagesReturn, useLanguageTexts, useLanguages };
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
LANGUAGE_MANAGEMENT_ROUTES: () => LANGUAGE_MANAGEMENT_ROUTES,
|
|
24
24
|
LanguageManagementService: () => LanguageManagementService,
|
|
25
|
+
LanguageManagementStateService: () => LanguageManagementStateService,
|
|
25
26
|
LanguageTextsComponent: () => LanguageTextsComponent,
|
|
26
27
|
LanguagesComponent: () => LanguagesComponent,
|
|
27
28
|
useLanguageTexts: () => useLanguageTexts,
|
|
@@ -211,6 +212,183 @@ var LanguageManagementService = class {
|
|
|
211
212
|
}
|
|
212
213
|
};
|
|
213
214
|
|
|
215
|
+
// src/services/language-management-state.service.ts
|
|
216
|
+
var LanguageManagementStateService = class {
|
|
217
|
+
constructor(rest) {
|
|
218
|
+
this.state = {
|
|
219
|
+
languageResponse: { items: [], totalCount: 0 },
|
|
220
|
+
languageTextsResponse: { items: [], totalCount: 0 },
|
|
221
|
+
selectedItem: null,
|
|
222
|
+
cultures: [],
|
|
223
|
+
resources: []
|
|
224
|
+
};
|
|
225
|
+
this.service = new LanguageManagementService(rest);
|
|
226
|
+
}
|
|
227
|
+
// ========================
|
|
228
|
+
// Getter Methods
|
|
229
|
+
// ========================
|
|
230
|
+
/**
|
|
231
|
+
* Get the current list of languages from state
|
|
232
|
+
*/
|
|
233
|
+
getLanguages() {
|
|
234
|
+
return this.state.languageResponse?.items ?? [];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get the total count of languages from state
|
|
238
|
+
*/
|
|
239
|
+
getLanguagesTotalCount() {
|
|
240
|
+
return this.state.languageResponse?.totalCount ?? 0;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Get the current list of language texts from state
|
|
244
|
+
*/
|
|
245
|
+
getLanguageTexts() {
|
|
246
|
+
return this.state.languageTextsResponse?.items ?? [];
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Get the total count of language texts from state
|
|
250
|
+
*/
|
|
251
|
+
getLanguageTextsTotalCount() {
|
|
252
|
+
return this.state.languageTextsResponse?.totalCount ?? 0;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Get the current list of cultures from state
|
|
256
|
+
*/
|
|
257
|
+
getCultures() {
|
|
258
|
+
return this.state.cultures ?? [];
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Get the current list of resources from state
|
|
262
|
+
*/
|
|
263
|
+
getResources() {
|
|
264
|
+
return this.state.resources ?? [];
|
|
265
|
+
}
|
|
266
|
+
// ========================
|
|
267
|
+
// Language Dispatch Methods
|
|
268
|
+
// ========================
|
|
269
|
+
/**
|
|
270
|
+
* Dispatch action to fetch languages with optional pagination
|
|
271
|
+
* @param params - Optional query parameters for pagination and filtering
|
|
272
|
+
* @returns Promise with the language response
|
|
273
|
+
*/
|
|
274
|
+
async dispatchGetLanguages(params = {}) {
|
|
275
|
+
const response = await this.service.getLanguages(params);
|
|
276
|
+
this.state = {
|
|
277
|
+
...this.state,
|
|
278
|
+
languageResponse: response
|
|
279
|
+
};
|
|
280
|
+
return response;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Dispatch action to fetch a language by ID
|
|
284
|
+
* @param id - The language ID
|
|
285
|
+
* @returns Promise with the language
|
|
286
|
+
*/
|
|
287
|
+
async dispatchGetLanguageById(id) {
|
|
288
|
+
const language = await this.service.getLanguageById(id);
|
|
289
|
+
this.state = {
|
|
290
|
+
...this.state,
|
|
291
|
+
selectedItem: language
|
|
292
|
+
};
|
|
293
|
+
return language;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Dispatch action to create or update a language
|
|
297
|
+
* @param body - The language data
|
|
298
|
+
* @param id - Optional ID for update (if not provided, creates new)
|
|
299
|
+
* @returns Promise with the created/updated language
|
|
300
|
+
*/
|
|
301
|
+
async dispatchCreateUpdateLanguage(body, id) {
|
|
302
|
+
let result;
|
|
303
|
+
if (id) {
|
|
304
|
+
result = await this.service.updateLanguage(id, body);
|
|
305
|
+
} else {
|
|
306
|
+
result = await this.service.createLanguage(body);
|
|
307
|
+
}
|
|
308
|
+
await this.dispatchGetLanguages();
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Dispatch action to delete a language
|
|
313
|
+
* @param id - The language ID to delete
|
|
314
|
+
* @returns Promise resolving when complete (returns null per v2.0.0 spec)
|
|
315
|
+
*/
|
|
316
|
+
async dispatchDeleteLanguage(id) {
|
|
317
|
+
await this.service.deleteLanguage(id);
|
|
318
|
+
await this.dispatchGetLanguages();
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Dispatch action to set a language as the default
|
|
323
|
+
* @param id - The language ID to set as default
|
|
324
|
+
* @returns Promise resolving when complete
|
|
325
|
+
*/
|
|
326
|
+
async dispatchSetAsDefaultLanguage(id) {
|
|
327
|
+
await this.service.setAsDefaultLanguage(id);
|
|
328
|
+
await this.dispatchGetLanguages();
|
|
329
|
+
}
|
|
330
|
+
// ========================
|
|
331
|
+
// Language Text Dispatch Methods
|
|
332
|
+
// ========================
|
|
333
|
+
/**
|
|
334
|
+
* Dispatch action to fetch language texts with filters
|
|
335
|
+
* @param params - Query parameters including resource name, cultures, and filter options
|
|
336
|
+
* @returns Promise with the language text response
|
|
337
|
+
*/
|
|
338
|
+
async dispatchGetLanguageTexts(params) {
|
|
339
|
+
const response = await this.service.getLanguageTexts(params);
|
|
340
|
+
this.state = {
|
|
341
|
+
...this.state,
|
|
342
|
+
languageTextsResponse: response
|
|
343
|
+
};
|
|
344
|
+
return response;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Dispatch action to update a language text by name
|
|
348
|
+
* @param params - Parameters including the new value
|
|
349
|
+
* @returns Promise with the updated language text
|
|
350
|
+
*/
|
|
351
|
+
async dispatchUpdateLanguageTextByName(params) {
|
|
352
|
+
const result = await this.service.updateLanguageTextByName(params);
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Dispatch action to restore a language text to its default value
|
|
357
|
+
* @param params - Parameters identifying the language text
|
|
358
|
+
* @returns Promise resolving when complete
|
|
359
|
+
*/
|
|
360
|
+
async dispatchRestoreLanguageTextByName(params) {
|
|
361
|
+
await this.service.restoreLanguageTextByName(params);
|
|
362
|
+
}
|
|
363
|
+
// ========================
|
|
364
|
+
// Culture & Resource Dispatch Methods
|
|
365
|
+
// ========================
|
|
366
|
+
/**
|
|
367
|
+
* Dispatch action to fetch available cultures
|
|
368
|
+
* @returns Promise with the list of cultures
|
|
369
|
+
*/
|
|
370
|
+
async dispatchGetLanguageCultures() {
|
|
371
|
+
const cultures = await this.service.getCultures();
|
|
372
|
+
this.state = {
|
|
373
|
+
...this.state,
|
|
374
|
+
cultures
|
|
375
|
+
};
|
|
376
|
+
return cultures;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Dispatch action to fetch available localization resources
|
|
380
|
+
* @returns Promise with the list of resources
|
|
381
|
+
*/
|
|
382
|
+
async dispatchGetLanguageResources() {
|
|
383
|
+
const resources = await this.service.getResources();
|
|
384
|
+
this.state = {
|
|
385
|
+
...this.state,
|
|
386
|
+
resources
|
|
387
|
+
};
|
|
388
|
+
return resources;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
|
|
214
392
|
// src/hooks/useLanguages.ts
|
|
215
393
|
var import_react = require("react");
|
|
216
394
|
var import_core = require("@abpjs/core");
|
|
@@ -1179,6 +1357,7 @@ function LanguageTextsComponent({
|
|
|
1179
1357
|
0 && (module.exports = {
|
|
1180
1358
|
LANGUAGE_MANAGEMENT_ROUTES,
|
|
1181
1359
|
LanguageManagementService,
|
|
1360
|
+
LanguageManagementStateService,
|
|
1182
1361
|
LanguageTextsComponent,
|
|
1183
1362
|
LanguagesComponent,
|
|
1184
1363
|
useLanguageTexts,
|
package/dist/index.mjs
CHANGED
|
@@ -180,6 +180,183 @@ var LanguageManagementService = class {
|
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
182
|
|
|
183
|
+
// src/services/language-management-state.service.ts
|
|
184
|
+
var LanguageManagementStateService = class {
|
|
185
|
+
constructor(rest) {
|
|
186
|
+
this.state = {
|
|
187
|
+
languageResponse: { items: [], totalCount: 0 },
|
|
188
|
+
languageTextsResponse: { items: [], totalCount: 0 },
|
|
189
|
+
selectedItem: null,
|
|
190
|
+
cultures: [],
|
|
191
|
+
resources: []
|
|
192
|
+
};
|
|
193
|
+
this.service = new LanguageManagementService(rest);
|
|
194
|
+
}
|
|
195
|
+
// ========================
|
|
196
|
+
// Getter Methods
|
|
197
|
+
// ========================
|
|
198
|
+
/**
|
|
199
|
+
* Get the current list of languages from state
|
|
200
|
+
*/
|
|
201
|
+
getLanguages() {
|
|
202
|
+
return this.state.languageResponse?.items ?? [];
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Get the total count of languages from state
|
|
206
|
+
*/
|
|
207
|
+
getLanguagesTotalCount() {
|
|
208
|
+
return this.state.languageResponse?.totalCount ?? 0;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Get the current list of language texts from state
|
|
212
|
+
*/
|
|
213
|
+
getLanguageTexts() {
|
|
214
|
+
return this.state.languageTextsResponse?.items ?? [];
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get the total count of language texts from state
|
|
218
|
+
*/
|
|
219
|
+
getLanguageTextsTotalCount() {
|
|
220
|
+
return this.state.languageTextsResponse?.totalCount ?? 0;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Get the current list of cultures from state
|
|
224
|
+
*/
|
|
225
|
+
getCultures() {
|
|
226
|
+
return this.state.cultures ?? [];
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get the current list of resources from state
|
|
230
|
+
*/
|
|
231
|
+
getResources() {
|
|
232
|
+
return this.state.resources ?? [];
|
|
233
|
+
}
|
|
234
|
+
// ========================
|
|
235
|
+
// Language Dispatch Methods
|
|
236
|
+
// ========================
|
|
237
|
+
/**
|
|
238
|
+
* Dispatch action to fetch languages with optional pagination
|
|
239
|
+
* @param params - Optional query parameters for pagination and filtering
|
|
240
|
+
* @returns Promise with the language response
|
|
241
|
+
*/
|
|
242
|
+
async dispatchGetLanguages(params = {}) {
|
|
243
|
+
const response = await this.service.getLanguages(params);
|
|
244
|
+
this.state = {
|
|
245
|
+
...this.state,
|
|
246
|
+
languageResponse: response
|
|
247
|
+
};
|
|
248
|
+
return response;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Dispatch action to fetch a language by ID
|
|
252
|
+
* @param id - The language ID
|
|
253
|
+
* @returns Promise with the language
|
|
254
|
+
*/
|
|
255
|
+
async dispatchGetLanguageById(id) {
|
|
256
|
+
const language = await this.service.getLanguageById(id);
|
|
257
|
+
this.state = {
|
|
258
|
+
...this.state,
|
|
259
|
+
selectedItem: language
|
|
260
|
+
};
|
|
261
|
+
return language;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Dispatch action to create or update a language
|
|
265
|
+
* @param body - The language data
|
|
266
|
+
* @param id - Optional ID for update (if not provided, creates new)
|
|
267
|
+
* @returns Promise with the created/updated language
|
|
268
|
+
*/
|
|
269
|
+
async dispatchCreateUpdateLanguage(body, id) {
|
|
270
|
+
let result;
|
|
271
|
+
if (id) {
|
|
272
|
+
result = await this.service.updateLanguage(id, body);
|
|
273
|
+
} else {
|
|
274
|
+
result = await this.service.createLanguage(body);
|
|
275
|
+
}
|
|
276
|
+
await this.dispatchGetLanguages();
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Dispatch action to delete a language
|
|
281
|
+
* @param id - The language ID to delete
|
|
282
|
+
* @returns Promise resolving when complete (returns null per v2.0.0 spec)
|
|
283
|
+
*/
|
|
284
|
+
async dispatchDeleteLanguage(id) {
|
|
285
|
+
await this.service.deleteLanguage(id);
|
|
286
|
+
await this.dispatchGetLanguages();
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Dispatch action to set a language as the default
|
|
291
|
+
* @param id - The language ID to set as default
|
|
292
|
+
* @returns Promise resolving when complete
|
|
293
|
+
*/
|
|
294
|
+
async dispatchSetAsDefaultLanguage(id) {
|
|
295
|
+
await this.service.setAsDefaultLanguage(id);
|
|
296
|
+
await this.dispatchGetLanguages();
|
|
297
|
+
}
|
|
298
|
+
// ========================
|
|
299
|
+
// Language Text Dispatch Methods
|
|
300
|
+
// ========================
|
|
301
|
+
/**
|
|
302
|
+
* Dispatch action to fetch language texts with filters
|
|
303
|
+
* @param params - Query parameters including resource name, cultures, and filter options
|
|
304
|
+
* @returns Promise with the language text response
|
|
305
|
+
*/
|
|
306
|
+
async dispatchGetLanguageTexts(params) {
|
|
307
|
+
const response = await this.service.getLanguageTexts(params);
|
|
308
|
+
this.state = {
|
|
309
|
+
...this.state,
|
|
310
|
+
languageTextsResponse: response
|
|
311
|
+
};
|
|
312
|
+
return response;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Dispatch action to update a language text by name
|
|
316
|
+
* @param params - Parameters including the new value
|
|
317
|
+
* @returns Promise with the updated language text
|
|
318
|
+
*/
|
|
319
|
+
async dispatchUpdateLanguageTextByName(params) {
|
|
320
|
+
const result = await this.service.updateLanguageTextByName(params);
|
|
321
|
+
return result;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Dispatch action to restore a language text to its default value
|
|
325
|
+
* @param params - Parameters identifying the language text
|
|
326
|
+
* @returns Promise resolving when complete
|
|
327
|
+
*/
|
|
328
|
+
async dispatchRestoreLanguageTextByName(params) {
|
|
329
|
+
await this.service.restoreLanguageTextByName(params);
|
|
330
|
+
}
|
|
331
|
+
// ========================
|
|
332
|
+
// Culture & Resource Dispatch Methods
|
|
333
|
+
// ========================
|
|
334
|
+
/**
|
|
335
|
+
* Dispatch action to fetch available cultures
|
|
336
|
+
* @returns Promise with the list of cultures
|
|
337
|
+
*/
|
|
338
|
+
async dispatchGetLanguageCultures() {
|
|
339
|
+
const cultures = await this.service.getCultures();
|
|
340
|
+
this.state = {
|
|
341
|
+
...this.state,
|
|
342
|
+
cultures
|
|
343
|
+
};
|
|
344
|
+
return cultures;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Dispatch action to fetch available localization resources
|
|
348
|
+
* @returns Promise with the list of resources
|
|
349
|
+
*/
|
|
350
|
+
async dispatchGetLanguageResources() {
|
|
351
|
+
const resources = await this.service.getResources();
|
|
352
|
+
this.state = {
|
|
353
|
+
...this.state,
|
|
354
|
+
resources
|
|
355
|
+
};
|
|
356
|
+
return resources;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
|
|
183
360
|
// src/hooks/useLanguages.ts
|
|
184
361
|
import { useState, useCallback, useMemo } from "react";
|
|
185
362
|
import { useRestService } from "@abpjs/core";
|
|
@@ -1168,6 +1345,7 @@ function LanguageTextsComponent({
|
|
|
1168
1345
|
export {
|
|
1169
1346
|
LANGUAGE_MANAGEMENT_ROUTES,
|
|
1170
1347
|
LanguageManagementService,
|
|
1348
|
+
LanguageManagementStateService,
|
|
1171
1349
|
LanguageTextsComponent,
|
|
1172
1350
|
LanguagesComponent,
|
|
1173
1351
|
useLanguageTexts,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abpjs/language-management",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "ABP Framework language-management components for React - translated from @volo/abp.ng.language-management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"@chakra-ui/react": "^3.2.0",
|
|
27
27
|
"@emotion/react": "^11.11.0",
|
|
28
28
|
"react-icons": "^5.3.0",
|
|
29
|
-
"@abpjs/core": "
|
|
30
|
-
"@abpjs/
|
|
31
|
-
"@abpjs/
|
|
29
|
+
"@abpjs/core": "2.0.0",
|
|
30
|
+
"@abpjs/permission-management": "2.0.0",
|
|
31
|
+
"@abpjs/theme-shared": "2.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@volo/abp.ng.language-management": "0.
|
|
34
|
+
"@volo/abp.ng.language-management": "2.0.0",
|
|
35
35
|
"@testing-library/jest-dom": "^6.9.1",
|
|
36
36
|
"@testing-library/react": "^14.0.0",
|
|
37
37
|
"@testing-library/user-event": "^14.6.1",
|