@abpjs/language-management 2.9.0 → 3.1.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 CHANGED
@@ -1,6 +1,138 @@
1
- import { ABP, RestService } from '@abpjs/core';
1
+ import { RoutesService, ABP, RestService } from '@abpjs/core';
2
2
  import React from 'react';
3
3
 
4
+ /**
5
+ * Language Management Policy Names
6
+ * Policy names for permission checking in the Language Management module.
7
+ * @since 3.0.0
8
+ */
9
+ /**
10
+ * Language Management policy names enum.
11
+ * Used for checking permissions in the language management module.
12
+ * @since 3.0.0
13
+ */
14
+ declare const eLanguageManagementPolicyNames: {
15
+ readonly LanguageManagement: "LanguageManagement.Languages || LanguageManagement.LanguageTexts";
16
+ readonly Languages: "LanguageManagement.Languages";
17
+ readonly LanguageTexts: "LanguageManagement.LanguageTexts";
18
+ };
19
+ /**
20
+ * Type for language management policy name values
21
+ */
22
+ type LanguageManagementPolicyNameKey = (typeof eLanguageManagementPolicyNames)[keyof typeof eLanguageManagementPolicyNames];
23
+
24
+ /**
25
+ * Language Management Route Names
26
+ * Translated from @volo/abp.ng.language-management v3.0.0
27
+ *
28
+ * @since 3.0.0
29
+ * Changes in v3.0.0:
30
+ * - Removed Administration key
31
+ * - Changed Languages value from 'LanguageManagement::Menu:Languages' to 'LanguageManagement::Languages'
32
+ * - Added LanguageManagement key for parent route
33
+ */
34
+ /**
35
+ * Enum-like const object for language management route names.
36
+ * Used for localization and navigation configuration.
37
+ * @since 3.0.0
38
+ */
39
+ declare const eLanguageManagementRouteNames: {
40
+ readonly LanguageManagement: "LanguageManagement::LanguageManagement";
41
+ readonly Languages: "LanguageManagement::Languages";
42
+ readonly LanguageTexts: "LanguageManagement::LanguageTexts";
43
+ };
44
+ /**
45
+ * Type for language management route name values
46
+ */
47
+ type LanguageManagementRouteNameKey = (typeof eLanguageManagementRouteNames)[keyof typeof eLanguageManagementRouteNames];
48
+
49
+ /**
50
+ * Language Management Route Provider
51
+ * Provides route configuration for the Language Management module.
52
+ * @since 3.0.0
53
+ */
54
+
55
+ /**
56
+ * Configures language management routes using the provided RoutesService.
57
+ * @param routes - The RoutesService instance to configure routes with
58
+ * @returns A function that adds language management routes when called
59
+ */
60
+ declare function configureRoutes(routes: RoutesService): () => void;
61
+ /**
62
+ * Initializes language management routes using the global RoutesService.
63
+ * Convenience function that uses the global RoutesService singleton.
64
+ * @returns A function that adds language management routes when called
65
+ */
66
+ declare function initializeLanguageManagementRoutes(): () => void;
67
+ /**
68
+ * Language Management route providers object.
69
+ * Can be used for DI-style configuration.
70
+ */
71
+ declare const LANGUAGE_MANAGEMENT_ROUTE_PROVIDERS: {
72
+ configureRoutes: typeof configureRoutes;
73
+ };
74
+
75
+ /**
76
+ * Language Management Extensions Guard
77
+ * Guard for loading language management extensions before route activation.
78
+ * @since 3.0.0
79
+ */
80
+ /**
81
+ * Hook to guard language management routes and load extensions.
82
+ * In Angular, this was a CanActivate guard that loaded entity actions,
83
+ * toolbar actions, entity props, and form props for language management components.
84
+ *
85
+ * In React, this is implemented as a hook that can be used in route loaders
86
+ * or component initialization.
87
+ *
88
+ * @returns Promise that resolves to true when extensions are loaded
89
+ */
90
+ declare function languageManagementExtensionsGuard(): Promise<boolean>;
91
+ /**
92
+ * React hook version of the extensions guard.
93
+ * Can be used in route loaders or useEffect.
94
+ *
95
+ * @example
96
+ * ```tsx
97
+ * import { useLanguageManagementExtensionsGuard } from '@abpjs/language-management';
98
+ *
99
+ * function LanguageManagementLayout() {
100
+ * const { isLoaded, loading } = useLanguageManagementExtensionsGuard();
101
+ *
102
+ * if (loading) return <Loading />;
103
+ *
104
+ * return <Outlet />;
105
+ * }
106
+ * ```
107
+ */
108
+ declare function useLanguageManagementExtensionsGuard(): {
109
+ isLoaded: boolean;
110
+ loading: boolean;
111
+ };
112
+ /**
113
+ * Language Management Extensions Guard class (for compatibility with Angular pattern).
114
+ * @deprecated Use languageManagementExtensionsGuard function or useLanguageManagementExtensionsGuard hook instead.
115
+ */
116
+ declare class LanguageManagementExtensionsGuard {
117
+ canActivate(): Promise<boolean>;
118
+ }
119
+
120
+ /**
121
+ * Language Management Component Identifiers
122
+ * Used for component registration and routing
123
+ *
124
+ * @since 2.4.0
125
+ * @updated 2.7.0 - Changed from enum to const object
126
+ */
127
+ declare const eLanguageManagementComponents: {
128
+ readonly Languages: "LanguageManagement.LanguagesComponent";
129
+ readonly LanguageTexts: "LanguageManagement.LanguageTextsComponent";
130
+ };
131
+ /**
132
+ * Type for language management component key values
133
+ */
134
+ type LanguageManagementComponentKey = (typeof eLanguageManagementComponents)[keyof typeof eLanguageManagementComponents];
135
+
4
136
  /**
5
137
  * Language Management Models
6
138
  * Translated from @volo/abp.ng.language-management v2.0.0
@@ -108,51 +240,211 @@ declare namespace LanguageManagement {
108
240
  }
109
241
 
110
242
  /**
111
- * Language Management Routes
112
- * Translated from @volo/abp.ng.language-management v0.7.2
243
+ * Language Management Extension Tokens
244
+ * Provides extension points for customizing language management components.
245
+ * @since 3.0.0
113
246
  */
114
247
 
115
248
  /**
116
- * Default routes for language management module
249
+ * Entity action definition for grid row actions.
250
+ * @template T - The entity type for the action
117
251
  */
118
- declare const LANGUAGE_MANAGEMENT_ROUTES: {
119
- routes: ABP.FullRoute[];
252
+ interface EntityAction<T> {
253
+ text: string;
254
+ action?: (record: {
255
+ record: T;
256
+ }) => void;
257
+ visible?: (data: {
258
+ record: T;
259
+ }) => boolean;
260
+ permission?: string;
261
+ icon?: string;
262
+ }
263
+ /**
264
+ * Toolbar action definition for grid toolbar buttons.
265
+ * @template T - The entity array type for the action
266
+ */
267
+ interface ToolbarAction<T> {
268
+ text: string;
269
+ action?: (data: {
270
+ data: T;
271
+ }) => void;
272
+ visible?: (data: {
273
+ data: T;
274
+ }) => boolean;
275
+ permission?: string;
276
+ icon?: string;
277
+ }
278
+ /**
279
+ * Entity prop definition for grid columns.
280
+ * @template T - The entity type for the prop
281
+ */
282
+ interface EntityProp<T> {
283
+ type: string;
284
+ name: keyof T | string;
285
+ displayName: string;
286
+ sortable?: boolean;
287
+ visible?: (data: {
288
+ record: T;
289
+ }) => boolean;
290
+ valueResolver?: (data: {
291
+ record: T;
292
+ }) => string | number | boolean;
293
+ }
294
+ /**
295
+ * Form prop definition for form fields.
296
+ * @template T - The entity type for the form
297
+ */
298
+ interface FormProp<T> {
299
+ type: string;
300
+ name: keyof T | string;
301
+ displayName: string;
302
+ validators?: unknown[];
303
+ visible?: (data: {
304
+ entity?: T;
305
+ }) => boolean;
306
+ defaultValue?: unknown;
307
+ options?: unknown[];
308
+ }
309
+ type EntityActionContributorCallback<T> = (actions: EntityAction<T>[]) => EntityAction<T>[];
310
+ type ToolbarActionContributorCallback<T> = (actions: ToolbarAction<T>[]) => ToolbarAction<T>[];
311
+ type EntityPropContributorCallback<T> = (props: EntityProp<T>[]) => EntityProp<T>[];
312
+ type CreateFormPropContributorCallback<T> = (props: FormProp<T>[]) => FormProp<T>[];
313
+ type EditFormPropContributorCallback<T> = (props: FormProp<T>[]) => FormProp<T>[];
314
+ /**
315
+ * Default entity actions for Languages component.
316
+ */
317
+ declare const DEFAULT_LANGUAGES_ENTITY_ACTIONS: EntityAction<LanguageManagement.Language>[];
318
+ /**
319
+ * Default entity actions for LanguageTexts component.
320
+ */
321
+ declare const DEFAULT_LANGUAGE_TEXTS_ENTITY_ACTIONS: EntityAction<LanguageManagement.LanguageText>[];
322
+ /**
323
+ * Combined default language management entity actions.
324
+ */
325
+ declare const DEFAULT_LANGUAGE_MANAGEMENT_ENTITY_ACTIONS: {
326
+ readonly 'LanguageManagement.LanguagesComponent': EntityAction<LanguageManagement.Language>[];
327
+ readonly 'LanguageManagement.LanguageTextsComponent': EntityAction<LanguageManagement.LanguageText>[];
120
328
  };
121
-
122
329
  /**
123
- * Language Management Component Identifiers
124
- * Used for component registration and routing
125
- *
126
- * @since 2.4.0
127
- * @updated 2.7.0 - Changed from enum to const object
330
+ * Default toolbar actions for Languages component.
128
331
  */
129
- declare const eLanguageManagementComponents: {
130
- readonly Languages: "LanguageManagement.LanguagesComponent";
131
- readonly LanguageTexts: "LanguageManagement.LanguageTextsComponent";
332
+ declare const DEFAULT_LANGUAGES_TOOLBAR_ACTIONS: ToolbarAction<LanguageManagement.Language[]>[];
333
+ /**
334
+ * Default toolbar actions for LanguageTexts component.
335
+ * Note: LanguageTexts typically doesn't have toolbar actions as texts are predefined.
336
+ */
337
+ declare const DEFAULT_LANGUAGE_TEXTS_TOOLBAR_ACTIONS: ToolbarAction<LanguageManagement.LanguageText[]>[];
338
+ /**
339
+ * Combined default language management toolbar actions.
340
+ */
341
+ declare const DEFAULT_LANGUAGE_MANAGEMENT_TOOLBAR_ACTIONS: {
342
+ readonly 'LanguageManagement.LanguagesComponent': ToolbarAction<LanguageManagement.Language[]>[];
343
+ readonly 'LanguageManagement.LanguageTextsComponent': ToolbarAction<LanguageManagement.LanguageText[]>[];
132
344
  };
133
345
  /**
134
- * Type for language management component key values
346
+ * Default entity props for Languages component.
135
347
  */
136
- type LanguageManagementComponentKey = (typeof eLanguageManagementComponents)[keyof typeof eLanguageManagementComponents];
137
-
348
+ declare const DEFAULT_LANGUAGES_ENTITY_PROPS: EntityProp<LanguageManagement.Language>[];
138
349
  /**
139
- * Language Management Route Names
140
- * Translated from @volo/abp.ng.language-management v2.7.0
350
+ * Combined default language management entity props.
351
+ * Note: LanguageTexts props are not included as they use a different display pattern.
141
352
  */
353
+ declare const DEFAULT_LANGUAGE_MANAGEMENT_ENTITY_PROPS: {
354
+ readonly 'LanguageManagement.LanguagesComponent': EntityProp<LanguageManagement.Language>[];
355
+ };
142
356
  /**
143
- * Enum-like const object for language management route names.
144
- * Used for localization and navigation configuration.
145
- * @since 2.7.0
357
+ * Default create form props for Languages component.
146
358
  */
147
- declare const eLanguageManagementRouteNames: {
148
- readonly Administration: "AbpUiNavigation::Menu:Administration";
149
- readonly Languages: "LanguageManagement::Menu:Languages";
150
- readonly LanguageTexts: "LanguageManagement::LanguageTexts";
359
+ declare const DEFAULT_LANGUAGES_CREATE_FORM_PROPS: FormProp<LanguageManagement.Language>[];
360
+ /**
361
+ * Default edit form props for Languages component.
362
+ */
363
+ declare const DEFAULT_LANGUAGES_EDIT_FORM_PROPS: FormProp<LanguageManagement.Language>[];
364
+ /**
365
+ * Combined default language management create form props.
366
+ */
367
+ declare const DEFAULT_LANGUAGE_MANAGEMENT_CREATE_FORM_PROPS: {
368
+ readonly 'LanguageManagement.LanguagesComponent': FormProp<LanguageManagement.Language>[];
151
369
  };
152
370
  /**
153
- * Type for language management route name values
371
+ * Combined default language management edit form props.
372
+ */
373
+ declare const DEFAULT_LANGUAGE_MANAGEMENT_EDIT_FORM_PROPS: {
374
+ readonly 'LanguageManagement.LanguagesComponent': FormProp<LanguageManagement.Language>[];
375
+ };
376
+ /**
377
+ * Entity action contributors type.
378
+ */
379
+ type LanguageManagementEntityActionContributors = Partial<{
380
+ [eLanguageManagementComponents.Languages]: EntityActionContributorCallback<LanguageManagement.Language>[];
381
+ [eLanguageManagementComponents.LanguageTexts]: EntityActionContributorCallback<LanguageManagement.LanguageText>[];
382
+ }>;
383
+ /**
384
+ * Toolbar action contributors type.
385
+ */
386
+ type LanguageManagementToolbarActionContributors = Partial<{
387
+ [eLanguageManagementComponents.Languages]: ToolbarActionContributorCallback<LanguageManagement.Language[]>[];
388
+ [eLanguageManagementComponents.LanguageTexts]: ToolbarActionContributorCallback<LanguageManagement.LanguageText[]>[];
389
+ }>;
390
+ /**
391
+ * Entity prop contributors type.
392
+ */
393
+ type LanguageManagementEntityPropContributors = Partial<{
394
+ [eLanguageManagementComponents.Languages]: EntityPropContributorCallback<LanguageManagement.Language>[];
395
+ [eLanguageManagementComponents.LanguageTexts]: EntityPropContributorCallback<LanguageManagement.LanguageText>[];
396
+ }>;
397
+ /**
398
+ * Create form prop contributors type.
399
+ */
400
+ type LanguageManagementCreateFormPropContributors = Partial<{
401
+ [eLanguageManagementComponents.Languages]: CreateFormPropContributorCallback<LanguageManagement.Language>[];
402
+ [eLanguageManagementComponents.LanguageTexts]: CreateFormPropContributorCallback<LanguageManagement.LanguageText>[];
403
+ }>;
404
+ /**
405
+ * Edit form prop contributors type.
406
+ */
407
+ type LanguageManagementEditFormPropContributors = Partial<{
408
+ [eLanguageManagementComponents.Languages]: EditFormPropContributorCallback<LanguageManagement.Language>[];
409
+ [eLanguageManagementComponents.LanguageTexts]: EditFormPropContributorCallback<LanguageManagement.LanguageText>[];
410
+ }>;
411
+ /**
412
+ * Token for language management entity action contributors.
413
+ * Use as a React Context key.
414
+ */
415
+ declare const LANGUAGE_MANAGEMENT_ENTITY_ACTION_CONTRIBUTORS: unique symbol;
416
+ /**
417
+ * Token for language management toolbar action contributors.
418
+ * Use as a React Context key.
419
+ */
420
+ declare const LANGUAGE_MANAGEMENT_TOOLBAR_ACTION_CONTRIBUTORS: unique symbol;
421
+ /**
422
+ * Token for language management entity prop contributors.
423
+ * Use as a React Context key.
424
+ */
425
+ declare const LANGUAGE_MANAGEMENT_ENTITY_PROP_CONTRIBUTORS: unique symbol;
426
+ /**
427
+ * Token for language management create form prop contributors.
428
+ * Use as a React Context key.
429
+ */
430
+ declare const LANGUAGE_MANAGEMENT_CREATE_FORM_PROP_CONTRIBUTORS: unique symbol;
431
+ /**
432
+ * Token for language management edit form prop contributors.
433
+ * Use as a React Context key.
434
+ */
435
+ declare const LANGUAGE_MANAGEMENT_EDIT_FORM_PROP_CONTRIBUTORS: unique symbol;
436
+
437
+ /**
438
+ * Language Management Routes
439
+ * Translated from @volo/abp.ng.language-management v0.7.2
154
440
  */
155
- type LanguageManagementRouteNameKey = (typeof eLanguageManagementRouteNames)[keyof typeof eLanguageManagementRouteNames];
441
+
442
+ /**
443
+ * Default routes for language management module
444
+ */
445
+ declare const LANGUAGE_MANAGEMENT_ROUTES: {
446
+ routes: ABP.FullRoute[];
447
+ };
156
448
 
157
449
  /**
158
450
  * Language Management Service
@@ -251,10 +543,13 @@ declare class LanguageManagementService {
251
543
 
252
544
  /**
253
545
  * Language Management State Service
254
- * Translated from @volo/abp.ng.language-management v2.0.0
546
+ * Translated from @volo/abp.ng.language-management v3.0.0
255
547
  *
256
548
  * Provides a stateful facade over language management operations,
257
549
  * maintaining internal state that mirrors the Angular NGXS store pattern.
550
+ *
551
+ * @since 2.0.0
552
+ * @updated 3.0.0 - Removed getLanguagesTotalCount() method
258
553
  */
259
554
 
260
555
  /**
@@ -273,7 +568,6 @@ declare class LanguageManagementService {
273
568
  *
274
569
  * // Access the result
275
570
  * const languages = stateService.getLanguages();
276
- * const total = stateService.getLanguagesTotalCount();
277
571
  * ```
278
572
  */
279
573
  declare class LanguageManagementStateService {
@@ -284,10 +578,6 @@ declare class LanguageManagementStateService {
284
578
  * Get the current list of languages from state
285
579
  */
286
580
  getLanguages(): LanguageManagement.Language[];
287
- /**
288
- * Get the total count of languages from state
289
- */
290
- getLanguagesTotalCount(): number;
291
581
  /**
292
582
  * Get the current list of language texts from state
293
583
  */
@@ -630,4 +920,4 @@ interface LanguageTextsComponentProps {
630
920
  */
631
921
  declare function LanguageTextsComponent({ onLanguageTextUpdated, onLanguageTextRestored, }: LanguageTextsComponentProps): React.ReactElement;
632
922
 
633
- export { LANGUAGE_MANAGEMENT_ROUTES, LanguageManagement, type LanguageManagementComponentKey, type LanguageManagementRouteNameKey, LanguageManagementService, LanguageManagementStateService, type LanguageOperationResult, type LanguageTextOperationResult, LanguageTextsComponent, type LanguageTextsComponentProps, LanguagesComponent, type LanguagesComponentProps, type SortOrder$1 as SortOrder, type UseLanguageTextsReturn, type UseLanguagesReturn, eLanguageManagementComponents, eLanguageManagementRouteNames, useLanguageTexts, useLanguages };
923
+ export { type CreateFormPropContributorCallback, DEFAULT_LANGUAGES_CREATE_FORM_PROPS, DEFAULT_LANGUAGES_EDIT_FORM_PROPS, DEFAULT_LANGUAGES_ENTITY_ACTIONS, DEFAULT_LANGUAGES_ENTITY_PROPS, DEFAULT_LANGUAGES_TOOLBAR_ACTIONS, DEFAULT_LANGUAGE_MANAGEMENT_CREATE_FORM_PROPS, DEFAULT_LANGUAGE_MANAGEMENT_EDIT_FORM_PROPS, DEFAULT_LANGUAGE_MANAGEMENT_ENTITY_ACTIONS, DEFAULT_LANGUAGE_MANAGEMENT_ENTITY_PROPS, DEFAULT_LANGUAGE_MANAGEMENT_TOOLBAR_ACTIONS, DEFAULT_LANGUAGE_TEXTS_ENTITY_ACTIONS, DEFAULT_LANGUAGE_TEXTS_TOOLBAR_ACTIONS, type EditFormPropContributorCallback, type EntityAction, type EntityActionContributorCallback, type EntityProp, type EntityPropContributorCallback, type FormProp, LANGUAGE_MANAGEMENT_CREATE_FORM_PROP_CONTRIBUTORS, LANGUAGE_MANAGEMENT_EDIT_FORM_PROP_CONTRIBUTORS, LANGUAGE_MANAGEMENT_ENTITY_ACTION_CONTRIBUTORS, LANGUAGE_MANAGEMENT_ENTITY_PROP_CONTRIBUTORS, LANGUAGE_MANAGEMENT_ROUTES, LANGUAGE_MANAGEMENT_ROUTE_PROVIDERS, LANGUAGE_MANAGEMENT_TOOLBAR_ACTION_CONTRIBUTORS, LanguageManagement, type LanguageManagementComponentKey, type LanguageManagementCreateFormPropContributors, type LanguageManagementEditFormPropContributors, type LanguageManagementEntityActionContributors, type LanguageManagementEntityPropContributors, LanguageManagementExtensionsGuard, type LanguageManagementPolicyNameKey, type LanguageManagementRouteNameKey, LanguageManagementService, LanguageManagementStateService, type LanguageManagementToolbarActionContributors, type LanguageOperationResult, type LanguageTextOperationResult, LanguageTextsComponent, type LanguageTextsComponentProps, LanguagesComponent, type LanguagesComponentProps, type SortOrder$1 as SortOrder, type ToolbarAction, type ToolbarActionContributorCallback, type UseLanguageTextsReturn, type UseLanguagesReturn, configureRoutes, eLanguageManagementComponents, eLanguageManagementPolicyNames, eLanguageManagementRouteNames, initializeLanguageManagementRoutes, languageManagementExtensionsGuard, useLanguageManagementExtensionsGuard, useLanguageTexts, useLanguages };