aq-fe-framework 0.1.81 → 0.1.83

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.
@@ -1,4 +1,4 @@
1
- // src/utils/converter.ts
1
+ // src/utils/utils_converter.ts
2
2
  var utils_converter_getLabelByValue = (data, value) => {
3
3
  const numericValue = Number(value);
4
4
  return data[numericValue] || "Kh\xF4ng x\xE1c \u0111\u1ECBnh";
@@ -22,7 +22,7 @@ function utils_converter_enumToSelectOptions(enumObject) {
22
22
  return result;
23
23
  }
24
24
 
25
- // src/utils/date.ts
25
+ // src/utils/utils_date.ts
26
26
  function U0DateToDDMMYYYString(date) {
27
27
  if (!(date instanceof Date) || isNaN(date.getTime())) return "";
28
28
  const day = String(date.getDate()).padStart(2, "0");
@@ -47,8 +47,11 @@ function utils_date_formatToDateTimeStartEnd(startDate, endDate) {
47
47
  return `${startday}/${startmonth}/${startyear} [${starthour}:${startminute} - ${endhour}:${endminuate}]`;
48
48
  }
49
49
 
50
- // src/utils/excel.ts
50
+ // src/utils/utils_excel.ts
51
51
  import saveAs from "file-saver";
52
+ function getValueByPath(obj, path) {
53
+ return path.split(".").reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
54
+ }
52
55
  async function utils_excel_exportExcel({
53
56
  workbook,
54
57
  sheetName,
@@ -56,72 +59,63 @@ async function utils_excel_exportExcel({
56
59
  config
57
60
  }) {
58
61
  const sheet = workbook.addWorksheet(sheetName);
59
- const fieldNames = config.map((item) => String(item.fieldKey));
62
+ const fieldKeys = config.map((item) => String(item.fieldKey));
60
63
  const headerMappings = {};
61
64
  const markedColumns = [];
62
65
  config.forEach((item) => {
63
66
  const fieldKeyStr = String(item.fieldKey);
64
67
  headerMappings[fieldKeyStr] = item.fieldName;
65
- if (item.isRequired) {
66
- markedColumns.push(fieldKeyStr);
67
- }
68
+ if (item.isRequired) markedColumns.push(fieldKeyStr);
68
69
  });
69
- const columns = fieldNames.map((fieldName) => {
70
- return {
71
- key: fieldName,
72
- width: 20
73
- };
74
- });
75
- sheet.columns = columns;
70
+ sheet.columns = fieldKeys.map((fieldKey) => ({
71
+ key: fieldKey,
72
+ width: 20
73
+ }));
76
74
  const displayRow = sheet.addRow(
77
- fieldNames.map((fieldName) => {
78
- const displayName = headerMappings[fieldName] || fieldName;
79
- return markedColumns.includes(fieldName) ? `${displayName} *` : displayName;
80
- })
75
+ fieldKeys.map(
76
+ (fieldKey) => markedColumns.includes(fieldKey) ? `${headerMappings[fieldKey]} *` : headerMappings[fieldKey] || fieldKey
77
+ )
81
78
  );
82
- const keyRow = sheet.addRow(fieldNames);
79
+ const keyRow = sheet.addRow(fieldKeys);
83
80
  data.forEach((item) => {
84
81
  const rowData = {};
85
- fieldNames.forEach((field) => {
86
- rowData[field] = item[field];
82
+ fieldKeys.forEach((fieldKey) => {
83
+ rowData[fieldKey] = getValueByPath(item, fieldKey);
87
84
  });
88
85
  sheet.addRow(rowData);
89
86
  });
90
- for (let i = 1; i <= fieldNames.length; i++) {
87
+ for (let i = 1; i <= fieldKeys.length; i++) {
91
88
  const cell = displayRow.getCell(i);
92
89
  cell.font = { bold: true };
93
90
  cell.fill = {
94
91
  type: "pattern",
95
92
  pattern: "solid",
96
93
  fgColor: { argb: "FFE0E0E0" }
97
- // Light gray background
98
94
  };
99
95
  }
100
- for (let i = 1; i <= fieldNames.length; i++) {
96
+ for (let i = 1; i <= fieldKeys.length; i++) {
101
97
  const cell = keyRow.getCell(i);
102
98
  cell.font = { italic: true };
103
99
  cell.fill = {
104
100
  type: "pattern",
105
101
  pattern: "solid",
106
102
  fgColor: { argb: "FFF0F0F0" }
107
- // Lighter gray background
108
103
  };
109
104
  }
110
105
  if (markedColumns.length > 0) {
111
- for (let i = 1; i <= fieldNames.length; i++) {
106
+ for (let i = 1; i <= fieldKeys.length; i++) {
112
107
  const cell = displayRow.getCell(i);
113
108
  const text = cell.value;
114
109
  if (typeof text === "string" && text.endsWith(" *")) {
115
110
  cell.value = {
116
111
  richText: [
117
112
  {
118
- text: text.substring(0, text.length - 2),
113
+ text: text.slice(0, -2),
119
114
  font: { bold: true }
120
115
  },
121
116
  {
122
117
  text: " *",
123
118
  font: { bold: true, color: { argb: "FFFF0000" } }
124
- // Red color
125
119
  }
126
120
  ]
127
121
  };
@@ -135,11 +129,13 @@ async function utils_excel_download({
135
129
  name
136
130
  }) {
137
131
  const buffer = await workbook.xlsx.writeBuffer();
138
- const blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
132
+ const blob = new Blob([buffer], {
133
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
134
+ });
139
135
  saveAs(blob, name);
140
136
  }
141
137
 
142
- // src/utils/file.ts
138
+ // src/utils/utils_file.ts
143
139
  import Docxtemplater from "docxtemplater";
144
140
  import { saveAs as saveAs2 } from "file-saver";
145
141
  import PizZip from "pizzip";
@@ -175,7 +171,7 @@ async function utils_file_docxtemplaterDownload({
175
171
  saveAs2(buffer, fileName || "output.docx");
176
172
  }
177
173
 
178
- // src/utils/notification.ts
174
+ // src/utils/utils_notification.ts
179
175
  import { notifications } from "@mantine/notifications";
180
176
  function utils_notification_show({ crudType = "create", message, color }) {
181
177
  if (crudType == "create") {
@@ -214,7 +210,7 @@ function utils_notification_show({ crudType = "create", message, color }) {
214
210
  }
215
211
  }
216
212
 
217
- // src/utils/pdf.ts
213
+ // src/utils/utils_pdf.ts
218
214
  import axios from "axios";
219
215
  async function utils_pdf_download(url) {
220
216
  try {
@@ -233,7 +229,7 @@ async function utils_pdf_download(url) {
233
229
  }
234
230
  }
235
231
 
236
- // src/utils/time.ts
232
+ // src/utils/utils_time.ts
237
233
  var utils_time_convertTimeStringToSeconds = (time) => {
238
234
  const [hours, minutes, seconds] = time.split(":").map(Number);
239
235
  return hours * 3600 + minutes * 60 + seconds;
@@ -249,7 +245,7 @@ var utils_time_getCurrentTimeString = () => {
249
245
  return `${hours}:${minutes}:${seconds}`;
250
246
  };
251
247
 
252
- // src/utils/validateForm.ts
248
+ // src/utils/utils_validateForm.ts
253
249
  import { isNotEmpty } from "@mantine/form";
254
250
  function U0MyValidateEmpty(message) {
255
251
  return isNotEmpty(message ? message : "Kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng");
@@ -9,7 +9,7 @@ import {
9
9
  utils_file_fileToAQDocumentType,
10
10
  utils_notification_show,
11
11
  utils_pdf_download
12
- } from "./chunk-42OQXQR5.mjs";
12
+ } from "./chunk-BNC4S63Y.mjs";
13
13
  import {
14
14
  __objRest,
15
15
  __spreadProps,
@@ -53,13 +53,28 @@ baseAxios.interceptors.request.use(
53
53
  var baseAxios_default = baseAxios;
54
54
 
55
55
  // src/components/Buttons/ButtonViewPDF/MyButtonViewPDF.tsx
56
- import { ActionIcon, Button, Group, LoadingOverlay, Modal, Paper, Text, Tooltip } from "@mantine/core";
56
+ import {
57
+ ActionIcon,
58
+ Button,
59
+ Group,
60
+ LoadingOverlay,
61
+ Modal,
62
+ Paper,
63
+ Text,
64
+ Tooltip
65
+ } from "@mantine/core";
57
66
  import { useDisclosure } from "@mantine/hooks";
58
67
  import { IconLivePhoto, IconMaximize, IconMinimize } from "@tabler/icons-react";
59
68
  import { useQuery } from "@tanstack/react-query";
60
69
  import { useState } from "react";
61
70
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
62
- function MyButtonViewPDF({ id, modalSize = "80%", label = "Xem file", src = "https://datafiles.chinhphu.vn/cpp/files/vbpq/2016/07/85.signed.pdf", isActionIcon = false }) {
71
+ function MyButtonViewPDF({
72
+ id,
73
+ modalSize = "80%",
74
+ label = "Xem file",
75
+ src = "https://datafiles.chinhphu.vn/cpp/files/vbpq/2016/07/85.signed.pdf",
76
+ isActionIcon = false
77
+ }) {
63
78
  var _a, _b;
64
79
  const disc = useDisclosure(false);
65
80
  const fullScreen = useState(false);
@@ -80,9 +95,17 @@ function MyButtonViewPDF({ id, modalSize = "80%", label = "Xem file", src = "htt
80
95
  },
81
96
  children: /* @__PURE__ */ jsx2(IconLivePhoto, {})
82
97
  }
83
- ) : /* @__PURE__ */ jsx2(Button, { color: "cyan", onClick: () => {
84
- disc[1].open();
85
- }, leftSection: /* @__PURE__ */ jsx2(IconLivePhoto, {}), children: label }) }),
98
+ ) : /* @__PURE__ */ jsx2(
99
+ Button,
100
+ {
101
+ color: "cyan",
102
+ onClick: () => {
103
+ disc[1].open();
104
+ },
105
+ leftSection: /* @__PURE__ */ jsx2(IconLivePhoto, {}),
106
+ children: label
107
+ }
108
+ ) }),
86
109
  /* @__PURE__ */ jsx2(
87
110
  Modal,
88
111
  {
@@ -113,22 +136,22 @@ function MyButtonViewPDF({ id, modalSize = "80%", label = "Xem file", src = "htt
113
136
  )
114
137
  ] }),
115
138
  children: /* @__PURE__ */ jsxs(Paper, { h: hSize[0], p: "lg", pos: "relative", children: [
116
- /* @__PURE__ */ jsx2(LoadingOverlay, { visible: query.isLoading, zIndex: 1e3, overlayProps: { radius: "sm", blur: 2 } }),
117
- query.data ? /* @__PURE__ */ jsx2(
118
- "iframe",
139
+ /* @__PURE__ */ jsx2(
140
+ LoadingOverlay,
119
141
  {
120
- src: `data:application/pdf;base64, ${(_b = (_a = query.data) == null ? void 0 : _a.fileDetail) == null ? void 0 : _b.fileBase64String}`,
121
- width: "100%",
122
- height: "100%"
142
+ visible: query.isLoading,
143
+ zIndex: 1e3,
144
+ overlayProps: { radius: "sm", blur: 2 }
123
145
  }
124
- ) : /* @__PURE__ */ jsx2(
146
+ ),
147
+ query.data ? /* @__PURE__ */ jsx2(
125
148
  "iframe",
126
149
  {
127
- src,
150
+ src: `data:application/pdf;base64, ${(_b = (_a = query.data) == null ? void 0 : _a.fileDetail) == null ? void 0 : _b.fileBase64String}`,
128
151
  width: "100%",
129
152
  height: "100%"
130
153
  }
131
- )
154
+ ) : /* @__PURE__ */ jsx2("iframe", { src, width: "100%", height: "100%" })
132
155
  ] })
133
156
  }
134
157
  )
@@ -815,7 +838,13 @@ import { IconLivePhoto as IconLivePhoto2, IconMaximize as IconMaximize2, IconMin
815
838
  import { useState as useState4 } from "react";
816
839
  import { Fragment as Fragment5, jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
817
840
  function MyActionIconViewPDF(_a) {
818
- var _b = _a, { modalSize = "80%", pdfLink = "https://datafiles.chinhphu.vn/cpp/files/vbpq/2021/07/17-bgd.signed.pdf" } = _b, rest = __objRest(_b, ["modalSize", "pdfLink"]);
841
+ var _b = _a, {
842
+ modalSize = "80%",
843
+ pdfLink = "https://datafiles.chinhphu.vn/cpp/files/vbpq/2021/07/17-bgd.signed.pdf"
844
+ } = _b, rest = __objRest(_b, [
845
+ "modalSize",
846
+ "pdfLink"
847
+ ]);
819
848
  const disc = useDisclosure5(false);
820
849
  const fullScreen = useState4(false);
821
850
  const hSize = useState4("80vh");
@@ -3,7 +3,7 @@ import react__default, { ReactNode, ComponentProps } from 'react';
3
3
  import { MantineSize, ActionIconProps, ButtonProps, useModalsStack, CheckboxProps, SelectProps, NumberFormatterProps, FieldsetProps, FileInputProps, NumberInputProps, TextareaProps, TextInputProps, ContainerProps, FlexProps, GroupProps, TypographyStylesProviderProps, TabsProps, SkeletonProps } from '@mantine/core';
4
4
  import { useDisclosure, useListState } from '@mantine/hooks';
5
5
  import { UseFormReturnType, useForm } from '@mantine/form';
6
- import { I as IUtils_Excel_ColumnConfig } from '../excel---d-HDs7.mjs';
6
+ import { I as IUtils_Excel_ColumnConfig } from '../utils_excel-CP9z_HOI.mjs';
7
7
  import { MRT_ColumnDef, MRT_RowData, MRT_TableOptions, MRT_TableInstance } from 'mantine-react-table';
8
8
  import { ConfigOptions } from 'export-to-csv';
9
9
  import { DateInputProps } from '@mantine/dates';
@@ -255,7 +255,7 @@ interface IMyButtonViewPDF {
255
255
  src?: string;
256
256
  isActionIcon?: boolean;
257
257
  }
258
- declare function MyButtonViewPDF({ id, modalSize, label, src, isActionIcon }: IMyButtonViewPDF): react_jsx_runtime.JSX.Element;
258
+ declare function MyButtonViewPDF({ id, modalSize, label, src, isActionIcon, }: IMyButtonViewPDF): react_jsx_runtime.JSX.Element;
259
259
 
260
260
  declare function MyCalendar(): react_jsx_runtime.JSX.Element;
261
261
 
@@ -62,9 +62,9 @@ import {
62
62
  useHeaderMegaMenuStore,
63
63
  useS_ButtonImport,
64
64
  utils_layout_getItemsWithoutLinks
65
- } from "../chunk-G75BBOMI.mjs";
65
+ } from "../chunk-WITBUG5F.mjs";
66
66
  import "../chunk-AL73DX37.mjs";
67
- import "../chunk-42OQXQR5.mjs";
67
+ import "../chunk-BNC4S63Y.mjs";
68
68
  import "../chunk-FWCSY2DS.mjs";
69
69
  export {
70
70
  AQButtonCreateByImportFile,
@@ -57,9 +57,9 @@ import {
57
57
  useS_authenticate,
58
58
  useS_core83092,
59
59
  utils_core83092_mergePage
60
- } from "../chunk-G75BBOMI.mjs";
60
+ } from "../chunk-WITBUG5F.mjs";
61
61
  import "../chunk-AL73DX37.mjs";
62
- import "../chunk-42OQXQR5.mjs";
62
+ import "../chunk-BNC4S63Y.mjs";
63
63
  import "../chunk-FWCSY2DS.mjs";
64
64
  export {
65
65
  F_authenticate_Login,
@@ -1,4 +1,4 @@
1
- export { I as IUtils_Excel_ColumnConfig, a as utils_excel_download, u as utils_excel_exportExcel } from '../excel---d-HDs7.mjs';
1
+ export { I as IUtils_Excel_ColumnConfig, a as utils_excel_download, u as utils_excel_exportExcel } from '../utils_excel-CP9z_HOI.mjs';
2
2
  import { DefaultMantineColor } from '@mantine/core';
3
3
  import * as react from 'react';
4
4
  import 'exceljs';
@@ -15,7 +15,7 @@ import {
15
15
  utils_pdf_download,
16
16
  utils_time_convertTimeStringToSeconds,
17
17
  utils_time_getCurrentTimeString
18
- } from "../chunk-42OQXQR5.mjs";
18
+ } from "../chunk-BNC4S63Y.mjs";
19
19
  import "../chunk-FWCSY2DS.mjs";
20
20
  export {
21
21
  U0DateToDDMMYYYString,
@@ -1,7 +1,7 @@
1
1
  import ExcelJS from 'exceljs';
2
2
 
3
3
  interface IUtils_Excel_ColumnConfig<T> {
4
- fieldKey: keyof T;
4
+ fieldKey: keyof T | string;
5
5
  fieldName: string;
6
6
  isRequired?: boolean;
7
7
  }
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "types": "./dist/modules-features/index.d.mts"
19
19
  }
20
20
  },
21
- "version": "0.1.81",
21
+ "version": "0.1.83",
22
22
  "private": false,
23
23
  "files": [
24
24
  "dist"