@abpjs/text-template-management 2.7.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.
@@ -0,0 +1,454 @@
1
+ import { ABP, RestService, PagedResultRequestDto, ListResultDto } from '@abpjs/core';
2
+ import React from 'react';
3
+
4
+ /**
5
+ * Component keys for the Text Template Management module.
6
+ * These keys are used for component replacement/customization.
7
+ * @since 2.7.0
8
+ */
9
+ declare const eTextTemplateManagementComponents: {
10
+ /**
11
+ * Key for the TextTemplates component.
12
+ * Use this to replace the default TextTemplates list with a custom implementation.
13
+ */
14
+ readonly TextTemplates: "TextTemplateManagement.TextTemplates";
15
+ /**
16
+ * Key for the TemplateContents component.
17
+ * Use this to replace the default template content editor.
18
+ */
19
+ readonly TemplateContents: "TextTemplateManagement.TemplateContents";
20
+ /**
21
+ * Key for the InlineTemplateContent component.
22
+ * Use this to replace the inline template content editor.
23
+ */
24
+ readonly InlineTemplateContent: "TextTemplateManagement.InlineTemplateContent";
25
+ };
26
+ /**
27
+ * Type for text template management component key values
28
+ */
29
+ type TextTemplateManagementComponentKey = (typeof eTextTemplateManagementComponents)[keyof typeof eTextTemplateManagementComponents];
30
+
31
+ /**
32
+ * Route name keys for the Text Template Management module.
33
+ * These keys are used for route localization and identification.
34
+ * @since 2.7.0
35
+ */
36
+ declare const eTextTemplateManagementRouteNames: {
37
+ /**
38
+ * Administration route name key.
39
+ * Used for the administration menu group.
40
+ */
41
+ readonly Administration: "AbpUiNavigation::Menu:Administration";
42
+ /**
43
+ * Text Templates route name key.
44
+ * Used for the text templates management route.
45
+ */
46
+ readonly TextTemplates: "TextTemplateManagement::Menu:TextTemplates";
47
+ };
48
+ /**
49
+ * Type for text template management route name key values
50
+ */
51
+ type TextTemplateManagementRouteNameKey = (typeof eTextTemplateManagementRouteNames)[keyof typeof eTextTemplateManagementRouteNames];
52
+
53
+ /**
54
+ * Text Template Management Models
55
+ * Translated from @volo/abp.ng.text-template-management v2.7.0
56
+ */
57
+ /**
58
+ * Text Template Management namespace containing types and interfaces
59
+ * @since 2.7.0
60
+ */
61
+ declare namespace TextTemplateManagement {
62
+ /**
63
+ * Template definition DTO
64
+ * Represents a text template definition
65
+ */
66
+ interface TemplateDefinitionDto {
67
+ /** Template name (unique identifier) */
68
+ name: string;
69
+ /** Display name for the template */
70
+ displayName: string;
71
+ /** Whether this template is a layout template */
72
+ isLayout: boolean;
73
+ /** Layout template name (if this template uses a layout) */
74
+ layout: string;
75
+ /** Default culture name for the template */
76
+ defaultCultureName: string;
77
+ /** Whether the template is localized inline */
78
+ isInlineLocalized: boolean;
79
+ }
80
+ /**
81
+ * Text template content DTO
82
+ * Represents the content of a text template
83
+ */
84
+ interface TextTemplateContentDto {
85
+ /** Template name */
86
+ name: string;
87
+ /** Culture name for the content */
88
+ cultureName: string;
89
+ /** Template content */
90
+ content: string;
91
+ }
92
+ /**
93
+ * Input for getting template content
94
+ */
95
+ interface TemplateContentInput {
96
+ /** Template name */
97
+ templateName: string;
98
+ /** Optional culture name */
99
+ cultureName?: string;
100
+ }
101
+ /**
102
+ * DTO for creating or updating template content
103
+ */
104
+ interface CreateOrUpdateTemplateContentDto {
105
+ /** Template name */
106
+ templateName: string;
107
+ /** Culture name for the content */
108
+ cultureName: string;
109
+ /** Template content */
110
+ content: string;
111
+ }
112
+ /**
113
+ * State interface for text template management
114
+ * @since 2.7.0
115
+ */
116
+ interface State {
117
+ /** List of template definitions */
118
+ templateDefinitions: TemplateDefinitionDto[];
119
+ /** Total count of template definitions */
120
+ totalCount: number;
121
+ /** Currently selected template definition */
122
+ selectedTemplate: TemplateDefinitionDto | null;
123
+ /** Template content for the selected template */
124
+ templateContent: TextTemplateContentDto | null;
125
+ }
126
+ /**
127
+ * Request parameters for fetching template definitions
128
+ */
129
+ interface GetTemplateDefinitionsInput {
130
+ /** Filter text */
131
+ filterText?: string;
132
+ /** Skip count for pagination */
133
+ skipCount?: number;
134
+ /** Max result count for pagination */
135
+ maxResultCount?: number;
136
+ /** Sorting field and order */
137
+ sorting?: string;
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Text Template Management Routes
143
+ * Translated from @volo/abp.ng.text-template-management v2.7.0
144
+ */
145
+
146
+ /**
147
+ * Default routes for text template management module
148
+ */
149
+ declare const TEXT_TEMPLATE_MANAGEMENT_ROUTES: {
150
+ routes: ABP.FullRoute[];
151
+ };
152
+
153
+ /**
154
+ * Template Definition Service
155
+ * Translated from @volo/abp.ng.text-template-management v2.7.0
156
+ *
157
+ * Provides REST API methods for managing text template definitions.
158
+ */
159
+
160
+ /**
161
+ * Service for template definition operations.
162
+ * This service wraps all REST API calls for template definitions.
163
+ *
164
+ * @since 2.7.0
165
+ */
166
+ declare class TemplateDefinitionService {
167
+ private restService;
168
+ /**
169
+ * API name for multi-API configurations
170
+ * @since 2.7.0
171
+ */
172
+ apiName: string;
173
+ constructor(restService: RestService);
174
+ /**
175
+ * Get list of template definitions
176
+ * @param params Query parameters for filtering and pagination
177
+ * @returns Promise with list of template definitions
178
+ */
179
+ getList(params?: Partial<PagedResultRequestDto>): Promise<ListResultDto<TextTemplateManagement.TemplateDefinitionDto>>;
180
+ }
181
+
182
+ /**
183
+ * Template Content Service
184
+ * Translated from @volo/abp.ng.text-template-management v2.7.0
185
+ *
186
+ * Provides REST API methods for managing text template content.
187
+ */
188
+
189
+ /**
190
+ * Service for template content operations.
191
+ * This service wraps all REST API calls for template content.
192
+ *
193
+ * @since 2.7.0
194
+ */
195
+ declare class TemplateContentService {
196
+ private restService;
197
+ /**
198
+ * API name for multi-API configurations
199
+ * @since 2.7.0
200
+ */
201
+ apiName: string;
202
+ constructor(restService: RestService);
203
+ /**
204
+ * Get template content by input parameters
205
+ * @param params Input parameters containing template name and optional culture name
206
+ * @returns Promise with template content
207
+ */
208
+ getByInput(params: TextTemplateManagement.TemplateContentInput): Promise<TextTemplateManagement.TextTemplateContentDto>;
209
+ /**
210
+ * Restore template content to default
211
+ * @param body Input containing template name and culture name to restore
212
+ * @returns Promise that resolves when restore is complete
213
+ */
214
+ restoreToDefaultByInput(body: TextTemplateManagement.TemplateContentInput): Promise<void>;
215
+ /**
216
+ * Update template content
217
+ * @param body DTO containing template name, culture name, and new content
218
+ * @returns Promise with updated template content
219
+ */
220
+ updateByInput(body: TextTemplateManagement.CreateOrUpdateTemplateContentDto): Promise<TextTemplateManagement.TextTemplateContentDto>;
221
+ }
222
+
223
+ /**
224
+ * Text Template Management State Service
225
+ * Translated from @volo/abp.ng.text-template-management v2.7.0
226
+ *
227
+ * Provides a stateful facade over text template operations,
228
+ * maintaining internal state similar to Angular's NGXS store pattern.
229
+ */
230
+
231
+ /**
232
+ * State service for text template management.
233
+ * Maintains state for template definitions and content.
234
+ *
235
+ * @since 2.7.0
236
+ */
237
+ declare class TextTemplateManagementStateService {
238
+ private templateDefinitionService;
239
+ private templateContentService;
240
+ private _state;
241
+ constructor(restService: RestService);
242
+ /**
243
+ * Get template definitions from state
244
+ * @returns Array of template definitions
245
+ */
246
+ getTemplateDefinitions(): TextTemplateManagement.TemplateDefinitionDto[];
247
+ /**
248
+ * Get total count of template definitions
249
+ * @returns Total count
250
+ */
251
+ getTotalCount(): number;
252
+ /**
253
+ * Get the currently selected template
254
+ * @returns Selected template or null
255
+ */
256
+ getSelectedTemplate(): TextTemplateManagement.TemplateDefinitionDto | null;
257
+ /**
258
+ * Get template content from state
259
+ * @returns Template content or null
260
+ */
261
+ getTemplateContent(): TextTemplateManagement.TextTemplateContentDto | null;
262
+ /**
263
+ * Dispatch action to fetch template definitions
264
+ * @param params Query parameters for filtering and pagination
265
+ * @returns Promise with list result
266
+ */
267
+ dispatchGetTemplateDefinitions(params?: Partial<PagedResultRequestDto>): Promise<ListResultDto<TextTemplateManagement.TemplateDefinitionDto>>;
268
+ /**
269
+ * Dispatch action to get template content
270
+ * @param params Input containing template name and optional culture name
271
+ * @returns Promise with template content
272
+ */
273
+ dispatchGetTemplateContent(params: TextTemplateManagement.TemplateContentInput): Promise<TextTemplateManagement.TextTemplateContentDto>;
274
+ /**
275
+ * Dispatch action to update template content
276
+ * @param body DTO containing template name, culture name, and content
277
+ * @returns Promise with updated template content
278
+ */
279
+ dispatchUpdateTemplateContent(body: TextTemplateManagement.CreateOrUpdateTemplateContentDto): Promise<TextTemplateManagement.TextTemplateContentDto>;
280
+ /**
281
+ * Dispatch action to restore template content to default
282
+ * @param body Input containing template name and culture name
283
+ * @returns Promise that resolves when restore is complete
284
+ */
285
+ dispatchRestoreToDefault(body: TextTemplateManagement.TemplateContentInput): Promise<void>;
286
+ /**
287
+ * Set the selected template
288
+ * @param template Template to select or null to clear
289
+ */
290
+ setSelectedTemplate(template: TextTemplateManagement.TemplateDefinitionDto | null): void;
291
+ /**
292
+ * Clear all state
293
+ */
294
+ reset(): void;
295
+ }
296
+
297
+ /**
298
+ * useTextTemplates Hook
299
+ * Translated from @volo/abp.ng.text-template-management v2.7.0
300
+ *
301
+ * Provides a React hook for managing text templates with state management.
302
+ */
303
+
304
+ /**
305
+ * Hook return type for useTextTemplates
306
+ */
307
+ interface UseTextTemplatesReturn {
308
+ /** List of template definitions */
309
+ templateDefinitions: TextTemplateManagement.TemplateDefinitionDto[];
310
+ /** Total count of template definitions */
311
+ totalCount: number;
312
+ /** Currently selected template */
313
+ selectedTemplate: TextTemplateManagement.TemplateDefinitionDto | null;
314
+ /** Template content for the selected template */
315
+ templateContent: TextTemplateManagement.TextTemplateContentDto | null;
316
+ /** Loading state */
317
+ isLoading: boolean;
318
+ /** Error message if any */
319
+ error: string | null;
320
+ /** Fetch template definitions */
321
+ fetchTemplateDefinitions: (params?: Partial<PagedResultRequestDto>) => Promise<void>;
322
+ /** Get template content */
323
+ getTemplateContent: (params: TextTemplateManagement.TemplateContentInput) => Promise<void>;
324
+ /** Update template content */
325
+ updateTemplateContent: (body: TextTemplateManagement.CreateOrUpdateTemplateContentDto) => Promise<{
326
+ success: boolean;
327
+ error?: string;
328
+ }>;
329
+ /** Restore template content to default */
330
+ restoreToDefault: (params: TextTemplateManagement.TemplateContentInput) => Promise<{
331
+ success: boolean;
332
+ error?: string;
333
+ }>;
334
+ /** Set selected template */
335
+ setSelectedTemplate: (template: TextTemplateManagement.TemplateDefinitionDto | null) => void;
336
+ /** Reset all state */
337
+ reset: () => void;
338
+ }
339
+ /**
340
+ * React hook for managing text templates
341
+ *
342
+ * @returns Hook state and methods
343
+ *
344
+ * @example
345
+ * ```tsx
346
+ * function TextTemplatesPage() {
347
+ * const {
348
+ * templateDefinitions,
349
+ * isLoading,
350
+ * fetchTemplateDefinitions,
351
+ * getTemplateContent,
352
+ * } = useTextTemplates();
353
+ *
354
+ * useEffect(() => {
355
+ * fetchTemplateDefinitions();
356
+ * }, [fetchTemplateDefinitions]);
357
+ *
358
+ * return (
359
+ * <div>
360
+ * {templateDefinitions.map(template => (
361
+ * <div key={template.name}>{template.displayName}</div>
362
+ * ))}
363
+ * </div>
364
+ * );
365
+ * }
366
+ * ```
367
+ */
368
+ declare function useTextTemplates(): UseTextTemplatesReturn;
369
+
370
+ /**
371
+ * Text Templates Component
372
+ * Translated from @volo/abp.ng.text-template-management v2.7.0
373
+ *
374
+ * Displays a list of text template definitions with pagination and actions.
375
+ */
376
+
377
+ interface TextTemplatesComponentProps {
378
+ /** Callback when edit contents is clicked */
379
+ onEditContents?: (template: TextTemplateManagement.TemplateDefinitionDto) => void;
380
+ /** Optional CSS class for the container */
381
+ className?: string;
382
+ /** Page size for pagination */
383
+ pageSize?: number;
384
+ }
385
+ /**
386
+ * Component for displaying and managing text templates.
387
+ * Shows a paginated list of template definitions with actions.
388
+ *
389
+ * @example
390
+ * ```tsx
391
+ * function TextTemplatesPage() {
392
+ * const navigate = useNavigate();
393
+ *
394
+ * return (
395
+ * <TextTemplatesComponent
396
+ * onEditContents={(template) => {
397
+ * navigate(`/text-templates/${template.name}/contents`);
398
+ * }}
399
+ * />
400
+ * );
401
+ * }
402
+ * ```
403
+ */
404
+ declare function TextTemplatesComponent({ onEditContents, className, pageSize, }: TextTemplatesComponentProps): React.ReactElement;
405
+
406
+ /**
407
+ * Template Contents Component
408
+ * Translated from @volo/abp.ng.text-template-management v2.7.0
409
+ *
410
+ * Displays and allows editing of template content for different cultures.
411
+ */
412
+
413
+ interface TemplateContentsComponentProps {
414
+ /** Template name to edit */
415
+ templateName: string;
416
+ /** Available culture names for selection */
417
+ cultures?: Array<{
418
+ name: string;
419
+ displayName: string;
420
+ }>;
421
+ /** Default culture name */
422
+ defaultCultureName?: string;
423
+ /** Callback when save is successful */
424
+ onSave?: (content: TextTemplateManagement.TextTemplateContentDto) => void;
425
+ /** Callback when restore to default is successful */
426
+ onRestore?: () => void;
427
+ /** Optional CSS class for the container */
428
+ className?: string;
429
+ }
430
+ /**
431
+ * Component for editing template content across different cultures.
432
+ * Supports viewing reference content and editing/restoring localized content.
433
+ *
434
+ * @example
435
+ * ```tsx
436
+ * function EditTemplatePage() {
437
+ * const { templateName } = useParams();
438
+ *
439
+ * return (
440
+ * <TemplateContentsComponent
441
+ * templateName={templateName}
442
+ * cultures={[
443
+ * { name: 'en', displayName: 'English' },
444
+ * { name: 'fr', displayName: 'French' },
445
+ * ]}
446
+ * onSave={() => toast.success('Template saved!')}
447
+ * />
448
+ * );
449
+ * }
450
+ * ```
451
+ */
452
+ declare function TemplateContentsComponent({ templateName, cultures, defaultCultureName, onSave, onRestore, className, }: TemplateContentsComponentProps): React.ReactElement;
453
+
454
+ export { TEXT_TEMPLATE_MANAGEMENT_ROUTES, TemplateContentService, TemplateContentsComponent, type TemplateContentsComponentProps, TemplateDefinitionService, TextTemplateManagement, type TextTemplateManagementComponentKey, type TextTemplateManagementRouteNameKey, TextTemplateManagementStateService, TextTemplatesComponent, type TextTemplatesComponentProps, type UseTextTemplatesReturn, eTextTemplateManagementComponents, eTextTemplateManagementRouteNames, useTextTemplates };