@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.
package/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version of
113
+ the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -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 };