aq-fe-framework 0.1.39 → 0.1.41

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.
@@ -3,10 +3,6 @@ import { DefaultMantineColor } from '@mantine/core';
3
3
  import * as react from 'react';
4
4
  import 'exceljs';
5
5
 
6
- declare const utils_converter_enumToOptions: (enumObj: object) => {
7
- value: string;
8
- label: string;
9
- }[];
10
6
  declare const utils_converter_getLabelByValue: (data: Record<number, string>, value?: number | string) => string;
11
7
  declare const utils_converter_getKeyByValue: <K extends string | number, V>(obj: Record<K, V>, value: V) => K | undefined;
12
8
  /**
@@ -44,4 +40,4 @@ declare const utils_time_getCurrentTimeString: () => string;
44
40
  declare function U0MyValidateEmpty(message?: string): (value: unknown) => string | number | bigint | true | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | null;
45
41
  declare function U0MyValidateEmail(value?: string): "Email không đúng định dạng" | null;
46
42
 
47
- export { U0DateToDDMMYYYString, U0MyValidateEmail, U0MyValidateEmpty, utils_converter_enumToOptions, utils_converter_enumToSelectOptions, utils_converter_getKeyByValue, utils_converter_getLabelByValue, utils_date_dateToDDMMYYYString, utils_file_docxtemplaterDownload, utils_file_fileToAQDocumentType, utils_notification_show, utils_pdf_download, utils_time_convertTimeStringToSeconds, utils_time_getCurrentTimeString };
43
+ export { U0DateToDDMMYYYString, U0MyValidateEmail, U0MyValidateEmpty, utils_converter_enumToSelectOptions, utils_converter_getKeyByValue, utils_converter_getLabelByValue, utils_date_dateToDDMMYYYString, utils_file_docxtemplaterDownload, utils_file_fileToAQDocumentType, utils_notification_show, utils_pdf_download, utils_time_convertTimeStringToSeconds, utils_time_getCurrentTimeString };
@@ -2,154 +2,25 @@ import {
2
2
  U0DateToDDMMYYYString,
3
3
  U0MyValidateEmail,
4
4
  U0MyValidateEmpty,
5
+ utils_converter_enumToSelectOptions,
6
+ utils_converter_getKeyByValue,
7
+ utils_converter_getLabelByValue,
5
8
  utils_date_dateToDDMMYYYString,
9
+ utils_excel_download,
10
+ utils_excel_exportExcel,
6
11
  utils_file_docxtemplaterDownload,
7
- utils_file_fileToAQDocumentType
8
- } from "../chunk-GHGYRQUR.mjs";
12
+ utils_file_fileToAQDocumentType,
13
+ utils_time_convertTimeStringToSeconds,
14
+ utils_time_getCurrentTimeString
15
+ } from "../chunk-2MRECBKN.mjs";
9
16
  import {
10
17
  utils_notification_show,
11
18
  utils_pdf_download
12
19
  } from "../chunk-ZEQATKHS.mjs";
13
-
14
- // src/utils/converter.ts
15
- var utils_converter_enumToOptions = (enumObj) => {
16
- return Object.entries(enumObj).filter(([key]) => isNaN(Number(key))).map(([label, value]) => ({ value: String(value), label }));
17
- };
18
- var utils_converter_getLabelByValue = (data, value) => {
19
- const numericValue = Number(value);
20
- return data[numericValue] || "Kh\xF4ng x\xE1c \u0111\u1ECBnh";
21
- };
22
- var utils_converter_getKeyByValue = (obj, value) => {
23
- var _a;
24
- return (_a = Object.entries(obj).find(([_, v]) => v === value)) == null ? void 0 : _a[0];
25
- };
26
- function utils_converter_enumToSelectOptions(enumObject) {
27
- const result = [];
28
- const numericEnumKeys = Object.keys(enumObject).filter((key) => isNaN(Number(key)));
29
- for (const key of numericEnumKeys) {
30
- const enumValue = enumObject[key];
31
- if (typeof enumValue === "number") {
32
- result.push({
33
- value: String(enumValue),
34
- label: key
35
- });
36
- }
37
- }
38
- return result;
39
- }
40
-
41
- // src/utils/excel.ts
42
- import saveAs from "file-saver";
43
- async function utils_excel_exportExcel({
44
- workbook,
45
- sheetName,
46
- data,
47
- config
48
- }) {
49
- const sheet = workbook.addWorksheet(sheetName);
50
- const fieldNames = config.map((item) => String(item.fieldKey));
51
- const headerMappings = {};
52
- const markedColumns = [];
53
- config.forEach((item) => {
54
- const fieldKeyStr = String(item.fieldKey);
55
- headerMappings[fieldKeyStr] = item.fieldName;
56
- if (item.isRequired) {
57
- markedColumns.push(fieldKeyStr);
58
- }
59
- });
60
- const columns = fieldNames.map((fieldName) => {
61
- return {
62
- key: fieldName,
63
- width: 20
64
- };
65
- });
66
- sheet.columns = columns;
67
- const displayRow = sheet.addRow(
68
- fieldNames.map((fieldName) => {
69
- const displayName = headerMappings[fieldName] || fieldName;
70
- return markedColumns.includes(fieldName) ? `${displayName} *` : displayName;
71
- })
72
- );
73
- const keyRow = sheet.addRow(fieldNames);
74
- data.forEach((item) => {
75
- const rowData = {};
76
- fieldNames.forEach((field) => {
77
- rowData[field] = item[field];
78
- });
79
- sheet.addRow(rowData);
80
- });
81
- for (let i = 1; i <= fieldNames.length; i++) {
82
- const cell = displayRow.getCell(i);
83
- cell.font = { bold: true };
84
- cell.fill = {
85
- type: "pattern",
86
- pattern: "solid",
87
- fgColor: { argb: "FFE0E0E0" }
88
- // Light gray background
89
- };
90
- }
91
- for (let i = 1; i <= fieldNames.length; i++) {
92
- const cell = keyRow.getCell(i);
93
- cell.font = { italic: true };
94
- cell.fill = {
95
- type: "pattern",
96
- pattern: "solid",
97
- fgColor: { argb: "FFF0F0F0" }
98
- // Lighter gray background
99
- };
100
- }
101
- if (markedColumns.length > 0) {
102
- for (let i = 1; i <= fieldNames.length; i++) {
103
- const cell = displayRow.getCell(i);
104
- const text = cell.value;
105
- if (typeof text === "string" && text.endsWith(" *")) {
106
- cell.value = {
107
- richText: [
108
- {
109
- text: text.substring(0, text.length - 2),
110
- font: { bold: true }
111
- },
112
- {
113
- text: " *",
114
- font: { bold: true, color: { argb: "FFFF0000" } }
115
- // Red color
116
- }
117
- ]
118
- };
119
- }
120
- }
121
- }
122
- return workbook;
123
- }
124
- async function utils_excel_download({
125
- workbook,
126
- name
127
- }) {
128
- const buffer = await workbook.xlsx.writeBuffer();
129
- const blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
130
- saveAs(blob, name);
131
- }
132
-
133
- // src/utils/time.ts
134
- var utils_time_convertTimeStringToSeconds = (time) => {
135
- const [hours, minutes, seconds] = time.split(":").map(Number);
136
- return hours * 3600 + minutes * 60 + seconds;
137
- };
138
- var utils_time_getCurrentTimeString = () => {
139
- const formatTime = (number) => {
140
- return number < 10 ? "0" + number : number;
141
- };
142
- const now = /* @__PURE__ */ new Date();
143
- const hours = formatTime(now.getHours());
144
- const minutes = formatTime(now.getMinutes());
145
- const seconds = formatTime(now.getSeconds());
146
- return `${hours}:${minutes}:${seconds}`;
147
- };
148
20
  export {
149
21
  U0DateToDDMMYYYString,
150
22
  U0MyValidateEmail,
151
23
  U0MyValidateEmpty,
152
- utils_converter_enumToOptions,
153
24
  utils_converter_enumToSelectOptions,
154
25
  utils_converter_getKeyByValue,
155
26
  utils_converter_getLabelByValue,
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "types": "./dist/modules-features//admin/core/index.d.mts"
19
19
  }
20
20
  },
21
- "version": "0.1.39",
21
+ "version": "0.1.41",
22
22
  "private": false,
23
23
  "files": [
24
24
  "dist"
@@ -1,67 +0,0 @@
1
- // src/utils/date.ts
2
- function U0DateToDDMMYYYString(date) {
3
- const day = String(date.getDate()).padStart(2, "0");
4
- const month = String(date.getMonth() + 1).padStart(2, "0");
5
- const year = date.getFullYear();
6
- return `${day}/${month}/${year}`;
7
- }
8
- function utils_date_dateToDDMMYYYString(date) {
9
- const day = String(date.getDate()).padStart(2, "0");
10
- const month = String(date.getMonth() + 1).padStart(2, "0");
11
- const year = date.getFullYear();
12
- return `${day}/${month}/${year}`;
13
- }
14
-
15
- // src/utils/file.ts
16
- import Docxtemplater from "docxtemplater";
17
- import { saveAs } from "file-saver";
18
- import PizZip from "pizzip";
19
- function utils_file_fileToAQDocumentType(file) {
20
- return new Promise((resolve, reject) => {
21
- const fileReader = new FileReader();
22
- fileReader.onloadend = () => {
23
- const fileName = file.name;
24
- const fileExtension = file.name.split(".").pop();
25
- const fileBase64String = fileReader.result;
26
- resolve({
27
- fileName,
28
- fileExtension,
29
- fileBase64String: fileBase64String.split(",")[1]
30
- // Chỉ lấy phần base64 sau dấu phẩy
31
- });
32
- };
33
- fileReader.onerror = reject;
34
- fileReader.readAsDataURL(file);
35
- });
36
- }
37
- async function utils_file_docxtemplaterDownload({
38
- data,
39
- filePath,
40
- fileName
41
- }) {
42
- const response = await fetch(filePath);
43
- const arrayBuffer = await response.arrayBuffer();
44
- const zip = new PizZip(arrayBuffer);
45
- const doc = new Docxtemplater(zip);
46
- doc.render(data);
47
- const buffer = doc.getZip().generate({ type: "blob" });
48
- saveAs(buffer, fileName || "output.docx");
49
- }
50
-
51
- // src/utils/validateForm.ts
52
- import { isNotEmpty } from "@mantine/form";
53
- function U0MyValidateEmpty(message) {
54
- return isNotEmpty(message ? message : "Kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng");
55
- }
56
- function U0MyValidateEmail(value) {
57
- return /^\S+@\S+$/.test(value) ? null : "Email kh\xF4ng \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng";
58
- }
59
-
60
- export {
61
- U0DateToDDMMYYYString,
62
- utils_date_dateToDDMMYYYString,
63
- utils_file_fileToAQDocumentType,
64
- utils_file_docxtemplaterDownload,
65
- U0MyValidateEmpty,
66
- U0MyValidateEmail
67
- };