@esvndev/es-print-template 0.0.1

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.
Files changed (54) hide show
  1. package/README.md +93 -0
  2. package/dist/component/edit-template/component/block-content.d.ts +25 -0
  3. package/dist/component/edit-template/component/block-signature.d.ts +17 -0
  4. package/dist/component/edit-template/component/block-table.d.ts +17 -0
  5. package/dist/component/edit-template/component/input-number.d.ts +18 -0
  6. package/dist/component/edit-template/component/select-field.d.ts +24 -0
  7. package/dist/component/edit-template/component/select-signature.d.ts +12 -0
  8. package/dist/component/edit-template/component/select-table-feld-component.d.ts +18 -0
  9. package/dist/component/edit-template/component/select-table.d.ts +17 -0
  10. package/dist/component/edit-template/component/setting-content.d.ts +16 -0
  11. package/dist/component/edit-template/component/setting-element/date.d.ts +9 -0
  12. package/dist/component/edit-template/component/setting-element/format.d.ts +11 -0
  13. package/dist/component/edit-template/component/setting-element/image.d.ts +12 -0
  14. package/dist/component/edit-template/component/setting-layout.d.ts +19 -0
  15. package/dist/component/edit-template/component/setting-page/index.d.ts +10 -0
  16. package/dist/component/edit-template/component/setting-page/setting-image.d.ts +11 -0
  17. package/dist/component/edit-template/component/setting-page/upload-image.d.ts +19 -0
  18. package/dist/component/edit-template/component/sidebar.d.ts +24 -0
  19. package/dist/component/edit-template/component/toolbar.d.ts +33 -0
  20. package/dist/component/edit-template/hooks/constant.d.ts +25 -0
  21. package/dist/component/edit-template/hooks/fonts.d.ts +4 -0
  22. package/dist/component/edit-template/hooks/index.d.ts +4 -0
  23. package/dist/component/edit-template/hooks/isNullOrUndefined.d.ts +2 -0
  24. package/dist/component/edit-template/hooks/useOnClickOutside.d.ts +1 -0
  25. package/dist/component/edit-template/hooks/utils.d.ts +122 -0
  26. package/dist/component/edit-template/icon/index.d.ts +2 -0
  27. package/dist/component/edit-template/index.d.ts +23 -0
  28. package/dist/component/edit-template/style/Style.d.ts +29 -0
  29. package/dist/component/edit-template/type/index.d.ts +2 -0
  30. package/dist/component/edit-template/type/print-type.d.ts +293 -0
  31. package/dist/component/edit-template/type/type-data.d.ts +32 -0
  32. package/dist/component/input/input-text/index.d.ts +35 -0
  33. package/dist/component/modal/index.d.ts +106 -0
  34. package/dist/component/modal/modal-edit-tempate.d.ts +21 -0
  35. package/dist/component/modal/modal-print-options.d.ts +33 -0
  36. package/dist/component/modal/modal.d.ts +36 -0
  37. package/dist/component/modal/sidebar-fields.d.ts +10 -0
  38. package/dist/component/modal/tab-select-file.d.ts +9 -0
  39. package/dist/component/modal-header/index.d.ts +10 -0
  40. package/dist/component/sidebar/index.d.ts +11 -0
  41. package/dist/index.d.ts +445 -0
  42. package/dist/index.js +92194 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/index.mjs +92168 -0
  45. package/dist/index.mjs.map +1 -0
  46. package/dist/styles/index.css +128 -0
  47. package/dist/styles/index.css.map +1 -0
  48. package/dist/styles/layout.css +29 -0
  49. package/dist/styles/layout.css.map +1 -0
  50. package/dist/styles/select-background.css +34 -0
  51. package/dist/styles/select-background.css.map +1 -0
  52. package/dist/styles/tab.css +20 -0
  53. package/dist/styles/tab.css.map +1 -0
  54. package/package.json +79 -0
@@ -0,0 +1,445 @@
1
+ import { Layout } from 'react-grid-layout';
2
+ import * as react from 'react';
3
+ import { IFColumnSelectTable } from 'react-table-edit';
4
+
5
+ type ITextAlign = 'center' | 'left' | 'right' | 'initial' | 'start' | 'unset' | 'inherit';
6
+ type IBorder = 'top' | 'left' | 'right' | 'bottom' | 'none' | 'inside' | 'outside' | 'full' | 'vertical' | 'horizontal';
7
+ type DataRecord = Record<string, unknown>;
8
+ type TemplateApiResponse<T = unknown> = Promise<T>;
9
+ type UploadFileApi<T = unknown> = (params: FormData) => TemplateApiResponse<T>;
10
+ type PageSizeKey = 'A4' | 'A4R' | 'A3' | 'A3R' | 'A5' | 'A5R';
11
+ type PageSize = {
12
+ width: number;
13
+ height: number;
14
+ };
15
+ type TemplateBreakpoint = 'lg' | 'md' | 'sm' | 'xs' | 'xxs';
16
+ type TemplateGridLayouts = Record<TemplateBreakpoint, Layout[]>;
17
+ type IFNumberFormat = {
18
+ dateFormat?: string;
19
+ decimalSeparator?: string;
20
+ thousandSeparator?: string;
21
+ colorNegative?: string;
22
+ prefixNegative?: string;
23
+ suffixNegative?: string;
24
+ };
25
+ type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
26
+ interface IFDataGeneralSetting {
27
+ id?: string;
28
+ organizationId: string;
29
+ type: 'PrintDocument' | 'ColumnsTable';
30
+ name: string;
31
+ category: string;
32
+ resourceCode: string;
33
+ value: string;
34
+ more?: string;
35
+ }
36
+
37
+ type ITypeEdit = "layout" | "section";
38
+ interface IFPrintDocumentLayoutDisplay {
39
+ i: string;
40
+ x: number;
41
+ y: number;
42
+ h: number;
43
+ w: number;
44
+ max?: number;
45
+ minW?: number;
46
+ minH?: number;
47
+ maxW?: number;
48
+ static?: boolean;
49
+ }
50
+ interface IFOrganization {
51
+ id: string;
52
+ name: string;
53
+ address: string;
54
+ }
55
+ interface IFPrintDocFile {
56
+ name: string;
57
+ path: string;
58
+ size: number;
59
+ title: string;
60
+ type: string;
61
+ tableFields: string[];
62
+ virtualPath: string;
63
+ }
64
+ /**
65
+ * Đại diện cho một tài liệu in
66
+ */
67
+ interface IFPrintDocument {
68
+ /** ID tài liệu (tùy chọn) */
69
+ id?: string;
70
+ /** Tên tài liệu */
71
+ name: string;
72
+ /** Loại tài liệu */
73
+ type: string;
74
+ /** Mã chức năng tài liệu */
75
+ resourceCode: string;
76
+ /** Có phải tài liệu mặc định không (tùy chọn) */
77
+ isDefault?: boolean;
78
+ /** Cấu hình tài liệu in bằng file*/
79
+ file?: IFPrintDocFile;
80
+ /** Cấu hình tài liệu in */
81
+ setting?: IFPrintDocumentSetting;
82
+ /** Danh sách trường dữ liệu (tùy chọn) */
83
+ dataFields?: IFPrintDocumentSetupColumn[];
84
+ /** Danh sách bảng dữ liệu (tùy chọn) */
85
+ tableFields?: IFPrintDocumentTableField[];
86
+ more?: string;
87
+ }
88
+ interface IFOptionTypePrint {
89
+ value: string;
90
+ label: string;
91
+ resourceCode: string;
92
+ /** Danh sách trường dữ liệu (tùy chọn) */
93
+ dataFields?: IFPrintDocumentSetupColumn[];
94
+ /** Danh sách bảng dữ liệu (tùy chọn) */
95
+ tableFields?: IFPrintDocumentTableField[];
96
+ }
97
+ /**
98
+ * Đại diện một bảng trong tài liệu in
99
+ */
100
+ interface IFPrintDocumentTableField {
101
+ /** Tên trường dữ liệu */
102
+ field: string;
103
+ /** Danh sách cột của bảng */
104
+ columns: IFPrintDocumentSetupColumn[];
105
+ /** Tiêu đề hiển thị của bảng */
106
+ headerText: string;
107
+ }
108
+ /**
109
+ * Cấu hình kiểu dữ liệu cho nội dung
110
+ */
111
+ interface IFDataStyleSetting {
112
+ /** Màu chữ */
113
+ color?: string;
114
+ /** Màu nền */
115
+ backgroundColor?: string;
116
+ /** Font chữ */
117
+ fontFamily?: string;
118
+ /** Kích thước chữ */
119
+ fontSize?: number;
120
+ /** In đậm hay không */
121
+ bold?: boolean;
122
+ /** In nghiêng hay không */
123
+ italic?: boolean;
124
+ /** Gạch chân hay không */
125
+ underline?: boolean;
126
+ }
127
+ /**
128
+ * Cấu hình của tài liệu in
129
+ */
130
+ interface IFPrintDocumentSetting {
131
+ /** Cấu hình trang in */
132
+ pageSetting: PageSetting;
133
+ /** Kiểu dáng chung */
134
+ style: IFDataStyleSetting;
135
+ /** Bố cục của tài liệu (mảng 2 chiều) */
136
+ layout: IFPrintDocumentLayout[][];
137
+ }
138
+ /**
139
+ * Định nghĩa bố cục của tài liệu in
140
+ */
141
+ interface IFPrintDocumentLayout {
142
+ /** ID của bố cục (tùy chọn) */
143
+ id?: string;
144
+ /** Số hàng trong bố cục */
145
+ rows?: number;
146
+ /** Độ rộng phần tử trong bố cục */
147
+ width: number;
148
+ /** Loại nội dung (bảng, chữ ký, nội dung) */
149
+ type?: "table" | "signature" | "content";
150
+ /** Căn chỉnh vị trí */
151
+ align?: ITextAlign;
152
+ /** Đường viền */
153
+ border?: IBorder;
154
+ /** Các cột con (nếu có) */
155
+ children?: IFPrintDocumentSetupColumn[][];
156
+ /** Định nghĩa bảng (nếu type là 'table') */
157
+ table?: IFPrintDocumentSetupTable;
158
+ /** Định nghĩa chữ ký (nếu type là 'signature') */
159
+ signature?: IFPrintDocumentSetupSignature;
160
+ }
161
+ /**
162
+ * Cấu hình bảng trong tài liệu in
163
+ */
164
+ interface IFPrintDocumentSetupTable {
165
+ /** Danh sách cột trong bảng */
166
+ columns: IFPrintDocumentSetupColumn[];
167
+ /** Cấu hình kiểu dữ liệu cho header */
168
+ header: IFDataStyleSetting;
169
+ /** Cấu hình kiểu dữ liệu cho nội dung */
170
+ content: IFDataStyleSetting;
171
+ /** Cấu hình kiểu dữ liệu cho tổng kết */
172
+ summary: IFDataStyleSetting;
173
+ /** Text hàng tổng */
174
+ headerSum?: string;
175
+ /** Tên trường dữ liệu chính */
176
+ field: string;
177
+ /** Danh sách trường cần tính tổng */
178
+ fieldSums: string[];
179
+ /** Có phải bảng tổng không */
180
+ isTotalTable: boolean;
181
+ /** Có hàng mẫu hay không*/
182
+ haveSampleRow?: boolean;
183
+ /** Các trường dùng để tính tổng bảng */
184
+ fieldTotalTable: string[];
185
+ }
186
+ /**
187
+ * Cấu hình hình ảnh trong tài liệu in
188
+ */
189
+ interface IFPrintDocumentSetupImage {
190
+ /** Chiều cao ảnh */
191
+ height: number;
192
+ /** Chiều rộng ảnh */
193
+ width: number;
194
+ /** Khoảng cách từ lề trái (tùy chọn) */
195
+ left?: number;
196
+ /** Khoảng cách từ lề trên (tùy chọn) */
197
+ top?: number;
198
+ /** Ảnh nằm dưới chữ hay không */
199
+ behindText?: boolean;
200
+ /** Đường dẫn ảnh */
201
+ url: string;
202
+ }
203
+ /**
204
+ * Cấu hình một cột trong bảng hoặc nội dung tài liệu in
205
+ */
206
+ interface IFPrintDocumentSetupColumn {
207
+ /** ID của cột (tùy chọn) */
208
+ id?: string;
209
+ /** Tiêu đề hiển thị của cột */
210
+ headerText: string;
211
+ /** Nội dung hiển thị ở header */
212
+ headerDisplay?: string;
213
+ /** Tên trường dữ liệu tương ứng */
214
+ field?: string;
215
+ /** Loại dữ liệu của cột */
216
+ type?: "text" | "template" | "image" | "data" | "blank";
217
+ /** Kiểu dữ liệu (số, ngày, chuỗi) */
218
+ dataType?: "number" | "date" | "string" | "QrCode" | "BarCode";
219
+ /** Định dạng hiển thị dữ liệu */
220
+ format?: string;
221
+ /** Độ rộng của cột */
222
+ width?: number;
223
+ /** Chiều cao của cột (tính theo hàng) */
224
+ rows?: number;
225
+ /** Số phần thập phân (nếu là số) */
226
+ fraction?: number;
227
+ /** Cấu hình kiểu dáng của cột */
228
+ style?: IFDataStyleSetting;
229
+ /** Cấu hình ảnh (nếu type là 'image') */
230
+ imageSetting?: IFPrintDocumentSetupImage;
231
+ /** Căn chỉnh tiêu đề */
232
+ headerAlign?: "left" | "right" | "center";
233
+ /** Các cột con (chỉ dùng cho bảng và dữ liệu text có chứa dữ liệu nhiều trường) */
234
+ children?: IFPrintDocumentSetupColumn[];
235
+ /** Gộp cột (chỉ dùng cho bảng) */
236
+ colspan?: number;
237
+ /** Gộp hàng (chỉ dùng cho bảng) */
238
+ rowspan?: number;
239
+ }
240
+ /**
241
+ * Cấu hình trang in
242
+ */
243
+ interface PageSetting {
244
+ /** Lề trên */
245
+ marginTop: number;
246
+ /** Lề dưới */
247
+ marginBottom: number;
248
+ /** Lề trái */
249
+ marginLeft: number;
250
+ /** Lề phải */
251
+ marginRight: number;
252
+ /** Màu nền trang */
253
+ background?: string;
254
+ /** Kích thước trang */
255
+ pageSize?: "A4" | "A4R" | "A3" | "A3R" | "A5" | "A5R";
256
+ /** Độ trong suốt của trang */
257
+ opacity?: number;
258
+ /** Khoảng cách giữa các phần trong trang */
259
+ spaceLayout?: number;
260
+ /** Danh sách hình ảnh trong trang */
261
+ images?: IFPrintDocumentSetupImage[];
262
+ }
263
+ /**
264
+ * Cấu hình chữ ký trong tài liệu in
265
+ */
266
+ interface IFPrintDocumentSetupSignature {
267
+ /** Cấu hình chữ ký */
268
+ setting: IFDataSetupSignature;
269
+ /** Kiểu dáng chữ ký */
270
+ style?: IFDataStyleSetting;
271
+ }
272
+ interface IFPrintDocOrganizationApi {
273
+ id: string;
274
+ organization: string;
275
+ setting?: IFPrintDocumentSetting;
276
+ file?: IFPrintDocFile;
277
+ data: DataRecord[];
278
+ typePage: string;
279
+ }
280
+ /**
281
+ * API tài liệu in
282
+ */
283
+ interface IFPrintDocumentApi {
284
+ /** Tổ chức sử dụng tài liệu này */
285
+ organization: IFOrganization;
286
+ /** Cấu hình tài liệu */
287
+ setting?: IFPrintDocumentSetting;
288
+ /** Cấu hình tài liệu in bằng file*/
289
+ file?: IFPrintDocFile;
290
+ /** Loại trang */
291
+ typePage?: string;
292
+ /** dữ liệu in */
293
+ data: DataRecord[];
294
+ /** Danh sách trường dữ liệu (tùy chọn) */
295
+ dataFields?: IFPrintDocumentSetupColumn[];
296
+ /** Danh sách bảng dữ liệu (tùy chọn) */
297
+ tableFields?: IFPrintDocumentTableField[];
298
+ }
299
+ /**
300
+ * Cấu hình chữ ký trong tài liệu in
301
+ */
302
+ interface IFDataSetupSignature {
303
+ /** Tiêu đề chữ ký */
304
+ title: string;
305
+ /** Danh sách chữ ký chi tiết */
306
+ detail: IFDataSetupSignatureDetail[];
307
+ /** In tên người ký lên chứng từ, báo cáo */
308
+ reportSigning?: number;
309
+ /** Lấy tên người lập biểu theo tài khoản đăng nhập */
310
+ loginSigning?: number;
311
+ }
312
+ /**
313
+ * Chi tiết của một chữ ký
314
+ */
315
+ interface IFDataSetupSignatureDetail {
316
+ /** ID chữ ký (tùy chọn) */
317
+ id?: string;
318
+ /** Vị trí chữ ký */
319
+ position: string;
320
+ /** Tiêu đề chữ ký */
321
+ title?: string;
322
+ /** Tên người ký */
323
+ name?: string;
324
+ /** Mã chữ ký / trường dữ liệu*/
325
+ code: string;
326
+ /** Là chữ ký từ dữ liệu phiếu */
327
+ isSignForm?: boolean;
328
+ }
329
+
330
+ type IFieldConfig = {
331
+ name: any;
332
+ label: any;
333
+ type: 'select';
334
+ options: any[];
335
+ } | {
336
+ name: any;
337
+ label: any;
338
+ type?: 'string' | undefined;
339
+ options?: never;
340
+ };
341
+
342
+ type IFActionPrint = {
343
+ /** Điều kiện hiển thị*/
344
+ condition?: {
345
+ /** Dư liệu dòng*/
346
+ rowData: any;
347
+ /** Danh sách điều kiện hiển thị*/
348
+ listCondition: IFieldConfig[];
349
+ };
350
+ /** Kích thước của cửa sổ (window size), có thể dùng để xác định layout in */
351
+ windowSize: any;
352
+ /** Tên mẫu in mặc định */
353
+ defaultNameTemplate: string;
354
+ /** Thuộc tính có lấy dữ liệu ban đầu khi khỏi tạo không?*/
355
+ isLoadOnInit?: boolean;
356
+ /** Thuộc tính diable in*/
357
+ isDisabled?: boolean;
358
+ /** Có hiện tên hay không */
359
+ showTitle?: boolean;
360
+ /** Tổ chức, dùng để xác định dữ liệu liên quan khi in */
361
+ organization: IFOrganization;
362
+ /** Cấu hình chữ ký trong tài liệu in */
363
+ signatures?: IFDataSetupSignature;
364
+ /** Cấu hình format số trong tài liệu in */
365
+ formatNumber: IFNumberFormat;
366
+ /** Danh sách tùy chọn kiểu in mặc định */
367
+ defaultOptionTypePrint: IFPrintDocument[];
368
+ /** Url xem PDF */
369
+ DOCUMENT_URL_VIEW: string;
370
+ /** Url cnd*/
371
+ CDN_URL_VIEW: string;
372
+ containerDropDown?: string | HTMLElement | React.RefObject<HTMLElement> | undefined;
373
+ /**
374
+ * API lấy danh sách cấu hình hộp cài đặt chung
375
+ * @param params - Tham số truyền lên API
376
+ */
377
+ getListBoxGeneralSettingApi: (params: any) => Promise<any>;
378
+ /**
379
+ * API cập nhật cấu hình chung
380
+ * @param params - Tham số cập nhật
381
+ */
382
+ updateGeneralSettingApi: (params: any) => Promise<any>;
383
+ /**
384
+ * Hàm lấy thông tin lọc in hàng loạt
385
+ * @param params - Tham số lọc, phân trang
386
+ * @returns Promise trả về dữ liệu
387
+ */
388
+ handleFilterPrint?: (data: any) => string;
389
+ /**
390
+ * API lấy dữ liệu phân trang
391
+ * @param params - Tham số lọc, phân trang
392
+ * @returns Promise trả về dữ liệu
393
+ */
394
+ getPagingDataApi?: (params: any) => Promise<any>;
395
+ /**
396
+ * API upload file
397
+ * @param params - Dữ liệu file cần upload
398
+ * @returns Promise trả về kết quả upload
399
+ */
400
+ uploadFileApi: (params: any) => Promise<any>;
401
+ /**
402
+ * API thực hiện in
403
+ * @param params - Tham số cấu hình in
404
+ * @returns Promise trả về kết quả in
405
+ */
406
+ exportApi: (params: IFPrintDocumentApi) => Promise<any>;
407
+ /**
408
+ * API xuất file sau khi merge dữ liệu
409
+ * @param params - Tham số cấu hình merge
410
+ * @returns Promise trả về kết quả file
411
+ */
412
+ printApi: (params: IFPrintDocumentApi) => Promise<any>;
413
+ /**
414
+ * Thực hiện lấy dữ liệu cần in
415
+ * @param type - Loại mẫu in
416
+ * @returns Promise trả về dữ liệu cần in
417
+ */
418
+ handlGetDataPrint: (type: string, name: string) => Promise<any>;
419
+ /**
420
+ * API Xóa cấu hình in
421
+ * @param params - id cấu hình in
422
+ * @returns Promise trả về kết quả in
423
+ */
424
+ deleteGeneralSettingApi: (params: string) => Promise<any>;
425
+ /**
426
+ * Tùy chọn thay thế
427
+ */
428
+ optionalFields?: {
429
+ field: string;
430
+ label: string;
431
+ isClearable?: boolean;
432
+ loadOptions?: any;
433
+ columns?: IFColumnSelectTable[];
434
+ fieldLabel?: string;
435
+ fieldValue?: string;
436
+ options: any[];
437
+ callback: (val: any, item: any) => void;
438
+ }[];
439
+ };
440
+ type IFPrintComponentRef = {
441
+ getListTemplate: any;
442
+ };
443
+ declare const PrintComponent: react.ForwardRefExoticComponent<IFActionPrint & react.RefAttributes<IFPrintComponentRef>>;
444
+
445
+ export { DataRecord, IBorder, IColumnType, IFActionPrint, IFDataGeneralSetting, IFDataSetupSignature, IFDataSetupSignatureDetail, IFDataStyleSetting, IFNumberFormat, IFOptionTypePrint, IFOrganization, IFPrintComponentRef, IFPrintDocFile, IFPrintDocOrganizationApi, IFPrintDocument, IFPrintDocumentApi, IFPrintDocumentLayout, IFPrintDocumentLayoutDisplay, IFPrintDocumentSetting, IFPrintDocumentSetupColumn, IFPrintDocumentSetupImage, IFPrintDocumentSetupSignature, IFPrintDocumentSetupTable, IFPrintDocumentTableField, ITextAlign, ITypeEdit, PageSetting, PageSize, PageSizeKey, TemplateApiResponse, TemplateBreakpoint, TemplateGridLayouts, UploadFileApi, PrintComponent as default };